LIChannel Class Reference

#include <LIChannel.h>

List of all members.

Public Member Functions

 LIChannel ()
 ~LIChannel ()
void AddEntry (Int_t entries, Float_t mean, Float_t rms)
void Clean ()
Float_t GetRms ()
void SetChannelId (RawChannelId channelId)
void SetEntry (Int_t entries, Float_t mean, Float_t rms)
void SetMean (Float_t mean)
void SetNumEntries (Int_t numEntries)
void SetRms (Float_t rms)
void SetSummaryCounter (Int_t counts)
RawChannelId GetChannelId ()
RawChannelId GetRawChannelId ()
Float_t GetMean ()
Int_t GetNumEntries ()
Int_t GetSummaryCounter ()

Private Attributes

RawChannelId fChannelId
Double_t fMean
Int_t fNumEntries
Double_t fRms
Double_t fSigma1
Double_t fSigma2
Int_t fSummaryCounter

Detailed Description

Definition at line 25 of file LIChannel.h.


Constructor & Destructor Documentation

LIChannel::LIChannel (  ) 

Definition at line 29 of file LIChannel.cxx.

References fMean, fNumEntries, fRms, fSigma1, fSigma2, and fSummaryCounter.

00030 {
00031   //initialise variables
00032   fMean=0;
00033   fNumEntries=0;
00034   fRms=0;
00035   fSigma1=0;
00036   fSigma2=0;
00037   fSummaryCounter=0;
00038 }

LIChannel::~LIChannel (  ) 

Definition at line 41 of file LIChannel.cxx.

00042 {
00043   //nothing
00044 }


Member Function Documentation

void LIChannel::AddEntry ( Int_t  entries,
Float_t  mean,
Float_t  rms 
)

Definition at line 120 of file LIChannel.cxx.

References fMean, fNumEntries, fSigma1, fSigma2, fSummaryCounter, Msg::kVerbose, and MSG.

00122 {
00123   //convert to double to preserve precision
00124   Double_t rms=static_cast<Double_t>(rmsInput);
00125   Double_t mean=static_cast<Double_t>(meanInput);
00126   
00127   MSG("LIChannel",Msg::kVerbose)
00128     <<" ent="<<entries<<", mean="<<meanInput<<", rms="<<rmsInput
00129     <<endl;
00130   
00131   //protect against fpe
00132   if(entries>0){   
00133     //calcuate the sum of the sq of the new mean and the new rms
00134     //and weight it by the number of new entries
00135     fSigma1+=entries*(pow(rms,2)+pow(mean,2));
00136     
00137     //calculate weighted sum of all the means
00138     fSigma2+=mean*entries;
00139     
00140     //calculate mean by weighting existing mean and new mean
00141     fMean=fMean*fNumEntries/(fNumEntries+entries)+
00142       mean*entries/(fNumEntries+entries);
00143     
00144     //sum the number of entries in this channel
00145     fNumEntries+=entries;
00146     
00147     //count the number of summaries included
00148     fSummaryCounter++;
00149   }
00150 }

void LIChannel::Clean (  ) 

Definition at line 62 of file LIChannel.cxx.

References fChannelId, fMean, fNumEntries, fRms, fSigma1, fSigma2, and fSummaryCounter.

00063 {
00064   //reset all variables
00065   fNumEntries=0;
00066   fMean=0.;
00067   fRms=0.;
00068   fSummaryCounter=0;
00069   fSigma1=0;
00070   fSigma2=0;
00071   fChannelId=RawChannelId();//set to default
00072 }

RawChannelId LIChannel::GetChannelId (  )  [inline]

Definition at line 45 of file LIChannel.h.

References fChannelId.

00045 {return fChannelId;}

Float_t LIChannel::GetMean (  )  [inline]

Definition at line 47 of file LIChannel.h.

References fMean.

00047 {return static_cast<Float_t>(fMean);}

Int_t LIChannel::GetNumEntries (  )  [inline]

Definition at line 48 of file LIChannel.h.

References fNumEntries.

00048 {return fNumEntries;}

RawChannelId LIChannel::GetRawChannelId ( void   )  [inline]

Definition at line 46 of file LIChannel.h.

References fChannelId.

Referenced by operator<(), and operator==().

00046 {return fChannelId;}

Float_t LIChannel::GetRms (  ) 

Definition at line 87 of file LIChannel.cxx.

References fMean, fNumEntries, fRms, fSigma1, fSigma2, Msg::kVerbose, and MSG.

00088 {
00089   //calcualte the rms from the sum of 
00090   //1.) the weighted sum of the (sq of the new mean plus the sq of the
00091   //    new rms)
00092   //2.) the weighted sum of all the means
00093   
00094   //protect against fpe
00095   if (fNumEntries==0) return fRms;
00096 
00097   //calculate averages
00098   Double_t avSigma1=fSigma1/fNumEntries;
00099   Double_t avSigma2Sqd=pow(fSigma2/fNumEntries,2);
00100   
00101   //calculate average rms if possible
00102   if (avSigma1>=avSigma2Sqd){
00103     fRms=sqrt(avSigma1-avSigma2Sqd);
00104   }
00105   else{//would be imaginary
00106     fRms=0;
00107     MSG("LIChannel",Msg::kVerbose) 
00108       << "Zero rms channel (avSigma1="<<avSigma1
00109       <<" < avSigma2Sqd="<<avSigma2Sqd<<")"
00110       <<", ent="<<fNumEntries
00111       <<", fMean="<<fMean
00112       <<", fRms="<<fRms 
00113       << endl;
00114   }
00115   return static_cast<Float_t>(fRms);
00116 }

Int_t LIChannel::GetSummaryCounter (  )  [inline]

Definition at line 49 of file LIChannel.h.

References fSummaryCounter.

00049 {return fSummaryCounter;}

void LIChannel::SetChannelId ( RawChannelId  channelId  )  [inline]

Definition at line 37 of file LIChannel.h.

References fChannelId.

00037 {fChannelId=channelId;}

void LIChannel::SetEntry ( Int_t  entries,
Float_t  mean,
Float_t  rms 
)

Definition at line 76 of file LIChannel.cxx.

References fMean, fNumEntries, fRms, and fSummaryCounter.

00078 {
00079   fNumEntries=entries;
00080   fMean=static_cast<Double_t>(mean);
00081   fRms=static_cast<Double_t>(rms);
00082   fSummaryCounter=1;
00083 }

void LIChannel::SetMean ( Float_t  mean  )  [inline]

Definition at line 39 of file LIChannel.h.

References fMean.

00039 {fMean=static_cast<Double_t>(mean);}

void LIChannel::SetNumEntries ( Int_t  numEntries  )  [inline]

Definition at line 40 of file LIChannel.h.

References fNumEntries.

00040 {fNumEntries=numEntries;}

void LIChannel::SetRms ( Float_t  rms  )  [inline]

Definition at line 41 of file LIChannel.h.

References fRms.

00041 {fRms=static_cast<Double_t>(rms);}

void LIChannel::SetSummaryCounter ( Int_t  counts  )  [inline]

Definition at line 42 of file LIChannel.h.

References fSummaryCounter.

00042 {fSummaryCounter=counts;}


Member Data Documentation

Definition at line 53 of file LIChannel.h.

Referenced by Clean(), GetChannelId(), GetRawChannelId(), and SetChannelId().

Double_t LIChannel::fMean [private]

Definition at line 54 of file LIChannel.h.

Referenced by AddEntry(), Clean(), GetMean(), GetRms(), LIChannel(), SetEntry(), and SetMean().

Int_t LIChannel::fNumEntries [private]

Definition at line 55 of file LIChannel.h.

Referenced by AddEntry(), Clean(), GetNumEntries(), GetRms(), LIChannel(), SetEntry(), and SetNumEntries().

Double_t LIChannel::fRms [private]

Definition at line 56 of file LIChannel.h.

Referenced by Clean(), GetRms(), LIChannel(), SetEntry(), and SetRms().

Double_t LIChannel::fSigma1 [private]

Definition at line 57 of file LIChannel.h.

Referenced by AddEntry(), Clean(), GetRms(), and LIChannel().

Double_t LIChannel::fSigma2 [private]

Definition at line 58 of file LIChannel.h.

Referenced by AddEntry(), Clean(), GetRms(), and LIChannel().

Int_t LIChannel::fSummaryCounter [private]

Definition at line 59 of file LIChannel.h.

Referenced by AddEntry(), Clean(), GetSummaryCounter(), LIChannel(), SetEntry(), and SetSummaryCounter().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1