|
Gaudi Framework, version v22r2 |
| Home | Generated: Tue May 10 2011 |
AIDA implementation for 2 D histograms using ROOT THD2. More...
#include <H2D.h>


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. | |
Static Public Member Functions | |
| static const CLID & | classID () |
| Retrieve reference to class definition structure (static access) | |
Protected Attributes | |
| double | m_sumwx |
| double | m_sumwy |
AIDA implementation for 2 D histograms using ROOT THD2.
Definition at line 20 of file H2D.h.
| Gaudi::Histogram2D::Histogram2D | ( | ) |
| Gaudi::Histogram2D::Histogram2D | ( | TH2D * | rep ) |
Standard initializing Constructor with TH2D representation to be adopted.
Definition at line 130 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] |
| static const CLID& Gaudi::Histogram2D::classID | ( | ) | [inline, static] |
Retrieve reference to class definition structure (static access)
Retrieve Pointer to class definition structure.
Reimplemented from DataObject.
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 Gaudi::Histogram2D::classID(); }
| void Gaudi::Histogram2D::copyFromAida | ( | const IHistogram2D & | h ) |
Create new histogram from any AIDA based histogram.
Definition at line 187 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 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;
m_rep->PutStats(&stat.front());
}
| bool Gaudi::Histogram2D::fill | ( | double | x, |
| double | y, | ||
| double | weight = 1. |
||
| ) |
Fill the Histogram2D with a value and the.
| bool Gaudi::Histogram2D::reset | ( | ) |
Reimplemented from Gaudi::Generic2D< INTERFACE, IMPLEMENTATION >.
| 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.
| bool Gaudi::Histogram2D::setRms | ( | double | rmsX, |
| double | rmsY | ||
| ) |
Sets the rms of the histogram.
Definition at line 167 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;
}