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