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

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