Cat
Histo1D.cpp
Go to the documentation of this file.
1 //$Id: Histo1D.cpp,v 1.3 2006/03/16 17:08:23 fmachefe Exp $
2 //------------------------------------------------------------------------------
3 //
4 // Package : Histo1D
5 //
6 // Description:
7 //
8 // Author(s) : F. Machefert -
9 // Date : 5 March 2004
10 //
11 //------------------------------------------------------------------------------
12 
13 // include files
14 #include <math.h>
15 
16 // CATCore include Files
17 #include "Tools.h"
18 
19 // local include file
20 #include "Histo1D.h"
21 
22 Histo1D::Histo1D( TH1D *histo ) : m_zero ( 1.e-30 ) , m_infini(1.e30) {
23  //m_histo = histo;
24 
25  m_nbins = histo->GetNbinsX();
26 
27  setTitle(std::string(histo -> GetTitle()));
28 
29  m_bins.resize (m_nbins,0.);
30  m_centers.resize (m_nbins,0.);
31  m_edges.resize (m_nbins+1,0.);
32 
33  unsigned long nbin=0;
34  for (nbin=0;nbin<m_nbins; ++nbin){
35  m_bins[nbin]=histo->GetBinContent(nbin+1);
36  m_centers[nbin]=histo->GetBinCenter(nbin+1);
37  }
38 
39  m_delta = histo->GetBinWidth(0);
40 
41  for (nbin=0;nbin<m_nbins+1; ++nbin){
42  m_edges[nbin]=histo->GetBinLowEdge(1)+nbin*m_delta;
43  }
44 
45  m_underflow = histo->GetBinContent(0);
46  m_overflow = histo->GetBinContent(histo->GetNbinsX()+1);
47 
48  m_minX = histo->GetBinLowEdge(1);
49  m_maxX = histo->GetBinLowEdge(histo->GetNbinsX()+1);
50 
51  m_minY = histo->GetMinimum();
52  m_maxY = histo->GetMaximum();
53 
54  m_content = histo->GetEntries();
55  m_mean = histo->GetMean();
56  m_rms = histo->GetRMS();
57 }
58 
59 double Histo1D::bin(double x){
60  if (x>=m_maxX) {return m_overflow;}
61  else if(x<m_minX) {return m_underflow;}
62  unsigned long bin=(unsigned long)(floor(m_nbins*(x-m_minX)/m_delta));
63  return m_bins[bin];
64 }
65 
66 double Histo1D::minY(){
67  return m_minY;
68 }
69 
70 double Histo1D::maxY(){
71  return m_maxY;
72 }
73 
74 double Histo1D::binEdgeMin( unsigned int bin ){
75  return m_minX+bin*(m_delta);
76 }
77 
78 double Histo1D::binEdgeMax ( unsigned int bin ){
79  return m_minX+(bin+1)*(m_delta);
80 }
81 
82 void Histo1D::statistics(double &content,
83  double &mean,
84  double &rms){
85  content=m_content;
86  mean =m_mean;
87  rms =m_rms;
88 }
89 
90 
double m_rms
Definition: Histo1D.h:104
double m_delta
Definition: Histo1D.h:97
double maxY()
Definition: Histo1D.cpp:70
void statistics(double &, double &, double &)
Definition: Histo1D.cpp:82
double m_maxX
Definition: Histo1D.h:94
double m_underflow
Definition: Histo1D.h:100
double binEdgeMax(unsigned int)
Definition: Histo1D.cpp:78
double minY()
Definition: Histo1D.cpp:66
double m_maxY
Definition: Histo1D.h:96
double m_minY
Definition: Histo1D.h:95
double binEdgeMin(unsigned int)
Definition: Histo1D.cpp:74
double m_overflow
Definition: Histo1D.h:99
double m_mean
Definition: Histo1D.h:103
unsigned long m_nbins
Definition: Histo1D.h:88
void setTitle(std::string title)
Definition: Object.h:54
std::vector< double > m_centers
Definition: Histo1D.h:90
Histo1D(TH1D *histo)
Definition: Histo1D.cpp:22
double m_minX
Definition: Histo1D.h:93
std::vector< double > m_bins
Definition: Histo1D.h:89
double bin(double x)
Definition: Histo1D.cpp:59
std::vector< double > m_edges
Definition: Histo1D.h:91
double m_content
Definition: Histo1D.h:102