Ignore:
Timestamp:
06/06/01 15:03:45 (23 years ago)
Author:
jflix
Message:
Few changes included in MPedCalcPedRun.cc to optimise the class.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc

    r802 r841  
    7474
    7575    MRawEvtPixelIter pixel(fRawEvt);
     76    const Byte_t HiGainSamples = fRawEvt->GetNumHiGainSamples();
    7677
    7778    while (pixel.Next())
     
    8081
    8182        Byte_t *ptr = pixel.GetHiGainFadcSamples();
    82         const Byte_t *end = ptr + fRawEvt->GetNumHiGainSamples();
     83        const Byte_t *end = ptr + HiGainSamples;
    8384
    84         Float_t HiGainPed = PedMeanCalcHiGain(ptr,end);
    85         Float_t HiGainRms = PedRmsCalcHiGain(ptr,end,HiGainPed);
     85        Float_t HiGainPed = PedMeanCalcHiGain(ptr,end,HiGainSamples);
     86        Float_t HiGainRms = PedRmsCalcHiGain(ptr,end,HiGainPed,HiGainSamples);
    8687
    87         Float_t HiGainPedErr = PedMeanErrCalcHiGain(HiGainRms);
    88         Float_t HiGainRmsErr = PedRmsErrCalcHiGain(HiGainRms);
     88        Float_t HiGainPedErr = PedMeanErrCalcHiGain(HiGainRms,HiGainSamples);
     89        Float_t HiGainRmsErr = PedRmsErrCalcHiGain(HiGainRms,HiGainSamples);
    8990
    9091        (*fPedestals)[pixid].SetPedestal(HiGainPed,HiGainRms);
     
    99100
    100101
    101 Float_t MPedCalcPedRun::PedMeanCalcHiGain(Byte_t *ptr, const Byte_t *end)
     102Float_t MPedCalcPedRun::PedMeanCalcHiGain(Byte_t *ptr, const Byte_t *end, const Byte_t HiGainSamples)
    102103{
    103104    Float_t sum=0;
     
    106107    while (ptr != end);
    107108
    108     sum = sum/(Int_t)fRawEvt->GetNumHiGainSamples();
     109    sum = sum/(Int_t)HiGainSamples;
    109110
    110111    return sum;
     
    112113
    113114
    114 Float_t MPedCalcPedRun::PedRmsCalcHiGain(Byte_t *ptr, const Byte_t *end, Float_t HiGainPed)
     115Float_t MPedCalcPedRun::PedRmsCalcHiGain(Byte_t *ptr, const Byte_t *end, Float_t HiGainPed, const Byte_t HiGainSamples)
    115116{
    116117
     
    118119
    119120  do{
    120     rms = rms + pow((*ptr - HiGainPed),2);
     121    rms = rms + (*ptr - HiGainPed)*(*ptr - HiGainPed);
    121122    *ptr++;
    122123    }while (ptr != end);
    123124
    124     rms = sqrt((Float_t)rms/((Int_t)fRawEvt->GetNumHiGainSamples()-1));
     125    rms = sqrt((Float_t)rms/((Int_t)HiGainSamples-1));
    125126
    126127  return rms;
     
    128129
    129130
    130 Float_t MPedCalcPedRun::PedMeanErrCalcHiGain(Float_t HiGainRms){
    131   return HiGainRms/sqrt((Int_t)fRawEvt->GetNumHiGainSamples());
     131Float_t MPedCalcPedRun::PedMeanErrCalcHiGain(Float_t HiGainRms, const Byte_t HiGainSamples){
     132  return HiGainRms/sqrt((Int_t)HiGainSamples);
    132133}
    133134
    134135
    135 Float_t MPedCalcPedRun::PedRmsErrCalcHiGain(Float_t HiGainRms){
    136   return HiGainRms/sqrt(2*(Int_t)fRawEvt->GetNumHiGainSamples());
     136Float_t MPedCalcPedRun::PedRmsErrCalcHiGain(Float_t HiGainRms, const Byte_t HiGainSamples){
     137  return HiGainRms/sqrt(2*(Int_t)HiGainSamples);
    137138}
    138139
Note: See TracChangeset for help on using the changeset viewer.