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>
70 bool setName(
const std::string& newName );
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 {
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 {
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 ); }
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." );
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;
236 template <
class INTERFACE,
class IMPLEMENTATION>
244 template <
class INTERFACE,
class IMPLEMENTATION>
246 m_rep->SetName( newName.c_str() );
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>
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 )
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
Implementation of the AIDA IAnnotation interface class.
An IAxis represents a binned histogram axis.
int allEntries() const override
Get the number or all the entries, both in range and underflow/overflow bins of the IProfile.
int coordToIndexY(double coord) const override
Get the bin number corresponding to a given coordinate along the y axis.
std::unique_ptr< IMPLEMENTATION > m_rep
Reference to underlying implementation.
std::string name() const
object name
const AIDA::IAxis & zAxis() const override
Get the z axis of the IHistogram3D.
double maxBinHeight() const override
Get the maximum height of the in-range bins.
Generic3D< INTERFACE, IMPLEMENTATION > Base
int write(const char *file_name) const override
Write (ASCII) the histogram table into a file.
AIDA::Annotation m_annotation
Object annotations.
double sumBinHeights() const override
Get the sum of in range bin heights in the IProfile.
double rmsX() const override
The RMS of the IHistogram3D along the x axis.
double equivalentBinEntries() const override
Number of equivalent entries, i.e. SUM[ weight ] ^ 2 / SUM[ weight^2 ]
double binError(int indexX, int indexY, int indexZ) const override
The error of a given bin.
double binHeightZ(int index) const override
Sum of all the heights of the bins along a given z bin.
std::string title() const override
Get the title of the object.
std::ostream & write(std::ostream &s) const override
Write (ASCII) the histogram table into the output stream.
double rmsZ() const override
The RMS of the IHistogram3D along the z axis.
int coordToIndexX(double coord) const override
Get the bin number corresponding to a given coordinate along the x axis.
bool add(const INTERFACE &hist) override
Add to this Histogram3D the contents of another IHistogram3D.
int binEntriesX(int index) const override
Sum of all the entries of the bins along a given x bin.
int binEntriesZ(int index) const override
Sum of all the entries of the bins along a given z bin.
int rIndexY(int index) const
Generic3D()=default
Default constructor.
double meanX() const override
The mean of the IHistogram3D along the x axis.
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).
int coordToIndexZ(double coord) const override
Get the bin number corresponding to a given coordinate along the z axis.
int rIndexZ(int index) const
void adoptRepresentation(TObject *rep) override
Adopt ROOT histogram representation.
int extraEntries() const override
double rmsY() const override
The RMS of the IHistogram3D along the y axis.
double meanZ() const override
The mean of the IHistogram3D along the z axis.
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 meanY() const override
The mean of the IHistogram3D along the y axis.
double binMeanY(int, int indexY, int) const override
The weighted mean along the y axis of a given bin.
int dimension() const override
Get the Histogram's dimension.
int entries() const override
Get the number or all the entries.
bool setName(const std::string &newName)
Sets the name of the object.
const AIDA::IAnnotation & annotation() const override
Access annotation object (cons)
const AIDA::IAxis & yAxis() const override
Get the y axis of the IHistogram3D.
double sumExtraBinHeights() const override
Get the sum of the underflow and overflow bin height.
const AIDA::IAxis & xAxis() const override
Get the x axis of the IHistogram3D.
double binMeanZ(int, int, int indexZ) const override
The weighted mean along the z axis of a given bin.
double minBinHeight() const override
Get the minimum height of the in-range bins.
double binHeightY(int index) const override
Sum of all the heights of the bins along a given y bin.
TObject * representation() const override
ROOT object implementation.
std::ostream & print(std::ostream &s) const override
Print (ASCII) the histogram into the output stream.
double sumAllBinHeights() const override
Get the sum of all the bins heights (including underflow and overflow bin).
bool setTitle(const std::string &title) override
Set the title of the object.
double binHeightX(int index) const override
Sum of all the heights of the bins along a given x bin.
Generic3D(IMPLEMENTATION *p)
constructor
int rIndexX(int index) const
double binHeight(int indexX, int indexY, int indexZ) const
Total height of the corresponding bin (ie the sum of the weights in this bin).
int binEntriesY(int index) const override
Sum of all the entries of the bins along a given y bin.
double binMeanX(int indexX, int, int) const override
The weighted mean along the x axis of a given bin.
AIDA::IAnnotation & annotation() override
Access annotation object.
Common base class for all histograms Use is solely functional to minimize dynamic_casts inside Histog...
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...