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

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