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

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