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