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" << endl;
|
---|
64 | gLog << " --debug-mem Debug memory usage" << endl << endl;
|
---|
65 | gLog << endl;
|
---|
66 | gLog << " -q Quit when job is finished" << endl;
|
---|
67 | gLog << " -f Force overwrite of existing files" << endl;
|
---|
68 | gLog << " --ind=path Path where to search for the data files" << endl;
|
---|
69 | gLog << " [default=standard path in datacenter]" << endl;
|
---|
70 | gLog << " --iny=path Path where to search for the calibration files" << endl;
|
---|
71 | gLog << " [default=local path or output path of Mode-C]" << endl;
|
---|
72 | gLog << " --outc=path Path to write Mode-C result to [def=local path]" << endl;
|
---|
73 | gLog << " --outy=path Path to write Mode-Y result to [def=local path]" << endl;
|
---|
74 | gLog << " --out=path Path to write the all results to [def=local path]" << endl;
|
---|
75 | gLog << " (overwrites --outc and --outy)" << endl;
|
---|
76 | gLog << " --path=path Path to write the all results to [def=local path]" << endl;
|
---|
77 | gLog << " (overwrites --iny, --outc and --outy)" << endl;
|
---|
78 | gLog << " --print-seq Print Sequence information" << endl;
|
---|
79 | gLog << " --print-files Print Files taken from Sequence" << endl;
|
---|
80 | gLog << " --print-found Print Files found from Sequence" << endl;
|
---|
81 | gLog << " --use-test Apply calibration constants to same calibration" << endl;
|
---|
82 | gLog << " file (for testing, calibration mode only)" << endl;
|
---|
83 | gLog << " --movie Write a movie in addition to Mode-Y (this might " << endl;
|
---|
84 | gLog << " stop the eventloop before all evts are processed)" << 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 corresponding 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 << " constants. 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 independently 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 showall)
|
---|
122 | {
|
---|
123 | const char *prep = showall ? "Found" : "Scheduled";
|
---|
124 |
|
---|
125 | MDirIter Next1, Next2, Next3;
|
---|
126 | seq.SetupPedRuns(Next1, kInpathD, raw);
|
---|
127 | seq.SetupCalRuns(Next2, kInpathD, raw);
|
---|
128 | seq.SetupDatRuns(Next3, kInpathD, raw);
|
---|
129 |
|
---|
130 | gLog << all;
|
---|
131 | gLog.Separator(Form("%s Pedestal Files", prep));
|
---|
132 | Next1.Print(showall?"all":"");
|
---|
133 | gLog << endl;
|
---|
134 | gLog.Separator(Form("%s Calibration Files", prep));
|
---|
135 | Next2.Print(showall?"all":"");
|
---|
136 | gLog << endl;
|
---|
137 | gLog.Separator(Form("%s Data Files", prep));
|
---|
138 | Next3.Print(showall?"all":"");
|
---|
139 | gLog << endl;
|
---|
140 | }
|
---|
141 |
|
---|
142 | int main(int argc, char **argv)
|
---|
143 | {
|
---|
144 | if (!MARS::CheckRootVer())
|
---|
145 | return 0xff;
|
---|
146 |
|
---|
147 | MLog::RedirectErrorHandler(MLog::kColor);
|
---|
148 |
|
---|
149 | //
|
---|
150 | // Evaluate arguments
|
---|
151 | //
|
---|
152 | MArgs arg(argc, argv, kTRUE);
|
---|
153 | gLog.Setup(arg);
|
---|
154 |
|
---|
155 | StartUpMessage();
|
---|
156 |
|
---|
157 | if (arg.HasOnly("-V") || arg.HasOnly("--version"))
|
---|
158 | return 0;
|
---|
159 |
|
---|
160 | if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
|
---|
161 | {
|
---|
162 | Usage();
|
---|
163 | return 2;
|
---|
164 | }
|
---|
165 |
|
---|
166 | const TString kConfig = arg.GetStringAndRemove("--config=", "callisto.rc");
|
---|
167 |
|
---|
168 | const Bool_t kPrintSeq = arg.HasOnlyAndRemove("--print-seq");
|
---|
169 | const Bool_t kPrintFiles = arg.HasOnlyAndRemove("--print-files");
|
---|
170 | const Bool_t kPrintFound = arg.HasOnlyAndRemove("--print-found");
|
---|
171 | const Bool_t kUseTest = arg.HasOnlyAndRemove("--use-test");
|
---|
172 | const Bool_t kMovie = arg.HasOnlyAndRemove("--movie");
|
---|
173 | const Bool_t kDebugMem = arg.HasOnlyAndRemove("--debug-mem");
|
---|
174 | Bool_t kMoon = arg.HasOnlyAndRemove("--moon");
|
---|
175 | Int_t kDebugEnv = arg.HasOnlyAndRemove("--debug-env") ? 1 : 0;
|
---|
176 | kDebugEnv = arg.GetIntAndRemove("--debug-env=", kDebugEnv);
|
---|
177 |
|
---|
178 | const Bool_t kQuit = arg.HasOnlyAndRemove("-q");
|
---|
179 | const Bool_t kBatch = arg.HasOnlyAndRemove("-b");
|
---|
180 | const Bool_t kOverwrite = arg.HasOnlyAndRemove("-f");
|
---|
181 | //const Bool_t kForceExec = arg.HasOnlyAndRemove("-ff");
|
---|
182 |
|
---|
183 | const TString kInpathD = arg.GetStringAndRemove("--ind=", "");
|
---|
184 | TString kInpathY = arg.GetStringAndRemove("--iny=", "");
|
---|
185 | TString kOutpathY = arg.GetStringAndRemove("--outy=", "");
|
---|
186 | TString kOutpathC = arg.GetStringAndRemove("--outc=", "");
|
---|
187 | const TString kOutpath = arg.GetStringAndRemove("--out=", "");
|
---|
188 | const TString kPath = arg.GetStringAndRemove("--path=", "");
|
---|
189 |
|
---|
190 | Bool_t kModeC = arg.HasOnlyAndRemove("-c");
|
---|
191 | Bool_t kModeY = arg.HasOnlyAndRemove("-y");
|
---|
192 | const Bool_t kIsMC = arg.HasOnlyAndRemove("-mc");
|
---|
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 | //
|
---|
200 | // check for the right usage of the program
|
---|
201 | //
|
---|
202 | if (arg.GetNumArguments()!=1)
|
---|
203 | {
|
---|
204 | Usage();
|
---|
205 | return 2;
|
---|
206 | }
|
---|
207 |
|
---|
208 | if (arg.GetNumOptions()>0)
|
---|
209 | {
|
---|
210 | gLog << warn << "WARNING - Unknown commandline options..." << endl;
|
---|
211 | arg.Print("options");
|
---|
212 | gLog << endl;
|
---|
213 | return 2;
|
---|
214 | }
|
---|
215 |
|
---|
216 | if (!kModeC && !kModeY /*&& !kUseTest*/)
|
---|
217 | {
|
---|
218 | gLog << err << "Neither calibration (-c), signal extraction (-y) or test-mode (--use-test)" << endl;
|
---|
219 | gLog << "specified! You can also give the operation mode by the options defining the" << endl;
|
---|
220 | gLog << "output path --outc, --outy or --out." << endl;
|
---|
221 | Usage();
|
---|
222 | return 2;
|
---|
223 | }
|
---|
224 | if (!kModeY && kMovie)
|
---|
225 | {
|
---|
226 | gLog << err << "Signal extraction mode (-y) not switched on but movie requested." << endl;
|
---|
227 | Usage();
|
---|
228 | return 2;
|
---|
229 | }
|
---|
230 |
|
---|
231 | if ((kModeC/* || kUseTest*/) && kOutpathC.IsNull())
|
---|
232 | kOutpathC = ".";
|
---|
233 | if (kModeY)
|
---|
234 | {
|
---|
235 | if (kInpathY.IsNull())
|
---|
236 | kInpathY = ".";
|
---|
237 | if (kOutpathY.IsNull())
|
---|
238 | kOutpathY = ".";
|
---|
239 | }
|
---|
240 | if (!kOutpath.IsNull())
|
---|
241 | {
|
---|
242 | kOutpathC = kOutpath;
|
---|
243 | kOutpathY = kOutpath;
|
---|
244 | }
|
---|
245 | if (!kPath.IsNull())
|
---|
246 | {
|
---|
247 | kOutpathC = kOutpath;
|
---|
248 | kOutpathY = kOutpath;
|
---|
249 | kInpathY = kOutpath;
|
---|
250 | }
|
---|
251 |
|
---|
252 | if (kModeC && kModeY)
|
---|
253 | kInpathY = kOutpathC;
|
---|
254 |
|
---|
255 | //
|
---|
256 | // Setup sequence file and check for its existance
|
---|
257 | //
|
---|
258 | TString kSequence = arg.GetArgumentStr(0);
|
---|
259 |
|
---|
260 | if (!MSequence::InflatePath(kSequence, kIsMC))
|
---|
261 | return 3;
|
---|
262 |
|
---|
263 | if (gSystem->AccessPathName(kConfig, kFileExists))
|
---|
264 | {
|
---|
265 | gLog << err << "Sorry, config file '" << kConfig << "' doesn't exist." << endl;
|
---|
266 | return 4;
|
---|
267 | }
|
---|
268 |
|
---|
269 | if (kDebugMem)
|
---|
270 | TObject::SetObjectStat(kTRUE);
|
---|
271 |
|
---|
272 | //
|
---|
273 | // Setup sequence and check its validity
|
---|
274 | //
|
---|
275 | MSequence seq(kSequence, kInpathD);
|
---|
276 | if (!seq.IsMonteCarlo())
|
---|
277 | seq.SetMonteCarlo(kIsMC);
|
---|
278 | if (kPrintSeq)
|
---|
279 | {
|
---|
280 | gLog << all;
|
---|
281 | gLog.Separator(kSequence);
|
---|
282 | seq.Print();
|
---|
283 | gLog << endl;
|
---|
284 | }
|
---|
285 | if (!seq.IsValid())
|
---|
286 | {
|
---|
287 | gLog << err << "Sequence read but not valid!" << endl << endl;
|
---|
288 | return 5;
|
---|
289 | }
|
---|
290 |
|
---|
291 | //
|
---|
292 | // Process print options
|
---|
293 | //
|
---|
294 | if (kPrintFiles)
|
---|
295 | PrintFiles(seq, kInpathD, !seq.IsMonteCarlo(), kFALSE);
|
---|
296 | if (kPrintFound)
|
---|
297 | PrintFiles(seq, kInpathD, !seq.IsMonteCarlo(), kTRUE);
|
---|
298 |
|
---|
299 | if (seq.HasMoon())
|
---|
300 | kMoon = kTRUE;
|
---|
301 |
|
---|
302 |
|
---|
303 | /*
|
---|
304 | //
|
---|
305 | // Check for existance of all files
|
---|
306 | //
|
---|
307 | MDirIter iter;
|
---|
308 | const Int_t n0 = seq.SetupAllRuns(iter, kInpathD, "[DPC]");
|
---|
309 | const Int_t n1 = seq.GetNumAllRuns();
|
---|
310 | if (n0 != n1)
|
---|
311 | {
|
---|
312 | if (kForceExec)
|
---|
313 | gLog << warn << "WARNING";
|
---|
314 | else
|
---|
315 | gLog << err << "ERROR";
|
---|
316 | gLog << " - " << n1 << " files in sequence defined, but " << n0 << " found in ";
|
---|
317 | gLog << (kInpathD.IsNull() ? "<defaultpath>" : kInpathD.Data()) << endl;
|
---|
318 | if (!kForceExec)
|
---|
319 | return 2;
|
---|
320 | }
|
---|
321 |
|
---|
322 | if (kPrintOnly)
|
---|
323 | return 0;
|
---|
324 | */
|
---|
325 | //
|
---|
326 | // Initialize root
|
---|
327 | //
|
---|
328 | MArray::Class()->IgnoreTObjectStreamer();
|
---|
329 | MParContainer::Class()->IgnoreTObjectStreamer();
|
---|
330 |
|
---|
331 | TApplication app("callisto", &argc, argv);
|
---|
332 | if (!gROOT->IsBatch() && !gClient || gROOT->IsBatch() && !kBatch)
|
---|
333 | {
|
---|
334 | gLog << err << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
|
---|
335 | return 1;
|
---|
336 | }
|
---|
337 |
|
---|
338 | //
|
---|
339 | // Update frequency by default = 1Hz
|
---|
340 | //
|
---|
341 | MStatusDisplay *d = new MStatusDisplay;
|
---|
342 |
|
---|
343 | // From now on each 'Exit' means: Terminate the application
|
---|
344 | d->SetBit(MStatusDisplay::kExitLoopOnExit);
|
---|
345 | d->SetTitle(kSequence);
|
---|
346 |
|
---|
347 | MEnv env(kConfig);
|
---|
348 | if (!env.IsValid())
|
---|
349 | {
|
---|
350 | gLog << err << "Configuration file " << kConfig << " not found." << endl;
|
---|
351 | return 0xfe;
|
---|
352 | }
|
---|
353 |
|
---|
354 | if (kModeC/* || kUseTest*/)
|
---|
355 | {
|
---|
356 | //
|
---|
357 | // Calculate pedestal for pedestal-calculation and calibration
|
---|
358 | //
|
---|
359 | MJPedestal job1(Form("MJPedestalC1 #%d", seq.GetSequence()));
|
---|
360 | job1.SetNoStorage();
|
---|
361 | job1.SetSequence(seq);
|
---|
362 | job1.SetEnv(&env);
|
---|
363 | job1.SetEnvDebug(kDebugEnv);
|
---|
364 | job1.SetDisplay(d);
|
---|
365 | job1.SetOverwrite(kOverwrite);
|
---|
366 | job1.SetUseHists(kMoon);
|
---|
367 |
|
---|
368 |
|
---|
369 | job1.SetExtractionFundamental();
|
---|
370 | // job1.SetPathOut(kOutpathC); // not yet needed
|
---|
371 | // job1.SetPathIn(kInpathC); // DO NOT CALL IT. IT WOULD READ THE XEXTRACTOR FROM calib-file
|
---|
372 |
|
---|
373 | if (!job1.Process())
|
---|
374 | {
|
---|
375 | gLog << err << "Calculation of pedestal failed." << endl << endl;
|
---|
376 | return 6;
|
---|
377 | }
|
---|
378 |
|
---|
379 | if (!job1.GetDisplay())
|
---|
380 | {
|
---|
381 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
382 | return 1;
|
---|
383 | }
|
---|
384 |
|
---|
385 | //
|
---|
386 | // Calculate pedestal and pedestal resolution
|
---|
387 | //
|
---|
388 | MJPedestal job2(Form("MJPedestalC2 #%d", seq.GetSequence()));
|
---|
389 | job2.SetNoStorage();
|
---|
390 | job2.SetSequence(seq);
|
---|
391 | job2.SetEnv(&env);
|
---|
392 | job2.SetEnvDebug(kDebugEnv);
|
---|
393 | job2.SetDisplay(d);;
|
---|
394 | job2.SetOverwrite(kOverwrite);
|
---|
395 | job2.SetUseHists(kMoon);
|
---|
396 | job2.SetDeadPixelCheck();
|
---|
397 | // job1.SetPathOut(kOutpathC); // not yet needed
|
---|
398 | // job1.SetPathIn(kInpathC); // DO NOT CALL IT. IT WOULD READ THE XEXTRACTOR FROM calib-file
|
---|
399 |
|
---|
400 | //job2.SetExtractorResolution();
|
---|
401 | job2.SetExtractionWithExtractorRndm();
|
---|
402 | job2.SetExtractor(job1.GetExtractor());
|
---|
403 | job2.SetPedestals(job1.GetPedestalCam());
|
---|
404 | job2.SetBadPixels(job1.GetBadPixels());
|
---|
405 |
|
---|
406 | // Please check the Changelog of 2005/04/20 about further deatils of the next comment
|
---|
407 | //if (job1.GetExtractor().InheritsFrom("MExtractTimeAndCharge"))
|
---|
408 | if (!job2.Process())
|
---|
409 | {
|
---|
410 | gLog << err << "Calculation of pedestal resolution failed." << endl << endl;
|
---|
411 | return 7;
|
---|
412 | }
|
---|
413 |
|
---|
414 | if (!job2.GetDisplay())
|
---|
415 | {
|
---|
416 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
417 | return 1;
|
---|
418 | }
|
---|
419 |
|
---|
420 | //
|
---|
421 | // Do calibration
|
---|
422 | //
|
---|
423 | MJCalibration job3(Form("MJCalibration #%d", seq.GetSequence()));
|
---|
424 | job3.SetSequence(seq);
|
---|
425 | job3.SetEnv(&env);
|
---|
426 | job3.SetEnvDebug(kDebugEnv);
|
---|
427 | job3.SetDisplay(d);
|
---|
428 | job3.SetOverwrite(kOverwrite);
|
---|
429 | job3.SetPathOut(kOutpathC);
|
---|
430 | // job2.SetPathIn(kInpathC); // not yet needed
|
---|
431 |
|
---|
432 | job3.SetBadPixels(job2.GetBadPixels());
|
---|
433 | job3.SetExtractor(job2.GetExtractor());
|
---|
434 | job3.SetExtractorCam(job2.GetPedestalCam());
|
---|
435 |
|
---|
436 | if (!job3.Process(job1.GetPedestalCam()))
|
---|
437 | {
|
---|
438 | gLog << err << "Calculation of calibration failed." << endl << endl;
|
---|
439 | return 8;
|
---|
440 | }
|
---|
441 |
|
---|
442 | if (kDebugEnv>0)
|
---|
443 | env.PrintUntouched();
|
---|
444 |
|
---|
445 | if (!job3.GetDisplay())
|
---|
446 | {
|
---|
447 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
448 | return 1;
|
---|
449 | }
|
---|
450 |
|
---|
451 | if (kUseTest)
|
---|
452 | {
|
---|
453 | MJCalibTest job4(Form("MJCalibTest #%d", seq.GetSequence()));
|
---|
454 | job4.SetBadPixels(job2.GetBadPixels());
|
---|
455 | job4.SetSequence(seq);
|
---|
456 | job4.SetEnv(&env);
|
---|
457 | job4.SetEnvDebug(kDebugEnv);
|
---|
458 | job4.SetDisplay(d);;
|
---|
459 | job4.SetOverwrite(kOverwrite);
|
---|
460 | job4.SetPathOut(kOutpathC);
|
---|
461 |
|
---|
462 | if (!job4.Process(job1.GetPedestalCam()))
|
---|
463 | {
|
---|
464 | gLog << err << "Calibration of calibration failed." << endl << endl;
|
---|
465 | return 9;
|
---|
466 | }
|
---|
467 |
|
---|
468 | if (kDebugEnv>0)
|
---|
469 | env.PrintUntouched();
|
---|
470 |
|
---|
471 | if (!job4.GetDisplay())
|
---|
472 | {
|
---|
473 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
474 | return 1;
|
---|
475 | }
|
---|
476 | }
|
---|
477 | }
|
---|
478 |
|
---|
479 | if (kModeY)
|
---|
480 | {
|
---|
481 | d->Reset();
|
---|
482 |
|
---|
483 | //
|
---|
484 | // Calculate starting pedestal for data extraction
|
---|
485 | //
|
---|
486 | MJPedestal job1(Form("MJPedestalY1 #%d", seq.GetSequence()));
|
---|
487 | job1.SetNoStorage();
|
---|
488 | job1.SetSequence(seq);
|
---|
489 | job1.SetEnv(&env);
|
---|
490 | job1.SetEnvDebug(kDebugEnv);
|
---|
491 | job1.SetDisplay(d);
|
---|
492 | job1.SetNoDisplay();
|
---|
493 | job1.SetOverwrite(kOverwrite);
|
---|
494 | job1.SetPathIn(kInpathY); // --> READ Extractor from calib-file
|
---|
495 | //job1.SetPathOut(kOutpathY); // not yet needed
|
---|
496 | job1.SetUseData();
|
---|
497 | job1.SetExtractionFundamental();
|
---|
498 | job1.SetUseHists(kMoon);
|
---|
499 |
|
---|
500 | if (!job1.Process())
|
---|
501 | {
|
---|
502 | gLog << err << "Calculation of fundamental pedestal failed." << endl << endl;
|
---|
503 | return 10;
|
---|
504 | }
|
---|
505 |
|
---|
506 | if (!job1.GetDisplay())
|
---|
507 | {
|
---|
508 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
509 | return 1;
|
---|
510 | }
|
---|
511 |
|
---|
512 | //
|
---|
513 | // Calculate pedestal and pedestal resolution
|
---|
514 | //
|
---|
515 | MJPedestal job2(Form("MJPedestalY2 #%d", seq.GetSequence()));
|
---|
516 | job2.SetNoStorage(kMovie);
|
---|
517 | job2.SetSequence(seq);
|
---|
518 | job2.SetEnv(&env);
|
---|
519 | job2.SetEnvDebug(kDebugEnv);
|
---|
520 | job2.SetDisplay(d);
|
---|
521 | job2.SetNoDisplay();
|
---|
522 | job2.SetOverwrite(kOverwrite);
|
---|
523 | job2.SetPathIn(kInpathY);
|
---|
524 | job2.SetPulsePosCheck(!seq.IsMonteCarlo());
|
---|
525 | job2.SetPathOut(kOutpathY); // for updating the extractor
|
---|
526 |
|
---|
527 | job2.SetUseData();
|
---|
528 | job2.SetExtractionWithExtractorRndm();
|
---|
529 | job2.SetExtractor(job1.GetExtractor());
|
---|
530 | job2.SetPedestals(job1.GetPedestalCam());
|
---|
531 | job2.SetBadPixels(job1.GetBadPixels());
|
---|
532 | job2.SetUseHists(kMoon);
|
---|
533 |
|
---|
534 | // Please check the Changelog of 2005/04/20 about further deatils of the next comment
|
---|
535 | //if (job1.GetExtractor().InheritsFrom("MExtractTimeAndCharge"))
|
---|
536 | const Int_t rc = job2.Process();
|
---|
537 | if (rc<=0)
|
---|
538 | {
|
---|
539 | // rc==0: Error
|
---|
540 | // rc==-1: too much to the left
|
---|
541 | // rc==-2: too much to the right
|
---|
542 | // rc==-3: too much to the right (beyond limits)
|
---|
543 |
|
---|
544 | gLog << err << "Calculation of pedestal from extractor (random) failed." << endl << endl;
|
---|
545 |
|
---|
546 | //error coding for the automatic analysis (to be filled into the database)
|
---|
547 | switch (rc)
|
---|
548 | {
|
---|
549 | case 0:
|
---|
550 | return 11;
|
---|
551 | case -1:
|
---|
552 | return 12;
|
---|
553 | case -2:
|
---|
554 | return 13;
|
---|
555 | case -3:
|
---|
556 | return 14;
|
---|
557 | }
|
---|
558 | return 2;
|
---|
559 | }
|
---|
560 |
|
---|
561 | if (!job2.GetDisplay())
|
---|
562 | {
|
---|
563 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
564 | return 1;
|
---|
565 | }
|
---|
566 |
|
---|
567 | //
|
---|
568 | // Calculate pedestal and pedestal resolution
|
---|
569 | //
|
---|
570 | MJPedestal job3(Form("MJPedestalY3 #%d", seq.GetSequence()));
|
---|
571 | job3.SetNoStorage();
|
---|
572 | job3.SetSequence(seq);
|
---|
573 | job3.SetEnv(&env);
|
---|
574 | job3.SetEnvDebug(kDebugEnv);
|
---|
575 | job3.SetDisplay(d);
|
---|
576 | job3.SetNoDisplay();
|
---|
577 | job3.SetOverwrite(kOverwrite);
|
---|
578 | job3.SetPathIn(kInpathY);
|
---|
579 | // job1.SetPathOut(kOutpathC); // not yet needed
|
---|
580 | // job1.SetPathIn(kInpathC); // not yet needed
|
---|
581 |
|
---|
582 | job3.SetUseData();
|
---|
583 | job3.SetExtractionWithExtractor();
|
---|
584 | job3.SetExtractor(job2.GetExtractor());
|
---|
585 | job3.SetPedestals(job1.GetPedestalCam());
|
---|
586 | job3.SetBadPixels(job1.GetBadPixels());
|
---|
587 | job3.SetUseHists(kMoon);
|
---|
588 |
|
---|
589 | if (!job3.Process())
|
---|
590 | {
|
---|
591 | gLog << err << "Calculation of pedestal from extractor failed." << endl << endl;
|
---|
592 | return 15;
|
---|
593 | }
|
---|
594 |
|
---|
595 | if (!job3.GetDisplay())
|
---|
596 | {
|
---|
597 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
598 | return 1;
|
---|
599 | }
|
---|
600 |
|
---|
601 | //
|
---|
602 | // Extract signal and calibrate it
|
---|
603 | //
|
---|
604 | MJCalibrateSignal job4(Form("MJCalibrateSignal #%d", seq.GetSequence()));
|
---|
605 | job4.SetSequence(seq);
|
---|
606 | job4.SetDisplay(d);;
|
---|
607 | job4.SetEnv(&env);
|
---|
608 | job4.SetEnvDebug(kDebugEnv);
|
---|
609 | job4.SetOverwrite(kOverwrite);
|
---|
610 | job4.SetPathIn(kInpathY);
|
---|
611 | job4.SetPathOut(kOutpathY);
|
---|
612 | job4.SetMovieMode(kMovie);
|
---|
613 | if (!seq.IsMonteCarlo())
|
---|
614 | job4.SetExtractor(job2.GetExtractor());
|
---|
615 |
|
---|
616 | // Where to search for calibration files
|
---|
617 | if (!job4.Process(job1.GetPedestalCam(), job3.GetPedestalCam(), job2.GetPedestalCam()))
|
---|
618 | return 16;
|
---|
619 |
|
---|
620 | if (kDebugEnv>0)
|
---|
621 | env.PrintUntouched();
|
---|
622 |
|
---|
623 | if (!job4.GetDisplay())
|
---|
624 | {
|
---|
625 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
626 | return 1;
|
---|
627 | }
|
---|
628 | }
|
---|
629 |
|
---|
630 | if (kBatch || kQuit)
|
---|
631 | delete d;
|
---|
632 | else
|
---|
633 | {
|
---|
634 | // From now on each 'Close' means: Terminate the application
|
---|
635 | d->SetBit(MStatusDisplay::kExitLoopOnClose);
|
---|
636 |
|
---|
637 | // Wait until the user decides to exit the application
|
---|
638 | app.Run(kFALSE);
|
---|
639 | }
|
---|
640 |
|
---|
641 | if (TObject::GetObjectStat())
|
---|
642 | {
|
---|
643 | TObject::SetObjectStat(kFALSE);
|
---|
644 | gObjectTable->Print();
|
---|
645 | }
|
---|
646 |
|
---|
647 | return 0;
|
---|
648 | }
|
---|
649 |
|
---|