![]() |
|
|||
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 ch3.cc 0028 /// \brief Main program of the ch3 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 #include "G4CoherentPairProductionPhysics.hh" 0041 0042 #include "G4VisExecutive.hh" 0043 #include "G4UIExecutive.hh" 0044 0045 #include "Randomize.hh" 0046 #include "G4Timer.hh" 0047 0048 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0049 0050 int main(int argc,char** argv) 0051 { 0052 // Get current time 0053 G4Timer* theTimer = new G4Timer(); 0054 theTimer->Start(); 0055 0056 // Choose the Random engine 0057 G4Random::setTheEngine(new CLHEP::RanecuEngine); 0058 CLHEP::HepRandom::setTheSeed(0.); 0059 0060 //use G4SteppingVerboseWithUnits 0061 G4int precision = 4; 0062 G4SteppingVerbose::UseBestUnit(precision); 0063 0064 // Detect interactive mode (if no arguments) and define UI session 0065 G4UIExecutive* ui = nullptr; 0066 if ( argc == 1 ) { ui = new G4UIExecutive(argc, argv); } 0067 0068 // Construct the default run manager 0069 auto* runManager = 0070 G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default); 0071 0072 // Set mandatory initialization classes 0073 // 0074 // Detector construction 0075 runManager->SetUserInitialization(new DetectorConstruction()); 0076 0077 // Physics list 0078 G4VModularPhysicsList* physicsList = new FTFP_BERT; 0079 0080 // -- Create helper tool, used to activate the fast simulation: 0081 G4FastSimulationPhysics* fastSimulationPhysics = new G4FastSimulationPhysics(); 0082 fastSimulationPhysics->BeVerbose(); 0083 // -- activation of fast simulation for particles having fast simulation models 0084 fastSimulationPhysics->ActivateFastSimulation("e-"); 0085 fastSimulationPhysics->ActivateFastSimulation("e+"); 0086 // -- Attach the fast simulation physics constructor to the physics list: 0087 physicsList->RegisterPhysics( fastSimulationPhysics ); 0088 0089 // Create coherent pair production physics 0090 G4CoherentPairProductionPhysics* coherentPairProductionPhysics = 0091 new G4CoherentPairProductionPhysics(); 0092 // CAUTION: using default for channeling model name "ChannelingModel" and 0093 // the region name "Crystal" (see DetectorConstruction). 0094 0095 // Register coherentPairProductionPhysics to the physics list: 0096 physicsList->RegisterPhysics(coherentPairProductionPhysics); 0097 0098 physicsList->SetVerboseLevel(1); 0099 runManager->SetUserInitialization(physicsList); 0100 0101 // User action initialization 0102 runManager->SetUserInitialization(new ActionInitialization()); 0103 0104 // Initialize visualization 0105 G4VisManager* visManager = new G4VisExecutive; 0106 // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance. 0107 // G4VisManager* visManager = new G4VisExecutive("Quiet"); 0108 visManager->Initialize(); 0109 0110 // Get the pointer to the User Interface manager 0111 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 0112 0113 // Process macro or start UI session 0114 if ( ! ui ) { 0115 // batch mode 0116 G4String command = "/control/execute "; 0117 G4String fileName = argv[1]; 0118 UImanager->ApplyCommand(command+fileName); 0119 } 0120 else { 0121 // interactive mode 0122 UImanager->ApplyCommand("/control/execute init_vis.mac"); 0123 ui->SessionStart(); 0124 delete ui; 0125 } 0126 0127 // Job termination 0128 // Free the store: user actions, physics_list and detector_description are 0129 // owned and deleted by the run manager, so they should not be deleted 0130 // in the main() program ! 0131 0132 delete visManager; 0133 delete runManager; 0134 0135 theTimer->Stop(); 0136 G4cout << "Execution terminated" << G4endl; 0137 G4cout << (*theTimer) << G4endl; 0138 delete theTimer; 0139 0140 } 0141 0142 //....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 |
![]() ![]() |