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 on <" << __DATE__ << ">" << endl;
|
---|
36 | gLog << " Using ROOT v" << ROOTVER << endl;
|
---|
37 | gLog << "========================================================" << endl;
|
---|
38 | gLog << endl;
|
---|
39 | }
|
---|
40 |
|
---|
41 | static void Usage()
|
---|
42 | {
|
---|
43 | // 1 2 3 4 5 6 7 8
|
---|
44 | // 12345678901234567890123456789012345678901234567890123456789012345678901234567890
|
---|
45 | gLog << all << endl;
|
---|
46 | gLog << "Sorry the usage is:" << endl;
|
---|
47 | gLog << " callisto [-c] [-y] [options] sequence.txt" << endl << endl;
|
---|
48 | gLog << " Arguments:" << endl;
|
---|
49 | gLog << " sequence.txt: Ascii file defining a sequence of runs" << 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" << endl;
|
---|
58 | gLog << " -mc Input root-files are monte carlo files" << endl;
|
---|
59 | gLog << " -root Read input from root-files (merpped) <default>" << 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 corresponmding 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 << " contants. 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 independantly 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 | StartUpMessage();
|
---|
145 |
|
---|
146 | //
|
---|
147 | // Evaluate arguments
|
---|
148 | //
|
---|
149 | MArgs arg(argc, argv, kTRUE);
|
---|
150 |
|
---|
151 | if (arg.HasOnly("-V") || arg.HasOnly("--version"))
|
---|
152 | return 0;
|
---|
153 |
|
---|
154 | if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
|
---|
155 | {
|
---|
156 | Usage();
|
---|
157 | return 2;
|
---|
158 | }
|
---|
159 |
|
---|
160 | gLog.Setup(arg);
|
---|
161 |
|
---|
162 | const TString kConfig = arg.GetStringAndRemove("--config=", "callisto.rc");
|
---|
163 |
|
---|
164 | const Bool_t kPrintSeq = arg.HasOnlyAndRemove("--print-seq");
|
---|
165 | const Bool_t kPrintFiles = arg.HasOnlyAndRemove("--print-files");
|
---|
166 | const Bool_t kPrintFound = arg.HasOnlyAndRemove("--print-found");
|
---|
167 | const Bool_t kUseTest = arg.HasOnlyAndRemove("--use-test");
|
---|
168 | const Bool_t kDebugMem = arg.HasOnlyAndRemove("--debug-mem");
|
---|
169 | Bool_t kMoon = arg.HasOnlyAndRemove("--moon");
|
---|
170 | Int_t kDebugEnv = arg.HasOnlyAndRemove("--debug-env") ? 1 : 0;
|
---|
171 | kDebugEnv = arg.GetIntAndRemove("--debug-env=", kDebugEnv);
|
---|
172 |
|
---|
173 | const Bool_t kQuit = arg.HasOnlyAndRemove("-q");
|
---|
174 | const Bool_t kBatch = arg.HasOnlyAndRemove("-b");
|
---|
175 | const Bool_t kOverwrite = arg.HasOnlyAndRemove("-f");
|
---|
176 | //const Bool_t kForceExec = arg.HasOnlyAndRemove("-ff");
|
---|
177 |
|
---|
178 | const TString kInpathD = arg.GetStringAndRemove("--ind=", "");
|
---|
179 | TString kInpathY = arg.GetStringAndRemove("--iny=", "");
|
---|
180 | TString kOutpathY = arg.GetStringAndRemove("--outy=", "");
|
---|
181 | TString kOutpathC = arg.GetStringAndRemove("--outc=", "");
|
---|
182 | const TString kOutpath = arg.GetStringAndRemove("--out=", "");
|
---|
183 | const TString kPath = arg.GetStringAndRemove("--path=", "");
|
---|
184 |
|
---|
185 | Bool_t kModeC = arg.HasOnlyAndRemove("-c");
|
---|
186 | Bool_t kModeY = arg.HasOnlyAndRemove("-y");
|
---|
187 |
|
---|
188 | MJCalib::DataType_t kDataType = MJCalib::kIsUseRootData; // root
|
---|
189 | if (arg.HasOnlyAndRemove("-raw"))
|
---|
190 | kDataType = MJCalib::kIsUseRawData; // raw
|
---|
191 | if (arg.HasOnlyAndRemove("-mc"))
|
---|
192 | kDataType = MJCalib::kIsUseMC; // monte carlo
|
---|
193 |
|
---|
194 | if (!kInpathY.IsNull() || !kOutpathY.IsNull() || !kOutpath.IsNull() || !kPath.IsNull())
|
---|
195 | kModeY = kTRUE;
|
---|
196 | if (!kOutpathC.IsNull() || !kOutpath.IsNull() || !kPath.IsNull())
|
---|
197 | kModeC = kTRUE;
|
---|
198 |
|
---|
199 | if (!kModeC && !kModeY /*&& !kUseTest*/)
|
---|
200 | {
|
---|
201 | gLog << err << "Neither calibration (-c) nor signal extraction (-y) or test-mode (--use-test) specified!" << endl;
|
---|
202 | Usage();
|
---|
203 | return 2;
|
---|
204 | }
|
---|
205 |
|
---|
206 | if ((kModeC/* || kUseTest*/) && kOutpathC.IsNull())
|
---|
207 | kOutpathC = ".";
|
---|
208 | if (kModeY)
|
---|
209 | {
|
---|
210 | if (kInpathY.IsNull())
|
---|
211 | kInpathY = ".";
|
---|
212 | if (kOutpathY.IsNull())
|
---|
213 | kOutpathY = ".";
|
---|
214 | }
|
---|
215 | if (!kOutpath.IsNull())
|
---|
216 | {
|
---|
217 | kOutpathC = kOutpath;
|
---|
218 | kOutpathY = kOutpath;
|
---|
219 | }
|
---|
220 | if (!kPath.IsNull())
|
---|
221 | {
|
---|
222 | kOutpathC = kOutpath;
|
---|
223 | kOutpathY = kOutpath;
|
---|
224 | kInpathY = kOutpath;
|
---|
225 | }
|
---|
226 |
|
---|
227 | if (kModeC && kModeY)
|
---|
228 | kInpathY = kOutpathC;
|
---|
229 |
|
---|
230 | if (arg.GetNumOptions()>0)
|
---|
231 | {
|
---|
232 | gLog << warn << "WARNING - Unknown commandline options..." << endl;
|
---|
233 | arg.Print("options");
|
---|
234 | gLog << endl;
|
---|
235 | return 2;
|
---|
236 | }
|
---|
237 |
|
---|
238 | //
|
---|
239 | // check for the right usage of the program
|
---|
240 | //
|
---|
241 | if (arg.GetNumArguments()!=1)
|
---|
242 | {
|
---|
243 | Usage();
|
---|
244 | return 2;
|
---|
245 | }
|
---|
246 |
|
---|
247 | //
|
---|
248 | // Setup sequence file and check for its existance
|
---|
249 | //
|
---|
250 | const TString kSequence = arg.GetArgumentStr(0);
|
---|
251 |
|
---|
252 | if (gSystem->AccessPathName(kSequence, kFileExists))
|
---|
253 | {
|
---|
254 | gLog << err << "Sorry, sequence file '" << kSequence << "' doesn't exist." << endl;
|
---|
255 | return 2;
|
---|
256 | }
|
---|
257 |
|
---|
258 | if (gSystem->AccessPathName(kConfig, kFileExists))
|
---|
259 | {
|
---|
260 | gLog << err << "Sorry, config file '" << kConfig << "' doesn't exist." << endl;
|
---|
261 | return 2;
|
---|
262 | }
|
---|
263 |
|
---|
264 | if (kDebugMem)
|
---|
265 | TObject::SetObjectStat(kTRUE);
|
---|
266 |
|
---|
267 | //
|
---|
268 | // Setup sequence and check its validity
|
---|
269 | //
|
---|
270 | MSequence seq(kSequence);
|
---|
271 | if (kPrintSeq)
|
---|
272 | {
|
---|
273 | gLog << all;
|
---|
274 | gLog.Separator(kSequence);
|
---|
275 | seq.Print();
|
---|
276 | gLog << endl;
|
---|
277 | }
|
---|
278 | if (!seq.IsValid())
|
---|
279 | {
|
---|
280 | gLog << err << "Sequence read but not valid!" << endl << endl;
|
---|
281 | return 2;
|
---|
282 | }
|
---|
283 |
|
---|
284 | //
|
---|
285 | // Process print options
|
---|
286 | //
|
---|
287 | if (kPrintFiles)
|
---|
288 | PrintFiles(seq, kInpathD, kDataType==MJCalib::kIsUseRawData, kFALSE);
|
---|
289 | if (kPrintFound)
|
---|
290 | PrintFiles(seq, kInpathD, kDataType==MJCalib::kIsUseRawData, kTRUE);
|
---|
291 |
|
---|
292 | if (seq.HasMoon())
|
---|
293 | kMoon = kTRUE;
|
---|
294 |
|
---|
295 |
|
---|
296 | /*
|
---|
297 | //
|
---|
298 | // Check for existance of all files
|
---|
299 | //
|
---|
300 | MDirIter iter;
|
---|
301 | const Int_t n0 = seq.SetupAllRuns(iter, kInpathD, "[DPC]");
|
---|
302 | const Int_t n1 = seq.GetNumAllRuns();
|
---|
303 | if (n0 != n1)
|
---|
304 | {
|
---|
305 | if (kForceExec)
|
---|
306 | gLog << warn << "WARNING";
|
---|
307 | else
|
---|
308 | gLog << err << "ERROR";
|
---|
309 | gLog << " - " << n1 << " files in sequence defined, but " << n0 << " found in ";
|
---|
310 | gLog << (kInpathD.IsNull() ? "<defaultpath>" : kInpathD.Data()) << endl;
|
---|
311 | if (!kForceExec)
|
---|
312 | return 2;
|
---|
313 | }
|
---|
314 |
|
---|
315 | if (kPrintOnly)
|
---|
316 | return 0;
|
---|
317 | */
|
---|
318 | //
|
---|
319 | // Initialize root
|
---|
320 | //
|
---|
321 | MArray::Class()->IgnoreTObjectStreamer();
|
---|
322 | MParContainer::Class()->IgnoreTObjectStreamer();
|
---|
323 |
|
---|
324 | TApplication app("Callisto", &argc, argv);
|
---|
325 | if (!gROOT->IsBatch() && !gClient || gROOT->IsBatch() && !kBatch)
|
---|
326 | {
|
---|
327 | gLog << err << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
|
---|
328 | return 1;
|
---|
329 | }
|
---|
330 |
|
---|
331 | //
|
---|
332 | // Update frequency by default = 1Hz
|
---|
333 | //
|
---|
334 | MStatusDisplay *d = new MStatusDisplay;
|
---|
335 |
|
---|
336 | // From now on each 'Exit' means: Terminate the application
|
---|
337 | d->SetBit(MStatusDisplay::kExitLoopOnExit);
|
---|
338 | d->SetTitle(kSequence);
|
---|
339 |
|
---|
340 | MEnv env(kConfig);
|
---|
341 | if (kModeC/* || kUseTest*/)
|
---|
342 | {
|
---|
343 | //
|
---|
344 | // Calculate pedestal for pedestal-calculation and calibration
|
---|
345 | //
|
---|
346 | MJPedestal job1(Form("MJPedestalC1 #%d", seq.GetSequence()));
|
---|
347 | job1.SetNoStorage();
|
---|
348 | job1.SetSequence(seq);
|
---|
349 | job1.SetEnv(&env);
|
---|
350 | job1.SetEnvDebug(kDebugEnv);
|
---|
351 | job1.SetDisplay(d);
|
---|
352 | job1.SetOverwrite(kOverwrite);
|
---|
353 | job1.SetPathData(kInpathD);
|
---|
354 | job1.SetDataType(kDataType);
|
---|
355 | job1.SetUseHists(kMoon);
|
---|
356 |
|
---|
357 |
|
---|
358 | job1.SetExtractionFundamental();
|
---|
359 | // job1.SetPathOut(kOutpathC); // not yet needed
|
---|
360 | // job1.SetPathIn(kInpathC); // not yet needed
|
---|
361 |
|
---|
362 | if (!job1.Process())
|
---|
363 | {
|
---|
364 | gLog << err << "Calculation of pedestal failed." << endl << endl;
|
---|
365 | return 2;
|
---|
366 | }
|
---|
367 |
|
---|
368 | if (!job1.GetDisplay())
|
---|
369 | {
|
---|
370 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
371 | return 1;
|
---|
372 | }
|
---|
373 |
|
---|
374 | //
|
---|
375 | // Calculate pedestal and pedestal resolution
|
---|
376 | //
|
---|
377 | MJPedestal job2(Form("MJPedestalC2 #%d", seq.GetSequence()));
|
---|
378 | job2.SetNoStorage();
|
---|
379 | job2.SetSequence(seq);
|
---|
380 | job2.SetEnv(&env);
|
---|
381 | job2.SetEnvDebug(kDebugEnv);
|
---|
382 | job2.SetDisplay(d);;
|
---|
383 | job2.SetOverwrite(kOverwrite);
|
---|
384 | job2.SetPathData(kInpathD);
|
---|
385 | job2.SetDataType(kDataType);
|
---|
386 | job2.SetUseHists(kMoon);
|
---|
387 | // job1.SetPathOut(kOutpathC); // not yet needed
|
---|
388 | // job1.SetPathIn(kInpathC); // not yet needed
|
---|
389 |
|
---|
390 | //job2.SetExtractorResolution();
|
---|
391 | job2.SetExtractionWithExtractorRndm();
|
---|
392 | job2.SetExtractor(job1.GetExtractor());
|
---|
393 | job2.SetPedestals(job1.GetPedestalCam());
|
---|
394 | job2.SetBadPixels(job1.GetBadPixels());
|
---|
395 |
|
---|
396 | // Please check the Changelog of 2005/04/20 about further deatils of the next comment
|
---|
397 | //if (job1.GetExtractor().InheritsFrom("MExtractTimeAndCharge"))
|
---|
398 | if (!job2.Process())
|
---|
399 | {
|
---|
400 | gLog << err << "Calculation of pedestal resolution failed." << endl << endl;
|
---|
401 | return 2;
|
---|
402 | }
|
---|
403 |
|
---|
404 | if (!job2.GetDisplay())
|
---|
405 | {
|
---|
406 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
407 | return 1;
|
---|
408 | }
|
---|
409 |
|
---|
410 | //
|
---|
411 | // Do calibration
|
---|
412 | //
|
---|
413 | MJCalibration job3(Form("MJCalibration #%d", seq.GetSequence()));
|
---|
414 | job3.SetSequence(seq);
|
---|
415 | job3.SetEnv(&env);
|
---|
416 | job3.SetEnvDebug(kDebugEnv);
|
---|
417 | job3.SetDisplay(d);
|
---|
418 | job3.SetOverwrite(kOverwrite);
|
---|
419 | job3.SetPathOut(kOutpathC);
|
---|
420 | job3.SetPathData(kInpathD);
|
---|
421 | job3.SetDataType(kDataType);
|
---|
422 | // job2.SetPathIn(kInpathC); // not yet needed
|
---|
423 |
|
---|
424 | job3.SetBadPixels(job2.GetBadPixels());
|
---|
425 | job3.SetExtractor(job2.GetExtractor());
|
---|
426 | job3.SetExtractorCam(job2.GetPedestalCam());
|
---|
427 |
|
---|
428 | if (!job3.Process(job1.GetPedestalCam()))
|
---|
429 | {
|
---|
430 | gLog << err << "Calculation of calibration failed." << endl << endl;
|
---|
431 | return 2;
|
---|
432 | }
|
---|
433 |
|
---|
434 | if (kDebugEnv>0)
|
---|
435 | env.PrintUntouched();
|
---|
436 |
|
---|
437 | if (!job3.GetDisplay())
|
---|
438 | {
|
---|
439 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
440 | return 1;
|
---|
441 | }
|
---|
442 |
|
---|
443 | if (kUseTest)
|
---|
444 | {
|
---|
445 | MJCalibTest job4(Form("MJCalibTest #%d", seq.GetSequence()));
|
---|
446 | job4.SetBadPixels(job2.GetBadPixels());
|
---|
447 | job4.SetSequence(seq);
|
---|
448 | job4.SetEnv(&env);
|
---|
449 | job4.SetEnvDebug(kDebugEnv);
|
---|
450 | job4.SetDisplay(d);;
|
---|
451 | job4.SetOverwrite(kOverwrite);
|
---|
452 | job4.SetPathOut(kOutpathC);
|
---|
453 | job4.SetPathData(kInpathD);
|
---|
454 | job4.SetDataType(kDataType);
|
---|
455 |
|
---|
456 | if (!job4.Process(job1.GetPedestalCam()))
|
---|
457 | {
|
---|
458 | gLog << err << "Calibration of calibration failed." << endl << endl;
|
---|
459 | return 2;
|
---|
460 | }
|
---|
461 |
|
---|
462 | if (kDebugEnv>0)
|
---|
463 | env.PrintUntouched();
|
---|
464 |
|
---|
465 | if (!job4.GetDisplay())
|
---|
466 | {
|
---|
467 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
468 | return 1;
|
---|
469 | }
|
---|
470 | }
|
---|
471 | }
|
---|
472 |
|
---|
473 | if (kModeY)
|
---|
474 | {
|
---|
475 | d->Reset();
|
---|
476 |
|
---|
477 | //
|
---|
478 | // Calculate starting pedestal for data extraction
|
---|
479 | //
|
---|
480 | MJPedestal job1(Form("MJPedestalY1 #%d", seq.GetSequence()));
|
---|
481 | job1.SetNoStorage();
|
---|
482 | job1.SetSequence(seq);
|
---|
483 | job1.SetEnv(&env);
|
---|
484 | job1.SetEnvDebug(kDebugEnv);
|
---|
485 | job1.SetDisplay(d);
|
---|
486 | job1.SetNoDisplay();
|
---|
487 | job1.SetOverwrite(kOverwrite);
|
---|
488 | job1.SetPathData(kInpathD);
|
---|
489 | job1.SetPathIn(kInpathY);
|
---|
490 | job1.SetDataType(kDataType);
|
---|
491 | //job1.SetPathOut(kOutpathY); // not yet needed
|
---|
492 | job1.SetUseData();
|
---|
493 | job1.SetExtractionFundamental();
|
---|
494 | job1.SetUseHists(kMoon);
|
---|
495 |
|
---|
496 | if (!job1.Process())
|
---|
497 | {
|
---|
498 | gLog << err << "Calculation of fundamental pedestal failed." << endl << endl;
|
---|
499 | return 2;
|
---|
500 | }
|
---|
501 |
|
---|
502 | if (!job1.GetDisplay())
|
---|
503 | {
|
---|
504 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
505 | return 1;
|
---|
506 | }
|
---|
507 |
|
---|
508 | //
|
---|
509 | // Calculate pedestal and pedestal resolution
|
---|
510 | //
|
---|
511 | MJPedestal job2(Form("MJPedestalY2 #%d", seq.GetSequence()));
|
---|
512 | job2.SetNoStorage();
|
---|
513 | job2.SetSequence(seq);
|
---|
514 | job2.SetEnv(&env);
|
---|
515 | job2.SetEnvDebug(kDebugEnv);
|
---|
516 | job2.SetDisplay(d);
|
---|
517 | job2.SetNoDisplay();
|
---|
518 | job2.SetOverwrite(kOverwrite);
|
---|
519 | job2.SetPathData(kInpathD);
|
---|
520 | job2.SetPathIn(kInpathY);
|
---|
521 | job2.SetDataType(kDataType);
|
---|
522 | job2.SetPulsePosCheck(kDataType!=MJCalib::kIsUseMC);
|
---|
523 | job2.SetPathOut(kOutpathY); // for updating the extractor
|
---|
524 |
|
---|
525 | job2.SetUseData();
|
---|
526 | job2.SetExtractionWithExtractor();
|
---|
527 | job2.SetExtractor(job1.GetExtractor());
|
---|
528 | job2.SetPedestals(job1.GetPedestalCam());
|
---|
529 | job2.SetBadPixels(job1.GetBadPixels());
|
---|
530 | job2.SetUseHists(kMoon);
|
---|
531 |
|
---|
532 | // Please check the Changelog of 2005/04/20 about further deatils of the next comment
|
---|
533 | //if (job1.GetExtractor().InheritsFrom("MExtractTimeAndCharge"))
|
---|
534 | if (!job2.Process())
|
---|
535 | {
|
---|
536 | gLog << err << "Calculation of pedestal from extrtactor (random) failed." << endl << endl;
|
---|
537 | return 2;
|
---|
538 | }
|
---|
539 |
|
---|
540 | if (!job2.GetDisplay())
|
---|
541 | {
|
---|
542 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
543 | return 1;
|
---|
544 | }
|
---|
545 |
|
---|
546 | //
|
---|
547 | // Calculate pedestal and pedestal resolution
|
---|
548 | //
|
---|
549 | MJPedestal job3(Form("MJPedestalY3 #%d", seq.GetSequence()));
|
---|
550 | job3.SetNoStorage();
|
---|
551 | job3.SetSequence(seq);
|
---|
552 | job3.SetEnv(&env);
|
---|
553 | job3.SetEnvDebug(kDebugEnv);
|
---|
554 | job3.SetDisplay(d);
|
---|
555 | job3.SetNoDisplay();
|
---|
556 | job3.SetOverwrite(kOverwrite);
|
---|
557 | job3.SetPathData(kInpathD);
|
---|
558 | job3.SetPathIn(kInpathY);
|
---|
559 | job3.SetDataType(kDataType);
|
---|
560 | // job1.SetPathOut(kOutpathC); // not yet needed
|
---|
561 | // job1.SetPathIn(kInpathC); // not yet needed
|
---|
562 |
|
---|
563 | job3.SetUseData();
|
---|
564 | job3.SetExtractionWithExtractorRndm();
|
---|
565 | job3.SetExtractor(job1.GetExtractor());
|
---|
566 | job3.SetPedestals(job1.GetPedestalCam());
|
---|
567 | job3.SetBadPixels(job1.GetBadPixels());
|
---|
568 | job3.SetUseHists(kMoon);
|
---|
569 |
|
---|
570 | if (!job3.Process())
|
---|
571 | {
|
---|
572 | gLog << err << "Calculation of pedestal from extractor failed." << endl << endl;
|
---|
573 | return 2;
|
---|
574 | }
|
---|
575 |
|
---|
576 | if (!job3.GetDisplay())
|
---|
577 | {
|
---|
578 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
579 | return 1;
|
---|
580 | }
|
---|
581 |
|
---|
582 | //
|
---|
583 | // Extract signal and calibrate it
|
---|
584 | //
|
---|
585 | MJCalibrateSignal job4(Form("MJCalibrateSignal #%d", seq.GetSequence()));
|
---|
586 | job4.SetSequence(seq);
|
---|
587 | job4.SetDisplay(d);;
|
---|
588 | job4.SetEnv(&env);
|
---|
589 | job4.SetEnvDebug(kDebugEnv);
|
---|
590 | job4.SetOverwrite(kOverwrite);
|
---|
591 | job4.SetPathIn(kInpathY);
|
---|
592 | job4.SetPathOut(kOutpathY);
|
---|
593 | job4.SetPathData(kInpathD);
|
---|
594 | job4.SetDataType(kDataType);
|
---|
595 | if (kDataType!=MJCalib::kIsUseMC)
|
---|
596 | job4.SetExtractor(job2.GetExtractor());
|
---|
597 |
|
---|
598 | // Where to search for calibration files
|
---|
599 | if (!job4.Process(job1.GetPedestalCam(), job2.GetPedestalCam(), job3.GetPedestalCam()))
|
---|
600 | return 2;
|
---|
601 |
|
---|
602 | if (kDebugEnv>0)
|
---|
603 | env.PrintUntouched();
|
---|
604 |
|
---|
605 | if (!job4.GetDisplay())
|
---|
606 | {
|
---|
607 | gLog << warn << "Display closed by user... execution aborted." << endl << endl;
|
---|
608 | return 1;
|
---|
609 | }
|
---|
610 | }
|
---|
611 |
|
---|
612 | if (kBatch || kQuit)
|
---|
613 | delete d;
|
---|
614 | else
|
---|
615 | {
|
---|
616 | // From now on each 'Close' means: Terminate the application
|
---|
617 | d->SetBit(MStatusDisplay::kExitLoopOnClose);
|
---|
618 |
|
---|
619 | // Wait until the user decides to exit the application
|
---|
620 | app.Run(kFALSE);
|
---|
621 | }
|
---|
622 |
|
---|
623 | if (TObject::GetObjectStat())
|
---|
624 | {
|
---|
625 | TObject::SetObjectStat(kFALSE);
|
---|
626 | gObjectTable->Print();
|
---|
627 | }
|
---|
628 |
|
---|
629 | return 0;
|
---|
630 | }
|
---|
631 |
|
---|