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