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