Ignore:
Timestamp:
03/19/04 20:11:30 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mcalib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc

    r3555 r3556  
    405405//
    406406//
    407 void MCalibrationChargeCalc::FinalizePedestals(MPedestalPix &ped, MCalibrationChargePix &cal,
    408                                                Float_t &avped, Float_t &avrms, Float_t &avnum)
     407void MCalibrationChargeCalc::FinalizePedestals(const MPedestalPix &ped, MCalibrationChargePix &cal,
     408                                               Float_t &avped, Float_t &avrms)
    409409{
    410410 
     
    421421  avped += pedes;
    422422  avrms += prms;
    423   avnum++;
    424423 
    425424  //
     
    442441}
    443442
    444 
    445 
     443void MCalibrationChargeCalc::FinalizeAvPedestals(MCalibrationChargePix &cal,
     444                                                 Float_t avped, Float_t avrms, Int_t avnum)
     445{
     446 
     447  //
     448  // set the pedestans in the calibration camera
     449  //
     450  if (cal.IsHiGainSaturation())
     451    {
     452      cal.SetPedestal(avped/avnum  * fNumLoGainSamples,
     453                      avrms/avnum * fSqrtLoGainSamples,
     454                      avrms/avnum * fSqrtLoGainSamples/avnum);
     455      cal.CalcLoGainPedestal((Float_t)fNumLoGainSamples);
     456    }
     457  else
     458    {
     459      cal.SetPedestal(avped/avnum  * fNumHiGainSamples,
     460                      avrms/avnum * fSqrtHiGainSamples,
     461                      avrms/avnum * fSqrtHiGainSamples/avnum);
     462    }
     463}
     464
     465//
     466// Finalize charges per pixel:
     467// * Check chage validity
     468// * check absolute time validity
     469// * calculate the reduced sigma
     470// * caluclate the number of photo-electrons
     471//
     472//
     473Bool_t MCalibrationChargeCalc::FinalizeCharges(MCalibrationChargePix &cal, MBadPixelsPix &bad)
     474{
     475 
     476  cal.CheckChargeValidity (&bad);
     477  cal.CheckTimeValidity   (&bad);
     478     
     479  if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
     480    return kFALSE;
     481
     482  if (!cal.CalcReducedSigma())
     483    {
     484      *fLog << warn << GetDescriptor()
     485            << ": Could not calculate reduced sigmas of pixel: " << cal.GetPixId() << endl;
     486      bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
     487      return kFALSE;
     488    }
     489 
     490  if (!cal.CalcFFactorMethod())
     491    {
     492      *fLog << warn << GetDescriptor()
     493            << ": Could not calculate F-Factor of pixel: " << cal.GetPixId() << endl;
     494      bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
     495      return kFALSE;
     496    }
     497  return kTRUE;
     498}
     499
     500//
     501// * Finalize the pedestals
     502// * Do the quality checks
     503// * Calculate the reduced sigma
     504// * Calculate the F-Factor Method
     505//
    446506Int_t MCalibrationChargeCalc::PostProcess()
    447507{
     
    450510  // loop over the pedestal events and check if we have calibration
    451511  //
    452   Int_t nvalid   = 0;
    453   Float_t avinnerped  = 0;
    454   Float_t avinnerprms = 0;
    455   Float_t avinnernum  = 0;
    456   Float_t avouterped  = 0;
    457   Float_t avouterprms = 0;
    458   Float_t avouternum  = 0;
     512  Int_t   nvalid      = 0;
     513  Float_t avinnerped  = 0.;
     514  Float_t avinnerprms = 0.;
     515  Int_t  avinnernum  = 0;
     516  Float_t avouterped  = 0.;
     517  Float_t avouterprms = 0.;
     518  Int_t  avouternum  = 0;
    459519
    460520  for (Int_t pixid=0; pixid<fPedestals->GetSize(); pixid++)
     
    468528        continue;
    469529
    470       MPedestalPix &ped = (*fPedestals)[pixid];
    471 
     530      MPedestalPix  &ped = (*fPedestals)[pixid];
     531      MBadPixelsPix &bad = (*fBadPixels)[pixid];
    472532
    473533      if (fGeom->GetPixRatio(pixid) == 1.)
    474         FinalizePedestals(ped,pix,avinnerped,avinnerprms,avinnernum);
     534        {
     535          FinalizePedestals(ped,pix,avinnerped,avinnerprms);
     536          avinnernum++;
     537        }
    475538      else
    476         FinalizePedestals(ped,pix,avouterped,avouterprms,avouternum);
    477 
    478 
    479       MBadPixelsPix         &bad = (*fBadPixels)[pixid];
    480 
    481       pix.CheckChargeValidity (&bad);
    482       pix.CheckTimeValidity   (&bad);
    483      
    484       if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
    485         continue;
    486      
    487       nvalid++;
    488 
    489       if (!pix.CalcReducedSigma())
    490539        {
    491           *fLog << warn << GetDescriptor()
    492                 << ": Could not calculate reduced sigmas of pixel: " << pix.GetPixId() << endl;
    493           bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
    494           continue;
     540          FinalizePedestals(ped,pix,avouterped,avouterprms);
     541          avouternum++;
    495542        }
    496      
    497       if (!pix.CalcFFactorMethod())
    498         {
    499           *fLog << warn << GetDescriptor()
    500                 << ": Could not calculate F-Factor of pixel: " << pix.GetPixId() << endl;
    501           bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
    502         }
     543
     544      if (FinalizeCharges(pix,bad))
     545          nvalid++;
    503546    }
    504547 
     
    516559  }
    517560
    518   MCalibrationChargePix *avinnerpix = fCam->GetAverageInnerPix();
    519   MCalibrationChargePix *avouterpix = fCam->GetAverageOuterPix();
    520   //
    521   // set the pedestans in the calibration camera
    522   //
    523   if (avinnerpix->IsHiGainSaturation())
    524   {
    525       avinnerpix->SetPedestal(avinnerped/avinnernum  * fNumLoGainSamples,
    526                               avinnerprms/avinnernum * fSqrtLoGainSamples,
    527                               avinnerprms/avinnernum * fSqrtLoGainSamples/avinnernum);
    528       avinnerpix->CalcLoGainPedestal((Float_t)fNumLoGainSamples);
    529   }
    530   else
    531   {
    532       avinnerpix->SetPedestal(avinnerped/avinnernum  * fNumHiGainSamples,
    533                               avinnerprms/avinnernum * fSqrtHiGainSamples,
    534                               avinnerprms/avinnernum * fSqrtHiGainSamples/avinnernum);
    535   }
    536 
    537   if (avouterpix->IsHiGainSaturation())
    538   {
    539       avouterpix->SetPedestal(avouterped/avouternum  * fNumLoGainSamples,
    540                               avouterprms/avouternum * fSqrtLoGainSamples,
    541                               avouterprms/avouternum * fSqrtLoGainSamples/avouternum);
    542       avouterpix->CalcLoGainPedestal((Float_t)fNumLoGainSamples);
    543   }
    544   else
    545   {
    546       avouterpix->SetPedestal(avouterped/avouternum  * fNumHiGainSamples,
    547                               avouterprms/avouternum * fSqrtHiGainSamples,
    548                               avouterprms/avouternum * fSqrtHiGainSamples/avouternum);
    549   }
    550 
    551   MBadPixelsPix *bad = fCam->GetAverageInnerBadPix();
    552  
    553   avinnerpix->CheckChargeValidity(bad);
    554   avinnerpix->CheckTimeValidity(bad);
    555 
    556   if (bad->IsCalibrationSignalOK())
    557     if (!avinnerpix->CalcReducedSigma())
    558       avinnerpix->CalcFFactorMethod();
    559 
    560   bad = fCam->GetAverageInnerBadPix();
    561 
    562   avouterpix->CheckChargeValidity(bad);
    563   avouterpix->CheckTimeValidity(bad);
    564 
    565   if (bad->IsCalibrationSignalOK()) 
    566     if (!avouterpix->CalcReducedSigma())
    567       avouterpix->CalcFFactorMethod();
     561  FinalizeAvPedestals(*fCam->GetAverageInnerPix(), avinnerped, avinnerprms,avinnernum);
     562  FinalizeAvPedestals(*fCam->GetAverageOuterPix(), avouterped, avouterprms,avouternum); 
     563
     564  FinalizeCharges(*fCam->GetAverageInnerPix(),*fCam->GetAverageInnerBadPix());
     565  FinalizeCharges(*fCam->GetAverageOuterPix(),*fCam->GetAverageOuterBadPix()); 
    568566
    569567  //
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h

    r3555 r3556  
    2727class MExtractedSignalCam;
    2828class MBadPixelsCam;
     29class MBadPixelsPix;
    2930class MTime;
    3031class MCalibrationChargeCalc : public MTask
     
    6263  Int_t  PostProcess();
    6364
    64   void FinalizePedestals(MPedestalPix &ped, MCalibrationChargePix &cal,
    65                          Float_t &avped, Float_t &avrms, Float_t &avnum);
     65  void FinalizePedestals(const MPedestalPix &ped, MCalibrationChargePix &cal,
     66                         Float_t &avped, Float_t &avrms);
     67  void FinalizeAvPedestals(MCalibrationChargePix &cal, Float_t avped, Float_t avrms, Int_t avnum);
    6668 
     69  Bool_t FinalizeCharges(MCalibrationChargePix &cal, MBadPixelsPix &bad);
    6770 
    6871public:
Note: See TracChangeset for help on using the changeset viewer.