Skip to content
Snippets Groups Projects
Commit 716512bd authored by matta's avatar matta
Browse files

* Add NPOption Manager to NPS

parent 7f028ebf
No related branches found
No related tags found
No related merge requests found
...@@ -13,103 +13,100 @@ ...@@ -13,103 +13,100 @@
#ifdef G4VIS_USE #ifdef G4VIS_USE
#include "G4VisExecutive.hh" #include "G4VisExecutive.hh"
#endif #endif
// NPS Source // NPS headers
#include "EventAction.hh" #include "EventAction.hh"
#include "VDetector.hh" #include "VDetector.hh"
//NPL headers
#include "NPOptionManager.h"
#include "RootOutput.h" #include "RootOutput.h"
// ROOT Source // ROOT headers
#include "TTree.h" #include "TTree.h"
#include "TFile.h" #include "TFile.h"
// STL // STL
#include <vector> #include <vector>
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
NPOptionManager* OptionManager = NPOptionManager::getInstance(argc,argv);
if (argc != 3) { G4String EventGeneratorFileName = OptionManager->GetReactionFilePath();
cout << "you need to specify both a Reaction file and a Detector file such as : Simulation myReaction.reaction myDetector.detector" << endl ; G4String DetectorFileName = OptionManager->GetDetectorFilePath();
return 0;
}
//my Verbose output class
// Getting arguments G4VSteppingVerbose::SetInstance(new SteppingVerbose);
G4String EventGeneratorFileName = argv[1];
G4String DetectorFileName = argv[2]; //Construct the default run manager
G4RunManager* runManager = new G4RunManager;
//my Verbose output class
G4VSteppingVerbose::SetInstance(new SteppingVerbose); //set mandatory initialization classes
DetectorConstruction* detector = new DetectorConstruction();
//Construct the default run manager runManager->SetUserInitialization(detector);
G4RunManager* runManager = new G4RunManager;
PhysicsList* physics = new PhysicsList();
//set mandatory initialization classes runManager->SetUserInitialization(physics);
DetectorConstruction* detector = new DetectorConstruction(); PrimaryGeneratorAction* primary = new PrimaryGeneratorAction(detector);
runManager->SetUserInitialization(detector);
//Initialize Geant4 kernel
PhysicsList* physics = new PhysicsList(); runManager->Initialize();
runManager->SetUserInitialization(physics); physics->MyOwnConstruction();
PrimaryGeneratorAction* primary = new PrimaryGeneratorAction(detector);
///////////////////////////////////////////////////////////////
//Initialize Geant4 kernel ///////////////// Initializing the Root Output ////////////////
runManager->Initialize(); ///////////////////////////////////////////////////////////////
physics->MyOwnConstruction(); RootOutput::getInstance("Simulation/"+OptionManager->GetOutputFilePath());
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
///////////////// Initializing the Root Output //////////////// ////////////// Reading Detector Configuration /////////////////
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
RootOutput::getInstance("Simulation/mySimul"); detector->ReadConfigurationFile(DetectorFileName);
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
////////////// Reading Detector Configuration ///////////////// ////////////////////// Reading Reaction ///////////////////////
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
detector->ReadConfigurationFile(DetectorFileName); primary->ReadEventGeneratorFile(EventGeneratorFileName);
runManager->SetUserAction(primary);
///////////////////////////////////////////////////////////////
////////////////////// Reading Reaction /////////////////////// ///////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////// ////////////////// Starting the Event Action //////////////////
primary->ReadEventGeneratorFile(EventGeneratorFileName); ///////////////////////////////////////////////////////////////
runManager->SetUserAction(primary); EventAction* event_action = new EventAction() ;
event_action->SetDetector(detector) ;
/////////////////////////////////////////////////////////////// runManager->SetUserAction(event_action) ;
////////////////// Starting the Event Action //////////////////
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
EventAction* event_action = new EventAction() ; /////// Get the pointer to the User Interface manager ////////
event_action->SetDetector(detector) ; ///////////////////////////////////////////////////////////////
runManager->SetUserAction(event_action) ; G4UImanager* UI = G4UImanager::GetUIpointer();
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
/////// Get the pointer to the User Interface manager //////// /////////// Define UI terminal for interactive mode ///////////
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
G4UImanager* UI = G4UImanager::GetUIpointer(); #ifdef G4VIS_USE
G4VisManager* visManager = new G4VisExecutive;
/////////////////////////////////////////////////////////////// visManager->Initialize();
/////////// Define UI terminal for interactive mode /////////// #endif
///////////////////////////////////////////////////////////////
#ifdef G4VIS_USE G4UIsession* session = 0;
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize(); #ifdef G4UI_USE_TCSH
#endif session = new G4UIterminal(new G4UItcsh);
#else
G4UIsession* session = 0; session = new G4UIterminal();
#endif
#ifdef G4UI_USE_TCSH
session = new G4UIterminal(new G4UItcsh); UI->ApplyCommand("/control/execute vis.mac");
#else session->SessionStart();
session = new G4UIterminal(); delete session;
#endif
#ifdef G4VIS_USE
UI->ApplyCommand("/control/execute vis.mac"); delete visManager;
session->SessionStart(); #endif
delete session;
///////////////////////////////////////////////////////////////
#ifdef G4VIS_USE ////////////////////// Job termination ////////////////////////
delete visManager; ///////////////////////////////////////////////////////////////
#endif RootOutput::getInstance()->Destroy();
/////////////////////////////////////////////////////////////// delete runManager;
////////////////////// Job termination //////////////////////// return 0;
/////////////////////////////////////////////////////////////// }
RootOutput::getInstance()->Destroy();
delete runManager;
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment