source: trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc@ 5856

Last change on this file since 5856 was 5854, checked in by gaug, 20 years ago
*** empty log message ***
File size: 24.3 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): Javier Lopez 12/2003 <mailto:jlopez@ifae.es>
19! Author(s): Javier Rico 01/2004 <mailto:jrico@ifae.es>
20! Author(s): Wolfgang Wittek 02/2004 <mailto:wittek@mppmu.mpg.de>
21! Author(s): Markus Gaug 04/2004 <mailto:markus@ifae.es>
22! Author(s): Hendrik Bartko 08/2004 <mailto:hbartko@mppmu.mpg.de>
23! Author(s): Thomas Bretz 08/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
24!
25! Copyright: MAGIC Software Development, 2000-2004
26!
27!
28\* ======================================================================== */
29
30///////////////////////////////////////////////////////////////////////////////////
31//
32// MCalibrateData
33//
34// This task takes the integrated charge from MExtractedSignal and applies
35// the calibration constants from MCalibrationCam to convert the summed FADC
36// slices into photons. The number of photons obtained is stored in MCerPhotEvt.
37// Optionally, the calibration of pedestals from an MPedestalCam container into
38// an MPedPhotCam container can be chosen with the member functions
39// SetPedestalType(). Default is 'kRun', i.e. calibration of pedestals from a
40// dedicated pedestal run.
41// In case, the chosen pedestal type is kRun or kEvent, in ReInit() the MPedPhotCam
42// container is filled using the information from MPedestalCam, MExtractedSignalCam,
43// MCalibrationChargeCam and MCalibrationQECam
44//
45// Selection of different calibration methods is allowed through the
46// SetCalibrationMode() member function (default: kFfactor)
47//
48// The calibration modes which exclude non-valid pixels are the following:
49//
50// kFfactor: calibrates using the F-Factor method
51// kBlindpixel: calibrates using the BlindPixel method
52// kBlindpixel: calibrates using the BlindPixel method
53// kFlatCharge: perform a charge flat-flatfielding. Outer pixels are area-corrected.
54// kDummy: calibrates with fixed conversion factors of 1 and errors of 0.
55//
56// The calibration modes which include all pixels regardless of their validity is:
57//
58// kNone: calibrates with fixed conversion factors of 1 and errors of 0.
59//
60// Use the kDummy and kNone methods ONLY FOR DEBUGGING!
61//
62//
63// This class can calibrate data and/or pedestals. To switch off calibration of data
64// set the Calibration Mode to kSkip. To switch on pedestal calibration call either
65// SetPedestalFlag(MCalibrateData::kRun) (calibration is done once in ReInit)
66// SetPedestalFlag(MCalibrateData::kEvent) (calibration is done for each event)
67//
68// By calling AddPedestal() you can control the name of the
69// MPedestalCam and/or MPedPhotCam container which is used.
70//
71// Assume you want to calibrate "MPedestalCam" once and "MPedestalFromLoGain" [MPedestalCam]
72// event-by-event, so:
73// MCalibrateData cal1;
74// cal1.SetCalibrationMode(MCalibrateData::kSkip);
75// cal1.SetPedestalFlag(MCalibrateData::kRun);
76// MCalibrateData cal2;
77// cal2.SetCalibrationMode(MCalibrateData::kSkip);
78// cal2.AddPedestal("FromLoGain");
79// cal2.SetPedestalFlag(MCalibrateData::kEvent);
80//
81//
82// Input Containers:
83// [MPedestalCam]
84// [MExtractedSignalCam]
85// [MCalibrationChargeCam]
86// [MCalibrationQECam]
87// MBadPixelsCam
88//
89// Output Containers:
90// [MPedPhotCam]
91// [MCerPhotEvt]
92//
93// See also: MJCalibration, MJPedestal, MJExtractSignal, MJExtractCalibTest
94//
95//////////////////////////////////////////////////////////////////////////////
96#include "MCalibrateData.h"
97
98#include <fstream>
99
100#include <TEnv.h>
101
102#include "MLog.h"
103#include "MLogManip.h"
104
105#include "MParList.h"
106#include "MH.h"
107
108#include "MGeomCam.h"
109
110#include "MPedestalCam.h"
111#include "MPedestalPix.h"
112
113#include "MCalibrationChargeCam.h"
114#include "MCalibrationChargePix.h"
115
116#include "MCalibrationQECam.h"
117#include "MCalibrationQEPix.h"
118
119#include "MExtractedSignalCam.h"
120#include "MExtractedSignalPix.h"
121
122#include "MPedPhotCam.h"
123#include "MPedPhotPix.h"
124
125#include "MBadPixelsCam.h"
126#include "MBadPixelsPix.h"
127
128#include "MCerPhotEvt.h"
129
130ClassImp(MCalibrateData);
131
132using namespace std;
133
134// --------------------------------------------------------------------------
135//
136// Default constructor.
137//
138// Sets all pointers to NULL
139//
140// Initializes:
141// - fCalibrationMode to kDefault
142// - fPedestalFlag to kNo
143//
144MCalibrateData::MCalibrateData(CalibrationMode_t calmode,const char *name, const char *title)
145 : fGeomCam(NULL), fBadPixels(NULL), fCalibrations(NULL),
146 fQEs(NULL), fSignals(NULL), fCerPhotEvt(NULL),
147 fPedestalFlag(kNo), fSignalType(kPhot), fRenormFactor(1.)
148{
149
150 fName = name ? name : "MCalibrateData";
151 fTitle = title ? title : "Task to calculate the number of photons in one event";
152
153 SetCalibrationMode(calmode);
154
155 fNamesPedestal.SetOwner();
156}
157
158void MCalibrateData::AddPedestal(const char *name)
159{
160 TString ped(name);
161 TString pho(name);
162 ped.Prepend("MPedestal");
163 pho.Prepend("MPedPhot");
164
165 fNamesPedestal.Add(new TNamed(ped, pho));
166}
167
168void MCalibrateData::AddPedestal(const char *pedestal, const char *pedphot)
169{
170 fNamesPedestal.Add(new TNamed(pedestal, pedphot));
171}
172
173// --------------------------------------------------------------------------
174//
175// The PreProcess searches for the following input containers:
176//
177// - MGeomCam
178// - MPedestalCam
179// - MCalibrationChargeCam
180// - MCalibrationQECam
181// - MExtractedSignalCam
182// - MBadPixelsCam
183//
184// The following output containers are also searched and created if
185// they were not found:
186//
187// - MPedPhotCam
188// - MCerPhotEvt
189//
190Int_t MCalibrateData::PreProcess(MParList *pList)
191{
192 // input containers
193
194 fBadPixels = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
195 if (!fBadPixels)
196 {
197 *fLog << err << AddSerialNumber("MBadPixelsCam") << " not found ... aborting" << endl;
198 return kFALSE;
199 }
200
201 fSignals = 0;
202 fCerPhotEvt = 0;
203 if (fCalibrationMode>kSkip)
204 {
205 fSignals = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
206 if (!fSignals)
207 {
208 *fLog << err << AddSerialNumber("MExtractedSignalCam") << " not found ... aborting" << endl;
209 return kFALSE;
210 }
211
212 fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj(AddSerialNumber("MCerPhotEvt"));
213 if (!fCerPhotEvt)
214 return kFALSE;
215 }
216
217 fCalibrations = 0;
218 fQEs = 0;
219 if (fCalibrationMode>kNone)
220 {
221 fCalibrations = (MCalibrationChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
222 if (!fCalibrations)
223 {
224 *fLog << err << AddSerialNumber("MCalibrationChargeCam") << " not found ... aborting." << endl;
225 return kFALSE;
226 }
227
228 fQEs = (MCalibrationQECam*)pList->FindObject(AddSerialNumber("MCalibrationQECam"));
229 if (!fQEs)
230 {
231 *fLog << err << AddSerialNumber("MCalibrationQECam") << " not found ... aborting." << endl;
232 return kFALSE;
233 }
234 }
235
236 if (fNamesPedestal.GetSize()>0 && fPedestalFlag==kNo)
237 {
238 *fLog << warn << "Pedestal list contains entries, but mode is set to kNo... setting to kEvent." << endl;
239 fPedestalFlag = kEvent;
240 }
241
242 if (fPedestalFlag)
243 {
244 if (fNamesPedestal.GetSize()==0)
245 {
246 *fLog << inf << "No container names specified... using default: MPedestalCam and MPedPhotCam." << endl;
247 AddPedestal();
248 }
249
250 fPedestalCams.Clear();
251 fPedPhotCams.Clear();
252
253 TIter Next(&fNamesPedestal);
254 TObject *o=0;
255 while ((o=Next()))
256 {
257 TObject *pedcam = pList->FindObject(AddSerialNumber(o->GetName()), "MPedestalCam");
258 if (!pedcam)
259 {
260 *fLog << err << AddSerialNumber(o->GetName()) << " [MPedestalCam] not found ... aborting" << endl;
261 return kFALSE;
262 }
263 TObject *pedphot = pList->FindCreateObj("MPedPhotCam", AddSerialNumber(o->GetTitle()));
264 if (!pedphot)
265 return kFALSE;
266
267 fPedestalCams.Add(pedcam);
268 fPedPhotCams.Add(pedphot);
269 }
270 }
271
272 switch (fSignalType)
273 {
274 case kPhe:
275 fRenormFactor = MCalibrationQEPix::gkDefaultAverageQE;
276 break;
277 case kPhot:
278 fRenormFactor = 1.;
279 break;
280 }
281
282 fCalibConsts.Reset();
283 fCalibFFactors.Reset();
284
285 return kTRUE;
286}
287
288// --------------------------------------------------------------------------
289//
290// The ReInit searches for the following input containers:
291//
292// - MGeomCam
293//
294// Check for validity of the selected calibration method, switch to a
295// different one in case of need
296//
297// Fill the MPedPhotCam container using the information from MPedestalCam,
298// MExtractedSignalCam and MCalibrationCam
299//
300Bool_t MCalibrateData::ReInit(MParList *pList)
301{
302 fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
303 if (!fGeomCam)
304 {
305 *fLog << err << "No MGeomCam found... aborting." << endl;
306 return kFALSE;
307 }
308
309 // Sizes might have changed
310 if (fPedestalFlag)
311 {
312 TIter Next(&fPedestalCams);
313 MPedestalCam *cam=0;
314 while ((cam=(MPedestalCam*)Next()))
315 if ((Int_t)cam->GetSize() != fSignals->GetSize())
316 {
317 *fLog << err << "Size mismatch of " << cam->GetDescriptor() << " and MCalibrationCam... abort." << endl;
318 return kFALSE;
319 }
320 }
321
322 if(fCalibrationMode == kBlindPixel && !fQEs->IsBlindPixelMethodValid())
323 {
324 *fLog << warn << "Blind pixel calibration method not valid, switching to F-factor method" << endl;
325 fCalibrationMode = kFfactor;
326 }
327
328 if(fCalibrationMode == kPinDiode && !fQEs->IsPINDiodeMethodValid())
329 {
330 *fLog << warn << "PIN diode calibration method not valid, switching to F-factor method" << endl;
331 fCalibrationMode = kFfactor;
332 }
333
334 if(fCalibrationMode == kCombined && !fQEs->IsCombinedMethodValid())
335 {
336 *fLog << warn << "Combined calibration method not valid, switching to F-factor method" << endl;
337 fCalibrationMode = kFfactor;
338 }
339
340 //
341 // output information or warnings:
342 //
343 switch(fCalibrationMode)
344 {
345 case kBlindPixel:
346 break;
347 case kFfactor:
348 break;
349 case kPinDiode:
350 *fLog << err << "PIN Diode Calibration mode not yet available!" << endl;
351 return kFALSE;
352 break;
353 case kCombined:
354 *fLog << err << "Combined Calibration mode not yet available!" << endl;
355 return kFALSE;
356 break;
357 case kFlatCharge:
358 *fLog << warn << "WARNING - Flat-fielding charges - only for muon calibration!" << endl;
359 break;
360 case kDummy:
361 *fLog << warn << "WARNING - Dummy calibration, no calibration applied!" << endl;
362 break;
363 case kNone:
364 *fLog << warn << "WARNING - No calibration applied!" << endl;
365 break;
366 default:
367 *fLog << warn << "WARNING - Calibration mode value (" << fCalibrationMode << ") not known" << endl;
368 return kFALSE;
369 }
370
371 //
372 // output information or warnings:
373 //
374 switch(fSignalType)
375 {
376 case kPhe:
377 *fLog << warn << "WARNING - Renormalization to photo-electrons applied!" << endl;
378 break;
379 case kPhot:
380 break;
381 }
382
383 const Int_t npixels = fGeomCam->GetNumPixels();
384
385 if (fCalibrationMode > kNone)
386 {
387
388 if (fCalibrations->GetSize() != npixels)
389 {
390 *fLog << err << GetDescriptor()
391 << ": Size mismatch between MGeomCam and MCalibrationChargeCam ... abort!" << endl;
392 return kFALSE;
393 }
394
395 if (fBadPixels->GetSize() != npixels)
396 {
397 *fLog << err << GetDescriptor()
398 << ": Size mismatch between MGeomCam and MBadPixelsCam ... abort!" << endl;
399 return kFALSE;
400 }
401
402 if (fBadPixels->GetSize() != npixels)
403 {
404 *fLog << err << GetDescriptor()
405 << ": Size mismatch between MGeomCam and MBadPixelsCam ... abort!" << endl;
406 return kFALSE;
407 }
408 }
409
410 fCalibConsts .Set(npixels);
411 fCalibFFactors.Set(npixels);
412 fHiLoConv .Set(npixels);
413 fHiLoConvErr .Set(npixels);
414
415 if (!UpdateConversionFactors())
416 return kFALSE;
417
418 if (TestPedestalFlag(kRun))
419 Calibrate(kFALSE, kTRUE);
420
421 return kTRUE;
422}
423
424// --------------------------------------------------------------------------
425//
426// Update the conversion factors and F-Factors from MCalibrationCams into
427// the arrays. Later, the here pre-calcualted conversion factors get simply
428// copied from memory.
429//
430// This function can be called from outside in case that the MCalibrationCams
431// have been updated...
432//
433Bool_t MCalibrateData::UpdateConversionFactors()
434{
435 //
436 // For the moment, we use only a dummy zenith for the calibration:
437 //
438 const Float_t zenith = -1.;
439
440 UInt_t skip = 0;
441
442 for (UInt_t pixidx=0; pixidx<fGeomCam->GetNumPixels(); pixidx++)
443 {
444
445 Float_t hiloconv = 1.;
446 Float_t hiloconverr = 0.;
447 Float_t calibConv = 1.;
448 Float_t calibConvVar = 0.;
449 Float_t calibFFactor = 0.;
450
451 Float_t calibQE = 1.;
452 Float_t calibQEVar = 0.;
453
454 if(fCalibrationMode!=kNone)
455 {
456 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCalibrations)[pixidx];
457
458 hiloconv = pix.GetConversionHiLo ();
459 hiloconverr= pix.GetConversionHiLoErr();
460
461 if ((*fBadPixels)[pixidx].IsUnsuitable())
462 {
463 skip++;
464 continue;
465 }
466
467 calibConv = pix.GetMeanConvFADC2Phe();
468 calibConvVar = pix.GetMeanConvFADC2PheVar();
469 calibFFactor = pix.GetMeanFFactorFADC2Phot();
470
471 MCalibrationQEPix &qe = (MCalibrationQEPix&) (*fQEs)[pixidx];
472
473 switch(fCalibrationMode)
474 {
475 case kFlatCharge:
476 {
477 MCalibrationChargePix &avpix = (MCalibrationChargePix&)fCalibrations->GetAverageArea(0);
478 calibConv = avpix.GetMean() / (pix.GetMean() * fGeomCam->GetPixRatio(pixidx));
479 calibConvVar = (avpix.GetMeanRelVar() + pix.GetMeanRelVar()) * calibConv * calibConv;
480 if (pix.IsFFactorMethodValid())
481 {
482 const Float_t convmin1 = qe.GetQECascadesFFactor(zenith)/pix.GetMeanConvFADC2Phe();
483 if (convmin1 > 0)
484 calibFFactor *= TMath::Sqrt(convmin1);
485 else
486 calibFFactor = -1.;
487 }
488 break;
489 }
490 case kBlindPixel:
491 if (!qe.IsBlindPixelMethodValid())
492 {
493 skip++;
494 continue;
495 }
496 calibQE = qe.GetQECascadesBlindPixel ( zenith );
497 calibQEVar = qe.GetQECascadesBlindPixelVar( zenith );
498 break;
499
500 case kPinDiode:
501 if (!qe.IsPINDiodeMethodValid())
502 {
503 skip++;
504 continue;
505 }
506 calibQE = qe.GetQECascadesPINDiode ( zenith );
507 calibQEVar = qe.GetQECascadesPINDiodeVar( zenith );
508 break;
509
510 case kFfactor:
511 if (!pix.IsFFactorMethodValid())
512 {
513 skip++;
514 continue;
515 }
516 calibQE = qe.GetQECascadesFFactor ( zenith );
517 calibQEVar = qe.GetQECascadesFFactorVar( zenith );
518 break;
519
520 case kCombined:
521 if (!qe.IsCombinedMethodValid())
522 {
523 skip++;
524 continue;
525 }
526 calibQE = qe.GetQECascadesCombined ( zenith );
527 calibQEVar = qe.GetQECascadesCombinedVar( zenith );
528 break;
529
530 case kDummy:
531 hiloconv = 1.;
532 hiloconverr = 0.;
533 break;
534 } /* switch calibration mode */
535 } /* if(fCalibrationMode!=kNone) */
536 else
537 {
538 calibConv = 1./fGeomCam->GetPixRatio(pixidx);
539 }
540
541 calibConv /= calibQE;
542
543 if (calibConv != 0. && calibQE != 0.)
544 {
545 // Now doing:
546 calibConvVar = calibConvVar/(calibConv*calibConv) + calibQEVar/(calibQE*calibQE);
547 calibConvVar *= (calibConv*calibConv);
548 // The above two lines had been commented by TB and replaced by the following line
549 // (without notice to me!) but it is simply wrong!
550 // calibConvVar += calibQEVar*(calibConv*calibConv)/(calibQE*calibQE);
551 }
552
553 calibConv *= fRenormFactor;
554
555 fHiLoConv [pixidx] = hiloconv;
556 fHiLoConvErr [pixidx] = hiloconverr;
557 fCalibConsts [pixidx] = calibConv;
558 fCalibFFactors[pixidx] = calibFFactor;
559
560 } /* for (Int_t pixidx=0; pixidx<fGeomCam->GetNumPixels(); pixidx++) */
561
562 if (skip>fGeomCam->GetNumPixels()*0.9)
563 {
564 *fLog << warn << GetDescriptor()
565 << ": WARNING - GetConversionFactor has skipped more than 90% of the pixels... abort." << endl;
566 return kFALSE;
567 }
568
569 return kTRUE;
570}
571
572
573// --------------------------------------------------------------------------
574//
575// Apply the conversion factors and F-Factors from the arrays to the data.
576//
577// The flags 'data' and 'pedestal' decide whether the signal and/or the pedetals
578// shall be calibrated, respectively.
579//
580Int_t MCalibrateData::Calibrate(Bool_t data, Bool_t pedestal) const
581{
582 if (!data && !pedestal)
583 return kTRUE;
584
585 const UInt_t npix = fSignals->GetSize();
586 const Float_t slices = fSignals->GetNumUsedHiGainFADCSlices();
587 const Float_t sqrtslices = TMath::Sqrt(slices);
588
589 for (UInt_t pixidx=0; pixidx<npix; pixidx++)
590 {
591
592 if (data)
593 {
594 const MExtractedSignalPix &sig = (*fSignals)[pixidx];
595
596 Float_t signal = 0;
597 Float_t signalErr = 0.;
598
599 if (sig.IsLoGainUsed())
600 {
601 signal = sig.GetExtractedSignalLoGain()*fHiLoConv [pixidx];
602 signalErr = sig.GetExtractedSignalLoGain()*fHiLoConvErr[pixidx];
603 }
604 else
605 {
606 if (sig.GetExtractedSignalHiGain() <= 9999.)
607 signal = sig.GetExtractedSignalHiGain();
608 }
609
610 const Float_t nphot = signal * fCalibConsts [pixidx];
611 const Float_t nphotErr = TMath::Sqrt(TMath::Abs(nphot)) * fCalibFFactors[pixidx];
612
613 MCerPhotPix *cpix = fCerPhotEvt->AddPixel(pixidx, nphot, nphotErr);
614
615 if (sig.GetNumHiGainSaturated() > 0)
616 cpix->SetPixelHGSaturated();
617
618 if (sig.GetNumLoGainSaturated() > 0)
619 cpix->SetPixelSaturated();
620 } /* if (data) */
621
622
623 if (pedestal)
624 {
625 TIter NextPed(&fPedestalCams);
626 TIter NextPhot(&fPedPhotCams);
627
628 MPedestalCam *pedestal = 0;
629 MPedPhotCam *pedphot = 0;
630
631 const Float_t pedmeancalib = slices *fCalibConsts[pixidx];
632 const Float_t pedrmscalib = sqrtslices*fCalibConsts[pixidx];
633
634 while ((pedestal=(MPedestalCam*)NextPed()) &&
635 (pedphot =(MPedPhotCam*)NextPhot()))
636 {
637 // pedestals/(used FADC slices) in [number of photons]
638 const Float_t mean = (*pedestal)[pixidx].GetPedestal() *pedmeancalib;
639 const Float_t rms = (*pedestal)[pixidx].GetPedestalRms()*pedrmscalib;
640
641 (*pedphot)[pixidx].Set(mean, rms);
642 pedphot->SetReadyToSave();
643 }
644 } /* if (pedestal) */
645 }
646
647 if (data)
648 {
649 fCerPhotEvt->FixSize();
650 fCerPhotEvt->SetReadyToSave();
651 }
652 return kTRUE;
653}
654
655// --------------------------------------------------------------------------
656//
657// Apply the calibration factors to the extracted signal according to the
658// selected calibration method
659//
660Int_t MCalibrateData::Process()
661{
662 return Calibrate(fCalibrationMode!=kSkip, TestPedestalFlag(kEvent));
663}
664
665// --------------------------------------------------------------------------
666//
667// Implementation of SavePrimitive. Used to write the call to a constructor
668// to a macro. In the original root implementation it is used to write
669// gui elements to a macro-file.
670//
671void MCalibrateData::StreamPrimitive(ofstream &out) const
672{
673 out << " " << ClassName() << " " << GetUniqueName() << "(\"";
674 out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
675
676 if (TestPedestalFlag(kEvent))
677 out << " " << GetUniqueName() << ".EnablePedestalType(MCalibrateData::kEvent)" << endl;
678 if (TestPedestalFlag(kRun))
679 out << " " << GetUniqueName() << ".EnablePedestalType(MCalibrateData::kRun)" << endl;
680
681 if (fCalibrationMode != kDefault)
682 {
683 out << " " << GetUniqueName() << ".SetCalibrationMode(MCalibrateData::";
684 switch (fCalibrationMode)
685 {
686 case kSkip: out << "kSkip"; break;
687 case kNone: out << "kNone"; break;
688 case kFlatCharge: out << "kFlatCharge"; break;
689 case kBlindPixel: out << "kBlindPixel"; break;
690 case kFfactor: out << "kFfactor"; break;
691 case kPinDiode: out << "kPinDiode"; break;
692 case kCombined: out << "kCombined"; break;
693 case kDummy: out << "kDummy"; break;
694 default: out << (int)fCalibrationMode; break;
695 }
696 out << ")" << endl;
697 }
698
699 TIter Next(&fNamesPedestal);
700 TObject *o=0;
701 while ((o=Next()))
702 {
703 out << " " << GetUniqueName() << ".AddPedestal(\"";
704 out << o->GetName() << "\", \"" << o->GetTitle() << "\");" << endl;
705 }
706}
707
708// --------------------------------------------------------------------------
709//
710// Read the setup from a TEnv, eg:
711// MJPedestal.MCalibrateDate.PedestalFlag: no,run,event
712// MJPedestal.MCalibrateDate.CalibrationMode: skip,none,flatcharge,blindpixel,ffactor,pindiode,combined,dummy,default
713//
714Int_t MCalibrateData::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
715{
716 Bool_t rc = kFALSE;
717 if (IsEnvDefined(env, prefix, "PedestalFlag", print))
718 {
719 rc = kTRUE;
720 TString s = GetEnvValue(env, prefix, "PedestalFlag", "");
721 s.ToLower();
722 if (s.BeginsWith("no"))
723 SetPedestalFlag(kNo);
724 if (s.BeginsWith("run"))
725 SetPedestalFlag(kRun);
726 if (s.BeginsWith("event"))
727 SetPedestalFlag(kEvent);
728 }
729
730 if (IsEnvDefined(env, prefix, "CalibrationMode", print))
731 {
732 rc = kTRUE;
733 TString s = GetEnvValue(env, prefix, "CalibrationMode", "");
734 s.ToLower();
735 if (s.BeginsWith("skip"))
736 SetCalibrationMode(kSkip);
737 if (s.BeginsWith("none"))
738 SetCalibrationMode(kNone);
739 if (s.BeginsWith("flatcharge"))
740 SetCalibrationMode(kFlatCharge);
741 if (s.BeginsWith("blindpixel"))
742 SetCalibrationMode(kBlindPixel);
743 if (s.BeginsWith("ffactor"))
744 SetCalibrationMode(kFfactor);
745 if (s.BeginsWith("pindiode"))
746 SetCalibrationMode(kPinDiode);
747 if (s.BeginsWith("combined"))
748 SetCalibrationMode(kCombined);
749 if (s.BeginsWith("dummy"))
750 SetCalibrationMode(kDummy);
751 if (s.BeginsWith("default"))
752 SetCalibrationMode();
753 }
754
755 return rc;
756}
Note: See TracBrowser for help on using the repository browser.