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

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