source: trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc@ 3065

Last change on this file since 3065 was 3065, checked in by gaug, 21 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): Markus Gaug 09/2003 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2001
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MCalibrationCalc
28//
29// Task to calculate the calibration conversion factors from the FADC
30// time slices. The integrated time slices have to be delivered by an
31// MExtractedSignalCam. The pedestals by an MPedestalCam.
32//
33// The output container MCalibrationCam holds one entry of type MCalibrationPix
34// for every pixel. It is filled in the following way:
35//
36// ProProcess: Search for MPedestalCam, MExtractedSignalCam
37// Initialize MCalibrationCam
38// Initialize pulser light wavelength
39//
40// ReInit: MCalibrationCam::InitSize(NumPixels) is called which allocates
41// memory in a TClonesArray of type MCalibrationPix
42// Initialize number of used FADC slices
43// Optionally exclude pixels from calibration
44//
45// Process: Optionally, a cut on cosmics can be performed
46//
47// Every MCalibrationPix holds a histogram class,
48// MHCalibrationPixel which itself hold histograms of type:
49// HCharge(npix) (distribution of summed FADC time slice
50// entries)
51// HTime(npix) (distribution of position of maximum)
52// HChargevsN(npix) (distribution of charges vs. event number.
53//
54// PostProcess: All histograms HCharge(npix) are fitted to a Gaussian
55// All histograms HTime(npix) are fitted to a Gaussian
56// The histogram HBlindPixelCharge (blind pixel) is fitted to
57// a single PhE fit
58//
59// The histograms of the PIN Diode are fitted to Gaussians
60//
61// Fits can be excluded via the commands:
62// MalibrationCam::SkipBlindPixelFits() (skip all blind
63// pixel fits)
64// MalibrationCam::SkipPinDiodeFits() (skip all PIN Diode
65// fits)
66//
67// Hi-Gain vs. Lo-Gain Calibration (very memory-intensive)
68// can be skipped with the command:
69// MalibrationCam::SkipHiLoGainCalibration()
70//
71// Input Containers:
72// MRawEvtData
73// MPedestalCam
74// MExtractedSignalCam
75//
76// Output Containers:
77// MCalibrationCam
78//
79//////////////////////////////////////////////////////////////////////////////
80#include "MCalibrationCalc.h"
81
82// FXIME: Usage of fstream is a preliminary workaround!
83#include <fstream>
84
85// FXIME: This has to be removed!!!! (YES, WHEN WE HAVE ACCESS TO THE DATABASE!!!!!)
86#include "MCalibrationConfig.h"
87
88#include <TSystem.h>
89
90#include "MLog.h"
91#include "MLogManip.h"
92
93#include "MParList.h"
94
95#include "MGeomCam.h"
96#include "MRawRunHeader.h"
97#include "MRawEvtPixelIter.h"
98
99#include "MPedestalCam.h"
100#include "MPedestalPix.h"
101
102#include "MCalibrationCam.h"
103#include "MCalibrationPix.h"
104
105#include "MExtractedSignalCam.h"
106#include "MExtractedSignalPix.h"
107
108#include "MCalibrationBlindPix.h"
109#include "MCalibrationPINDiode.h"
110
111ClassImp(MCalibrationCalc);
112
113using namespace std;
114
115const UInt_t MCalibrationCalc::fBlindPixelId = 559;
116const UInt_t MCalibrationCalc::fPINDiodeId = 9999;
117const Byte_t MCalibrationCalc::fgSaturationLimit = 254;
118const Byte_t MCalibrationCalc::fgBlindPixelFirst = 3;
119const Byte_t MCalibrationCalc::fgBlindPixelLast = 14;
120
121// --------------------------------------------------------------------------
122//
123// Default constructor.
124//
125MCalibrationCalc::MCalibrationCalc(const char *name, const char *title)
126 : fPedestals(NULL), fCalibrations(NULL), fSignals(NULL),
127 fRawEvt(NULL), fRunHeader(NULL), fEvtTime(NULL)
128{
129
130 fName = name ? name : "MCalibrationCalc";
131 fTitle = title ? title : "Task to calculate the calibration constants and MCalibrationCam ";
132
133 AddToBranchList("MRawEvtData.fHiGainPixId");
134 AddToBranchList("MRawEvtData.fLoGainPixId");
135 AddToBranchList("MRawEvtData.fHiGainFadcSamples");
136 AddToBranchList("MRawEvtData.fLoGainFadcSamples");
137
138 Clear();
139}
140
141void MCalibrationCalc::Clear(const Option_t *o)
142{
143
144 SETBIT(fFlags, kUseBlindPixelFit);
145 SETBIT(fFlags, kUseCosmicsRejection);
146 SETBIT(fFlags, kUseQualityChecks);
147 SETBIT(fFlags, kHiLoGainCalibration);
148
149 CLRBIT(fFlags, kHiGainOverFlow);
150 CLRBIT(fFlags, kLoGainOverFlow);
151 // As long as we don't have the PIN Diode:
152 CLRBIT(fFlags, kUsePinDiodeFit);
153
154
155
156 fEvents = 0;
157 fCosmics = 0;
158
159 fNumHiGainSamples = 0;
160 fNumLoGainSamples = 0;
161 fConversionHiLo = 0;
162 fNumExcludedPixels = 0;
163
164 fColor = kECT1;
165}
166
167
168MCalibrationBlindPix *MCalibrationCalc::GetBlindPixel() const
169{
170 return fCalibrations->GetBlindPixel();
171}
172
173MCalibrationPINDiode *MCalibrationCalc::GetPINDiode() const
174{
175 return fCalibrations->GetPINDiode();
176}
177
178// --------------------------------------------------------------------------
179//
180// The PreProcess searches for the following input containers:
181// - MRawEvtData
182// - MPedestalCam
183//
184// The following output containers are also searched and created if
185// they were not found:
186//
187// - MHCalibrationBlindPixel
188// - MCalibrationCam
189//
190// The following output containers are only searched, but not created
191//
192// - MTime
193//
194Int_t MCalibrationCalc::PreProcess(MParList *pList)
195{
196
197 fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
198 if (!fRawEvt)
199 {
200 *fLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
201 return kFALSE;
202 }
203
204 const MRawRunHeader *runheader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
205 if (!runheader)
206 *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
207 else
208 if (runheader->GetRunType() == kRTMonteCarlo)
209 {
210 return kTRUE;
211 }
212
213 fCalibrations = (MCalibrationCam*)pList->FindCreateObj("MCalibrationCam");
214 if (!fCalibrations)
215 {
216 *fLog << err << dbginf << "MCalibrationCam could not be created ... aborting." << endl;
217 return kFALSE;
218 }
219
220 fEvtTime = (MTime*)pList->FindObject("MTime");
221
222 switch (fColor)
223 {
224 case kEBlue:
225 fCalibrations->SetColor(MCalibrationCam::kECBlue);
226 break;
227 case kEGreen:
228 fCalibrations->SetColor(MCalibrationCam::kECGreen);
229 break;
230 case kEUV:
231 fCalibrations->SetColor(MCalibrationCam::kECUV);
232 break;
233 case kECT1:
234 fCalibrations->SetColor(MCalibrationCam::kECCT1);
235 break;
236 default:
237 fCalibrations->SetColor(MCalibrationCam::kECCT1);
238 }
239
240 fPedestals = (MPedestalCam*)pList->FindObject("MPedestalCam");
241 if (!fPedestals)
242 {
243 *fLog << err << dbginf << "Cannot find MPedestalCam ... aborting" << endl;
244 return kFALSE;
245 }
246
247
248 fSignals = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
249 if (!fSignals)
250 {
251 *fLog << err << dbginf << "Cannot find MExtractedSignalCam ... aborting" << endl;
252 return kFALSE;
253 }
254
255 return kTRUE;
256}
257
258
259// --------------------------------------------------------------------------
260//
261// The ReInit searches for the following input containers:
262// - MRawRunHeader
263//
264Bool_t MCalibrationCalc::ReInit(MParList *pList )
265{
266
267 fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
268 if (!fRunHeader)
269 {
270 *fLog << err << dbginf << ": MRawRunHeader not found... aborting." << endl;
271 return kFALSE;
272 }
273
274
275 MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam");
276 if (!cam)
277 {
278 *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
279 return kFALSE;
280 }
281
282
283 fCalibrations->SetGeomCam(cam);
284
285 fNumHiGainSamples = fSignals->GetNumUsedHiGainFADCSlices();
286 fNumLoGainSamples = fSignals->GetNumUsedLoGainFADCSlices();
287 fSqrtHiGainSamples = TMath::Sqrt((Float_t)fNumHiGainSamples);
288
289 UInt_t npixels = cam->GetNumPixels();
290
291 for (UInt_t i=0; i<npixels; i++)
292 {
293
294 MCalibrationPix &pix = (*fCalibrations)[i];
295 pix.DefinePixId(i);
296
297 pix.SetAbsTimeBordersHiGain(fSignals->GetFirstUsedSliceHiGain(),
298 fSignals->GetLastUsedSliceHiGain());
299 pix.SetAbsTimeBordersLoGain(fSignals->GetFirstUsedSliceLoGain(),
300 fSignals->GetLastUsedSliceLoGain());
301
302 if (!TESTBIT(fFlags,kUseQualityChecks))
303 pix.SetExcludeQualityCheck();
304
305 // Exclude the blind pixel and the PIN Diode from normal pixel calibration:
306 if (i == fBlindPixelId)
307 pix.SetExcluded();
308
309 if (i == fPINDiodeId)
310 pix.SetExcluded();
311
312 }
313
314 //
315 // Look for file to exclude pixels from analysis
316 //
317 if (!fExcludedPixelsFile.IsNull())
318 {
319
320 fExcludedPixelsFile = gSystem->ExpandPathName(fExcludedPixelsFile.Data());
321
322 //
323 // Initialize reading the file
324 //
325 ifstream in(fExcludedPixelsFile.Data(),ios::in);
326
327 if (in)
328 {
329 *fLog << inf << "Use excluded pixels from file: '" << fExcludedPixelsFile.Data() << "'" << endl;
330 //
331 // Read the file and count the number of entries
332 //
333 UInt_t pixel = 0;
334
335 while (++fNumExcludedPixels)
336 {
337
338 in >> pixel;
339
340 if (!in.good())
341 break;
342 //
343 // Check for out of range
344 //
345 if (pixel > npixels)
346 {
347 *fLog << warn << "WARNING: To be excluded pixel: " << pixel
348 << " is out of range " << endl;
349 continue;
350 }
351 //
352 // Exclude pixel
353 //
354 MCalibrationPix &pix = (*fCalibrations)[pixel];
355 pix.SetExcluded();
356
357 *fLog << GetDescriptor() << inf << ": Exclude Pixel: " << pixel << endl;
358
359 }
360
361 if (--fNumExcludedPixels == 0)
362 *fLog << warn << "WARNING: File '" << fExcludedPixelsFile.Data()
363 << "'" << " is empty " << endl;
364 else
365 fCalibrations->SetNumPixelsExcluded(fNumExcludedPixels);
366
367 }
368 else
369 *fLog << warn << dbginf << "Cannot open file '" << fExcludedPixelsFile.Data() << "'" << endl;
370 }
371
372 return kTRUE;
373}
374
375
376// --------------------------------------------------------------------------
377//
378// Calculate the integral of the FADC time slices and store them as a new
379// pixel in the MCerPhotEvt container.
380//
381Int_t MCalibrationCalc::Process()
382{
383
384 //
385 // Initialize pointers to blind pixel, PIN Diode and individual pixels
386 //
387 MCalibrationBlindPix &blindpixel = *(fCalibrations->GetBlindPixel());
388 MCalibrationPINDiode &pindiode = *(fCalibrations->GetPINDiode());
389
390 MRawEvtPixelIter pixel(fRawEvt);
391
392 //
393 // Perform cosmics cut
394 //
395 if (TESTBIT(fFlags,kUseCosmicsRejection))
396 {
397
398 Int_t cosmicpix = 0;
399
400 //
401 // Create a first loop to sort out the cosmics ...
402 //
403 // This is a very primitive check for the number of cosmicpixs
404 // The cut will be applied in the fit, but for the blind pixel,
405 // we need to remove this event
406 //
407 // FIXME: In the future need a much more sophisticated one!!!
408 //
409
410 while (pixel.Next())
411 {
412
413 const UInt_t pixid = pixel.GetPixelId();
414
415 MExtractedSignalPix &sig = (*fSignals)[pixid];
416 MPedestalPix &ped = (*fPedestals)[pixid];
417 Float_t pedrms = ped.GetPedestalRms()*fSqrtHiGainSamples;
418 Float_t sumhi = sig.GetExtractedSignalHiGain();
419
420 //
421 // We consider a pixel as presumably due to cosmics
422 // if its sum of FADC slices is lower than 3 pedestal RMS
423 //
424 if (sumhi < 3.*pedrms )
425 cosmicpix++;
426 }
427
428 //
429 // If the camera contains more than 230
430 // (this is the number of outer pixels plus about 50 inner ones)
431 // presumed pixels due to cosmics, then the event is discarted.
432 // This procedure is more or less equivalent to keeping only events
433 // with at least 350 pixels with high signals.
434 //
435 if (cosmicpix > 230.)
436 {
437 fCosmics++;
438 return kCONTINUE;
439 }
440
441 pixel.Reset();
442 }
443
444 fEvents++;
445
446 Float_t referencetime = 0.;
447
448 //
449 // Create a (second) loop to do fill the calibration histograms
450 // Search for: a signal in MExtractedSignalCam
451 // Fill histograms with:
452 // charge
453 // charge vs. event nr.
454 // relative arrival time w.r.t. pixel 1
455 //
456 while (pixel.Next())
457 {
458
459 const UInt_t pixid = pixel.GetPixelId();
460
461 MCalibrationPix &pix = (*fCalibrations)[pixid];
462
463 MExtractedSignalPix &sig = (*fSignals)[pixid];
464
465 const Float_t sumhi = sig.GetExtractedSignalHiGain();
466 const Float_t sumlo = sig.GetExtractedSignalLoGain();
467
468 Float_t abstime = 0.;
469 Float_t reltime = 0.;
470
471#if 0
472 if (TESTBIT(fFlags,kUseTimes))
473 {
474
475 //
476 // Have a look in MArrivalTime,
477 // otherwise search the position of maximum bin
478 // in MRawEvtData
479 //
480 if (fArrivalTime)
481 {
482 abstime = (*fArrivalTime)[pixid];
483 reltime = abstime - (*fArrivalTime)[1];
484 }
485
486 else
487 {
488 if (pixid == 1)
489 referencetime = (Float_t)pixel.GetIdxMaxHiGainSample();
490#endif
491 if (sig.IsLoGainUsed())
492 {
493 abstime = (Float_t)pixel.GetIdxMaxLoGainSample();
494 // reltime = abstime - referencetime;
495 }
496 else
497 {
498 abstime = (Float_t)pixel.GetIdxMaxHiGainSample();
499 // reltime = abstime - referencetime;
500 }
501 // }
502 // } /* if Use Times */
503
504 switch(pixid)
505 {
506
507 case fBlindPixelId:
508
509 if (TESTBIT(fFlags,kUseBlindPixelFit))
510 {
511
512 Float_t blindpixelsumhi = 0.;
513 Float_t blindpixelsumlo = 0.;
514 //
515 // We need a dedicated signal extractor for the blind pixel
516 //
517 MPedestalPix &ped = (*fPedestals)[pixid];
518 if (!CalcSignalBlindPixel(pixel.GetHiGainSamples(), blindpixelsumhi, ped.GetPedestal()))
519 return kFALSE;
520
521 CalcSignalBlindPixel(pixel.GetLoGainSamples(), blindpixelsumlo, ped.GetPedestal());
522
523 blindpixel.FillGraphs(blindpixelsumhi,blindpixelsumlo);
524
525 if (!blindpixel.FillCharge(blindpixelsumhi))
526 *fLog << warn <<
527 "Overflow or Underflow occurred filling Blind Pixel sum = " << blindpixelsumhi << endl;
528
529 } /* if use blind pixel */
530
531 break;
532
533 case fPINDiodeId:
534
535 if (TESTBIT(fFlags,kUsePinDiodeFit))
536 {
537
538 if (!pindiode.FillCharge(sumhi))
539 *fLog << warn
540 << "Overflow or Underflow occurred filling PINDiode: sum = "
541 << sumhi << endl;
542
543 if (!pindiode.FillAbsTime(abstime))
544 *fLog << warn
545 << "Overflow or Underflow occurred filling PINDiode abs. time = "
546 << abstime << endl;
547
548 if (!pindiode.FillGraphs(sumhi,sumlo))
549 *fLog << warn
550 << "Overflow or Underflow occurred filling PINDiode: eventnr = "
551 << fEvents << endl;
552
553 } /* if use PIN Diode */
554
555 break;
556
557 default:
558
559 if (pix.IsExcluded())
560 continue;
561
562 pix.FillGraphs(sumhi,sumlo);
563
564 if (sig.IsLoGainUsed())
565 {
566
567 if (!pix.FillChargeLoGain(sumlo))
568 *fLog << warn << "Could not fill Lo Gain Charge of pixel: " << pixid
569 << " signal = " << sumlo << endl;
570
571 if (!pix.FillAbsTimeLoGain(abstime))
572 *fLog << warn << "Could not fill Lo Gain Abs. Time of pixel: "
573 << pixid << " time = " << abstime << endl;
574 /*
575 if (!pix.FillRelTimeLoGain(reltime))
576 *fLog << warn << "Could not fill Lo Gain Rel. Time of pixel: "
577 << pixid << " time = " << reltime << endl;
578 */
579 } /* if (sig.IsLoGainUsed()) */
580 else
581 {
582 if (!pix.FillChargeHiGain(sumhi))
583 *fLog << warn << "Could not fill Hi Gain Charge of pixel: " << pixid
584 << " signal = " << sumhi << endl;
585
586 if (!pix.FillAbsTimeHiGain(abstime))
587 *fLog << warn << "Could not fill Hi Gain Abs. Time of pixel: "
588 << pixid << " time = " << abstime << endl;
589 /*
590 if (!pix.FillRelTimeHiGain(reltime))
591 *fLog << warn << "Could not fill Hi Gain Rel. Time of pixel: "
592 << pixid << " time = " << reltime << endl;
593 */
594 } /* else (sig.IsLoGainUsed()) */
595 break;
596
597 } /* switch(pixid) */
598
599 } /* while (pixel.Next()) */
600
601 return kTRUE;
602}
603
604Int_t MCalibrationCalc::PostProcess()
605{
606
607 *fLog << inf << endl;
608
609 if (fEvents == 0)
610 {
611 *fLog << err << GetDescriptor()
612 << ": This run contains only cosmics or pedestals, "
613 << "cannot find events with more than 350 illuminated pixels. " << endl;
614 return kFALSE;
615 }
616
617 if (fEvents < fCosmics)
618 *fLog << warn << GetDescriptor()
619 << ": WARNING: Run contains more cosmics or pedestals than calibration events " << endl;
620
621
622 *fLog << inf << GetDescriptor() << ": Cut Histogram Edges" << endl;
623
624 //
625 // Cut edges to make fits and viewing of the hists easier
626 //
627 fCalibrations->CutEdges();
628
629 //
630 // Fit the blind pixel
631 //
632 if (TESTBIT(fFlags,kUseBlindPixelFit))
633 {
634 //
635 // Get pointer to blind pixel
636 //
637 MCalibrationBlindPix &blindpixel = *(fCalibrations->GetBlindPixel());
638
639 *fLog << inf << GetDescriptor() << ": Fitting the Blind Pixel" << endl;
640
641 //
642 // retrieve mean and sigma of the blind pixel pedestal,
643 // so that we can use it for the fit
644 //
645 if (fPedestals->GetHistSize() > fBlindPixelId)
646 {
647 //
648 // retrieve the pedestal pix of the blind pixel
649 //
650 MHPedestalPixel &pedhist = (*fPedestals)(fBlindPixelId);
651 MPedestalPix &pedpix = (*fPedestals)[fBlindPixelId];
652 //
653 // retrieve the histogram containers
654 //
655 MHCalibrationBlindPixel *hist = blindpixel.GetHist();
656 //
657 // Set the corresponding values
658 //
659 const Float_t nslices = (Float_t)(fgBlindPixelLast-fgBlindPixelFirst+1);
660 const Float_t sqrslice = TMath::Sqrt(nslices);
661 const ULong_t nentries = fPedestals->GetTotalEntries();
662
663 const Float_t peddiff = (pedhist.GetChargeMean()-pedpix.GetPedestal())*nslices;
664
665 Float_t pederr = pedhist.GetChargeMeanErr()*pedhist.GetChargeMeanErr();
666 pederr += pedpix.GetPedestalRms()*pedpix.GetPedestalRms()/nentries;
667 pederr = TMath::Sqrt(pederr)*sqrslice;
668
669 //
670 // Fitted sigma: 1. one sqrt(Nr. slices) for the division which is not
671 // not appropriate: sigma(real)/slice = GetSigma*sqrt(nslices)
672 // 2. another sqrt(Nr. slices) to calculate back to number
673 // of slices
674 //
675 const Float_t pedsigma = pedhist.GetChargeSigma()*nslices;
676 const Float_t pedsigmaerr = pedhist.GetChargeSigmaErr()*nslices;
677
678 hist->SetMeanPedestal(peddiff);
679 hist->SetMeanPedestalErr(pederr);
680 hist->SetSigmaPedestal(pedsigma);
681 hist->SetSigmaPedestalErr(pedsigmaerr);
682 }
683
684 if (!blindpixel.FitCharge())
685 {
686 *fLog << warn << "Could not fit the blind pixel! " << endl;
687 *fLog << warn << "Setting bit kBlindPixelMethodValid to FALSE in MCalibrationCam" << endl;
688 fCalibrations->SetBlindPixelMethodValid(kFALSE);
689 }
690
691 blindpixel.CheckOscillations();
692
693 fCalibrations->SetBlindPixelMethodValid(kTRUE);
694 blindpixel.DrawClone();
695 }
696 else
697 *fLog << inf << GetDescriptor() << ": Skipping Blind Pixel Fit " << endl;
698
699
700 *fLog << inf << GetDescriptor() << ": Fitting the Normal Pixels" << endl;
701
702 //
703 // loop over the pedestal events and check if we have calibration
704 //
705 for (Int_t pixid=0; pixid<fPedestals->GetSize(); pixid++)
706 {
707
708 MCalibrationPix &pix = (*fCalibrations)[pixid];
709
710 //
711 // Check if the pixel has been excluded from the fits
712 //
713 if (pix.IsExcluded())
714 continue;
715
716 //
717 // get the pedestals
718 //
719 const Float_t ped = (*fPedestals)[pixid].GetPedestal();
720 const Float_t prms = (*fPedestals)[pixid].GetPedestalRms();
721
722 //
723 // set them in the calibration camera
724 //
725 pix.SetPedestal(ped,prms,(Float_t)fNumHiGainSamples,(Float_t)fNumLoGainSamples);
726
727 //
728 // perform the Gauss fits to the charges
729 //
730 pix.FitCharge();
731
732 //
733 // check also for oscillations
734 //
735 pix.CheckOscillations();
736
737 }
738
739 if (TESTBIT(fFlags,kUseBlindPixelFit) && fCalibrations->IsBlindPixelMethodValid())
740 {
741
742 if (!fCalibrations->CalcNumPhotInsidePlexiglass())
743 {
744 *fLog << err
745 << "Could not calculate the number of photons from the blind pixel " << endl;
746 *fLog << err
747 << "You can try to calibrate using the MCalibrationCalc::SkipBlindPixelFit()" << endl;
748 fCalibrations->SetBlindPixelMethodValid(kFALSE);
749 }
750 }
751 else
752 *fLog << inf << GetDescriptor() << ": Skipping Blind Pixel Calibration! " << endl;
753
754
755 if (TESTBIT(fFlags,kUsePinDiodeFit) && fCalibrations->IsPINDiodeMethodValid())
756 {
757
758 if (!fCalibrations->CalcNumPhotInsidePlexiglass())
759 {
760 *fLog << err
761 << "Could not calculate the number of photons from the blind pixel " << endl;
762 *fLog << err
763 << "You can try to calibrate using the MCalibrationCalc::SkipPINDiodeFit()" << endl;
764 fCalibrations->SetPINDiodeMethodValid(kFALSE);
765 }
766 }
767 else
768 *fLog << inf << GetDescriptor() << ": Skipping PIN Diode Calibration! " << endl;
769
770 fCalibrations->SetReadyToSave();
771
772 if (GetNumExecutions()==0)
773 return kTRUE;
774
775 *fLog << inf << endl;
776 *fLog << dec << setfill(' ') << fCosmics << " Events presumably cosmics" << endl;
777
778 return kTRUE;
779}
780
781Bool_t MCalibrationCalc::CalcSignalBlindPixel(Byte_t *ptr, Float_t &signal, const Float_t ped) const
782{
783
784 Byte_t *start = ptr + fgBlindPixelFirst;
785 Byte_t *end = ptr + fgBlindPixelLast;
786
787 Byte_t sum = 0;
788 Int_t sat = 0;
789
790 ptr = start;
791
792 while (ptr<end)
793 {
794 sum += *ptr;
795
796 if (*ptr++ >= fgSaturationLimit)
797 sat++;
798 }
799
800 if (sat)
801 {
802 *fLog << err << "HI Gain Saturation occurred in the blind pixel! "
803 << " Do not know yet how to treat this ... aborting " << endl;
804 return kFALSE;
805 }
806
807 signal = (Float_t)sum - ped*(Float_t)(fgBlindPixelLast-fgBlindPixelFirst+1);
808
809 return kTRUE;
810}
Note: See TracBrowser for help on using the repository browser.