Changeset 3555


Ignore:
Timestamp:
03/19/04 19:37:51 (21 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r3554 r3555  
    4646   * mcalib/MCalibrationChargeCalc.[h,cc]
    4747     - added MCalibrationQECam
     48
     49   * mcalib/MCalibrationChargePix.[h,cc]
     50     - took out fNumLoGainSampels whihc is not needed any more because
     51       conversion is only done in the getters
     52     - Canceled function ApplyLoGainConversion (for same reason)
    4853
    4954
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc

    r3554 r3555  
    389389
    390390
    391 // --------------------------------------------------------------------------
    392 //
    393 // Calculate the integral of the FADC time slices and store them as a new
    394 // pixel in the MCerPhotEvt container.
    395 //
    396391Int_t MCalibrationChargeCalc::Process()
    397392{
    398393  return kTRUE;
    399394}
     395
     396// --------------------------------------------------------------------------
     397// 
     398// Finalize pedestals:
     399//
     400// * Retrieve pedestal and pedestal RMS from MPedestalPix
     401// * Retrieve total entries from MPedestalCam
     402// * sum up pedestal and pedestalRMS for the average pixel
     403// * set pedestal*number of used samples in MCalibrationChargePix
     404// * set pedestal RMS * sqrt of number of used samples in MCalibrationChargePix
     405//
     406//
     407void MCalibrationChargeCalc::FinalizePedestals(MPedestalPix &ped, MCalibrationChargePix &cal,
     408                                               Float_t &avped, Float_t &avrms, Float_t &avnum)
     409{
     410 
     411  //
     412  // get the pedestals
     413  //
     414  const Float_t pedes  = ped.GetPedestal();
     415  const Float_t prms   = ped.GetPedestalRms();
     416  const Float_t num    = TMath::Sqrt((Float_t)fPedestals->GetTotalEntries());
     417
     418  //
     419  // Calculate the average pedestal
     420  //
     421  avped += pedes;
     422  avrms += prms;
     423  avnum++;
     424 
     425  //
     426  // set them in the calibration camera
     427  //
     428  if (cal.IsHiGainSaturation())
     429    {
     430      cal.SetPedestal(pedes* fNumLoGainSamples,
     431                      prms * fSqrtLoGainSamples,
     432                      prms * fNumLoGainSamples / num);
     433      cal.CalcLoGainPedestal((Float_t)fNumLoGainSamples);
     434    }
     435  else
     436    {
     437      cal.SetPedestal(pedes* fNumHiGainSamples,
     438                      prms * fSqrtHiGainSamples,
     439                      prms * fNumHiGainSamples / num);
     440    }
     441 
     442}
     443
     444
    400445
    401446Int_t MCalibrationChargeCalc::PostProcess()
     
    417462
    418463      MCalibrationChargePix &pix = (*fCam)[pixid];
    419       MBadPixelsPix         &bad = (*fBadPixels)[pixid];
    420 
    421464      //
    422465      // Check if the pixel has been excluded from the fits
     
    425468        continue;
    426469
    427       //
    428       // get the pedestals
    429       //
    430       const Float_t ped    = (*fPedestals)[pixid].GetPedestal();
    431       const Float_t prms   = (*fPedestals)[pixid].GetPedestalRms();
    432       const Float_t num    = TMath::Sqrt((Float_t)fPedestals->GetTotalEntries());
     470      MPedestalPix &ped = (*fPedestals)[pixid];
     471
    433472
    434473      if (fGeom->GetPixRatio(pixid) == 1.)
    435       {
    436           avinnerped  += ped;
    437           avinnerprms += prms;
    438           avinnernum++;
    439       }
     474        FinalizePedestals(ped,pix,avinnerped,avinnerprms,avinnernum);
    440475      else
    441       {
    442           avouterped  += ped;
    443           avouterprms += prms;
    444           avouternum++;
    445       }
    446       //
    447       // set them in the calibration camera
    448       //
    449       if (pix.IsHiGainSaturation())
    450       {
    451           pix.SetPedestal(ped  * fNumLoGainSamples,
    452                           prms * fSqrtLoGainSamples,
    453                           prms * fNumLoGainSamples / num);
    454           pix.SetNumLoGainSamples(fNumLoGainSamples);
    455           pix.ApplyLoGainConversion();
    456       }
    457       else
    458       {
    459           pix.SetPedestal(ped  * fNumHiGainSamples,
    460                           prms * fSqrtHiGainSamples,
    461                           prms * fNumHiGainSamples / num);
    462       }
     476        FinalizePedestals(ped,pix,avouterped,avouterprms,avouternum);
     477
     478
     479      MBadPixelsPix         &bad = (*fBadPixels)[pixid];
    463480
    464481      pix.CheckChargeValidity (&bad);
     
    509526                              avinnerprms/avinnernum * fSqrtLoGainSamples,
    510527                              avinnerprms/avinnernum * fSqrtLoGainSamples/avinnernum);
    511       avinnerpix->SetNumLoGainSamples(fNumLoGainSamples);
    512       avinnerpix->ApplyLoGainConversion();
     528      avinnerpix->CalcLoGainPedestal((Float_t)fNumLoGainSamples);
    513529  }
    514530  else
     
    524540                              avouterprms/avouternum * fSqrtLoGainSamples,
    525541                              avouterprms/avouternum * fSqrtLoGainSamples/avouternum);
    526       avouterpix->SetNumLoGainSamples(fNumLoGainSamples);
    527       avouterpix->ApplyLoGainConversion();
     542      avouterpix->CalcLoGainPedestal((Float_t)fNumLoGainSamples);
    528543  }
    529544  else
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.h

    r3554 r3555  
    1818class MRawRunHeader;
    1919class MPedestalCam;
     20class MPedestalPix;
    2021class MCalibrationChargePINDiode;
    2122class MCalibrationChargeBlindPix;
     23class MCalibrationChargePix;
    2224class MCalibrationChargeCam;
    2325class MCalibrationQECam;
     
    5961  Int_t  Process();
    6062  Int_t  PostProcess();
     63
     64  void FinalizePedestals(MPedestalPix &ped, MCalibrationChargePix &cal,
     65                         Float_t &avped, Float_t &avrms, Float_t &avnum);
     66 
    6167 
    6268public:
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.cc

    r3554 r3555  
    177177  fLoGainNumPickup                  =  -1;
    178178
    179   fNumLoGainSamples                 =  -1.;
    180 
    181179  fPed                              =  -1.;
    182180  fPedRms                           =  -1.;
     
    708706}
    709707
    710 void MCalibrationChargePix::CalcLoGainPed()
    711 {
    712 
    713     Float_t pedRmsSquare      = fPedRms * fPedRms;
    714     Float_t pedRmsSquareVar   = fPedVar * pedRmsSquare; // fPedRmsErr = fPedErr/2.
    715    
    716     //
    717     // We do not know the Lo Gain Pedestal RMS, so we have to retrieve it
    718     // from the HI GAIN (all calculation per slice up to now): 
    719     //
    720     // We extract the pure NSB contribution:
    721     //
    722     const Float_t elecRmsSquare    =    fElectronicPedRms    * fElectronicPedRms;
    723     const Float_t elecRmsSquareVar = 4.*fElectronicPedRmsVar * elecRmsSquare;
    724    
    725     Float_t nsbSquare             =  pedRmsSquare    - elecRmsSquare;
    726     Float_t nsbSquareRelVar       = (pedRmsSquareVar + elecRmsSquareVar)
    727                                         / (nsbSquare * nsbSquare) ;
    728    
    729     if (nsbSquare < 0.)
    730       nsbSquare = 0.;
    731    
    732     //
    733     // Now, we divide the NSB by the conversion factor and
    734     // add it quadratically to the electronic noise
    735     //
    736     const Float_t conversionSquare        =    fConversionHiLo    * fConversionHiLo;
    737     const Float_t convertedNsbSquare      =    nsbSquare       / conversionSquare;
    738     const Float_t convertedNsbSquareVar   =    nsbSquareRelVar
    739                                             * convertedNsbSquare * convertedNsbSquare;
    740    
    741     pedRmsSquare     = convertedNsbSquare    + elecRmsSquare;
    742     pedRmsSquareVar  = convertedNsbSquareVar + elecRmsSquareVar;
    743    
    744     fLoGainPedRms    = TMath::Sqrt(pedRmsSquare);
    745     fLoGainPedRmsVar = 0.25 * pedRmsSquareVar /  pedRmsSquare;
    746 
    747 }
    748708
    749709//
     
    844804
    845805
    846 void MCalibrationChargePix::ApplyLoGainConversion()
    847 {
    848  
    849   fElectronicPedRms       = gkElectronicPedRms    * TMath::Sqrt(fNumLoGainSamples);
    850   fElectronicPedRmsVar    = gkElectronicPedRmsErr * gkElectronicPedRmsErr * fNumLoGainSamples;
    851  
    852   CalcLoGainPed();
    853 }
    854 
    855 
     806void MCalibrationChargePix::CalcLoGainPedestal(Float_t logainsamples)
     807{
     808
     809  fElectronicPedRms       = gkElectronicPedRms    * TMath::Sqrt(logainsamples);
     810  fElectronicPedRmsVar    = gkElectronicPedRmsErr * gkElectronicPedRmsErr * logainsamples;
     811 
     812  Float_t pedRmsSquare      = fPedRms * fPedRms;
     813  Float_t pedRmsSquareVar   = fPedVar * pedRmsSquare; // fPedRmsErr = fPedErr/2.
     814 
     815  //
     816  // We do not know the Lo Gain Pedestal RMS, so we have to retrieve it
     817  // from the HI GAIN (all calculation per slice up to now): 
     818  //
     819  // We extract the pure NSB contribution:
     820  //
     821  const Float_t elecRmsSquare    =    fElectronicPedRms    * fElectronicPedRms;
     822  const Float_t elecRmsSquareVar = 4.*fElectronicPedRmsVar * elecRmsSquare;
     823 
     824  Float_t nsbSquare             =  pedRmsSquare    - elecRmsSquare;
     825  Float_t nsbSquareRelVar       = (pedRmsSquareVar + elecRmsSquareVar)
     826                                 / (nsbSquare * nsbSquare) ;
     827 
     828  if (nsbSquare < 0.)
     829    nsbSquare = 0.;
     830 
     831  //
     832  // Now, we divide the NSB by the conversion factor and
     833  // add it quadratically to the electronic noise
     834  //
     835  const Float_t conversionSquare        =    fConversionHiLo    * fConversionHiLo;
     836  const Float_t convertedNsbSquare      =    nsbSquare       / conversionSquare;
     837  const Float_t convertedNsbSquareVar   =    nsbSquareRelVar
     838                                            * convertedNsbSquare * convertedNsbSquare;
     839   
     840  pedRmsSquare     = convertedNsbSquare    + elecRmsSquare;
     841  pedRmsSquareVar  = convertedNsbSquareVar + elecRmsSquareVar;
     842 
     843  fLoGainPedRms    = TMath::Sqrt(pedRmsSquare);
     844  fLoGainPedRmsVar = 0.25 * pedRmsSquareVar /  pedRmsSquare;
     845 
     846}
     847 
     848 
     849 
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargePix.h

    r3553 r3555  
    109109  Float_t fConversionHiLoVar;               // The error of the conversion factor between Hi Gain and Lo Gain 
    110110
    111   Float_t fNumLoGainSamples;
    112 
    113   Float_t   fHiGainNumPickup;
    114   Float_t   fLoGainNumPickup;
     111  Float_t fHiGainNumPickup;
     112  Float_t fLoGainNumPickup;
    115113
    116114  enum  { kHiGainSaturation, kLoGainSaturation,
     
    121119          kPINDiodeMethodValid, kCombinedMethodValid };
    122120
    123   void CalcLoGainPed();
    124  
    125121public:
    126122
     
    170166  void SetAbsTimeMean           ( const Float_t f ) { fAbsTimeMean           = f; }
    171167  void SetAbsTimeRms            ( const Float_t f ) { fAbsTimeRms            = f; }
    172 
    173   void SetNumLoGainSamples      ( const Float_t f ) { fNumLoGainSamples      = f; }
    174168
    175169  // Conversion Factors
     
    283277
    284278  // Miscellaneous
    285   void  ApplyLoGainConversion();
    286 
    287279  void CheckChargeValidity ( MBadPixelsPix *bad );
    288280  void CheckTimeValidity   ( MBadPixelsPix *bad );
     281
     282  void  CalcLoGainPedestal(const Float_t logainsamples);
    289283  Bool_t CalcReducedSigma();
    290284  Bool_t CalcFFactorMethod();
Note: See TracChangeset for help on using the changeset viewer.