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