All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Gaudi::Histogram3D Class Reference

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

Inheritance diagram for Gaudi::Histogram3D:
Collaboration diagram for Gaudi::Histogram3D:

Public Member Functions

 Histogram3D ()
 Standard Constructor. More...
 
 Histogram3D (TH3D *rep)
 Standard Constructor. More...
 
virtual ~Histogram3D ()
 Destructor. More...
 
bool fill (double x, double y, double z, double weight)
 Fill bin content. More...
 
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. More...
 
virtual bool setRms (double rmsX, double rmsY, double rmsZ)
 Sets the rms of the histogram. More...
 
virtual bool reset ()
 
void * cast (const std::string &className) const
 Introspection method. More...
 
void copyFromAida (const AIDA::IHistogram3D &h)
 Create new histogram from any AIDA based histogram. More...
 
virtual const CLIDclID () const
 Retrieve reference to class defininition identifier. More...
 
- Public Member Functions inherited from DataObject
 DataObject ()
 Standard Constructor. More...
 
 DataObject (const DataObject &)
 Copy Constructor. More...
 
virtual ~DataObject ()
 Standard Destructor. More...
 
virtual unsigned long addRef ()
 Add reference to object. More...
 
virtual unsigned long release ()
 release reference to object More...
 
const std::string & name () const
 Retreive DataObject name. It is the name when registered in the store. More...
 
virtual StatusCode update ()
 Provide empty placeholder for internal object reconfiguration callback. More...
 
void setRegistry (IRegistry *pRegistry)
 Set pointer to Registry. More...
 
IRegistryregistry () const
 Get pointer to Registry. More...
 
LinkManagerlinkMgr () const
 Retrieve Link manager. More...
 
unsigned char version () const
 Retrieve version number of this object representation. More...
 
void setVersion (unsigned char vsn)
 Set version number of this object representation. More...
 
unsigned long refCount () const
 Return the refcount. More...
 
virtual std::ostream & fillStream (std::ostream &s) const
 Fill the output stream (ASCII) More...
 
- Public Member Functions inherited from Gaudi::Generic3D< INTERFACE, IMPLEMENTATION >
 Generic3D ()
 Default constructor. More...
 
virtual ~Generic3D ()
 Destructor. More...
 
TObject * representation () const
 ROOT object implementation. More...
 
virtual void adoptRepresentation (TObject *rep)
 Adopt ROOT histogram representation. More...
 
virtual int dimension () const
 Get the Histogram's dimension. More...
 
virtual std::string title () const
 Get the title of the object. More...
 
virtual bool setTitle (const std::string &title)
 Set the title of the object. More...
 
virtual std::string name () const
 object name More...
 
bool setName (const std::string &newName)
 Sets the name of the object. More...
 
virtual AIDA::IAnnotation & annotation ()
 Access annotation object. More...
 
virtual const AIDA::IAnnotation & annotation () const
 Access annotation object (cons) More...
 
virtual int entries () const
 Get the number or all the entries. More...
 
virtual int allEntries () const
 Get the number or all the entries, both in range and underflow/overflow bins of the IProfile. More...
 
virtual double sumBinHeights () const
 Get the sum of in range bin heights in the IProfile. More...
 
virtual double sumAllBinHeights () const
 Get the sum of all the bins heights (including underflow and overflow bin). More...
 
virtual double sumExtraBinHeights () const
 Get the sum of the underflow and overflow bin height. More...
 
virtual double minBinHeight () const
 Get the minimum height of the in-range bins. More...
 
virtual double maxBinHeight () const
 Get the maximum height of the in-range bins. More...
 
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. More...
 
double binMeanY (int, int indexY, int) const
 The weighted mean along the y axis of a given bin. More...
 
double binMeanZ (int, int, int indexZ) const
 The weighted mean along the z axis of a given bin. More...
 
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). More...
 
virtual int binEntriesX (int index) const
 Sum of all the entries of the bins along a given x bin. More...
 
virtual int binEntriesY (int index) const
 Sum of all the entries of the bins along a given y bin. More...
 
virtual int binEntriesZ (int index) const
 Sum of all the entries of the bins along a given z bin. More...
 
double binHeight (int indexX, int indexY, int indexZ) const
 Total height of the corresponding bin (ie the sum of the weights in this bin). More...
 
virtual double binHeightX (int index) const
 Sum of all the heights of the bins along a given x bin. More...
 
virtual double binHeightY (int index) const
 Sum of all the heights of the bins along a given y bin. More...
 
virtual double binHeightZ (int index) const
 Sum of all the heights of the bins along a given z bin. More...
 
virtual double binError (int indexX, int indexY, int indexZ) const
 The error of a given bin. More...
 
virtual double meanX () const
 The mean of the IHistogram3D along the x axis. More...
 
virtual double meanY () const
 The mean of the IHistogram3D along the y axis. More...
 
virtual double meanZ () const
 The mean of the IHistogram3D along the z axis. More...
 
virtual double rmsX () const
 The RMS of the IHistogram3D along the x axis. More...
 
virtual double rmsY () const
 The RMS of the IHistogram3D along the y axis. More...
 
virtual double rmsZ () const
 The RMS of the IHistogram3D along the z axis. More...
 
virtual const AIDA::IAxis & xAxis () const
 Get the x axis of the IHistogram3D. More...
 
virtual const AIDA::IAxis & yAxis () const
 Get the y axis of the IHistogram3D. More...
 
virtual const AIDA::IAxis & zAxis () const
 Get the z axis of the IHistogram3D. More...
 
virtual int coordToIndexX (double coord) const
 Get the bin number corresponding to a given coordinate along the x axis. More...
 
virtual int coordToIndexY (double coord) const
 Get the bin number corresponding to a given coordinate along the y axis. More...
 
virtual int coordToIndexZ (double coord) const
 Get the bin number corresponding to a given coordinate along the z axis. More...
 
virtual double equivalentBinEntries () const
 Number of equivalent entries, i.e. SUM[ weight ] ^ 2 / SUM[ weight^2 ] More...
 
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. More...
 
virtual bool add (const INTERFACE &hist)
 Add to this Histogram3D the contents of another IHistogram3D. More...
 
int extraEntries () const
 
virtual std::ostream & print (std::ostream &s) const
 Print (ASCII) the histogram into the output stream. More...
 
virtual std::ostream & write (std::ostream &s) const
 Write (ASCII) the histogram table into the output stream. More...
 
virtual int write (const char *file_name) const
 Write (ASCII) the histogram table into a file. More...
 
template<>
void adoptRepresentation (TObject *rep)
 Adopt ROOT histogram representation. More...
 
- Public Member Functions inherited from Gaudi::HistogramBase
virtual ~HistogramBase ()
 

Static Public Member Functions

static const CLIDclassID ()
 
- Static Public Member Functions inherited from DataObject
static const CLIDclassID ()
 Retrieve reference to class definition structure (static access) More...
 

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. More...
 
IMPLEMENTATION * m_rep
 Reference to underlying implementation. More...
 
std::string m_classType
 
int m_sumEntries
 

Additional Inherited Members

- Public Types inherited from Gaudi::Generic3D< INTERFACE, IMPLEMENTATION >
typedef Generic3D< INTERFACE,
IMPLEMENTATION > 
Base
 

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.

98  {
99  m_rep = new TH3D();
100  setTitle("");
101  m_rep->Sumw2();
102  m_sumEntries = 0;
103  m_sumwx = 0;
104  m_sumwy = 0;
105  m_sumwz = 0;
106  m_rep->SetDirectory(0);
107 }
double m_sumwx
Definition: H3D.cpp:53
IMPLEMENTATION * m_rep
Reference to underlying implementation.
Definition: Generic3D.h:213
double m_sumwy
Definition: H3D.cpp:54
virtual bool setTitle(const std::string &title)
Set the title of the object.
Definition: Generic3D.h:221
double m_sumwz
Definition: H3D.cpp:55
Gaudi::Histogram3D::Histogram3D ( TH3D *  rep)

Standard Constructor.

Definition at line 109 of file H3D.cpp.

109  {
110  m_rep = 0;
111  adoptRepresentation(rep);
112  m_sumEntries = 0;
113  m_sumwx = 0;
114  m_sumwy = 0;
115  m_sumwz = 0;
116  m_rep->SetDirectory(0);
117 }
double m_sumwx
Definition: H3D.cpp:53
IMPLEMENTATION * m_rep
Reference to underlying implementation.
Definition: Generic3D.h:213
double m_sumwy
Definition: H3D.cpp:54
double m_sumwz
Definition: H3D.cpp:55
virtual void adoptRepresentation(TObject *rep)
Adopt ROOT histogram representation.
virtual Gaudi::Histogram3D::~Histogram3D ( )
inlinevirtual

Destructor.

Definition at line 34 of file H3D.cpp.

34 {}

Member Function Documentation

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

Introspection method.

Definition at line 147 of file H3D.cpp.

147  {
148  if (className == "AIDA::IHistogram3D") {
149  return (AIDA::IHistogram3D*)this;
150  }
151  else if (className == "AIDA::IHistogram") {
152  return (AIDA::IHistogram*)this;
153  }
154  return 0;
155 }
static const CLID& Gaudi::Histogram3D::classID ( )
inlinestatic

Definition at line 49 of file H3D.cpp.

49 { return CLID_H3D; }
virtual const CLID& Gaudi::Histogram3D::clID ( ) const
inlinevirtual

Retrieve reference to class defininition identifier.

Reimplemented from DataObject.

Definition at line 48 of file H3D.cpp.

48 { return classID(); }
static const CLID & classID()
Definition: H3D.cpp:49
void Gaudi::Histogram3D::copyFromAida ( const AIDA::IHistogram3D &  h)

Create new histogram from any AIDA based histogram.

Definition at line 190 of file H3D.cpp.

190  {
191  delete m_rep;
192  // implement here the copy
193  const char* tit = h.title().c_str();
194  if (h.xAxis().isFixedBinning() && h.yAxis().isFixedBinning() && h.zAxis().isFixedBinning() ) {
195  m_rep = new TH3D(tit,tit,
196  h.xAxis().bins(), h.xAxis().lowerEdge(), h.xAxis().upperEdge(),
197  h.yAxis().bins(), h.yAxis().lowerEdge(), h.yAxis().upperEdge(),
198  h.zAxis().bins(), h.zAxis().lowerEdge(), h.zAxis().upperEdge() );
199  }
200  else {
201  Edges eX, eY, eZ;
202  for (int i =0; i < h.xAxis().bins(); ++i)
203  eX.push_back(h.xAxis().binLowerEdge(i));
204  // add also upperedges at the end
205  eX.push_back(h.xAxis().upperEdge() );
206  for (int i =0; i < h.yAxis().bins(); ++i)
207  eY.push_back(h.yAxis().binLowerEdge(i));
208  // add also upperedges at the end
209  eY.push_back(h.yAxis().upperEdge() );
210  for (int i =0; i < h.zAxis().bins(); ++i)
211  eZ.push_back(h.zAxis().binLowerEdge(i));
212  // add also upperedges at the end
213  eZ.push_back(h.zAxis().upperEdge() );
214  m_rep = new TH3D(tit,tit,eX.size()-1,&eX.front(),eY.size()-1,&eY.front(),eZ.size()-1,&eZ.front());
215  }
216  m_xAxis.initialize(m_rep->GetXaxis(),true);
217  m_yAxis.initialize(m_rep->GetYaxis(),true);
218  m_zAxis.initialize(m_rep->GetZaxis(),true);
219  const TArrayD* a = m_rep->GetSumw2();
220  if ( 0 == a || (a && a->GetSize()==0) ) m_rep->Sumw2();
221  m_sumEntries = 0;
222  m_sumwx = 0;
223  m_sumwy = 0;
224  m_sumwz = 0;
225 
226  // statistics
227  double sumw = h.sumBinHeights();
228  double sumw2 = 0;
229  if (h.equivalentBinEntries() != 0)
230  sumw2 = ( sumw * sumw ) /h.equivalentBinEntries();
231  double sumwx = h.meanX()*h.sumBinHeights();
232  double sumwx2 = (h.meanX()*h.meanX() + h.rmsX()*h.rmsX() )*h.sumBinHeights();
233  double sumwy = h.meanY()*h.sumBinHeights();
234  double sumwy2 = (h.meanY()*h.meanY() + h.rmsY()*h.rmsY() )*h.sumBinHeights();
235  double sumwz = h.meanZ()*h.sumBinHeights();
236  double sumwz2 = (h.meanZ()*h.meanZ() + h.rmsZ()*h.rmsZ() )*h.sumBinHeights();
237  double sumwxy = 0;
238  double sumwxz = 0;
239  double sumwyz = 0;
240 
241  // copy the contents in (AIDA underflow/overflow are -2,-1)
242  for (int i=-2; i < xAxis().bins(); ++i) {
243  for (int j=-2; j < yAxis().bins(); ++j) {
244  for (int k=-2; k < zAxis().bins(); ++k) {
245  m_rep->SetBinContent(rIndexX(i), rIndexY(j), rIndexZ(k), h.binHeight(i,j,k) );
246  m_rep->SetBinError(rIndexX(i), rIndexY(j), rIndexZ(k), h.binError(i,j,k) );
247  // calculate statistics
248  if ( i >= 0 && j >= 0 && k >= 0) {
249  sumwxy += h.binHeight(i,j,k)*h.binMeanX(i,j,k)*h.binMeanY(i,j,k);
250  sumwxz += h.binHeight(i,j,k)*h.binMeanX(i,j,k)*h.binMeanZ(i,j,k);
251  sumwyz += h.binHeight(i,j,k)*h.binMeanY(i,j,k)*h.binMeanZ(i,j,k);
252  }
253  }
254  }
255  }
256  // need to do set entries after setting contents otherwise root will recalulate them
257  // taking into account how many time SetBinContents() has been called
258  m_rep->SetEntries(h.allEntries());
259 
260  // fill stat vector
261  std::vector<double> stat(11);
262  stat[0] = sumw;
263  stat[1] = sumw2;
264  stat[2] = sumwx;
265  stat[3] = sumwx2;
266  stat[4] = sumwy;
267  stat[5] = sumwy2;
268  stat[6] = sumwxy;
269  stat[7] = sumwz;
270  stat[8] = sumwz2;
271  stat[9] = sumwxz;
272  stat[10] = sumwyz;
273  m_rep->PutStats(&stat.front());
274 }
int rIndexZ(int index) const
Definition: Generic3D.h:73
int rIndexX(int index) const
Definition: Generic3D.h:71
Gaudi::Axis m_xAxis
Definition: Generic3D.h:207
Gaudi::Axis m_yAxis
Definition: Generic3D.h:208
std::vector< double > Edges
Definition: GaudiPI.h:19
double m_sumwx
Definition: H3D.cpp:53
IMPLEMENTATION * m_rep
Reference to underlying implementation.
Definition: Generic3D.h:213
virtual const AIDA::IAxis & zAxis() const
Get the z axis of the IHistogram3D.
Definition: Generic3D.h:166
double m_sumwy
Definition: H3D.cpp:54
Gaudi::Axis m_zAxis
Definition: Generic3D.h:209
int rIndexY(int index) const
Definition: Generic3D.h:72
void initialize(TAxis *itaxi, bool)
Definition: Axis.h:71
virtual const AIDA::IAxis & xAxis() const
Get the x axis of the IHistogram3D.
Definition: Generic3D.h:162
list i
Definition: ana.py:128
double m_sumwz
Definition: H3D.cpp:55
virtual const AIDA::IAxis & yAxis() const
Get the y axis of the IHistogram3D.
Definition: Generic3D.h:164
bool Gaudi::Histogram3D::fill ( double  x,
double  y,
double  z,
double  weight 
)

Fill bin content.

Definition at line 142 of file H3D.cpp.

142  {
143  m_rep->Fill ( x , y, z, weight );
144  return true;
145 }
IMPLEMENTATION * m_rep
Reference to underlying implementation.
Definition: Generic3D.h:213
bool Gaudi::Histogram3D::reset ( )
virtual

Definition at line 133 of file H3D.cpp.

133  {
134  m_sumwx = 0;
135  m_sumwy = 0;
136  m_sumwz = 0;
137  m_sumEntries = 0;
138  m_rep->Reset ( );
139  return true;
140 }
double m_sumwx
Definition: H3D.cpp:53
IMPLEMENTATION * m_rep
Reference to underlying implementation.
Definition: Generic3D.h:213
double m_sumwy
Definition: H3D.cpp:54
double m_sumwz
Definition: H3D.cpp:55
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.

120  {
121  m_rep->SetBinContent(rIndexX(i), rIndexY(j), rIndexZ(k), height);
122  m_rep->SetBinError(rIndexX(i), rIndexY(j), rIndexZ(k), error);
123  // accumulate sum bin centers
124  if (i >=0 && j >= 0 && k >= 0) {
125  m_sumwx += centreX*height;
126  m_sumwy += centreY*height;
127  m_sumwz += centreZ*height;
128  }
130  return true;
131 }
int rIndexZ(int index) const
Definition: Generic3D.h:73
int rIndexX(int index) const
Definition: Generic3D.h:71
virtual int entries() const
Get the number or all the entries.
Definition: Generic3D.h:237
double m_sumwx
Definition: H3D.cpp:53
IMPLEMENTATION * m_rep
Reference to underlying implementation.
Definition: Generic3D.h:213
double m_sumwy
Definition: H3D.cpp:54
int rIndexY(int index) const
Definition: Generic3D.h:72
list i
Definition: ana.py:128
double m_sumwz
Definition: H3D.cpp:55
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.

163  {
164  m_rep->SetEntries(m_sumEntries);
165  std::vector<double> stat(11);
166  // sum weights
167  stat[0] = sumBinHeights();
168  stat[1] = 0;
169  if (equivalentBinEntries() != 0)
170  stat[1] = ( sumBinHeights() * sumBinHeights() ) / equivalentBinEntries();
171  stat[2] = m_sumwx;
172  double meanX = 0;
173  if ( sumBinHeights() != 0 ) meanX = m_sumwx/ sumBinHeights();
174  stat[3] = ( meanX*meanX + rmsX*rmsX )* sumBinHeights();
175  stat[4] = m_sumwy;
176  double meanY = 0;
177  if ( sumBinHeights() != 0 ) meanY = m_sumwy/ sumBinHeights();
178  stat[5] = ( meanY*meanY + rmsY*rmsY )* sumBinHeights();
179  stat[6] = 0;
180  stat[7] = m_sumwz;
181  double meanZ = 0;
182  if ( sumBinHeights() != 0 ) meanZ = m_sumwz/ sumBinHeights();
183  stat[8] = ( meanZ*meanZ + rmsZ*rmsZ )* sumBinHeights();
184  // do not need to use sumwxy sumwxz and sumwyz
185 
186  m_rep->PutStats(&stat.front());
187  return true;
188 }
virtual double sumBinHeights() const
Get the sum of in range bin heights in the IProfile.
Definition: Generic3D.h:257
virtual double rmsY() const
The RMS of the IHistogram3D along the y axis.
Definition: Generic3D.h:158
virtual double rmsZ() const
The RMS of the IHistogram3D along the z axis.
Definition: Generic3D.h:160
double m_sumwx
Definition: H3D.cpp:53
IMPLEMENTATION * m_rep
Reference to underlying implementation.
Definition: Generic3D.h:213
virtual double meanZ() const
The mean of the IHistogram3D along the z axis.
Definition: Generic3D.h:154
double m_sumwy
Definition: H3D.cpp:54
virtual double meanY() const
The mean of the IHistogram3D along the y axis.
Definition: Generic3D.h:152
virtual double equivalentBinEntries() const
Number of equivalent entries, i.e. SUM[ weight ] ^ 2 / SUM[ weight^2 ]
Definition: Generic3D.h:267
virtual double rmsX() const
The RMS of the IHistogram3D along the x axis.
Definition: Generic3D.h:156
double m_sumwz
Definition: H3D.cpp:55
virtual double meanX() const
The mean of the IHistogram3D along the x axis.
Definition: Generic3D.h:149

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: