All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Gaudi::Histogram2D Class Reference

AIDA implementation for 2 D histograms using ROOT THD2. More...

#include <src/HistogramSvc/H2D.h>

Inheritance diagram for Gaudi::Histogram2D:
Collaboration diagram for Gaudi::Histogram2D:

Public Member Functions

 Histogram2D ()
 Standard Constructor. More...
 
 Histogram2D (TH2D *rep)
 Standard initializing Constructor with TH2D representation to be adopted. More...
 
virtual ~Histogram2D ()
 Destructor. More...
 
bool fill (double x, double y, double weight=1.)
 Fill the Histogram2D with a value and the. More...
 
virtual bool setBinContents (int binIndexX, int binIndexY, int entries, double height, double error, double centreX, double centreY)
 Fast filling method for a given bin. It can be also the over/underflow bin. More...
 
bool setRms (double rmsX, double rmsY)
 Sets the rms of the histogram. More...
 
bool reset ()
 
void copyFromAida (const IHistogram2D &h)
 Create new histogram from any AIDA based histogram. More...
 
virtual const CLIDclID () const
 Retrieve reference to class defininition identifier. More...
 
- Public Member Functions inherited from DataObject
 DataObject ()
 Standard Constructor. More...
 
 DataObject (const DataObject &)
 Copy Constructor. More...
 
virtual ~DataObject ()
 Standard Destructor. More...
 
virtual unsigned long addRef ()
 Add reference to object. More...
 
virtual unsigned long release ()
 release reference to object More...
 
const std::string & name () const
 Retreive DataObject name. It is the name when registered in the store. More...
 
virtual StatusCode update ()
 Provide empty placeholder for internal object reconfiguration callback. More...
 
void setRegistry (IRegistry *pRegistry)
 Set pointer to Registry. More...
 
IRegistryregistry () const
 Get pointer to Registry. More...
 
LinkManagerlinkMgr () const
 Retrieve Link manager. More...
 
unsigned char version () const
 Retrieve version number of this object representation. More...
 
void setVersion (unsigned char vsn)
 Set version number of this object representation. More...
 
unsigned long refCount () const
 Return the refcount. More...
 
virtual std::ostream & fillStream (std::ostream &s) const
 Fill the output stream (ASCII) More...
 
- Public Member Functions inherited from Gaudi::Generic2D< INTERFACE, IMPLEMENTATION >
 Generic2D ()
 
virtual ~Generic2D ()
 Destructor. More...
 
TObject * representation () const
 ROOT object implementation. More...
 
virtual void adoptRepresentation (TObject *rep)
 Adopt ROOT histogram representation. More...
 
virtual std::string title () const
 Get the title of the object. More...
 
virtual bool setTitle (const std::string &title)
 Set the title of the object. More...
 
std::string name () const
 object name More...
 
bool setName (const std::string &newName)
 Set the name of the object. More...
 
virtual AIDA::IAnnotation & annotation ()
 Access annotation object. More...
 
virtual const AIDA::IAnnotation & annotation () const
 Access annotation object (cons) More...
 
virtual const AIDA::IAxis & xAxis () const
 Return the X axis. More...
 
virtual const AIDA::IAxis & yAxis () const
 Return the Y axis. More...
 
virtual int rIndexX (int index) const
 operator methods More...
 
virtual int rIndexY (int index) const
 operator methods More...
 
virtual int entries () const
 Get the number or all the entries. More...
 
virtual int allEntries () const
 Get the number or all the entries, both in range and underflow/overflow bins of the IProfile. More...
 
virtual int extraEntries () const
 Get the number of entries in the underflow and overflow bins. More...
 
virtual double sumBinHeights () const
 Get the sum of in range bin heights in the IProfile. More...
 
virtual double sumAllBinHeights () const
 Get the sum of all the bins heights (including underflow and overflow bin). More...
 
virtual double sumExtraBinHeights () const
 Get the sum of the underflow and overflow bin height. More...
 
virtual double minBinHeight () const
 Get the minimum height of the in-range bins. More...
 
virtual double maxBinHeight () const
 Get the maximum height of the in-range bins. More...
 
virtual double binMeanX (int indexX, int indexY) const
 The weighted mean along x of a given bin. More...
 
virtual double binMeanY (int indexX, int indexY) const
 The weighted mean along y of a given bin. More...
 
virtual int binEntries (int indexX, int indexY) const
 The number of entries (ie the number of times fill was called for this bin). More...
 
virtual int binEntriesX (int indexX) const
 Equivalent to projectionX().binEntries(indexX). More...
 
virtual int binEntriesY (int indexY) const
 Equivalent to projectionY().binEntries(indexY). More...
 
virtual double binHeight (int indexX, int indexY) const
 Total height of the corresponding bin (ie the sum of the weights in this bin). More...
 
virtual double binHeightX (int indexX) const
 Equivalent to projectionX().binHeight(indexX). More...
 
virtual double binHeightY (int indexY) const
 Equivalent to projectionY().binHeight(indexY). More...
 
virtual double binError (int indexX, int indexY) const
 The error on this bin. More...
 
virtual double binRms (int indexX, int indexY) const
 The spread (RMS) of this bin. More...
 
virtual double meanX () const
 Returns the mean of the profile, as calculated on filling-time projected on the X axis. More...
 
virtual double meanY () const
 Returns the mean of the profile, as calculated on filling-time projected on the Y axis. More...
 
virtual double rmsX () const
 Returns the rms of the profile as calculated on filling-time projected on the X axis. More...
 
virtual double rmsY () const
 Returns the rms of the profile as calculated on filling-time projected on the Y axis. More...
 
virtual int coordToIndexX (double coordX) const
 Convenience method, equivalent to xAxis().coordToIndex(coord). More...
 
virtual int coordToIndexY (double coordY) const
 Convenience method, equivalent to yAxis().coordToIndex(coord). More...
 
virtual double equivalentBinEntries () const
 Number of equivalent entries, i.e. SUM[ weight ] ^ 2 / SUM[ weight^2 ] More...
 
virtual bool scale (double scaleFactor)
 Scale the weights and the errors of all the IHistogram's bins (in-range and out-of-range ones) by a given scale factor. More...
 
virtual bool add (const INTERFACE &h)
 Modifies this profile by adding the contents of profile to it. More...
 
bool reset ()
 
void * cast (const std::string &className) const
 Introspection method. More...
 
const std::string & userLevelClassType () const
 The AIDA user-level unterface leaf class type. More...
 
virtual int dimension () const
 Get the Histogram's dimension. More...
 
virtual std::ostream & print (std::ostream &s) const
 Print (ASCII) the histogram into the output stream. More...
 
virtual std::ostream & write (std::ostream &s) const
 Write (ASCII) the histogram table into the output stream. More...
 
virtual int write (const char *file_name) const
 Write (ASCII) the histogram table into a file. More...
 
template<>
void * cast (const std::string &className) const
 
template<>
int binEntries (int indexX, int indexY) const
 
template<>
void adoptRepresentation (TObject *rep)
 Adopt ROOT histogram representation. More...
 
template<>
void * cast (const std::string &className) const
 
template<>
int binEntries (int idX, int idY) const
 
template<>
void adoptRepresentation (TObject *rep)
 Adopt ROOT histogram representation. More...
 
- Public Member Functions inherited from Gaudi::HistogramBase
virtual ~HistogramBase ()
 

Static Public Member Functions

static const CLIDclassID ()
 
- Static Public Member Functions inherited from DataObject
static const CLIDclassID ()
 Retrieve reference to class definition structure (static access) More...
 

Protected Attributes

double m_sumwx
 
double m_sumwy
 
- Protected Attributes inherited from Gaudi::Generic2D< INTERFACE, IMPLEMENTATION >
Axis m_xAxis
 X axis member. More...
 
Axis m_yAxis
 Y axis member. More...
 
AIDA::Annotation m_annotation
 Object annotations. More...
 
IMPLEMENTATION * m_rep
 Reference to underlying implementation. More...
 
std::string m_classType
 class type More...
 
int m_sumEntries
 cache sumEntries (allEntries) when setting contents since Root can't compute by himself More...
 

Additional Inherited Members

- Public Types inherited from Gaudi::Generic2D< INTERFACE, IMPLEMENTATION >
typedef Generic2D< INTERFACE,
IMPLEMENTATION > 
Base
 

Detailed Description

AIDA implementation for 2 D histograms using ROOT THD2.

Author
M.Frank

Definition at line 20 of file H2D.h.

Constructor & Destructor Documentation

Gaudi::Histogram2D::Histogram2D ( )

Standard Constructor.

Definition at line 120 of file H2D.cpp.

120  {
121  m_rep = new TH2D();
122  m_rep->Sumw2();
123  m_sumEntries = 0;
124  m_sumwx = m_sumwy = 0;
125  setTitle("");
126  m_rep->SetDirectory(0);
127 }
int m_sumEntries
cache sumEntries (allEntries) when setting contents since Root can't compute by himself ...
Definition: Generic2D.h:147
virtual bool setTitle(const std::string &title)
Set the title of the object.
Definition: Generic2D.h:151
double m_sumwy
Definition: H2D.h:46
double m_sumwx
Definition: H2D.h:45
IMPLEMENTATION * m_rep
Reference to underlying implementation.
Definition: Generic2D.h:143
Gaudi::Histogram2D::Histogram2D ( TH2D *  rep)

Standard initializing Constructor with TH2D representation to be adopted.

Definition at line 129 of file H2D.cpp.

129  {
130  m_rep = 0;
131  adoptRepresentation(rep);
132  m_sumEntries = 0;
133  m_sumwx = m_sumwy = 0;
134  m_rep->SetDirectory(0);
135 }
int m_sumEntries
cache sumEntries (allEntries) when setting contents since Root can't compute by himself ...
Definition: Generic2D.h:147
double m_sumwy
Definition: H2D.h:46
double m_sumwx
Definition: H2D.h:45
virtual void adoptRepresentation(TObject *rep)
Adopt ROOT histogram representation.
IMPLEMENTATION * m_rep
Reference to underlying implementation.
Definition: Generic2D.h:143
virtual Gaudi::Histogram2D::~Histogram2D ( )
inlinevirtual

Destructor.

Definition at line 27 of file H2D.h.

27 {}

Member Function Documentation

static const CLID& Gaudi::Histogram2D::classID ( )
inlinestatic

Definition at line 42 of file H2D.h.

42 { return CLID_H2D; }
virtual const CLID& Gaudi::Histogram2D::clID ( ) const
inlinevirtual

Retrieve reference to class defininition identifier.

Reimplemented from DataObject.

Definition at line 41 of file H2D.h.

41 { return classID(); }
static const CLID & classID()
Definition: H2D.h:42
void Gaudi::Histogram2D::copyFromAida ( const IHistogram2D &  h)

Create new histogram from any AIDA based histogram.

Definition at line 186 of file H2D.cpp.

186  {
187  // implement here the copy
188  delete m_rep;
189  const char* tit = h.title().c_str();
190  if (h.xAxis().isFixedBinning() && h.yAxis().isFixedBinning() )
191  m_rep = new TH2D(tit,tit,
192  h.xAxis().bins(),h.xAxis().lowerEdge(),h.xAxis().upperEdge(),
193  h.yAxis().bins(),h.yAxis().lowerEdge(),h.yAxis().upperEdge() );
194  else {
195  Edges eX, eY;
196  for (int i =0; i < h.xAxis().bins(); ++i)
197  eX.push_back(h.xAxis().binLowerEdge(i));
198  // add also upperedges at the end
199  eX.push_back(h.xAxis().upperEdge() );
200  for (int i =0; i < h.yAxis().bins(); ++i)
201  eY.push_back(h.yAxis().binLowerEdge(i));
202  // add also upperedges at the end
203  eY.push_back(h.yAxis().upperEdge() );
204  m_rep = new TH2D(tit,tit,eX.size()-1,&eX.front(),eY.size()-1,&eY.front());
205  }
206  m_xAxis.initialize(m_rep->GetXaxis(),true);
207  m_yAxis.initialize(m_rep->GetYaxis(),true);
208  m_rep->Sumw2();
209  m_sumEntries = 0;
210  m_sumwx = 0;
211  m_sumwy = 0;
212  // statistics
213  double sumw = h.sumBinHeights();
214  double sumw2 = 0;
215  if (h.equivalentBinEntries() != 0)
216  sumw2 = ( sumw * sumw ) /h.equivalentBinEntries();
217  double sumwx = h.meanX()*h.sumBinHeights();
218  double sumwx2 = (h.meanX()*h.meanX() + h.rmsX()*h.rmsX() )*h.sumBinHeights();
219  double sumwy = h.meanY()*h.sumBinHeights();
220  double sumwy2 = (h.meanY()*h.meanY() + h.rmsY()*h.rmsY() )*h.sumBinHeights();
221  double sumwxy = 0;
222 
223  // copy the contents in (AIDA underflow/overflow are -2,-1)
224  for (int i=-2; i < xAxis().bins(); ++i) {
225  for (int j=-2; j < yAxis().bins(); ++j) {
226  // root binning starts from one !
227  m_rep->SetBinContent(rIndexX(i), rIndexY(j), h.binHeight(i,j) );
228  m_rep->SetBinError(rIndexX(i), rIndexY(j), h.binError(i,j) );
229  // calculate statistics
230  if ( i >= 0 && j >= 0) {
231  sumwxy += h.binHeight(i,j)*h.binMeanX(i,j)*h.binMeanY(i,j);
232  }
233  }
234  }
235  // need to do set entries after setting contents otherwise root will recalculate them
236  // taking into account how many time SetBinContents() has been called
237  m_rep->SetEntries(h.allEntries());
238  // fill stat vector
239  std::vector<double> stat(11);
240  stat[0] = sumw;
241  stat[1] = sumw2;
242  stat[2] = sumwx;
243  stat[3] = sumwx2;
244  stat[4] = sumwy;
245  stat[5] = sumwy2;
246  stat[6] = sumwxy;
247  m_rep->PutStats(&stat.front());
248 }
int m_sumEntries
cache sumEntries (allEntries) when setting contents since Root can't compute by himself ...
Definition: Generic2D.h:147
std::vector< double > Edges
Definition: GaudiPI.h:19
virtual int rIndexX(int index) const
operator methods
Definition: Generic2D.h:61
Axis m_xAxis
X axis member.
Definition: Generic2D.h:137
void initialize(TAxis *itaxi, bool)
Definition: Axis.h:71
Axis m_yAxis
Y axis member.
Definition: Generic2D.h:139
virtual const AIDA::IAxis & yAxis() const
Return the Y axis.
Definition: Generic2D.h:59
virtual int rIndexY(int index) const
operator methods
Definition: Generic2D.h:63
double m_sumwy
Definition: H2D.h:46
double m_sumwx
Definition: H2D.h:45
list i
Definition: ana.py:128
virtual const AIDA::IAxis & xAxis() const
Return the X axis.
Definition: Generic2D.h:57
IMPLEMENTATION * m_rep
Reference to underlying implementation.
Definition: Generic2D.h:143
bool Gaudi::Histogram2D::fill ( double  x,
double  y,
double  weight = 1. 
)

Fill the Histogram2D with a value and the.

Definition at line 161 of file H2D.cpp.

161  {
162  (weight==1.) ? m_rep->Fill(x,y) : m_rep->Fill(x,y,weight );
163  return true;
164 }
IMPLEMENTATION * m_rep
Reference to underlying implementation.
Definition: Generic2D.h:143
bool Gaudi::Histogram2D::reset ( )

Definition at line 149 of file H2D.cpp.

149  {
150  m_sumwx = 0;
151  m_sumwy = 0;
152  return Base::reset();
153 }
double m_sumwy
Definition: H2D.h:46
double m_sumwx
Definition: H2D.h:45
bool Gaudi::Histogram2D::setBinContents ( int  binIndexX,
int  binIndexY,
int  entries,
double  height,
double  error,
double  centreX,
double  centreY 
)
virtual

Fast filling method for a given bin. It can be also the over/underflow bin.

Definition at line 137 of file H2D.cpp.

137  {
138  m_rep->SetBinContent(rIndexX(i), rIndexY(j), height);
139  m_rep->SetBinError(rIndexX(i), rIndexY(j), error);
140  // accumulate sumwx for in range bins
141  if (i >=0 && j >= 0) {
142  m_sumwx += centreX*height;
143  m_sumwy += centreY*height;
144  }
146  return true;
147 }
int m_sumEntries
cache sumEntries (allEntries) when setting contents since Root can't compute by himself ...
Definition: Generic2D.h:147
virtual int rIndexX(int index) const
operator methods
Definition: Generic2D.h:61
virtual int entries() const
Get the number or all the entries.
Definition: Generic2D.h:168
virtual int rIndexY(int index) const
operator methods
Definition: Generic2D.h:63
double m_sumwy
Definition: H2D.h:46
double m_sumwx
Definition: H2D.h:45
list i
Definition: ana.py:128
IMPLEMENTATION * m_rep
Reference to underlying implementation.
Definition: Generic2D.h:143
bool Gaudi::Histogram2D::setRms ( double  rmsX,
double  rmsY 
)

Sets the rms of the histogram.

Definition at line 166 of file H2D.cpp.

166  {
167  m_rep->SetEntries(m_sumEntries);
168  std::vector<double> stat(11);
169  stat[0] = sumBinHeights();
170  stat[1] = 0;
171  if(equivalentBinEntries() != 0)
172  stat[1] = (sumBinHeights() * sumBinHeights()) / equivalentBinEntries();
173  stat[2] = m_sumwx;
174  double meanX = 0;
175  if(sumBinHeights() != 0) meanX = m_sumwx/ sumBinHeights();
176  stat[3] = (meanX*meanX + rmsX*rmsX) * sumBinHeights();
177  stat[4] = m_sumwy;
178  double meanY = 0;
179  if(sumBinHeights() != 0) meanY = m_sumwy/ sumBinHeights();
180  stat[5] = (meanY*meanY + rmsY*rmsY) * sumBinHeights();
181  stat[6] = 0;
182  m_rep->PutStats(&stat.front());
183  return true;
184 }
int m_sumEntries
cache sumEntries (allEntries) when setting contents since Root can't compute by himself ...
Definition: Generic2D.h:147
virtual double equivalentBinEntries() const
Number of equivalent entries, i.e. SUM[ weight ] ^ 2 / SUM[ weight^2 ]
Definition: Generic2D.h:305
virtual double rmsX() const
Returns the rms of the profile as calculated on filling-time projected on the X axis.
Definition: Generic2D.h:266
virtual double sumBinHeights() const
Get the sum of in range bin heights in the IProfile.
Definition: Generic2D.h:188
virtual double meanY() const
Returns the mean of the profile, as calculated on filling-time projected on the Y axis...
Definition: Generic2D.h:261
double m_sumwy
Definition: H2D.h:46
double m_sumwx
Definition: H2D.h:45
virtual double rmsY() const
Returns the rms of the profile as calculated on filling-time projected on the Y axis.
Definition: Generic2D.h:271
IMPLEMENTATION * m_rep
Reference to underlying implementation.
Definition: Generic2D.h:143
virtual double meanX() const
Returns the mean of the profile, as calculated on filling-time projected on the X axis...
Definition: Generic2D.h:256

Member Data Documentation

double Gaudi::Histogram2D::m_sumwx
protected

Definition at line 45 of file H2D.h.

double Gaudi::Histogram2D::m_sumwy
protected

Definition at line 46 of file H2D.h.


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