QwGeant4
QweakSimG4.cc
Go to the documentation of this file.
1 //=============================================================================
2 //
3 // ---------------------------
4 // | Doxygen File Information |
5 // ---------------------------
6 //
7 /**
8 
9  \file QweakSimG4.cc
10 
11  $Revision: 1.2 $
12  $Date: 2005/12/27 19:09:32 $
13 
14  \author Klaus Hans Grimm
15 
16 */
17 //=============================================================================
18 
19 // geant4 includes
20 #include "G4RunManager.hh"
21 #include "G4UImanager.hh"
22 #include "G4UIterminal.hh"
23 #include "G4UItcsh.hh"
24 
25 #include "G4Version.hh"
26 #if G4VERSION_NUMBER < 1000
27 #include "G4StepLimiterBuilder.hh"
28 #else
29 #include "G4StepLimiterPhysics.hh"
30 #endif
31 
32 #include "G4OpticalPhysics.hh"
33 #include "G4PhysListFactory.hh"
34 #include "G4VModularPhysicsList.hh"
35 
36 #ifdef G4UI_USE_QT
37  #include "G4UIQt.hh"
38 #endif
39 
40 #ifdef G4UI_USE_XM
41  #include "G4UIXm.hh"
42 #endif
43 
44 #ifdef G4VIS_USE
45  #include "G4VisExecutive.hh"
46 #endif
47 #include "G4UIExecutive.hh"
48 
49 
50 // user includes
54 #include "QweakSimRunAction.hh"
55 #include "QweakSimEventAction.hh"
60 #include "QweakSimAnalysis.hh"
61 #include "QweakSimEPEvent.hh"
62 
63 #define USE_CUSTOM_NUCLEAR_SCATTERING 0
64 #if USE_CUSTOM_NUCLEAR_SCATTERING
67 #endif
68 
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70 
71 int main(int argc,char** argv) {
72 
73  // Verbose output class
74  //G4VSteppingVerbose::SetInstance( new QweakSimSteppingVerbose() );
75 
76  // Run manager
77  G4RunManager * runManager = new G4RunManager();
78 
79  // UserInitialization classes (mandatory)
80  QweakSimUserInformation* myQweakSimUserInformation = new QweakSimUserInformation();
81  QweakSimDetectorConstruction* myQweakSimExperiment = new QweakSimDetectorConstruction(myQweakSimUserInformation);
82  QweakSimAnalysis* myQweakSimAnalysis = new QweakSimAnalysis(myQweakSimUserInformation);
83 
84 //jpan@nuclear.uwinnipeg.ca
85  QweakSimEPEvent* myEPEvent = new QweakSimEPEvent(myQweakSimUserInformation);
86 
87  runManager->SetUserInitialization(myQweakSimExperiment);
88 
89 
90  // Calls a reference physics list for the simulation
91  G4PhysListFactory factory;
92  G4VModularPhysicsList* physlist = factory.GetReferencePhysList("QGSP_BERT_LIV");
93  physlist->RegisterPhysics(new G4OpticalPhysics());
94  #if G4VERSION_NUMBER < 1000
95  physlist->RegisterPhysics(new G4StepLimiterBuilder());
96  #else
97  physlist->RegisterPhysics(new G4StepLimiterPhysics());
98  #endif
99  // Replace the standard EM with the customized version to add Pb A_T
100  #if USE_CUSTOM_NUCLEAR_SCATTERING
101  physlist->ReplacePhysics(new QweakSimEmLivermorePhysics());
102  #endif
103 
104  runManager->SetUserInitialization(physlist);
105 
106  // Original Qweak Physics List, uncomment to use and add correct #include lines
107  //runManager->SetUserInitialization(new QweakSimPhysicsList() );
108 
109  // UserAction classes
110  runManager->SetUserAction( new QweakSimPrimaryGeneratorAction(myQweakSimUserInformation, myEPEvent) );
111  //runManager->SetUserAction( new QweakSimPrimaryGeneratorAction( ) );
112  runManager->SetUserAction( new QweakSimSteppingAction(myQweakSimUserInformation, myEPEvent));
113  runManager->SetUserAction( new QweakSimStackingAction() );
114  runManager->SetUserAction( new QweakSimTrackingAction(myQweakSimUserInformation) );
115  runManager->SetUserAction( new QweakSimEventAction(myQweakSimAnalysis, myQweakSimUserInformation) );
116  runManager->SetUserAction( new QweakSimRunAction(myQweakSimAnalysis) );
117 
118  runManager->StoreRandomNumberStatusToG4Event(1);
119 
120  //Initialize G4 kernel
121  runManager->Initialize();
122  G4UIsession* session = 0;
123 
124  if (argc==1) // Define UI session for interactive mode.
125  {
126 
127  // G4UIterminal is a (dumb) terminal.
128  #if defined(G4UI_USE_QT)
129  session = new G4UIQt(argc,argv);
130  #elif defined(G4UI_USE_XM)
131  session = new G4UIXm(argc,argv);
132  #elif defined(G4UI_USE_WIN32)
133  session = new G4UIWin32();
134  #elif defined(G4UI_USE_TCSH)
135  session = new G4UIterminal(new G4UItcsh);
136  #else
137  session = new G4UIterminal();
138  #endif
139 
140  }
141 
142 
143 #ifdef G4VIS_USE
144  // Visualization, if you choose to have it!
145  //
146  // Simple graded message scheme - give first letter or a digit:
147  // 0) quiet, // Nothing is printed.
148  // 1) startup, // Startup and endup messages are printed...
149  // 2) errors, // ...and errors...
150  // 3) warnings, // ...and warnings...
151  // 4) confirmations, // ...and confirming messages...
152  // 5) parameters, // ...and parameters of scenes and views...
153  // 6) all // ...and everything available.
154 
155  G4VisManager* visManager = new G4VisExecutive;
156  //visManager -> SetVerboseLevel (1);
157  visManager ->Initialize();
158 #endif
159 
160 
161  //get the pointer to the User Interface manager
162  G4UImanager * UI = G4UImanager::GetUIpointer();
163 
164  if (session) // Define UI session for interactive mode.
165  {
166  // G4UIterminal is a (dumb) terminal.
167  //UI->ApplyCommand("/control/execute myVis.mac");
168 
169 #if defined(G4UI_USE_XM) || defined(G4UI_USE_WIN32) || defined(G4UI_USE_QT)
170  // Customize the G4UIXm,Win32 menubar with a macro file :
171  UI->ApplyCommand("/control/execute gui.mac");
172 #endif
173 
174  session->SessionStart();
175  delete session;
176  }
177  else // Batch mode
178  {
179 #ifdef G4VIS_USE
180  visManager->SetVerboseLevel("quiet");
181 #endif
182  G4String command = "/control/execute ";
183  G4String fileName = argv[1];
184  UI->ApplyCommand(command+fileName);
185  }
186 
187 
188 
189 #ifdef G4VIS_USE
190  delete visManager;
191 #endif
192 
193  delete runManager;
194  delete myEPEvent;
195 
196  return 0;
197 }
198 
199 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
200 
201 
main class of QweakSim. All experiment components are are placed here.
Deal with primary particle generation and inject it in the detector.
Adds additional information to primary/secondary track before track starts stepping.
Defines actions at the beginning and the end of run.
Handling of the output ROOT file.
int main(int argc, char **argv)
Definition: Hadr00.cc:69
Mainly filling/storing the hit event structure at the end of an event.