Cat
Histo2D.cpp
Go to the documentation of this file.
1 //$Id: Histo2D.cpp,v 1.3 2006/03/16 17:08:23 fmachefe Exp $
2 //------------------------------------------------------------------------------
3 //
4 // Package : Histo2D
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 "Histo2D.h"
21 
22 Histo2D::Histo2D( TH2D *histo ) : m_zero ( 1.e-30 ) , m_infini(1.e30) {
23  //m_histo = histo;
24 
25  m_nxbins = histo->GetNbinsX();
26  m_nybins = histo->GetNbinsY();
27 
28  setTitle(std::string(histo -> GetTitle()));
29 
30  m_minX = histo->GetXaxis()->GetXmin();
31  m_maxX = histo->GetXaxis()->GetXmax();
32  m_minY = histo->GetYaxis()->GetXmin();
33  m_maxY = histo->GetYaxis()->GetXmax();
34 
35  m_minZ = histo->GetMinimum();
36  m_maxZ = histo->GetMaximum();
37 
38  unsigned long nxbin=0;
39  unsigned long nybin=0;
40  for (nybin=0;nxbin<m_nybins; ++nybin){
41  /*
42  std::vector<double> tmpbins;
43  std::vector<double> tmpxbin;
44  std::vector<double> tmpybin;
45  */
46  for (nxbin=0;nxbin<m_nxbins; ++nxbin){
47  m_bins.push_back(histo->GetBinContent(nybin*nxbin+1+2*(nybin-1)));
48  m_xcenters.push_back(histo->GetXaxis()->GetBinCenter(nxbin+1));
49  m_ycenters.push_back(histo->GetYaxis()->GetBinCenter(nybin+1));
50  }
51  /*
52  m_bins.push_back(tmpbins);
53  m_xcenters.push_back(tmpxbin);
54  m_ycenters.push_back(tmpybin);
55  */
56  }
57 
58  /*
59  m_underflow = histo->GetBinContent(0);
60  m_overflow = histo->GetBinContent(histo->GetNbinsX()+1);
61  */
62 
63  m_content = histo->GetEntries();
64  m_mean = histo->GetMean();
65  m_rms = histo->GetRMS();
66 }
67 
68 /*
69 double Histo2D::bin(double x){
70  if (x>=m_maxX) {return m_overflow;}
71  else if(x<m_minX) {return m_underflow;}
72  unsigned long bin=(unsigned long)(floor(m_nbins*(x-m_minX)/m_delta));
73  return m_bins[bin];
74 }
75 */
76 
77 void Histo2D::statistics(double &content,
78  double &mean,
79  double &rms){
80  content=m_content;
81  mean =m_mean;
82  rms =m_rms;
83 }
84 
85 
unsigned long m_nybins
Definition: Histo2D.h:110
std::vector< double > m_xcenters
Definition: Histo2D.h:119
double m_maxZ
Definition: Histo2D.h:127
double m_content
Definition: Histo2D.h:132
std::vector< double > m_ycenters
Definition: Histo2D.h:120
unsigned long m_nxbins
Definition: Histo2D.h:109
Histo2D(TH2D *histo)
Definition: Histo2D.cpp:22
double m_minZ
Definition: Histo2D.h:126
double m_maxX
Definition: Histo2D.h:123
double m_mean
Definition: Histo2D.h:133
double m_rms
Definition: Histo2D.h:134
void setTitle(std::string title)
Definition: Object.h:54
double m_minY
Definition: Histo2D.h:124
void statistics(double &, double &, double &)
Definition: Histo2D.cpp:77
double m_maxY
Definition: Histo2D.h:125
double m_minX
Definition: Histo2D.h:122
std::vector< double > m_bins
Definition: Histo2D.h:118