Changeset 4794


Ignore:
Timestamp:
08/29/04 17:28:42 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mpedestal
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mpedestal/MPedestalCam.cc

    r4784 r4794  
    3636
    3737#include <TArrayI.h>
     38#include <TArrayF.h>
    3839#include <TArrayD.h>
    3940
     
    326327// in the calculation of the size average.
    327328//
    328 Float_t MPedestalCam::GetAveragedPedPerArea(const MGeomCam &geom, const UInt_t ai, MBadPixelsCam *bad)
     329// Returns a TArrayF of dimension 2:
     330// arr[0]: averaged pedestal (default: -1.)
     331// arr[1]: Error (rms) of averaged pedestal (default: 0.)
     332//
     333// ATTENTION: THE USER HAS TO DELETE THE RETURNED TARRAYF ACCORDINGLY
     334//
     335TArrayF *MPedestalCam::GetAveragedPedPerArea(const MGeomCam &geom, const UInt_t ai, MBadPixelsCam *bad)
    329336{
    330337
    331338  const Int_t np = GetSize();
    332339
    333   Double_t mean = 0.;
    334   Int_t    nr   = 0;
     340  Double_t mean  = 0.;
     341  Double_t mean2 = 0.;
     342  Int_t    nr    = 0;
    335343
    336344  for (int i=0; i<np; i++)
     
    346354      const MPedestalPix &pix = (*this)[i];
    347355     
    348       mean += pix.GetPedestal();
    349       nr   ++;
    350      
    351     }
    352 
    353   return mean/nr;
     356      mean  += pix.GetPedestal();
     357      mean2 += pix.GetPedestal()*pix.GetPedestal();
     358      nr    ++;
     359     
     360    }
     361
     362  TArrayF *arr = new TArrayF(2);
     363  arr->AddAt(nr   ? mean/nr : -1.,0);
     364  arr->AddAt(nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0. ,1);
     365
     366  return arr;
    354367}
    355368
     
    362375// in the calculation of the size average.
    363376//
    364 Float_t MPedestalCam::GetAveragedRmsPerArea(const MGeomCam &geom, const UInt_t ai, MBadPixelsCam *bad)
     377// Returns a TArrayF of dimension 2:
     378// arr[0]: averaged pedestal RMS (default: -1.)
     379// arr[1]: Error (rms) of averaged pedestal RMS (default: 0.)
     380//
     381// ATTENTION: THE USER HAS TO DELETE THE RETURNED TARRAYF ACCORDINGLY
     382//
     383TArrayF *MPedestalCam::GetAveragedRmsPerArea(const MGeomCam &geom, const UInt_t ai, MBadPixelsCam *bad)
    365384{
    366385
    367386  const Int_t np = GetSize();
    368387
    369   Double_t rms = 0.;
    370   Int_t    nr  = 0;
     388  Double_t rms  = 0.;
     389  Double_t rms2 = 0.;
     390  Int_t    nr   = 0;
    371391
    372392  for (int i=0; i<np; i++)
     
    382402      const MPedestalPix &pix = (*this)[i];
    383403     
    384       rms += pix.GetPedestalRms();
    385       nr  ++;
    386     }
    387 
    388   return rms/nr;
     404      rms  += pix.GetPedestalRms();
     405      rms2 += pix.GetPedestalRms()*pix.GetPedestalRms();
     406      nr   ++;
     407    }
     408
     409  TArrayF *arr = new TArrayF(2);
     410  arr->AddAt(nr   ? rms/nr : -1.,0);
     411  arr->AddAt(nr>1 ? TMath::Sqrt((rms2 - rms*rms/nr)/(nr-1)) : 0. ,1);
     412
     413  return arr;
    389414}
    390415
     
    397422// in the calculation of the size average.
    398423//
    399 Float_t MPedestalCam::GetAveragedPedPerSector(const MGeomCam &geom, const UInt_t sec, MBadPixelsCam *bad)
     424// Returns a TArrayF of dimension 2:
     425// arr[0]: averaged pedestal (default: -1.)
     426// arr[1]: Error (rms) of averaged pedestal (default: 0.)
     427//
     428// ATTENTION: THE USER HAS TO DELETE THE RETURNED TARRAYF ACCORDINGLY
     429//
     430TArrayF *MPedestalCam::GetAveragedPedPerSector(const MGeomCam &geom, const UInt_t sec, MBadPixelsCam *bad)
    400431{
    401432
     
    403434
    404435  Double_t mean = 0.;
     436  Double_t mean2 = 0.;
    405437  Int_t    nr   = 0;
    406438
     
    417449      const MPedestalPix &pix = (*this)[i];
    418450     
    419       mean += pix.GetPedestal();
    420       nr   ++;
    421      
    422     }
    423 
    424   return mean/nr;
     451      mean  += pix.GetPedestal();
     452      mean2 += pix.GetPedestal()*pix.GetPedestal();
     453      nr    ++;
     454     
     455    }
     456
     457  TArrayF *arr = new TArrayF(2);
     458  arr->AddAt(nr   ? mean/nr : -1.,0);
     459  arr->AddAt(nr>1 ? TMath::Sqrt((mean2 - mean*mean/nr)/(nr-1)) : 0. ,1);
     460
     461  return arr;
    425462}
    426463
     
    433470// in the calculation of the size average.
    434471//
    435 Float_t MPedestalCam::GetAveragedRmsPerSector(const MGeomCam &geom, const UInt_t sec, MBadPixelsCam *bad)
     472// Returns a TArrayF of dimension 2:
     473// arr[0]: averaged pedestal RMS (default: -1.)
     474// arr[1]: Error (rms) of averaged pedestal RMS (default: 0.)
     475//
     476// ATTENTION: THE USER HAS TO DELETE THE RETURNED TARRAYF ACCORDINGLY
     477//
     478TArrayF *MPedestalCam::GetAveragedRmsPerSector(const MGeomCam &geom, const UInt_t sec, MBadPixelsCam *bad)
    436479{
    437480
    438481  const Int_t np = GetSize();
    439482
    440   Double_t rms = 0.;
    441   Int_t    nr  = 0;
     483  Double_t rms  = 0.;
     484  Double_t rms2 = 0.;
     485  Int_t    nr   = 0;
    442486
    443487  for (int i=0; i<np; i++)
     
    453497      const MPedestalPix &pix = (*this)[i];
    454498     
    455       rms += pix.GetPedestalRms();
    456       nr  ++;
    457      
    458     }
    459 
    460   return rms/nr;
     499      rms  += pix.GetPedestalRms();
     500      rms2 += pix.GetPedestalRms()*pix.GetPedestalRms();
     501      nr   ++;
     502     
     503    }
     504
     505  TArrayF *arr = new TArrayF(2);
     506  arr->AddAt(nr   ? rms/nr : -1.,0);
     507  arr->AddAt(nr>1 ? TMath::Sqrt((rms2 - rms*rms/nr)/(nr-1)) : 0. ,1);
     508
     509  return arr;
     510 
    461511}
    462512
  • trunk/MagicSoft/Mars/mpedestal/MPedestalCam.h

    r4784 r4794  
    1414class MPedestalPix;
    1515class MBadPixelsCam;
    16 
     16class TArrayF;
    1717class MPedestalCam : public MParContainer, public MCamEvent
    1818{
     
    4444  ULong_t             GetTotalEntries  ()                      const { return fTotalEntries; }
    4545
    46   Float_t GetAveragedPedPerArea  ( const MGeomCam &geom, const UInt_t ai=0,  MBadPixelsCam *bad=NULL );
    47   Float_t GetAveragedPedPerSector( const MGeomCam &geom, const UInt_t sec=0, MBadPixelsCam *bad=NULL ); 
    48   Float_t GetAveragedRmsPerArea  ( const MGeomCam &geom, const UInt_t ai=0,  MBadPixelsCam *bad=NULL );
    49   Float_t GetAveragedRmsPerSector( const MGeomCam &geom, const UInt_t sec=0, MBadPixelsCam *bad=NULL ); 
     46  TArrayF *GetAveragedPedPerArea  ( const MGeomCam &geom, const UInt_t ai=0,  MBadPixelsCam *bad=NULL );
     47  TArrayF *GetAveragedPedPerSector( const MGeomCam &geom, const UInt_t sec=0, MBadPixelsCam *bad=NULL ); 
     48  TArrayF *GetAveragedRmsPerArea  ( const MGeomCam &geom, const UInt_t ai=0,  MBadPixelsCam *bad=NULL );
     49  TArrayF *GetAveragedRmsPerSector( const MGeomCam &geom, const UInt_t sec=0, MBadPixelsCam *bad=NULL ); 
    5050 
    5151        MPedestalPix &operator[]       ( Int_t i             );
Note: See TracChangeset for help on using the changeset viewer.