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-2008
|
---|
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 | // Core
|
---|
43 | #include "MLog.h"
|
---|
44 | #include "MLogManip.h"
|
---|
45 |
|
---|
46 | #include "MDirIter.h"
|
---|
47 | #include "MTaskList.h"
|
---|
48 | #include "MParList.h"
|
---|
49 | #include "MEvtLoop.h"
|
---|
50 |
|
---|
51 | #include "MStatusDisplay.h"
|
---|
52 |
|
---|
53 | // General containers
|
---|
54 | #include "MGeomCam.h"
|
---|
55 | #include "MBadPixelsCam.h"
|
---|
56 | #include "MCalibConstCam.h"
|
---|
57 | #include "MPedestalCam.h"
|
---|
58 | #include "MArrivalTimeCam.h"
|
---|
59 |
|
---|
60 | // General histograms
|
---|
61 | #include "MH3.h"
|
---|
62 | #include "MHCamEvent.h"
|
---|
63 | #include "MHVsTime.h"
|
---|
64 |
|
---|
65 | // Calibration containers
|
---|
66 | #include "MCalibrationQECam.h"
|
---|
67 | #include "MCalibrationBlindCam.h"
|
---|
68 | #include "MCalibrationChargeCam.h"
|
---|
69 | #include "MCalibrationRelTimeCam.h"
|
---|
70 | #include "MCalibrationChargePINDiode.h"
|
---|
71 |
|
---|
72 | // Calibration histograms
|
---|
73 | #include "MHCalibrationChargeCam.h"
|
---|
74 | #include "MHCalibrationChargeBlindCam.h"
|
---|
75 | #include "MHCalibrationChargePINDiode.h"
|
---|
76 | #include "MHCalibrationRelTimeCam.h"
|
---|
77 |
|
---|
78 | // Tasks
|
---|
79 | #include "MReadMarsFile.h"
|
---|
80 | #include "MRawFileRead.h"
|
---|
81 | #include "MTaskEnv.h"
|
---|
82 | #include "MContinue.h"
|
---|
83 | #include "MFillH.h"
|
---|
84 | #include "MGeomApply.h"
|
---|
85 | #include "MExtractTimeAndCharge.h"
|
---|
86 | #include "MTriggerPatternDecode.h"
|
---|
87 | #include "MCalibrationPatternDecode.h"
|
---|
88 | #include "MCalibrationChargeCalc.h"
|
---|
89 | #include "MCalibrationRelTimeCalc.h"
|
---|
90 | #include "MCalibCalcFromPast.h"
|
---|
91 | #include "MPedestalSubtract.h"
|
---|
92 | #include "MPedCalcFromLoGain.h"
|
---|
93 | #include "MCalibrateData.h"
|
---|
94 | #include "MExtractPINDiode.h"
|
---|
95 | #include "MExtractBlindPixel.h"
|
---|
96 | #include "MCalibrateRelTimes.h"
|
---|
97 | #include "MBadPixelsCalc.h"
|
---|
98 | #include "MBadPixelsTreat.h"
|
---|
99 | #include "MWriteRootFile.h"
|
---|
100 |
|
---|
101 | // Filter
|
---|
102 | #include "MFTriggerPattern.h"
|
---|
103 | #include "MFCosmics.h"
|
---|
104 | #include "MFilterList.h"
|
---|
105 | #include "MFDataPhrase.h"
|
---|
106 |
|
---|
107 | // Classes for writing movies
|
---|
108 | #include "MFEvtNumber.h"
|
---|
109 | #include "MMoviePrepare.h"
|
---|
110 | #include "MMovieWrite.h"
|
---|
111 | #include "MImgCleanStd.h"
|
---|
112 |
|
---|
113 |
|
---|
114 | ClassImp(MJCalibrateSignal);
|
---|
115 |
|
---|
116 | using namespace std;
|
---|
117 |
|
---|
118 | // --------------------------------------------------------------------------
|
---|
119 | //
|
---|
120 | // Default constructor.
|
---|
121 | //
|
---|
122 | // Sets:
|
---|
123 | // - fIsInterlaced to kTRUE
|
---|
124 | // - fIsRelTimesUpdate to kFALSE
|
---|
125 | // - fIsHiLoCalibration to kFALSE
|
---|
126 | //
|
---|
127 | MJCalibrateSignal::MJCalibrateSignal(const char *name, const char *title)
|
---|
128 | : fExtractor(0), fIsInterlaced(kTRUE), fIsRelTimesUpdate(kTRUE), fIsMovieMode(kFALSE)
|
---|
129 | {
|
---|
130 | fName = name ? name : "MJCalibrateSignal";
|
---|
131 | fTitle = title ? title : "Tool to calibrate data";
|
---|
132 | }
|
---|
133 |
|
---|
134 | MJCalibrateSignal::~MJCalibrateSignal()
|
---|
135 | {
|
---|
136 | if (fExtractor)
|
---|
137 | delete fExtractor;
|
---|
138 | }
|
---|
139 |
|
---|
140 | void MJCalibrateSignal::SetExtractor(const MExtractor *ext)
|
---|
141 | {
|
---|
142 | if (fExtractor)
|
---|
143 | delete fExtractor;
|
---|
144 |
|
---|
145 | fExtractor = ext ? (MExtractor*)ext->Clone() : NULL;
|
---|
146 | }
|
---|
147 |
|
---|
148 | Bool_t MJCalibrateSignal::WriteResult() const
|
---|
149 | {
|
---|
150 | if (IsNoStorage() || fIsMovieMode)
|
---|
151 | return kTRUE;
|
---|
152 |
|
---|
153 | // FIXME: This is not nice because it will update the signal
|
---|
154 | // file always. Which might make the usage outside of
|
---|
155 | // callisto difficult.
|
---|
156 | TObjArray cont;
|
---|
157 | cont.Add(const_cast<TEnv*>(GetEnv()));
|
---|
158 | cont.Add(const_cast<MSequence*>(&fSequence));
|
---|
159 |
|
---|
160 | if (fDisplay)
|
---|
161 | cont.Add(fDisplay);
|
---|
162 |
|
---|
163 | const TString name(Form("signal%08d.root", fSequence.GetSequence()));
|
---|
164 | return WriteContainer(cont, name, "UPDATE");
|
---|
165 | }
|
---|
166 |
|
---|
167 | Bool_t MJCalibrateSignal::ReadCalibration(TObjArray &l, MBadPixelsCam &cam, MExtractor* &ext2, MExtractor* &ext3, TString &geom) const
|
---|
168 | {
|
---|
169 | TString fname = Form("%s/calib%08d.root", fPathIn.Data(), fSequence.GetSequence());
|
---|
170 |
|
---|
171 | *fLog << inf << "Reading from file: " << fname << endl;
|
---|
172 |
|
---|
173 | TFile file(fname, "READ");
|
---|
174 | if (!file.IsOpen())
|
---|
175 | {
|
---|
176 | *fLog << err << dbginf << "ERROR - Could not open file " << fname << endl;
|
---|
177 | return kFALSE;
|
---|
178 | }
|
---|
179 |
|
---|
180 | TObject *o = file.Get("ExtractSignal");
|
---|
181 | if (o && !o->InheritsFrom(MExtractor::Class()))
|
---|
182 | {
|
---|
183 | *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
|
---|
184 | return kFALSE;
|
---|
185 | }
|
---|
186 | ext3 = o ? (MExtractor*)o->Clone() : NULL;
|
---|
187 |
|
---|
188 | o = file.Get("ExtractTime");
|
---|
189 | if (o && !o->InheritsFrom(MExtractor::Class()))
|
---|
190 | {
|
---|
191 | *fLog << err << dbginf << "ERROR - ExtractTime read from " << fname << " doesn't inherit from MExtractor!" << endl;
|
---|
192 | return kFALSE;
|
---|
193 | }
|
---|
194 | ext2 = o ? (MExtractor*)o->Clone() : NULL;
|
---|
195 | if (!ext3 && !ext2)
|
---|
196 | {
|
---|
197 | *fLog << err << dbginf << "ERROR - Neither ExtractSignal nor ExrtractTime found in " << fname << "!" << endl;
|
---|
198 | return kFALSE;
|
---|
199 | }
|
---|
200 |
|
---|
201 | o = file.Get("MGeomCam");
|
---|
202 | if (o && !o->InheritsFrom(MGeomCam::Class()))
|
---|
203 | {
|
---|
204 | *fLog << err << dbginf << "ERROR - MGeomCam read from " << fname << " doesn't inherit from MGeomCam!" << endl;
|
---|
205 | return kFALSE;
|
---|
206 | }
|
---|
207 | geom = o ? o->ClassName() : "";
|
---|
208 |
|
---|
209 | TObjArray cont(l);
|
---|
210 | cont.Add(&cam);
|
---|
211 | return ReadContainer(cont);
|
---|
212 | }
|
---|
213 |
|
---|
214 | // --------------------------------------------------------------------------
|
---|
215 | //
|
---|
216 | // MJCalibration allows to setup several option by a resource file:
|
---|
217 | // MJCalibrateSignal.RawData: yes,no
|
---|
218 | //
|
---|
219 | // For more details see the class description and the corresponding Getters
|
---|
220 | //
|
---|
221 | Bool_t MJCalibrateSignal::CheckEnvLocal()
|
---|
222 | {
|
---|
223 | SetInterlaced(GetEnv("Interlaced", fIsInterlaced));
|
---|
224 | SetRelTimesUpdate(GetEnv("RelTimesUpdate", fIsRelTimesUpdate));
|
---|
225 | SetMovieMode(GetEnv("MovieMode", fIsMovieMode));
|
---|
226 |
|
---|
227 | return MJCalib::CheckEnvLocal();
|
---|
228 | }
|
---|
229 |
|
---|
230 | #include "MParameterCalc.h" // FIXME
|
---|
231 | Bool_t MJCalibrateSignal::Process(MPedestalCam &pedcamab, MPedestalCam &pedcambias,
|
---|
232 | MPedestalCam &pedcamextr)
|
---|
233 | {
|
---|
234 | if (!fSequence.IsValid())
|
---|
235 | {
|
---|
236 | *fLog << err << "ERROR - Sequence invalid..." << endl;
|
---|
237 | return kFALSE;
|
---|
238 | }
|
---|
239 |
|
---|
240 | *fLog << inf;
|
---|
241 | fLog->Separator(GetDescriptor());
|
---|
242 | *fLog << "Calculate calibrated data from Sequence #";
|
---|
243 | *fLog << fSequence.GetSequence() << endl << endl;
|
---|
244 |
|
---|
245 |
|
---|
246 | //if (!CheckEnv())
|
---|
247 | // return kFALSE;
|
---|
248 |
|
---|
249 | CheckEnv();
|
---|
250 |
|
---|
251 | // --------------------------------------------------------------------------------
|
---|
252 |
|
---|
253 | MDirIter iter;
|
---|
254 | if (fSequence.IsValid())
|
---|
255 | {
|
---|
256 | if (fSequence.SetupDatRuns(iter, 0, !fSequence.IsMonteCarlo())<=0)
|
---|
257 | return kFALSE;
|
---|
258 | }
|
---|
259 |
|
---|
260 | // Read File
|
---|
261 | MHCalibrationChargeCam hchacam;
|
---|
262 | MHCalibrationChargeBlindCam hbndcam;
|
---|
263 | MHCalibrationChargePINDiode hpndiod;
|
---|
264 | MHCalibrationRelTimeCam hrelcam;
|
---|
265 | //MHCalibrationHiLoCam hilocam;
|
---|
266 | //MHCalibrationPulseTimeCam hpulcam;
|
---|
267 |
|
---|
268 | hchacam.SetOscillations(kFALSE);
|
---|
269 | hbndcam.SetOscillations(kFALSE);
|
---|
270 | hrelcam.SetOscillations(kFALSE);
|
---|
271 |
|
---|
272 | MCalibrationChargeCam calcam;
|
---|
273 | MCalibrationQECam qecam;
|
---|
274 | MCalibrationBlindCam bndcam;
|
---|
275 | MCalibrationChargePINDiode pind;
|
---|
276 | MCalibrationRelTimeCam tmcam;
|
---|
277 | //MCalibrationHiLoCam hilcam;
|
---|
278 | //MCalibrationPulseTimeCam pulcam;
|
---|
279 |
|
---|
280 | MBadPixelsCam badpix;
|
---|
281 |
|
---|
282 | TObjArray interlacedcont;
|
---|
283 | if (fIsInterlaced)
|
---|
284 | {
|
---|
285 | interlacedcont.Add(&hchacam);
|
---|
286 | if (IsUseBlindPixel())
|
---|
287 | interlacedcont.Add(&hbndcam);
|
---|
288 | if (IsUsePINDiode())
|
---|
289 | interlacedcont.Add(&hpndiod);
|
---|
290 | if (fIsRelTimesUpdate)
|
---|
291 | interlacedcont.Add(&hrelcam);
|
---|
292 | }
|
---|
293 |
|
---|
294 | MExtractor *extractor1=fExtractor;
|
---|
295 | MExtractor *extractor2=0;
|
---|
296 | MExtractor *extractor3=0;
|
---|
297 | TString geom;
|
---|
298 |
|
---|
299 | TObjArray calibcont;
|
---|
300 | calibcont.Add(&calcam);
|
---|
301 | calibcont.Add(&qecam);
|
---|
302 | calibcont.Add(&bndcam);
|
---|
303 | calibcont.Add(&tmcam);
|
---|
304 | if (IsUseBlindPixel())
|
---|
305 | calibcont.Add(&bndcam);
|
---|
306 |
|
---|
307 | if (!ReadCalibration(calibcont, badpix, extractor2, extractor3, geom))
|
---|
308 | return kFALSE;
|
---|
309 |
|
---|
310 | *fLog << all;
|
---|
311 | if (!geom.IsNull())
|
---|
312 | *fLog << inf << "Camera geometry found in file: " << geom << endl;
|
---|
313 | else
|
---|
314 | *fLog << inf << "No Camera geometry found using default <MGeomCamMagic>" << endl;
|
---|
315 |
|
---|
316 | if (extractor3)
|
---|
317 | {
|
---|
318 | *fLog << underline << "Signal Extractor found in calibration file" << endl;
|
---|
319 | extractor3->Print();
|
---|
320 | *fLog << endl;
|
---|
321 | }
|
---|
322 | else
|
---|
323 | *fLog << inf << "No Signal Extractor: ExtractSignal in file." << endl;
|
---|
324 |
|
---|
325 |
|
---|
326 | if (extractor1)
|
---|
327 | {
|
---|
328 | *fLog << underline << "Modified Signal Extractor set by user." << endl;
|
---|
329 | extractor1->Print();
|
---|
330 | *fLog << endl;
|
---|
331 | }
|
---|
332 | else
|
---|
333 | {
|
---|
334 | *fLog << inf << "No modified Signal Extractor set by user... using ExtractSignal." << endl;
|
---|
335 | extractor1 = extractor3 ? (MExtractor*)extractor3->Clone() : 0;
|
---|
336 | }
|
---|
337 |
|
---|
338 | if (extractor2)
|
---|
339 | {
|
---|
340 | *fLog << underline << "Time Extractor found in calibration file" << endl;
|
---|
341 | extractor2->Print();
|
---|
342 | *fLog << endl;
|
---|
343 | }
|
---|
344 | else
|
---|
345 | *fLog << inf << "No Time Extractor: ExtractTime in file." << endl;
|
---|
346 |
|
---|
347 | // This is necessary for the case in which it is not in the files
|
---|
348 | MCalibConstCam constcam;
|
---|
349 |
|
---|
350 | //MBadPixelsCam badcam;
|
---|
351 | constcam.SetBadPixels(&badpix);
|
---|
352 |
|
---|
353 | // Setup Parlist
|
---|
354 | MParList plist;
|
---|
355 | plist.AddToList(this); // take care of fDisplay!
|
---|
356 | plist.AddToList(&badpix);
|
---|
357 | plist.AddToList(&constcam);
|
---|
358 | //plist.AddToList(&hilcam);
|
---|
359 | plist.AddToList(&calibcont); // Using AddToList(TObjArray *)
|
---|
360 | plist.AddToList(&interlacedcont); // Using AddToList(TObjArray *)
|
---|
361 | //plist.AddToList(&pulcam);
|
---|
362 |
|
---|
363 | // Setup Tasklist
|
---|
364 | MTaskList tlist;
|
---|
365 | plist.AddToList(&tlist);
|
---|
366 |
|
---|
367 | MReadMarsFile readmc("Events");
|
---|
368 | readmc.DisableAutoScheme();
|
---|
369 |
|
---|
370 | MRawFileRead rawread(NULL);
|
---|
371 | rawread.SetForceMode(); // Ignore broken time-stamps
|
---|
372 |
|
---|
373 | MRead *read = fSequence.IsMonteCarlo() ? (MRead*)&readmc : (MRead*)&rawread;
|
---|
374 | read->AddFiles(iter);
|
---|
375 |
|
---|
376 | const TString fname(Form("%s{s/_D_/_Y_}{s/\\.raw$/.root}{s/\\.raw\\.gz$/.root}", fPathOut.Data()));
|
---|
377 |
|
---|
378 | // Skips MC which have no contents. This are precisely the
|
---|
379 | // events which fullfilled the MC Lvl1 trigger and an
|
---|
380 | // arbitrary cut (typically at 50phe) to speed up simulation
|
---|
381 | MContinue contmc("MRawEvtData.GetNumPixels<0.5", "ContEmptyMC");
|
---|
382 |
|
---|
383 | //MPointingPosInterpolate pextr;
|
---|
384 | //pextr.AddFiles(&iter);
|
---|
385 |
|
---|
386 | MGeomApply apply; // Only necessary to create geometry
|
---|
387 | if (!geom.IsNull())
|
---|
388 | apply.SetGeometry(geom);
|
---|
389 | //MBadPixelsMerge merge(&badpix);
|
---|
390 |
|
---|
391 | // Make sure that pedcamab has the correct name
|
---|
392 | pedcamab.SetName("MPedestalFundamental");
|
---|
393 | pedcamextr.SetName("MPedestalFromExtractorRndm");
|
---|
394 | pedcambias.SetName("MPedestalFromExtractor");
|
---|
395 | plist.AddToList(&pedcamextr);
|
---|
396 | plist.AddToList(&pedcambias);
|
---|
397 | plist.AddToList(&pedcamab);
|
---|
398 |
|
---|
399 | MArrivalTimeCam timecam;
|
---|
400 | plist.AddToList(&timecam);
|
---|
401 |
|
---|
402 | // Check for interleaved events
|
---|
403 | MCalibrationPatternDecode caldec;
|
---|
404 | MTriggerPatternDecode decode;
|
---|
405 |
|
---|
406 | MH3 hpat("MRawRunHeader.fRunNumber", "MTriggerPattern.GetUnprescaled");
|
---|
407 | hpat.SetWeight("1./MRawRunHeader.GetRunLength");
|
---|
408 | hpat.SetName("TrigPat");
|
---|
409 | hpat.SetTitle("Rate of the trigger pattern [Hz];Run Number;Trigger Pattern;Rate [Hz]");
|
---|
410 | hpat.InitLabels(MH3::kLabelsXY);
|
---|
411 | //hpat.DefineLabelsY("1=Lvl1;2=Cal;3=Cal;4=Lvl2;5=Cal;7=Cal;8=Ped;9=Ped+Trig;13=Ped+Trig;16=Pin;32=Sum");
|
---|
412 | hpat.DefaultLabelY("UNKNOWN");
|
---|
413 | hpat.DefineLabelY( 0, "0"); // 0: No pattern
|
---|
414 | hpat.DefineLabelY( 1, "Trig"); // 1: Lvl1
|
---|
415 | hpat.DefineLabelY( 2, "Cal"); // 2: Cal
|
---|
416 | hpat.DefineLabelY( 3, "Cal"); // Cal+Lvl1
|
---|
417 | hpat.DefineLabelY( 4, "Trig"); // 4: Lvl2
|
---|
418 | hpat.DefineLabelY( 5, "Trig"); // Lvl2+Lvl1
|
---|
419 | hpat.DefineLabelY( 7, "Cal"); // Lvl2+Cal+Lvl
|
---|
420 | hpat.DefineLabelY( 8, "Ped"); // 8: Ped
|
---|
421 | hpat.DefineLabelY( 9, "Ped+Trig"); // Ped+Lvl1
|
---|
422 | hpat.DefineLabelY(10, "Ped+Cal"); // Ped+Cal
|
---|
423 | hpat.DefineLabelY(12, "Ped+Trig"); // Ped+Lvl2
|
---|
424 | hpat.DefineLabelY(13, "Ped+Trig"); // Ped+Lvl2+Lvl1
|
---|
425 | hpat.DefineLabelY(16, "Pin"); // 16: Pin
|
---|
426 | hpat.DefineLabelY(32, "Sum"); // 32: Sum
|
---|
427 | hpat.DefineLabelY(33, "Trig"); // Sum+Lvl1
|
---|
428 | hpat.DefineLabelY(34, "Cal"); // Sum+Cal
|
---|
429 | hpat.DefineLabelY(35, "Cal"); // Sum+Cal+Lvl1
|
---|
430 | hpat.DefineLabelY(36, "Trig"); // Sum+Lvl2
|
---|
431 | hpat.DefineLabelY(37, "Trig"); // Sum+Lvl1+Lvl2
|
---|
432 | hpat.DefineLabelY(39, "Cal"); // Sum+Lvl2+Cal+Lvl1
|
---|
433 |
|
---|
434 | MFillH fillpat(&hpat, "", "FillPattern");
|
---|
435 | fillpat.SetDrawOption("box");
|
---|
436 |
|
---|
437 | // This will make that for data with version less than 5, where
|
---|
438 | // trigger patterns were not yet correct, all the events in the real
|
---|
439 | // data file will be processed. In any case there are no interleaved
|
---|
440 | // calibration events in such data, so this is fine.
|
---|
441 | // We allow only cosmics triggered events to pass (before prescaling)
|
---|
442 | MFTriggerPattern fcalped;
|
---|
443 | fcalped.SetInverted();
|
---|
444 | fcalped.SetDefault(kTRUE);
|
---|
445 | fcalped.DenyAll();
|
---|
446 | fcalped.AllowTriggerLvl1();
|
---|
447 | fcalped.AllowTriggerLvl2();
|
---|
448 | fcalped.AllowSumTrigger();
|
---|
449 |
|
---|
450 | // This will skip interleaved events with a cal- or ped-trigger
|
---|
451 | MContinue contcalped(&fcalped, "ContTrigPattern");
|
---|
452 |
|
---|
453 | // Create the pedestal subtracted raw-data
|
---|
454 | MPedestalSubtract pedsub;
|
---|
455 | pedsub.SetPedestalCam(&pedcamab);
|
---|
456 |
|
---|
457 | // Do signal and pedestal calculation
|
---|
458 | MPedCalcFromLoGain pedlo1("MPedCalcFundamental");
|
---|
459 | pedlo1.SetPedestalUpdate(kTRUE);
|
---|
460 | pedlo1.SetNamePedestalCamOut("MPedestalFundamental");
|
---|
461 |
|
---|
462 | MPedCalcFromLoGain pedlo2("MPedCalcWithExtractorRndm");
|
---|
463 | pedlo2.SetPedestalUpdate(kTRUE);
|
---|
464 | pedlo2.SetRandomCalculation(kTRUE);
|
---|
465 | pedlo2.SetNamePedestalCamOut("MPedestalFromExtractorRndm");
|
---|
466 |
|
---|
467 | MPedCalcFromLoGain pedlo3("MPedCalcWithExtractor");
|
---|
468 | pedlo3.SetPedestalUpdate(kTRUE);
|
---|
469 | pedlo3.SetRandomCalculation(kFALSE);
|
---|
470 | pedlo3.SetNamePedestalCamOut("MPedestalFromExtractor");
|
---|
471 |
|
---|
472 | if (!extractor1)
|
---|
473 | {
|
---|
474 | *fLog << err << "ERROR - extractor1 == NULL" << endl;
|
---|
475 | return kFALSE;
|
---|
476 | }
|
---|
477 |
|
---|
478 | // Setup to use the hi-gain extraction window in the lo-gain
|
---|
479 | // range (the start of the lo-gain range is added automatically
|
---|
480 | // by MPedCalcFromLoGain)
|
---|
481 | //
|
---|
482 | // The window size of the extractor is not yet initialized,
|
---|
483 | // so we have to stick to the extraction range
|
---|
484 | //
|
---|
485 | // Even if we would like to use a range comparable to the
|
---|
486 | // hi-gain extraction we use the lo-gain range to make
|
---|
487 | // sure that exclusions (eg. due to switching noise)
|
---|
488 | // are correctly handled.
|
---|
489 | //
|
---|
490 | pedlo1.SetRangeFromExtractor(*extractor1);
|
---|
491 |
|
---|
492 | if (extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
---|
493 | {
|
---|
494 | pedlo2.SetExtractor((MExtractTimeAndCharge*)extractor1);
|
---|
495 | pedlo3.SetExtractor((MExtractTimeAndCharge*)extractor1);
|
---|
496 | }
|
---|
497 | else
|
---|
498 | {
|
---|
499 | pedlo2.SetRangeFromExtractor(*extractor1);
|
---|
500 | pedlo3.SetRangeFromExtractor(*extractor1);
|
---|
501 | }
|
---|
502 |
|
---|
503 | //------------------------------
|
---|
504 | //
|
---|
505 | // this is the filter to find pedestal events. For the Siegen FADC
|
---|
506 | // these are all events which are not calibration events because
|
---|
507 | // the pedestal is extracted from the lo-gain signal. For MUX
|
---|
508 | // data this are artifiially triggered events with the pedestal
|
---|
509 | // trigger flag, and for safty without Lvl1 or Lvl2 flag)
|
---|
510 | //
|
---|
511 | // For the time "before" the trigger pattern all events (Siegen FADC)
|
---|
512 | // can be considered to be pedestal, because this was also the time
|
---|
513 | // without artifially calibration events
|
---|
514 | //
|
---|
515 | // Deny or allow is done before prescaling.
|
---|
516 | //
|
---|
517 | MFTriggerPattern fped("SelectPedestals");
|
---|
518 | fped.SetDefault(kTRUE);
|
---|
519 | fped.DenyCalibration();
|
---|
520 | if (!extractor1->HasLoGain())
|
---|
521 | {
|
---|
522 | fped.DenyAll();
|
---|
523 | fped.RequirePedestal();
|
---|
524 | }
|
---|
525 |
|
---|
526 | //------------------------------
|
---|
527 | //
|
---|
528 | // Apply a filter against cosmics (this is to make sure that the
|
---|
529 | // trigger system was working properly and no empty events survive)
|
---|
530 | // For every event 5% of the pixel must not be empty. In PostProcess
|
---|
531 | // an error is raised if more than 50% of the events were skipped.
|
---|
532 | //
|
---|
533 | MFCosmics fcosmicscal;
|
---|
534 | fcosmicscal.SetNamePedestalCam("MPedestalFundamental"); //CORRECT?
|
---|
535 | fcosmicscal.SetMaxEmptyPixels(0.05);
|
---|
536 | fcosmicscal.SetMaxAcceptedFraction(0.5);
|
---|
537 |
|
---|
538 | MContinue contcoscal(&fcosmicscal, "ContCosmicsCal");
|
---|
539 |
|
---|
540 | //------------------------------
|
---|
541 | /*
|
---|
542 | MFCosmics fcosmicsped; // Def=20% empty pixels
|
---|
543 | fcosmicsped.SetNamePedestalCam("MPedestalFundamental"); //CORRECT?
|
---|
544 | MContinue contcosped(&fcosmicsped, "ContCosmicsPed");
|
---|
545 | contcosped.SetInverted();
|
---|
546 | */
|
---|
547 |
|
---|
548 | //------------------------------
|
---|
549 | //
|
---|
550 | // Thie signal extractors
|
---|
551 | //
|
---|
552 | MTaskEnv taskenv1("ExtractSignal");
|
---|
553 | MTaskEnv taskenv2("ExtractTime");
|
---|
554 | MTaskEnv taskenv3("ExtractInterlaced");
|
---|
555 | taskenv1.SetDefault(extractor1);
|
---|
556 | taskenv2.SetDefault(extractor2);
|
---|
557 | taskenv3.SetDefault(extractor3);
|
---|
558 |
|
---|
559 | //
|
---|
560 | // This is new calibration to photo-electrons, hard-coded
|
---|
561 | // as decided at the Wuerzburg software meeting 26.01.05
|
---|
562 | //
|
---|
563 | MCalibrateData calib;
|
---|
564 | calib.SetSignalType(MCalibrateData::kPhe);
|
---|
565 | //calib.AddPedestal("Fundamental");
|
---|
566 | calib.AddPedestal("FromExtractor");
|
---|
567 | calib.AddPedestal("FromExtractorRndm");
|
---|
568 | calib.SetPedestalFlag(MCalibrateData::kEvent);
|
---|
569 |
|
---|
570 | //----------------------------------------------------------
|
---|
571 |
|
---|
572 | MExtractPINDiode pinext;
|
---|
573 | MExtractBlindPixel bldext;
|
---|
574 |
|
---|
575 | // Execute for all events with the calibration trigger. If no
|
---|
576 | // trigger pattern is available do not execute it
|
---|
577 | // The selection is done before prescaling.
|
---|
578 | MFTriggerPattern fcalib("CalibFilter");
|
---|
579 | fcalib.SetDefault(kFALSE);
|
---|
580 | fcalib.DenyAll();
|
---|
581 | fcalib.RequireCalibration();
|
---|
582 | fcalib.AllowTriggerLvl1();
|
---|
583 | fcalib.AllowTriggerLvl2();
|
---|
584 | fcalib.AllowSumTrigger();
|
---|
585 |
|
---|
586 | MCalibrationChargeCalc chcalc;
|
---|
587 | chcalc.SetContinousCalibration();
|
---|
588 | chcalc.SetExtractor(extractor3);
|
---|
589 |
|
---|
590 | MCalibrationRelTimeCalc recalc;
|
---|
591 | MCalibCalcFromPast pacalc;
|
---|
592 |
|
---|
593 | chcalc.SetPedestals(&pedcamextr);
|
---|
594 |
|
---|
595 | pacalc.SetChargeCalc(&chcalc);
|
---|
596 | if (fIsRelTimesUpdate)
|
---|
597 | pacalc.SetRelTimeCalc(&recalc);
|
---|
598 | pacalc.SetCalibrate(&calib);
|
---|
599 |
|
---|
600 | //
|
---|
601 | // Calibration histogramming
|
---|
602 | //
|
---|
603 | MFillH filpin(&hpndiod, "MExtractedSignalPINDiode", "FillPINDiode");
|
---|
604 | MFillH filbnd(&hbndcam, "MExtractedSignalBlindPixel", "FillBlindCam");
|
---|
605 | MFillH filcam(&hchacam, "MExtractedSignalCam", "FillChargeCam");
|
---|
606 | MFillH filtme(&hrelcam, "MArrivalTimeCam", "FillRelTime");
|
---|
607 | //MFillH filhil(&hilocam, "MExtractedSignalCam", "FillHiLoRatio");
|
---|
608 | //MFillH filpul(&hpulcam, "MRawEvtData", "FillPulseTime");
|
---|
609 | filpin.SetBit(MFillH::kDoNotDisplay);
|
---|
610 | filbnd.SetBit(MFillH::kDoNotDisplay);
|
---|
611 | filcam.SetBit(MFillH::kDoNotDisplay);
|
---|
612 | filtme.SetBit(MFillH::kDoNotDisplay);
|
---|
613 | //filhil.SetBit(MFillH::kDoNotDisplay);
|
---|
614 | //filpul.SetBit(MFillH::kDoNotDisplay);
|
---|
615 |
|
---|
616 | MCalibrateRelTimes caltm;
|
---|
617 | MBadPixelsCalc bpcal;
|
---|
618 | MBadPixelsTreat treat;
|
---|
619 |
|
---|
620 | //bpcal.SetNamePedPhotCam("MPedPhotFromExtractor");
|
---|
621 | bpcal.SetNamePedPhotCam("MPedPhotFromExtractorRndm");
|
---|
622 |
|
---|
623 | //treat.AddNamePedPhotCam("MPedPhotFundamental");
|
---|
624 | treat.AddNamePedPhotCam("MPedPhotFromExtractor");
|
---|
625 | treat.AddNamePedPhotCam("MPedPhotFromExtractorRndm");
|
---|
626 | if (!extractor2 && !extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
---|
627 | treat.SetProcessTimes(kFALSE);
|
---|
628 |
|
---|
629 | MHCamEvent evt0( 0, "PedFLG", "Fundamental Pedestal from Lo Gain;;P [cnts/sl]");
|
---|
630 | MHCamEvent evt1( 2, "PedRmsFLG", "RMS from Extractor applied to ped.;;\\sigma_{p} [cnts/sl]");
|
---|
631 | MHCamEvent evt2( 0, "Extra'd", "Extracted Signal;;S [cnts/sl]");
|
---|
632 | // MHCamEvent evt3(4, "PedPhot", "Calibrated Pedestal;;P [phe]");
|
---|
633 | MHCamEvent evt4( 5, "PedRMS", "Calibrated RMS from Extractor applied to ped.;;\\sigma_{p} [phe]");
|
---|
634 | MHCamEvent evt5( 0, "Interp'd", "Interpolated Signal scaled with A/A_{0};;S [phe]");
|
---|
635 | MHCamEvent evt6(102, "Unsuitable", "Fraction of unsuitable events per Pixel;;[1]");
|
---|
636 | // MHCamEvent evt7( 6, "Times", "Calibrated Arrival Time;;T [fadc sl]");
|
---|
637 | MHCamEvent evt8( 0, "Conv", "Calibration Conv. Factors;;[phe/cnts]");
|
---|
638 | MHCamEvent evt9( 7, "PulsePos", "Pulse Position of cosmics (>50phe);;T [ns]");
|
---|
639 | MHCamEvent evtR( 4, "HiLoCal", "Hi-/Lo-Gain ratio;;Ratio");
|
---|
640 | MHCamEvent evtO( 7, "HiLoOff", "Lo-/Hi-Gain Offset;;Offset");
|
---|
641 | MHCamEvent evtC( 4, "CalPos", "Extracted pulse position of calibration pulses;;T [sl]");
|
---|
642 | //MHCamEvent evt2(0, "Extra'd", "Extracted Calibration Signal;;S [cnts/sl]");
|
---|
643 | evt2.SetErrorSpread(kFALSE);
|
---|
644 | evt5.SetErrorSpread(kFALSE);
|
---|
645 | evt6.SetErrorSpread(kFALSE);
|
---|
646 | evt6.SetThreshold();
|
---|
647 |
|
---|
648 | MFillH fill0(&evt0, "MPedestalFundamental", "FillPedFLG");
|
---|
649 | MFillH fill1(&evt1, "MPedestalFromExtractorRndm", "FillPedRmsFLG");
|
---|
650 | MFillH fill2(&evt2, "MExtractedSignalCam", "FillExtracted");
|
---|
651 | // MFillH fill3(&evt3, "MPedPhotFundamental", "FillPedPhot");
|
---|
652 | MFillH fill4(&evt4, "MPedPhotFromExtractorRndm", "FillPedRMS");
|
---|
653 | MFillH fill5(&evt5, "MSignalCam", "FillInterpolated");
|
---|
654 | MFillH fill6(&evt6, "MBadPixelsCam", "FillUnsuitable");
|
---|
655 | // MFillH fill7(&evt7, "MSignalCam", "FillTimes");
|
---|
656 | MFillH fill8(&evt8, "MCalibConstCam", "FillConv");
|
---|
657 | MFillH fill9(&evt9, "MSignalCam", "FillPulsePos");
|
---|
658 | MFillH fillR(&evtR, "MExtractedSignalCam", "FillHiLoCal");
|
---|
659 | MFillH fillO(&evtO, "MArrivalTimeCam", "FillHiLoOff");
|
---|
660 | MFillH fillC(&evtC, "MArrivalTimeCam", "FillCalPos");
|
---|
661 | //MFillH fill2(&evt2, "MExtractedSignalCam", "FillExtractedSignal");
|
---|
662 |
|
---|
663 | MHVsTime histbp("MBadPixelsCam.GetNumUnsuitable");
|
---|
664 | histbp.SetName("BadPixTm");
|
---|
665 | histbp.SetTitle("Number of unsuitable pixels;;N");
|
---|
666 | histbp.SetMinimum(0);
|
---|
667 |
|
---|
668 | MHVsTime histdp("MSignalCam.GetNumPixelsUnmapped");
|
---|
669 | histdp.SetName("DeadPixTm");
|
---|
670 | histdp.SetTitle("Number of dead/unmapped pixels;;N");
|
---|
671 | histdp.SetMinimum(0);
|
---|
672 |
|
---|
673 | // Task to fill the histogram
|
---|
674 | MFillH fillB(&histbp, "MTime", "FillBadPixTm");
|
---|
675 | MFillH fillD(&histdp, "MTime", "FillDeadPixTm");
|
---|
676 | fillB.SetNameTab("BadPixTm");
|
---|
677 | fillD.SetNameTab("DeadPixTm");
|
---|
678 |
|
---|
679 | /*
|
---|
680 | MFillH fillP("MHPulseShape", "", "FillPulseShape");
|
---|
681 | fillP.SetNameTab("Pulse");
|
---|
682 | */
|
---|
683 |
|
---|
684 | /*
|
---|
685 | MHVsTime hbadpix("MBadPixelsCam.GetNumUnsuitable");
|
---|
686 | hbadpix.SetNumEvents(50);
|
---|
687 | MFillH fillB(&hbadpix, "MTime");
|
---|
688 | */
|
---|
689 |
|
---|
690 | MTaskEnv fillflorian("FinalFantasy");
|
---|
691 | fillflorian.SetDefault();
|
---|
692 |
|
---|
693 | // The second rule is for the case reading raw-files!
|
---|
694 | MWriteRootFile write(2, fname, fOverwrite?"RECREATE":"NEW");
|
---|
695 | // Run Header
|
---|
696 | write.AddContainer("MRawRunHeader", "RunHeaders");
|
---|
697 | // write.AddContainer("MBadPixelsCam", "RunHeaders");
|
---|
698 | write.AddContainer("MGeomCam", "RunHeaders");
|
---|
699 | // Monte Carlo Headers
|
---|
700 | write.AddContainer("MMcRunHeader", "RunHeaders", kFALSE);
|
---|
701 | write.AddContainer("MMcFadcHeader", "RunHeaders", kFALSE);
|
---|
702 | write.AddContainer("MMcTrigHeader", "RunHeaders", kFALSE);
|
---|
703 | write.AddContainer("MMcConfigRunHeader", "RunHeaders", kFALSE);
|
---|
704 | write.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
|
---|
705 | // Monte Carlo
|
---|
706 | write.AddContainer("MMcEvt", "Events", kFALSE);
|
---|
707 | write.AddContainer("MMcTrig", "Events", kFALSE);
|
---|
708 | // Data tree
|
---|
709 | write.AddContainer("MSignalCam", "Events");
|
---|
710 | // write.AddContainer("MPedPhotFundamental", "Events");
|
---|
711 | write.AddContainer("MPedPhotFromExtractor", "Events");
|
---|
712 | write.AddContainer("MPedPhotFromExtractorRndm", "Events");
|
---|
713 | write.AddContainer("MTime", "Events", kFALSE);
|
---|
714 | write.AddContainer("MRawEvtHeader", "Events");
|
---|
715 | write.AddContainer("MTriggerPattern", "Events");
|
---|
716 |
|
---|
717 | // Trees with slow-control information (obsolete
|
---|
718 | // if we don't read merpped root-files)
|
---|
719 | write.AddTree("Trigger", kFALSE);
|
---|
720 | write.AddTree("Drive", kFALSE);
|
---|
721 | write.AddTree("CC", kFALSE);
|
---|
722 | write.AddTree("Pyrometer", kFALSE);
|
---|
723 | write.AddTree("Currents", kFALSE);
|
---|
724 | write.AddTree("Camera", kFALSE);
|
---|
725 | // Slow-Control: Current-tree
|
---|
726 | write.AddContainer("MCameraDC", "Currents", kFALSE);
|
---|
727 | // Slow-Control: Camera-tree
|
---|
728 | write.AddContainer("MCameraAUX", "Camera", kFALSE);
|
---|
729 | write.AddContainer("MCameraCalibration", "Camera", kFALSE);
|
---|
730 | write.AddContainer("MCameraCooling", "Camera", kFALSE);
|
---|
731 | write.AddContainer("MCameraHV", "Camera", kFALSE);
|
---|
732 | write.AddContainer("MCameraLV", "Camera", kFALSE);
|
---|
733 | write.AddContainer("MCameraLids", "Camera", kFALSE);
|
---|
734 |
|
---|
735 | // Write the special MC tree
|
---|
736 | MWriteRootFile writemc(2, fname, fOverwrite?"RECREATE":"NEW");
|
---|
737 | writemc.SetName("WriteMC");
|
---|
738 | writemc.AddContainer("MMcEvtBasic", "OriginalMC");
|
---|
739 |
|
---|
740 | // Write the special calib tree
|
---|
741 | /*
|
---|
742 | MWriteRootFile writecal(2, fname, fOverwrite?"RECREATE":"NEW");
|
---|
743 | writecal.SetName("WriteCalib");
|
---|
744 | writecal.AddContainer("MBadPixelsCam", "Calib");
|
---|
745 | writecal.AddContainer("MCalibrationChargeCam", "Calib");
|
---|
746 | writecal.AddContainer("MCalibrationRelTimeCam", "Calib");
|
---|
747 | */
|
---|
748 |
|
---|
749 | //-----------------------------------------------------------
|
---|
750 | // Build tasklist
|
---|
751 |
|
---|
752 | MTaskList tlist2;
|
---|
753 |
|
---|
754 | tlist2.AddToList(&caldec);
|
---|
755 | tlist2.AddToList(&decode);
|
---|
756 | tlist2.AddToList(&fillpat);
|
---|
757 | tlist2.AddToList(&apply);
|
---|
758 | //tlist2.AddToList(&merge);
|
---|
759 | tlist2.AddToList(&pedsub);
|
---|
760 |
|
---|
761 | //-----------------------------------------------------------
|
---|
762 | // Pedestal extraction
|
---|
763 |
|
---|
764 | MTaskList tlist3;
|
---|
765 | tlist3.SetFilter(&fped); // Deny events with cal-trigger
|
---|
766 |
|
---|
767 | tlist2.AddToList(&fped); // If no lo-gain require ped-trigger
|
---|
768 | tlist2.AddToList(&tlist3); // and deny cosmics (lvl1/2) trigger
|
---|
769 |
|
---|
770 | tlist3.AddToList(&pedlo1); // extract pedestal events
|
---|
771 | tlist3.AddToList(&pedlo2); // extract pedestal events
|
---|
772 | tlist3.AddToList(&pedlo3); // extract pedestal events
|
---|
773 | tlist3.AddToList(&fill0); // fill pedestal events
|
---|
774 | tlist3.AddToList(&fill1); // fill pedestal events
|
---|
775 |
|
---|
776 | //-----------------------------------------------------------
|
---|
777 | // Calibration
|
---|
778 |
|
---|
779 | MTaskList tlist4;
|
---|
780 | tlist4.SetFilter(&fcalib); // process only events with cal-trigger
|
---|
781 |
|
---|
782 | //MFDataPhrase filcalco("MCalibrationConstCam.IsReadyToSave>0.5", "CalibConstFilter");
|
---|
783 | if (fIsInterlaced)
|
---|
784 | {
|
---|
785 | // The task list is executed for all events with the calibration
|
---|
786 | // trigger
|
---|
787 | tlist2.AddToList(&fcalib); // MFTriggerPattern
|
---|
788 | tlist2.AddToList(&tlist4);
|
---|
789 |
|
---|
790 | tlist4.AddToList(&taskenv3);
|
---|
791 | tlist4.AddToList(&contcoscal); // MContinue/ContCosmicsCal
|
---|
792 | if (IsUsePINDiode())
|
---|
793 | tlist4.AddToList(&pinext); // MExtractPINDiode
|
---|
794 | if (IsUseBlindPixel())
|
---|
795 | tlist4.AddToList(&bldext); // MExtractBlindPixel
|
---|
796 | tlist4.AddToList(&pacalc); // MCalibCalcFromPast
|
---|
797 | /*
|
---|
798 | tlist3.AddToList(&filcalco); // CalibConstFilter (IsReadyToSave)
|
---|
799 | fill8.SetFilter(&filcalco);
|
---|
800 | tlist3.AddToList(&fill8); // FillConvUpd
|
---|
801 | */
|
---|
802 |
|
---|
803 | tlist4.AddToList(&filcam); // FillChargeCam
|
---|
804 | if (fIsRelTimesUpdate)
|
---|
805 | tlist4.AddToList(&filtme); // FillRelTime
|
---|
806 | if (IsUseBlindPixel())
|
---|
807 | tlist4.AddToList(&filbnd); // FillBlindCam
|
---|
808 | if (IsUsePINDiode())
|
---|
809 | tlist4.AddToList(&filpin); // FillPINDiode
|
---|
810 | tlist4.AddToList(&chcalc); // MCalibrationChargeCalc
|
---|
811 | if (fIsRelTimesUpdate)
|
---|
812 | tlist4.AddToList(&recalc); // MCalibrationRelTimeCam
|
---|
813 |
|
---|
814 | tlist4.AddToList(&fillC); // FillCalPos
|
---|
815 |
|
---|
816 | //tlist3.AddToList(&writecal); // MWriteRootFile
|
---|
817 | }
|
---|
818 |
|
---|
819 | //-----------------------------------------------------------
|
---|
820 | // Cosmics extraction
|
---|
821 |
|
---|
822 | // remove all events with a cal- or ped-trigger (no matter
|
---|
823 | // whether they have lvl1 or lvl2 or any other flag
|
---|
824 | tlist2.AddToList(&contcalped);
|
---|
825 |
|
---|
826 | // Extract the signal
|
---|
827 | if (extractor1)
|
---|
828 | tlist2.AddToList(&taskenv1);
|
---|
829 |
|
---|
830 | // remove all events which definitly don't have a signal
|
---|
831 | // using MFCosmics (ContCosmicsPed)
|
---|
832 | // tlist2.AddToList(&contcosped);
|
---|
833 |
|
---|
834 | // Extract arrival time (if a dedicated extrator given)
|
---|
835 | if (extractor2)
|
---|
836 | tlist2.AddToList(&taskenv2);
|
---|
837 |
|
---|
838 | /*
|
---|
839 | if (fIsHiLoCalibration)
|
---|
840 | {
|
---|
841 | plist.AddToList(&hilocam);
|
---|
842 | tlist2.AddToList(&filhil);
|
---|
843 | }
|
---|
844 |
|
---|
845 | if (fIsPulsePosCheck)
|
---|
846 | {
|
---|
847 | plist.AddToList(&hpulcam);
|
---|
848 | tlist2.AddToList(&filpul);
|
---|
849 | }
|
---|
850 | */
|
---|
851 |
|
---|
852 | tlist2.AddToList(&fill2);
|
---|
853 | tlist2.AddToList(&fill8); // FillConv
|
---|
854 | tlist2.AddToList(&calib); // MCalibrateData
|
---|
855 | if (extractor2 || extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
---|
856 | tlist2.AddToList(&caltm);
|
---|
857 |
|
---|
858 | tlist2.AddToList(&bpcal); // MBadPixelsCalc
|
---|
859 | tlist2.AddToList(&treat); // MBadPixelsTreat
|
---|
860 | tlist2.AddToList(&fill6);
|
---|
861 | // tlist2.AddToList(&fill3);
|
---|
862 | tlist2.AddToList(&fill4);
|
---|
863 | tlist2.AddToList(&fill5);
|
---|
864 | //if (extractor2 || extractor1->InheritsFrom("MExtractTimeAndCharge"))
|
---|
865 | // tlist2.AddToList(&fill7);
|
---|
866 | tlist2.AddToList(&fill9);
|
---|
867 | if (!fSequence.IsMonteCarlo())
|
---|
868 | {
|
---|
869 | tlist2.AddToList(&fillB);
|
---|
870 | tlist2.AddToList(&fillD);
|
---|
871 | }
|
---|
872 | if (extractor1->HasLoGain())
|
---|
873 | {
|
---|
874 | tlist2.AddToList(&fillR);
|
---|
875 | tlist2.AddToList(&fillO);
|
---|
876 | }
|
---|
877 |
|
---|
878 | /*
|
---|
879 | MFillH fillC("MHCleaning", "", "FillClean");
|
---|
880 | tlist2.AddToList(&fillC);
|
---|
881 |
|
---|
882 | //tlist2.AddToList(&fillP);
|
---|
883 | */
|
---|
884 |
|
---|
885 | // ----- Start: Code for encoding movies -----
|
---|
886 |
|
---|
887 | MMoviePrepare movprep;
|
---|
888 | MMovieWrite movwrite;
|
---|
889 | movprep.SetRangeFromExtractor(*extractor1);
|
---|
890 |
|
---|
891 | //MFDataPhrase movfilt("MMovieData.fMax>150");
|
---|
892 | MFDataPhrase movfilt("MMovieData.fMax>5*MMovieData.fMedianPedestalRms", "MovieFilter");
|
---|
893 |
|
---|
894 | MImgCleanStd movclean(8.5, 4.0);
|
---|
895 | movclean.SetMethod(MImgCleanStd::kAbsolute);
|
---|
896 |
|
---|
897 | //movprep.SetFilter(&evtnum);
|
---|
898 | movclean.SetFilter(&movfilt);
|
---|
899 | movwrite.SetFilter(&movfilt);
|
---|
900 |
|
---|
901 | MTaskList tlistmov("MovieEncoder");
|
---|
902 | tlistmov.AddToList(&movprep);
|
---|
903 | tlistmov.AddToList(&movfilt);
|
---|
904 | tlistmov.AddToList(&movclean);
|
---|
905 | tlistmov.AddToList(&movwrite);
|
---|
906 |
|
---|
907 | MFEvtNumber evtnum;
|
---|
908 | //evtnum.SetSelector("ThetaSquared.fVal<0.04");
|
---|
909 | //evtnum.SetFileName("ganymed00000001.root");
|
---|
910 | tlistmov.SetFilter(&evtnum);
|
---|
911 |
|
---|
912 | if (fIsMovieMode)
|
---|
913 | {
|
---|
914 | tlist2.AddToList(&evtnum);
|
---|
915 | tlist2.AddToList(&tlistmov);
|
---|
916 | }
|
---|
917 |
|
---|
918 | // ----- End: Code for encoding movies -----
|
---|
919 |
|
---|
920 | tlist2.AddToList(&fillflorian);
|
---|
921 |
|
---|
922 | // Setup List for Drive-tree
|
---|
923 | //MPointingPosCalc pcalc;
|
---|
924 |
|
---|
925 | // Now setup main tasklist
|
---|
926 | tlist.AddToList(read);
|
---|
927 |
|
---|
928 | if (fSequence.IsMonteCarlo())
|
---|
929 | {
|
---|
930 | if (!fIsMovieMode && !HasNullOut())
|
---|
931 | tlist.AddToList(&writemc);
|
---|
932 | tlist.AddToList(&contmc);
|
---|
933 | }
|
---|
934 |
|
---|
935 | //if (IsUseRootData())
|
---|
936 | // tlist2.AddToList(&pextr);
|
---|
937 | tlist.AddToList(&tlist2, fSequence.IsMonteCarlo() ? "Events" : "All");
|
---|
938 |
|
---|
939 | //if (fSequence.IsMonteCarlo())
|
---|
940 | // tlist.AddToList(&pcalc, "Drive");
|
---|
941 |
|
---|
942 | if (!fIsMovieMode && !HasNullOut())
|
---|
943 | tlist.AddToList(&write);
|
---|
944 |
|
---|
945 | // Create and setup the eventloop
|
---|
946 | MEvtLoop evtloop(fName);
|
---|
947 | evtloop.SetParList(&plist);
|
---|
948 | evtloop.SetDisplay(fDisplay);
|
---|
949 | evtloop.SetLogStream(fLog);
|
---|
950 | if (!SetupEnv(evtloop))
|
---|
951 | return kFALSE;
|
---|
952 |
|
---|
953 | // Execute first analysis
|
---|
954 | const Bool_t rc = evtloop.Eventloop(fMaxEvents);
|
---|
955 |
|
---|
956 | // make sure owned object are deleted
|
---|
957 | if (extractor1 && extractor1!=fExtractor)
|
---|
958 | delete extractor1;
|
---|
959 | if (extractor2)
|
---|
960 | delete extractor2;
|
---|
961 | if (extractor3)
|
---|
962 | delete extractor3;
|
---|
963 |
|
---|
964 | // return if job failed
|
---|
965 | if (!rc)
|
---|
966 | {
|
---|
967 | *fLog << err << GetDescriptor() << ": Failed." << endl;
|
---|
968 | return kFALSE;
|
---|
969 | }
|
---|
970 |
|
---|
971 | // if everything went ok write and display result
|
---|
972 | DisplayResult(plist);
|
---|
973 |
|
---|
974 | /*
|
---|
975 | if (fIsPixelCheck)
|
---|
976 | {
|
---|
977 | if (fIsPulsePosCheck)
|
---|
978 | hpulcam[fCheckedPixId].DrawClone("");
|
---|
979 |
|
---|
980 | //if (fIsHiLoCalibration)
|
---|
981 | // hilocam[fCheckedPixId].DrawClone("");
|
---|
982 | }
|
---|
983 | interlacedcont.Add(&pulcam);
|
---|
984 | */
|
---|
985 |
|
---|
986 | //if (fIsHiLoCalibration)
|
---|
987 | // interlacedcont.Add(&hilcam);
|
---|
988 |
|
---|
989 | //if (fIsPulsePosCheck)
|
---|
990 | // interlacedcont.Add(plist.FindObject("MHCalibrationPulseTimeCam"));
|
---|
991 |
|
---|
992 | //if (fIsHiLoCalibration)
|
---|
993 | // interlacedcont.Add(plist.FindObject("MHCalibrationHiLoCam"));
|
---|
994 |
|
---|
995 | if (!WriteResult())
|
---|
996 | return kFALSE;
|
---|
997 |
|
---|
998 | // return if job went ok
|
---|
999 | *fLog << all << GetDescriptor() << ": Done." << endl;
|
---|
1000 | *fLog << endl << endl;
|
---|
1001 |
|
---|
1002 | return kTRUE;
|
---|
1003 | }
|
---|
1004 |
|
---|
1005 |
|
---|
1006 | void MJCalibrateSignal::DisplayResult(MParList &plist)
|
---|
1007 | {
|
---|
1008 | /*
|
---|
1009 | if (!fDisplay || !fIsHiLoCalibration)
|
---|
1010 | return;
|
---|
1011 |
|
---|
1012 | MCalibrationHiLoCam *hcam = (MCalibrationHiLoCam*)plist.FindObject("MCalibrationHiLoCam");
|
---|
1013 | MGeomCam *geom = (MGeomCam*)plist.FindObject("MGeomCam");
|
---|
1014 | if (!hcam || !geom)
|
---|
1015 | return;
|
---|
1016 |
|
---|
1017 | // Create histograms to display
|
---|
1018 | MHCamera disp1(*geom, "HiLoConv", "Ratio Amplification HiGain vs. LoGain (Charges)");
|
---|
1019 | MHCamera disp2(*geom, "HiLoDiff", "Arrival Time Diff. HiGain vs. LoGain (Times)");
|
---|
1020 |
|
---|
1021 | disp1.SetCamContent(*hcam, 0);
|
---|
1022 | disp1.SetCamError( *hcam, 1);
|
---|
1023 | disp2.SetCamContent(*hcam, 5);
|
---|
1024 | disp2.SetCamError( *hcam, 6);
|
---|
1025 |
|
---|
1026 | disp1.SetYTitle("R [1]");
|
---|
1027 | disp2.SetYTitle("\\Delta T [FADC sl.]");
|
---|
1028 |
|
---|
1029 | TCanvas &c1 = fDisplay->AddTab("HiLoConv");
|
---|
1030 | c1.Divide(2,3);
|
---|
1031 |
|
---|
1032 | disp1.CamDraw(c1, 1, 2, 1);
|
---|
1033 | disp2.CamDraw(c1, 2, 2, 1);
|
---|
1034 | */
|
---|
1035 | }
|
---|
1036 |
|
---|