1 | #include <TROOT.h>
|
---|
2 | #include <TClass.h>
|
---|
3 | #include <TSystem.h>
|
---|
4 | #include <TGClient.h>
|
---|
5 | #include <TApplication.h>
|
---|
6 | #include <TObjectTable.h>
|
---|
7 |
|
---|
8 | #include "MLog.h"
|
---|
9 | #include "MLogManip.h"
|
---|
10 |
|
---|
11 | #include "MEnv.h"
|
---|
12 | #include "MArgs.h"
|
---|
13 | #include "MArray.h"
|
---|
14 | #include "MDirIter.h"
|
---|
15 |
|
---|
16 | #include "MStatusDisplay.h"
|
---|
17 |
|
---|
18 | #include "MSequence.h"
|
---|
19 | #include "MJPedestal.h"
|
---|
20 | #include "MJCalibration.h"
|
---|
21 | #include "MJCalibrateSignal.h"
|
---|
22 | #include "MJCalibTest.h"
|
---|
23 |
|
---|
24 | using namespace std;
|
---|
25 |
|
---|
26 | static void StartUpMessage()
|
---|
27 | {
|
---|
28 | gLog << all << endl;
|
---|
29 |
|
---|
30 | // 1 2 3 4 5
|
---|
31 | // 12345678901234567890123456789012345678901234567890
|
---|
32 | gLog << "========================================================" << endl;
|
---|
33 | gLog << " Callisto - MARS V" << MARSVER << endl;
|
---|
34 | gLog << " MARS -- CALibrate LIght Signals and Time Offsets" << endl;
|
---|
35 | gLog << " Compiled on <" << __DATE__ << ">" << endl;
|
---|
36 | gLog << " Using ROOT v" << ROOTVER << endl;
|
---|
37 | gLog << "========================================================" << endl;
|
---|
38 | gLog << endl;
|
---|
39 | }
|
---|
40 |
|
---|
41 | static void Usage()
|
---|
42 | {
|
---|
43 | // 1 2 3 4 5 6 7 8
|
---|
44 | // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
|
---|
45 | gLog << all << endl;
|
---|
46 | gLog << "Sorry the usage is:" << endl;
|
---|
47 | gLog << " callisto [-c] [-y] [options] sequence.txt" << endl << endl;
|
---|
48 | gLog << " Arguments:" << endl;
|
---|
49 | gLog << " sequence.txt: Ascii file defining a sequence of runs" << endl;
|
---|
50 | gLog << " For more details see MSequence" << endl;
|
---|
51 | gLog << " Root Options:" << endl;
|
---|
52 | gLog << " -b Batch mode (no graphical output to screen)" << endl<<endl;
|
---|
53 | gLog << " Operation Modes:" << endl;
|
---|
54 | gLog << " -c Calculate the calibration constants" << endl;
|
---|
55 | gLog << " -y Extract and calibrate signal" << endl << endl;
|
---|
56 | gLog << " Data Type (exclusive):" << endl;
|
---|
57 | gLog << " -raw Read input from raw-data" << endl;
|
---|
58 | gLog << " -mc Input root-files are monte carlo files" << endl;
|
---|
59 | gLog << " -root Read input from root-files (merpped) <default>" << endl << endl;
|
---|
60 | gLog << " Options:" << endl;
|
---|
61 | gLog.Usage();
|
---|
62 | gLog << " --debug-env=0 Disable debugging setting resources <default>" << endl;
|
---|
63 | gLog << " --debug-env[=1] Display untouched resources after program execution" << endl;
|
---|
64 | gLog << " --debug-env=2 Display untouched resources after eventloop setup" << endl;
|
---|
65 | gLog << " --debug-env=3 Debug setting resources from resource file" << endl;
|
---|
66 | gLog << " --debug-mem Debug memory usage" << endl << endl;
|
---|
67 | gLog << endl;
|
---|
68 | gLog << " -q Quit when job is finished" << endl;
|
---|
69 | gLog << " -f Force overwrite of existing files" << endl;
|
---|
70 | gLog << " --ind=path Path where to search for the data files" << endl;
|
---|
71 | gLog << " [default=standard path in datacenter]" << endl;
|
---|
72 | gLog << " --iny=path Path where to search for the calibration files" << endl;
|
---|
73 | gLog << " [default=local path or output path of Mode-C]" << endl;
|
---|
74 | gLog << " --outc=path Path to write Mode-C result to [def=local path]" << endl;
|
---|
75 | gLog << " --outy=path Path to write Mode-Y result to [def=local path]" << endl;
|
---|
76 | gLog << " --out=path Path to write the all results to [def=local path]" << endl;
|
---|
77 | gLog << " (overwrites --outc and --outy)" << endl;
|
---|
78 | gLog << " --path=path Path to write the all results to [def=local path]" << endl;
|
---|
79 | gLog << " (overwrites --iny, --outc and --outy)" << endl;
|
---|
80 | gLog << " --print-seq Print Sequence information" << endl;
|
---|
81 | gLog << " --print-files Print Files taken from Sequence" << endl;
|
---|
82 | gLog << " --print-found Print Files found from Sequence" << endl;
|
---|
83 | gLog << " --use-test Apply calibration constants to same calibration" << endl;
|
---|
84 | gLog << " file (for testing, calibration mode only)" << endl;
|
---|
85 | gLog << " --moon Force using pedestal fits instead of calculated RMS" << endl;
|
---|
86 | gLog << " --config=callisto.rc Resource file [default=callisto.rc]" << endl;
|
---|
87 | gLog << endl;
|
---|
88 | gLog << " --version, -V Show startup message with version number" << endl;
|
---|
89 | gLog << " -?, -h, --help This help" << endl << endl;
|
---|
90 | gLog << " Setup of the two jobs run by callisto (MJPedestal and MJCalibration)" << endl;
|
---|
91 | gLog << " can be done with the resource file. See MJPedestal and MJCalibration" << endl;
|
---|
92 | gLog << " especially CheckEnv() for more details. Command line options might" << endl;
|
---|
93 | gLog << " be overwritten by the resource file." << endl << endl;
|
---|
94 | gLog << " If running in Mode-C and Mode-Y --iny= is obsolete, instead --outc=" << endl;
|
---|
95 | gLog << " is used." << endl << endl;
|
---|
96 | gLog << " Using --iny=, --outc=, --outy=, --out= or --path= automatically" << endl;
|
---|
97 | gLog << " enables the corresponmding modes. In this case -c/-y are obsolete." << endl << endl;
|
---|
98 | gLog << "Description:" << endl;
|
---|
99 | gLog << " callisto will calculate pedestals from pedestal-files defined in a" << endl;
|
---|
100 | gLog << " sequence-file. This pedestals are used to calculate the calibration" << endl;
|
---|
101 | gLog << " contants. These constants are stored in a so called calibration-file" << endl;
|
---|
102 | gLog << " together with some datacheck plots which can be viewed using either" << endl;
|
---|
103 | gLog << " showplot or MStatusDisplay in the interpreter. A description of a" << endl;
|
---|
104 | gLog << " sequence-file can be found in the class reference of MSequence." << endl << endl;
|
---|
105 | gLog << "Background:" << endl;
|
---|
106 | gLog << " Callisto is a large, icy, dark-colored, low-density outer moon of" << endl;
|
---|
107 | gLog << " Jupiter that is scarred with impact craters and ejecta. It has a" << endl;
|
---|
108 | gLog << " diameter of about 4800km, the second-largest moon of Jupiter; it is" << endl;
|
---|
109 | gLog << " roughly the size of Mercury. Callisto has the largest-known impact" << endl;
|
---|
110 | gLog << " crater in the Solar System, Valhalla, which has a bright patch 600km" << endl;
|
---|
111 | gLog << " across and rings that go out to almost 3000km. Callisto orbits" << endl;
|
---|
112 | gLog << " Jupiter at a mean distance of 1,883,000km. Its mass is 1.1e23 kg. It" << endl;
|
---|
113 | gLog << " takes Callisto 16.7 days to orbit Jupiter in a synchronous orbit." << endl;
|
---|
114 | gLog << " Jupiter's moon Callisto was discovered independantly by Galileo and" << endl;
|
---|
115 | gLog << " S.Marius in 1610." << endl << endl;
|
---|
116 | gLog << "Example:" << endl;
|
---|
117 | gLog << " callisto -f --outc=mycal/ --outy=mysignal/ --log sequence02345.txt" << endl;
|
---|
118 | gLog << endl;
|
---|
119 | }
|
---|
120 |
|
---|
121 | static void PrintFiles(const MSequence &seq, const TString &kInpathD, Bool_t raw, Bool_t all)
|
---|
122 | {
|
---|
123 | const char *prep = all ? "Found" : "Scheduled";
|
---|
124 |
|
---|
125 | MDirIter Next1, Next2, Next3;
|
---|
126 | seq.SetupPedRuns(Next1, kInpathD, "P", raw);
|
---|
127 | seq.SetupCalRuns(Next2, kInpathD, "C", raw);
|
---|
128 | seq.SetupDatRuns(Next3, kInpathD, "D", raw);
|
---|
129 |
|
---|
130 | gLog << all;
|
---|
131 | gLog.Separator(Form("%s Pedestal Files", prep));
|
---|
132 | Next1.Print(all?"all":"");
|
---|
133 | gLog << endl;
|
---|
134 | gLog.Separator(Form("%s Calibration Files", prep));
|
---|
135 | Next2.Print(all?"all":"");
|
---|
136 | gLog << endl;
|
---|
137 | gLog.Separator(Form("%s Data Files", prep));
|
---|
138 | Next3.Print(all?"all":"");
|
---|
139 | gLog << endl;
|
---|
140 | }
|
---|
141 |
|
---|
142 | int main(int argc, char **argv)
|
---|
143 | {
|
---|
144 | StartUpMessage();
|
---|
145 |
|
---|
146 | //
|
---|
147 | // Evaluate arguments
|
---|
148 | //
|
---|
149 | MArgs arg(argc, argv, kTRUE);
|
---|
150 |
|
---|
151 | if (arg.HasOnly("-V") || arg.HasOnly("--version"))
|
---|
152 | return 0;
|
---|
153 |
|
---|
154 | if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
|
---|
155 | {
|
---|
156 | Usage();
|
---|
157 | return 2;
|
---|
158 | }
|
---|
159 |
|
---|
160 | gLog.Setup(arg);
|
---|
161 |
|
---|
162 | const TString kConfig = arg.GetStringAndRemove("--config=", "callisto.rc");
|
---|
163 |
|
---|
164 | const Bool_t kPrintSeq = arg.HasOnlyAndRemove("--print-seq");
|
---|
165 | const Bool_t kPrintFiles = arg.HasOnlyAndRemove("--print-files");
|
---|
166 | const Bool_t kPrintFound = arg.HasOnlyAndRemove("--print-found");
|
---|
167 | const Bool_t kUseTest = arg.HasOnlyAndRemove("--use-test");
|
---|
168 | const Bool_t kDebugMem = arg.HasOnlyAndRemove("--debug-mem");
|
---|
169 | Bool_t kMoon = arg.HasOnlyAndRemove("--moon");
|
---|
170 | Int_t kDebugEnv = arg.HasOnlyAndRemove("--debug-env") ? 1 : 0;
|
---|
171 | kDebugEnv = arg.GetIntAndRemove("--debug-env=", kDebugEnv);
|
---|
172 |
|
---|
173 | const Bool_t kQuit = arg.HasOnlyAndRemove("-q");
|
---|
174 | const Bool_t kBatch = arg.HasOnlyAndRemove("-b");
|
---|
175 | const Bool_t kOverwrite = arg.HasOnlyAndRemove("-f");
|
---|
176 | //const Bool_t kForceExec = arg.HasOnlyAndRemove("-ff");
|
---|
177 |
|
---|
178 | const TString kInpathD = arg.GetStringAndRemove("--ind=", "");
|
---|
179 | TString kInpathY = arg.GetStringAndRemove("--iny=", "");
|
---|
180 | TString kOutpathY = arg.GetStringAndRemove("--outy=", "");
|
---|
181 | TString kOutpathC = arg.GetStringAndRemove("--outc=", "");
|
---|
182 | const TString kOutpath = arg.GetStringAndRemove("--out=", "");
|
---|
183 | const TString kPath = arg.GetStringAndRemove("--path=", "");
|
---|
184 |
|
---|
185 | Bool_t kModeC = arg.HasOnlyAndRemove("-c");
|
---|
186 | Bool_t kModeY = arg.HasOnlyAndRemove("-y");
|
---|
187 |
|
---|
188 | MJCalib::DataType_t kDataType = MJCalib::kIsUseRootData; // root
|
---|
189 | if (arg.HasOnlyAndRemove("-raw"))
|
---|
190 | kDataType = MJCalib::kIsUseRawData; // raw
|
---|
191 | if (arg.HasOnlyAndRemove("-mc"))
|
---|
192 | kDataType = MJCalib::kIsUseMC; // monte carlo
|
---|
193 |
|
---|
194 | if (!kInpathY.IsNull() || !kOutpathY.IsNull() || !kOutpath.IsNull() || !kPath.IsNull())
|
---|
195 | kModeY = kTRUE;
|
---|
196 | if (!kOutpathC.IsNull() || !kOutpath.IsNull() || !kPath.IsNull())
|
---|
197 | kModeC = kTRUE;
|
---|
198 |
|
---|
199 | if (!kModeC && !kModeY /*&& !kUseTest*/)
|
---|
200 | {
|
---|
201 | gLog << err << "Neither calibration (-c) nor signal extraction (-y) or test-mode (--use-test) specified!" << endl;
|
---|
202 | Usage();
|
---|
203 | return 2;
|
---|
204 | }
|
---|
205 |
|
---|
206 | if ((kModeC/* || kUseTest*/) && kOutpathC.IsNull())
|
---|
207 | kOutpathC = ".";
|
---|
208 | if (kModeY)
|
---|
209 | {
|
---|
210 | if (kInpathY.IsNull())
|
---|
211 | kInpathY = ".";
|
---|
212 | if (kOutpathY.IsNull())
|
---|
213 | kOutpathY = ".";
|
---|
214 | }
|
---|
215 | if (!kOutpath.IsNull())
|
---|
216 | {
|
---|
217 | kOutpathC = kOutpath;
|
---|
218 | kOutpathY = kOutpath;
|
---|
219 | }
|
---|
220 | if (!kPath.IsNull())
|
---|
221 | {
|
---|
222 | kOutpathC = kOutpath;
|
---|
223 | kOutpathY = kOutpath;
|
---|
224 | kInpathY = kOutpath;
|
---|
225 | }
|
---|
226 |
|
---|
227 | if (kModeC && kModeY)
|
---|
228 | kInpathY = kOutpathC;
|
---|
229 |
|
---|
230 | if (arg.GetNumOptions()>0)
|
---|
231 | {
|
---|
232 | gLog << warn << "WARNING - Unknown commandline options..." << endl;
|
---|
233 | arg.Print("options");
|
---|
234 | gLog << endl;
|
---|
235 | return 2;
|
---|
236 | }
|
---|
237 |
|
---|
238 | //
|
---|
239 | // check for the right usage of the program
|
---|
240 | //
|
---|
241 | if (arg.GetNumArguments()!=1)
|
---|
242 | {
|
---|
243 | Usage();
|
---|
244 | return 2;
|
---|
245 | }
|
---|
246 |
|
---|
247 | //
|
---|
248 | // Setup sequence file and check for its existance
|
---|
249 | //
|
---|
250 | const TString kSequence = arg.GetArgumentStr(0);
|
---|
251 |
|
---|
252 | if (gSystem->AccessPathName(kSequence, kFileExists))
|
---|
253 | {
|
---|
254 | gLog << err << "Sorry, sequence file '" << kSequence << "' doesn't exist." << endl;
|
---|
255 | return 2;
|
---|
256 | }
|
---|
257 |
|
---|
258 | if (gSystem->AccessPathName(kConfig, kFileExists))
|
---|
259 | {
|
---|
260 | gLog << err << "Sorry, config file '" << kConfig << "' doesn't exist." << endl;
|
---|
261 | return 2;
|
---|
262 | }
|
---|
263 |
|
---|
264 | if (kDebugMem)
|
---|
265 | TObject::SetObjectStat(kTRUE);
|
---|
266 |
|
---|
267 | //
|
---|
268 | // Setup sequence and check its validity
|
---|
269 | //
|
---|
270 | MSequence seq(kSequence);
|
---|
271 | if (kPrintSeq)
|
---|
272 | {
|
---|
273 | gLog << all;
|
---|
274 | gLog.Separator(kSequence);
|
---|
275 | seq.Print();
|
---|
276 | gLog << endl;
|
---|
277 | }
|
---|
278 | if (!seq.IsValid())
|
---|
279 | {
|
---|
280 | gLog << err << "Sequence read but not valid!" << endl << endl;
|
---|
281 | return 2;
|
---|
282 | }
|
---|
283 |
|
---|
284 | //
|
---|
285 | // Process print options
|
---|
286 | //
|
---|
287 | if (kPrintFiles)
|
---|
288 | PrintFiles(seq, kInpathD, kDataType==MJCalib::kIsUseRawData, kFALSE);
|
---|
289 | if (kPrintFound)
|
---|
290 | PrintFiles(seq, kInpathD, kDataType==MJCalib::kIsUseRawData, kTRUE);
|
---|
291 |
|
---|
292 | if (seq.HasMoon())
|
---|
293 | kMoon = kTRUE;
|
---|
294 |
|
---|
295 |
|
---|
296 | /*
|
---|
297 | //
|
---|
298 | // Check for existance of all files
|
---|
299 | //
|
---|
300 | MDirIter iter;
|
---|
301 | const Int_t n0 = seq.SetupAllRuns(iter, kInpathD, "[DPC]");
|
---|
302 | const Int_t n1 = seq.GetNumAllRuns();
|
---|
303 | if (n0 != n1)
|
---|
304 | {
|
---|
305 | if (kForceExec)
|
---|
306 | gLog << warn << "WARNING";
|
---|
307 | else
|
---|
308 | gLog << err << "ERROR";
|
---|
309 | gLog << " - " << n1 << " files in sequence defined, but " << n0 << " found in ";
|
---|
310 | gLog << (kInpathD.IsNull() ? "<defaultpath>" : kInpathD.Data()) << endl;
|
---|
311 | if (!kForceExec)
|
---|
312 | return 2;
|
---|
313 | }
|
---|
314 |
|
---|
315 | if (kPrintOnly)
|
---|
316 | return 0;
|
---|
317 | */
|
---|
318 | //
|
---|
319 | // Initialize root
|
---|
320 | //
|
---|
321 | MArray::Class()->IgnoreTObjectStreamer();
|
---|
322 | MParContainer::Class()->IgnoreTObjectStreamer();
|
---|
323 |
|
---|
324 | TApplication app("Callisto", &argc, argv);
|
---|
325 | if (!gROOT->IsBatch() && !gClient || gROOT->IsBatch() && !kBatch)
|
---|
326 | {
|
---|
327 | gLog << err << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
|
---|
328 | return 1;
|
---|
329 | }
|
---|
330 |
|
---|
331 | //
|
---|
332 | // Update frequency by default = 1Hz
|
---|
333 | //
|
---|
334 | MStatusDisplay *d = new MStatusDisplay;
|
---|
335 |
|
---|
336 | // From now on each 'Exit' means: Terminate the application
|
---|
337 | d->SetBit(MStatusDisplay::kExitLoopOnExit);
|
---|
338 | d->SetTitle(kSequence);
|
---|
339 |
|
---|
340 | MEnv env(kConfig);
|
---|
341 | if (kModeC/* || kUseTest*/)
|
---|
342 | {
|
---|
343 | //
|
---|
344 | // Calculate pedestal for pedestal-calculation and calibration
|
---|
345 | //
|
---|
346 | MJPedestal job1(Form("MJPedestalC1 #%d", seq.GetSequence()));
|
---|
347 | job1.SetNoStorage();
|
---|
348 | job1.SetSequence(seq);
|
---|
349 | job1.SetEnv(&env);
|
---|
350 | job1.SetEnvDebug(kDebugEnv);
|
---|
351 | job1.SetDisplay(d);
|
---|
352 | job1.SetOverwrite(kOverwrite);
|
---|
353 | job1.SetPathData(kInpathD);
|
---|
354 | job1.SetDataType(kDataType);
|
---|
355 | job1.SetUseHists(kMoon);
|
---|
356 |
|
---|
357 |
|
---|
358 | job1.SetExtractionFundamental();
|
---|
359 | // job1.SetPathOut(kOutpathC); // not yet needed
|
---|
360 | // job1.SetPathIn(kInpathC); // not yet needed
|
---|
361 |
|
---|
362 | if (!job1.ProcessFile())
|
---|
363 | {
|
---|
364 | gLog << err << "Calculation of pedestal failed." << endl << endl;
|
---|
365 | return 2;
|
---|
366 | }
|
---|
367 |
|
---|
368 | if (!job1.GetDisplay())
|
---|
369 | {
|
---|
370 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
371 | return 1;
|
---|
372 | }
|
---|
373 |
|
---|
374 | //
|
---|
375 | // Calculate pedestal and pedestal resolution
|
---|
376 | //
|
---|
377 | MJPedestal job2(Form("MJPedestalC2 #%d", seq.GetSequence()));
|
---|
378 | job2.SetNoStorage();
|
---|
379 | job2.SetSequence(seq);
|
---|
380 | job2.SetEnv(&env);
|
---|
381 | job2.SetEnvDebug(kDebugEnv);
|
---|
382 | job2.SetDisplay(d);;
|
---|
383 | job2.SetOverwrite(kOverwrite);
|
---|
384 | job2.SetPathData(kInpathD);
|
---|
385 | job2.SetDataType(kDataType);
|
---|
386 | job2.SetUseHists(kMoon);
|
---|
387 | // job1.SetPathOut(kOutpathC); // not yet needed
|
---|
388 | // job1.SetPathIn(kInpathC); // not yet needed
|
---|
389 |
|
---|
390 | //job2.SetExtractorResolution();
|
---|
391 | job2.SetExtractionWithExtractorRndm();
|
---|
392 | job2.SetExtractor(job1.GetExtractor());
|
---|
393 | job2.SetPedestals(job1.GetPedestalCam());
|
---|
394 | job2.SetBadPixels(job1.GetBadPixels());
|
---|
395 |
|
---|
396 | if (!job2.ProcessFile())
|
---|
397 | {
|
---|
398 | gLog << err << "Calculation of pedestal resolution failed." << endl << endl;
|
---|
399 | return 2;
|
---|
400 | }
|
---|
401 |
|
---|
402 | if (!job2.GetDisplay())
|
---|
403 | {
|
---|
404 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
405 | return 1;
|
---|
406 | }
|
---|
407 |
|
---|
408 | //
|
---|
409 | // Do calibration
|
---|
410 | //
|
---|
411 | MJCalibration job3(Form("MJCalibration #%d", seq.GetSequence()));
|
---|
412 | job3.SetSequence(seq);
|
---|
413 | job3.SetEnv(&env);
|
---|
414 | job3.SetEnvDebug(kDebugEnv);
|
---|
415 | job3.SetDisplay(d);
|
---|
416 | job3.SetOverwrite(kOverwrite);
|
---|
417 | job3.SetPathOut(kOutpathC);
|
---|
418 | job3.SetPathData(kInpathD);
|
---|
419 | job3.SetDataType(kDataType);
|
---|
420 | // job2.SetPathIn(kInpathC); // not yet needed
|
---|
421 |
|
---|
422 | job3.SetBadPixels(job2.GetBadPixels());
|
---|
423 | job3.SetExtractor(job2.GetExtractor());
|
---|
424 | job3.SetExtractorCam(job2.GetPedestalCam());
|
---|
425 |
|
---|
426 | if (!job3.ProcessFile(job1.GetPedestalCam()))
|
---|
427 | {
|
---|
428 | gLog << err << "Calculation of calibration failed." << endl << endl;
|
---|
429 | return 2;
|
---|
430 | }
|
---|
431 |
|
---|
432 | if (kDebugEnv>0)
|
---|
433 | env.PrintUntouched();
|
---|
434 |
|
---|
435 | if (!job3.GetDisplay())
|
---|
436 | {
|
---|
437 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
438 | return 1;
|
---|
439 | }
|
---|
440 |
|
---|
441 | if (kUseTest)
|
---|
442 | {
|
---|
443 | MJCalibTest job4(Form("MJCalibTest #%d", seq.GetSequence()));
|
---|
444 | job4.SetBadPixels(job2.GetBadPixels());
|
---|
445 | job4.SetSequence(seq);
|
---|
446 | job4.SetEnv(&env);
|
---|
447 | job4.SetEnvDebug(kDebugEnv);
|
---|
448 | job4.SetDisplay(d);;
|
---|
449 | job4.SetOverwrite(kOverwrite);
|
---|
450 | job4.SetPathOut(kOutpathC);
|
---|
451 | job4.SetPathData(kInpathD);
|
---|
452 | job4.SetDataType(kDataType);
|
---|
453 |
|
---|
454 | if (!job4.ProcessFile(job1.GetPedestalCam()))
|
---|
455 | {
|
---|
456 | gLog << err << "Calibration of calibration failed." << endl << endl;
|
---|
457 | return 2;
|
---|
458 | }
|
---|
459 |
|
---|
460 | if (kDebugEnv>0)
|
---|
461 | env.PrintUntouched();
|
---|
462 |
|
---|
463 | if (!job4.GetDisplay())
|
---|
464 | {
|
---|
465 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
466 | return 1;
|
---|
467 | }
|
---|
468 | }
|
---|
469 | }
|
---|
470 |
|
---|
471 | if (kModeY)
|
---|
472 | {
|
---|
473 | d->Reset();
|
---|
474 |
|
---|
475 | //
|
---|
476 | // Calculate starting pedestal for data extraction
|
---|
477 | //
|
---|
478 | MJPedestal job1(Form("MJPedestalY1 #%d", seq.GetSequence()));
|
---|
479 | job1.SetNoStorage();
|
---|
480 | job1.SetSequence(seq);
|
---|
481 | job1.SetEnv(&env);
|
---|
482 | job1.SetEnvDebug(kDebugEnv);
|
---|
483 | job1.SetDisplay(d);
|
---|
484 | job1.SetNoDisplay();
|
---|
485 | job1.SetOverwrite(kOverwrite);
|
---|
486 | job1.SetPathData(kInpathD);
|
---|
487 | job1.SetPathIn(kInpathY);
|
---|
488 | job1.SetDataType(kDataType);
|
---|
489 | //job1.SetPathOut(kOutpathY); // not yet needed
|
---|
490 | job1.SetUseData();
|
---|
491 | job1.SetExtractionFundamental();
|
---|
492 | job1.SetUseHists(kMoon);
|
---|
493 |
|
---|
494 | if (!job1.ProcessFile())
|
---|
495 | {
|
---|
496 | gLog << err << "Calculation of fundamental pedestal failed." << endl << endl;
|
---|
497 | return 2;
|
---|
498 | }
|
---|
499 |
|
---|
500 | if (!job1.GetDisplay())
|
---|
501 | {
|
---|
502 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
503 | return 1;
|
---|
504 | }
|
---|
505 |
|
---|
506 | //
|
---|
507 | // Calculate pedestal and pedestal resolution
|
---|
508 | //
|
---|
509 | MJPedestal job2(Form("MJPedestalY2 #%d", seq.GetSequence()));
|
---|
510 | job2.SetNoStorage();
|
---|
511 | job2.SetSequence(seq);
|
---|
512 | job2.SetEnv(&env);
|
---|
513 | job2.SetEnvDebug(kDebugEnv);
|
---|
514 | job2.SetDisplay(d);
|
---|
515 | job2.SetNoDisplay();
|
---|
516 | job2.SetOverwrite(kOverwrite);
|
---|
517 | job2.SetPathData(kInpathD);
|
---|
518 | job2.SetPathIn(kInpathY);
|
---|
519 | job2.SetDataType(kDataType);
|
---|
520 | job2.SetPulsePosCheck(kDataType!=MJCalib::kIsUseMC);
|
---|
521 | job2.SetPathOut(kOutpathY); // for updating the extractor
|
---|
522 |
|
---|
523 | job2.SetUseData();
|
---|
524 | job2.SetExtractionWithExtractor();
|
---|
525 | job2.SetExtractor(job1.GetExtractor());
|
---|
526 | job2.SetPedestals(job1.GetPedestalCam());
|
---|
527 | job2.SetBadPixels(job1.GetBadPixels());
|
---|
528 | job2.SetUseHists(kMoon);
|
---|
529 |
|
---|
530 | if (!job2.ProcessFile())
|
---|
531 | {
|
---|
532 | gLog << err << "Calculation of pedestal from extrtactor (random) failed." << endl << endl;
|
---|
533 | return 2;
|
---|
534 | }
|
---|
535 |
|
---|
536 | if (!job2.GetDisplay())
|
---|
537 | {
|
---|
538 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
539 | return 1;
|
---|
540 | }
|
---|
541 |
|
---|
542 | //
|
---|
543 | // Calculate pedestal and pedestal resolution
|
---|
544 | //
|
---|
545 | MJPedestal job3(Form("MJPedestalY3 #%d", seq.GetSequence()));
|
---|
546 | job3.SetNoStorage();
|
---|
547 | job3.SetSequence(seq);
|
---|
548 | job3.SetEnv(&env);
|
---|
549 | job3.SetEnvDebug(kDebugEnv);
|
---|
550 | job3.SetDisplay(d);
|
---|
551 | job3.SetNoDisplay();
|
---|
552 | job3.SetOverwrite(kOverwrite);
|
---|
553 | job3.SetPathData(kInpathD);
|
---|
554 | job3.SetPathIn(kInpathY);
|
---|
555 | job3.SetDataType(kDataType);
|
---|
556 | // job1.SetPathOut(kOutpathC); // not yet needed
|
---|
557 | // job1.SetPathIn(kInpathC); // not yet needed
|
---|
558 |
|
---|
559 | job3.SetUseData();
|
---|
560 | job3.SetExtractionWithExtractorRndm();
|
---|
561 | job3.SetExtractor(job1.GetExtractor());
|
---|
562 | job3.SetPedestals(job1.GetPedestalCam());
|
---|
563 | job3.SetBadPixels(job1.GetBadPixels());
|
---|
564 | job3.SetUseHists(kMoon);
|
---|
565 |
|
---|
566 | if (!job3.ProcessFile())
|
---|
567 | {
|
---|
568 | gLog << err << "Calculation of pedestal from extractor failed." << endl << endl;
|
---|
569 | return 2;
|
---|
570 | }
|
---|
571 |
|
---|
572 | if (!job3.GetDisplay())
|
---|
573 | {
|
---|
574 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
575 | return 1;
|
---|
576 | }
|
---|
577 |
|
---|
578 | //
|
---|
579 | // Extract signal and calibrate it
|
---|
580 | //
|
---|
581 | MJCalibrateSignal job4(Form("MJCalibrateSignal #%d", seq.GetSequence()));
|
---|
582 | job4.SetSequence(seq);
|
---|
583 | job4.SetDisplay(d);;
|
---|
584 | job4.SetEnv(&env);
|
---|
585 | job4.SetEnvDebug(kDebugEnv);
|
---|
586 | job4.SetOverwrite(kOverwrite);
|
---|
587 | job4.SetPathIn(kInpathY);
|
---|
588 | job4.SetPathOut(kOutpathY);
|
---|
589 | job4.SetPathData(kInpathD);
|
---|
590 | job4.SetDataType(kDataType);
|
---|
591 | if (kDataType!=MJCalib::kIsUseMC)
|
---|
592 | job4.SetExtractor(job2.GetExtractor());
|
---|
593 |
|
---|
594 | // Where to search for calibration files
|
---|
595 | if (!job4.ProcessFile(job1.GetPedestalCam(), job2.GetPedestalCam(), job3.GetPedestalCam()))
|
---|
596 | return 2;
|
---|
597 |
|
---|
598 | if (kDebugEnv>0)
|
---|
599 | env.PrintUntouched();
|
---|
600 |
|
---|
601 | if (!job4.GetDisplay())
|
---|
602 | {
|
---|
603 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
604 | return 1;
|
---|
605 | }
|
---|
606 | }
|
---|
607 |
|
---|
608 | if (kBatch || kQuit)
|
---|
609 | delete d;
|
---|
610 | else
|
---|
611 | {
|
---|
612 | // From now on each 'Close' means: Terminate the application
|
---|
613 | d->SetBit(MStatusDisplay::kExitLoopOnClose);
|
---|
614 |
|
---|
615 | // Wait until the user decides to exit the application
|
---|
616 | app.Run(kFALSE);
|
---|
617 | }
|
---|
618 |
|
---|
619 | if (TObject::GetObjectStat())
|
---|
620 | {
|
---|
621 | TObject::SetObjectStat(kFALSE);
|
---|
622 | gObjectTable->Print();
|
---|
623 | }
|
---|
624 |
|
---|
625 | return 0;
|
---|
626 | }
|
---|
627 |
|
---|