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 "MBadPixelsIntensityCam.h"
|
---|
77 |
|
---|
78 | #include "MHCalibrationChargeCam.h"
|
---|
79 | #include "MHCalibrationChargeBlindCam.h"
|
---|
80 | #include "MHCalibrationChargePINDiode.h"
|
---|
81 | #include "MHCalibrationRelTimeCam.h"
|
---|
82 | #include "MHCalibrationPulseTimeCam.h"
|
---|
83 | #include "MHCalibrationHiLoCam.h"
|
---|
84 | #include "MHCamera.h"
|
---|
85 |
|
---|
86 | #include "MCalibCalcFromPast.h"
|
---|
87 |
|
---|
88 | #include "MReadReports.h"
|
---|
89 | #include "MReadMarsFile.h"
|
---|
90 | #include "MRawFileRead.h"
|
---|
91 | #include "MContinue.h"
|
---|
92 | #include "MTriggerPatternDecode.h"
|
---|
93 | #include "MFTriggerPattern.h"
|
---|
94 | #include "MGeomApply.h"
|
---|
95 | //#include "MMcPedestalCopy.h"
|
---|
96 | #include "MPointingPosCalc.h"
|
---|
97 | #include "MPointingPosInterpolate.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 | MBadPixelsIntensityCam ibdcam;
|
---|
272 |
|
---|
273 | MHCalibrationChargeCam hchacam;
|
---|
274 | MHCalibrationChargeBlindCam hbndcam;
|
---|
275 | MHCalibrationChargePINDiode hpndiod;
|
---|
276 | MHCalibrationRelTimeCam hrelcam;
|
---|
277 | MHCalibrationHiLoCam hilocam;
|
---|
278 | MHCalibrationPulseTimeCam hpulcam;
|
---|
279 |
|
---|
280 | hchacam.SetOscillations(kFALSE);
|
---|
281 | hbndcam.SetOscillations(kFALSE);
|
---|
282 | hrelcam.SetOscillations(kFALSE);
|
---|
283 |
|
---|
284 | MCalibrationChargeCam calcam;
|
---|
285 | MCalibrationQECam qecam;
|
---|
286 | MCalibrationBlindCam bndcam;
|
---|
287 | MCalibrationChargePINDiode pind;
|
---|
288 | MCalibrationRelTimeCam tmcam;
|
---|
289 | MCalibrationHiLoCam hilcam;
|
---|
290 | MCalibrationPulseTimeCam pulcam;
|
---|
291 |
|
---|
292 | MBadPixelsCam badpix;
|
---|
293 |
|
---|
294 | TObjArray interlacedcont;
|
---|
295 | if (fIsInterlaced)
|
---|
296 | {
|
---|
297 | interlacedcont.Add(&ichcam);
|
---|
298 | interlacedcont.Add(&iqecam);
|
---|
299 | interlacedcont.Add(&iblcam);
|
---|
300 | interlacedcont.Add(&itmcam);
|
---|
301 | interlacedcont.Add(&ibdcam);
|
---|
302 | interlacedcont.Add(&hchacam);
|
---|
303 | if (IsUseBlindPixel())
|
---|
304 | interlacedcont.Add(&hbndcam);
|
---|
305 | if (IsUsePINDiode())
|
---|
306 | interlacedcont.Add(&hpndiod);
|
---|
307 | if (fIsRelTimesUpdate)
|
---|
308 | interlacedcont.Add(&hrelcam);
|
---|
309 | }
|
---|
310 |
|
---|
311 | MExtractor *extractor1=fExtractor;
|
---|
312 | MExtractor *extractor2=0;
|
---|
313 | MExtractor *extractor3=0;
|
---|
314 | TString geom;
|
---|
315 |
|
---|
316 | TObjArray calibcont;
|
---|
317 | calibcont.Add(&calcam);
|
---|
318 | calibcont.Add(&qecam);
|
---|
319 | calibcont.Add(&bndcam);
|
---|
320 | calibcont.Add(&pind);
|
---|
321 | calibcont.Add(&tmcam);
|
---|
322 |
|
---|
323 | if (!ReadCalibration(calibcont, badpix, extractor2, extractor3, geom))
|
---|
324 | return kFALSE;
|
---|
325 |
|
---|
326 | *fLog << all;
|
---|
327 | if (!geom.IsNull())
|
---|
328 | *fLog << inf << "Camera geometry found in file: " << geom << endl;
|
---|
329 | else
|
---|
330 | *fLog << inf << "No Camera geometry found using default <MGeomCamMagic>" << endl;
|
---|
331 |
|
---|
332 | if (extractor3)
|
---|
333 | {
|
---|
334 | *fLog << underline << "Signal Extractor found in calibration file" << endl;
|
---|
335 | extractor3->Print();
|
---|
336 | *fLog << endl;
|
---|
337 | }
|
---|
338 | else
|
---|
339 | *fLog << inf << "No Signal Extractor: ExtractSignal in file." << endl;
|
---|
340 |
|
---|
341 |
|
---|
342 | if (extractor1)
|
---|
343 | {
|
---|
344 | *fLog << underline << "Modified Signal Extractor set by user." << endl;
|
---|
345 | extractor1->Print();
|
---|
346 | *fLog << endl;
|
---|
347 | }
|
---|
348 | else
|
---|
349 | {
|
---|
350 | *fLog << inf << "No modified Signal Extractor set by user... using ExtractSignal." << endl;
|
---|
351 | extractor1 = extractor3 ? (MExtractor*)extractor3->Clone() : 0;
|
---|
352 | }
|
---|
353 |
|
---|
354 | if (extractor2)
|
---|
355 | {
|
---|
356 | *fLog << underline << "Time Extractor found in calibration file" << endl;
|
---|
357 | extractor2->Print();
|
---|
358 | *fLog << endl;
|
---|
359 | }
|
---|
360 | else
|
---|
361 | *fLog << inf << "No Time Extractor: ExtractTime in file." << endl;
|
---|
362 |
|
---|
363 | // This is necessary for the case in which it is not in the files
|
---|
364 | MBadPixelsCam badcam;
|
---|
365 |
|
---|
366 | // Setup Parlist
|
---|
367 | MParList plist;
|
---|
368 | plist.AddToList(this); // take care of fDisplay!
|
---|
369 | plist.AddToList(&badcam);
|
---|
370 | plist.AddToList(&hilcam);
|
---|
371 | plist.AddToList(&calibcont); // Using AddToList(TObjArray *)
|
---|
372 | plist.AddToList(&interlacedcont); // Using AddToList(TObjArray *)
|
---|
373 | plist.AddToList(&pulcam);
|
---|
374 |
|
---|
375 | // Setup Tasklist
|
---|
376 | MTaskList tlist;
|
---|
377 | plist.AddToList(&tlist);
|
---|
378 |
|
---|
379 | MReadReports readreal;
|
---|
380 | readreal.AddTree("Events", "MTime.", kTRUE);
|
---|
381 | readreal.AddTree("Trigger");
|
---|
382 | readreal.AddTree("Camera");
|
---|
383 | readreal.AddTree("Drive");
|
---|
384 | readreal.AddTree("CC");
|
---|
385 | readreal.AddTree("Currents");
|
---|
386 |
|
---|
387 | MReadMarsFile readmc("Events");
|
---|
388 | readmc.DisableAutoScheme();
|
---|
389 |
|
---|
390 | MRawFileRead rawread(NULL);
|
---|
391 |
|
---|
392 | MRead *read = 0;
|
---|
393 | switch (GetDataFlag())
|
---|
394 | {
|
---|
395 | case kIsUseRawData: read = &rawread; break;
|
---|
396 | case kIsUseMC: read = &readmc; break;
|
---|
397 | case kIsUseRootData: read = &readreal; break;
|
---|
398 | }
|
---|
399 | read->AddFiles(iter);
|
---|
400 |
|
---|
401 | const TString fname(Form("%s{s/_D_/_Y_}{s/.raw$/.root}", fPathOut.Data()));
|
---|
402 |
|
---|
403 |
|
---|
404 | // Skips MC which have no contents. This are precisely the
|
---|
405 | // events which fullfilled the MC Lvl1 trigger and an
|
---|
406 | // arbitrary cut (typically at 50phe) to speed up simulation
|
---|
407 | MContinue contmc("MRawEvtData.GetNumPixels<0.5", "ContEmptyMC");
|
---|
408 |
|
---|
409 | MPointingPosInterpolate pextr;
|
---|
410 | pextr.AddFiles(&iter);
|
---|
411 |
|
---|
412 | MGeomApply apply; // Only necessary to create geometry
|
---|
413 | if (!geom.IsNull())
|
---|
414 | apply.SetGeometry(geom);
|
---|
415 | MBadPixelsMerge merge(&badpix);
|
---|
416 |
|
---|
417 | // Make sure that pedcamab has the correct name
|
---|
418 | pedcamab.SetName("MPedestalFundamental");
|
---|
419 | pedcamextr.SetName("MPedestalFromExtractorRndm");
|
---|
420 | pedcambias.SetName("MPedestalFromExtractor");
|
---|
421 | plist.AddToList(&pedcamextr);
|
---|
422 | plist.AddToList(&pedcambias);
|
---|
423 | plist.AddToList(&pedcamab);
|
---|
424 |
|
---|
425 | MArrivalTimeCam timecam;
|
---|
426 | plist.AddToList(&timecam);
|
---|
427 |
|
---|
428 | // Check for interleaved events
|
---|
429 | MCalibrationPatternDecode caldec;
|
---|
430 | MTriggerPatternDecode decode;
|
---|
431 |
|
---|
432 | // This will make that for data with version less than 5, where
|
---|
433 | // trigger patterns were not yet correct, all the events in the real
|
---|
434 | // data file will be processed. In any case there are no interleaved
|
---|
435 | // calibration events in such data, so this is fine.
|
---|
436 | MFTriggerPattern ftp;
|
---|
437 | ftp.SetDefault(kTRUE);
|
---|
438 | // ftp.RequireCalibration();
|
---|
439 | ftp.DenyCalibration();
|
---|
440 | ftp.DenyPedestal();
|
---|
441 | // ftp.DenyPinDiode();
|
---|
442 | ftp.SetInverted();
|
---|
443 |
|
---|
444 | // This will skip interleaved calibration events and pedestal events (if any)
|
---|
445 | // --> tlist2
|
---|
446 | MContinue conttp(&ftp, "ContTrigPattern");
|
---|
447 |
|
---|
448 | // Do signal and pedestal calculation
|
---|
449 | MPedCalcFromLoGain pedlo1("MPedCalcFundamental");
|
---|
450 | pedlo1.SetPedestalUpdate(kTRUE);
|
---|
451 | pedlo1.SetNamePedestalCamOut("MPedestalFundamental");
|
---|
452 |
|
---|
453 | MPedCalcFromLoGain pedlo2("MPedCalcWithExtractorRndm");
|
---|
454 | pedlo2.SetPedestalUpdate(kTRUE);
|
---|
455 | pedlo2.SetRandomCalculation(kTRUE);
|
---|
456 | pedlo2.SetNamePedestalCamIn("MPedestalFundamental");
|
---|
457 | pedlo2.SetNamePedestalCamOut("MPedestalFromExtractorRndm");
|
---|
458 |
|
---|
459 | MPedCalcFromLoGain pedlo3("MPedCalcWithExtractor");
|
---|
460 | pedlo3.SetPedestalUpdate(kTRUE);
|
---|
461 | pedlo3.SetRandomCalculation(kFALSE);
|
---|
462 | pedlo3.SetNamePedestalCamIn("MPedestalFundamental");
|
---|
463 | pedlo3.SetNamePedestalCamOut("MPedestalFromExtractor");
|
---|
464 |
|
---|
465 | if (extractor1)
|
---|
466 | {
|
---|
467 | extractor1->SetPedestals(&pedcamab);
|
---|
468 |
|
---|
469 | if (extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
---|
470 | {
|
---|
471 | pedlo2.SetExtractor((MExtractTimeAndCharge*)extractor1);
|
---|
472 | pedlo3.SetExtractor((MExtractTimeAndCharge*)extractor1);
|
---|
473 | const Int_t win = ((MExtractTimeAndCharge*)extractor1)->GetWindowSizeHiGain();
|
---|
474 | pedlo1.SetExtractWindow(15, win);
|
---|
475 | pedlo2.SetExtractWindow(15, win/*obsolete*/);
|
---|
476 | pedlo3.SetExtractWindow(15, win/*obsolete*/);
|
---|
477 | }
|
---|
478 | else
|
---|
479 | {
|
---|
480 | // FIXME: How to get the fixed value 15 automatically?
|
---|
481 | const Int_t f = (Int_t)(15.5+extractor1->GetHiGainFirst());
|
---|
482 | const Int_t n = (Int_t)(15.5+extractor1->GetNumHiGainSamples());
|
---|
483 | pedlo1.SetExtractWindow(f, n);
|
---|
484 | pedlo2.SetExtractWindow(f, n);
|
---|
485 | pedlo3.SetExtractWindow(f, n);
|
---|
486 | }
|
---|
487 | }
|
---|
488 | if (extractor2)
|
---|
489 | extractor2->SetPedestals(&pedcamab);
|
---|
490 |
|
---|
491 | if (extractor3)
|
---|
492 | extractor3->SetPedestals(&pedcamab);
|
---|
493 |
|
---|
494 | MFCosmics fcosmics;
|
---|
495 | fcosmics.SetNamePedestalCam("MPedestalFundamental");
|
---|
496 | MContinue contcos(&fcosmics, "ContTrigEvts");
|
---|
497 | contcos.SetInverted();
|
---|
498 |
|
---|
499 | //MMcPedestalCopy pcopy;
|
---|
500 | MTaskEnv taskenv1("ExtractSignal");
|
---|
501 | MTaskEnv taskenv2("ExtractTime");
|
---|
502 | MTaskEnv taskenv3("ExtractInterlaced");
|
---|
503 | taskenv1.SetDefault(extractor1);
|
---|
504 | taskenv2.SetDefault(extractor2);
|
---|
505 | taskenv3.SetDefault(extractor3);
|
---|
506 |
|
---|
507 | //
|
---|
508 | // This is new calibration to photo-electrons, hard-coded
|
---|
509 | // as decided at the Wuerzburg software meeting 26.01.05
|
---|
510 | //
|
---|
511 | MCalibrateData calib;
|
---|
512 | calib.SetSignalType(MCalibrateData::kPhe);
|
---|
513 | calib.AddPedestal("Fundamental");
|
---|
514 | calib.AddPedestal("FromExtractor");
|
---|
515 | calib.AddPedestal("FromExtractorRndm");
|
---|
516 | calib.SetPedestalFlag(MCalibrateData::kEvent);
|
---|
517 | //----------------------------------------------------------
|
---|
518 |
|
---|
519 | MExtractPINDiode pinext;
|
---|
520 | MExtractBlindPixel bldext;
|
---|
521 |
|
---|
522 | MFTriggerPattern fcalib("CalibFilter");
|
---|
523 | fcalib.SetDefault(kFALSE);
|
---|
524 | fcalib.RequireCalibration();
|
---|
525 |
|
---|
526 | MCalibrationChargeCalc chcalc;
|
---|
527 | MCalibrationRelTimeCalc recalc;
|
---|
528 | MCalibCalcFromPast pacalc;
|
---|
529 | chcalc.SetOutputFile("");
|
---|
530 | recalc.SetOutputFile("");
|
---|
531 |
|
---|
532 | pinext.SetPedestals(&pedcamab);
|
---|
533 | bldext.SetPedestals(&pedcamab);
|
---|
534 | chcalc.SetPedestals(&pedcamextr);
|
---|
535 |
|
---|
536 | pacalc.SetChargeCalc(&chcalc);
|
---|
537 | if (fIsRelTimesUpdate)
|
---|
538 | pacalc.SetRelTimeCalc(&recalc);
|
---|
539 | pacalc.SetCalibrate(&calib);
|
---|
540 |
|
---|
541 | //
|
---|
542 | // Intensity Calibration histogramming
|
---|
543 | //
|
---|
544 | MFillH filpin(&hpndiod, "MExtractedSignalPINDiode", "FillPINDiode");
|
---|
545 | MFillH filbnd(&hbndcam, "MExtractedSignalBlindPixel", "FillBlindCam");
|
---|
546 | MFillH filcam(&hchacam, "MExtractedSignalCam", "FillChargeCam");
|
---|
547 | MFillH filtme(&hrelcam, "MArrivalTimeCam", "FillRelTime");
|
---|
548 | MFillH filhil(&hilocam, "MExtractedSignalCam", "FillHiLoRatio");
|
---|
549 | MFillH filpul(&hpulcam, "MRawEvtData", "FillPulseTime");
|
---|
550 | filpin.SetBit(MFillH::kDoNotDisplay);
|
---|
551 | filbnd.SetBit(MFillH::kDoNotDisplay);
|
---|
552 | filcam.SetBit(MFillH::kDoNotDisplay);
|
---|
553 | filtme.SetBit(MFillH::kDoNotDisplay);
|
---|
554 | filhil.SetBit(MFillH::kDoNotDisplay);
|
---|
555 | filpul.SetBit(MFillH::kDoNotDisplay);
|
---|
556 |
|
---|
557 | MCalibrateRelTimes caltm;
|
---|
558 | MBadPixelsCalc bpcal;
|
---|
559 | MBadPixelsTreat treat;
|
---|
560 |
|
---|
561 | bpcal.SetNamePedPhotCam("MPedPhotFromExtractor");
|
---|
562 | treat.AddNamePedPhotCam("MPedPhotFundamental");
|
---|
563 | treat.AddNamePedPhotCam("MPedPhotFromExtractor");
|
---|
564 | treat.AddNamePedPhotCam("MPedPhotFromExtractorRndm");
|
---|
565 | if (!extractor2 && !extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
---|
566 | treat.SetProcessTimes(kFALSE);
|
---|
567 |
|
---|
568 | MHCamEvent evt0( 0, "PedFLG", "Fundamental Pedestal from Lo Gain;;P [cnts/sl]");
|
---|
569 | MHCamEvent evt1( 2, "PedRmsFLG", "RMS from Extractor applied to ped.;;\\sigma_{p} [cnts/sl]");
|
---|
570 | MHCamEvent evt2( 0, "Extra'd", "Extracted Signal;;S [cnts/sl]");
|
---|
571 | // MHCamEvent evt3(4, "PedPhot", "Calibrated Pedestal;;P [phe]");
|
---|
572 | MHCamEvent evt4( 5, "PedRMS", "Calibrated RMS from Extractor applied to ped.;;\\sigma_{p} [phe]");
|
---|
573 | MHCamEvent evt5( 0, "Interp'd", "Interpolated Signal;;S [phe]");
|
---|
574 | MHCamEvent evt6(102, "Unsuitable", "Fraction of unsuitable events per Pixel;;[1]");
|
---|
575 | MHCamEvent evt7( 6, "Times", "Calibrated Arrival Time;;T [fadc sl]");
|
---|
576 | MHCamEvent evt8( 0, "Conv", "Calibration Conv. Factors;;[phe/fadc cnts]");
|
---|
577 | MHCamEvent evt9( 7, "PulsePos", "Pulse Position of cosmics (>15phe);;T"); //Calibration Conv. Factors;;[phe/fadc cnts]
|
---|
578 | evt6.SetThreshold();
|
---|
579 |
|
---|
580 | MFillH fill0(&evt0, "MPedestalFundamental", "FillPedFLG");
|
---|
581 | MFillH fill1(&evt1, "MPedestalFromExtractorRndm", "FillPedRmsFLG");
|
---|
582 | MFillH fill2(&evt2, "MExtractedSignalCam", "FillExtracted");
|
---|
583 | // MFillH fill3(&evt3, "MPedPhotFundamental", "FillPedPhot");
|
---|
584 | MFillH fill4(&evt4, "MPedPhotFromExtractorRndm", "FillPedRMS");
|
---|
585 | MFillH fill5(&evt5, "MSignalCam", "FillInterpolated");
|
---|
586 | MFillH fill6(&evt6, "MBadPixelsCam", "FillUnsuitable");
|
---|
587 | MFillH fill7(&evt7, "MSignalCam", "FillTimes");
|
---|
588 | MFillH fill8(&evt8, "MCalibConstCam", "FillConv");
|
---|
589 | MFillH fill9(&evt9, "MSignalCam", "FillPulse");
|
---|
590 |
|
---|
591 | MTaskEnv fillflorian("FinalFantasy");
|
---|
592 | fillflorian.SetDefault();
|
---|
593 |
|
---|
594 | // The second rule is for the case reading raw-files!
|
---|
595 | MWriteRootFile write(2, fname, fOverwrite?"RECREATE":"NEW");
|
---|
596 | // Run Header
|
---|
597 | write.AddContainer("MRawRunHeader", "RunHeaders");
|
---|
598 | write.AddContainer("MBadPixelsCam", "RunHeaders");
|
---|
599 | write.AddContainer("MGeomCam", "RunHeaders");
|
---|
600 | // Monte Carlo Headers
|
---|
601 | write.AddContainer("MMcRunHeader", "RunHeaders", kFALSE);
|
---|
602 | write.AddContainer("MMcFadcHeader", "RunHeaders", kFALSE);
|
---|
603 | write.AddContainer("MMcTrigHeader", "RunHeaders", kFALSE);
|
---|
604 | write.AddContainer("MMcConfigRunHeader", "RunHeaders", kFALSE);
|
---|
605 | write.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
|
---|
606 | // Monte Carlo
|
---|
607 | write.AddContainer("MMcEvt", "Events", kFALSE);
|
---|
608 | write.AddContainer("MMcTrig", "Events", kFALSE);
|
---|
609 | // Data tree
|
---|
610 | write.AddContainer("MSignalCam", "Events");
|
---|
611 | write.AddContainer("MPedPhotFundamental", "Events");
|
---|
612 | write.AddContainer("MPedPhotFromExtractor", "Events");
|
---|
613 | write.AddContainer("MPedPhotFromExtractorRndm", "Events");
|
---|
614 | write.AddContainer("MTime", "Events", kFALSE);
|
---|
615 | write.AddContainer("MRawEvtHeader", "Events");
|
---|
616 | //write.AddContainer("MArrivalTime", "Events", kFALSE);
|
---|
617 | //write.AddContainer("MPointingPos", "Events", kFALSE);
|
---|
618 | // Slow-Control: Current-tree
|
---|
619 | write.AddContainer("MTimeCurrents", "Currents", kFALSE);
|
---|
620 | write.AddContainer("MCameraDC", "Currents", kFALSE);
|
---|
621 | write.AddContainer("MReportCurrents", "Currents", kFALSE);
|
---|
622 | // Slow-Control: Camera-tree
|
---|
623 | write.AddContainer("MReportCamera", "Camera", kFALSE);
|
---|
624 | write.AddContainer("MTimeCamera", "Camera", kFALSE);
|
---|
625 | write.AddContainer("MCameraAUX", "Camera", kFALSE);
|
---|
626 | write.AddContainer("MCameraCalibration", "Camera", kFALSE);
|
---|
627 | write.AddContainer("MCameraCooling", "Camera", kFALSE);
|
---|
628 | write.AddContainer("MCameraHV", "Camera", kFALSE);
|
---|
629 | write.AddContainer("MCameraLV", "Camera", kFALSE);
|
---|
630 | write.AddContainer("MCameraLids", "Camera", kFALSE);
|
---|
631 | // Slow-Control: Trigger-tree
|
---|
632 | write.AddContainer("MReportTrigger", "Trigger", kFALSE);
|
---|
633 | write.AddContainer("MTimeTrigger", "Trigger", kFALSE);
|
---|
634 | // Slow-Control: Drive-tree
|
---|
635 | write.AddContainer("MReportDrive", "Drive", kFALSE);
|
---|
636 | write.AddContainer("MTimeDrive", "Drive", kFALSE);
|
---|
637 | // Slow-Control: Central Control-tree
|
---|
638 | write.AddContainer("MReportCC", "CC", kFALSE);
|
---|
639 | write.AddContainer("MTimeCC", "CC", kFALSE);
|
---|
640 |
|
---|
641 | // Write the special MC tree
|
---|
642 | MWriteRootFile writemc(2, fname, fOverwrite?"RECREATE":"NEW");
|
---|
643 | writemc.SetName("WriteMC");
|
---|
644 | writemc.AddContainer("MMcEvtBasic", "OriginalMC");
|
---|
645 |
|
---|
646 | // Now setup tasklist for events
|
---|
647 | MTaskList tlist2;
|
---|
648 |
|
---|
649 | tlist2.AddToList(&caldec);
|
---|
650 | tlist2.AddToList(&decode);
|
---|
651 | tlist2.AddToList(&apply);
|
---|
652 | tlist2.AddToList(&merge);
|
---|
653 | tlist2.AddToList(&pedlo1);
|
---|
654 | tlist2.AddToList(&pedlo2);
|
---|
655 | tlist2.AddToList(&pedlo3);
|
---|
656 | //-----------------------------------------------------------
|
---|
657 |
|
---|
658 | MTaskList tlist3;
|
---|
659 | tlist3.SetFilter(&fcalib);
|
---|
660 |
|
---|
661 | if (fIsInterlaced)
|
---|
662 | {
|
---|
663 | tlist2.AddToList(&fcalib);
|
---|
664 | tlist2.AddToList(&tlist3);
|
---|
665 |
|
---|
666 | if (IsUsePINDiode())
|
---|
667 | tlist3.AddToList(&pinext);
|
---|
668 | if (IsUseBlindPixel())
|
---|
669 | tlist3.AddToList(&bldext);
|
---|
670 | tlist3.AddToList(&taskenv3);
|
---|
671 | tlist3.AddToList(&pacalc);
|
---|
672 | tlist3.AddToList(&filcam);
|
---|
673 | if (fIsRelTimesUpdate)
|
---|
674 | tlist3.AddToList(&filtme);
|
---|
675 | if (IsUseBlindPixel())
|
---|
676 | tlist3.AddToList(&filbnd);
|
---|
677 | if (IsUsePINDiode())
|
---|
678 | tlist3.AddToList(&filpin);
|
---|
679 | tlist3.AddToList(&chcalc);
|
---|
680 | if (fIsRelTimesUpdate)
|
---|
681 | tlist3.AddToList(&recalc);
|
---|
682 | }
|
---|
683 |
|
---|
684 | // Continue for all non-cosmic events
|
---|
685 | tlist2.AddToList(&conttp);
|
---|
686 | if (extractor1)
|
---|
687 | tlist2.AddToList(&taskenv1);
|
---|
688 | if (extractor2)
|
---|
689 | tlist2.AddToList(&taskenv2);
|
---|
690 | tlist2.AddToList(&fill0);
|
---|
691 | tlist2.AddToList(&fill1);
|
---|
692 | tlist2.AddToList(&contcos);
|
---|
693 | if (fIsHiLoCalibration)
|
---|
694 | {
|
---|
695 | plist.AddToList(&hilocam);
|
---|
696 | tlist2.AddToList(&filhil);
|
---|
697 | }
|
---|
698 | if (fIsPulsePosCheck)
|
---|
699 | {
|
---|
700 | plist.AddToList(&hpulcam);
|
---|
701 | tlist2.AddToList(&filpul);
|
---|
702 | }
|
---|
703 |
|
---|
704 | tlist2.AddToList(&fill2);
|
---|
705 | tlist2.AddToList(&calib);
|
---|
706 | if (extractor2 || extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
---|
707 | tlist2.AddToList(&caltm);
|
---|
708 | if (fIsInterlaced)
|
---|
709 | tlist2.AddToList(&fill8);
|
---|
710 | tlist2.AddToList(&bpcal);
|
---|
711 | tlist2.AddToList(&treat);
|
---|
712 | tlist2.AddToList(&fill6);
|
---|
713 | // tlist2.AddToList(&fill3);
|
---|
714 | tlist2.AddToList(&fill4);
|
---|
715 | tlist2.AddToList(&fill5);
|
---|
716 | if (extractor2 || extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
---|
717 | tlist2.AddToList(&fill7);
|
---|
718 | tlist2.AddToList(&fill9);
|
---|
719 |
|
---|
720 | tlist2.AddToList(&fillflorian);
|
---|
721 |
|
---|
722 | // Setup List for Drive-tree
|
---|
723 | //MPointingPosCalc pcalc;
|
---|
724 |
|
---|
725 | // Now setup main tasklist
|
---|
726 | tlist.AddToList(read);
|
---|
727 | if (IsUseMC())
|
---|
728 | {
|
---|
729 | tlist.AddToList(&writemc);
|
---|
730 | tlist.AddToList(&contmc);
|
---|
731 | }
|
---|
732 |
|
---|
733 | if (IsUseRootData())
|
---|
734 | tlist2.AddToList(&pextr);
|
---|
735 | tlist.AddToList(&tlist2, IsUseRootData() ? "Events" : "All");
|
---|
736 |
|
---|
737 | //if (IsUseMC())
|
---|
738 | // tlist.AddToList(&pcalc, "Drive");
|
---|
739 |
|
---|
740 | tlist.AddToList(&write);
|
---|
741 |
|
---|
742 | // Create and setup the eventloop
|
---|
743 | MEvtLoop evtloop(fName);
|
---|
744 | evtloop.SetParList(&plist);
|
---|
745 | evtloop.SetDisplay(fDisplay);
|
---|
746 | evtloop.SetLogStream(fLog);
|
---|
747 | if (!SetupEnv(evtloop))
|
---|
748 | return kFALSE;
|
---|
749 |
|
---|
750 | // Execute first analysis
|
---|
751 | const Bool_t rc = evtloop.Eventloop(fMaxEvents);
|
---|
752 |
|
---|
753 | // make sure owned object are deleted
|
---|
754 | if (extractor1 && extractor1!=fExtractor)
|
---|
755 | delete extractor1;
|
---|
756 | if (extractor2)
|
---|
757 | delete extractor2;
|
---|
758 | if (extractor3)
|
---|
759 | delete extractor3;
|
---|
760 |
|
---|
761 | // return if job failed
|
---|
762 | if (!rc)
|
---|
763 | {
|
---|
764 | *fLog << err << GetDescriptor() << ": Failed." << endl;
|
---|
765 | return kFALSE;
|
---|
766 | }
|
---|
767 |
|
---|
768 | // if everything went ok write and display result
|
---|
769 | DisplayResult(plist);
|
---|
770 |
|
---|
771 | if (fIsPixelCheck)
|
---|
772 | {
|
---|
773 | if (fIsPulsePosCheck)
|
---|
774 | hpulcam[fCheckedPixId].DrawClone("");
|
---|
775 |
|
---|
776 | if (fIsHiLoCalibration)
|
---|
777 | hilocam[fCheckedPixId].DrawClone("");
|
---|
778 | }
|
---|
779 |
|
---|
780 | interlacedcont.Add(&pulcam);
|
---|
781 |
|
---|
782 | if (fIsHiLoCalibration)
|
---|
783 | interlacedcont.Add(&hilcam);
|
---|
784 |
|
---|
785 | if (fIsPulsePosCheck)
|
---|
786 | interlacedcont.Add(plist.FindObject("MHCalibrationPulseTimeCam"));
|
---|
787 |
|
---|
788 | if (fIsHiLoCalibration)
|
---|
789 | interlacedcont.Add(plist.FindObject("MHCalibrationHiLoCam"));
|
---|
790 |
|
---|
791 | if (!WriteResult(interlacedcont))
|
---|
792 | return kFALSE;
|
---|
793 |
|
---|
794 | // return if job went ok
|
---|
795 | *fLog << all << GetDescriptor() << ": Done." << endl;
|
---|
796 | *fLog << endl << endl;
|
---|
797 |
|
---|
798 | return kTRUE;
|
---|
799 | }
|
---|
800 |
|
---|
801 |
|
---|
802 | void MJCalibrateSignal::DisplayResult(MParList &plist)
|
---|
803 | {
|
---|
804 | if (!fDisplay || !fIsHiLoCalibration)
|
---|
805 | return;
|
---|
806 |
|
---|
807 | MCalibrationHiLoCam *hcam = (MCalibrationHiLoCam*)plist.FindObject("MCalibrationHiLoCam");
|
---|
808 | MGeomCam *geom = (MGeomCam*)plist.FindObject("MGeomCam");
|
---|
809 | if (!hcam || !geom)
|
---|
810 | return;
|
---|
811 |
|
---|
812 | // Create histograms to display
|
---|
813 | MHCamera disp1(*geom, "HiLoConv", "Ratio Amplification HiGain vs. LoGain (Charges)");
|
---|
814 | MHCamera disp2(*geom, "HiLoDiff", "Arrival Time Diff. HiGain vs. LoGain (Times)");
|
---|
815 |
|
---|
816 | disp1.SetCamContent(*hcam, 0);
|
---|
817 | disp1.SetCamError( *hcam, 1);
|
---|
818 | disp2.SetCamContent(*hcam, 5);
|
---|
819 | disp2.SetCamError( *hcam, 6);
|
---|
820 |
|
---|
821 | disp1.SetYTitle("R [1]");
|
---|
822 | disp2.SetYTitle("\\Delta T [FADC sl.]");
|
---|
823 |
|
---|
824 | TCanvas &c1 = fDisplay->AddTab("HiLoConv");
|
---|
825 | c1.Divide(2,3);
|
---|
826 |
|
---|
827 | disp1.CamDraw(c1, 1, 2, 1);
|
---|
828 | disp2.CamDraw(c1, 2, 2, 1);
|
---|
829 | }
|
---|
830 |
|
---|