Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Anp::CountHist Class Reference

#include <CountHist.h>

Inheritance diagram for Anp::CountHist:

Anp::Base List of all members.

Public Member Functions

 CountHist (int iactn_, int reson_, Particle::Particle_t particle_)
virtual ~CountHist ()
void Fill (double value, double weight_all, double weight_sel)
TH1 * ComputeRatio (const std::string &option="")
bool SetRatio (TH1 *hN, TH1 *hD, TH1 *hR)
TH1 * Refill (Hist1d< double > &hist, TH1 *hO)
bool Valid () const
Particle::Particle_t GetParticle () const
int GetInteraction () const
int GetReson () const

Public Attributes

TH1 * hall
TH1 * hsel
TH1 * hrat
double nmin
Particle::Particle_t particle
int iactn
int reson
bool verbose

Constructor & Destructor Documentation

Anp::CountHist::CountHist int  iactn_,
int  reson_,
Particle::Particle_t  particle_
 

Definition at line 18 of file CountHist.cxx.

00019    :hall(0),
00020     hsel(0),
00021     hrat(0),
00022     nmin(1000.0),
00023     particle(particle_),
00024     iactn(iactn_),
00025     reson(reson_),
00026     verbose(false)
00027 {
00028 }

Anp::CountHist::~CountHist  )  [virtual]
 

Definition at line 31 of file CountHist.cxx.

00032 {
00033 }


Member Function Documentation

TH1 * Anp::CountHist::ComputeRatio const std::string &  option = ""  ) 
 

Definition at line 53 of file CountHist.cxx.

References DirectoryHelpers::GetDirectory(), Nav::GetName(), hall, hrat, hsel, Anp::Hist1d< T >::Merge(), nmin, option, Anp::SetDir(), SetRatio(), and Valid().

00054 {
00055    if(!Valid())
00056    {
00057       return 0;
00058    }
00059 
00060    CountHist::SetRatio(hsel, hall, hrat);
00061 
00062    if(option.find("merge") != string::npos && nmin > 0.0)
00063    {
00064       Anp::Hist1d<double> hist(*hsel);
00065       hist.Merge(nmin);
00066 
00067       TH1 *HAll = CountHist::Refill(hist, hall);
00068       TH1 *HSel = CountHist::Refill(hist, hsel);
00069       TH1 *HRat = CountHist::Refill(hist, hrat);
00070       
00071       const string name = std::string(hrat -> GetName()) + "_merge";
00072 
00073       HRat -> Reset();
00074       Anp::SetDir(HRat, hrat -> GetDirectory(), name);
00075 
00076       SetRatio(HSel, HAll, HRat);
00077 
00078       delete HAll;
00079       delete HSel;
00080    }  
00081 
00082    return hrat;
00083 }

void Anp::CountHist::Fill double  value,
double  weight_all,
double  weight_sel
 

Definition at line 36 of file CountHist.cxx.

References hall, and hsel.

00037 {
00038    if(!CountHist::Valid())
00039    {
00040       return;
00041    }
00042 
00043    if(weight_all < 0.0 || weight_sel < 0.0)
00044    {
00045       cerr << "CountHist::Fill - event with negative weight" << endl;
00046    }
00047 
00048    hall -> Fill(value, weight_all);
00049    hsel -> Fill(value, weight_sel);
00050 }

int Anp::CountHist::GetInteraction  )  const
 

Definition at line 173 of file CountHist.cxx.

00174 {
00175    return iactn;
00176 }

Particle::Particle_t Anp::CountHist::GetParticle  )  const
 

Definition at line 167 of file CountHist.cxx.

00168 {
00169    return particle;
00170 }

int Anp::CountHist::GetReson  )  const
 

Definition at line 179 of file CountHist.cxx.

00180 {
00181    return reson;
00182 }

TH1 * Anp::CountHist::Refill Hist1d< double > &  hist,
TH1 *  hO
 

Definition at line 133 of file CountHist.cxx.

References Anp::Hist1d< T >::Fill(), Nav::GetName(), Anp::Hist1d< T >::Reset(), and Anp::SetDir().

00134 {
00135    if(!hO)
00136    {
00137       return 0;
00138    }
00139 
00140    hist.Reset();
00141    hist.Fill(*hO);
00142    
00143    TH1 *hN = Anp::CreateTH1<double>(hist, hO -> GetName());
00144    Anp::SetDir(hN, 0, hO -> GetName());
00145 
00146    hN -> SetTitle(hO -> GetTitle());
00147    hN -> GetXaxis() -> SetTitle(hO -> GetXaxis() -> GetTitle());
00148    hN -> GetYaxis() -> SetTitle(hO -> GetYaxis() -> GetTitle());
00149    hN -> GetXaxis() -> CenterTitle();
00150    hN -> GetYaxis() -> CenterTitle();
00151 
00152    return hN;
00153 }

bool Anp::CountHist::SetRatio TH1 *  hN,
TH1 *  hD,
TH1 *  hR
 

Definition at line 86 of file CountHist.cxx.

Referenced by ComputeRatio().

00087 {
00088    if(!hN || !hD || !hR)
00089    {
00090       return false;
00091    }
00092 
00093    const int nbin = hN -> GetNbinsX();
00094    
00095    if(hD -> GetNbinsX() != nbin)
00096    {
00097       cerr << "CountHist::SetRatio - mismatched number of bins" << endl;
00098       return false;
00099    }
00100 
00101    for(int ibin = 1; ibin <= nbin; ++ibin)
00102    {      
00103       const double valueN = hN -> GetBinContent(ibin);
00104       const double valueD = hD -> GetBinContent(ibin);
00105 
00106       if(!(valueN > 0.0) || !(valueD > 0.0))
00107       {
00108          continue;
00109       }
00110 
00111       if(valueD < valueN)
00112       {
00113          if(verbose)
00114          {
00115          cerr << "CountHist::SetRatio - denominator is smaller than nominator " 
00116               << valueN << "/" << valueD << " = " << valueN/valueD << endl;
00117          }
00118 
00119          continue;
00120       }
00121 
00122       const double ratio = valueN/valueD;           
00123       const double error = std::sqrt(valueN*(1.0 - valueN/valueD))/valueD;
00124 
00125       hR -> SetBinContent(ibin, ratio);
00126       hR -> SetBinError(ibin, error);
00127    }   
00128 
00129    return true;
00130 }

bool Anp::CountHist::Valid  )  const
 

Definition at line 156 of file CountHist.cxx.

References hall, and hsel.

Referenced by ComputeRatio().

00157 {
00158    if(hall && hsel && hrat)
00159    {
00160       return true;
00161    }
00162 
00163    return false;
00164 }


Member Data Documentation

TH1* Anp::CountHist::hall
 

Definition at line 45 of file CountHist.h.

Referenced by ComputeRatio(), Fill(), and Valid().

TH1* Anp::CountHist::hrat
 

Definition at line 47 of file CountHist.h.

Referenced by ComputeRatio().

TH1* Anp::CountHist::hsel
 

Definition at line 46 of file CountHist.h.

Referenced by ComputeRatio(), Fill(), and Valid().

int Anp::CountHist::iactn
 

Definition at line 53 of file CountHist.h.

double Anp::CountHist::nmin
 

Definition at line 49 of file CountHist.h.

Referenced by ComputeRatio().

Particle::Particle_t Anp::CountHist::particle
 

Definition at line 51 of file CountHist.h.

int Anp::CountHist::reson
 

Definition at line 54 of file CountHist.h.

bool Anp::CountHist::verbose
 

Definition at line 56 of file CountHist.h.


The documentation for this class was generated from the following files:
Generated on Mon Feb 15 11:10:32 2010 for loon by  doxygen 1.3.9.1