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

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