Hadr00.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #include "G4RunManager.hh"
00048 #include "G4UImanager.hh"
00049 #include "Randomize.hh"
00050
00051 #include "DetectorConstruction.hh"
00052 #include "G4PhysListFactory.hh"
00053 #include "G4VModularPhysicsList.hh"
00054 #include "PrimaryGeneratorAction.hh"
00055
00056 #include "RunAction.hh"
00057 #include "EventAction.hh"
00058
00059 #ifdef G4VIS_USE
00060 #include "G4VisExecutive.hh"
00061 #endif
00062
00063 #ifdef G4UI_USE
00064 #include "G4UIExecutive.hh"
00065 #endif
00066
00067
00068
00069 int main(int argc,char** argv) {
00070
00071
00072 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine());
00073
00074
00075 G4RunManager * runManager = new G4RunManager();
00076
00077
00078 runManager->SetUserInitialization(new DetectorConstruction());
00079
00080 G4PhysListFactory factory;
00081 G4VModularPhysicsList* phys = 0;
00082 G4String physName = "";
00083
00084
00085 if (argc==3) { physName = argv[2]; }
00086
00087
00088 if("" == physName) {
00089 char* path = getenv("PHYSLIST");
00090 if (path) { physName = G4String(path); }
00091 }
00092
00093
00094 if("" == physName || !factory.IsReferencePhysList(physName)) {
00095 physName = "QGSP_BERT";
00096 }
00097
00098
00099 phys = factory.GetReferencePhysList(physName);
00100
00101 runManager->SetUserInitialization(phys);
00102
00103 runManager->SetUserAction(new PrimaryGeneratorAction());
00104
00105
00106 runManager->SetUserAction(new RunAction());
00107 runManager->SetUserAction(new EventAction());
00108
00109
00110 G4UImanager* UImanager = G4UImanager::GetUIpointer();
00111 #ifdef G4VIS_USE
00112 G4VisManager* visManager = 0;
00113 #endif
00114
00115 if (argc==1)
00116 {
00117 #ifdef G4VIS_USE
00118
00119 visManager = new G4VisExecutive;
00120 visManager->Initialize();
00121 #endif
00122 #ifdef G4UI_USE
00123 G4UIExecutive* ui = new G4UIExecutive(argc, argv);
00124 ui->SessionStart();
00125 delete ui;
00126 #endif
00127 }
00128 else
00129 {
00130 G4String command = "/control/execute ";
00131 G4String fileName = argv[1];
00132 UImanager->ApplyCommand(command+fileName);
00133 }
00134
00135
00136 #ifdef G4VIS_USE
00137 delete visManager;
00138 #endif
00139 delete runManager;
00140
00141 return 0;
00142 }
00143
00144