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 26 /// \file electromagnetic/TestEm10/TestEm10.cc 27 /// \brief Main program of the electromagnetic 27 /// \brief Main program of the electromagnetic/TestEm10 example 28 // 28 // 29 // 29 // 30 // 30 // 31 // 31 // 32 //....oooOO0OOooo........oooOO0OOooo........oo 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 33 //....oooOO0OOooo........oooOO0OOooo........oo 33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 34 34 >> 35 #include "G4RunManager.hh" >> 36 #include "G4UImanager.hh" >> 37 #include "Randomize.hh" >> 38 35 #include "DetectorConstruction.hh" 39 #include "DetectorConstruction.hh" 36 #include "EventAction.hh" << 37 #include "PhysicsList.hh" 40 #include "PhysicsList.hh" 38 #include "PrimaryGeneratorAction.hh" 41 #include "PrimaryGeneratorAction.hh" 39 #include "RunAction.hh" 42 #include "RunAction.hh" >> 43 #include "EventAction.hh" 40 #include "StackingAction.hh" 44 #include "StackingAction.hh" 41 45 42 #include "G4RunManagerFactory.hh" << 43 #include "G4UIExecutive.hh" 46 #include "G4UIExecutive.hh" 44 #include "G4UImanager.hh" << 45 #include "G4VisExecutive.hh" 47 #include "G4VisExecutive.hh" 46 #include "Randomize.hh" << 47 48 48 //....oooOO0OOooo........oooOO0OOooo........oo 49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 49 << 50 50 int main(int argc, char** argv) << 51 int main(int argc,char** argv) 51 { 52 { 52 // detect interactive mode (if no arguments) << 53 >> 54 //detect interactive mode (if no arguments) and define UI session 53 G4UIExecutive* ui = nullptr; 55 G4UIExecutive* ui = nullptr; 54 if (argc == 1) ui = new G4UIExecutive(argc, << 56 if (argc == 1) ui = new G4UIExecutive(argc,argv); 55 57 56 // choose the Random engine << 58 //choose the Random engine 57 CLHEP::HepRandom::setTheEngine(new CLHEP::Ra 59 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); >> 60 >> 61 //construct the default run manager >> 62 G4RunManager * runManager = new G4RunManager; 58 63 59 // construct a serial run manager << 64 //set mandatory initialization classes 60 auto* runManager = G4RunManagerFactory::Crea << 61 << 62 // set mandatory initialization classes << 63 DetectorConstruction* detector; 65 DetectorConstruction* detector; 64 detector = new DetectorConstruction; 66 detector = new DetectorConstruction; 65 67 66 // ALICEDetectorConstruction* detector; 68 // ALICEDetectorConstruction* detector; 67 // detector = new ALICEDetectorConstruction; 69 // detector = new ALICEDetectorConstruction; 68 70 69 runManager->SetUserInitialization(detector); 71 runManager->SetUserInitialization(detector); 70 runManager->SetUserInitialization(new Physic 72 runManager->SetUserInitialization(new PhysicsList(detector)); 71 73 72 // set user action classes << 74 //set user action classes 73 runManager->SetUserAction(new PrimaryGenerat 75 runManager->SetUserAction(new PrimaryGeneratorAction()); 74 76 75 RunAction* runAction = new RunAction; 77 RunAction* runAction = new RunAction; 76 runManager->SetUserAction(runAction); 78 runManager->SetUserAction(runAction); 77 79 78 EventAction* eventAction = new EventAction(r 80 EventAction* eventAction = new EventAction(runAction); 79 runManager->SetUserAction(eventAction); 81 runManager->SetUserAction(eventAction); 80 82 81 runManager->SetUserAction(new StackingAction << 83 runManager->SetUserAction( new StackingAction ); 82 84 83 // initialize visualization << 85 //initialize visualization 84 G4VisManager* visManager = nullptr; 86 G4VisManager* visManager = nullptr; 85 87 86 // get the pointer to the User Interface man << 88 //get the pointer to the User Interface manager 87 G4UImanager* UImanager = G4UImanager::GetUIp 89 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 88 90 89 if (ui) { << 91 if (ui) { 90 // interactive mode << 92 //interactive mode 91 visManager = new G4VisExecutive; << 93 visManager = new G4VisExecutive; 92 visManager->Initialize(); << 94 visManager->Initialize(); 93 ui->SessionStart(); << 95 ui->SessionStart(); 94 delete ui; << 96 delete ui; 95 } 97 } 96 else { << 98 else { 97 // batch mode << 99 //batch mode 98 G4String command = "/control/execute "; << 100 G4String command = "/control/execute "; 99 G4String fileName = argv[1]; << 101 G4String fileName = argv[1]; 100 UImanager->ApplyCommand(command + fileName << 102 UImanager->ApplyCommand(command+fileName); 101 } 103 } 102 104 103 // job termination << 105 //job termination 104 delete visManager; 106 delete visManager; 105 delete runManager; 107 delete runManager; 106 } 108 } 107 109 108 //....oooOO0OOooo........oooOO0OOooo........oo 110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 109 111