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

Last change on this file since 3057 was 3057, 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 = 12;
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 fNumHiGainSamples = fSignals->GetNumUsedHiGainFADCSlices();
283 fNumLoGainSamples = fSignals->GetNumUsedLoGainFADCSlices();
284 fSqrtHiGainSamples = TMath::Sqrt((Float_t)fNumHiGainSamples);
285
286 UInt_t npixels = cam->GetNumPixels();
287
288 for (UInt_t i=0; i<npixels; i++)
289 {
290
291 MCalibrationPix &pix = (*fCalibrations)[i];
292 pix.DefinePixId(i);
293
294 pix.SetAbsTimeBordersHiGain(fSignals->GetFirstUsedSliceHiGain(),
295 fSignals->GetLastUsedSliceHiGain());
296 pix.SetAbsTimeBordersLoGain(fSignals->GetFirstUsedSliceLoGain(),
297 fSignals->GetLastUsedSliceLoGain());
298
299 if (!TESTBIT(fFlags,kUseQualityChecks))
300 pix.SetExcludeQualityCheck();
301
302 // Exclude the blind pixel and the PIN Diode from normal pixel calibration:
303 if (i == fBlindPixelId)
304 pix.SetExcluded();
305
306 if (i == fPINDiodeId)
307 pix.SetExcluded();
308
309 }
310
311 //
312 // Look for file to exclude pixels from analysis
313 //
314 if (!fExcludedPixelsFile.IsNull())
315 {
316
317 fExcludedPixelsFile = gSystem->ExpandPathName(fExcludedPixelsFile.Data());
318
319 //
320 // Initialize reading the file
321 //
322 ifstream in(fExcludedPixelsFile.Data(),ios::in);
323
324 if (in)
325 {
326 *fLog << inf << "Use excluded pixels from file: '" << fExcludedPixelsFile.Data() << "'" << endl;
327 //
328 // Read the file and count the number of entries
329 //
330 UInt_t pixel = 0;
331
332 while (++fNumExcludedPixels)
333 {
334
335 in >> pixel;
336
337 if (!in.good())
338 break;
339 //
340 // Check for out of range
341 //
342 if (pixel > npixels)
343 {
344 *fLog << warn << "WARNING: To be excluded pixel: " << pixel
345 << " is out of range " << endl;
346 continue;
347 }
348 //
349 // Exclude pixel
350 //
351 MCalibrationPix &pix = (*fCalibrations)[pixel];
352 pix.SetExcluded();
353
354 *fLog << GetDescriptor() << inf << ": Exclude Pixel: " << pixel << endl;
355
356 }
357
358 if (--fNumExcludedPixels == 0)
359 *fLog << warn << "WARNING: File '" << fExcludedPixelsFile.Data()
360 << "'" << " is empty " << endl;
361 else
362 fCalibrations->SetNumPixelsExcluded(fNumExcludedPixels);
363
364 }
365 else
366 *fLog << warn << dbginf << "Cannot open file '" << fExcludedPixelsFile.Data() << "'" << endl;
367 }
368
369 return kTRUE;
370}
371
372
373// --------------------------------------------------------------------------
374//
375// Calculate the integral of the FADC time slices and store them as a new
376// pixel in the MCerPhotEvt container.
377//
378Int_t MCalibrationCalc::Process()
379{
380
381 //
382 // Initialize pointers to blind pixel, PIN Diode and individual pixels
383 //
384 MCalibrationBlindPix &blindpixel = *(fCalibrations->GetBlindPixel());
385 MCalibrationPINDiode &pindiode = *(fCalibrations->GetPINDiode());
386
387 MRawEvtPixelIter pixel(fRawEvt);
388
389 //
390 // Perform cosmics cut
391 //
392 if (TESTBIT(fFlags,kUseCosmicsRejection))
393 {
394
395 Int_t cosmicpix = 0;
396
397 //
398 // Create a first loop to sort out the cosmics ...
399 //
400 // This is a very primitive check for the number of cosmicpixs
401 // The cut will be applied in the fit, but for the blind pixel,
402 // we need to remove this event
403 //
404 // FIXME: In the future need a much more sophisticated one!!!
405 //
406
407 while (pixel.Next())
408 {
409
410 const UInt_t pixid = pixel.GetPixelId();
411
412 MExtractedSignalPix &sig = (*fSignals)[pixid];
413 MPedestalPix &ped = (*fPedestals)[pixid];
414 Float_t pedrms = ped.GetPedestalRms()*fSqrtHiGainSamples;
415 Float_t sumhi = sig.GetExtractedSignalHiGain();
416
417 //
418 // We consider a pixel as presumably due to cosmics
419 // if its sum of FADC slices is lower than 3 pedestal RMS
420 //
421 if (sumhi < 3.*pedrms )
422 cosmicpix++;
423 }
424
425 //
426 // If the camera contains more than 230
427 // (this is the number of outer pixels plus about 50 inner ones)
428 // presumed pixels due to cosmics, then the event is discarted.
429 // This procedure is more or less equivalent to keeping only events
430 // with at least 350 pixels with high signals.
431 //
432 if (cosmicpix > 230.)
433 {
434 fCosmics++;
435 return kCONTINUE;
436 }
437
438 pixel.Reset();
439 }
440
441 fEvents++;
442
443 Float_t referencetime = 0.;
444
445 //
446 // Create a (second) loop to do fill the calibration histograms
447 // Search for: a signal in MExtractedSignalCam
448 // Fill histograms with:
449 // charge
450 // charge vs. event nr.
451 // relative arrival time w.r.t. pixel 1
452 //
453 while (pixel.Next())
454 {
455
456 const UInt_t pixid = pixel.GetPixelId();
457
458 MCalibrationPix &pix = (*fCalibrations)[pixid];
459
460 MExtractedSignalPix &sig = (*fSignals)[pixid];
461
462 const Float_t sumhi = sig.GetExtractedSignalHiGain();
463 const Float_t sumlo = sig.GetExtractedSignalLoGain();
464
465 Float_t abstime = 0.;
466 Float_t reltime = 0.;
467
468#if 0
469 if (TESTBIT(fFlags,kUseTimes))
470 {
471
472 //
473 // Have a look in MArrivalTime,
474 // otherwise search the position of maximum bin
475 // in MRawEvtData
476 //
477 if (fArrivalTime)
478 {
479 abstime = (*fArrivalTime)[pixid];
480 reltime = abstime - (*fArrivalTime)[1];
481 }
482
483 else
484 {
485 if (pixid == 1)
486 referencetime = (Float_t)pixel.GetIdxMaxHiGainSample();
487#endif
488 if (sig.IsLoGainUsed())
489 {
490 abstime = (Float_t)pixel.GetIdxMaxLoGainSample();
491 // reltime = abstime - referencetime;
492 }
493 else
494 {
495 abstime = (Float_t)pixel.GetIdxMaxHiGainSample();
496 // reltime = abstime - referencetime;
497 }
498 // }
499 // } /* if Use Times */
500
501 switch(pixid)
502 {
503
504 case fBlindPixelId:
505
506 if (TESTBIT(fFlags,kUseBlindPixelFit))
507 {
508
509 Float_t blindpixelsum = 0.;
510 //
511 // We need a dedicated signal extractor for the blind pixel
512 //
513 MPedestalPix &ped = (*fPedestals)[pixid];
514 if (!CalcSignalBlindPixel(pixel.GetHiGainSamples(), blindpixelsum, ped.GetPedestal()))
515 return kFALSE;
516
517 if (!blindpixel.FillCharge(blindpixelsum))
518 *fLog << warn <<
519 "Overflow or Underflow occurred filling Blind Pixel sum = " << blindpixelsum << endl;
520
521 // if (!blindpixel.FillRChargevsTime(blindpixelsum,fEvents))
522 // *fLog << warn <<
523 // "Overflow or Underflow occurred filling Blind Pixel eventnr = " << fEvents << endl;
524 } /* if use blind pixel */
525
526 break;
527
528 case fPINDiodeId:
529
530 if (TESTBIT(fFlags,kUsePinDiodeFit))
531 {
532
533 if (!pindiode.FillCharge(sumhi))
534 *fLog << warn
535 << "Overflow or Underflow occurred filling PINDiode: sum = "
536 << sumhi << endl;
537
538 if (!pindiode.FillAbsTime(abstime))
539 *fLog << warn
540 << "Overflow or Underflow occurred filling PINDiode abs. time = "
541 << abstime << endl;
542
543 if (!pindiode.FillGraphs(sumhi,sumlo))
544 *fLog << warn
545 << "Overflow or Underflow occurred filling PINDiode: eventnr = "
546 << fEvents << endl;
547
548 } /* if use PIN Diode */
549
550 break;
551
552 default:
553
554 if (pix.IsExcluded())
555 continue;
556
557 pix.FillGraphs(sumhi,sumlo);
558
559 if (sig.IsLoGainUsed())
560 {
561
562 if (!pix.FillChargeLoGain(sumlo))
563 *fLog << warn << "Could not fill Lo Gain Charge of pixel: " << pixid
564 << " signal = " << sumlo << endl;
565
566 if (!pix.FillAbsTimeLoGain(abstime))
567 *fLog << warn << "Could not fill Lo Gain Abs. Time of pixel: "
568 << pixid << " time = " << abstime << endl;
569 /*
570 if (!pix.FillRelTimeLoGain(reltime))
571 *fLog << warn << "Could not fill Lo Gain Rel. Time of pixel: "
572 << pixid << " time = " << reltime << endl;
573 */
574 } /* if (sig.IsLoGainUsed()) */
575 else
576 {
577 if (!pix.FillChargeHiGain(sumhi))
578 *fLog << warn << "Could not fill Hi Gain Charge of pixel: " << pixid
579 << " signal = " << sumhi << endl;
580
581 if (!pix.FillAbsTimeHiGain(abstime))
582 *fLog << warn << "Could not fill Hi Gain Abs. Time of pixel: "
583 << pixid << " time = " << abstime << endl;
584 /*
585 if (!pix.FillRelTimeHiGain(reltime))
586 *fLog << warn << "Could not fill Hi Gain Rel. Time of pixel: "
587 << pixid << " time = " << reltime << endl;
588 */
589 } /* else (sig.IsLoGainUsed()) */
590 break;
591
592 } /* switch(pixid) */
593
594 } /* while (pixel.Next()) */
595
596 return kTRUE;
597}
598
599Int_t MCalibrationCalc::PostProcess()
600{
601
602 *fLog << inf << endl;
603
604 if (fEvents == 0)
605 {
606 *fLog << err << GetDescriptor()
607 << ": This run contains only cosmics or pedestals, "
608 << "cannot find events with more than 350 illuminated pixels. " << endl;
609 return kFALSE;
610 }
611
612 if (fEvents < fCosmics)
613 *fLog << warn << GetDescriptor()
614 << ": WARNING: Run contains more cosmics or pedestals than calibration events " << endl;
615
616
617 *fLog << inf << GetDescriptor() << ": Cut Histogram Edges" << endl;
618
619 //
620 // Cut edges to make fits and viewing of the hists easier
621 //
622 fCalibrations->CutEdges();
623
624 //
625 // Fit the blind pixel
626 //
627 if (TESTBIT(fFlags,kUseBlindPixelFit))
628 {
629 //
630 // Get pointer to blind pixel
631 //
632 MCalibrationBlindPix &blindpixel = *(fCalibrations->GetBlindPixel());
633
634 *fLog << inf << GetDescriptor() << ": Fitting the Blind Pixel" << endl;
635
636 //
637 // retrieve mean and sigma of the blind pixel pedestal,
638 // so that we can use it for the fit
639 //
640 if (fPedestals->GetHistSize() > fBlindPixelId)
641 {
642 //
643 // retrieve the pedestal pix of the blind pixel
644 //
645 MHPedestalPixel &pedhist = (*fPedestals)(fBlindPixelId);
646 MPedestalPix &pedpix = (*fPedestals)[fBlindPixelId];
647 //
648 // retrieve the histogram containers
649 //
650 MHCalibrationBlindPixel *hist = blindpixel.GetHist();
651 //
652 // Set the corresponding values
653 //
654 const Float_t nslices = (Float_t)(fgBlindPixelLast-fgBlindPixelFirst+1);
655 const Float_t sqrslice = TMath::Sqrt(nslices);
656 const ULong_t nentries = fPedestals->GetTotalEntries();
657
658 const Float_t peddiff = (pedhist.GetChargeMean()-pedpix.GetPedestal())*nslices;
659
660 Float_t pederr = pedhist.GetChargeMeanErr()*pedhist.GetChargeMeanErr();
661 pederr += pedpix.GetPedestalRms()*pedpix.GetPedestalRms()/nentries;
662 pederr = TMath::Sqrt(pederr)*sqrslice;
663
664 //
665 // Fitted sigma: 1. one sqrt(Nr. slices) for the division which is not
666 // not appropriate: sigma(real)/slice = GetSigma*sqrt(nslices)
667 // 2. another sqrt(Nr. slices) to calculate back to number
668 // of slices
669 //
670 const Float_t pedsigma = pedhist.GetChargeSigma()*nslices;
671 const Float_t pedsigmaerr = pedhist.GetChargeSigmaErr()*nslices;
672
673 hist->SetMeanPedestal(peddiff);
674 hist->SetMeanPedestalErr(pederr);
675 hist->SetSigmaPedestal(pedsigma);
676 hist->SetSigmaPedestalErr(pedsigmaerr);
677 }
678
679 if (!blindpixel.FitCharge())
680 {
681 *fLog << warn << "Could not fit the blind pixel! " << endl;
682 *fLog << warn << "Setting bit kBlindPixelMethodValid to FALSE in MCalibrationCam" << endl;
683 fCalibrations->SetBlindPixelMethodValid(kFALSE);
684 }
685
686 fCalibrations->SetBlindPixelMethodValid(kTRUE);
687 blindpixel.DrawClone();
688 }
689 else
690 *fLog << inf << GetDescriptor() << ": Skipping Blind Pixel Fit " << endl;
691
692
693 *fLog << inf << GetDescriptor() << ": Fitting the Normal Pixels" << endl;
694
695 //
696 // loop over the pedestal events and check if we have calibration
697 //
698 for (Int_t pixid=0; pixid<fPedestals->GetSize(); pixid++)
699 {
700
701 MCalibrationPix &pix = (*fCalibrations)[pixid];
702
703 //
704 // Check if the pixel has been excluded from the fits
705 //
706 if (pix.IsExcluded())
707 continue;
708
709 //
710 // get the pedestals
711 //
712 const Float_t ped = (*fPedestals)[pixid].GetPedestal();
713 const Float_t prms = (*fPedestals)[pixid].GetPedestalRms();
714
715 //
716 // set them in the calibration camera
717 //
718 pix.SetPedestal(ped,prms,(Float_t)fNumHiGainSamples,(Float_t)fNumLoGainSamples);
719
720 //
721 // perform the Gauss fits to the charges
722 //
723 pix.FitCharge();
724
725 //
726 // check also for oscillations
727 //
728 pix.CheckOscillations();
729
730 }
731
732 if (TESTBIT(fFlags,kUseBlindPixelFit) && fCalibrations->IsBlindPixelMethodValid())
733 {
734
735 if (!fCalibrations->CalcNumPhotInsidePlexiglass())
736 {
737 *fLog << err
738 << "Could not calculate the number of photons from the blind pixel " << endl;
739 *fLog << err
740 << "You can try to calibrate using the MCalibrationCalc::SkipBlindPixelFit()" << endl;
741 fCalibrations->SetBlindPixelMethodValid(kFALSE);
742 }
743 }
744 else
745 *fLog << inf << GetDescriptor() << ": Skipping Blind Pixel Calibration! " << endl;
746
747
748 if (TESTBIT(fFlags,kUsePinDiodeFit) && fCalibrations->IsPINDiodeMethodValid())
749 {
750
751 if (!fCalibrations->CalcNumPhotInsidePlexiglass())
752 {
753 *fLog << err
754 << "Could not calculate the number of photons from the blind pixel " << endl;
755 *fLog << err
756 << "You can try to calibrate using the MCalibrationCalc::SkipPINDiodeFit()" << endl;
757 fCalibrations->SetPINDiodeMethodValid(kFALSE);
758 }
759 }
760 else
761 *fLog << inf << GetDescriptor() << ": Skipping PIN Diode Calibration! " << endl;
762
763 fCalibrations->SetReadyToSave();
764
765 if (GetNumExecutions()==0)
766 return kTRUE;
767
768 *fLog << inf << endl;
769 *fLog << dec << setfill(' ') << fCosmics << " Events presumably cosmics" << endl;
770
771 return kTRUE;
772}
773
774Bool_t MCalibrationCalc::CalcSignalBlindPixel(Byte_t *ptr, Float_t &signal, const Float_t ped) const
775{
776
777 Byte_t *start = ptr + fgBlindPixelFirst;
778 Byte_t *end = ptr + fgBlindPixelLast;
779
780 Byte_t sum = 0;
781 Int_t sat = 0;
782
783 ptr = start;
784
785 while (ptr<end)
786 {
787 sum += *ptr;
788
789 if (*ptr++ >= fgSaturationLimit)
790 sat++;
791 }
792
793 if (sat)
794 {
795 *fLog << err << "HI Gain Saturation occurred in the blind pixel! "
796 << " Do not know yet how to treat this ... aborting " << endl;
797 return kFALSE;
798 }
799
800 signal = (Float_t)sum - ped*(Float_t)(fgBlindPixelLast-fgBlindPixelFirst+1);
801
802 return kTRUE;
803}
Note: See TracBrowser for help on using the repository browser.