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