File indexing completed on 2026-04-18 07:41:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 #include "DetectorConstruction.hh"
0034 #include "ActionInitialization.hh"
0035
0036 #include "G4RunManagerFactory.hh"
0037 #include "G4SteppingVerbose.hh"
0038 #include "G4UImanager.hh"
0039 #include "G4ScoringManager.hh"
0040 #include "G4AnalysisManager.hh"
0041 #include "G4VisExecutive.hh"
0042 #include "G4UIExecutive.hh"
0043
0044 #include "FTFP_BERT.hh"
0045 #include "G4FastSimulationPhysics.hh"
0046 #include "G4CoherentPairProductionPhysics.hh"
0047
0048 #include "Randomize.hh"
0049 #include <ctime>
0050 #include "G4Timer.hh"
0051
0052 #include "G4ParticleTable.hh"
0053 #include "G4ParticleDefinition.hh"
0054
0055
0056
0057 int main(int argc,char** argv)
0058 {
0059
0060 G4Timer* theTimer = new G4Timer();
0061 theTimer->Start();
0062
0063
0064 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
0065 G4String option_file = "random.in";
0066 std::ifstream fin(option_file);
0067 long random_seed = 0;
0068 if (fin.is_open()) {
0069 fin >> random_seed;
0070 fin.close();
0071 }
0072 random_seed += time(NULL);
0073 G4cout << "Random seed: " << random_seed << G4endl;
0074 CLHEP::HepRandom::setTheSeed(random_seed);
0075
0076
0077 G4int precision = 4;
0078 G4SteppingVerbose::UseBestUnit(precision);
0079
0080
0081 int vNumberOfThreads = 1;
0082 if (argc > 2) {
0083 vNumberOfThreads = atoi(argv[2]);
0084 }
0085 auto* runManager =
0086 G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
0087 runManager->SetNumberOfThreads(vNumberOfThreads);
0088 G4cout << "### Using " << vNumberOfThreads << " threads ###" << G4endl;
0089
0090
0091 G4ScoringManager* scManager = G4ScoringManager::GetScoringManager();
0092 scManager->SetVerboseLevel(0);
0093
0094
0095
0096
0097 runManager->SetUserInitialization(new DetectorConstruction);
0098
0099
0100 G4VModularPhysicsList* physicsList = new FTFP_BERT;
0101
0102 G4FastSimulationPhysics* fastSimulationPhysics = new G4FastSimulationPhysics();
0103 fastSimulationPhysics->BeVerbose();
0104
0105
0106 fastSimulationPhysics->ActivateFastSimulation("e-");
0107 fastSimulationPhysics->ActivateFastSimulation("e+");
0108 fastSimulationPhysics->ActivateFastSimulation("pi-");
0109 fastSimulationPhysics->ActivateFastSimulation("pi+");
0110 fastSimulationPhysics->ActivateFastSimulation("mu-");
0111 fastSimulationPhysics->ActivateFastSimulation("mu+");
0112 fastSimulationPhysics->ActivateFastSimulation("proton");
0113 fastSimulationPhysics->ActivateFastSimulation("anti_proton");
0114 fastSimulationPhysics->ActivateFastSimulation("GenericIon");
0115
0116 physicsList->RegisterPhysics(fastSimulationPhysics);
0117
0118
0119
0120
0121
0122
0123 physicsList->SetVerboseLevel(1);
0124 runManager->SetUserInitialization(physicsList);
0125
0126
0127 runManager->SetUserInitialization(new ActionInitialization());
0128
0129
0130
0131 G4UImanager* UImanager = G4UImanager::GetUIpointer();
0132
0133 if (argc != 1) {
0134
0135 G4String command = "/control/execute ";
0136 G4String fileName = argv[1];
0137 UImanager->ApplyCommand(command+fileName);
0138 } else {
0139
0140 G4VisManager* visManager = new G4VisExecutive;
0141 visManager->Initialize();
0142
0143
0144 G4UIExecutive* ui = new G4UIExecutive(argc,argv);
0145 UImanager->ApplyCommand("/control/execute macros/init_vis.mac");
0146 if (ui->IsGUI()) UImanager->ApplyCommand("/control/execute macros/gui.mac");
0147 ui->SessionStart();
0148 delete ui;
0149
0150 delete visManager;
0151 }
0152
0153
0154 delete runManager;
0155
0156 theTimer->Stop();
0157 G4cout << "Execution terminated" << G4endl;
0158 G4cout << (*theTimer) << G4endl;
0159 delete theTimer;
0160
0161 return 0;
0162 }
0163
0164