#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "Randomize.hh"
#include "G4VModularPhysicsList.hh"
#include "DetectorConstruction.hh"
#include "PhysicsList.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "EventAction.hh"
#include "SteppingAction.hh"
#include "SteppingVerbose.hh"
#include "G4RadioactiveDecayPhysics.hh"
#include "MyStepLimiter.hh"
#include "QGSP_BERT.hh"
#include "QGSP_BERT_HP.hh"
#include "TFile.h"
#include "TTree.h"
#include "MyStackingAction.hh"
#include "MyTrackingAction.hh"
#include "MyRoot.hh"
#include "MyAnalysisSvc.hh"
#include <iostream>
#include <fstream>
Go to the source code of this file.
Functions | |
int | main (int argc, char **argv) |
int main | ( | int | argc, | |
char ** | argv | |||
) |
Definition at line 74 of file g4sim.cc.
00075 { 00076 00077 MyRoot* myRoot = new MyRoot(); 00078 00079 // Choose the Random engine 00080 // 00081 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); 00082 00083 // User Verbose output class 00084 // 00085 G4VSteppingVerbose::SetInstance(new SteppingVerbose); 00086 00087 // Construct the default run manager 00088 // 00089 G4RunManager * runManager = new G4RunManager; 00090 00091 // Set mandatory initialization classes 00092 // 00093 runManager->SetUserInitialization(new DetectorConstruction); 00094 // 00095 00096 // get physicslist 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 // Set user action classes 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 // Initialize G4 kernel 00135 // 00136 runManager->Initialize(); 00137 00138 MyAnalysisSvc* myAnalysisSvc = new MyAnalysisSvc(); 00139 00140 // Get the pointer to the User Interface manager 00141 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 00142 00143 #ifdef G4VIS_USE 00144 // Initialize visualization 00145 // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance. 00146 // G4VisManager* visManager = new G4VisExecutive("Quiet"); 00147 G4VisManager* visManager = new G4VisExecutive; 00148 #endif 00149 00150 if (argc!=1) // batch mode 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 { // interactive mode : define UI session 00161 #ifdef G4UI_USE 00162 G4UIExecutive* ui = new G4UIExecutive(argc, argv); 00163 G4String macros_dir = getenv("MACROSCOMMONROOT"); 00164 #ifdef G4VIS_USE 00165 // Initialize visualization 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 // Job termination 00177 // Free the store: user actions, physics_list and detector_description are 00178 // owned and deleted by the run manager, so they should not 00179 // be deleted in the main() program ! 00180 #ifdef G4VIS_USE 00181 delete visManager; 00182 std::cout<<"visManager deleted!!"<<std::endl; 00183 #endif 00184 00185 // delete myRoot; 00186 std::cout<<"myRoot deleted!!"<<std::endl; 00187 //delete myAnalysisSvc; 00188 //std::cout<<"myAnalysisSvc deleted!!"<<std::endl; 00189 00190 delete runManager; 00191 std::cout<<"runManager deleted!!"<<std::endl; 00192 00193 return 0; 00194 }