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

Detailed Description

Definition at line 21 of file CountHist.h.


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 = ""  ) 
void Anp::CountHist::Fill ( double  value,
double  weight_all,
double  weight_sel 
)

Definition at line 36 of file CountHist.cxx.

References hall, hsel, and Valid().

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.

References iactn.

00174 {
00175    return iactn;
00176 }

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

Definition at line 167 of file CountHist.cxx.

References particle.

00168 {
00169    return particle;
00170 }

int Anp::CountHist::GetReson (  )  const

Definition at line 179 of file CountHist.cxx.

References reson.

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.

References verbose.

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, hrat, and hsel.

Referenced by Fill().

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


Member Data Documentation

Definition at line 45 of file CountHist.h.

Referenced by Fill(), and Valid().

Definition at line 47 of file CountHist.h.

Referenced by Valid().

Definition at line 46 of file CountHist.h.

Referenced by Fill(), and Valid().

Definition at line 53 of file CountHist.h.

Referenced by GetInteraction().

Definition at line 49 of file CountHist.h.

Definition at line 51 of file CountHist.h.

Referenced by GetParticle().

Definition at line 54 of file CountHist.h.

Referenced by GetReson().

Definition at line 56 of file CountHist.h.

Referenced by SetRatio().


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

Generated on 16 Jan 2018 for loon by  doxygen 1.6.1