Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 ////////////////////////////////////////////// 23 /////////////////////////////////////////////////////////////////////////////// 27 // File: CompositeCalorimeter.cc 24 // File: CompositeCalorimeter.cc 28 // Description: Main function for Geant4 appli 25 // Description: Main function for Geant4 application HCAL Test-BEAM H2-96 29 ////////////////////////////////////////////// 26 /////////////////////////////////////////////////////////////////////////////// 30 27 31 #include "CCalDetectorConstruction.hh" 28 #include "CCalDetectorConstruction.hh" 32 #include "CCalActionInitializer.hh" << 29 #include "CCalEndOfEventAction.hh" >> 30 #include "CCalRunAction.hh" 33 31 34 #include "G4AnalysisManager.hh" << 32 #include "CCalPrimaryGeneratorAction.hh" >> 33 #include "" >> 34 #include "" >> 35 #include "" >> 36 >> 37 #include "G4RunManager.hh" >> 38 #include "G4UIterminal.hh" >> 39 >> 40 #ifdef G4UI_USE_XM >> 41 #include "G4UIXm.hh" >> 42 #endif >> 43 >> 44 #ifdef G4VIS_USE >> 45 #include "CCalVisManager.hh" >> 46 #endif 35 47 36 #include "G4PhysListFactory.hh" << 37 << 38 #include "G4RunManagerFactory.hh" << 39 #include "G4UImanager.hh" << 40 << 41 #include "G4VisExecutive.hh" << 42 << 43 #include "G4UIExecutive.hh" << 44 48 45 int main(int argc,char** argv) { 49 int main(int argc,char** argv) { 46 50 47 G4VisManager *visManager = nullptr; << 51 #ifdef G4VIS_USE >> 52 CCalVisManager *visManager = new CCalVisManager; >> 53 visManager->Initialize(); >> 54 #endif 48 55 49 auto* runManager = G4RunManagerFactory::Crea << 56 G4RunManager * runManager = new G4RunManager; 50 runManager->SetUserInitialization(new CCalDe 57 runManager->SetUserInitialization(new CCalDetectorConstruction); 51 58 52 G4PhysListFactory factory; << 59 //***LOOKHERE*** CHOOSE THE PHYSICS LIST. 53 runManager->SetUserInitialization(factory.Re << 60 // runManager->SetUserInitialization(new LHEP); // LHEP >> 61 runManager->SetUserInitialization(new QGSP); // QGSP >> 62 // runManager->SetUserInitialization(new QGSC); // QGSC >> 63 //***endLOOKHERE*** >> 64 >> 65 //////////////////////////// >> 66 // User action classes. // >> 67 // -------------------- // >> 68 //////////////////////////// >> 69 >> 70 ////////////////////////////////// >> 71 // PRIMARY PARTICLEs GENERATION // >> 72 ////////////////////////////////// >> 73 >> 74 CCalPrimaryGeneratorAction* primaryGenerator = new CCalPrimaryGeneratorAction; >> 75 runManager->SetUserAction(primaryGenerator); >> 76 >> 77 ///////// >> 78 // RUN // >> 79 ///////// >> 80 >> 81 runManager->SetUserAction(new CCalRunAction); >> 82 >> 83 /////////// >> 84 // EVENT // >> 85 /////////// 54 86 55 runManager->SetUserInitialization(new CCalAc << 87 runManager->SetUserAction(new CCalEndOfEventAction(primaryGenerator)); 56 88 57 G4UImanager * UImanager = G4UImanager::GetUI << 89 G4UImanager * UI = G4UImanager::GetUIpointer(); 58 UImanager->ApplyCommand("/CCal/generator/ver << 90 UI->ApplyCommand("/CCal/generator/verbose 2"); 59 UImanager->ApplyCommand("/gun/position -1380 << 91 UI->ApplyCommand("/gun/position -1380. 0. 0. mm"); 60 UImanager->ApplyCommand("/gun/direction 1. 0 << 92 UI->ApplyCommand("/gun/direction 1. 0. 0."); 61 UImanager->ApplyCommand("/gun/energy 100 GeV << 93 UI->ApplyCommand("/gun/energy 100 GeV"); 62 94 >> 95 G4UIsession * session = 0; 63 // Define (G)UI terminal for interactive mod 96 // Define (G)UI terminal for interactive mode 64 if (argc==1) { // No arguments - interactiv << 97 if (argc==1) { 65 98 66 visManager = new G4VisExecutive; << 99 #ifdef G4UI_USE_XM 67 visManager->Initialize(); << 100 session = new G4UIXm(argc,argv); >> 101 #else // G4UIterminal is a (dumb) terminal. >> 102 session = new G4UIterminal; >> 103 #endif 68 104 69 G4UIExecutive* ui = new G4UIExecutive(argc << 70 if (ui->IsGUI()) { << 71 // Customize the menubar with a macro fi << 72 UImanager->ApplyCommand("/control/execut << 73 } << 74 G4cout <<" Run initializing ..."<<G4endl; 105 G4cout <<" Run initializing ..."<<G4endl; 75 UImanager->ApplyCommand("/process/verbose << 106 UI->ApplyCommand("/process/verbose 0"); 76 UImanager->ApplyCommand("/run/verbose 2"); << 107 UI->ApplyCommand("/run/verbose 2"); 77 UImanager->ApplyCommand("/run/initialize") << 108 UI->ApplyCommand("/run/initialize"); 78 << 109 >> 110 #ifdef G4VIS_USE 79 // Create empty scene 111 // Create empty scene 80 G4String visCommand = "/vis/scene/create"; 112 G4String visCommand = "/vis/scene/create"; 81 UImanager->ApplyCommand(visCommand); << 113 UI->ApplyCommand(visCommand); 82 << 114 83 // Choose one default viewer 115 // Choose one default viewer 84 // (the user can always change it later on 116 // (the user can always change it later on) 85 // visCommand = "/vis/open DAWNFILE"; 117 // visCommand = "/vis/open DAWNFILE"; 86 // visCommand = "/vis/open VRML2FILE"; 118 // visCommand = "/vis/open VRML2FILE"; 87 visCommand = "/vis/open OGL"; << 119 visCommand = "/vis/open OGLIX"; 88 UImanager->ApplyCommand(visCommand); << 120 UI->ApplyCommand(visCommand); 89 << 121 90 visCommand = "/vis/viewer/flush"; 122 visCommand = "/vis/viewer/flush"; 91 UImanager->ApplyCommand(visCommand); << 123 UI->ApplyCommand(visCommand); 92 visCommand = "/tracking/storeTrajectory 1" 124 visCommand = "/tracking/storeTrajectory 1"; 93 UImanager->ApplyCommand(visCommand); << 125 UI->ApplyCommand(visCommand); >> 126 #endif 94 127 >> 128 #ifdef G4UI_USE_XM >> 129 // Customize the G4UIXm menubar with a macro file : >> 130 UI->ApplyCommand("/control/execute gui.mac"); >> 131 #else 95 G4cout <<"Now, please, apply beamOn comman 132 G4cout <<"Now, please, apply beamOn command..."<<G4endl; 96 ui->SessionStart(); << 133 #endif 97 delete ui; << 134 >> 135 session->SessionStart(); >> 136 delete session; 98 137 99 } else { 138 } else { 100 139 101 // Batch mode 140 // Batch mode 102 G4String command = "/control/execute "; 141 G4String command = "/control/execute "; 103 G4String fileName = argv[1]; 142 G4String fileName = argv[1]; 104 UImanager->ApplyCommand(command+fileName); << 143 UI->ApplyCommand(command+fileName); >> 144 105 } 145 } 106 146 107 // Complete clean-up << 108 delete runManager; 147 delete runManager; >> 148 >> 149 #ifdef G4VIS_USE 109 delete visManager; 150 delete visManager; >> 151 #endif >> 152 110 return 0; 153 return 0; 111 } 154 } >> 155 112 156