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 read("Events");
|
---|
355 | //read.DisableAutoScheme();
|
---|
356 | MRawFileRead rawread(NULL);
|
---|
357 | if (IsUseRawData())
|
---|
358 | rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns);
|
---|
359 | else
|
---|
360 | readreal.AddFiles(fSequence.IsValid() ? iter : *fRuns);
|
---|
361 |
|
---|
362 | MPointingPosInterpolate pextr;
|
---|
363 | pextr.AddFiles(&iter);
|
---|
364 |
|
---|
365 | MGeomApply apply; // Only necessary to create geometry
|
---|
366 | if (!geom.IsNull())
|
---|
367 | apply.SetGeometry(geom);
|
---|
368 | MBadPixelsMerge merge(&badpix);
|
---|
369 |
|
---|
370 | // Make sure that pedcamab has the correct name
|
---|
371 | pedcamab.SetName("MPedestalFundamental");
|
---|
372 | pedcamextr.SetName("MPedestalFromExtractorRndm");
|
---|
373 | pedcambias.SetName("MPedestalFromExtractor");
|
---|
374 | plist.AddToList(&pedcamextr);
|
---|
375 | plist.AddToList(&pedcambias);
|
---|
376 | plist.AddToList(&pedcamab);
|
---|
377 |
|
---|
378 | // Check for interleaved events
|
---|
379 | MCalibrationPatternDecode caldec;
|
---|
380 | MTriggerPatternDecode decode;
|
---|
381 |
|
---|
382 | MFTriggerPattern ftp;
|
---|
383 | // ftp.RequireCalibration();
|
---|
384 | ftp.DenyCalibration();
|
---|
385 | ftp.DenyPedestal();
|
---|
386 | // ftp.DenyPinDiode();
|
---|
387 | ftp.SetInverted();
|
---|
388 | MContinue conttp(&ftp, "ContTrigPattern");
|
---|
389 | // --> tlist2
|
---|
390 |
|
---|
391 | // Do signal and pedestal calculation
|
---|
392 | MPedCalcFromLoGain pedlo1("MPedCalcFundamental");
|
---|
393 | pedlo1.SetPedestalUpdate(kTRUE);
|
---|
394 | pedlo1.SetNamePedestalCamOut("MPedestalFundamental");
|
---|
395 |
|
---|
396 | MPedCalcFromLoGain pedlo2("MPedCalcWithExtractorRndm");
|
---|
397 | pedlo2.SetPedestalUpdate(kTRUE);
|
---|
398 | pedlo2.SetRandomCalculation(kTRUE);
|
---|
399 | pedlo2.SetNamePedestalCamIn("MPedestalFundamental");
|
---|
400 | pedlo2.SetNamePedestalCamOut("MPedestalFromExtractorRndm");
|
---|
401 |
|
---|
402 | MPedCalcFromLoGain pedlo3("MPedCalcWithExtractor");
|
---|
403 | pedlo3.SetPedestalUpdate(kTRUE);
|
---|
404 | pedlo3.SetRandomCalculation(kFALSE);
|
---|
405 | pedlo3.SetNamePedestalCamIn("MPedestalFundamental");
|
---|
406 | pedlo3.SetNamePedestalCamOut("MPedestalFromExtractor");
|
---|
407 |
|
---|
408 | if (extractor1)
|
---|
409 | {
|
---|
410 | extractor1->SetPedestals(&pedcamab);
|
---|
411 |
|
---|
412 | if (extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
---|
413 | {
|
---|
414 | pedlo2.SetExtractor((MExtractTimeAndCharge*)extractor1);
|
---|
415 | pedlo3.SetExtractor((MExtractTimeAndCharge*)extractor1);
|
---|
416 | const Int_t win = ((MExtractTimeAndCharge*)extractor1)->GetWindowSizeHiGain();
|
---|
417 | pedlo1.SetExtractWindow(15, win);
|
---|
418 | pedlo2.SetExtractWindow(15, win/*obsolete*/);
|
---|
419 | pedlo3.SetExtractWindow(15, win/*obsolete*/);
|
---|
420 | }
|
---|
421 | else
|
---|
422 | {
|
---|
423 | // FIXME: How to get the fixed value 15 automatically?
|
---|
424 | const Int_t f = (Int_t)(15.5+extractor1->GetHiGainFirst());
|
---|
425 | const Int_t n = (Int_t)(15.5+extractor1->GetNumHiGainSamples());
|
---|
426 | pedlo1.SetExtractWindow(f, n);
|
---|
427 | pedlo2.SetExtractWindow(f, n);
|
---|
428 | pedlo3.SetExtractWindow(f, n);
|
---|
429 | }
|
---|
430 | }
|
---|
431 | if (extractor2)
|
---|
432 | extractor2->SetPedestals(&pedcamab);
|
---|
433 |
|
---|
434 | if (extractor3)
|
---|
435 | extractor3->SetPedestals(&pedcamab);
|
---|
436 |
|
---|
437 | MFCosmics fcosmics;
|
---|
438 | fcosmics.SetNamePedestalCam("MPedestalFundamental");
|
---|
439 | MContinue contcos(&fcosmics, "ContTrigEvts");
|
---|
440 | contcos.SetInverted();
|
---|
441 |
|
---|
442 | MMcPedestalCopy pcopy;
|
---|
443 | MTaskEnv taskenv1("ExtractSignal");
|
---|
444 | MTaskEnv taskenv2("ExtractTime");
|
---|
445 | MTaskEnv taskenv3("ExtractInterlaced");
|
---|
446 | taskenv1.SetDefault(extractor1);
|
---|
447 | taskenv2.SetDefault(extractor2);
|
---|
448 | taskenv3.SetDefault(extractor3);
|
---|
449 |
|
---|
450 | MCalibrateData calib;
|
---|
451 | //
|
---|
452 | // This is new calibration to eff. photo-electrons, hard-coded as decided
|
---|
453 | // at the Wuerzburg software meeting 26.01.05
|
---|
454 | //
|
---|
455 | #warning Default calibration now in equiv. photo-electrons!
|
---|
456 | calib.SetSignalType(MCalibrateData::kPhe);
|
---|
457 |
|
---|
458 | if (IsUseMC()) // MC file
|
---|
459 | {
|
---|
460 | calib.SetCalibrationMode(MCalibrateData::kFfactor);
|
---|
461 | calib.SetPedestalFlag(MCalibrateData::kRun);
|
---|
462 | // FIXME: What to do for MC files???
|
---|
463 | calib.AddPedestal("MPedestalCam", "MPedPhotFundamental");
|
---|
464 | calib.AddPedestal("MPedestalCam", "MPedPhotFromExtractor");
|
---|
465 | calib.AddPedestal("MPedestalCam", "MPedPhotFromExtractorRndm");
|
---|
466 | }
|
---|
467 | else
|
---|
468 | {
|
---|
469 | calib.AddPedestal("Fundamental");
|
---|
470 | calib.AddPedestal("FromExtractor");
|
---|
471 | calib.AddPedestal("FromExtractorRndm");
|
---|
472 | calib.SetPedestalFlag(MCalibrateData::kEvent);
|
---|
473 | }
|
---|
474 |
|
---|
475 | MExtractPINDiode pinext;
|
---|
476 | MExtractBlindPixel bldext;
|
---|
477 |
|
---|
478 | MFTriggerPattern fcalib("CalibFilter");
|
---|
479 | fcalib.RequireCalibration();
|
---|
480 |
|
---|
481 | MCalibrationChargeCalc chcalc;
|
---|
482 | MCalibrationRelTimeCalc recalc;
|
---|
483 | MCalibCalcFromPast pacalc;
|
---|
484 | chcalc.SetOutputFile("");
|
---|
485 | recalc.SetOutputFile("");
|
---|
486 |
|
---|
487 | pinext.SetPedestals(&pedcamab);
|
---|
488 | bldext.SetPedestals(&pedcamab);
|
---|
489 | chcalc.SetPedestals(&pedcamextr);
|
---|
490 |
|
---|
491 | pacalc.SetChargeCalc(&chcalc);
|
---|
492 | if (fIsRelTimesUpdate)
|
---|
493 | pacalc.SetRelTimeCalc(&recalc);
|
---|
494 | pacalc.SetCalibrate(&calib);
|
---|
495 |
|
---|
496 | //
|
---|
497 | // Intensity Calibration histogramming
|
---|
498 | //
|
---|
499 | MFillH filpin("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode", "FillPINDiode");
|
---|
500 | MFillH filbnd("MHCalibrationChargeBlindCam", "MExtractedSignalBlindPixel", "FillBlindCam");
|
---|
501 | MFillH filcam("MHCalibrationChargeCam", "MExtractedSignalCam", "FillChargeCam");
|
---|
502 | MFillH filtme("MHCalibrationRelTimeCam", "MArrivalTimeCam", "FillRelTime");
|
---|
503 | MFillH filhil("MHCalibrationHiLoCam", "MExtractedSignalCam", "FillHiLoRatio");
|
---|
504 |
|
---|
505 | filpin.SetBit(MFillH::kDoNotDisplay);
|
---|
506 | filbnd.SetBit(MFillH::kDoNotDisplay);
|
---|
507 | filcam.SetBit(MFillH::kDoNotDisplay);
|
---|
508 | filtme.SetBit(MFillH::kDoNotDisplay);
|
---|
509 | filhil.SetBit(MFillH::kDoNotDisplay);
|
---|
510 |
|
---|
511 | MCalibrateRelTimes caltm;
|
---|
512 | MBadPixelsCalc bpcal;
|
---|
513 | MBadPixelsTreat treat;
|
---|
514 |
|
---|
515 | bpcal.SetNamePedPhotCam("MPedPhotFromExtractor");
|
---|
516 | treat.AddNamePedPhotCam("MPedPhotFundamental");
|
---|
517 | treat.AddNamePedPhotCam("MPedPhotFromExtractor");
|
---|
518 | treat.AddNamePedPhotCam("MPedPhotFromExtractorRndm");
|
---|
519 | if (!extractor2 && !extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
---|
520 | treat.SetProcessTimes(kFALSE);
|
---|
521 |
|
---|
522 | MHCamEvent evt0(0, "PedFLG", "Fundamental Pedestal from Lo Gain;;P [cnts/sl]");
|
---|
523 | MHCamEvent evt1(2, "PedRmsFLG", "RMS from Extractor applied to ped.;;\\sigma_{p} [cnts/sl]");
|
---|
524 | MHCamEvent evt2(0, "Extra'd", "Extracted Signal;;S [cnts/sl]");
|
---|
525 | // MHCamEvent evt3(4, "PedPhot", "Calibrated Pedestal;;P [phe]");
|
---|
526 | MHCamEvent evt4(5, "PedRMS", "Calibrated RMS from Extractor applied to ped.;;\\sigma_{p} [phe]");
|
---|
527 | MHCamEvent evt5(0, "Interp'd", "Interpolated Signal;;S [phe]");
|
---|
528 | MHCamEvent evt6(2, "Unsuitable", "Fraction of unsuitable events per Pixel;;[1]");
|
---|
529 | MHCamEvent evt7(0, "Times", "Calibrated Arrival Time;;T [fadc sl]");
|
---|
530 | MHCamEvent evt8(2, "Conv", "Calibration Conv. Factors;;[phe/fadc cnts]");
|
---|
531 |
|
---|
532 | evt0.EnableSqrtVariance();
|
---|
533 | evt1.EnableSqrtVariance();
|
---|
534 | evt2.EnableSqrtVariance();
|
---|
535 | // evt3.EnableVariance();
|
---|
536 | evt4.EnableSqrtVariance();
|
---|
537 | evt5.EnableSqrtVariance();
|
---|
538 | evt7.EnableSqrtVariance();
|
---|
539 | evt8.EnableSqrtVariance();
|
---|
540 |
|
---|
541 | MFillH fill0(&evt0, "MPedestalFundamental", "FillPedFLG");
|
---|
542 | MFillH fill1(&evt1, "MPedestalFromExtractor", "FillPedRmsFLG");
|
---|
543 | MFillH fill2(&evt2, "MExtractedSignalCam", "FillExtracted");
|
---|
544 | // MFillH fill3(&evt3, "MPedPhotFundamental", "FillPedPhot");
|
---|
545 | MFillH fill4(&evt4, "MPedPhotFromExtractor", "FillPedRMS");
|
---|
546 | MFillH fill5(&evt5, "MCerPhotEvt", "FillInterpolated");
|
---|
547 | MFillH fill6(&evt6, "MBadPixelsCam", "FillUnsuitable");
|
---|
548 | MFillH fill7(&evt7, "MArrivalTime", "FillTimes");
|
---|
549 | MFillH fill8(&evt8, "MCalibConstCam", "FillConv");
|
---|
550 |
|
---|
551 | MTaskEnv fillflorian("FinalFantasy");
|
---|
552 | fillflorian.SetDefault();
|
---|
553 |
|
---|
554 | // The second rule is for the case reading raw-files!
|
---|
555 | MWriteRootFile write(2, Form("%s{s/_D_/_Y_}{s/.raw$/.root}", fPathOut.Data()), fOverwrite?"RECREATE":"NEW");
|
---|
556 | // Run Header
|
---|
557 | write.AddContainer("MRawRunHeader", "RunHeaders");
|
---|
558 | write.AddContainer("MBadPixelsCam", "RunHeaders");
|
---|
559 | write.AddContainer("MGeomCam", "RunHeaders");
|
---|
560 | // Monte Carlo Headers
|
---|
561 | write.AddContainer("MMcRunHeader", "RunHeaders", kFALSE);
|
---|
562 | write.AddContainer("MMcTrigHeader", "RunHeaders", kFALSE);
|
---|
563 | write.AddContainer("MMcConfigRunHeader", "RunHeaders", kFALSE);
|
---|
564 | write.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
|
---|
565 | // Monte Carlo
|
---|
566 | write.AddContainer("MMcEvt", "Events", kFALSE);
|
---|
567 | write.AddContainer("MMcTrig", "Events", kFALSE);
|
---|
568 | // Data tree
|
---|
569 | write.AddContainer("MCerPhotEvt", "Events");
|
---|
570 | write.AddContainer("MPedPhotFundamental", "Events");
|
---|
571 | write.AddContainer("MPedPhotFromExtractor", "Events");
|
---|
572 | write.AddContainer("MPedPhotFromExtractorRndm", "Events");
|
---|
573 | write.AddContainer("MTime", "Events", kFALSE);
|
---|
574 | write.AddContainer("MRawEvtHeader", "Events");
|
---|
575 | write.AddContainer("MArrivalTime", "Events", kFALSE);
|
---|
576 | write.AddContainer("MPointingPos", "Events", kFALSE);
|
---|
577 | // Slow-Control: Current-tree
|
---|
578 | write.AddContainer("MTimeCurrents", "Currents", kFALSE);
|
---|
579 | write.AddContainer("MCameraDC", "Currents", kFALSE);
|
---|
580 | write.AddContainer("MReportCurrents", "Currents", kFALSE);
|
---|
581 | // Slow-Control: Camera-tree
|
---|
582 | write.AddContainer("MReportCamera", "Camera", kFALSE);
|
---|
583 | write.AddContainer("MTimeCamera", "Camera", kFALSE);
|
---|
584 | write.AddContainer("MCameraAUX", "Camera", kFALSE);
|
---|
585 | write.AddContainer("MCameraCalibration", "Camera", kFALSE);
|
---|
586 | write.AddContainer("MCameraCooling", "Camera", kFALSE);
|
---|
587 | write.AddContainer("MCameraHV", "Camera", kFALSE);
|
---|
588 | write.AddContainer("MCameraLV", "Camera", kFALSE);
|
---|
589 | write.AddContainer("MCameraLids", "Camera", kFALSE);
|
---|
590 | // Slow-Control: Trigger-tree
|
---|
591 | write.AddContainer("MReportTrigger", "Trigger", kFALSE);
|
---|
592 | write.AddContainer("MTimeTrigger", "Trigger", kFALSE);
|
---|
593 | // Slow-Control: Drive-tree
|
---|
594 | write.AddContainer("MReportDrive", "Drive", kFALSE);
|
---|
595 | write.AddContainer("MTimeDrive", "Drive", kFALSE);
|
---|
596 | // Slow-Control: Central Control-tree
|
---|
597 | write.AddContainer("MReportCC", "CC", kFALSE);
|
---|
598 | write.AddContainer("MTimeCC", "CC", kFALSE);
|
---|
599 |
|
---|
600 | // Now setup tasklist for events
|
---|
601 | MTaskList tlist2;
|
---|
602 |
|
---|
603 | tlist2.AddToList(&caldec);
|
---|
604 | tlist2.AddToList(&decode);
|
---|
605 | tlist2.AddToList(&apply);
|
---|
606 | tlist2.AddToList(&merge);
|
---|
607 | if (IsUseMC())
|
---|
608 | tlist2.AddToList(&pcopy);
|
---|
609 | else
|
---|
610 | {
|
---|
611 | tlist2.AddToList(&pedlo1);
|
---|
612 | tlist2.AddToList(&pedlo2);
|
---|
613 | tlist2.AddToList(&pedlo3);
|
---|
614 | }
|
---|
615 | if (fIsInterlaced)
|
---|
616 | {
|
---|
617 | pinext.SetFilter(&fcalib);
|
---|
618 | bldext.SetFilter(&fcalib);
|
---|
619 | taskenv3.SetFilter(&fcalib);
|
---|
620 | pacalc.SetFilter(&fcalib);
|
---|
621 | filcam.SetFilter(&fcalib);
|
---|
622 | filtme.SetFilter(&fcalib);
|
---|
623 | filbnd.SetFilter(&fcalib);
|
---|
624 | filpin.SetFilter(&fcalib);
|
---|
625 | chcalc.SetFilter(&fcalib);
|
---|
626 | recalc.SetFilter(&fcalib);
|
---|
627 |
|
---|
628 | tlist2.AddToList(&fcalib);
|
---|
629 | tlist2.AddToList(&pinext);
|
---|
630 | tlist2.AddToList(&bldext);
|
---|
631 | tlist2.AddToList(&taskenv3);
|
---|
632 | tlist2.AddToList(&pacalc);
|
---|
633 | tlist2.AddToList(&filcam);
|
---|
634 | if (fIsRelTimesUpdate)
|
---|
635 | tlist2.AddToList(&filtme);
|
---|
636 | tlist2.AddToList(&filbnd);
|
---|
637 | tlist2.AddToList(&filpin);
|
---|
638 | tlist2.AddToList(&chcalc);
|
---|
639 | if (fIsRelTimesUpdate)
|
---|
640 | tlist2.AddToList(&recalc);
|
---|
641 | }
|
---|
642 |
|
---|
643 | tlist2.AddToList(&conttp);
|
---|
644 | if (extractor1)
|
---|
645 | tlist2.AddToList(&taskenv1);
|
---|
646 | if (extractor2)
|
---|
647 | tlist2.AddToList(&taskenv2);
|
---|
648 | tlist2.AddToList(&fill0);
|
---|
649 | tlist2.AddToList(&fill1);
|
---|
650 | tlist2.AddToList(&contcos);
|
---|
651 | if (fIsHiLoCalibration)
|
---|
652 | tlist2.AddToList(&filhil);
|
---|
653 | tlist2.AddToList(&fill2);
|
---|
654 | tlist2.AddToList(&calib);
|
---|
655 | if (extractor2 || extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
---|
656 | tlist2.AddToList(&caltm);
|
---|
657 | if (fIsInterlaced)
|
---|
658 | tlist2.AddToList(&fill8);
|
---|
659 | tlist2.AddToList(&bpcal);
|
---|
660 | tlist2.AddToList(&treat);
|
---|
661 | tlist2.AddToList(&fill6);
|
---|
662 | // tlist2.AddToList(&fill3);
|
---|
663 | tlist2.AddToList(&fill4);
|
---|
664 | tlist2.AddToList(&fill5);
|
---|
665 | if (extractor2 || extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
---|
666 | tlist2.AddToList(&fill7);
|
---|
667 |
|
---|
668 | tlist2.AddToList(&fillflorian);
|
---|
669 |
|
---|
670 | // Setup List for Drive-tree
|
---|
671 | MPointingPosCalc pcalc;
|
---|
672 |
|
---|
673 | // Now setup main tasklist
|
---|
674 | tlist.AddToList(IsUseRawData() ? (MTask*)&rawread : (MTask*)&readreal);
|
---|
675 | if (IsUseRootData())
|
---|
676 | tlist2.AddToList(&pextr);
|
---|
677 | tlist.AddToList(&tlist2, IsUseRootData() ? "Events" : "All");
|
---|
678 |
|
---|
679 | if (IsUseMC())
|
---|
680 | tlist.AddToList(&pcalc, "Drive");
|
---|
681 |
|
---|
682 | tlist.AddToList(&write);
|
---|
683 |
|
---|
684 | // Create and setup the eventloop
|
---|
685 | MEvtLoop evtloop(fName);
|
---|
686 | evtloop.SetParList(&plist);
|
---|
687 | evtloop.SetDisplay(fDisplay);
|
---|
688 | evtloop.SetLogStream(fLog);
|
---|
689 | if (!SetupEnv(evtloop))
|
---|
690 | return kFALSE;
|
---|
691 |
|
---|
692 | // Execute first analysis
|
---|
693 | const Bool_t rc = evtloop.Eventloop(fMaxEvents);
|
---|
694 |
|
---|
695 | // Print statistics
|
---|
696 | tlist.PrintStatistics();
|
---|
697 |
|
---|
698 | // make sure owned object are deleted
|
---|
699 | if (extractor1)
|
---|
700 | delete extractor1;
|
---|
701 | if (extractor2)
|
---|
702 | delete extractor2;
|
---|
703 | if (extractor3)
|
---|
704 | delete extractor3;
|
---|
705 |
|
---|
706 | // return if job failed
|
---|
707 | if (!rc)
|
---|
708 | {
|
---|
709 | *fLog << err << GetDescriptor() << ": Failed." << endl;
|
---|
710 | return kFALSE;
|
---|
711 | }
|
---|
712 |
|
---|
713 | // if everything went ok write and display result
|
---|
714 | DisplayResult(plist);
|
---|
715 |
|
---|
716 | if (!WriteResult(interlacedcont))
|
---|
717 | return kFALSE;
|
---|
718 |
|
---|
719 | // return if job went ok
|
---|
720 | *fLog << all << GetDescriptor() << ": Done." << endl;
|
---|
721 | *fLog << endl << endl;
|
---|
722 |
|
---|
723 | return kTRUE;
|
---|
724 | }
|
---|
725 |
|
---|
726 |
|
---|
727 | void MJCalibrateSignal::DisplayResult(MParList &plist)
|
---|
728 | {
|
---|
729 |
|
---|
730 | if (!fDisplay)
|
---|
731 | return;
|
---|
732 |
|
---|
733 | if (!fIsHiLoCalibration)
|
---|
734 | return;
|
---|
735 |
|
---|
736 | //
|
---|
737 | // Get container from list
|
---|
738 | //
|
---|
739 | MGeomCam &geomcam = *(MGeomCam*)plist.FindObject("MGeomCam");
|
---|
740 | MCalibrationHiLoCam *cam = (MCalibrationHiLoCam*)plist.FindObject("MCalibrationHiLoCam");
|
---|
741 |
|
---|
742 | // Create histograms to display
|
---|
743 | MHCamera disp1 (geomcam, "HiLoConv", "Ratio Amplification HiGain vs. LoGain (Charges)");
|
---|
744 | MHCamera disp2 (geomcam, "HiLoDiff", "Arrival Time Diff. HiGain vs. LoGain (Times)");
|
---|
745 |
|
---|
746 | disp1.SetCamContent(*cam, 0);
|
---|
747 | disp1.SetCamError( *cam, 1);
|
---|
748 | disp2.SetCamContent(*cam, 5);
|
---|
749 | disp2.SetCamError( *cam, 6);
|
---|
750 |
|
---|
751 | disp1.SetYTitle("R [1]");
|
---|
752 | disp2.SetYTitle("\\Delta T [FADC sl.]");
|
---|
753 |
|
---|
754 |
|
---|
755 | TCanvas &c1 = fDisplay->AddTab("HiLoConv");
|
---|
756 | c1.Divide(2,3);
|
---|
757 |
|
---|
758 | disp1.CamDraw(c1, 1, 2, 1);
|
---|
759 | disp2.CamDraw(c1, 2, 2, 1);
|
---|
760 | }
|
---|
761 |
|
---|