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

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