source: branches/Corsika7500Compatibility/mirrorSimulation.cc@ 18481

Last change on this file since 18481 was 18451, checked in by ftemme, 9 years ago
Added the new program mirrorSimulation which performs the simulation of the reflector. Adapted the Makefiles and added the corresponding mjob MJSimReflector
File size: 7.3 KB
Line 
1/////////////////////////////////////////////////////////////////////////////
2//
3// mirrorSimulation
4//
5//
6// This program performs a simulation of the mirrors (in detail all processes up
7// to the camera front window.
8//
9// It is meaned only for test purposes of the mirror simulation. At the moment it
10// is a copy of the normal ceres simulation (revision 18447), with all processor removed behind
11// MSimAbsorption absapd (so the absorption by the pde of the SiPMs).
12//
13// It doesn't provide any graphical output, and the only output is a ASCII file
14// with the information of the photons.
15//
16//
17/////////////////////////////////////////////////////////////////////////////
18
19#include <TClass.h>
20#include <TSystem.h>
21#include <TApplication.h>
22#include <TObjectTable.h>
23
24#include <TVector2.h>
25
26#include "MArray.h"
27
28#include "MLog.h"
29#include "MLogManip.h"
30
31#include "MStatusDisplay.h"
32
33#include "MEnv.h"
34#include "MArgs.h"
35#include "MDirIter.h"
36
37#include "MJSimReflector.h"
38
39
40using namespace std;
41
42static void StartUpMessage()
43{
44 gLog << all << endl;
45
46 // 1 2 3 4 5
47 // 12345678901234567890123456789012345678901234567890
48 gLog << "====================================================" << endl;
49 gLog << " MirrorSimulation - MARS V" << MARSVER << endl;
50 gLog << " MARS - Camera Electronics and REflector Simulation" << endl;
51 gLog << " Compiled with ROOT v" << ROOT_RELEASE << " on <" << __DATE__ << ">" << endl;
52 gLog << "====================================================" << endl;
53 gLog << endl;
54}
55
56static void Usage()
57{
58 gLog << all << endl;
59 gLog << "Sorry the no usage description at the moment:" << endl;
60}
61
62
63int main(int argc, char **argv)
64{
65 if (!MARS::CheckRootVer())
66 return 0xff;
67
68 MLog::RedirectErrorHandler(MLog::kColor);
69
70 //
71 // Evaluate arguments
72 //
73 MArgs arg(argc, argv);
74 gLog.Setup(arg);
75
76 StartUpMessage();
77
78 if (arg.HasOnly("-V") || arg.HasOnly("--version"))
79 return 0;
80
81 if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
82 {
83 Usage();
84 return 2;
85 }
86
87 const Bool_t kForce = arg.HasOnlyAndRemove("-ff");
88 const Bool_t kOverwrite = arg.HasOnlyAndRemove("-f");
89 const Bool_t kBatch = kTRUE;
90
91 const TString kConfig = arg.GetStringAndRemove("--config=", "reflector.rc");
92 const TString kInpath = arg.GetStringAndRemove("--ind=", "");
93 const TString kOutpath = arg.GetStringAndRemove("--out=", ".");
94 const TString kOutfile = arg.GetStringAndRemove("--outf=", "");
95
96 const Int_t kRunNumber = arg.GetIntAndRemove("--run-number=", -1);
97
98 const TString kOpMode = arg.GetStringAndRemove("--mode=", "data");
99
100 Int_t opmode = -1;
101 if (TString("data").BeginsWith(kOpMode, TString::kIgnoreCase))
102 opmode = MJSimReflector::kModeData;
103 if (TString("pointrun").BeginsWith(kOpMode, TString::kIgnoreCase))
104 opmode = MJSimReflector::kModePointRun;
105 if (TString("pedestal").BeginsWith(kOpMode, TString::kIgnoreCase))
106 opmode = MJSimReflector::kModePed;
107 if (TString("calibration").BeginsWith(kOpMode, TString::kIgnoreCase))
108 opmode = MJSimReflector::kModeCal;
109
110 if (opmode<0)
111 {
112 gLog << err << "ERROR - Wrong mode specified..." << endl;
113 Usage();
114 return 2;
115 }
116
117 //
118 // check for the right usage of the program (number of arguments)
119 if (arg.GetNumArguments()<1 && opmode==MJSimReflector::kModeData)
120 {
121 gLog << warn << "WARNING - Wrong number of arguments..." << endl;
122 Usage();
123 return 2;
124 }
125
126 if (arg.GetNumArguments()>0 && opmode!=MJSimReflector::kModeData)
127 {
128 gLog << warn << "WARNING - No arguments allowed in this mode..." << endl;
129 Usage();
130 return 2;
131 }
132
133 //
134 // Now we access/read the resource file. This will remove all
135 // --rc= from the list of arguments.
136 //
137 MEnv env(kConfig, "ceres.rc");
138 if (!env.IsValid())
139 {
140 gLog << err << "ERROR - Reading resource file " << kConfig << "." << endl;
141 return 0xfe;
142 }
143
144 //
145 // check for the right usage of the program (number of options)
146 //
147 if (arg.GetNumOptions()>0)
148 {
149 gLog << warn << "WARNING - Unknown commandline options..." << endl;
150 arg.Print("options");
151 gLog << endl;
152 return 2;
153 }
154
155 //
156 // Setup sequence file and check for its existance
157 //
158 TString kSequence = arg.GetNumArguments()==1 ? arg.GetArgumentStr(0) : "";
159
160 //
161 // Check if the first argument (if any) is a sequence file or not
162 //
163 if (!kSequence.EndsWith(".txt"))
164 kSequence = "";
165
166 //
167 // Something special for datacenter access
168 //
169 if (!kSequence.IsNull() && !MSequence::InflateSeq(kSequence, kTRUE))
170 return 2;
171
172 //
173 // Setup sequence and check its validity
174 //
175 MSequence seq(kSequence, kInpath);
176 if (!kSequence.IsNull())
177 {
178// if (kPrintSeq)
179// {
180// gLog << all;
181// gLog.Separator(kSequence);
182// seq.Print();
183// gLog << endl;
184// }
185 if (seq.IsValid() && !seq.IsMonteCarlo())
186 {
187 gLog << err << "Sequence is not a Monte Carlo Sequence." << endl << endl;
188 return 2;
189 }
190 if (!seq.IsValid())
191 {
192 gLog << err << "Sequence read but not valid!" << endl << endl;
193 return 2;
194 }
195
196 //
197 // Process print options
198 //
199// if (kPrintFiles)
200// PrintFiles(seq, kInpath, kFALSE);
201// if (kPrintFound)
202// PrintFiles(seq, kInpath, kTRUE);
203 }
204 else
205 {
206// if (kPrintFiles)
207// PrintFiles(arg, kFALSE);
208// if (kPrintFound)
209// PrintFiles(arg, kTRUE);
210 }
211
212 //
213 // Initialize root
214 //
215 TVector2::Class()->IgnoreTObjectStreamer();
216 MArray::Class()->IgnoreTObjectStreamer();
217 MParContainer::Class()->IgnoreTObjectStreamer();
218
219 TApplication app("reflector", &argc, argv);
220 if ((!gROOT->IsBatch() && !gClient) || (gROOT->IsBatch() && !kBatch))
221 {
222 gLog << err << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
223 return 1;
224 }
225
226 {
227 MJSimReflector job("SimReflector");
228 //job.SetSequence(seq);
229 job.SetEnv(&env);
230 job.SetOverwrite(kOverwrite);
231 job.SetPathOut(kOutpath);
232 job.SetFileOut(kOutfile);
233 job.SetForceMode(kForce);
234 job.SetMode(opmode);
235 job.SetCommandLine(MArgs::GetCommandLine(argc, argv));
236 job.SetRunNumber(kRunNumber);
237
238 if (!job.Process(arg, seq))
239 {
240 gLog << err << "Calculation of reflector failed." << endl << endl;
241 return 2;
242 }
243
244 if (!job.GetDisplay())
245 {
246 gLog << warn << "Display closed by user... execution aborted." << endl << endl;
247 return 1;
248 }
249 }
250
251// if (kBatch || kQuit)
252// delete d;
253// else
254// {
255// // From now on each 'Close' means: Terminate the application
256// d->SetBit(MStatusDisplay::kExitLoopOnClose);
257
258// // Wait until the user decides to exit the application
259// app.Run(kFALSE);
260// }
261
262 if (TObject::GetObjectStat())
263 {
264 TObject::SetObjectStat(kFALSE);
265 gObjectTable->Print();
266 }
267
268 return 0;
269}
Note: See TracBrowser for help on using the repository browser.