OscFit::Binning Class Reference

#include <Binning.h>

List of all members.

Public Member Functions

 Binning (const char *xtitle, Int_t xbins, Double_t *xedges)
 Binning (const char *xtitle, Int_t xbins, Double_t *xedges, const char *ytitle, Int_t ybins, Double_t *yedges)
 ~Binning ()
Int_t GetNbins ()
Int_t GetNbinsX ()
Int_t GetNbinsY ()
Int_t FindBin (Double_t x, Double_t y=0)
Int_t GetBinNumber (Int_t x, Int_t y=0)
void PrintBinningScheme ()
TH1D * MakeTH1D (const char *histName)
TH2D * MakeTH2D (const char *histName)
Int_t FindBinX (Double_t x)
Int_t FindBinY (Double_t y)

Public Attributes

Int_t fXbins
Double_t * fXedges
Int_t fYbins
Double_t * fYedges
TString fXtitle
TString fYtitle

Detailed Description

Definition at line 12 of file Binning.h.


Constructor & Destructor Documentation

Binning::Binning ( const char *  xtitle,
Int_t  xbins,
Double_t *  xedges 
)

Definition at line 8 of file Binning.cxx.

References fXbins, fXedges, fXtitle, fYbins, fYedges, and fYtitle.

00009 {
00010   fXbins = xbins;
00011   fXedges = new Double_t[fXbins+1];
00012   fXtitle = xtitle;
00013   
00014   for( Int_t ibin=0; ibin<fXbins+1; ibin++ ){
00015     fXedges[ibin] = xedges[ibin];
00016   }
00017 
00018   fYbins = 1;
00019   fYedges = new Double_t[2];
00020   fYedges[0] = -1.0e6;
00021   fYedges[1] = +1.0e6;
00022   fYtitle = "";
00023 }

Binning::Binning ( const char *  xtitle,
Int_t  xbins,
Double_t *  xedges,
const char *  ytitle,
Int_t  ybins,
Double_t *  yedges 
)

Definition at line 25 of file Binning.cxx.

References fXbins, fXedges, fXtitle, fYbins, fYedges, and fYtitle.

00026 {
00027   fXbins = xbins;
00028   fXedges = new Double_t[fXbins+1];
00029   fXtitle = xtitle;
00030 
00031   for( Int_t ibin=0; ibin<fXbins+1; ibin++ ){
00032     fXedges[ibin] = xedges[ibin];
00033   } 
00034 
00035   fYbins = ybins;
00036   fYedges = new Double_t[fYbins+1];
00037   fYtitle = ytitle;
00038 
00039   for( Int_t ibin=0; ibin<fYbins+1; ibin++ ){
00040     fYedges[ibin] = yedges[ibin];
00041   }
00042 }

Binning::~Binning (  ) 

Definition at line 44 of file Binning.cxx.

References fXedges, and fYedges.

00045 {
00046   if( fXedges ) delete [] fXedges;
00047   if( fYedges ) delete [] fYedges;
00048 }


Member Function Documentation

Int_t Binning::FindBin ( Double_t  x,
Double_t  y = 0 
)

Definition at line 72 of file Binning.cxx.

References FindBinX(), FindBinY(), and GetBinNumber().

Referenced by OscFit::Histogram::Fill2D().

00073 {
00074   Int_t binX = FindBinX(x);
00075   Int_t binY = FindBinY(y);
00076 
00077   return GetBinNumber(binX,binY);
00078 }

Int_t Binning::FindBinX ( Double_t  x  ) 

Definition at line 50 of file Binning.cxx.

References fXbins, and fXedges.

Referenced by FindBin().

00051 { 
00052   for( Int_t ibin=0; ibin<fXbins; ibin++ ){
00053     if( x>=fXedges[ibin] && x<fXedges[ibin+1] ){
00054       return ibin;
00055     }
00056   }
00057 
00058   return -1;
00059 }

Int_t Binning::FindBinY ( Double_t  y  ) 

Definition at line 61 of file Binning.cxx.

References fYbins, and fYedges.

Referenced by FindBin().

00062 { 
00063   for( Int_t ibin=0; ibin<fYbins; ibin++ ){
00064     if( y>=fYedges[ibin] && y<fYedges[ibin+1] ){
00065       return ibin;
00066     }
00067   }
00068 
00069   return -1;
00070 }

Int_t Binning::GetBinNumber ( Int_t  x,
Int_t  y = 0 
)

Definition at line 80 of file Binning.cxx.

References fXbins, and fYbins.

Referenced by FindBin(), OscFit::Histogram::MakeTH1D(), and OscFit::Histogram::MakeTH2D().

00081 {
00082   if( x>=0 && x<fXbins
00083    && y>=0 && y<fYbins ){
00084     return x + fXbins*y;
00085   }
00086 
00087   return -1;
00088 }

Int_t OscFit::Binning::GetNbins (  )  [inline]

Definition at line 20 of file Binning.h.

References fXbins, and fYbins.

Referenced by OscFit::Histogram::GetNbins().

00020 { return fXbins*fYbins; }

Int_t OscFit::Binning::GetNbinsX (  )  [inline]

Definition at line 21 of file Binning.h.

References fXbins.

Referenced by OscFit::BinningScheme::CheckBinning(), OscFit::Histogram::MakeTH1D(), and OscFit::Histogram::MakeTH2D().

00021 { return fXbins; }

Int_t OscFit::Binning::GetNbinsY (  )  [inline]

Definition at line 22 of file Binning.h.

References fYbins.

Referenced by OscFit::BinningScheme::CheckBinning(), OscFit::Histogram::Fill(), and OscFit::Histogram::MakeTH2D().

00022 { return fYbins; }

TH1D * Binning::MakeTH1D ( const char *  histName  ) 

Definition at line 90 of file Binning.cxx.

References fXbins, fXedges, fXtitle, and fYbins.

Referenced by OscFit::Histogram::MakeTH1D().

00091 {
00092   if( fYbins>1 ) return 0;
00093 
00094   TH1D* hNew = new TH1D(histName,"",fXbins,fXedges);
00095   hNew->GetXaxis()->SetTitle(fXtitle.Data());
00096   hNew->GetXaxis()->CenterTitle();
00097 
00098   return hNew;
00099 }

TH2D * Binning::MakeTH2D ( const char *  histName  ) 

Definition at line 101 of file Binning.cxx.

References fXbins, fXedges, fXtitle, fYbins, fYedges, and fYtitle.

Referenced by OscFit::Histogram::MakeTH2D().

00102 {
00103   TH2D* hNew = new TH2D(histName,"",fXbins,fXedges,
00104                                     fYbins,fYedges);
00105   hNew->GetXaxis()->SetTitle(fXtitle.Data());
00106   hNew->GetYaxis()->SetTitle(fYtitle.Data());
00107   hNew->GetXaxis()->CenterTitle();
00108   hNew->GetYaxis()->CenterTitle();
00109 
00110   return hNew;
00111 }

void Binning::PrintBinningScheme (  ) 

Definition at line 113 of file Binning.cxx.

References fXbins, fXedges, fXtitle, fYbins, fYedges, fYtitle, and n.

Referenced by OscFit::BinningScheme::TestBinningScheme().

00114 {
00115   std::cout << " *** Binning::PrintBinningScheme() *** " << std::endl;
00116 
00117   if( fXbins>1 ){
00118     std::cout << "  X-axis (" << fXtitle.Data() << "):" << std::endl;
00119     for( Int_t n=0; n<fXbins+1; n++ ){
00120       std::cout << "   [" << n << "] " << fXedges[n] << std::endl;
00121     }
00122   }
00123 
00124   if( fYbins>1 ){
00125     std::cout << "  Y-axis (" << fYtitle.Data() << "): " << std::endl;
00126     for( Int_t n=0; n<fYbins+1; n++ ){
00127       std::cout << "   [" << n << "] " << fYedges[n] << std::endl;
00128     }
00129   }
00130 }


Member Data Documentation

Definition at line 43 of file Binning.h.

Referenced by Binning(), MakeTH1D(), MakeTH2D(), and PrintBinningScheme().

Definition at line 41 of file Binning.h.

Referenced by Binning(), FindBinY(), MakeTH2D(), PrintBinningScheme(), and ~Binning().

Definition at line 44 of file Binning.h.

Referenced by Binning(), MakeTH2D(), and PrintBinningScheme().


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

Generated on 3 Oct 2018 for loon by  doxygen 1.6.1