| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

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

List of all members.

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

## 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 117 of file H2D.cpp.

    00117                               {
    00118   m_rep = new TH2D();
    00119   m_rep->Sumw2();
    00120   m_sumEntries = 0;
    00121   m_sumwx = m_sumwy = 0;
    00122   setTitle("");
    00123   m_rep->SetDirectory(0);
    00124 }

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

Standard initializing Constructor with TH2D representation to be adopted.

Definition at line 126 of file H2D.cpp.

    00126                                         {
    00127   m_rep = 0;
    00128   adoptRepresentation(rep);
    00129   m_sumEntries = 0;
    00130   m_sumwx = m_sumwy = 0;
    00131   m_rep->SetDirectory(0);
    00132 }

virtual Gaudi::Histogram2D::~Histogram2D | ( |  | ) | `[inline, virtual]`

Destructor.

Definition at line 27 of file H2D.h.

    00027 {}

## Member Function Documentation

bool Gaudi::Histogram2D::fill | ( | double | x,
|  | double | y,
|  | double | weight = `1.` |
| ) |  |  |

Fill the Histogram2D with a value and the.

Definition at line 158 of file H2D.cpp.

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

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 134 of file H2D.cpp.

    00134                                                                                                                        {
    00135   m_rep->SetBinContent(rIndexX(i), rIndexY(j), height);
    00136   m_rep->SetBinError(rIndexX(i), rIndexY(j), error);
    00137   // accumulate sumwx for in range bins
    00138   if (i >=0 && j >= 0) {
    00139     m_sumwx += centreX*height;
    00140     m_sumwy += centreY*height;
    00141   }
    00142   m_sumEntries += entries;
    00143   return true;
    00144 }

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

Sets the rms of the histogram.

Definition at line 163 of file H2D.cpp.

    00163                                                      {
    00164   m_rep->SetEntries(m_sumEntries);
    00165   std::vector<double> stat(11);
    00166   stat[0] =  sumBinHeights();
    00167   stat[1] = 0;
    00168   if(equivalentBinEntries() != 0)
    00169     stat[1] = (sumBinHeights() * sumBinHeights()) / equivalentBinEntries();
    00170   stat[2] = m_sumwx;
    00171   double meanX = 0;
    00172   if(sumBinHeights() != 0) meanX =  m_sumwx/ sumBinHeights();
    00173   stat[3] = (meanX*meanX + rmsX*rmsX) * sumBinHeights();
    00174   stat[4] = m_sumwy;
    00175   double meanY = 0;
    00176   if(sumBinHeights() != 0) meanY =  m_sumwy/ sumBinHeights();
    00177   stat[5] = (meanY*meanY + rmsY*rmsY) * sumBinHeights();
    00178   stat[6] = 0;
    00179   m_rep->PutStats(&stat.front());
    00180   return true;
    00181 }

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

Reimplemented from Gaudi::Generic2D< IHistogram2D, TH2D >.

Definition at line 146 of file H2D.cpp.

    00146                               {
    00147   m_sumwx = 0;
    00148   m_sumwy = 0;
    00149   return Base::reset();
    00150 }

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

Create new histogram from any AIDA based histogram.

Definition at line 183 of file H2D.cpp.

    00183                                                          {
    00184   // implement here the copy
    00185   delete m_rep;
    00186   const char* tit = h.title().c_str();
    00187   if (h.xAxis().isFixedBinning() && h.yAxis().isFixedBinning()  )
    00188     m_rep = new TH2D(tit,tit,
    00189                      h.xAxis().bins(),h.xAxis().lowerEdge(),h.xAxis().upperEdge(),
    00190                      h.yAxis().bins(),h.yAxis().lowerEdge(),h.yAxis().upperEdge() );
    00191   else {
    00192     Edges eX, eY;
    00193     for (int i =0; i < h.xAxis().bins(); ++i)
    00194       eX.push_back(h.xAxis().binLowerEdge(i));
    00195     // add also upperedges at the end
    00196     eX.push_back(h.xAxis().upperEdge() );
    00197     for (int i =0; i < h.yAxis().bins(); ++i)
    00198       eY.push_back(h.yAxis().binLowerEdge(i));
    00199     // add also upperedges at the end
    00200     eY.push_back(h.yAxis().upperEdge() );
    00201     m_rep = new TH2D(tit,tit,eX.size()-1,&eX.front(),eY.size()-1,&eY.front());
    00202   }
    00203   m_xAxis.initialize(m_rep->GetXaxis(),true);
    00204   m_yAxis.initialize(m_rep->GetYaxis(),true);
    00205   m_rep->Sumw2();
    00206   m_sumEntries = 0;
    00207   m_sumwx = 0;
    00208   m_sumwy = 0;
    00209   // statistics
    00210   double sumw = h.sumBinHeights();
    00211   double sumw2 = 0;
    00212   if (h.equivalentBinEntries() != 0)
    00213     sumw2 = ( sumw * sumw ) /h.equivalentBinEntries();
    00214   double sumwx = h.meanX()*h.sumBinHeights();
    00215   double sumwx2 = (h.meanX()*h.meanX() + h.rmsX()*h.rmsX() )*h.sumBinHeights();
    00216   double sumwy = h.meanY()*h.sumBinHeights();
    00217   double sumwy2 = (h.meanY()*h.meanY() + h.rmsY()*h.rmsY() )*h.sumBinHeights();
    00218   double sumwxy = 0;
    00219
    00220   // copy the contents in  (AIDA underflow/overflow are -2,-1)
    00221   for (int i=-2; i < xAxis().bins(); ++i) {
    00222     for (int j=-2; j < yAxis().bins(); ++j) {
    00223       // root binning starts from one !
    00224       m_rep->SetBinContent(rIndexX(i), rIndexY(j), h.binHeight(i,j) );
    00225       m_rep->SetBinError(rIndexX(i), rIndexY(j), h.binError(i,j) );
    00226       // calculate statistics
    00227       if ( i >= 0 && j >= 0) {
    00228         sumwxy += h.binHeight(i,j)*h.binMeanX(i,j)*h.binMeanY(i,j);
    00229       }
    00230     }
    00231   }
    00232   // need to do set entries after setting contents otherwise root will recalulate them
    00233   // taking into account how many time  SetBinContents() has been called
    00234   m_rep->SetEntries(h.allEntries());
    00235   // fill stat vector
    00236   std::vector<double> stat(11);
    00237   stat[0] = sumw;
    00238   stat[1] = sumw2;
    00239   stat[2] = sumwx;
    00240   stat[3] = sumwx2;
    00241   stat[4] = sumwy;
    00242   stat[5] = sumwy2;
    00243   stat[6] = sumwxy;
    00244   m_rep->PutStats(&stat.front());
    00245 }

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.

    00041 { return Gaudi::Histogram2D::classID(); }

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.

    00042 { return CLID_H2D; }

## 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_v21r10p1/GaudiSvc/src/HistogramSvc/H2D.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiSvc/src/HistogramSvc/H2D.cpp