| # 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::Histogram3D Class Reference

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

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

## Public Member Functions
| Histogram3D ()
| Standard Constructor.
| Histogram3D (TH3D *rep)
| Standard Constructor.
virtual | ~Histogram3D ()
| Destructor.
bool | fill (double x, double y, double z, double weight)
| Fill bin content.
virtual bool | setBinContents (int i, int j, int k, int entries, double height, double error, double centreX, double centreY, double centreZ)
| Fast filling method for a given bin. It can be also the over/underflow bin.
virtual bool | setRms (double rmsX, double rmsY, double rmsZ)
| Sets the rms of the histogram.
virtual bool | reset ()
void * | cast (const std::string &className) const
| Introspection method.
void | copyFromAida (const AIDA::IHistogram3D &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::Generic3D< INTERFACE, IMPLEMENTATION >
| Generic3D ()
| Default constructor.
virtual | ~Generic3D ()
| Destructor.
TObject * | representation () const
| ROOT object implementation.
virtual void | adoptRepresentation (TObject *rep)
| Adopt ROOT histogram representation.
virtual int | dimension () const
| Get the Histogram's dimension.
virtual std::string | title () const
| Get the title of the object.
virtual bool | setTitle (const std::string &title)
| Set the title of the object.
virtual std::string | name () const
| object name
bool | setName (const std::string &newName)
| Sets the name of the object.
virtual AIDA::IAnnotation & | annotation ()
| Access annotation object.
virtual const AIDA::IAnnotation & | annotation () const
| Access annotation object (cons)
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 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.
int | rIndexX (int index) const
int | rIndexY (int index) const
int | rIndexZ (int index) const
double | binMeanX (int indexX, int, int) const
| The weighted mean along the x axis of a given bin.
double | binMeanY (int, int indexY, int) const
| The weighted mean along the y axis of a given bin.
double | binMeanZ (int, int, int indexZ) const
| The weighted mean along the z axis of a given bin.
int | binEntries (int indexX, int indexY, int indexZ) const
| Number of entries in the corresponding bin (ie the number of times fill was calle d for this bin).
virtual int | binEntriesX (int index) const
| Sum of all the entries of the bins along a given x bin.
virtual int | binEntriesY (int index) const
| Sum of all the entries of the bins along a given y bin.
virtual int | binEntriesZ (int index) const
| Sum of all the entries of the bins along a given z bin.
double | binHeight (int indexX, int indexY, int indexZ) const
| Total height of the corresponding bin (ie the sum of the weights in this bin).
virtual double | binHeightX (int index) const
| Sum of all the heights of the bins along a given x bin.
virtual double | binHeightY (int index) const
| Sum of all the heights of the bins along a given y bin.
virtual double | binHeightZ (int index) const
| Sum of all the heights of the bins along a given z bin.
virtual double | binError (int indexX, int indexY, int indexZ) const
| The error of a given bin.
virtual double | meanX () const
| The mean of the IHistogram3D along the x axis.
virtual double | meanY () const
| The mean of the IHistogram3D along the y axis.
virtual double | meanZ () const
| The mean of the IHistogram3D along the z axis.
virtual double | rmsX () const
| The RMS of the IHistogram3D along the x axis.
virtual double | rmsY () const
| The RMS of the IHistogram3D along the y axis.
virtual double | rmsZ () const
| The RMS of the IHistogram3D along the z axis.
virtual const AIDA::IAxis & | xAxis () const
| Get the x axis of the IHistogram3D.
virtual const AIDA::IAxis & | yAxis () const
| Get the y axis of the IHistogram3D.
virtual const AIDA::IAxis & | zAxis () const
| Get the z axis of the IHistogram3D.
virtual int | coordToIndexX (double coord) const
| Get the bin number corresponding to a given coordinate along the x axis.
virtual int | coordToIndexY (double coord) const
| Get the bin number corresponding to a given coordinate along the y axis.
virtual int | coordToIndexZ (double coord) const
| Get the bin number corresponding to a given coordinate along the z axis.
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 &hist)
| Add to this Histogram3D the contents of another IHistogram3D.
int | extraEntries () const
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 | 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
double | m_sumwz
Protected Attributes inherited from Gaudi::Generic3D< INTERFACE, IMPLEMENTATION >
Gaudi::Axis | m_xAxis
Gaudi::Axis | m_yAxis
Gaudi::Axis | m_zAxis
AIDA::Annotation | m_annotation
| Object annotations.
IMPLEMENTATION * | m_rep
| Reference to underlying implementation.
std::string | m_classType
int | m_sumEntries

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

## Detailed Description

AIDA implementation for 2 D histograms using ROOT THD2.

Author
  M.Frank

Definition at line 27 of file H3D.cpp.

## Constructor & Destructor Documentation

Gaudi::Histogram3D::Histogram3D | ( |  | ) |

Standard Constructor.

Definition at line 98 of file H3D.cpp.

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

Gaudi::Histogram3D::Histogram3D | ( | TH3D * | rep | ) |

Standard Constructor.

Definition at line 109 of file H3D.cpp.

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

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

Destructor.

Definition at line 34 of file H3D.cpp.

{}

## Member Function Documentation

void * Gaudi::Histogram3D::cast | ( | const std::string & | className | ) | const

Introspection method.

Definition at line 147 of file H3D.cpp.

{
if (className == "AIDA::IHistogram3D") {
return (AIDA::IHistogram3D*)this;
}
else if (className == "AIDA::IHistogram") {
return (AIDA::IHistogram*)this;
}
return 0;
}

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

Definition at line 49 of file H3D.cpp.

{ return CLID_H3D; }

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

Retrieve reference to class defininition identifier.

Reimplemented from DataObject.

Definition at line 48 of file H3D.cpp.

{ return classID(); }

void Gaudi::Histogram3D::copyFromAida | ( | const AIDA::IHistogram3D & | h | ) |

Create new histogram from any AIDA based histogram.

Definition at line 190 of file H3D.cpp.

{
delete m_rep;
// implement here the copy
const char* tit = h.title().c_str();
if (h.xAxis().isFixedBinning() && h.yAxis().isFixedBinning() && h.zAxis().isFixedBinning() ) {
m_rep = new TH3D(tit,tit,
h.xAxis().bins(), h.xAxis().lowerEdge(), h.xAxis().upperEdge(),
h.yAxis().bins(), h.yAxis().lowerEdge(), h.yAxis().upperEdge(),
h.zAxis().bins(), h.zAxis().lowerEdge(), h.zAxis().upperEdge() );
}
else {
Edges eX, eY, eZ;
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() );
for (int i =0; i < h.zAxis().bins(); ++i)
eZ.push_back(h.zAxis().binLowerEdge(i));
// add also upperedges at the end
eZ.push_back(h.zAxis().upperEdge() );
m_rep = new TH3D(tit,tit,eX.size()-1,&eX.front(),eY.size()-1,&eY.front(),eZ.size()-1,&eZ.front());
}
m_xAxis.initialize(m_rep->GetXaxis(),true);
m_yAxis.initialize(m_rep->GetYaxis(),true);
m_zAxis.initialize(m_rep->GetZaxis(),true);
const TArrayD* a = m_rep->GetSumw2();
if ( 0 == a || (a && a->GetSize()==0) ) m_rep->Sumw2();
m_sumEntries = 0;
m_sumwx = 0;
m_sumwy = 0;
m_sumwz = 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 sumwz = h.meanZ()*h.sumBinHeights();
double sumwz2 = (h.meanZ()*h.meanZ() + h.rmsZ()*h.rmsZ() )*h.sumBinHeights();
double sumwxy = 0;
double sumwxz = 0;
double sumwyz = 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) {
for (int k=-2; k < zAxis().bins(); ++k) {
m_rep->SetBinContent(rIndexX(i), rIndexY(j), rIndexZ(k), h.binHeight(i,j,k) );
m_rep->SetBinError(rIndexX(i), rIndexY(j), rIndexZ(k), h.binError(i,j,k) );
// calculate statistics
if ( i >= 0 && j >= 0 && k >= 0) {
sumwxy += h.binHeight(i,j,k)*h.binMeanX(i,j,k)*h.binMeanY(i,j,k);
sumwxz += h.binHeight(i,j,k)*h.binMeanX(i,j,k)*h.binMeanZ(i,j,k);
sumwyz += h.binHeight(i,j,k)*h.binMeanY(i,j,k)*h.binMeanZ(i,j,k);
}
}
}
}
// need to do set entries after setting contents otherwise root will recalulate 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;
stat[7] = sumwz;
stat[8] = sumwz2;
stat[9] = sumwxz;
stat[10] = sumwyz;
m_rep->PutStats(&stat.front());
}

bool Gaudi::Histogram3D::fill | ( | double | x,
|  | double | y,
|  | double | z,
|  | double | weight
| ) |  |

Fill bin content.

Definition at line 142 of file H3D.cpp.

{
m_rep->Fill ( x , y, z, weight );
return true;
}

bool Gaudi::Histogram3D::reset | ( |  | ) |
| virtual

Definition at line 133 of file H3D.cpp.

{
m_sumwx = 0;
m_sumwy = 0;
m_sumwz = 0;
m_sumEntries = 0;
m_rep->Reset ( );
return true;
}

bool Gaudi::Histogram3D::setBinContents | ( | int | i,
|  | int | j,
|  | int | k,
|  | int | entries,
|  | double | height,
|  | double | error,
|  | double | centreX,
|  | double | centreY,
|  | double | centreZ
| ) |  |
| virtual

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

Definition at line 120 of file H3D.cpp.

{
m_rep->SetBinContent(rIndexX(i), rIndexY(j), rIndexZ(k), height);
m_rep->SetBinError(rIndexX(i), rIndexY(j), rIndexZ(k), error);
// accumulate sum bin centers
if (i >=0 && j >= 0 && k >= 0) {
m_sumwx += centreX*height;
m_sumwy += centreY*height;
m_sumwz += centreZ*height;
}
m_sumEntries += entries;
return true;
}

bool Gaudi::Histogram3D::setRms | ( | double | rmsX,
|  | double | rmsY,
|  | double | rmsZ
| ) |  |
| virtual

Sets the rms of the histogram.

Definition at line 163 of file H3D.cpp.

{
m_rep->SetEntries(m_sumEntries);
std::vector<double> stat(11);
// sum weights
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;
stat[7] = m_sumwz;
double meanZ = 0;
if ( sumBinHeights() != 0 ) meanZ = m_sumwz/ sumBinHeights();
stat[8] = ( meanZ*meanZ + rmsZ*rmsZ )* sumBinHeights();
// do not need to use sumwxy sumwxz and sumwyz
m_rep->PutStats(&stat.front());
return true;
}

## Member Data Documentation

double Gaudi::Histogram3D::m_sumwx
| protected

Definition at line 53 of file H3D.cpp.

double Gaudi::Histogram3D::m_sumwy
| protected

Definition at line 54 of file H3D.cpp.

double Gaudi::Histogram3D::m_sumwz
| protected

Definition at line 55 of file H3D.cpp.

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

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