#include "G4RunManager.hh" #include "G4UImanager.hh" #include "G4UIterminal.hh" #include "G4UItcsh.hh" #include "G4VSteppingVerbose.hh" #ifdef G4UI_USE_XM #include "G4UIXm.hh" #endif #include "Randomize.hh" #ifdef G4VIS_USE #include "G4VisExecutive.hh" #endif #include "DetectorConstruction.hh" #include "PhysicsList.hh" // include for Geant Version 9 #include "PrimaryGeneratorAction.hh" #include "RunAction.hh" #include "EventAction.hh" #include "SteppingAction.hh" #include "SteppingVerbose.hh" #include "EventActionMessenger.hh" #include "DetectorMessenger.hh" #include "G4PhysListFactory.hh" #include "G4ScoringManager.hh" #include "FTFP_BERT.hh" #include "QGSP_BERT_HP.hh" #include "G4EmDNAPhysics.hh" #include "QGSP_BIC_HP.hh" #include int main(int argc,char** argv) { // choose the Random engine //HepRandom::setTheEngine(new RanecuEngine); //Geant 4.9 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); SteppingVerbose* stepping_verbose = new SteppingVerbose(); //G4VSteppingVerbose::SetInstance(new SteppingVerbose); G4VSteppingVerbose::SetInstance(stepping_verbose); // Construct the default run manager G4RunManager * runManager = new G4RunManager; //Activate command-based scorer G4ScoringManager* scoringManager = G4ScoringManager::GetScoringManager(); // set mandatory initialization classes DetectorConstruction* detector = new DetectorConstruction; DetectorMessenger* detectorMessenger = new DetectorMessenger(detector); runManager->SetUserInitialization(detector); //get the pointer to the User Interface manager G4UImanager* UI = G4UImanager::GetUIpointer(); G4String command, fileName; G4cout << "argc = " << argc << G4endl; if (argc==3) { command = "/control/execute "; fileName = argv[2]; UI->ApplyCommand(command+fileName); } //Geant Version 9 (user defined physics list) // runManager->SetUserInitialization(new PhysicsList); //Geant Version 10 (predefined physics list, as from example B4a) //G4VModularPhysicsList* physicsList = new FTFP_BERT; G4VModularPhysicsList* physicsList = new QGSP_BERT_HP; //G4VModularPhysicsList* physicsList = new G4EmDNAPhysics; // G4VModularPhysicsList* physicsList = new QGSP_BIC_HP; runManager->SetUserInitialization(physicsList); G4UIsession* session=0; if (argc==1) // Define UI session for interactive mode. { // G4UIterminal is a (dumb) terminal. #ifdef G4UI_USE_XM session = new G4UIXm(argc,argv); #else #ifdef G4UI_USE_TCSH session = new G4UIterminal(new G4UItcsh); #else session = new G4UIterminal(); #endif #endif } #ifdef G4VIS_USE // visualization manager G4VisManager* visManager = new G4VisExecutive; visManager->Initialize(); #endif // set user action classes PrimaryGeneratorAction* pga = new PrimaryGeneratorAction; runManager->SetUserAction(pga); //runManager->SetUserAction(new RunAction); //runManager->SetUserAction(new EventAction(pga)); RunAction* run_action = new RunAction; runManager->SetUserAction(run_action); EventAction* event_action = new EventAction(pga); runManager->SetUserAction(event_action); EventActionMessenger* messenger = new EventActionMessenger(event_action, stepping_verbose); SteppingAction* stepping_action = new SteppingAction(detector, event_action); runManager->SetUserAction(stepping_action); //Initialize G4 kernel runManager->Initialize(); // Define UI session for interactive mode. if(session) { // G4UIterminal is a (dumb) terminal. UI->ApplyCommand("/control/execute inter_60MeV.mac"); session->SessionStart(); delete session; } // Batch mode else { command = "/control/execute "; fileName = argv[1]; UI->ApplyCommand(command+fileName); } // job termination #ifdef G4VIS_USE delete visManager; #endif delete runManager; return 0; }