Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // 27 /// \file ch2.cc 28 /// \brief Main program of the ch2 example 29 // 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 32 #include "DetectorConstruction.hh" 33 #include "ActionInitialization.hh" 34 35 #include "G4RunManagerFactory.hh" 36 #include "G4SteppingVerbose.hh" 37 #include "G4UImanager.hh" 38 #include "FTFP_BERT.hh" 39 #include "G4FastSimulationPhysics.hh" 40 41 #include "G4VisExecutive.hh" 42 #include "G4UIExecutive.hh" 43 44 #include "Randomize.hh" 45 #include "G4Timer.hh" 46 47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 48 49 int main(int argc,char** argv) 50 { 51 // Get current time 52 G4Timer* theTimer = new G4Timer(); 53 theTimer->Start(); 54 55 // Choose the Random engine 56 G4Random::setTheEngine(new CLHEP::RanecuEngine); 57 CLHEP::HepRandom::setTheSeed(0.); 58 59 //use G4SteppingVerboseWithUnits 60 G4int precision = 4; 61 G4SteppingVerbose::UseBestUnit(precision); 62 63 // Detect interactive mode (if no arguments) and define UI session 64 G4UIExecutive* ui = nullptr; 65 if ( argc == 1 ) { ui = new G4UIExecutive(argc, argv); } 66 67 // Construct the default run manager 68 auto* runManager = 69 G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default); 70 71 // Set mandatory initialization classes 72 // 73 // Detector construction 74 runManager->SetUserInitialization(new DetectorConstruction()); 75 76 // Physics list 77 G4VModularPhysicsList* physicsList = new FTFP_BERT; 78 79 // -- Create helper tool, used to activate the fast simulation: 80 G4FastSimulationPhysics* fastSimulationPhysics = new G4FastSimulationPhysics(); 81 fastSimulationPhysics->BeVerbose(); 82 // -- activation of fast simulation for particles having fast simulation models 83 // -- attached in the mass geometry: 84 // you may add any charged particles here 85 // CAUTION: for the particles other then e+- you would likely want 86 // to switch off the radiation 87 fastSimulationPhysics->ActivateFastSimulation("e-"); 88 fastSimulationPhysics->ActivateFastSimulation("e+"); 89 fastSimulationPhysics->ActivateFastSimulation("proton"); 90 fastSimulationPhysics->ActivateFastSimulation("anti_proton"); 91 fastSimulationPhysics->ActivateFastSimulation("mu+"); 92 fastSimulationPhysics->ActivateFastSimulation("mu-"); 93 fastSimulationPhysics->ActivateFastSimulation("pi+"); 94 fastSimulationPhysics->ActivateFastSimulation("pi-"); 95 fastSimulationPhysics->ActivateFastSimulation("GenericIon"); 96 //fastSimulationPhysics->ActivateFastSimulation("your_particle"); 97 // you may activate this model for any charged particle 98 // a neutral particle will not enter the model 99 100 // -- Attach the fast simulation physics constructor to the physics list: 101 physicsList->RegisterPhysics( fastSimulationPhysics ); 102 physicsList->SetVerboseLevel(1); 103 runManager->SetUserInitialization(physicsList); 104 105 // User action initialization 106 runManager->SetUserInitialization(new ActionInitialization()); 107 108 // Initialize visualization 109 G4VisManager* visManager = new G4VisExecutive; 110 // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance. 111 // G4VisManager* visManager = new G4VisExecutive("Quiet"); 112 visManager->Initialize(); 113 114 // Get the pointer to the User Interface manager 115 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 116 117 // Process macro or start UI session 118 if ( ! ui ) { 119 // batch mode 120 G4String command = "/control/execute "; 121 G4String fileName = argv[1]; 122 UImanager->ApplyCommand(command+fileName); 123 } 124 else { 125 // interactive mode 126 UImanager->ApplyCommand("/control/execute init_vis.mac"); 127 ui->SessionStart(); 128 delete ui; 129 } 130 131 // Job termination 132 // Free the store: user actions, physics_list and detector_description are 133 // owned and deleted by the run manager, so they should not be deleted 134 // in the main() program ! 135 136 delete visManager; 137 delete runManager; 138 139 theTimer->Stop(); 140 G4cout << "Execution terminated" << G4endl; 141 G4cout << (*theTimer) << G4endl; 142 delete theTimer; 143 144 } 145 146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 147