Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /// \file electromagnetic/TestEm10/TestEm10.cc << 27 /// \brief Main program of the electromagnetic << 28 // 26 // >> 27 // $Id: TestEm10.cc,v 1.8 2006/08/16 15:58:32 grichine Exp $ >> 28 // GEANT4 tag $Name: geant4-08-03-patch-02 $ 29 // 29 // >> 30 // >> 31 // -------------------------------------------------------------- >> 32 // GEANT 4 - TestEm10 30 // 33 // 31 // << 34 // -------------------------------------------------------------- 32 //....oooOO0OOooo........oooOO0OOooo........oo << 35 // Comments 33 //....oooOO0OOooo........oooOO0OOooo........oo << 36 // 34 << 37 // 35 #include "DetectorConstruction.hh" << 38 // -------------------------------------------------------------- 36 #include "EventAction.hh" << 37 #include "PhysicsList.hh" << 38 #include "PrimaryGeneratorAction.hh" << 39 #include "RunAction.hh" << 40 #include "StackingAction.hh" << 41 39 42 #include "G4RunManagerFactory.hh" << 40 #include "G4RunManager.hh" 43 #include "G4UIExecutive.hh" << 44 #include "G4UImanager.hh" 41 #include "G4UImanager.hh" 45 #include "G4VisExecutive.hh" << 42 #include "G4UIterminal.hh" 46 #include "Randomize.hh" 43 #include "Randomize.hh" 47 44 48 //....oooOO0OOooo........oooOO0OOooo........oo << 45 #ifdef G4VIS_USE >> 46 #include "G4VisExecutive.hh" >> 47 #endif 49 48 50 int main(int argc, char** argv) << 49 #include "Em10DetectorConstruction.hh" >> 50 // #include "ALICEDetectorConstruction.hh" >> 51 #include "Em10PhysicsList.hh" >> 52 #include "Em10PrimaryGeneratorAction.hh" >> 53 #include "Em10RunAction.hh" >> 54 #include "Em10EventAction.hh" >> 55 #include "Em10SteppingAction.hh" >> 56 #include "Em10SteppingVerbose.hh" >> 57 #include "Em10TrackingAction.hh" >> 58 >> 59 int main(int argc,char** argv) 51 { 60 { 52 // detect interactive mode (if no arguments) << 53 G4UIExecutive* ui = nullptr; << 54 if (argc == 1) ui = new G4UIExecutive(argc, << 55 61 56 // choose the Random engine << 62 //choose the Random engine >> 63 57 CLHEP::HepRandom::setTheEngine(new CLHEP::Ra 64 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); >> 65 >> 66 //my Verbose output class >> 67 >> 68 G4VSteppingVerbose::SetInstance(new Em10SteppingVerbose); >> 69 >> 70 // Construct the default run manager 58 71 59 // construct a serial run manager << 72 G4RunManager * runManager = new G4RunManager; 60 auto* runManager = G4RunManagerFactory::Crea << 61 73 62 // set mandatory initialization classes 74 // set mandatory initialization classes 63 DetectorConstruction* detector; << 75 64 detector = new DetectorConstruction; << 76 Em10DetectorConstruction* detector; >> 77 detector = new Em10DetectorConstruction; 65 78 66 // ALICEDetectorConstruction* detector; 79 // ALICEDetectorConstruction* detector; 67 // detector = new ALICEDetectorConstruction; 80 // detector = new ALICEDetectorConstruction; 68 81 69 runManager->SetUserInitialization(detector); 82 runManager->SetUserInitialization(detector); 70 runManager->SetUserInitialization(new Physic << 83 runManager->SetUserInitialization(new Em10PhysicsList(detector)); >> 84 >> 85 #ifdef G4VIS_USE >> 86 >> 87 // visualization manager 71 88 >> 89 G4VisManager* visManager = new G4VisExecutive; >> 90 visManager->Initialize(); >> 91 >> 92 #endif >> 93 72 // set user action classes 94 // set user action classes 73 runManager->SetUserAction(new PrimaryGenerat << 74 95 75 RunAction* runAction = new RunAction; << 96 runManager->SetUserAction(new Em10PrimaryGeneratorAction(detector)); 76 runManager->SetUserAction(runAction); << 77 97 78 EventAction* eventAction = new EventAction(r << 98 Em10RunAction* runAction = new Em10RunAction; 79 runManager->SetUserAction(eventAction); << 80 99 81 runManager->SetUserAction(new StackingAction << 100 runManager->SetUserAction(runAction); 82 101 83 // initialize visualization << 102 Em10EventAction* eventAction = new Em10EventAction(runAction); 84 G4VisManager* visManager = nullptr; << 85 103 86 // get the pointer to the User Interface man << 104 runManager->SetUserAction(eventAction); 87 G4UImanager* UImanager = G4UImanager::GetUIp << 88 105 89 if (ui) { << 106 Em10SteppingAction* steppingAction = new Em10SteppingAction(detector, 90 // interactive mode << 107 eventAction, 91 visManager = new G4VisExecutive; << 108 runAction); 92 visManager->Initialize(); << 109 runManager->SetUserAction(steppingAction); 93 ui->SessionStart(); << 110 94 delete ui; << 111 >> 112 runManager->SetUserAction( new Em10TrackingAction ); >> 113 >> 114 >> 115 >> 116 //Initialize G4 kernel, physics tables ... >> 117 >> 118 // runManager->Initialize(); >> 119 >> 120 // get the pointer to the User Interface manager >> 121 >> 122 G4UImanager* UI = G4UImanager::GetUIpointer(); >> 123 >> 124 if (argc==1) // Define UI terminal for interactive mode >> 125 { >> 126 G4UIsession * session = new G4UIterminal; >> 127 UI->ApplyCommand("/control/execute init.mac"); >> 128 session->SessionStart(); >> 129 delete session; 95 } 130 } 96 else { << 131 else // Batch mode 97 // batch mode << 132 { 98 G4String command = "/control/execute "; << 133 G4String command = "/control/execute "; 99 G4String fileName = argv[1]; << 134 G4String fileName = argv[1]; 100 UImanager->ApplyCommand(command + fileName << 135 UI->ApplyCommand(command+fileName); 101 } 136 } 102 << 137 103 // job termination 138 // job termination >> 139 >> 140 #ifdef G4VIS_USE 104 delete visManager; 141 delete visManager; >> 142 #endif 105 delete runManager; 143 delete runManager; >> 144 >> 145 return 0; 106 } 146 } 107 147 108 //....oooOO0OOooo........oooOO0OOooo........oo << 109 148