#include "version.h" #include "musrDetectorConstruction.hh" #include "musrPhysicsList.hh" #include "musrPrimaryGeneratorAction.hh" #include "musrRunAction.hh" #include "musrEventAction.hh" #include "musrStackingAction.hh" #include "musrSteppingAction.hh" #include "musrSteppingVerbose.hh" #include "Randomize.hh" #include "G4RunManager.hh" #include "G4UImanager.hh" #include "G4UIterminal.hh" #include "G4UItcsh.hh" //JSL: should be commented on windows ? // The following two lines are needed to cope with the problem of // "Error in : Cannot find plugin handler for TVirtualStreamerInfo! // Does $ROOTSYS/etc/plugins/TVirtualStreamerInfo exist?" #include "TROOT.h" #include "TPluginManager.h" #include "G4VisExecutive.hh" #include "G4TrajectoryDrawByCharge.hh" // TS Trajectory drawing by ID or charge #include "musrRootOutput.hh" #include "musrParameters.hh" #include "musrErrorMessage.hh" #include #include int main(int argc, char **argv) { G4String steeringFileName; G4cout << "\n\n*************************************************************" << G4endl; G4cout << " musrSim version " << MUSRSIM_VERSION << " for Geant 11.4" << G4endl; G4cout << " WWW: https://www.psi.ch/lmu/geant4-simulations\n" << G4endl; if (argc > 1) { steeringFileName = argv[1]; } else { G4cerr << "Usage: " << argv[0] << " [idle]" << G4endl; return 1; } // choose the Random engine G4Random::setTheEngine(new CLHEP::HepJamesRandom); // my Verbose output class G4VSteppingVerbose::SetInstance(new musrSteppingVerbose); // Run manager auto runManager = std::make_unique(); // Create class "myParameters", which is a collection of many different parameters auto myParameters = std::make_unique(steeringFileName); // Create class "musrErrorMessage" auto myErrorMessage = std::make_unique(); // Create Root class for storing the output of the Geant simulation auto myRootOutput = std::make_unique(); // The following command is needed to cope with the problem of // "Error in : Cannot find plugin handler for TVirtualStreamerInfo! // Does $ROOTSYS/etc/plugins/TVirtualStreamerInfo exist?" // /* magic line from Rene - for future reference! */ gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", "*", "TStreamerInfo", "RIO", "TStreamerInfo()"); // UserInitialization classes (mandatory) if (argc > 1) { G4int myRunNr = std::atoi(argv[1]); // Get the run number from the name of the // parameter file, if it starts with a number. if (myRunNr > 0) { runManager->SetRunIDCounter(myRunNr); } } // Keep raw pointer for cross-object writing but in principle object should be owned by runManager // after the next line auto musrdetector = new musrDetectorConstruction(steeringFileName); runManager->SetUserInitialization(musrdetector); runManager->SetUserInitialization(new musrPhysicsList); // Visualization, if you choose to have it! auto visManager = std::make_unique(); visManager->Initialize(); // UserAction classes runManager->SetUserAction(new musrPrimaryGeneratorAction(musrdetector)); runManager->SetUserAction(new musrRunAction); runManager->SetUserAction(new musrEventAction); // Initiate musrStackingAction only if optical photons are required (otherwise not needed) if (musrParameters::boolG4OpticalPhotons) runManager->SetUserAction(new musrStackingAction); runManager->SetUserAction(new musrSteppingAction); // Initialize G4 kernel runManager->Initialize(); // get the pointer to the User Interface manager G4UImanager *UI = G4UImanager::GetUIpointer(); // Define (G)UI terminal for interactive mode if (argc == 1) { auto session = std::make_unique(); UI->ApplyCommand("/control/execute vis.mac"); session->SessionStart(); } else { G4String command = "/control/execute "; G4String fileName = argv[1]; UI->ApplyCommand(command + fileName); if (argc > 2) { G4String SecondArgument = argv[2]; if (SecondArgument == "idle") { auto session = std::make_unique(); G4cout << "Go to idle state now:" << G4endl; session->SessionStart(); } } } return 0; }