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): Thomas Bretz, 1/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MJCalibrateSignal
|
---|
28 | //
|
---|
29 | // This class is reading the output written by callisto. It calibrates
|
---|
30 | // signal and time.
|
---|
31 | //
|
---|
32 | // The signal and time extractors are read from the callisto-output. In
|
---|
33 | // pricipal you could overwrite these default using the resource file,
|
---|
34 | // but this is NOT recommended!
|
---|
35 | //
|
---|
36 | /////////////////////////////////////////////////////////////////////////////
|
---|
37 | #include "MJCalibrateSignal.h"
|
---|
38 |
|
---|
39 | #include <TEnv.h>
|
---|
40 | #include <TFile.h>
|
---|
41 |
|
---|
42 | #include "MLog.h"
|
---|
43 | #include "MLogManip.h"
|
---|
44 |
|
---|
45 | #include "MDirIter.h"
|
---|
46 | #include "MRunIter.h"
|
---|
47 | #include "MParList.h"
|
---|
48 | #include "MTaskList.h"
|
---|
49 | #include "MEvtLoop.h"
|
---|
50 |
|
---|
51 | #include "MStatusDisplay.h"
|
---|
52 |
|
---|
53 | #include "MGeomCam.h"
|
---|
54 | #include "MHCamEvent.h"
|
---|
55 | #include "MPedestalCam.h"
|
---|
56 | #include "MBadPixelsCam.h"
|
---|
57 |
|
---|
58 | #include "MCalibrationQECam.h"
|
---|
59 | #include "MCalibrationBlindCam.h"
|
---|
60 | #include "MCalibrationChargeCam.h"
|
---|
61 | #include "MCalibrationRelTimeCam.h"
|
---|
62 | #include "MCalibrationChargePINDiode.h"
|
---|
63 | #include "MCalibrationHiLoCam.h"
|
---|
64 | #include "MCalibrationPatternDecode.h"
|
---|
65 |
|
---|
66 | #include "MCalibrationChargeCalc.h"
|
---|
67 | #include "MCalibrationRelTimeCalc.h"
|
---|
68 |
|
---|
69 | #include "MCalibrationIntensityChargeCam.h"
|
---|
70 | #include "MCalibrationIntensityBlindCam.h"
|
---|
71 | #include "MCalibrationIntensityRelTimeCam.h"
|
---|
72 | #include "MCalibrationIntensityQECam.h"
|
---|
73 | #include "MBadPixelsIntensityCam.h"
|
---|
74 |
|
---|
75 | #include "MHCalibrationChargeCam.h"
|
---|
76 | #include "MHCalibrationChargeBlindCam.h"
|
---|
77 | #include "MHCalibrationChargePINDiode.h"
|
---|
78 | #include "MHCalibrationRelTimeCam.h"
|
---|
79 | #include "MHCamera.h"
|
---|
80 |
|
---|
81 | #include "MCalibCalcFromPast.h"
|
---|
82 |
|
---|
83 | #include "MReadReports.h"
|
---|
84 | #include "MReadMarsFile.h"
|
---|
85 | #include "MRawFileRead.h"
|
---|
86 | #include "MContinue.h"
|
---|
87 | #include "MTriggerPatternDecode.h"
|
---|
88 | #include "MFTriggerPattern.h"
|
---|
89 | #include "MGeomApply.h"
|
---|
90 | #include "MMcPedestalCopy.h"
|
---|
91 | #include "MPointingPosCalc.h"
|
---|
92 | #include "MPointingPosInterpolate.h"
|
---|
93 | #include "MPedCalcFromLoGain.h"
|
---|
94 | #include "MExtractor.h"
|
---|
95 | #include "MExtractTimeAndCharge.h"
|
---|
96 | #include "MExtractPINDiode.h"
|
---|
97 | #include "MExtractBlindPixel.h"
|
---|
98 | #include "MFCosmics.h"
|
---|
99 | #include "MTaskEnv.h"
|
---|
100 | #include "MCalibrateData.h"
|
---|
101 | #include "MCalibrateRelTimes.h"
|
---|
102 | #include "MBadPixelsMerge.h"
|
---|
103 | #include "MBadPixelsCalc.h"
|
---|
104 | #include "MBadPixelsTreat.h"
|
---|
105 | #include "MFillH.h"
|
---|
106 | #include "MWriteRootFile.h"
|
---|
107 |
|
---|
108 | ClassImp(MJCalibrateSignal);
|
---|
109 |
|
---|
110 | using namespace std;
|
---|
111 |
|
---|
112 | // --------------------------------------------------------------------------
|
---|
113 | //
|
---|
114 | // Default constructor.
|
---|
115 | //
|
---|
116 | // Sets:
|
---|
117 | // - fIsInterlaced to kTRUE
|
---|
118 | // - fIsRelTimesUpdate to kFALSE
|
---|
119 | // - fIsHiLoCalibration to kFALSE
|
---|
120 | //
|
---|
121 | MJCalibrateSignal::MJCalibrateSignal(const char *name, const char *title)
|
---|
122 | : fIsInterlaced(kTRUE), fIsRelTimesUpdate(kFALSE), fIsHiLoCalibration(kFALSE)
|
---|
123 | {
|
---|
124 | fName = name ? name : "MJCalibrateSignal";
|
---|
125 | fTitle = title ? title : "Tool to calibrate data";
|
---|
126 |
|
---|
127 | }
|
---|
128 |
|
---|
129 | Bool_t MJCalibrateSignal::WriteResult(TObjArray &cont)
|
---|
130 | {
|
---|
131 | const TString name(Form("signal%08d.root", fSequence.GetSequence()));
|
---|
132 | return WriteContainer(cont, name);
|
---|
133 | }
|
---|
134 |
|
---|
135 | Bool_t MJCalibrateSignal::ReadCalibration(TObjArray &l, MBadPixelsCam &cam, MExtractor* &ext1, MExtractor* &ext2, TString &geom) const
|
---|
136 | {
|
---|
137 | const TString fname = Form("%s/calib%08d.root", fPathIn.Data(), fSequence.GetSequence());
|
---|
138 |
|
---|
139 | *fLog << inf << "Reading from file: " << fname << endl;
|
---|
140 |
|
---|
141 | TFile file(fname, "READ");
|
---|
142 | if (!file.IsOpen())
|
---|
143 | {
|
---|
144 | *fLog << err << dbginf << "ERROR - Could not open file " << fname << endl;
|
---|
145 | return kFALSE;
|
---|
146 | }
|
---|
147 |
|
---|
148 | TObject *o = file.Get("ExtractSignal");
|
---|
149 | if (o && !o->InheritsFrom(MExtractor::Class()))
|
---|
150 | {
|
---|
151 | *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
|
---|
152 | return kFALSE;
|
---|
153 | }
|
---|
154 | ext1 = o ? (MExtractor*)o->Clone() : NULL;
|
---|
155 |
|
---|
156 | o = file.Get("ExtractTime");
|
---|
157 | if (o && !o->InheritsFrom(MExtractor::Class()))
|
---|
158 | {
|
---|
159 | *fLog << err << dbginf << "ERROR - ExtractTime read from " << fname << " doesn't inherit from MExtractor!" << endl;
|
---|
160 | return kFALSE;
|
---|
161 | }
|
---|
162 | ext2 = o ? (MExtractor*)o->Clone() : NULL;
|
---|
163 | if (!ext1 && !ext2)
|
---|
164 | {
|
---|
165 | *fLog << err << dbginf << "ERROR - Neither ExtractSignal nor ExrtractTime found in " << fname << "!" << endl;
|
---|
166 | return kFALSE;
|
---|
167 | }
|
---|
168 |
|
---|
169 | o = file.Get("MGeomCam");
|
---|
170 | if (o && !o->InheritsFrom(MGeomCam::Class()))
|
---|
171 | {
|
---|
172 | *fLog << err << dbginf << "ERROR - MGeomCam read from " << fname << " doesn't inherit from MGeomCam!" << endl;
|
---|
173 | return kFALSE;
|
---|
174 | }
|
---|
175 | geom = o ? o->ClassName() : "";
|
---|
176 |
|
---|
177 | TObjArray cont(l);
|
---|
178 | cont.Add(&cam);
|
---|
179 | return ReadContainer(cont);
|
---|
180 | }
|
---|
181 |
|
---|
182 | // --------------------------------------------------------------------------
|
---|
183 | //
|
---|
184 | // MJCalibration allows to setup several option by a resource file:
|
---|
185 | // MJCalibrateSignal.RawData: yes,no
|
---|
186 | //
|
---|
187 | // For more details see the class description and the corresponding Getters
|
---|
188 | //
|
---|
189 | Bool_t MJCalibrateSignal::CheckEnvLocal()
|
---|
190 | {
|
---|
191 |
|
---|
192 | SetInterlaced(GetEnv("Interlaced", fIsInterlaced));
|
---|
193 | SetRelTimesUpdate(GetEnv("RelTimesUpdate", fIsRelTimesUpdate));
|
---|
194 | SetHiLoCalibration(GetEnv("HiLoCalibration", fIsHiLoCalibration));
|
---|
195 |
|
---|
196 | return MJCalib::CheckEnvLocal();
|
---|
197 | }
|
---|
198 |
|
---|
199 | Bool_t MJCalibrateSignal::ProcessFile(MPedestalCam &pedcamab, MPedestalCam &pedcambias,
|
---|
200 | MPedestalCam &pedcamextr)
|
---|
201 | {
|
---|
202 | if (!fSequence.IsValid())
|
---|
203 | {
|
---|
204 | if (!fRuns)
|
---|
205 | {
|
---|
206 | *fLog << err << "ERROR - Sequence invalid and no runs chosen!" << endl;
|
---|
207 | return kFALSE;
|
---|
208 | }
|
---|
209 |
|
---|
210 | if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
|
---|
211 | {
|
---|
212 | *fLog << err << "Number of files found doesn't match number of runs... abort."
|
---|
213 | << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl;
|
---|
214 | return kFALSE;
|
---|
215 | }
|
---|
216 | *fLog << "Calibrate data from ";
|
---|
217 | *fLog << "Runs " << fRuns->GetRunsAsString() << endl;
|
---|
218 | *fLog << endl;
|
---|
219 | }
|
---|
220 |
|
---|
221 | //if (!CheckEnv())
|
---|
222 | // return kFALSE;
|
---|
223 |
|
---|
224 | CheckEnv();
|
---|
225 |
|
---|
226 | // --------------------------------------------------------------------------------
|
---|
227 |
|
---|
228 | *fLog << inf;
|
---|
229 | fLog->Separator(GetDescriptor());
|
---|
230 | *fLog << "Calculate calibrated data from runs ";
|
---|
231 | *fLog << fSequence.GetName() << endl;
|
---|
232 | *fLog << endl;
|
---|
233 |
|
---|
234 | // --------------------------------------------------------------------------------
|
---|
235 |
|
---|
236 | MDirIter iter;
|
---|
237 | if (fSequence.IsValid())
|
---|
238 | {
|
---|
239 | const Int_t n0 = fSequence.SetupDatRuns(iter, fPathData, "D", IsUseRawData());
|
---|
240 | const Int_t n1 = fSequence.GetNumDatRuns();
|
---|
241 | if (n0==0)
|
---|
242 | {
|
---|
243 | *fLog << err << "ERROR - No input files of sequence found!" << endl;
|
---|
244 | return kFALSE;
|
---|
245 | }
|
---|
246 | if (n0!=n1)
|
---|
247 | {
|
---|
248 | *fLog << err << "ERROR - Number of files found (" << n0 << ") doesn't match number of files in sequence (" << n1 << ")" << endl;
|
---|
249 | return kFALSE;
|
---|
250 | }
|
---|
251 | }
|
---|
252 |
|
---|
253 | // Read File
|
---|
254 | MCalibrationIntensityChargeCam ichcam;
|
---|
255 | MCalibrationIntensityQECam iqecam;
|
---|
256 | MCalibrationIntensityBlindCam iblcam;
|
---|
257 | MCalibrationIntensityRelTimeCam itmcam;
|
---|
258 | MBadPixelsIntensityCam ibdcam;
|
---|
259 |
|
---|
260 | MHCalibrationChargeCam hchacam;
|
---|
261 | MHCalibrationChargeBlindCam hbndcam;
|
---|
262 | MHCalibrationChargePINDiode hpndiod;
|
---|
263 | MHCalibrationRelTimeCam hrelcam;
|
---|
264 |
|
---|
265 | MCalibrationChargeCam calcam;
|
---|
266 | MCalibrationQECam qecam;
|
---|
267 | MCalibrationBlindCam bndcam;
|
---|
268 | MCalibrationChargePINDiode pind;
|
---|
269 | MCalibrationRelTimeCam tmcam;
|
---|
270 | MCalibrationHiLoCam hilcam;
|
---|
271 |
|
---|
272 | MBadPixelsCam badpix;
|
---|
273 |
|
---|
274 | TObjArray interlacedcont;
|
---|
275 | if (fIsInterlaced)
|
---|
276 | {
|
---|
277 | interlacedcont.Add(&ichcam);
|
---|
278 | interlacedcont.Add(&iqecam);
|
---|
279 | interlacedcont.Add(&iblcam);
|
---|
280 | interlacedcont.Add(&itmcam);
|
---|
281 | interlacedcont.Add(&ibdcam);
|
---|
282 | interlacedcont.Add(&hchacam);
|
---|
283 | interlacedcont.Add(&hbndcam);
|
---|
284 | interlacedcont.Add(&hpndiod);
|
---|
285 | if (fIsRelTimesUpdate)
|
---|
286 | interlacedcont.Add(&hrelcam);
|
---|
287 | if (fIsHiLoCalibration)
|
---|
288 | interlacedcont.Add(&hilcam);
|
---|
289 | }
|
---|
290 |
|
---|
291 | MExtractor *extractor1=0;
|
---|
292 | MExtractor *extractor2=0;
|
---|
293 | MExtractor *extractor3=0;
|
---|
294 | TString geom;
|
---|
295 |
|
---|
296 | TObjArray calibcont;
|
---|
297 | calibcont.Add(&calcam);
|
---|
298 | calibcont.Add(&qecam);
|
---|
299 | calibcont.Add(&bndcam);
|
---|
300 | calibcont.Add(&pind);
|
---|
301 | calibcont.Add(&tmcam);
|
---|
302 |
|
---|
303 | if (!ReadCalibration(calibcont, badpix, extractor1, extractor2, geom))
|
---|
304 | return kFALSE;
|
---|
305 |
|
---|
306 | *fLog << all;
|
---|
307 | if (extractor1)
|
---|
308 | {
|
---|
309 | *fLog << underline << "Signal Extractor found in calibration file" << endl;
|
---|
310 | extractor1->Print();
|
---|
311 | *fLog << endl;
|
---|
312 | extractor3 = (MExtractor*)extractor1->Clone();
|
---|
313 | }
|
---|
314 | else
|
---|
315 | *fLog << inf << "No Signal Extractor: ExtractSignal in file." << endl;
|
---|
316 |
|
---|
317 | if (extractor2)
|
---|
318 | {
|
---|
319 | *fLog << underline << "Time Extractor found in calibration file" << endl;
|
---|
320 | extractor2->Print();
|
---|
321 | *fLog << endl;
|
---|
322 | }
|
---|
323 | else
|
---|
324 | *fLog << inf << "No Time Extractor: ExtractTime in file." << endl;
|
---|
325 |
|
---|
326 | if (!geom.IsNull())
|
---|
327 | *fLog << inf << "Camera geometry found in file: " << geom << endl;
|
---|
328 | else
|
---|
329 | *fLog << inf << "No Camera geometry found using default <MGeomCamMagic>" << endl;
|
---|
330 |
|
---|
331 | // This is necessary for the case in which it is not in the files
|
---|
332 | MBadPixelsCam badcam;
|
---|
333 |
|
---|
334 | // Setup Parlist
|
---|
335 | MParList plist;
|
---|
336 | plist.AddToList(this); // take care of fDisplay!
|
---|
337 | plist.AddToList(&badcam);
|
---|
338 | plist.AddToList(&hilcam);
|
---|
339 | plist.AddToList(&calibcont); // Using AddToList(TObjArray *)
|
---|
340 | plist.AddToList(&interlacedcont); // Using AddToList(TObjArray *)
|
---|
341 |
|
---|
342 | // Setup Tasklist
|
---|
343 | MTaskList tlist;
|
---|
344 | plist.AddToList(&tlist);
|
---|
345 |
|
---|
346 | MReadReports readreal;
|
---|
347 | readreal.AddTree("Events", "MTime.", kTRUE);
|
---|
348 | readreal.AddTree("Trigger");
|
---|
349 | readreal.AddTree("Camera");
|
---|
350 | readreal.AddTree("Drive");
|
---|
351 | readreal.AddTree("CC");
|
---|
352 | readreal.AddTree("Currents");
|
---|
353 |
|
---|
354 | MReadMarsFile readmc("Events");
|
---|
355 | readmc.DisableAutoScheme();
|
---|
356 |
|
---|
357 | MRawFileRead rawread(NULL);
|
---|
358 |
|
---|
359 | switch (GetDataFlag())
|
---|
360 | {
|
---|
361 | case kIsUseRawData:
|
---|
362 | rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns);
|
---|
363 | break;
|
---|
364 | case kIsUseMC:
|
---|
365 | readmc.AddFiles(fSequence.IsValid() ? iter : *fRuns);
|
---|
366 | break;
|
---|
367 | case kIsUseRootData:
|
---|
368 | readreal.AddFiles(fSequence.IsValid() ? iter : *fRuns);
|
---|
369 | break;
|
---|
370 | }
|
---|
371 |
|
---|
372 | MPointingPosInterpolate pextr;
|
---|
373 | pextr.AddFiles(&iter);
|
---|
374 |
|
---|
375 | MGeomApply apply; // Only necessary to create geometry
|
---|
376 | if (!geom.IsNull())
|
---|
377 | apply.SetGeometry(geom);
|
---|
378 | MBadPixelsMerge merge(&badpix);
|
---|
379 |
|
---|
380 | // Make sure that pedcamab has the correct name
|
---|
381 | pedcamab.SetName("MPedestalFundamental");
|
---|
382 | pedcamextr.SetName("MPedestalFromExtractorRndm");
|
---|
383 | pedcambias.SetName("MPedestalFromExtractor");
|
---|
384 | plist.AddToList(&pedcamextr);
|
---|
385 | plist.AddToList(&pedcambias);
|
---|
386 | plist.AddToList(&pedcamab);
|
---|
387 |
|
---|
388 | // Check for interleaved events
|
---|
389 | MCalibrationPatternDecode caldec;
|
---|
390 | MTriggerPatternDecode decode;
|
---|
391 |
|
---|
392 | MFTriggerPattern ftp;
|
---|
393 | // ftp.RequireCalibration();
|
---|
394 | ftp.DenyCalibration();
|
---|
395 | ftp.DenyPedestal();
|
---|
396 | // ftp.DenyPinDiode();
|
---|
397 | ftp.SetInverted();
|
---|
398 | MContinue conttp(&ftp, "ContTrigPattern");
|
---|
399 | // --> tlist2
|
---|
400 |
|
---|
401 | // Do signal and pedestal calculation
|
---|
402 | MPedCalcFromLoGain pedlo1("MPedCalcFundamental");
|
---|
403 | pedlo1.SetPedestalUpdate(kTRUE);
|
---|
404 | pedlo1.SetNamePedestalCamOut("MPedestalFundamental");
|
---|
405 |
|
---|
406 | MPedCalcFromLoGain pedlo2("MPedCalcWithExtractorRndm");
|
---|
407 | pedlo2.SetPedestalUpdate(kTRUE);
|
---|
408 | pedlo2.SetRandomCalculation(kTRUE);
|
---|
409 | pedlo2.SetNamePedestalCamIn("MPedestalFundamental");
|
---|
410 | pedlo2.SetNamePedestalCamOut("MPedestalFromExtractorRndm");
|
---|
411 |
|
---|
412 | MPedCalcFromLoGain pedlo3("MPedCalcWithExtractor");
|
---|
413 | pedlo3.SetPedestalUpdate(kTRUE);
|
---|
414 | pedlo3.SetRandomCalculation(kFALSE);
|
---|
415 | pedlo3.SetNamePedestalCamIn("MPedestalFundamental");
|
---|
416 | pedlo3.SetNamePedestalCamOut("MPedestalFromExtractor");
|
---|
417 |
|
---|
418 | if (extractor1)
|
---|
419 | {
|
---|
420 | extractor1->SetPedestals(&pedcamab);
|
---|
421 |
|
---|
422 | if (extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
---|
423 | {
|
---|
424 | pedlo2.SetExtractor((MExtractTimeAndCharge*)extractor1);
|
---|
425 | pedlo3.SetExtractor((MExtractTimeAndCharge*)extractor1);
|
---|
426 | const Int_t win = ((MExtractTimeAndCharge*)extractor1)->GetWindowSizeHiGain();
|
---|
427 | pedlo1.SetExtractWindow(15, win);
|
---|
428 | pedlo2.SetExtractWindow(15, win/*obsolete*/);
|
---|
429 | pedlo3.SetExtractWindow(15, win/*obsolete*/);
|
---|
430 | }
|
---|
431 | else
|
---|
432 | {
|
---|
433 | // FIXME: How to get the fixed value 15 automatically?
|
---|
434 | const Int_t f = (Int_t)(15.5+extractor1->GetHiGainFirst());
|
---|
435 | const Int_t n = (Int_t)(15.5+extractor1->GetNumHiGainSamples());
|
---|
436 | pedlo1.SetExtractWindow(f, n);
|
---|
437 | pedlo2.SetExtractWindow(f, n);
|
---|
438 | pedlo3.SetExtractWindow(f, n);
|
---|
439 | }
|
---|
440 | }
|
---|
441 | if (extractor2)
|
---|
442 | extractor2->SetPedestals(&pedcamab);
|
---|
443 |
|
---|
444 | if (extractor3)
|
---|
445 | extractor3->SetPedestals(&pedcamab);
|
---|
446 |
|
---|
447 | MFCosmics fcosmics;
|
---|
448 | fcosmics.SetNamePedestalCam("MPedestalFundamental");
|
---|
449 | MContinue contcos(&fcosmics, "ContTrigEvts");
|
---|
450 | contcos.SetInverted();
|
---|
451 |
|
---|
452 | MMcPedestalCopy pcopy;
|
---|
453 | MTaskEnv taskenv1("ExtractSignal");
|
---|
454 | MTaskEnv taskenv2("ExtractTime");
|
---|
455 | MTaskEnv taskenv3("ExtractInterlaced");
|
---|
456 | taskenv1.SetDefault(extractor1);
|
---|
457 | taskenv2.SetDefault(extractor2);
|
---|
458 | taskenv3.SetDefault(extractor3);
|
---|
459 |
|
---|
460 | MCalibrateData calib;
|
---|
461 | //
|
---|
462 | // This is new calibration to eff. photo-electrons, hard-coded as decided
|
---|
463 | // at the Wuerzburg software meeting 26.01.05
|
---|
464 | //
|
---|
465 | #warning Default calibration now in equiv. photo-electrons!
|
---|
466 | calib.SetSignalType(MCalibrateData::kPhe);
|
---|
467 |
|
---|
468 | if (IsUseMC()) // MC file
|
---|
469 | {
|
---|
470 | calib.SetCalibrationMode(MCalibrateData::kFfactor);
|
---|
471 | calib.SetPedestalFlag(MCalibrateData::kRun);
|
---|
472 | // FIXME: What to do for MC files???
|
---|
473 | calib.AddPedestal("MPedestalCam", "MPedPhotFundamental");
|
---|
474 | calib.AddPedestal("MPedestalCam", "MPedPhotFromExtractor");
|
---|
475 | calib.AddPedestal("MPedestalCam", "MPedPhotFromExtractorRndm");
|
---|
476 | }
|
---|
477 | else
|
---|
478 | {
|
---|
479 | calib.AddPedestal("Fundamental");
|
---|
480 | calib.AddPedestal("FromExtractor");
|
---|
481 | calib.AddPedestal("FromExtractorRndm");
|
---|
482 | calib.SetPedestalFlag(MCalibrateData::kEvent);
|
---|
483 | }
|
---|
484 |
|
---|
485 | MExtractPINDiode pinext;
|
---|
486 | MExtractBlindPixel bldext;
|
---|
487 |
|
---|
488 | MFTriggerPattern fcalib("CalibFilter");
|
---|
489 | fcalib.RequireCalibration();
|
---|
490 |
|
---|
491 | MCalibrationChargeCalc chcalc;
|
---|
492 | MCalibrationRelTimeCalc recalc;
|
---|
493 | MCalibCalcFromPast pacalc;
|
---|
494 | chcalc.SetOutputFile("");
|
---|
495 | recalc.SetOutputFile("");
|
---|
496 |
|
---|
497 | pinext.SetPedestals(&pedcamab);
|
---|
498 | bldext.SetPedestals(&pedcamab);
|
---|
499 | chcalc.SetPedestals(&pedcamextr);
|
---|
500 |
|
---|
501 | pacalc.SetChargeCalc(&chcalc);
|
---|
502 | if (fIsRelTimesUpdate)
|
---|
503 | pacalc.SetRelTimeCalc(&recalc);
|
---|
504 | pacalc.SetCalibrate(&calib);
|
---|
505 |
|
---|
506 | //
|
---|
507 | // Intensity Calibration histogramming
|
---|
508 | //
|
---|
509 | MFillH filpin("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode", "FillPINDiode");
|
---|
510 | MFillH filbnd("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel", "FillBlindCam");
|
---|
511 | MFillH filcam("MHCalibrationChargeCam", "MExtractedSignalCam", "FillChargeCam");
|
---|
512 | MFillH filtme("MHCalibrationRelTimeCam", "MArrivalTimeCam", "FillRelTime");
|
---|
513 | MFillH filhil("MHCalibrationHiLoCam", "MExtractedSignalCam", "FillHiLoRatio");
|
---|
514 |
|
---|
515 | filpin.SetBit(MFillH::kDoNotDisplay);
|
---|
516 | filbnd.SetBit(MFillH::kDoNotDisplay);
|
---|
517 | filcam.SetBit(MFillH::kDoNotDisplay);
|
---|
518 | filtme.SetBit(MFillH::kDoNotDisplay);
|
---|
519 | filhil.SetBit(MFillH::kDoNotDisplay);
|
---|
520 |
|
---|
521 | MCalibrateRelTimes caltm;
|
---|
522 | MBadPixelsCalc bpcal;
|
---|
523 | MBadPixelsTreat treat;
|
---|
524 |
|
---|
525 | bpcal.SetNamePedPhotCam("MPedPhotFromExtractor");
|
---|
526 | treat.AddNamePedPhotCam("MPedPhotFundamental");
|
---|
527 | treat.AddNamePedPhotCam("MPedPhotFromExtractor");
|
---|
528 | treat.AddNamePedPhotCam("MPedPhotFromExtractorRndm");
|
---|
529 | if (!extractor2 && !extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
---|
530 | treat.SetProcessTimes(kFALSE);
|
---|
531 |
|
---|
532 | MHCamEvent evt0(0, "PedFLG", "Fundamental Pedestal from Lo Gain;;P [cnts/sl]");
|
---|
533 | MHCamEvent evt1(2, "PedRmsFLG", "RMS from Extractor applied to ped.;;\\sigma_{p} [cnts/sl]");
|
---|
534 | MHCamEvent evt2(0, "Extra'd", "Extracted Signal;;S [cnts/sl]");
|
---|
535 | // MHCamEvent evt3(4, "PedPhot", "Calibrated Pedestal;;P [phe]");
|
---|
536 | MHCamEvent evt4(5, "PedRMS", "Calibrated RMS from Extractor applied to ped.;;\\sigma_{p} [phe]");
|
---|
537 | MHCamEvent evt5(0, "Interp'd", "Interpolated Signal;;S [phe]");
|
---|
538 | MHCamEvent evt6(2, "Unsuitable", "Fraction of unsuitable events per Pixel;;[1]");
|
---|
539 | MHCamEvent evt7(0, "Times", "Calibrated Arrival Time;;T [fadc sl]");
|
---|
540 | MHCamEvent evt8(2, "Conv", "Calibration Conv. Factors;;[phe/fadc cnts]");
|
---|
541 |
|
---|
542 | evt0.EnableSqrtVariance();
|
---|
543 | evt1.EnableSqrtVariance();
|
---|
544 | evt2.EnableSqrtVariance();
|
---|
545 | // evt3.EnableVariance();
|
---|
546 | evt4.EnableSqrtVariance();
|
---|
547 | evt5.EnableSqrtVariance();
|
---|
548 | evt7.EnableSqrtVariance();
|
---|
549 | evt8.EnableSqrtVariance();
|
---|
550 |
|
---|
551 | MFillH fill0(&evt0, "MPedestalFundamental", "FillPedFLG");
|
---|
552 | MFillH fill1(&evt1, "MPedestalFromExtractor", "FillPedRmsFLG");
|
---|
553 | MFillH fill2(&evt2, "MExtractedSignalCam", "FillExtracted");
|
---|
554 | // MFillH fill3(&evt3, "MPedPhotFundamental", "FillPedPhot");
|
---|
555 | MFillH fill4(&evt4, "MPedPhotFromExtractor", "FillPedRMS");
|
---|
556 | MFillH fill5(&evt5, "MCerPhotEvt", "FillInterpolated");
|
---|
557 | MFillH fill6(&evt6, "MBadPixelsCam", "FillUnsuitable");
|
---|
558 | MFillH fill7(&evt7, "MArrivalTime", "FillTimes");
|
---|
559 | MFillH fill8(&evt8, "MCalibConstCam", "FillConv");
|
---|
560 |
|
---|
561 | MTaskEnv fillflorian("FinalFantasy");
|
---|
562 | fillflorian.SetDefault();
|
---|
563 |
|
---|
564 | // The second rule is for the case reading raw-files!
|
---|
565 | MWriteRootFile write(2, Form("%s{s/_D_/_Y_}{s/.raw$/.root}", fPathOut.Data()), fOverwrite?"RECREATE":"NEW");
|
---|
566 | // Run Header
|
---|
567 | write.AddContainer("MRawRunHeader", "RunHeaders");
|
---|
568 | write.AddContainer("MBadPixelsCam", "RunHeaders");
|
---|
569 | write.AddContainer("MGeomCam", "RunHeaders");
|
---|
570 | // Monte Carlo Headers
|
---|
571 | write.AddContainer("MMcRunHeader", "RunHeaders", kFALSE);
|
---|
572 | write.AddContainer("MMcTrigHeader", "RunHeaders", kFALSE);
|
---|
573 | write.AddContainer("MMcConfigRunHeader", "RunHeaders", kFALSE);
|
---|
574 | write.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
|
---|
575 | // Monte Carlo
|
---|
576 | write.AddContainer("MMcEvt", "Events", kFALSE);
|
---|
577 | write.AddContainer("MMcTrig", "Events", kFALSE);
|
---|
578 | // Data tree
|
---|
579 | write.AddContainer("MCerPhotEvt", "Events");
|
---|
580 | write.AddContainer("MPedPhotFundamental", "Events");
|
---|
581 | write.AddContainer("MPedPhotFromExtractor", "Events");
|
---|
582 | write.AddContainer("MPedPhotFromExtractorRndm", "Events");
|
---|
583 | write.AddContainer("MTime", "Events", kFALSE);
|
---|
584 | write.AddContainer("MRawEvtHeader", "Events");
|
---|
585 | write.AddContainer("MArrivalTime", "Events", kFALSE);
|
---|
586 | write.AddContainer("MPointingPos", "Events", kFALSE);
|
---|
587 | // Slow-Control: Current-tree
|
---|
588 | write.AddContainer("MTimeCurrents", "Currents", kFALSE);
|
---|
589 | write.AddContainer("MCameraDC", "Currents", kFALSE);
|
---|
590 | write.AddContainer("MReportCurrents", "Currents", kFALSE);
|
---|
591 | // Slow-Control: Camera-tree
|
---|
592 | write.AddContainer("MReportCamera", "Camera", kFALSE);
|
---|
593 | write.AddContainer("MTimeCamera", "Camera", kFALSE);
|
---|
594 | write.AddContainer("MCameraAUX", "Camera", kFALSE);
|
---|
595 | write.AddContainer("MCameraCalibration", "Camera", kFALSE);
|
---|
596 | write.AddContainer("MCameraCooling", "Camera", kFALSE);
|
---|
597 | write.AddContainer("MCameraHV", "Camera", kFALSE);
|
---|
598 | write.AddContainer("MCameraLV", "Camera", kFALSE);
|
---|
599 | write.AddContainer("MCameraLids", "Camera", kFALSE);
|
---|
600 | // Slow-Control: Trigger-tree
|
---|
601 | write.AddContainer("MReportTrigger", "Trigger", kFALSE);
|
---|
602 | write.AddContainer("MTimeTrigger", "Trigger", kFALSE);
|
---|
603 | // Slow-Control: Drive-tree
|
---|
604 | write.AddContainer("MReportDrive", "Drive", kFALSE);
|
---|
605 | write.AddContainer("MTimeDrive", "Drive", kFALSE);
|
---|
606 | // Slow-Control: Central Control-tree
|
---|
607 | write.AddContainer("MReportCC", "CC", kFALSE);
|
---|
608 | write.AddContainer("MTimeCC", "CC", kFALSE);
|
---|
609 |
|
---|
610 | // Now setup tasklist for events
|
---|
611 | MTaskList tlist2;
|
---|
612 |
|
---|
613 | tlist2.AddToList(&caldec);
|
---|
614 | tlist2.AddToList(&decode);
|
---|
615 | tlist2.AddToList(&apply);
|
---|
616 | tlist2.AddToList(&merge);
|
---|
617 | if (IsUseMC())
|
---|
618 | tlist2.AddToList(&pcopy);
|
---|
619 | else
|
---|
620 | {
|
---|
621 | tlist2.AddToList(&pedlo1);
|
---|
622 | tlist2.AddToList(&pedlo2);
|
---|
623 | tlist2.AddToList(&pedlo3);
|
---|
624 | }
|
---|
625 | if (fIsInterlaced)
|
---|
626 | {
|
---|
627 | pinext.SetFilter(&fcalib);
|
---|
628 | bldext.SetFilter(&fcalib);
|
---|
629 | taskenv3.SetFilter(&fcalib);
|
---|
630 | pacalc.SetFilter(&fcalib);
|
---|
631 | filcam.SetFilter(&fcalib);
|
---|
632 | filtme.SetFilter(&fcalib);
|
---|
633 | filbnd.SetFilter(&fcalib);
|
---|
634 | filpin.SetFilter(&fcalib);
|
---|
635 | chcalc.SetFilter(&fcalib);
|
---|
636 | recalc.SetFilter(&fcalib);
|
---|
637 |
|
---|
638 | tlist2.AddToList(&fcalib);
|
---|
639 | tlist2.AddToList(&pinext);
|
---|
640 | tlist2.AddToList(&bldext);
|
---|
641 | tlist2.AddToList(&taskenv3);
|
---|
642 | tlist2.AddToList(&pacalc);
|
---|
643 | tlist2.AddToList(&filcam);
|
---|
644 | if (fIsRelTimesUpdate)
|
---|
645 | tlist2.AddToList(&filtme);
|
---|
646 | tlist2.AddToList(&filbnd);
|
---|
647 | tlist2.AddToList(&filpin);
|
---|
648 | tlist2.AddToList(&chcalc);
|
---|
649 | if (fIsRelTimesUpdate)
|
---|
650 | tlist2.AddToList(&recalc);
|
---|
651 | }
|
---|
652 |
|
---|
653 | tlist2.AddToList(&conttp);
|
---|
654 | if (extractor1)
|
---|
655 | tlist2.AddToList(&taskenv1);
|
---|
656 | if (extractor2)
|
---|
657 | tlist2.AddToList(&taskenv2);
|
---|
658 | tlist2.AddToList(&fill0);
|
---|
659 | tlist2.AddToList(&fill1);
|
---|
660 | tlist2.AddToList(&contcos);
|
---|
661 | if (fIsHiLoCalibration)
|
---|
662 | tlist2.AddToList(&filhil);
|
---|
663 | tlist2.AddToList(&fill2);
|
---|
664 | tlist2.AddToList(&calib);
|
---|
665 | if (extractor2 || extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
---|
666 | tlist2.AddToList(&caltm);
|
---|
667 | if (fIsInterlaced)
|
---|
668 | tlist2.AddToList(&fill8);
|
---|
669 | tlist2.AddToList(&bpcal);
|
---|
670 | tlist2.AddToList(&treat);
|
---|
671 | tlist2.AddToList(&fill6);
|
---|
672 | // tlist2.AddToList(&fill3);
|
---|
673 | tlist2.AddToList(&fill4);
|
---|
674 | tlist2.AddToList(&fill5);
|
---|
675 | if (extractor2 || extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
---|
676 | tlist2.AddToList(&fill7);
|
---|
677 |
|
---|
678 | tlist2.AddToList(&fillflorian);
|
---|
679 |
|
---|
680 | // Setup List for Drive-tree
|
---|
681 | MPointingPosCalc pcalc;
|
---|
682 |
|
---|
683 | // Now setup main tasklist
|
---|
684 | switch (GetDataFlag())
|
---|
685 | {
|
---|
686 | case kIsUseRawData:
|
---|
687 | tlist.AddToList(&rawread);
|
---|
688 | break;
|
---|
689 | case kIsUseMC:
|
---|
690 | tlist.AddToList(&readmc);
|
---|
691 | break;
|
---|
692 | case kIsUseRootData:
|
---|
693 | tlist.AddToList(&readreal);
|
---|
694 | break;
|
---|
695 | }
|
---|
696 | //tlist.AddToList(IsUseRawData() ? (MTask*)&rawread : (MTask*)&readreal);
|
---|
697 | if (IsUseRootData())
|
---|
698 | tlist2.AddToList(&pextr);
|
---|
699 | tlist.AddToList(&tlist2, IsUseRootData() ? "Events" : "All");
|
---|
700 |
|
---|
701 | if (IsUseMC())
|
---|
702 | tlist.AddToList(&pcalc, "Drive");
|
---|
703 |
|
---|
704 | tlist.AddToList(&write);
|
---|
705 |
|
---|
706 | // Create and setup the eventloop
|
---|
707 | MEvtLoop evtloop(fName);
|
---|
708 | evtloop.SetParList(&plist);
|
---|
709 | evtloop.SetDisplay(fDisplay);
|
---|
710 | evtloop.SetLogStream(fLog);
|
---|
711 | if (!SetupEnv(evtloop))
|
---|
712 | return kFALSE;
|
---|
713 |
|
---|
714 | // Execute first analysis
|
---|
715 | const Bool_t rc = evtloop.Eventloop(fMaxEvents);
|
---|
716 |
|
---|
717 | // Print statistics
|
---|
718 | tlist.PrintStatistics();
|
---|
719 |
|
---|
720 | // make sure owned object are deleted
|
---|
721 | if (extractor1)
|
---|
722 | delete extractor1;
|
---|
723 | if (extractor2)
|
---|
724 | delete extractor2;
|
---|
725 | if (extractor3)
|
---|
726 | delete extractor3;
|
---|
727 |
|
---|
728 | // return if job failed
|
---|
729 | if (!rc)
|
---|
730 | {
|
---|
731 | *fLog << err << GetDescriptor() << ": Failed." << endl;
|
---|
732 | return kFALSE;
|
---|
733 | }
|
---|
734 |
|
---|
735 | // if everything went ok write and display result
|
---|
736 | DisplayResult(plist);
|
---|
737 |
|
---|
738 | if (!WriteResult(interlacedcont))
|
---|
739 | return kFALSE;
|
---|
740 |
|
---|
741 | // return if job went ok
|
---|
742 | *fLog << all << GetDescriptor() << ": Done." << endl;
|
---|
743 | *fLog << endl << endl;
|
---|
744 |
|
---|
745 | return kTRUE;
|
---|
746 | }
|
---|
747 |
|
---|
748 |
|
---|
749 | void MJCalibrateSignal::DisplayResult(MParList &plist)
|
---|
750 | {
|
---|
751 |
|
---|
752 | if (!fDisplay)
|
---|
753 | return;
|
---|
754 |
|
---|
755 | if (!fIsHiLoCalibration)
|
---|
756 | return;
|
---|
757 |
|
---|
758 | //
|
---|
759 | // Get container from list
|
---|
760 | //
|
---|
761 | MGeomCam &geomcam = *(MGeomCam*)plist.FindObject("MGeomCam");
|
---|
762 | MCalibrationHiLoCam *cam = (MCalibrationHiLoCam*)plist.FindObject("MCalibrationHiLoCam");
|
---|
763 |
|
---|
764 | // Create histograms to display
|
---|
765 | MHCamera disp1 (geomcam, "HiLoConv", "Ratio Amplification HiGain vs. LoGain (Charges)");
|
---|
766 | MHCamera disp2 (geomcam, "HiLoDiff", "Arrival Time Diff. HiGain vs. LoGain (Times)");
|
---|
767 |
|
---|
768 | disp1.SetCamContent(*cam, 0);
|
---|
769 | disp1.SetCamError( *cam, 1);
|
---|
770 | disp2.SetCamContent(*cam, 5);
|
---|
771 | disp2.SetCamError( *cam, 6);
|
---|
772 |
|
---|
773 | disp1.SetYTitle("R [1]");
|
---|
774 | disp2.SetYTitle("\\Delta T [FADC sl.]");
|
---|
775 |
|
---|
776 |
|
---|
777 | TCanvas &c1 = fDisplay->AddTab("HiLoConv");
|
---|
778 | c1.Divide(2,3);
|
---|
779 |
|
---|
780 | disp1.CamDraw(c1, 1, 2, 1);
|
---|
781 | disp2.CamDraw(c1, 2, 2, 1);
|
---|
782 | }
|
---|
783 |
|
---|