source: trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc@ 6106

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