LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
PurgMag.cc File Reference
#include "G4Types.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "Randomize.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "PurgMagDetectorConstruction.hh"
#include "PurgMagPhysicsList.hh"
#include "PurgMagActionInitializer.hh"
#include "PurgMagAnalysisManager.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 56 of file PurgMag.cc.

56  {
57 
58  //choose the Random engine
59  G4Random::setTheEngine(new CLHEP::RanecuEngine);
60 
61  // Construct the default run manager
62 #ifdef G4MULTITHREADED
63  G4MTRunManager* runManager = new G4MTRunManager;
64  //runManager->SetNumberOfThreads(2);
65 #else
66  G4RunManager* runManager = new G4RunManager;
67 #endif
68 
69  // set mandatory initialization classes
70  runManager->SetUserInitialization(new PurgMagDetectorConstruction);
71  runManager->SetUserInitialization(new PurgMagPhysicsList);
72  runManager->SetUserInitialization(new PurgMagActionInitializer());
73 
74  // visualization manager
75  G4VisManager* visManager = new G4VisExecutive;
76  visManager->Initialize();
77 
78  //Initialize G4 kernel
79  runManager->Initialize();
80 
81  // get the pointer to the User Interface manager
82  G4UImanager* UImanager = G4UImanager::GetUIpointer();
83 
84 
85  if (argc==1) // Define UI session for interactive mode.
86  {
87  G4UIExecutive* ui = new G4UIExecutive(argc, argv);
88  UImanager->ApplyCommand("/control/execute vis.mac");
89  ui->SessionStart();
90  delete ui;
91  }
92  else // Batch mode
93  {
94  G4String command = "/control/execute ";
95  G4String fileName = argv[1];
96  UImanager->ApplyCommand(command+fileName);
97  }
98 
99  // Save histograms
100  G4AnalysisManager* man = G4AnalysisManager::Instance();
101  man->Write();
102  man->CloseFile();
103 
104  // job termination
105  delete visManager;
106 
107  delete runManager;
108 
109  return 0;
110 }