-
Notifications
You must be signed in to change notification settings - Fork 0
/
NuSD.cc
211 lines (178 loc) · 6.98 KB
/
NuSD.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
//***********************************************************************
//* Neutrino Segmented Detector (NuSD) Copyright 2022 Mustafa Kandemir *
//* *
//* This file is part of NuSD. *
//* *
//* NuSD is free software: you can redistribute it and/or modify *
//* it under the terms of the GNU General Public License as published *
//* by the Free Software Foundation, either version 3 of the License, *
//* or any later version. *
//* *
//* NuSD is distributed in the hope that it will be useful, but *
//* WITHOUT ANY WARRANTY; without even the implied warranty of *
//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
//* GNU General Public License for more details. *
//* *
//* You should have received a copy of the GNU General Public License *
//* along with NuSD. If not, see <https://www.gnu.org/licenses/>. *
//* *
//***********************************************************************
// --------------------------------------------------------------
// NuSD (Neutrino Segmented Detector)
// --------------------------------------------------------------
//
// Code developed by Mustafa Kandemir
//
// *******************************
// * *
// * NuSD.cc *
// * *
// *******************************
#include "NuSD_config.h"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#if DETECTOR_NAME == CHANDLER
#include "NuSDChandlerDetConstruction.hh"
#elif DETECTOR_NAME == SWEANY
#include "NuSDSweanyDetConstruction.hh"
#elif DETECTOR_NAME == SOLID
#include "NuSDSolidDetConstruction.hh"
#elif DETECTOR_NAME == NULAT
#include "NuSDNulatDetConstruction.hh"
#elif DETECTOR_NAME == PANDA
#include "NuSDPandaDetConstruction.hh"
#elif DETECTOR_NAME == PROSPECT
#include "NuSDProspectDetConstruction.hh"
#elif DETECTOR_NAME == HSP
#include "NuSDHspDetConstruction.hh"
#endif
#include "NuSDPhysicsList.hh"
//#include "G4OpticalPhysics.hh"
//#include "FTFP_BERT_HP.hh"
//#include "QGSP_BERT_HP.hh"
//#include "QGSP_BIC_HP.hh"
#include "NuSDActionInitialization.hh"
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
#else
#include "G4RunManager.hh"
#endif
#include "G4UImanager.hh"
#include "G4UIExecutive.hh"
#include "G4VisExecutive.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
namespace {
void PrintUsage()
{
G4cerr << " Usage: " << G4endl;
G4cerr << " NuSD [-b batch ] [-i interactive] [-t nThreads] [-r seed] "
<< G4endl;
G4cerr << " note: -t option is available only for multi-threaded mode."
<< G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// argc holds the number of arguments (including the name) on the command line
// -> it is ONE when only the name is given !!!
// argv[0] is always the name of the program
// argv[1] points to the first argument, and so on
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int main(int argc, char** argv)
{
// Evaluate arguments
if ( argc > 9 ) {
PrintUsage();
return 1;
}
G4String batchMacro;
G4String interactiveMacro;
#ifdef G4MULTITHREADED
G4int nThreads = 0;
#endif
G4long myseed = 345354;
for ( G4int i=1; i<argc; i=i+2 )
{
if ( G4String(argv[i]) == "-b" ) batchMacro = argv[i+1];
else if ( G4String(argv[i]) == "-i" ) interactiveMacro = argv[i+1];
else if ( G4String(argv[i]) == "-r" ) myseed = atoi(argv[i+1]);
#ifdef G4MULTITHREADED
else if ( G4String(argv[i]) == "-t" )
{
nThreads = G4UIcommand::ConvertToInt(argv[i+1]);
G4cout<<"Number of threads: "<<nThreads<<G4endl;
}
#endif
else
{
PrintUsage();
return 1;
}
}
// Instantiate G4UIExecutive if interactive mode
G4UIExecutive* ui = nullptr;
if ( batchMacro.size() == 0 )
{
ui = new G4UIExecutive(argc, argv);
}
// Choose the Random engine
G4Random::setTheEngine(new CLHEP::RanecuEngine);
#ifdef G4MULTITHREADED
G4cout << "Using the MT Run Manager (G4MULTITHREADED=ON)" << G4endl;
G4MTRunManager* runManager = new G4MTRunManager();
if ( nThreads > 0 ) runManager->SetNumberOfThreads(nThreads);
#else
G4RunManager * runManager = new G4RunManager;
G4cout << "Using the sequential Run Manager" << G4endl;
#endif
// Seed the random number generator manually
G4Random::setTheSeed(myseed);
#if DETECTOR_NAME == CHANDLER
runManager->SetUserInitialization(new NuSDChandlerDetConstruction());
#elif DETECTOR_NAME == SWEANY
runManager->SetUserInitialization(new NuSDSweanyDetConstruction());
#elif DETECTOR_NAME == SOLID
runManager->SetUserInitialization(new NuSDSolidDetConstruction() );
#elif DETECTOR_NAME == NULAT
runManager->SetUserInitialization(new NuSDNulatDetConstruction());
#elif DETECTOR_NAME == PANDA
runManager->SetUserInitialization(new NuSDPandaDetConstruction());
#elif DETECTOR_NAME == PROSPECT
runManager->SetUserInitialization(new NuSDProspectDetConstruction());
#elif DETECTOR_NAME == HSP
runManager->SetUserInitialization(new NuSDHspDetConstruction());
#endif
runManager->SetUserInitialization(new NuSDPhysicsList());
runManager->SetUserInitialization(new NuSDActionInitialization());
// Initialize visualization
// G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
// get the pointer to the UI manager and set verbosities
G4UImanager* uImanager = G4UImanager::GetUIpointer();
uImanager->ApplyCommand("/control/execute macros/common.mac");
if ( batchMacro.size() ) // Batch mode
{
G4String command = "/control/execute macros/";
uImanager->ApplyCommand(command+batchMacro);
uImanager->ApplyCommand("/control/execute macros/run.mac");
}
else if ( interactiveMacro.size() )// Define UI session Macro for interactive mode
{
runManager->SetNumberOfThreads(1);
G4String command = "/control/execute macros/";
uImanager->ApplyCommand(command+interactiveMacro);
uImanager->ApplyCommand("/control/execute macros/vis.mac");
ui->SessionStart();
delete ui;
}else // Define UI session Macro for default interactive mode
{
uImanager->ApplyCommand("/run/initialize");
uImanager->ApplyCommand("/control/execute macros/vis.mac");
ui->SessionStart();
delete ui;
}
delete visManager;
delete runManager;
return 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......