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 #include "G4RunManager.hh"
00035 #include "G4UImanager.hh"
00036
00037 #include "Randomize.hh"
00038
00039 #include "G4VModularPhysicsList.hh"
00040 #include "DetectorConstruction.hh"
00041 #include "PhysicsList.hh"
00042 #include "PrimaryGeneratorAction.hh"
00043 #include "RunAction.hh"
00044 #include "EventAction.hh"
00045 #include "SteppingAction.hh"
00046 #include "SteppingVerbose.hh"
00047 #include "G4RadioactiveDecayPhysics.hh"
00048 #include "MyStepLimiter.hh"
00049 #include "QGSP_BERT.hh"
00050 #include "QGSP_BERT_HP.hh"
00051
00052
00053 #ifdef G4VIS_USE
00054 #include "G4VisExecutive.hh"
00055 #endif
00056
00057 #ifdef G4UI_USE
00058 #include "G4UIExecutive.hh"
00059 #endif
00060
00061 #include "TFile.h"
00062 #include "TTree.h"
00063
00064 #include "MyStackingAction.hh"
00065 #include "MyTrackingAction.hh"
00066 #include "MyRoot.hh"
00067 #include "MyAnalysisSvc.hh"
00068
00069 #include <iostream>
00070 #include <fstream>
00071
00072
00073
00074 int main(int argc,char** argv)
00075 {
00076
00077 MyRoot* myRoot = new MyRoot();
00078
00079
00080
00081 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine);
00082
00083
00084
00085 G4VSteppingVerbose::SetInstance(new SteppingVerbose);
00086
00087
00088
00089 G4RunManager * runManager = new G4RunManager;
00090
00091
00092
00093 runManager->SetUserInitialization(new DetectorConstruction);
00094
00095
00096
00097 G4VModularPhysicsList* physics;
00098 G4String PhysicsListName = getenv("PHYSICSLIST");
00099 std::cout<<"PhysicsList: \""<<PhysicsListName<<"\""<<std::endl;
00100 if (PhysicsListName=="QGSP_BERT_HP"){
00101 physics= new QGSP_BERT_HP;
00102 physics->RegisterPhysics(new G4RadioactiveDecayPhysics());
00103 }
00104 else if (PhysicsListName=="QGSP_BERT_HP_noRadi"){
00105 physics = new QGSP_BERT_HP;
00106 }
00107 else if (PhysicsListName=="QGSP_BERT_noRadi"){
00108 physics = new QGSP_BERT;
00109 }
00110 else if (PhysicsListName=="PhysicsList"){
00111 physics = new PhysicsList;
00112 }
00113 else{
00114 physics = new QGSP_BERT;
00115 physics ->RegisterPhysics(new G4RadioactiveDecayPhysics());
00116 }
00117 physics->RegisterPhysics(new MyStepLimiter());
00118 runManager->SetUserInitialization(physics);
00119
00120
00121
00122 runManager->SetUserAction(new PrimaryGeneratorAction);
00123
00124 runManager->SetUserAction(new RunAction());
00125
00126 runManager->SetUserAction(new EventAction);
00127
00128 runManager->SetUserAction(new SteppingAction);
00129
00130 runManager->SetUserAction(new MyTrackingAction);
00131
00132 runManager->SetUserAction(new MyStackingAction());
00133
00134
00135
00136 runManager->Initialize();
00137
00138 MyAnalysisSvc* myAnalysisSvc = new MyAnalysisSvc();
00139
00140
00141 G4UImanager* UImanager = G4UImanager::GetUIpointer();
00142
00143 #ifdef G4VIS_USE
00144
00145
00146
00147 G4VisManager* visManager = new G4VisExecutive;
00148 #endif
00149
00150 if (argc!=1)
00151 {
00152 #ifdef G4VIS_USE
00153 visManager->Initialize();
00154 #endif
00155 G4String command = "/control/execute ";
00156 G4String fileName = argv[1];
00157 UImanager->ApplyCommand(command+fileName);
00158 }
00159 else
00160 {
00161 #ifdef G4UI_USE
00162 G4UIExecutive* ui = new G4UIExecutive(argc, argv);
00163 G4String macros_dir = getenv("MACROSCOMMONROOT");
00164 #ifdef G4VIS_USE
00165
00166 visManager->Initialize();
00167 UImanager->ApplyCommand("/control/execute "+macros_dir+"/vis.mac");
00168 #endif
00169 if (ui->IsGUI())
00170 UImanager->ApplyCommand("/control/execute "+macros_dir+"/gui.mac");
00171 ui->SessionStart();
00172 delete ui;
00173 #endif
00174 }
00175
00176
00177
00178
00179
00180 #ifdef G4VIS_USE
00181 delete visManager;
00182 std::cout<<"visManager deleted!!"<<std::endl;
00183 #endif
00184
00185
00186 std::cout<<"myRoot deleted!!"<<std::endl;
00187
00188
00189
00190 delete runManager;
00191 std::cout<<"runManager deleted!!"<<std::endl;
00192
00193 return 0;
00194 }
00195
00196