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