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