Gaudi Framework, version v22r2

Home   Generated: Tue May 10 2011
Public Member Functions | Static Public Member Functions | Protected Attributes

Gaudi::Histogram2D Class Reference

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

#include <H2D.h>

Inheritance diagram for Gaudi::Histogram2D:
Inheritance graph
[legend]
Collaboration diagram for Gaudi::Histogram2D:
Collaboration graph
[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 CLIDclID () const
 Retrieve reference to class defininition identifier.

Static Public Member Functions

static const CLIDclassID ()
 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 121 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 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]

Destructor.

Definition at line 27 of file H2D.h.

{}

Member Function Documentation

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.

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.

Definition at line 162 of file H2D.cpp.

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

Reimplemented from Gaudi::Generic2D< INTERFACE, IMPLEMENTATION >.

Definition at line 150 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 138 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 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;
}

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:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Tue May 10 2011 18:55:19 for Gaudi Framework, version v22r2 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004