Changeset 845


Ignore:
Timestamp:
06/12/01 13:27:42 (24 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r844 r845  
    1818     - use of SetHasChanged added
    1919
     20   * manalysis/MPedCalcPedRun.[h,cc]:
     21     - made fNumHiGainSamples a class member
     22     - renamed some member functions
     23     - made the 'internal' member functions private
     24     - added SetHasChanged
     25     - made these functions const
     26     
    2027   * mbase/BaseLinkDef.h
    2128     - MWriteAsciiFile added
  • trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc

    r841 r845  
    1717!
    1818!   Author(s): Josep Flix 04/2001 (jflix@ifae.es)
     19!              Thomas Bretz 05/2001 (tbretz@uni-sw.gwdg.de)
    1920!
    2021!   Copyright: MAGIC Software Development, 2000-2001
     
    6162    fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
    6263    if (!fPedestals)
    63     {
    64         *fLog << dbginf << "MPedestalCam not found... aborting." << endl;
    6564        return kFALSE;
    66     }
     65
     66    fNumHiGainSamples = fRawEvt->GetNumHiGainSamples();
    6767
    6868    return kTRUE;
     
    7272Bool_t MPedCalcPedRun::Process()
    7373{
    74 
    7574    MRawEvtPixelIter pixel(fRawEvt);
    76     const Byte_t HiGainSamples = fRawEvt->GetNumHiGainSamples();
    7775
    7876    while (pixel.Next())
    7977    {
     78              Byte_t *ptr = pixel.GetHiGainFadcSamples();
     79        const Byte_t *end = ptr + fRawEvt->GetNumHiGainSamples();
     80
     81        const Float_t higainped = CalcHiGainMean(ptr, end);
     82        const Float_t higainrms = CalcHiGainRms(ptr, end, higainped);
     83
     84        const Float_t higainpederr = CalcHiGainMeanErr(higainrms);
     85        const Float_t higainrmserr = CalcHiGainRmsErr(higainrms);
     86
    8087        const UInt_t pixid = pixel.GetPixelId();
     88        MPedestalPix &pix = (*fPedestals)[pixid];
    8189
    82         Byte_t *ptr = pixel.GetHiGainFadcSamples();
    83         const Byte_t *end = ptr + HiGainSamples;
    84 
    85         Float_t HiGainPed = PedMeanCalcHiGain(ptr,end,HiGainSamples);
    86         Float_t HiGainRms = PedRmsCalcHiGain(ptr,end,HiGainPed,HiGainSamples);
    87 
    88         Float_t HiGainPedErr = PedMeanErrCalcHiGain(HiGainRms,HiGainSamples);
    89         Float_t HiGainRmsErr = PedRmsErrCalcHiGain(HiGainRms,HiGainSamples);
    90 
    91         (*fPedestals)[pixid].SetPedestal(HiGainPed,HiGainRms);
    92         (*fPedestals)[pixid].SetPedestalRms(HiGainPedErr,HiGainRmsErr);
    93 
     90        pix.SetPedestal(higainped, higainrms);
     91        pix.SetPedestalRms(higainpederr, higainrmserr);
    9492    }
    9593
     94    fPedestals->SetHasChanged();
     95
    9696    return kTRUE;
     97}
    9798
     99Float_t MPedCalcPedRun::CalcHiGainMean(Byte_t *ptr, const Byte_t *end) const
     100{
     101    Int_t sum=0;
     102
     103    do sum += *ptr;
     104    while (++ptr != end);
     105
     106    return (Float_t)sum/fNumHiGainSamples;
    98107}
    99108
    100109
     110Float_t MPedCalcPedRun::CalcHiGainRms(Byte_t *ptr, const Byte_t *end, Float_t higainped) const
     111{
     112    Float_t rms = 0;
    101113
    102 Float_t MPedCalcPedRun::PedMeanCalcHiGain(Byte_t *ptr, const Byte_t *end, const Byte_t HiGainSamples)
    103 {
    104     Float_t sum=0;
     114    do
     115    {
     116        const Float_t diff = (Float_t)(*ptr)-higainped;
    105117
    106     do sum += *ptr++;
    107     while (ptr != end);
     118        rms += diff*diff;
     119    } while (++ptr != end);
    108120
    109     sum = sum/(Int_t)HiGainSamples;
    110 
    111     return sum;
     121    return sqrt(rms/(fNumHiGainSamples-1));
    112122}
    113123
    114 
    115 Float_t MPedCalcPedRun::PedRmsCalcHiGain(Byte_t *ptr, const Byte_t *end, Float_t HiGainPed, const Byte_t HiGainSamples)
     124Float_t MPedCalcPedRun::CalcHiGainMeanErr(Float_t higainrms) const
    116125{
    117 
    118   Float_t rms = 0;
    119 
    120   do{
    121     rms = rms + (*ptr - HiGainPed)*(*ptr - HiGainPed);
    122     *ptr++;
    123     }while (ptr != end);
    124 
    125     rms = sqrt((Float_t)rms/((Int_t)HiGainSamples-1));
    126 
    127   return rms;
     126    return higainrms/sqrt(fNumHiGainSamples);
    128127}
    129128
    130 
    131 Float_t MPedCalcPedRun::PedMeanErrCalcHiGain(Float_t HiGainRms, const Byte_t HiGainSamples){
    132   return HiGainRms/sqrt((Int_t)HiGainSamples);
     129Float_t MPedCalcPedRun::CalcHiGainRmsErr(Float_t higainrms) const
     130{
     131    return higainrms/sqrt(2.*fNumHiGainSamples);
    133132}
    134133
    135 
    136 Float_t MPedCalcPedRun::PedRmsErrCalcHiGain(Float_t HiGainRms, const Byte_t HiGainSamples){
    137   return HiGainRms/sqrt(2*(Int_t)HiGainSamples);
    138 }
    139 
  • trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.h

    r840 r845  
    1919class MPedCalcPedRun : public MTask
    2020{
     21    Byte_t fNumHiGainSamples;
    2122
    2223    MRawEvtData  *fRawEvt;     // raw event data (time slices)
    2324    MPedestalCam *fPedestals;  // Pedestals of all pixels in the camera
     25
     26    Float_t CalcHiGainMean(Byte_t *ptr, const Byte_t *end) const;
     27    Float_t CalcHiGainRms(Byte_t *ptr, const Byte_t *end, Float_t higainped) const;
     28    Float_t CalcHiGainMeanErr(Float_t higainrms) const;
     29    Float_t CalcHiGainRmsErr(Float_t higainrms) const;
    2430
    2531public:
     
    3036    Bool_t Process();
    3137
    32     Float_t PedMeanCalcHiGain(Byte_t *ptr, const Byte_t *end, const Byte_t HiGainSamples);
    33     Float_t PedRmsCalcHiGain(Byte_t *ptr, const Byte_t *end, Float_t HiGainPed, const Byte_t HiGainSamples);
    34     Float_t PedMeanErrCalcHiGain(Float_t HiGainRms, const Byte_t HiGainSamples);
    35     Float_t PedRmsErrCalcHiGain(Float_t HiGainRms, const Byte_t HiGainSamples);
    36 
    3738    ClassDef(MPedCalcPedRun, 0)   // Task to calculate pedestals from pedestal runs raw data
    3839};
Note: See TracChangeset for help on using the changeset viewer.