1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Markus Gaug, 04/2004 <mailto:markus@ifae.es>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2005
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MJCalibTest
|
---|
28 | //
|
---|
29 | // If the flag SetDataCheckDisplay() is set, only the most important distributions
|
---|
30 | // are displayed.
|
---|
31 | // Otherwise, (default: SetNormalDisplay()), a good selection of plots is given
|
---|
32 | //
|
---|
33 | /////////////////////////////////////////////////////////////////////////////
|
---|
34 | #include "MJCalibTest.h"
|
---|
35 |
|
---|
36 | #include <TFile.h>
|
---|
37 | #include <TStyle.h>
|
---|
38 | #include <TCanvas.h>
|
---|
39 | #include <TSystem.h>
|
---|
40 |
|
---|
41 | #include "MLog.h"
|
---|
42 | #include "MLogManip.h"
|
---|
43 |
|
---|
44 | #include "MRunIter.h"
|
---|
45 | #include "MParList.h"
|
---|
46 | #include "MTaskList.h"
|
---|
47 | #include "MTaskEnv.h"
|
---|
48 | #include "MEvtLoop.h"
|
---|
49 |
|
---|
50 | #include "MHCamera.h"
|
---|
51 |
|
---|
52 | #include "MPedestalCam.h"
|
---|
53 | #include "MPedPhotCam.h"
|
---|
54 | #include "MBadPixelsCam.h"
|
---|
55 | #include "MBadPixelsTreat.h"
|
---|
56 | #include "MBadPixelsCalc.h"
|
---|
57 | #include "MBadPixelsMerge.h"
|
---|
58 | #include "MCerPhotEvt.h"
|
---|
59 | #include "MArrivalTime.h"
|
---|
60 | #include "MCalibrationChargeCam.h"
|
---|
61 | #include "MCalibrationRelTimeCam.h"
|
---|
62 | #include "MCalibrationQECam.h"
|
---|
63 | #include "MCalibrationTestCam.h"
|
---|
64 | #include "MCalibrationTestCalc.h"
|
---|
65 | #include "MHCamEvent.h"
|
---|
66 | #include "MHCalibrationTestCam.h"
|
---|
67 | #include "MHCalibrationTestTimeCam.h"
|
---|
68 | #include "MHCalibrationPix.h"
|
---|
69 |
|
---|
70 | #include "MReadMarsFile.h"
|
---|
71 | #include "MRawFileRead.h"
|
---|
72 | #include "MGeomApply.h"
|
---|
73 | #include "MGeomCam.h"
|
---|
74 | #include "MExtractTimeAndChargeSlidingWindow.h"
|
---|
75 | #include "MExtractor.h"
|
---|
76 | #include "MExtractTime.h"
|
---|
77 | #include "MExtractTimeFastSpline.h"
|
---|
78 | #include "MFCosmics.h"
|
---|
79 | #include "MContinue.h"
|
---|
80 | #include "MFillH.h"
|
---|
81 | #include "MCalibrateData.h"
|
---|
82 | #include "MCalibrateRelTimes.h"
|
---|
83 |
|
---|
84 | #include "MTriggerPattern.h"
|
---|
85 | #include "MTriggerPatternDecode.h"
|
---|
86 | #include "MFTriggerPattern.h"
|
---|
87 |
|
---|
88 | #include "MStatusDisplay.h"
|
---|
89 |
|
---|
90 | ClassImp(MJCalibTest);
|
---|
91 |
|
---|
92 | using namespace std;
|
---|
93 | // --------------------------------------------------------------------------
|
---|
94 | //
|
---|
95 | // Default constructor.
|
---|
96 | //
|
---|
97 | // Sets fUseCosmicsFilter to kTRUE, fRuns to 0, fExtractor to NULL, fTimeExtractor to NULL
|
---|
98 | // fDisplay to kNormalDisplay
|
---|
99 | //
|
---|
100 | MJCalibTest::MJCalibTest(const char *name, const char *title)
|
---|
101 | : fUseCosmicsFilter(kTRUE), fExtractor(NULL), fTimeExtractor(NULL),
|
---|
102 | fDisplayType(kNormalDisplay), fGeometry("MGeomCamMagic")
|
---|
103 | {
|
---|
104 | fName = name ? name : "MJCalibTest";
|
---|
105 | fTitle = title ? title : "Tool to extract, calibrate and test signals from a file";
|
---|
106 | }
|
---|
107 |
|
---|
108 |
|
---|
109 | void MJCalibTest::DisplayResult(MParList &plist)
|
---|
110 | {
|
---|
111 | if (!fDisplay)
|
---|
112 | return;
|
---|
113 |
|
---|
114 | //
|
---|
115 | // Get container from list
|
---|
116 | //
|
---|
117 | MGeomCam &geomcam = *(MGeomCam*) plist.FindObject("MGeomCam");
|
---|
118 | MHCalibrationTestCam &testcam = *(MHCalibrationTestCam*)plist.FindObject("MHCalibrationTestCam");
|
---|
119 |
|
---|
120 | // Create histograms to display
|
---|
121 | MHCamera disp1 (geomcam, "Test;PhotoElectrons", "Mean equiv. phes");
|
---|
122 | MHCamera disp2 (geomcam, "Test;SigmaPhes", "Sigma equiv.phes");
|
---|
123 | MHCamera disp3 (geomcam, "Test;PhesPerArea", "Equiv. Phes per Area");
|
---|
124 | MHCamera disp4 (geomcam, "Test;SigmaPhotPerArea", "Sigma equiv. Phes per Area");
|
---|
125 | MHCamera disp5 (geomcam, "Test;Phot", "Calibrated Phes from Fit");
|
---|
126 | MHCamera disp6 (geomcam, "Test;PhotPerArea", "Calibrated Phes per Area from Fit");
|
---|
127 | MHCamera disp7 (geomcam, "Test;NotInterpolate", "Not interpolated pixels");
|
---|
128 | MHCamera disp8 (geomcam, "Test;DeviatingPhots", "Deviating Number Phes");
|
---|
129 | MHCamera disp9 (geomcam, "Test;Arr.Times", "Mean of calibrated Arr.Times");
|
---|
130 | MHCamera disp10(geomcam, "Test;SigmaArr.Times", "Sigma of calibrated Arr.Times");
|
---|
131 |
|
---|
132 | // Fitted charge means and sigmas
|
---|
133 | disp1.SetCamContent(testcam, 0);
|
---|
134 | disp1.SetCamError( testcam, 1);
|
---|
135 | disp2.SetCamContent(testcam, 2);
|
---|
136 | disp2.SetCamError( testcam, 3);
|
---|
137 | disp3.SetCamContent(testcam, 7);
|
---|
138 | disp3.SetCamError( testcam, 8);
|
---|
139 | disp4.SetCamContent(testcam, 9);
|
---|
140 | disp4.SetCamError( testcam, 10);
|
---|
141 |
|
---|
142 | disp5.SetCamContent(fTestCam, 0);
|
---|
143 | disp5.SetCamError( fTestCam, 1);
|
---|
144 | disp6.SetCamContent(fTestCam, 2);
|
---|
145 | disp6.SetCamError( fTestCam, 3);
|
---|
146 | disp7.SetCamError( fTestCam, 4);
|
---|
147 |
|
---|
148 | disp8.SetCamError( fBadPixels, 22);
|
---|
149 |
|
---|
150 | disp9.SetCamContent(fTestTimeCam, 0);
|
---|
151 | disp9.SetCamError( fTestTimeCam, 1);
|
---|
152 | disp10.SetCamContent(fTestTimeCam, 2);
|
---|
153 | disp10.SetCamError( fTestTimeCam, 3);
|
---|
154 |
|
---|
155 |
|
---|
156 | disp1.SetYTitle("Phes");
|
---|
157 | disp2.SetYTitle("\\sigma_{phe}");
|
---|
158 | disp3.SetYTitle("Phes per area [mm^{-2}]");
|
---|
159 | disp4.SetYTitle("\\sigma_{phe} per area [mm^{-2}]");
|
---|
160 |
|
---|
161 | disp5.SetYTitle("Phes");
|
---|
162 | disp6.SetYTitle("Phes per area [mm^{-2}]");
|
---|
163 | disp7.SetYTitle("[1]");
|
---|
164 | disp8.SetYTitle("[1]");
|
---|
165 |
|
---|
166 | disp9.SetYTitle("Mean Arr.Times [FADC units]");
|
---|
167 | disp10.SetYTitle("\\sigma_{t} [FADC units]");
|
---|
168 |
|
---|
169 | TCanvas &c = fDisplay->AddTab("TestPhes");
|
---|
170 | c.Divide(4,4);
|
---|
171 |
|
---|
172 | disp1.CamDraw(c, 1, 4, 2, 1);
|
---|
173 | disp2.CamDraw(c, 2, 4, 2, 1);
|
---|
174 | disp3.CamDraw(c, 3, 4, 1, 1);
|
---|
175 | disp4.CamDraw(c, 4, 4, 2, 1);
|
---|
176 |
|
---|
177 | /*
|
---|
178 |
|
---|
179 | TCanvas &c2 = fDisplay->AddTab("TestResult");
|
---|
180 | c2.Divide(2,4);
|
---|
181 |
|
---|
182 | disp5.CamDraw(c2, 1, 2, 2, 1);
|
---|
183 | disp6.CamDraw(c2, 2, 2, 2, 1);
|
---|
184 |
|
---|
185 | */
|
---|
186 |
|
---|
187 | TCanvas &c3 = fDisplay->AddTab("TestDefects");
|
---|
188 | c3.Divide(2,2);
|
---|
189 |
|
---|
190 | disp7.CamDraw(c3, 1, 2, 0);
|
---|
191 | disp8.CamDraw(c3, 2, 2, 0);
|
---|
192 |
|
---|
193 | //
|
---|
194 | // Display times
|
---|
195 | //
|
---|
196 | TCanvas &c4 = fDisplay->AddTab("TestTimes");
|
---|
197 | c4.Divide(2,4);
|
---|
198 |
|
---|
199 | disp9.CamDraw(c4, 1, 2, 5, 1);
|
---|
200 | disp10.CamDraw(c4, 2, 2, 5, 1);
|
---|
201 |
|
---|
202 | return;
|
---|
203 |
|
---|
204 | }
|
---|
205 |
|
---|
206 | // --------------------------------------------------------------------------
|
---|
207 | //
|
---|
208 | // Retrieve the output file written by WriteResult()
|
---|
209 | //
|
---|
210 | const char* MJCalibTest::GetOutputFile() const
|
---|
211 | {
|
---|
212 | const TString name(GetOutputFileName());
|
---|
213 | if (name.IsNull())
|
---|
214 | return "";
|
---|
215 |
|
---|
216 | return Form("%s/%s", fPathOut.Data(), name.Data());
|
---|
217 | }
|
---|
218 |
|
---|
219 |
|
---|
220 | const char* MJCalibTest::GetOutputFileName() const
|
---|
221 | {
|
---|
222 |
|
---|
223 | if (fSequence.IsValid())
|
---|
224 | return Form("calib%08d.root", fSequence.GetSequence());
|
---|
225 |
|
---|
226 | if (!fRuns)
|
---|
227 | return "";
|
---|
228 |
|
---|
229 | return Form("%s-F1.root", (const char*)fRuns->GetRunsAsFileName());
|
---|
230 |
|
---|
231 | }
|
---|
232 |
|
---|
233 | Bool_t MJCalibTest::ReadCalibration(TObjArray &l, MBadPixelsCam &cam, MExtractor* &ext1, MExtractor* &ext2, TString &geom) const
|
---|
234 | {
|
---|
235 |
|
---|
236 | const TString fname = GetOutputFile();
|
---|
237 |
|
---|
238 | *fLog << inf << "Reading from file: " << fname << endl;
|
---|
239 |
|
---|
240 | TFile file(fname, "READ");
|
---|
241 | if (!file.IsOpen())
|
---|
242 | {
|
---|
243 | *fLog << err << dbginf << "ERROR - Could not open file " << fname << endl;
|
---|
244 | return kFALSE;
|
---|
245 | }
|
---|
246 |
|
---|
247 | TObject *o = file.Get("ExtractSignal");
|
---|
248 | if (o && !o->InheritsFrom(MExtractor::Class()))
|
---|
249 | {
|
---|
250 | *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
|
---|
251 | return kFALSE;
|
---|
252 | }
|
---|
253 | ext1 = o ? (MExtractor*)o->Clone() : NULL;
|
---|
254 |
|
---|
255 | o = file.Get("ExtractTime");
|
---|
256 | if (o && !o->InheritsFrom(MExtractor::Class()))
|
---|
257 | {
|
---|
258 | *fLog << err << dbginf << "ERROR - ExtractTime read from " << fname << " doesn't inherit from MExtractor!" << endl;
|
---|
259 | return kFALSE;
|
---|
260 | }
|
---|
261 | ext2 = o ? (MExtractor*)o->Clone() : NULL;
|
---|
262 | if (!ext1 && !ext2)
|
---|
263 | {
|
---|
264 | *fLog << err << dbginf << "ERROR - Neither ExtractSignal nor ExrtractTime found in " << fname << "!" << endl;
|
---|
265 | return kFALSE;
|
---|
266 | }
|
---|
267 |
|
---|
268 | o = file.Get("MGeomCam");
|
---|
269 | if (o && !o->InheritsFrom(MGeomCam::Class()))
|
---|
270 | {
|
---|
271 | *fLog << err << dbginf << "ERROR - MGeomCam read from " << fname << " doesn't inherit from MGeomCam!" << endl;
|
---|
272 | return kFALSE;
|
---|
273 | }
|
---|
274 | geom = o ? o->ClassName() : "";
|
---|
275 |
|
---|
276 | TObjArray cont(l);
|
---|
277 | cont.Add(&cam);
|
---|
278 | return ReadContainer(cont);
|
---|
279 | }
|
---|
280 |
|
---|
281 | // --------------------------------------------------------------------------
|
---|
282 | //
|
---|
283 | // MJCalibration allows to setup several option by a resource file:
|
---|
284 | // MJCalibrateSignal.RawData: yes,no
|
---|
285 | //
|
---|
286 | // For more details see the class description and the corresponding Getters
|
---|
287 | //
|
---|
288 | Bool_t MJCalibTest::CheckEnvLocal()
|
---|
289 | {
|
---|
290 |
|
---|
291 | SetUseRootData();
|
---|
292 |
|
---|
293 | if (HasEnv("DataType"))
|
---|
294 | {
|
---|
295 | TString dat = GetEnv("DataType", "");
|
---|
296 | if (dat.BeginsWith("raw", TString::kIgnoreCase))
|
---|
297 | {
|
---|
298 | fDataFlag = 0;
|
---|
299 | SetUseRawData();
|
---|
300 | }
|
---|
301 | if (dat.BeginsWith("root", TString::kIgnoreCase))
|
---|
302 | {
|
---|
303 | fDataFlag = 0;
|
---|
304 | SetUseRootData();
|
---|
305 | }
|
---|
306 | if (dat.BeginsWith("mc", TString::kIgnoreCase))
|
---|
307 | {
|
---|
308 | fDataFlag = 0;
|
---|
309 | SetUseMC();
|
---|
310 | }
|
---|
311 | }
|
---|
312 | return kTRUE;
|
---|
313 | }
|
---|
314 |
|
---|
315 | Bool_t MJCalibTest::ProcessFile(MPedestalCam &pedcam)
|
---|
316 | {
|
---|
317 |
|
---|
318 |
|
---|
319 | if (!fSequence.IsValid())
|
---|
320 | {
|
---|
321 | if (!fRuns)
|
---|
322 | {
|
---|
323 | *fLog << err << "ERROR - Sequence invalid and no runs chosen!" << endl;
|
---|
324 | return kFALSE;
|
---|
325 | }
|
---|
326 |
|
---|
327 | if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
|
---|
328 | {
|
---|
329 | *fLog << err << "Number of files found doesn't match number of runs... abort."
|
---|
330 | << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl;
|
---|
331 | return kFALSE;
|
---|
332 | }
|
---|
333 | *fLog << "Calibrate data from ";
|
---|
334 | *fLog << "Runs " << fRuns->GetRunsAsString() << endl;
|
---|
335 | *fLog << endl;
|
---|
336 | }
|
---|
337 |
|
---|
338 | CheckEnv();
|
---|
339 |
|
---|
340 | *fLog << inf;
|
---|
341 | fLog->Separator(GetDescriptor());
|
---|
342 |
|
---|
343 | *fLog << "Calibrate Calibration data from ";
|
---|
344 | if (fSequence.IsValid())
|
---|
345 | *fLog << "Sequence #" << fSequence.GetSequence() << endl;
|
---|
346 | else
|
---|
347 | *fLog << "Runs " << fRuns->GetRunsAsString() << endl;
|
---|
348 | *fLog << endl;
|
---|
349 |
|
---|
350 | MDirIter iter;
|
---|
351 |
|
---|
352 | if (fSequence.IsValid())
|
---|
353 | {
|
---|
354 | const Int_t n0 = fSequence.SetupDatRuns(iter, fPathData, "D", IsUseRawData());
|
---|
355 | const Int_t n1 = fSequence.GetNumDatRuns();
|
---|
356 | if (n0==0)
|
---|
357 | {
|
---|
358 | *fLog << err << "ERROR - No input files of sequence found!" << endl;
|
---|
359 | return kFALSE;
|
---|
360 | }
|
---|
361 | if (n0!=n1)
|
---|
362 | {
|
---|
363 | *fLog << err << "ERROR - Number of files found (" << n0 << ") doesn't match number of files in sequence (" << n1 << ")" << endl;
|
---|
364 | return kFALSE;
|
---|
365 | }
|
---|
366 | }
|
---|
367 |
|
---|
368 | MCalibrationChargeCam calcam;
|
---|
369 | MCalibrationQECam qecam;
|
---|
370 | MCalibrationRelTimeCam tmcam;
|
---|
371 | MBadPixelsCam badpix;
|
---|
372 |
|
---|
373 | TObjArray calibcont;
|
---|
374 | calibcont.Add(&calcam);
|
---|
375 | calibcont.Add(&qecam);
|
---|
376 | calibcont.Add(&tmcam);
|
---|
377 |
|
---|
378 | MExtractor *extractor1=0;
|
---|
379 | MExtractor *extractor2=0;
|
---|
380 | TString geom;
|
---|
381 |
|
---|
382 | if (!ReadCalibration(calibcont, badpix, extractor1, extractor2, geom))
|
---|
383 | {
|
---|
384 | *fLog << err << "Could not read calibration constants " << endl;
|
---|
385 | return kFALSE;
|
---|
386 | }
|
---|
387 |
|
---|
388 | *fLog << all;
|
---|
389 | if (extractor1)
|
---|
390 | {
|
---|
391 | *fLog << underline << "Signal Extractor found in calibration file" << endl;
|
---|
392 | extractor1->Print();
|
---|
393 | *fLog << endl;
|
---|
394 | }
|
---|
395 | else
|
---|
396 | *fLog << inf << "No Signal Extractor: ExtractSignal in file." << endl;
|
---|
397 |
|
---|
398 | if (extractor2)
|
---|
399 | {
|
---|
400 | *fLog << underline << "Time Extractor found in calibration file" << endl;
|
---|
401 | extractor2->Print();
|
---|
402 | *fLog << endl;
|
---|
403 | }
|
---|
404 | else
|
---|
405 | *fLog << inf << "No Time Extractor: ExtractTime in file." << endl;
|
---|
406 |
|
---|
407 | if (!geom.IsNull())
|
---|
408 | *fLog << inf << "Camera geometry found in file: " << geom << endl;
|
---|
409 | else
|
---|
410 | *fLog << inf << "No Camera geometry found using default <MGeomCamMagic>" << endl;
|
---|
411 |
|
---|
412 | if (fExtractor)
|
---|
413 | extractor1 = fExtractor;
|
---|
414 | if (fTimeExtractor)
|
---|
415 | extractor2 = fTimeExtractor;
|
---|
416 |
|
---|
417 | // Setup Lists
|
---|
418 | MParList plist;
|
---|
419 | plist.AddToList(this); // take care of fDisplay!
|
---|
420 | plist.AddToList(&fTestCam);
|
---|
421 | plist.AddToList(&fTestTimeCam);
|
---|
422 | plist.AddToList(&badpix);
|
---|
423 | plist.AddToList(&pedcam);
|
---|
424 | plist.AddToList(&calcam);
|
---|
425 | plist.AddToList(&qecam);
|
---|
426 | plist.AddToList(&tmcam);
|
---|
427 |
|
---|
428 | MCerPhotEvt cerphot;
|
---|
429 | MPedPhotCam pedphot;
|
---|
430 | MHCalibrationTestCam testcam;
|
---|
431 |
|
---|
432 | plist.AddToList(&cerphot);
|
---|
433 | plist.AddToList(&pedphot);
|
---|
434 | plist.AddToList(&testcam);
|
---|
435 |
|
---|
436 | pedcam.SetName("MPedestalFundamental");
|
---|
437 |
|
---|
438 | MTaskList tlist;
|
---|
439 | plist.AddToList(&tlist);
|
---|
440 |
|
---|
441 | // Setup Task-lists
|
---|
442 | MRawFileRead rawread(NULL);
|
---|
443 | MReadMarsFile read("Events");
|
---|
444 | read.DisableAutoScheme();
|
---|
445 |
|
---|
446 | if (IsUseRawData())
|
---|
447 | rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns);
|
---|
448 | else
|
---|
449 | static_cast<MRead&>(read).AddFiles(fSequence.IsValid() ? iter : *fRuns);
|
---|
450 |
|
---|
451 | // Check for interleaved events
|
---|
452 | MTriggerPatternDecode decode;
|
---|
453 | MFTriggerPattern fcalib;
|
---|
454 | fcalib.DenyCalibration();
|
---|
455 | MContinue conttp(&fcalib, "ContTrigPattern");
|
---|
456 |
|
---|
457 | MGeomApply apply; // Only necessary to craete geometry
|
---|
458 | if (!geom.IsNull())
|
---|
459 | apply.SetGeometry(geom);
|
---|
460 | MBadPixelsMerge merge(&badpix);
|
---|
461 |
|
---|
462 | MExtractTimeAndChargeSlidingWindow extrsw;
|
---|
463 | MExtractTimeFastSpline extime;
|
---|
464 | extime.SetPedestals(&pedcam);
|
---|
465 |
|
---|
466 | MTaskEnv taskenv1("ExtractSignal");
|
---|
467 | MTaskEnv taskenv2("ExtractTime");
|
---|
468 |
|
---|
469 | if (extractor1)
|
---|
470 | {
|
---|
471 | extractor1->SetPedestals(&pedcam);
|
---|
472 | taskenv1.SetDefault(extractor1);
|
---|
473 | }
|
---|
474 |
|
---|
475 | if (extractor2)
|
---|
476 | {
|
---|
477 | fTimeExtractor->SetPedestals(&pedcam);
|
---|
478 | taskenv2.SetDefault(fTimeExtractor);
|
---|
479 | }
|
---|
480 | else if (!(extractor1->InheritsFrom("MExtractTimeAndCharge")))
|
---|
481 | {
|
---|
482 | extrsw.SetPedestals(&pedcam);
|
---|
483 | extrsw.SetWindowSize(8,8);
|
---|
484 | taskenv2.SetDefault(&extrsw);
|
---|
485 | *fLog << warn << GetDescriptor()
|
---|
486 | << ": No extractor has been chosen, take default MExtractTimeAndChargeSlidingWindow " << endl;
|
---|
487 | }
|
---|
488 |
|
---|
489 | MCalibrateData photcalc;
|
---|
490 | MCalibrateRelTimes caltimes;
|
---|
491 | if (IsUseMC()) // MC file
|
---|
492 | {
|
---|
493 | photcalc.SetCalibrationMode(MCalibrateData::kFfactor);
|
---|
494 | photcalc.SetPedestalFlag(MCalibrateData::kRun);
|
---|
495 | photcalc.AddPedestal("MPedestalCam", "MPedPhotFundamental");
|
---|
496 | }
|
---|
497 | else
|
---|
498 | {
|
---|
499 | photcalc.SetCalibrationMode(MCalibrateData::kFfactor);
|
---|
500 | photcalc.AddPedestal("Fundamental");
|
---|
501 | photcalc.SetPedestalFlag(MCalibrateData::kEvent);
|
---|
502 | photcalc.SetSignalType(MCalibrateData::kPhe);
|
---|
503 | }
|
---|
504 |
|
---|
505 | MBadPixelsCalc badcalc;
|
---|
506 | MBadPixelsTreat badtreat;
|
---|
507 | badtreat.SetProcessTimes(kFALSE);
|
---|
508 |
|
---|
509 | badcalc.SetNamePedPhotCam("MPedPhotFundamental");
|
---|
510 | badtreat.SetUseInterpolation();
|
---|
511 | badtreat.AddNamePedPhotCam("MPedPhotFundamental");
|
---|
512 |
|
---|
513 | MCalibrationTestCalc testcalc;
|
---|
514 |
|
---|
515 | if (!fSequence.IsValid())
|
---|
516 | {
|
---|
517 | testcalc.SetOutputPath(fPathOut);
|
---|
518 | testcalc.SetOutputFile(Form("%s-TestCalibStat.txt",(const char*)fRuns->GetRunsAsFileName()));
|
---|
519 | }
|
---|
520 |
|
---|
521 | MHCamEvent evt0(0,"Signal", "Un-Calibrated Signal;;S [FADC cnts]" );
|
---|
522 | MHCamEvent evt1(0,"CalSig", "Cal. and Interp. Sig. by Pixel Size Ratio;;S [phe]");
|
---|
523 | MHCamEvent evt2(0,"Times" , "Arrival Time;;T [slice]");
|
---|
524 |
|
---|
525 | MFillH fill0(&evt0, "MExtractedSignalCam", "FillUncalibrated");
|
---|
526 | MFillH fill1(&evt1, "MCerPhotEvt", "FillCalibrated");
|
---|
527 | MFillH fill2(&evt2, "MArrivalTime","FillTimes");
|
---|
528 |
|
---|
529 | MFillH fillcam("MHCalibrationTestCam", "MCerPhotEvt" ,"FillTest");
|
---|
530 | MFillH filltme("MHCalibrationTestTimeCam", "MArrivalTime","FillTestTime");
|
---|
531 | fillcam.SetBit(MFillH::kDoNotDisplay);
|
---|
532 | filltme.SetBit(MFillH::kDoNotDisplay);
|
---|
533 |
|
---|
534 | MFCosmics cosmics;
|
---|
535 | cosmics.SetNamePedestalCam("MPedestalFundamental");
|
---|
536 | MContinue contcos(&cosmics,"ContCosmics");
|
---|
537 |
|
---|
538 | tlist.AddToList(&read);
|
---|
539 | tlist.AddToList(&decode);
|
---|
540 | tlist.AddToList(&apply);
|
---|
541 | tlist.AddToList(&merge);
|
---|
542 | // tlist.AddToList(&conttp);
|
---|
543 | tlist.AddToList(&taskenv1);
|
---|
544 | if (!extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
---|
545 | tlist.AddToList(&taskenv2);
|
---|
546 |
|
---|
547 | tlist.AddToList(&contcos);
|
---|
548 | tlist.AddToList(&fill0);
|
---|
549 | tlist.AddToList(&photcalc);
|
---|
550 | tlist.AddToList(&caltimes);
|
---|
551 | tlist.AddToList(&badcalc);
|
---|
552 | tlist.AddToList(&badtreat);
|
---|
553 | tlist.AddToList(&fill1);
|
---|
554 | tlist.AddToList(&fill2);
|
---|
555 | tlist.AddToList(&fillcam);
|
---|
556 | tlist.AddToList(&filltme);
|
---|
557 | tlist.AddToList(&testcalc);
|
---|
558 |
|
---|
559 | // Create and setup the eventloop
|
---|
560 | MEvtLoop evtloop(fName);
|
---|
561 | evtloop.SetParList(&plist);
|
---|
562 | evtloop.SetDisplay(fDisplay);
|
---|
563 | evtloop.SetLogStream(fLog);
|
---|
564 |
|
---|
565 | // Execute first analysis
|
---|
566 | if (!evtloop.Eventloop())
|
---|
567 | {
|
---|
568 | *fLog << err << GetDescriptor() << ": Failed." << endl;
|
---|
569 | return kFALSE;
|
---|
570 | }
|
---|
571 |
|
---|
572 | tlist.PrintStatistics();
|
---|
573 |
|
---|
574 | /*
|
---|
575 | MHCalibrationTestCam *hcam = (MHCalibrationTestCam*)plist.FindObject("MHCalibrationTestCam");
|
---|
576 | MHCalibrationPix &pix1 = (*hcam)[47];
|
---|
577 | pix1.DrawClone("");
|
---|
578 | gPad->SaveAs("test_test_100.ps");
|
---|
579 |
|
---|
580 | MHCalibrationTestTimeCam *hccam = (MHCalibrationTestTimeCam*)plist.FindObject("MHCalibrationTestTimeCam");
|
---|
581 | MHCalibrationPix &pix11 = (*hccam)[47];
|
---|
582 | pix11.DrawClone("");
|
---|
583 | gPad->SaveAs("test_testtime_100.ps");
|
---|
584 | */
|
---|
585 |
|
---|
586 | DisplayResult(plist);
|
---|
587 |
|
---|
588 | if (!WriteResult())
|
---|
589 | return kFALSE;
|
---|
590 |
|
---|
591 | *fLog << inf << GetDescriptor() << ": Done." << endl;
|
---|
592 |
|
---|
593 | return kTRUE;
|
---|
594 | }
|
---|
595 |
|
---|
596 | Bool_t MJCalibTest::WriteResult()
|
---|
597 | {
|
---|
598 |
|
---|
599 | if (fPathOut.IsNull())
|
---|
600 | return kTRUE;
|
---|
601 |
|
---|
602 | const TString oname(GetOutputFile());
|
---|
603 |
|
---|
604 | *fLog << inf << "Writing to file: " << oname << endl;
|
---|
605 |
|
---|
606 | TFile file(oname, "UPDATE");
|
---|
607 |
|
---|
608 | if (fDisplay && fDisplay->Write()<=0)
|
---|
609 | {
|
---|
610 | *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
|
---|
611 | return kFALSE;
|
---|
612 | }
|
---|
613 |
|
---|
614 | if (fTestCam.Write()<=0)
|
---|
615 | {
|
---|
616 | *fLog << err << "Unable to write MCalibrationTestCam to " << oname << endl;
|
---|
617 | return kFALSE;
|
---|
618 | }
|
---|
619 |
|
---|
620 | if (fTestTimeCam.Write()<=0)
|
---|
621 | {
|
---|
622 | *fLog << err << "Unable to write MCalibrationTestCam to " << oname << endl;
|
---|
623 | return kFALSE;
|
---|
624 | }
|
---|
625 |
|
---|
626 | return kTRUE;
|
---|
627 |
|
---|
628 | }
|
---|
629 |
|
---|