![]() |
|
|||
File indexing completed on 2025-10-13 08:26:58
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // 0027 /// \file ch2.cc 0028 /// \brief Main program of the ch2 example 0029 // 0030 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0031 0032 #include "DetectorConstruction.hh" 0033 #include "ActionInitialization.hh" 0034 0035 #include "G4RunManagerFactory.hh" 0036 #include "G4SteppingVerbose.hh" 0037 #include "G4UImanager.hh" 0038 #include "FTFP_BERT.hh" 0039 #include "G4FastSimulationPhysics.hh" 0040 0041 #include "G4VisExecutive.hh" 0042 #include "G4UIExecutive.hh" 0043 0044 #include "Randomize.hh" 0045 #include "G4Timer.hh" 0046 0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0048 0049 int main(int argc,char** argv) 0050 { 0051 // Get current time 0052 G4Timer* theTimer = new G4Timer(); 0053 theTimer->Start(); 0054 0055 // Choose the Random engine 0056 G4Random::setTheEngine(new CLHEP::RanecuEngine); 0057 CLHEP::HepRandom::setTheSeed(0.); 0058 0059 //use G4SteppingVerboseWithUnits 0060 G4int precision = 4; 0061 G4SteppingVerbose::UseBestUnit(precision); 0062 0063 // Detect interactive mode (if no arguments) and define UI session 0064 G4UIExecutive* ui = nullptr; 0065 if ( argc == 1 ) { ui = new G4UIExecutive(argc, argv); } 0066 0067 // Construct the default run manager 0068 auto* runManager = 0069 G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default); 0070 0071 // Set mandatory initialization classes 0072 // 0073 // Detector construction 0074 runManager->SetUserInitialization(new DetectorConstruction()); 0075 0076 // Physics list 0077 G4VModularPhysicsList* physicsList = new FTFP_BERT; 0078 0079 // -- Create helper tool, used to activate the fast simulation: 0080 G4FastSimulationPhysics* fastSimulationPhysics = new G4FastSimulationPhysics(); 0081 fastSimulationPhysics->BeVerbose(); 0082 // -- activation of fast simulation for particles having fast simulation models 0083 // -- attached in the mass geometry: 0084 // you may add any charged particles here 0085 // CAUTION: for the particles other then e+- you would likely want 0086 // to switch off the radiation 0087 fastSimulationPhysics->ActivateFastSimulation("e-"); 0088 fastSimulationPhysics->ActivateFastSimulation("e+"); 0089 fastSimulationPhysics->ActivateFastSimulation("proton"); 0090 fastSimulationPhysics->ActivateFastSimulation("anti_proton"); 0091 fastSimulationPhysics->ActivateFastSimulation("mu+"); 0092 fastSimulationPhysics->ActivateFastSimulation("mu-"); 0093 fastSimulationPhysics->ActivateFastSimulation("pi+"); 0094 fastSimulationPhysics->ActivateFastSimulation("pi-"); 0095 fastSimulationPhysics->ActivateFastSimulation("GenericIon"); 0096 //fastSimulationPhysics->ActivateFastSimulation("your_particle"); 0097 // you may activate this model for any charged particle 0098 // a neutral particle will not enter the model 0099 0100 // -- Attach the fast simulation physics constructor to the physics list: 0101 physicsList->RegisterPhysics( fastSimulationPhysics ); 0102 physicsList->SetVerboseLevel(1); 0103 runManager->SetUserInitialization(physicsList); 0104 0105 // User action initialization 0106 runManager->SetUserInitialization(new ActionInitialization()); 0107 0108 // Initialize visualization 0109 G4VisManager* visManager = new G4VisExecutive; 0110 // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance. 0111 // G4VisManager* visManager = new G4VisExecutive("Quiet"); 0112 visManager->Initialize(); 0113 0114 // Get the pointer to the User Interface manager 0115 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 0116 0117 // Process macro or start UI session 0118 if ( ! ui ) { 0119 // batch mode 0120 G4String command = "/control/execute "; 0121 G4String fileName = argv[1]; 0122 UImanager->ApplyCommand(command+fileName); 0123 } 0124 else { 0125 // interactive mode 0126 UImanager->ApplyCommand("/control/execute init_vis.mac"); 0127 ui->SessionStart(); 0128 delete ui; 0129 } 0130 0131 // Job termination 0132 // Free the store: user actions, physics_list and detector_description are 0133 // owned and deleted by the run manager, so they should not be deleted 0134 // in the main() program ! 0135 0136 delete visManager; 0137 delete runManager; 0138 0139 theTimer->Stop(); 0140 G4cout << "Execution terminated" << G4endl; 0141 G4cout << (*theTimer) << G4endl; 0142 delete theTimer; 0143 0144 } 0145 0146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |