| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Gaudi::Histogram2D Class Reference

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

`#include <H2D.h>`

Inheritance diagram for Gaudi::Histogram2D:
[legend]
Collaboration diagram for Gaudi::Histogram2D:
[legend]

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

## Static Public Member Functions
static const CLID & | classID ()
Static Public Member Functions inherited from DataObject
static const CLID & | classID ()
| Retrieve reference to class definition structure (static access)

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

## Additional Inherited Members
Public Types inherited from Gaudi::Generic2D< INTERFACE, IMPLEMENTATION >
typedef Generic2D< INTERFACE, IMPLEMENTATION > | Base
Friends inherited from DataObject

## 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.

{
m_rep = new TH2D();
m_rep->Sumw2();
m_sumEntries = 0;
m_sumwx = m_sumwy = 0;
setTitle("");
m_rep->SetDirectory(0);
}

Gaudi::Histogram2D::Histogram2D | ( | TH2D * | rep | ) |

Standard initializing Constructor with TH2D representation to be adopted.

Definition at line 129 of file H2D.cpp.

{
m_rep = 0;
adoptRepresentation(rep);
m_sumEntries = 0;
m_sumwx = m_sumwy = 0;
m_rep->SetDirectory(0);
}

virtual Gaudi::Histogram2D::~Histogram2D | ( |  | ) |
| inline virtual

Destructor.

Definition at line 27 of file H2D.h.

{}

## Member Function Documentation

static const CLID& Gaudi::Histogram2D::classID | ( |  | ) |
| inline static

Definition at line 42 of file H2D.h.

{ return CLID_H2D; }

virtual const CLID& Gaudi::Histogram2D::clID | ( |  | ) | const
| inline virtual

Retrieve reference to class defininition identifier.

Reimplemented from DataObject.

Definition at line 41 of file H2D.h.

{ return classID(); }

void Gaudi::Histogram2D::copyFromAida | ( | const IHistogram2D & | h | ) |

Create new histogram from any AIDA based histogram.

Definition at line 186 of file H2D.cpp.

{
// implement here the copy
delete m_rep;
const char* tit = h.title().c_str();
if (h.xAxis().isFixedBinning() && h.yAxis().isFixedBinning() )
m_rep = new TH2D(tit,tit,
h.xAxis().bins(),h.xAxis().lowerEdge(),h.xAxis().upperEdge(),
h.yAxis().bins(),h.yAxis().lowerEdge(),h.yAxis().upperEdge() );
else {
Edges eX, eY;
for (int i =0; i < h.xAxis().bins(); ++i)
eX.push_back(h.xAxis().binLowerEdge(i));
// add also upperedges at the end
eX.push_back(h.xAxis().upperEdge() );
for (int i =0; i < h.yAxis().bins(); ++i)
eY.push_back(h.yAxis().binLowerEdge(i));
// add also upperedges at the end
eY.push_back(h.yAxis().upperEdge() );
m_rep = new TH2D(tit,tit,eX.size()-1,&eX.front(),eY.size()-1,&eY.front());
}
m_xAxis.initialize(m_rep->GetXaxis(),true);
m_yAxis.initialize(m_rep->GetYaxis(),true);
m_rep->Sumw2();
m_sumEntries = 0;
m_sumwx = 0;
m_sumwy = 0;
// statistics
double sumw = h.sumBinHeights();
double sumw2 = 0;
if (h.equivalentBinEntries() != 0)
sumw2 = ( sumw * sumw ) /h.equivalentBinEntries();
double sumwx = h.meanX()*h.sumBinHeights();
double sumwx2 = (h.meanX()*h.meanX() + h.rmsX()*h.rmsX() )*h.sumBinHeights();
double sumwy = h.meanY()*h.sumBinHeights();
double sumwy2 = (h.meanY()*h.meanY() + h.rmsY()*h.rmsY() )*h.sumBinHeights();
double sumwxy = 0;
// copy the contents in (AIDA underflow/overflow are -2,-1)
for (int i=-2; i < xAxis().bins(); ++i) {
for (int j=-2; j < yAxis().bins(); ++j) {
// root binning starts from one !
m_rep->SetBinContent(rIndexX(i), rIndexY(j), h.binHeight(i,j) );
m_rep->SetBinError(rIndexX(i), rIndexY(j), h.binError(i,j) );
// calculate statistics
if ( i >= 0 && j >= 0) {
sumwxy += h.binHeight(i,j)*h.binMeanX(i,j)*h.binMeanY(i,j);
}
}
}
// need to do set entries after setting contents otherwise root will recalculate them
// taking into account how many time SetBinContents() has been called
m_rep->SetEntries(h.allEntries());
// fill stat vector
std::vector<double> stat(11);
stat[0] = sumw;
stat[1] = sumw2;
stat[2] = sumwx;
stat[3] = sumwx2;
stat[4] = sumwy;
stat[5] = sumwy2;
stat[6] = sumwxy;
m_rep->PutStats(&stat.front());
}

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.

{
(weight==1.) ? m_rep->Fill(x,y) : m_rep->Fill(x,y,weight );
return true;
}

bool Gaudi::Histogram2D::reset | ( |  | ) |

Definition at line 149 of file H2D.cpp.

{
m_sumwx = 0;
m_sumwy = 0;
return Base::reset();
}

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.

{
m_rep->SetBinContent(rIndexX(i), rIndexY(j), height);
m_rep->SetBinError(rIndexX(i), rIndexY(j), error);
// accumulate sumwx for in range bins
if (i >=0 && j >= 0) {
m_sumwx += centreX*height;
m_sumwy += centreY*height;
}
m_sumEntries += entries;
return true;
}

bool Gaudi::Histogram2D::setRms | ( | double | rmsX,
|  | double | rmsY
| ) |  |

Sets the rms of the histogram.

Definition at line 166 of file H2D.cpp.

{
m_rep->SetEntries(m_sumEntries);
std::vector<double> stat(11);
stat[0] = sumBinHeights();
stat[1] = 0;
if(equivalentBinEntries() != 0)
stat[1] = (sumBinHeights() * sumBinHeights()) / equivalentBinEntries();
stat[2] = m_sumwx;
double meanX = 0;
if(sumBinHeights() != 0) meanX = m_sumwx/ sumBinHeights();
stat[3] = (meanX*meanX + rmsX*rmsX) * sumBinHeights();
stat[4] = m_sumwy;
double meanY = 0;
if(sumBinHeights() != 0) meanY = m_sumwy/ sumBinHeights();
stat[5] = (meanY*meanY + rmsY*rmsY) * sumBinHeights();
stat[6] = 0;
m_rep->PutStats(&stat.front());
return true;
}

## 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:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/GaudiCommonSvc/src/HistogramSvc/H2D.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/GaudiCommonSvc/src/HistogramSvc/H2D.cpp