g4lbnf.cc
Go to the documentation of this file.
1 #include <getopt.h>
2 
3 #include "G4RunManager.hh"
4 #include "G4UImanager.hh"
5 #include "G4UIExecutive.hh"
6 #include "G4UIterminal.hh"
7 #include "G4UItcsh.hh"
8 #ifdef G4VIS_USE_OPENGLQT
9 #include "G4UIQt.hh"
10 #endif
11 #ifdef G4VIS_USE_OPENGLXM
12 #include "G4UIXm.hh"
13 #endif
14 
15 #include "G4ParticleDefinition.hh"
16 #include "G4ParticleTypes.hh"
17 #include "G4DecayTable.hh"
18 #include "G4KL3DecayChannel.hh"
19 #include "G4StepLimiter.hh"
20 #include "G4ParticleTable.hh"
21 
22 #include "G4ProcessManager.hh"
23 #include "G4ParticleDefinition.hh"
24 #include "G4VEnergyLossProcess.hh"
25 
27 
28 // Interaction Physics Lists
29 #include "G4PhysListFactory.hh"
30 
32 #include "LBNEEventAction.hh"
33 #include "LBNEStackingAction.hh"
34 #include "LBNESteppingAction.hh"
35 #include "LBNETrackingAction.hh"
36 #include "LBNERunAction.hh"
37 #include "LBNERunManager.hh"
38 #include "LBNESurveyor.hh"
39 #include "LBNEVolumePlacements.hh"
41 #include "VersionAndContext.hh"
42 
43 #ifdef G4VIS_USE
44 #include "LBNEVisManager.hh"
45 #endif
46 
47 
49 {
50  // Helpful help message goes here
51  G4cout << "" << G4endl;
52  G4cout << "-------------------------------------------------" << G4endl;
53  G4cout << "G4LBNF Help" << G4endl;
54  G4cout << "Usage:" << G4endl;
55  G4cout << " /path/to/g4lbne --input /path/to/inputfile ";
56  G4cout << "--physicslist physlistname /path/to/macrofile" << G4endl;
57  G4cout << "ALTERNATELY: " << G4endl;
58  G4cout << " /path/to/g4lbne -i /path/to/inputfile -p physlistname ";
59  G4cout << "/path/to/macrofile " << G4endl;
60  G4cout << "The default physics list is QGSP_BERT" << G4endl;
61  G4cout << "The options --help or -h display this message " << G4endl;
62  G4cout << "-------------------------------------------------" << G4endl;
63  G4cout << "" << G4endl;
64 }
65 
66 int main(int argc,char** argv)
67 {
68 
69  G4String macroFileName = "";
70  G4String inputFileName = "";
71  G4String physListName = "QGSP_BERT"; // default
72 
74 
75  // Parse Arguments
76  int c;
77  while(1){
78  int option_index = 0;
79  static struct option long_options[] = {
80  {"help", 0, 0, 0},
81  {"input", required_argument, 0, 0},
82  {"physicslist", required_argument, 0, 0},
83  {0,0,0,0}
84  };
85  c = getopt_long(argc, argv, "hi:p:", long_options, &option_index);
86  if(c == -1) break;
87  switch (c) {
88  case 0:
89  switch(option_index){
90  case 0: // --help
91  DisplayHelp();
92  exit(0);
93  case 1: // --input
94  inputFileName = optarg;
95  break;
96  case 2: // --physicslist
97  physListName = optarg;
98  break;
99  }
100  break;
101  case 'h':
102  DisplayHelp();
103  exit(0);
104  break;
105  case 'i':
106  inputFileName = optarg;
107  break;
108  case 'p':
109  physListName = optarg;
110  break;
111  }
112  }
113  if(optind < argc){
114  G4cout << "Setting macroFile to " << argv[argc-1] << G4endl;
115  macroFileName = argv[argc-1];
116  }
117  std::string aNameTmp(macroFileName);
118  versionContext->SetMacroFileName(aNameTmp);
119  std::string aNameTmp2(physListName);
120  versionContext->SetPhysicsList(aNameTmp2);
121 
122  // Invoke both the Surveoyr class and the Volume placement
123  // such the internal variable are define and the messenger are set
124  // prior to declare a run
125 
127 // std::cerr << " LBNESurveyor created " << std::endl;
128 
131 
132 // The class that sets up the geometry..
133 
135 
136  // get the pointer to the UI manager and set verbosities
137  G4UImanager* UI = G4UImanager::GetUIpointer();
138 
139  // Construct the default run manager
140  LBNERunManager* runManager = new LBNERunManager();
141 
142  runManager->SetPhysicsListName(physListName);
143 
144  runManager->SetUserInitialization(theDetector);
145  // set user action classes
146 
147 #ifdef G4VIS_USE
148  // Visualization, if you choose to have it!
149  G4VisManager* visManager = new LBNEVisManager;
150  visManager->Initialize();
151 #endif
152 
153  if(argc==1)
154  // Define (G)UI terminal for interactive mode
155  {
156  /*
157  G4UIsession * session = 0;
158 
159  // G4UIterminal is a (dumb) terminal.
160 #ifdef G4UI_USE_TCSH
161  session = new G4UIterminal(new G4UItcsh);
162 #else
163  session = new G4UIterminal();
164 #endif
165 
166  session->SessionStart();
167  delete session;
168  */
169  // G4UIExecutive* ui = new G4UIExecutive(argc,argv,"tcsh");
170  G4UIExecutive* ui = new G4UIExecutive(argc,argv);
171  ui->SessionStart();
172  delete ui;
173 
174  }
175  else // Batch mode
176  {
177  G4String command = "/control/execute ";
178  G4cout << "Executing " << command+macroFileName << G4endl;
179  UI->ApplyCommand(command+macroFileName);
180  }
181 
182 # // job termination
183  G4cout<<"Delete RunManager"<<G4endl;
184  delete runManager;
185  return 0;
186 }
187 
188 
void SetPhysicsList(std::string &val)
std::string string
Definition: nybbler.cc:12
static LBNEVolumePlacements * Instance()
int command
static VersionAndContext * Instance()
static LBNESurveyor * Instance()
void DisplayHelp()
Definition: g4lbnf.cc:48
void SetPhysicsListName(G4String &t)
void SetMacroFileName(std::string &val)
int main(int argc, char **argv)
Definition: g4lbnf.cc:66
static LBNEPlacementMessenger * Instance()