Go to the documentation of this file.
15 #include <AIDA/IHistogram3D.h>
24 # pragma clang diagnostic push
25 # pragma clang diagnostic ignored "-Wsuggest-override"
26 # pragma clang diagnostic ignored "-Winconsistent-missing-override"
27 #elif defined( __GNUC__ )
28 # pragma GCC diagnostic push
29 # pragma GCC diagnostic ignored "-Wsuggest-override"
44 template <
typename INTERFACE,
typename IMPLEMENTATION>
64 std::string
title()
const override {
return m_annotation.value(
"Title" ); }
66 bool setTitle(
const std::string& title )
override;
68 std::string
name()
const {
return m_annotation.value(
"Name" ); }
70 bool setName(
const std::string& newName );
72 AIDA::IAnnotation&
annotation()
override {
return m_annotation; }
74 const AIDA::IAnnotation&
annotation()
const override {
return m_annotation; }
96 double binMeanX(
int indexX,
int,
int )
const override {
97 return m_rep->GetXaxis()->GetBinCenter( rIndexX( indexX ) );
100 double binMeanY(
int,
int indexY,
int )
const override {
101 return m_rep->GetYaxis()->GetBinCenter( rIndexY( indexY ) );
104 double binMeanZ(
int,
int,
int indexZ )
const override {
105 return m_rep->GetYaxis()->GetBinCenter( rIndexY( indexZ ) );
108 int binEntries(
int indexX,
int indexY,
int indexZ )
const override {
109 if ( binHeight( indexX, indexY, indexZ ) <= 0 )
return 0;
110 double xx = binHeight( indexX, indexY, indexZ ) / binError( indexX, indexY, indexZ );
111 return int( xx * xx + 0.5 );
116 for (
int i = -2; i < yAxis().bins(); ++i )
117 for (
int j = -2;
j < zAxis().bins(); ++
j )
n += binEntries(
index, i,
j );
123 for (
int i = -2; i < xAxis().bins(); ++i )
124 for (
int j = -2;
j < zAxis().bins(); ++
j )
n += binEntries( i,
index,
j );
131 for (
int i = -2; i < xAxis().bins(); ++i )
132 for (
int j = -2;
j < yAxis().bins(); ++
j )
n += binEntries( i,
j,
index );
137 double binHeight(
int indexX,
int indexY,
int indexZ )
const {
138 return m_rep->GetBinContent( rIndexX( indexX ), rIndexY( indexY ), rIndexZ( indexZ ) );
144 for (
int i = -2; i < yAxis().bins(); ++i )
145 for (
int j = -2;
j < zAxis().bins(); ++
j )
s += binHeight(
index, i,
j );
151 for (
int i = -2; i < xAxis().bins(); ++i )
152 for (
int j = -2;
j < zAxis().bins(); ++
j )
s += binHeight( i,
index,
j );
158 for (
int i = -2; i < xAxis().bins(); ++i )
159 for (
int j = -2;
j < yAxis().bins(); ++
j )
s += binHeight( i,
j,
index );
163 double binError(
int indexX,
int indexY,
int indexZ )
const override {
164 return m_rep->GetBinError( rIndexX( indexX ), rIndexY( indexY ), rIndexZ( indexZ ) );
167 double meanX()
const override {
return m_rep->GetMean( 1 ); }
170 double meanY()
const override {
return m_rep->GetMean( 2 ); }
172 double meanZ()
const override {
return m_rep->GetMean( 3 ); }
174 double rmsX()
const override {
return m_rep->GetRMS( 1 ); }
176 double rmsY()
const override {
return m_rep->GetRMS( 2 ); }
178 double rmsZ()
const override {
return m_rep->GetRMS( 3 ); }
180 const AIDA::IAxis&
xAxis()
const override {
return m_xAxis; }
182 const AIDA::IAxis&
yAxis()
const override {
return m_yAxis; }
184 const AIDA::IAxis&
zAxis()
const override {
return m_zAxis; }
186 int coordToIndexX(
double coord )
const override {
return xAxis().coordToIndex( coord ); }
188 int coordToIndexY(
double coord )
const override {
return yAxis().coordToIndex( coord ); }
190 int coordToIndexZ(
double coord )
const override {
return zAxis().coordToIndex( coord ); }
196 bool scale(
double scaleFactor )
override;
198 bool add(
const INTERFACE& hist )
override {
199 const Base* p =
dynamic_cast<const Base*
>( &hist );
200 if ( !p )
throw std::runtime_error(
"Cannot add profile histograms of different implementations." );
201 m_rep->Add( p->
m_rep.get() );
207 return binEntries( AIDA::IAxis::UNDERFLOW_BIN, AIDA::IAxis::UNDERFLOW_BIN, AIDA::IAxis::UNDERFLOW_BIN ) +
208 binEntries( AIDA::IAxis::UNDERFLOW_BIN, AIDA::IAxis::UNDERFLOW_BIN, AIDA::IAxis::OVERFLOW_BIN ) +
209 binEntries( AIDA::IAxis::UNDERFLOW_BIN, AIDA::IAxis::OVERFLOW_BIN, AIDA::IAxis::UNDERFLOW_BIN ) +
210 binEntries( AIDA::IAxis::OVERFLOW_BIN, AIDA::IAxis::UNDERFLOW_BIN, AIDA::IAxis::UNDERFLOW_BIN ) +
211 binEntries( AIDA::IAxis::OVERFLOW_BIN, AIDA::IAxis::UNDERFLOW_BIN, AIDA::IAxis::OVERFLOW_BIN ) +
212 binEntries( AIDA::IAxis::OVERFLOW_BIN, AIDA::IAxis::OVERFLOW_BIN, AIDA::IAxis::UNDERFLOW_BIN ) +
213 binEntries( AIDA::IAxis::OVERFLOW_BIN, AIDA::IAxis::OVERFLOW_BIN, AIDA::IAxis::OVERFLOW_BIN );
216 std::ostream&
print( std::ostream&
s )
const override;
218 std::ostream&
write( std::ostream&
s )
const override;
220 int write(
const char* file_name )
const override;
229 std::unique_ptr<IMPLEMENTATION>
m_rep;
233 int m_sumEntries = 0;
236 template <
class INTERFACE,
class IMPLEMENTATION>
238 m_rep->SetTitle( title.c_str() );
239 if ( !annotation().addItem(
"Title", title ) ) m_annotation.setValue(
"Title", title );
240 if ( !annotation().addItem(
"title", title ) ) annotation().setValue(
"title", title );
244 template <
class INTERFACE,
class IMPLEMENTATION>
246 m_rep->SetName( newName.c_str() );
247 m_annotation.setValue(
"Name", newName );
250 template <
class INTERFACE,
class IMPLEMENTATION>
252 return m_rep->GetEntries();
255 template <
class INTERFACE,
class IMPLEMENTATION>
257 return int( m_rep->GetEntries() );
260 template <
class INTERFACE,
class IMPLEMENTATION>
262 return m_rep->GetMinimum();
265 template <
class INTERFACE,
class IMPLEMENTATION>
267 return m_rep->GetMaximum();
270 template <
class INTERFACE,
class IMPLEMENTATION>
272 return m_rep->GetSumOfWeights();
275 template <
class INTERFACE,
class IMPLEMENTATION>
277 return m_rep->GetSum();
280 template <
class INTERFACE,
class IMPLEMENTATION>
282 if ( sumBinHeights() <= 0 )
return 0;
284 m_rep->GetStats( stats );
285 return stats[0] * stats[0] / stats[1];
288 template <
class INTERFACE,
class IMPLEMENTATION>
290 m_rep->Scale( scaleFactor );
294 template <
class INTERFACE,
class IMPLEMENTATION>
297 m_rep->Print(
"all" );
302 template <
class INTERFACE,
class IMPLEMENTATION>
304 s <<
"\n3D Histogram Table: " << std::endl;
305 s <<
"BinX, BinY, BinZ, Height, Error " << std::endl;
306 for (
int i = 0; i < xAxis().bins(); ++i )
307 for (
int j = 0;
j < yAxis().bins(); ++
j )
308 for (
int k = 0; k < zAxis().bins(); ++k )
309 s << binMeanX( i,
j, k ) <<
", " << binMeanY( i,
j, k ) <<
", " << binMeanZ( i,
j, k ) <<
", "
310 << binHeight( i,
j, k ) <<
", " << binError( i,
j, k ) << std::endl;
316 template <
class INTERFACE,
class IMPLEMENTATION>
318 TFile* f = TFile::Open( file_name,
"RECREATE" );
319 Int_t nbytes = m_rep->Write();
326 # pragma clang diagnostic pop
327 #elif defined( __GNUC__ )
328 # pragma GCC diagnostic pop
double maxBinHeight() const override
Get the maximum height of the in-range bins.
double meanX() const override
The mean of the IHistogram3D along the x axis.
int coordToIndexY(double coord) const override
Get the bin number corresponding to a given coordinate along the y axis.
double rmsY() const override
The RMS of the IHistogram3D along the y axis.
AIDA::IAnnotation & annotation() override
Access annotation object.
int dimension() const override
Get the Histogram's dimension.
std::unique_ptr< IMPLEMENTATION > m_rep
Reference to underlying implementation.
bool scale(double scaleFactor) override
Scale the weights and the errors of all the IHistogram's bins (in-range and out-of-range ones) by a g...
double binHeight(int indexX, int indexY, int indexZ) const
Total height of the corresponding bin (ie the sum of the weights in this bin).
double sumAllBinHeights() const override
Get the sum of all the bins heights (including underflow and overflow bin).
double equivalentBinEntries() const override
Number of equivalent entries, i.e. SUM[ weight ] ^ 2 / SUM[ weight^2 ]
Implementation of the AIDA IAnnotation interface class.
const AIDA::IAxis & zAxis() const override
Get the z axis of the IHistogram3D.
int write(const char *file_name) const override
Write (ASCII) the histogram table into a file.
double meanZ() const override
The mean of the IHistogram3D along the z axis.
Generic3D< INTERFACE, IMPLEMENTATION > Base
double binHeightZ(int index) const override
Sum of all the heights of the bins along a given z bin.
Generic3D()=default
Default constructor.
int rIndexX(int index) const
double binHeightX(int index) const override
Sum of all the heights of the bins along a given x bin.
const AIDA::IAxis & xAxis() const override
Get the x axis of the IHistogram3D.
int coordToIndexX(double coord) const override
Get the bin number corresponding to a given coordinate along the x axis.
double binHeightY(int index) const override
Sum of all the heights of the bins along a given y bin.
const AIDA::IAxis & yAxis() const override
Get the y axis of the IHistogram3D.
Generic3D(IMPLEMENTATION *p)
constructor
int rIndexY(int index) const
double rmsX() const override
The RMS of the IHistogram3D along the x axis.
double meanY() const override
The mean of the IHistogram3D along the y axis.
TObject * representation() const override
ROOT object implementation.
int binEntriesX(int index) const override
Sum of all the entries of the bins along a given x bin.
int binEntriesY(int index) const override
Sum of all the entries of the bins along a given y bin.
double sumBinHeights() const override
Get the sum of in range bin heights in the IProfile.
std::string name() const
object name
double rmsZ() const override
The RMS of the IHistogram3D along the z axis.
int allEntries() const override
Get the number or all the entries, both in range and underflow/overflow bins of the IProfile.
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
bool setName(const std::string &newName)
Sets the name of the object.
int extraEntries() const override
void adoptRepresentation(TObject *rep) override
Adopt ROOT histogram representation.
std::ostream & write(std::ostream &s) const override
Write (ASCII) the histogram table into the output stream.
int binEntries(int indexX, int indexY, int indexZ) const override
Number of entries in the corresponding bin (ie the number of times fill was calle d for this bin).
An IAxis represents a binned histogram axis.
double minBinHeight() const override
Get the minimum height of the in-range bins.
std::ostream & print(std::ostream &s) const override
Print (ASCII) the histogram into the output stream.
int entries() const override
Get the number or all the entries.
double sumExtraBinHeights() const override
Get the sum of the underflow and overflow bin height.
int coordToIndexZ(double coord) const override
Get the bin number corresponding to a given coordinate along the z axis.
int rIndexZ(int index) const
const AIDA::IAnnotation & annotation() const override
Access annotation object (cons)
bool setTitle(const std::string &title) override
Set the title of the object.
AIDA::Annotation m_annotation
Object annotations.
bool add(const INTERFACE &hist) override
Add to this Histogram3D the contents of another IHistogram3D.
double binMeanX(int indexX, int, int) const override
The weighted mean along the x axis of a given bin.
double binMeanY(int, int indexY, int) const override
The weighted mean along the y axis of a given bin.
int binEntriesZ(int index) const override
Sum of all the entries of the bins along a given z bin.
double binError(int indexX, int indexY, int indexZ) const override
The error of a given bin.
std::string title() const override
Get the title of the object.
size_t index(const Gaudi::ParticleProperty *property, const Gaudi::Interfaces::IParticlePropertySvc *service)
helper utility for mapping of Gaudi::ParticleProperty object into non-negative integral sequential id...
double binMeanZ(int, int, int indexZ) const override
The weighted mean along the z axis of a given bin.