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 << " -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 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 | //
|
---|
148 | // Evaluate arguments
|
---|
149 | //
|
---|
150 | MArgs arg(argc, argv, kTRUE);
|
---|
151 | gLog.Setup(arg);
|
---|
152 |
|
---|
153 | StartUpMessage();
|
---|
154 |
|
---|
155 | if (arg.HasOnly("-V") || arg.HasOnly("--version"))
|
---|
156 | return 0;
|
---|
157 |
|
---|
158 | if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
|
---|
159 | {
|
---|
160 | Usage();
|
---|
161 | return 2;
|
---|
162 | }
|
---|
163 |
|
---|
164 | const TString kConfig = arg.GetStringAndRemove("--config=", "callisto.rc");
|
---|
165 |
|
---|
166 | const Bool_t kPrintSeq = arg.HasOnlyAndRemove("--print-seq");
|
---|
167 | const Bool_t kPrintFiles = arg.HasOnlyAndRemove("--print-files");
|
---|
168 | const Bool_t kPrintFound = arg.HasOnlyAndRemove("--print-found");
|
---|
169 | const Bool_t kUseTest = arg.HasOnlyAndRemove("--use-test");
|
---|
170 | const Bool_t kDebugMem = arg.HasOnlyAndRemove("--debug-mem");
|
---|
171 | Bool_t kMoon = arg.HasOnlyAndRemove("--moon");
|
---|
172 | Int_t kDebugEnv = arg.HasOnlyAndRemove("--debug-env") ? 1 : 0;
|
---|
173 | kDebugEnv = arg.GetIntAndRemove("--debug-env=", kDebugEnv);
|
---|
174 |
|
---|
175 | const Bool_t kQuit = arg.HasOnlyAndRemove("-q");
|
---|
176 | const Bool_t kBatch = arg.HasOnlyAndRemove("-b");
|
---|
177 | const Bool_t kOverwrite = arg.HasOnlyAndRemove("-f");
|
---|
178 | //const Bool_t kForceExec = arg.HasOnlyAndRemove("-ff");
|
---|
179 |
|
---|
180 | const TString kInpathD = arg.GetStringAndRemove("--ind=", "");
|
---|
181 | TString kInpathY = arg.GetStringAndRemove("--iny=", "");
|
---|
182 | TString kOutpathY = arg.GetStringAndRemove("--outy=", "");
|
---|
183 | TString kOutpathC = arg.GetStringAndRemove("--outc=", "");
|
---|
184 | const TString kOutpath = arg.GetStringAndRemove("--out=", "");
|
---|
185 | const TString kPath = arg.GetStringAndRemove("--path=", "");
|
---|
186 |
|
---|
187 | Bool_t kModeC = arg.HasOnlyAndRemove("-c");
|
---|
188 | Bool_t kModeY = arg.HasOnlyAndRemove("-y");
|
---|
189 |
|
---|
190 | MJCalib::DataType_t kDataType = MJCalib::kIsUseRawData; // root
|
---|
191 | if (arg.HasOnlyAndRemove("-root"))
|
---|
192 | kDataType = MJCalib::kIsUseRootData; // root
|
---|
193 | if (arg.HasOnlyAndRemove("-raw"))
|
---|
194 | kDataType = MJCalib::kIsUseRawData; // raw
|
---|
195 | if (arg.HasOnlyAndRemove("-mc"))
|
---|
196 | kDataType = MJCalib::kIsUseMC; // monte carlo
|
---|
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
|
---|
205 | //
|
---|
206 | if (arg.GetNumArguments()!=1)
|
---|
207 | {
|
---|
208 | Usage();
|
---|
209 | return 2;
|
---|
210 | }
|
---|
211 |
|
---|
212 | if (arg.GetNumOptions()>0)
|
---|
213 | {
|
---|
214 | gLog << warn << "WARNING - Unknown commandline options..." << endl;
|
---|
215 | arg.Print("options");
|
---|
216 | gLog << endl;
|
---|
217 | return 2;
|
---|
218 | }
|
---|
219 |
|
---|
220 | if (!kModeC && !kModeY /*&& !kUseTest*/)
|
---|
221 | {
|
---|
222 | gLog << err << "Neither calibration (-c), signal extraction (-y) or test-mode (--use-test)" << endl;
|
---|
223 | gLog << "specified! You can also give the operation mode by the options defining the" << endl;
|
---|
224 | gLog << "output path --outc, --outy or --out." << endl;
|
---|
225 | Usage();
|
---|
226 | return 2;
|
---|
227 | }
|
---|
228 |
|
---|
229 | if ((kModeC/* || kUseTest*/) && kOutpathC.IsNull())
|
---|
230 | kOutpathC = ".";
|
---|
231 | if (kModeY)
|
---|
232 | {
|
---|
233 | if (kInpathY.IsNull())
|
---|
234 | kInpathY = ".";
|
---|
235 | if (kOutpathY.IsNull())
|
---|
236 | kOutpathY = ".";
|
---|
237 | }
|
---|
238 | if (!kOutpath.IsNull())
|
---|
239 | {
|
---|
240 | kOutpathC = kOutpath;
|
---|
241 | kOutpathY = kOutpath;
|
---|
242 | }
|
---|
243 | if (!kPath.IsNull())
|
---|
244 | {
|
---|
245 | kOutpathC = kOutpath;
|
---|
246 | kOutpathY = kOutpath;
|
---|
247 | kInpathY = kOutpath;
|
---|
248 | }
|
---|
249 |
|
---|
250 | if (kModeC && kModeY)
|
---|
251 | kInpathY = kOutpathC;
|
---|
252 |
|
---|
253 | //
|
---|
254 | // Setup sequence file and check for its existance
|
---|
255 | //
|
---|
256 | TString kSequence = arg.GetArgumentStr(0);
|
---|
257 |
|
---|
258 | if (kSequence.IsDigit())
|
---|
259 | {
|
---|
260 | const Int_t numseq = kSequence.Atoi();
|
---|
261 | kSequence = Form("/magic/sequences/%04d/sequence%08d.txt", numseq/10000, numseq);
|
---|
262 | gLog << inf << "Inflated sequence file: " << kSequence << endl;
|
---|
263 | }
|
---|
264 |
|
---|
265 | if (gSystem->AccessPathName(kSequence, kFileExists))
|
---|
266 | {
|
---|
267 | gLog << err << "Sorry, sequence file '" << kSequence << "' doesn't exist." << endl;
|
---|
268 | return 3;
|
---|
269 | }
|
---|
270 |
|
---|
271 | if (gSystem->AccessPathName(kConfig, kFileExists))
|
---|
272 | {
|
---|
273 | gLog << err << "Sorry, config file '" << kConfig << "' doesn't exist." << endl;
|
---|
274 | return 4;
|
---|
275 | }
|
---|
276 |
|
---|
277 | if (kDebugMem)
|
---|
278 | TObject::SetObjectStat(kTRUE);
|
---|
279 |
|
---|
280 | //
|
---|
281 | // Setup sequence and check its validity
|
---|
282 | //
|
---|
283 | MSequence seq(kSequence);
|
---|
284 | if (kPrintSeq)
|
---|
285 | {
|
---|
286 | gLog << all;
|
---|
287 | gLog.Separator(kSequence);
|
---|
288 | seq.Print();
|
---|
289 | gLog << endl;
|
---|
290 | }
|
---|
291 | if (!seq.IsValid())
|
---|
292 | {
|
---|
293 | gLog << err << "Sequence read but not valid!" << endl << endl;
|
---|
294 | return 5;
|
---|
295 | }
|
---|
296 |
|
---|
297 | //
|
---|
298 | // Process print options
|
---|
299 | //
|
---|
300 | if (kPrintFiles)
|
---|
301 | PrintFiles(seq, kInpathD, kDataType==MJCalib::kIsUseRawData, kFALSE);
|
---|
302 | if (kPrintFound)
|
---|
303 | PrintFiles(seq, kInpathD, kDataType==MJCalib::kIsUseRawData, kTRUE);
|
---|
304 |
|
---|
305 | if (seq.HasMoon())
|
---|
306 | kMoon = kTRUE;
|
---|
307 |
|
---|
308 |
|
---|
309 | /*
|
---|
310 | //
|
---|
311 | // Check for existance of all files
|
---|
312 | //
|
---|
313 | MDirIter iter;
|
---|
314 | const Int_t n0 = seq.SetupAllRuns(iter, kInpathD, "[DPC]");
|
---|
315 | const Int_t n1 = seq.GetNumAllRuns();
|
---|
316 | if (n0 != n1)
|
---|
317 | {
|
---|
318 | if (kForceExec)
|
---|
319 | gLog << warn << "WARNING";
|
---|
320 | else
|
---|
321 | gLog << err << "ERROR";
|
---|
322 | gLog << " - " << n1 << " files in sequence defined, but " << n0 << " found in ";
|
---|
323 | gLog << (kInpathD.IsNull() ? "<defaultpath>" : kInpathD.Data()) << endl;
|
---|
324 | if (!kForceExec)
|
---|
325 | return 2;
|
---|
326 | }
|
---|
327 |
|
---|
328 | if (kPrintOnly)
|
---|
329 | return 0;
|
---|
330 | */
|
---|
331 | //
|
---|
332 | // Initialize root
|
---|
333 | //
|
---|
334 | MArray::Class()->IgnoreTObjectStreamer();
|
---|
335 | MParContainer::Class()->IgnoreTObjectStreamer();
|
---|
336 |
|
---|
337 | TApplication app("callisto", &argc, argv);
|
---|
338 | if (!gROOT->IsBatch() && !gClient || gROOT->IsBatch() && !kBatch)
|
---|
339 | {
|
---|
340 | gLog << err << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
|
---|
341 | return 1;
|
---|
342 | }
|
---|
343 |
|
---|
344 | //
|
---|
345 | // Update frequency by default = 1Hz
|
---|
346 | //
|
---|
347 | MStatusDisplay *d = new MStatusDisplay;
|
---|
348 |
|
---|
349 | // From now on each 'Exit' means: Terminate the application
|
---|
350 | d->SetBit(MStatusDisplay::kExitLoopOnExit);
|
---|
351 | d->SetTitle(kSequence);
|
---|
352 |
|
---|
353 | MEnv env(kConfig);
|
---|
354 | if (!env.IsValid())
|
---|
355 | {
|
---|
356 | gLog << err << "Configuration file " << kConfig << " not found." << endl;
|
---|
357 | return 0xfe;
|
---|
358 | }
|
---|
359 |
|
---|
360 | if (kModeC/* || kUseTest*/)
|
---|
361 | {
|
---|
362 | //
|
---|
363 | // Calculate pedestal for pedestal-calculation and calibration
|
---|
364 | //
|
---|
365 | MJPedestal job1(Form("MJPedestalC1 #%d", seq.GetSequence()));
|
---|
366 | job1.SetNoStorage();
|
---|
367 | job1.SetSequence(seq);
|
---|
368 | job1.SetEnv(&env);
|
---|
369 | job1.SetEnvDebug(kDebugEnv);
|
---|
370 | job1.SetDisplay(d);
|
---|
371 | job1.SetOverwrite(kOverwrite);
|
---|
372 | job1.SetPathData(kInpathD);
|
---|
373 | job1.SetDataType(kDataType);
|
---|
374 | job1.SetUseHists(kMoon);
|
---|
375 |
|
---|
376 |
|
---|
377 | job1.SetExtractionFundamental();
|
---|
378 | // job1.SetPathOut(kOutpathC); // not yet needed
|
---|
379 | // job1.SetPathIn(kInpathC); // DO NOT CALL IT. IT WOULD READ THE XEXTRACTOR FROM calib-file
|
---|
380 |
|
---|
381 | if (!job1.Process())
|
---|
382 | {
|
---|
383 | gLog << err << "Calculation of pedestal failed." << endl << endl;
|
---|
384 | return 6;
|
---|
385 | }
|
---|
386 |
|
---|
387 | if (!job1.GetDisplay())
|
---|
388 | {
|
---|
389 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
390 | return 1;
|
---|
391 | }
|
---|
392 |
|
---|
393 | //
|
---|
394 | // Calculate pedestal and pedestal resolution
|
---|
395 | //
|
---|
396 | MJPedestal job2(Form("MJPedestalC2 #%d", seq.GetSequence()));
|
---|
397 | job2.SetNoStorage();
|
---|
398 | job2.SetSequence(seq);
|
---|
399 | job2.SetEnv(&env);
|
---|
400 | job2.SetEnvDebug(kDebugEnv);
|
---|
401 | job2.SetDisplay(d);;
|
---|
402 | job2.SetOverwrite(kOverwrite);
|
---|
403 | job2.SetPathData(kInpathD);
|
---|
404 | job2.SetDataType(kDataType);
|
---|
405 | job2.SetUseHists(kMoon);
|
---|
406 | job2.SetDeadPixelCheck();
|
---|
407 | // job1.SetPathOut(kOutpathC); // not yet needed
|
---|
408 | // job1.SetPathIn(kInpathC); // DO NOT CALL IT. IT WOULD READ THE XEXTRACTOR FROM calib-file
|
---|
409 |
|
---|
410 | //job2.SetExtractorResolution();
|
---|
411 | job2.SetExtractionWithExtractorRndm();
|
---|
412 | job2.SetExtractor(job1.GetExtractor());
|
---|
413 | job2.SetPedestals(job1.GetPedestalCam());
|
---|
414 | job2.SetBadPixels(job1.GetBadPixels());
|
---|
415 |
|
---|
416 | // Please check the Changelog of 2005/04/20 about further deatils of the next comment
|
---|
417 | //if (job1.GetExtractor().InheritsFrom("MExtractTimeAndCharge"))
|
---|
418 | if (!job2.Process())
|
---|
419 | {
|
---|
420 | gLog << err << "Calculation of pedestal resolution failed." << endl << endl;
|
---|
421 | return 7;
|
---|
422 | }
|
---|
423 |
|
---|
424 | if (!job2.GetDisplay())
|
---|
425 | {
|
---|
426 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
427 | return 1;
|
---|
428 | }
|
---|
429 |
|
---|
430 | //
|
---|
431 | // Do calibration
|
---|
432 | //
|
---|
433 | MJCalibration job3(Form("MJCalibration #%d", seq.GetSequence()));
|
---|
434 | job3.SetSequence(seq);
|
---|
435 | job3.SetEnv(&env);
|
---|
436 | job3.SetEnvDebug(kDebugEnv);
|
---|
437 | job3.SetDisplay(d);
|
---|
438 | job3.SetOverwrite(kOverwrite);
|
---|
439 | job3.SetPathOut(kOutpathC);
|
---|
440 | job3.SetPathData(kInpathD);
|
---|
441 | job3.SetDataType(kDataType);
|
---|
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 | job4.SetPathData(kInpathD);
|
---|
474 | job4.SetDataType(kDataType);
|
---|
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.SetPathData(kInpathD);
|
---|
509 | job1.SetPathIn(kInpathY); // --> READ Extractor from calib-file
|
---|
510 | job1.SetDataType(kDataType);
|
---|
511 | //job1.SetPathOut(kOutpathY); // not yet needed
|
---|
512 | job1.SetUseData();
|
---|
513 | job1.SetExtractionFundamental();
|
---|
514 | job1.SetUseHists(kMoon);
|
---|
515 |
|
---|
516 | if (!job1.Process())
|
---|
517 | {
|
---|
518 | gLog << err << "Calculation of fundamental pedestal failed." << endl << endl;
|
---|
519 | return 10;
|
---|
520 | }
|
---|
521 |
|
---|
522 | if (!job1.GetDisplay())
|
---|
523 | {
|
---|
524 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
525 | return 1;
|
---|
526 | }
|
---|
527 |
|
---|
528 | //
|
---|
529 | // Calculate pedestal and pedestal resolution
|
---|
530 | //
|
---|
531 | MJPedestal job2(Form("MJPedestalY2 #%d", seq.GetSequence()));
|
---|
532 | job2.SetNoStorage();
|
---|
533 | job2.SetSequence(seq);
|
---|
534 | job2.SetEnv(&env);
|
---|
535 | job2.SetEnvDebug(kDebugEnv);
|
---|
536 | job2.SetDisplay(d);
|
---|
537 | job2.SetNoDisplay();
|
---|
538 | job2.SetOverwrite(kOverwrite);
|
---|
539 | job2.SetPathData(kInpathD);
|
---|
540 | job2.SetPathIn(kInpathY);
|
---|
541 | job2.SetDataType(kDataType);
|
---|
542 | job2.SetPulsePosCheck(kDataType!=MJCalib::kIsUseMC);
|
---|
543 | job2.SetPathOut(kOutpathY); // for updating the extractor
|
---|
544 |
|
---|
545 | job2.SetUseData();
|
---|
546 | job2.SetExtractionWithExtractorRndm();
|
---|
547 | job2.SetExtractor(job1.GetExtractor());
|
---|
548 | job2.SetPedestals(job1.GetPedestalCam());
|
---|
549 | job2.SetBadPixels(job1.GetBadPixels());
|
---|
550 | job2.SetUseHists(kMoon);
|
---|
551 |
|
---|
552 | // Please check the Changelog of 2005/04/20 about further deatils of the next comment
|
---|
553 | //if (job1.GetExtractor().InheritsFrom("MExtractTimeAndCharge"))
|
---|
554 | const Int_t rc = job2.Process();
|
---|
555 | if (rc<=0)
|
---|
556 | {
|
---|
557 | // rc==0: Error
|
---|
558 | // rc==-1: too much to the left
|
---|
559 | // rc==-2: too much to the right
|
---|
560 | // rc==-3: too much to the right (beyond limits)
|
---|
561 |
|
---|
562 | gLog << err << "Calculation of pedestal from extractor (random) failed." << endl << endl;
|
---|
563 |
|
---|
564 | //error coding for the automatic analysis (to be filled into the database)
|
---|
565 | switch (rc)
|
---|
566 | {
|
---|
567 | case 0:
|
---|
568 | return 11;
|
---|
569 | case -1:
|
---|
570 | return 12;
|
---|
571 | case -2:
|
---|
572 | return 13;
|
---|
573 | case -3:
|
---|
574 | return 14;
|
---|
575 | }
|
---|
576 | return 2;
|
---|
577 | }
|
---|
578 |
|
---|
579 | if (!job2.GetDisplay())
|
---|
580 | {
|
---|
581 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
582 | return 1;
|
---|
583 | }
|
---|
584 |
|
---|
585 | //
|
---|
586 | // Calculate pedestal and pedestal resolution
|
---|
587 | //
|
---|
588 | MJPedestal job3(Form("MJPedestalY3 #%d", seq.GetSequence()));
|
---|
589 | job3.SetNoStorage();
|
---|
590 | job3.SetSequence(seq);
|
---|
591 | job3.SetEnv(&env);
|
---|
592 | job3.SetEnvDebug(kDebugEnv);
|
---|
593 | job3.SetDisplay(d);
|
---|
594 | job3.SetNoDisplay();
|
---|
595 | job3.SetOverwrite(kOverwrite);
|
---|
596 | job3.SetPathData(kInpathD);
|
---|
597 | job3.SetPathIn(kInpathY);
|
---|
598 | job3.SetDataType(kDataType);
|
---|
599 | // job1.SetPathOut(kOutpathC); // not yet needed
|
---|
600 | // job1.SetPathIn(kInpathC); // not yet needed
|
---|
601 |
|
---|
602 | job3.SetUseData();
|
---|
603 | job3.SetExtractionWithExtractor();
|
---|
604 | job3.SetExtractor(job2.GetExtractor());
|
---|
605 | job3.SetPedestals(job1.GetPedestalCam());
|
---|
606 | job3.SetBadPixels(job1.GetBadPixels());
|
---|
607 | job3.SetUseHists(kMoon);
|
---|
608 |
|
---|
609 | if (!job3.Process())
|
---|
610 | {
|
---|
611 | gLog << err << "Calculation of pedestal from extractor failed." << endl << endl;
|
---|
612 | return 15;
|
---|
613 | }
|
---|
614 |
|
---|
615 | if (!job3.GetDisplay())
|
---|
616 | {
|
---|
617 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
618 | return 1;
|
---|
619 | }
|
---|
620 |
|
---|
621 | //
|
---|
622 | // Extract signal and calibrate it
|
---|
623 | //
|
---|
624 | MJCalibrateSignal job4(Form("MJCalibrateSignal #%d", seq.GetSequence()));
|
---|
625 | job4.SetSequence(seq);
|
---|
626 | job4.SetDisplay(d);;
|
---|
627 | job4.SetEnv(&env);
|
---|
628 | job4.SetEnvDebug(kDebugEnv);
|
---|
629 | job4.SetOverwrite(kOverwrite);
|
---|
630 | job4.SetPathIn(kInpathY);
|
---|
631 | job4.SetPathOut(kOutpathY);
|
---|
632 | job4.SetPathData(kInpathD);
|
---|
633 | job4.SetDataType(kDataType);
|
---|
634 | if (kDataType!=MJCalib::kIsUseMC)
|
---|
635 | job4.SetExtractor(job2.GetExtractor());
|
---|
636 |
|
---|
637 | // Where to search for calibration files
|
---|
638 | if (!job4.Process(job1.GetPedestalCam(), job3.GetPedestalCam(), job2.GetPedestalCam()))
|
---|
639 | return 16;
|
---|
640 |
|
---|
641 | if (kDebugEnv>0)
|
---|
642 | env.PrintUntouched();
|
---|
643 |
|
---|
644 | if (!job4.GetDisplay())
|
---|
645 | {
|
---|
646 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
647 | return 1;
|
---|
648 | }
|
---|
649 | }
|
---|
650 |
|
---|
651 | if (kBatch || kQuit)
|
---|
652 | delete d;
|
---|
653 | else
|
---|
654 | {
|
---|
655 | // From now on each 'Close' means: Terminate the application
|
---|
656 | d->SetBit(MStatusDisplay::kExitLoopOnClose);
|
---|
657 |
|
---|
658 | // Wait until the user decides to exit the application
|
---|
659 | app.Run(kFALSE);
|
---|
660 | }
|
---|
661 |
|
---|
662 | if (TObject::GetObjectStat())
|
---|
663 | {
|
---|
664 | TObject::SetObjectStat(kFALSE);
|
---|
665 | gObjectTable->Print();
|
---|
666 | }
|
---|
667 |
|
---|
668 | return 0;
|
---|
669 | }
|
---|
670 |
|
---|