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