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

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