AtNuResBayesPdf Class Reference

#include <AtNuResBayesPdf.h>

List of all members.

Public Member Functions

 AtNuResBayesPdf (Int_t fbins, Double_t fmin, Double_t fmax)
 ~AtNuResBayesPdf ()
Int_t GetBins ()
Double_t GetMin ()
Double_t GetMax ()
Int_t GetBin (Double_t x)
Double_t GetCenter (Int_t bin)
Double_t GetTotalWeight ()
Double_t GetWeight (Int_t bin)
Double_t GetWeight (Double_t x)
Double_t GetMean ()
Double_t GetRMS ()
void Fill (Double_t x, Double_t weight)
void Reset ()
TH1D * MakeTH1D (const char *histname, Bool_t renormalise=1)

Private Attributes

Int_t fBins
Double_t fMin
Double_t fMax
Double_t fSw
Double_t fSwx
Double_t fSwx2
Double_t fWeight
Double_t * fPdf

Detailed Description

Definition at line 8 of file AtNuResBayesPdf.h.


Constructor & Destructor Documentation

AtNuResBayesPdf::AtNuResBayesPdf ( Int_t  fbins,
Double_t  fmin,
Double_t  fmax 
)

Definition at line 8 of file AtNuResBayesPdf.cxx.

References n.

00009 {
00010   fBins = fbins;
00011   fMin = fmin;
00012   fMax = fmax;
00013 
00014   fSw = 0.0;
00015   fSwx = 0.0;
00016   fSwx2 = 0.0;
00017   fWeight = 0.0;
00018 
00019   fPdf = new Double_t[fBins];
00020 
00021   for( Int_t n=0; n<fBins; n++ ){
00022     fPdf[n] = 0.0;
00023   }
00024 }

AtNuResBayesPdf::~AtNuResBayesPdf (  ) 

Definition at line 26 of file AtNuResBayesPdf.cxx.

References fPdf.

00027 {
00028   delete [] fPdf;
00029 }


Member Function Documentation

void AtNuResBayesPdf::Fill ( Double_t  x,
Double_t  weight 
)

Definition at line 79 of file AtNuResBayesPdf.cxx.

References fBins, fPdf, fSw, fSwx, fSwx2, fWeight, and GetBin().

Referenced by AtNuResolution::AddToBayesPdf().

00080 {
00081   Int_t bin = this->GetBin(x);
00082 
00083   if( bin>=0 && bin<fBins ){
00084     fPdf[bin] += weight;
00085   }
00086 
00087   fSw += weight;
00088   fSwx += weight*x;
00089   fSwx2 += weight*x*x;
00090   fWeight += weight;
00091 
00092   return;
00093 }

Int_t AtNuResBayesPdf::GetBin ( Double_t  x  )  [inline]

Definition at line 18 of file AtNuResBayesPdf.h.

References fBins, fMax, and fMin.

Referenced by Fill(), and GetWeight().

00018 { return (Int_t)(fBins*(x-fMin)/(fMax-fMin)); }

Int_t AtNuResBayesPdf::GetBins (  )  [inline]

Definition at line 14 of file AtNuResBayesPdf.h.

References fBins.

00014 { return fBins; }

Double_t AtNuResBayesPdf::GetCenter ( Int_t  bin  )  [inline]

Definition at line 19 of file AtNuResBayesPdf.h.

References fBins, fMax, and fMin.

00019 { return fMin+((bin+0.5)/fBins)*(fMax-fMin); }

Double_t AtNuResBayesPdf::GetMax (  )  [inline]

Definition at line 16 of file AtNuResBayesPdf.h.

References fMax.

00016 { return fMax; }

Double_t AtNuResBayesPdf::GetMean (  ) 

Definition at line 49 of file AtNuResBayesPdf.cxx.

References fSw, and fSwx.

00050 {
00051   if( fSw>0.0 ){
00052     return fSwx/fSw;
00053   }
00054   else return -999.9;
00055 }

Double_t AtNuResBayesPdf::GetMin (  )  [inline]

Definition at line 15 of file AtNuResBayesPdf.h.

References fMin.

00015 { return fMin; }

Double_t AtNuResBayesPdf::GetRMS (  ) 

Definition at line 57 of file AtNuResBayesPdf.cxx.

References fSw, fSwx, and fSwx2.

Referenced by AtNuResolution::GetResolutionCV().

00058 {
00059   if( fSwx2*fSw>fSwx*fSwx ){
00060     return sqrt( (fSwx2/fSw)-(fSwx/fSw)*(fSwx/fSw) );
00061   }
00062   else return -999.9;
00063 }

Double_t AtNuResBayesPdf::GetTotalWeight (  )  [inline]

Definition at line 20 of file AtNuResBayesPdf.h.

References fWeight.

Referenced by AtNuResolution::GetResolutionCV().

00020 { return fWeight; }

Double_t AtNuResBayesPdf::GetWeight ( Double_t  x  ) 

Definition at line 42 of file AtNuResBayesPdf.cxx.

References GetBin(), and GetWeight().

00043 {
00044   Int_t bin = this->GetBin(x);
00045 
00046   return this->GetWeight(bin);
00047 }

Double_t AtNuResBayesPdf::GetWeight ( Int_t  bin  ) 

Definition at line 31 of file AtNuResBayesPdf.cxx.

References fBins, and fPdf.

Referenced by GetWeight().

00032 { 
00033   Double_t weight = 0.0;
00034 
00035   if( bin>=0 && bin<fBins ){
00036     weight = fPdf[bin];
00037   }
00038 
00039   return weight;
00040 }

TH1D * AtNuResBayesPdf::MakeTH1D ( const char *  histname,
Bool_t  renormalise = 1 
)

Definition at line 95 of file AtNuResBayesPdf.cxx.

References fBins, fMax, fMin, fPdf, max, and n.

Referenced by AtNuResolution::GetResolutionPdf().

00096 {
00097   TH1D* newpdf = new TH1D(histname,histname,fBins,fMin,fMax);
00098 
00099   for( Int_t n=0; n<fBins; n++ ){
00100     newpdf->SetBinContent(n+1,fPdf[n]);
00101   }
00102 
00103   if( renormalize ){
00104     Double_t max = 0.0;
00105     for( Int_t n=0; n<newpdf->GetXaxis()->GetNbins(); n++ ){
00106       if( newpdf->GetBinContent(n+1)>max ){
00107         max = newpdf->GetBinContent(n+1);
00108       }
00109     }
00110     if( max>0.0 ){
00111       newpdf->Scale(1.0/max);
00112     }
00113   }
00114 
00115   return newpdf;
00116 }

void AtNuResBayesPdf::Reset (  ) 

Definition at line 65 of file AtNuResBayesPdf.cxx.

References fBins, fPdf, fSw, fSwx, fSwx2, fWeight, and n.

Referenced by AtNuResolution::GetResolutionCV(), and AtNuResolution::GetResolutionUPMU().

00066 {
00067   for( Int_t n=0; n<fBins; n++ ){
00068     fPdf[n] = 0.0;
00069   }
00070  
00071   fSw = 0.0;
00072   fSwx = 0.0;
00073   fSwx2 = 0.0;
00074   fWeight = 0.0;
00075 
00076   return;
00077 }


Member Data Documentation

Int_t AtNuResBayesPdf::fBins [private]

Definition at line 34 of file AtNuResBayesPdf.h.

Referenced by Fill(), GetBin(), GetBins(), GetCenter(), GetWeight(), MakeTH1D(), and Reset().

Double_t AtNuResBayesPdf::fMax [private]

Definition at line 36 of file AtNuResBayesPdf.h.

Referenced by GetBin(), GetCenter(), GetMax(), and MakeTH1D().

Double_t AtNuResBayesPdf::fMin [private]

Definition at line 35 of file AtNuResBayesPdf.h.

Referenced by GetBin(), GetCenter(), GetMin(), and MakeTH1D().

Double_t* AtNuResBayesPdf::fPdf [private]

Definition at line 43 of file AtNuResBayesPdf.h.

Referenced by Fill(), GetWeight(), MakeTH1D(), Reset(), and ~AtNuResBayesPdf().

Double_t AtNuResBayesPdf::fSw [private]

Definition at line 38 of file AtNuResBayesPdf.h.

Referenced by Fill(), GetMean(), GetRMS(), and Reset().

Double_t AtNuResBayesPdf::fSwx [private]

Definition at line 39 of file AtNuResBayesPdf.h.

Referenced by Fill(), GetMean(), GetRMS(), and Reset().

Double_t AtNuResBayesPdf::fSwx2 [private]

Definition at line 40 of file AtNuResBayesPdf.h.

Referenced by Fill(), GetRMS(), and Reset().

Double_t AtNuResBayesPdf::fWeight [private]

Definition at line 41 of file AtNuResBayesPdf.h.

Referenced by Fill(), GetTotalWeight(), and Reset().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1