| # Gaudi Framework, version v21r7 |

Home |  | Generated: 22 Jan 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 112 of file H2D.cpp.

    00112                               {
    00113   m_rep = new TH2D();
    00114   m_rep->Sumw2();
    00115   m_sumEntries = 0;
    00116   m_sumwx = m_sumwy = 0;
    00117   setTitle("");
    00118   m_rep->SetDirectory(0);
    00119 }

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

Standard initializing Constructor with TH2D representation to be adopted.

Definition at line 121 of file H2D.cpp.

    00121                                         {
    00122   m_rep = 0;
    00123   adoptRepresentation(rep);
    00124   m_sumEntries = 0;
    00125   m_sumwx = m_sumwy = 0;
    00126   m_rep->SetDirectory(0);
    00127 }

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

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

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

    00146                                                      {
    00147   m_rep->SetEntries(m_sumEntries);
    00148   std::vector<double> stat(11);
    00149   stat[0] =  sumBinHeights();
    00150   stat[1] = 0;
    00151   if(equivalentBinEntries() != 0)
    00152     stat[1] = (sumBinHeights() * sumBinHeights()) / equivalentBinEntries();
    00153   stat[2] = m_sumwx;
    00154   double meanX = 0;
    00155   if(sumBinHeights() != 0) meanX =  m_sumwx/ sumBinHeights();
    00156   stat[3] = (meanX*meanX + rmsX*rmsX) * sumBinHeights();
    00157   stat[4] = m_sumwy;
    00158   double meanY = 0;
    00159   if(sumBinHeights() != 0) meanY =  m_sumwy/ sumBinHeights();
    00160   stat[5] = (meanY*meanY + rmsY*rmsY) * sumBinHeights();
    00161   stat[6] = 0;
    00162   m_rep->PutStats(&stat.front());
    00163   return true;
    00164 }

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

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

Definition at line 166 of file H2D.cpp.

    00166                               {
    00167   m_sumwx = 0;
    00168   m_sumwy = 0;
    00169   return Base::reset();
    00170 }

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

Create new histogram from any AIDA based histogram.

Definition at line 172 of file H2D.cpp.

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

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