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

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