-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathprex_sim.cc
164 lines (131 loc) · 4.74 KB
/
prex_sim.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#include "MollerDetectorConstruction.hh"
#include "MollerGlobalMagnetField.hh"
#include "PhysicsList.hh"
#include "MollerPrimaryGenAction.hh"
#include "MollerRunAction.hh"
#include "MollerEventAction.hh"
#include "MollerSteppingAction.hh"
#include "G4Version.hh"
#if G4VERSION_NUMBER < 1000
#include "G4StepLimiterBuilder.hh"
#else
#include "G4StepLimiterPhysics.hh"
#endif
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIterminal.hh"
#include "G4UItcsh.hh"
#include "G4PhysListFactory.hh"
#include "G4VModularPhysicsList.hh"
#include "PhysicsListMessenger.hh"
// user interface
#ifdef G4UI_USE_QT
#include "G4UIQt.hh"
#include "G4Qt.hh"
#endif
#include "G4UIExecutive.hh"
#include "G4VisExecutive.hh"
#include <time.h>
#include <fstream>
#include "MollerAnalysis.hh"
int main(int argc, char** argv)
{
clock_t tStart=clock();
// Construct the default Run Manager
//
G4RunManager* runManager = new G4RunManager;
// Mandatory User Initialization classes
//
MollerDetectorConstruction* detector = new MollerDetectorConstruction;
runManager->SetUserInitialization(detector);
G4PhysListFactory factory;
G4VModularPhysicsList* phys = 0;
PhysicsListMessenger* mess = 0;
G4String physName = "QGSP_BERT_HP";
G4int verbose=0;
if(factory.IsReferencePhysList(physName)) {
phys = factory.GetReferencePhysList(physName);
phys->SetVerboseLevel(verbose);
#if G4VERSION_NUMBER < 1000
phys->RegisterPhysics(new G4StepLimiterBuilder(verbose));
#else
phys->RegisterPhysics(new G4StepLimiterPhysics());
#endif
mess = new PhysicsListMessenger();
}
// define physics
runManager->SetUserInitialization(phys);
// User Action Classes
//
runManager->SetUserAction(new MollerPrimaryGenAction);
runManager->SetUserAction(new MollerRunAction);
runManager->SetUserAction(new MollerEventAction);
runManager->SetUserAction(new MollerSteppingAction);
// Get the pointer to the User Interface manager
G4UImanager* UImanager = G4UImanager::GetUIpointer();
if (argc > 2) // batch mode
{
G4cout << "==========================================================="<< G4endl;
G4cout << "Batch mode"<< G4endl;
G4cout << "==========================================================="<< G4endl;
G4String command = "/control/execute ";
G4String fileName = argv[1];
G4String fileName2 = argv[2];
UImanager->ApplyCommand(command+fileName);
// Start analysis
//
MollerAnalysis* analysis = new MollerAnalysis(detector);
//pass the GDML and macro files here
analysis->AddGDMLFileName(detector->GetDetectorGeomFile());
analysis->AddMacro_1(fileName);
analysis->AddMacro_2(fileName2);
analysis->SetLowLimMagneticShield(detector->GetLowLimMagneticShield());
analysis->SetHighLimMagneticShield(detector->GetHighLimMagneticShield());
analysis->SetMagFieldScaleFactor(detector->GetMagFieldScaleFactor());
// Initialize G4 kernel
//
runManager->Initialize();
// Get condition of run from second macro
//
UImanager->ApplyCommand(command+fileName2);
// End analysis
//
analysis->End();
delete analysis;
}
else if (argc == 2)
{ // interactive mode : define UI session
G4cout << "==========================================================="<< G4endl;
G4cout << "Interactive mode"<< G4endl;
G4cout << "==========================================================="<< G4endl;
G4String command = "/control/execute ";
G4String fileName = argv[1];
UImanager->ApplyCommand(command+fileName);
G4UIExecutive* ui = new G4UIExecutive(argc, argv);
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
UImanager->ApplyCommand("/control/macroPath macros");
UImanager->ApplyCommand("/control/execute vis/vis.mac");
//#endif
if (ui->IsGUI()){
UImanager->ApplyCommand("/control/macroPath macros");
UImanager->ApplyCommand("/control/execute gui.mac");
}
ui->SessionStart();
delete ui;
delete visManager;
} else {
G4cout << G4endl<< G4endl;
G4cout << "==========================================================="<< G4endl;
G4cout << "Please specify the prerun macro, or live with the defaults!"<< G4endl;
G4cout << "==========================================================="<< G4endl;
G4cout << G4endl<< G4endl;
}
// Job termination
// Free the store: user actions, physics_list and detector_description are
// owned and deleted by the run manager, so they should not
// be deleted in the main() program !
delete runManager;
G4cout<<" Running time[s]: "<< (double) ((clock() - tStart)/CLOCKS_PER_SEC)<<G4endl;
return 0;
}