forked from WCSim/WCSim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWCSim.cc
More file actions
137 lines (105 loc) · 4.06 KB
/
Copy pathWCSim.cc
File metadata and controls
137 lines (105 loc) · 4.06 KB
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
#include "G4ios.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "G4UIterminal.hh"
#include "G4UItcsh.hh"
#include "WCSimDetectorConstruction.hh"
#include "WCSimPhysicsList.hh"
#include "WCSimPhysicsMessenger.hh"
#include "WCSimPhysicsListFactory.hh"
#include "WCSimPhysicsListFactoryMessenger.hh"
#include "WCSimTuningParameters.hh"
#include "WCSimTuningMessenger.hh"
#include "WCSimPrimaryGeneratorAction.hh"
#include "WCSimEventAction.hh"
#include "WCSimRunAction.hh"
#include "WCSimStackingAction.hh"
#include "WCSimTrackingAction.hh"
#include "WCSimSteppingAction.hh"
#include "WCSimVisManager.hh"
#include "WCSimRandomParameters.hh"
#include <iostream>
void file_exists(const char * filename) {
bool exists = access(filename, F_OK) != -1;
if(!exists) {
G4cerr << filename << " not found or inaccessible. Exiting" << G4endl;
exit(-1);
}
}
int main(int argc,char** argv)
{
// Construct the default run manager
G4RunManager* runManager = new G4RunManager;
// get the pointer to the UI manager
G4UImanager* UI = G4UImanager::GetUIpointer();
// Set up the tuning parameters that need to be read before the detector
// construction is done
WCSimTuningParameters* tuningpars = new WCSimTuningParameters();
// Get the tuning parameters
file_exists("tuning_parameters.mac");
UI->ApplyCommand("/control/execute tuning_parameters.mac");
// define random number generator parameters
WCSimRandomParameters *randomparameters = new WCSimRandomParameters();
// UserInitialization classes (mandatory)
enum DetConfiguration {wfm=1,fwm=2};
G4int WCSimConfiguration = fwm;
WCSimDetectorConstruction* WCSimdetector = new
WCSimDetectorConstruction(WCSimConfiguration,tuningpars);
runManager->SetUserInitialization(WCSimdetector);
// Added selectable physics lists 2010-07 by DMW
// Set up the messenger hooks here, initialize the actual list after loading jobOptions.mac
WCSimPhysicsListFactory *physFactory = new WCSimPhysicsListFactory();
// Currently, default model is set to BINARY
file_exists("jobOptions.mac");
UI->ApplyCommand("/control/execute jobOptions.mac");
// Initialize the physics factory to register the selected physics.
physFactory->InitializeList();
runManager->SetUserInitialization(physFactory);
// If the WCSim physics list was chosen in jobOptions.mac,
// then it's hadronic model needs to be selected in jobOptions2.mac
//=================================
// Added by JLR 2005-07-05
//=================================
// Choice of hadronic interaction model for
// protons & neutrons. This file must be read in
// by the program BEFORE the runManager is initialized.
// If file does not exist, default model will be used.
// Currently, default model is set to BINARY.
file_exists("jobOptions2.mac");
UI->ApplyCommand("/control/execute jobOptions2.mac");
// Visualization
G4VisManager* visManager = new WCSimVisManager;
visManager->Initialize();
// Set user action classes
WCSimPrimaryGeneratorAction* myGeneratorAction = new
WCSimPrimaryGeneratorAction(WCSimdetector);
runManager->SetUserAction(myGeneratorAction);
WCSimRunAction* myRunAction = new WCSimRunAction(WCSimdetector);
runManager->SetUserAction(myRunAction);
runManager->SetUserAction(new WCSimEventAction(myRunAction, WCSimdetector,
myGeneratorAction));
runManager->SetUserAction(new WCSimTrackingAction);
runManager->SetUserAction(new WCSimStackingAction(WCSimdetector));
runManager->SetUserAction(new WCSimSteppingAction);
// Initialize G4 kernel
runManager->Initialize();
if (argc==1) // Define UI terminal for interactive mode
{
// Start UI Session
G4UIsession* session = new G4UIterminal(new G4UItcsh);
// Visualization Macro
UI->ApplyCommand("/control/execute vis.mac");
// Start Interactive Mode
session->SessionStart();
delete session;
}
else // Batch mode
{
G4String command = "/control/execute ";
G4String fileName = argv[1];
UI->ApplyCommand(command+fileName);
}
delete visManager;
delete runManager;
return 0;
}