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