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/TestEm6/TestEm6.cc << 26 // $Id: TestEm6.cc,v 1.17 2010-05-21 08:56:45 maire Exp $ 27 /// \brief Main program of the electromagnetic << 27 // GEANT4 tag $Name: geant4-09-04-patch-01 $ 28 // << 28 // 29 // << 30 //....oooOO0OOooo........oooOO0OOooo........oo << 31 //....oooOO0OOooo........oooOO0OOooo........oo 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 31 >> 32 #include "G4RunManager.hh" >> 33 #include "G4UImanager.hh" >> 34 #include "Randomize.hh" 32 35 33 #include "DetectorConstruction.hh" 36 #include "DetectorConstruction.hh" 34 #include "PhysicsList.hh" 37 #include "PhysicsList.hh" 35 #include "PrimaryGeneratorAction.hh" 38 #include "PrimaryGeneratorAction.hh" >> 39 #include "SteppingVerbose.hh" >> 40 36 #include "RunAction.hh" 41 #include "RunAction.hh" 37 #include "StackingAction.hh" << 42 #include "EventAction.hh" 38 #include "SteppingAction.hh" 43 #include "SteppingAction.hh" >> 44 #include "StackingAction.hh" >> 45 >> 46 #ifdef G4VIS_USE >> 47 #include "G4VisExecutive.hh" >> 48 #endif 39 49 40 #include "G4RunManagerFactory.hh" << 50 #ifdef G4UI_USE 41 #include "G4SteppingVerbose.hh" << 42 #include "G4UIExecutive.hh" 51 #include "G4UIExecutive.hh" 43 #include "G4UImanager.hh" << 52 #endif 44 #include "G4VisExecutive.hh" << 45 53 46 //....oooOO0OOooo........oooOO0OOooo........oo 54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 << 55 48 int main(int argc, char** argv) << 56 int main(int argc,char** argv) { 49 { << 57 50 // detect interactive mode (if no arguments) << 58 //choose the Random engine 51 G4UIExecutive* ui = nullptr; << 59 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); 52 if (argc == 1) ui = new G4UIExecutive(argc, << 60 53 << 61 //my Verbose output class 54 // Use SteppingVerbose with Unit << 62 G4VSteppingVerbose::SetInstance(new SteppingVerbose); 55 G4int precision = 4; << 63 56 G4SteppingVerbose::UseBestUnit(precision); << 64 //Construct the default run manager 57 << 65 G4RunManager * runManager = new G4RunManager; 58 // Construct a serial run manager << 66 59 auto* runManager = G4RunManagerFactory::Crea << 67 //set mandatory initialization classes 60 << 68 DetectorConstruction* det; 61 // set mandatory initialization classes << 69 runManager->SetUserInitialization(det = new DetectorConstruction); 62 DetectorConstruction* det = new DetectorCons << 70 runManager->SetUserInitialization(new PhysicsList); 63 runManager->SetUserInitialization(det); << 64 runManager->SetUserInitialization(new Physic << 65 runManager->SetUserAction(new PrimaryGenerat 71 runManager->SetUserAction(new PrimaryGeneratorAction(det)); 66 << 72 67 // set user action classes << 73 //set user action classes 68 RunAction* runAct = new RunAction(det); << 74 RunAction* RunAct; 69 << 75 70 runManager->SetUserAction(runAct); << 76 runManager->SetUserAction(RunAct = new RunAction); 71 runManager->SetUserAction(new SteppingAction << 77 runManager->SetUserAction(new EventAction); 72 runManager->SetUserAction(new StackingAction << 78 runManager->SetUserAction(new SteppingAction(RunAct)); 73 << 79 runManager->SetUserAction(new StackingAction); 74 // initialize visualization << 80 75 G4VisManager* visManager = nullptr; << 81 //get the pointer to the User Interface manager 76 << 82 G4UImanager* UI = G4UImanager::GetUIpointer(); 77 // get the pointer to the User Interface man << 83 78 G4UImanager* UImanager = G4UImanager::GetUIp << 84 if (argc!=1) // batch mode 79 << 85 { 80 if (ui) { << 86 G4String command = "/control/execute "; 81 // interactive mode << 87 G4String fileName = argv[1]; 82 visManager = new G4VisExecutive; << 88 UI->ApplyCommand(command+fileName); 83 visManager->Initialize(); << 89 } 84 ui->SessionStart(); << 90 85 delete ui; << 91 else //define visualization and UI terminal for interactive mode 86 delete visManager; << 92 { 87 } << 93 #ifdef G4VIS_USE 88 else { << 94 G4VisManager* visManager = new G4VisExecutive; 89 // batch mode << 95 visManager->Initialize(); 90 G4String command = "/control/execute "; << 96 #endif 91 G4String fileName = argv[1]; << 97 92 UImanager->ApplyCommand(command + fileName << 98 #ifdef G4UI_USE 93 } << 99 G4UIExecutive * ui = new G4UIExecutive(argc,argv); 94 << 100 ui->SessionStart(); 95 // job termination << 101 delete ui; >> 102 #endif >> 103 >> 104 #ifdef G4VIS_USE >> 105 delete visManager; >> 106 #endif >> 107 } >> 108 >> 109 //job termination >> 110 // 96 delete runManager; 111 delete runManager; >> 112 >> 113 return 0; 97 } 114 } 98 115 99 //....oooOO0OOooo........oooOO0OOooo........oo << 116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 100 117