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

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