Go to the documentation of this file.
   11 #ifndef GAUDISVC_GENERIC3D_H 
   12 #define GAUDISVC_GENERIC3D_H 1 
   16 #include <AIDA/IHistogram3D.h> 
   25 #  pragma clang diagnostic push 
   26 #  pragma clang diagnostic ignored "-Wsuggest-override" 
   27 #  pragma clang diagnostic ignored "-Winconsistent-missing-override" 
   28 #elif defined( __GNUC__ ) 
   29 #  pragma GCC diagnostic push 
   30 #  pragma GCC diagnostic ignored "-Wsuggest-override" 
   45   template <
typename INTERFACE, 
typename IMPLEMENTATION>
 
   73     AIDA::IAnnotation& 
annotation()
 override { 
return m_annotation; }
 
   75     const AIDA::IAnnotation& 
annotation()
 const override { 
return m_annotation; }
 
   97     double binMeanX( 
int indexX, 
int, 
int )
 const override {
 
   98       return m_rep->GetXaxis()->GetBinCenter( rIndexX( indexX ) );
 
  101     double binMeanY( 
int, 
int indexY, 
int )
 const override {
 
  102       return m_rep->GetYaxis()->GetBinCenter( rIndexY( indexY ) );
 
  105     double binMeanZ( 
int, 
int, 
int indexZ )
 const override {
 
  106       return m_rep->GetYaxis()->GetBinCenter( rIndexY( indexZ ) );
 
  109     int binEntries( 
int indexX, 
int indexY, 
int indexZ )
 const override {
 
  110       if ( binHeight( indexX, indexY, indexZ ) <= 0 ) 
return 0;
 
  111       double xx = binHeight( indexX, indexY, indexZ ) / binError( indexX, indexY, indexZ );
 
  112       return int( xx * xx + 0.5 );
 
  117       for ( 
int i = -2; i < yAxis().bins(); ++i )
 
  118         for ( 
int j = -2; 
j < zAxis().bins(); ++
j ) 
n += binEntries( 
index, i, 
j );
 
  124       for ( 
int i = -2; i < xAxis().bins(); ++i )
 
  125         for ( 
int j = -2; 
j < zAxis().bins(); ++
j ) 
n += binEntries( i, 
index, 
j );
 
  132       for ( 
int i = -2; i < xAxis().bins(); ++i )
 
  133         for ( 
int j = -2; 
j < yAxis().bins(); ++
j ) 
n += binEntries( i, 
j, 
index );
 
  138     double binHeight( 
int indexX, 
int indexY, 
int indexZ )
 const {
 
  139       return m_rep->GetBinContent( rIndexX( indexX ), rIndexY( indexY ), rIndexZ( indexZ ) );
 
  145       for ( 
int i = -2; i < yAxis().bins(); ++i )
 
  146         for ( 
int j = -2; 
j < zAxis().bins(); ++
j ) 
s += binHeight( 
index, i, 
j );
 
  152       for ( 
int i = -2; i < xAxis().bins(); ++i )
 
  153         for ( 
int j = -2; 
j < zAxis().bins(); ++
j ) 
s += binHeight( i, 
index, 
j );
 
  159       for ( 
int i = -2; i < xAxis().bins(); ++i )
 
  160         for ( 
int j = -2; 
j < yAxis().bins(); ++
j ) 
s += binHeight( i, 
j, 
index );
 
  164     double binError( 
int indexX, 
int indexY, 
int indexZ )
 const override {
 
  165       return m_rep->GetBinError( rIndexX( indexX ), rIndexY( indexY ), rIndexZ( indexZ ) );
 
  168     double meanX()
 const override { 
return m_rep->GetMean( 1 ); }
 
  171     double meanY()
 const override { 
return m_rep->GetMean( 2 ); }
 
  173     double meanZ()
 const override { 
return m_rep->GetMean( 3 ); }
 
  175     double rmsX()
 const override { 
return m_rep->GetRMS( 1 ); }
 
  177     double rmsY()
 const override { 
return m_rep->GetRMS( 2 ); }
 
  179     double rmsZ()
 const override { 
return m_rep->GetRMS( 3 ); }
 
  181     const AIDA::IAxis& 
xAxis()
 const override { 
return m_xAxis; }
 
  183     const AIDA::IAxis& 
yAxis()
 const override { 
return m_yAxis; }
 
  185     const AIDA::IAxis& 
zAxis()
 const override { 
return m_zAxis; }
 
  187     int coordToIndexX( 
double coord )
 const override { 
return xAxis().coordToIndex( coord ); }
 
  189     int coordToIndexY( 
double coord )
 const override { 
return yAxis().coordToIndex( coord ); }
 
  191     int coordToIndexZ( 
double coord )
 const override { 
return zAxis().coordToIndex( coord ); }
 
  197     bool scale( 
double scaleFactor ) 
override;
 
  199     bool add( 
const INTERFACE& hist )
 override {
 
  200       const Base* p = 
dynamic_cast<const Base*
>( &hist );
 
  201       if ( !p ) 
throw std::runtime_error( 
"Cannot add profile histograms of different implementations." );
 
  208       return binEntries( AIDA::IAxis::UNDERFLOW_BIN, AIDA::IAxis::UNDERFLOW_BIN, AIDA::IAxis::UNDERFLOW_BIN ) +
 
  209              binEntries( AIDA::IAxis::UNDERFLOW_BIN, AIDA::IAxis::UNDERFLOW_BIN, AIDA::IAxis::OVERFLOW_BIN ) +
 
  210              binEntries( AIDA::IAxis::UNDERFLOW_BIN, AIDA::IAxis::OVERFLOW_BIN, AIDA::IAxis::UNDERFLOW_BIN ) +
 
  211              binEntries( AIDA::IAxis::OVERFLOW_BIN, AIDA::IAxis::UNDERFLOW_BIN, AIDA::IAxis::UNDERFLOW_BIN ) +
 
  212              binEntries( AIDA::IAxis::OVERFLOW_BIN, AIDA::IAxis::UNDERFLOW_BIN, AIDA::IAxis::OVERFLOW_BIN ) +
 
  213              binEntries( AIDA::IAxis::OVERFLOW_BIN, AIDA::IAxis::OVERFLOW_BIN, AIDA::IAxis::UNDERFLOW_BIN ) +
 
  214              binEntries( AIDA::IAxis::OVERFLOW_BIN, AIDA::IAxis::OVERFLOW_BIN, AIDA::IAxis::OVERFLOW_BIN );
 
  221     int write( 
const char* file_name ) 
const override;
 
  234     int m_sumEntries = 0;
 
  237   template <
class INTERFACE, 
class IMPLEMENTATION>
 
  239     m_rep->SetTitle( title.
c_str() );
 
  240     if ( !annotation().addItem( 
"Title", title ) ) m_annotation.setValue( 
"Title", title );
 
  241     if ( !annotation().addItem( 
"title", title ) ) annotation().setValue( 
"title", title );
 
  245   template <
class INTERFACE, 
class IMPLEMENTATION>
 
  247     m_rep->SetName( newName.
c_str() );
 
  248     m_annotation.setValue( 
"Name", newName );
 
  251   template <
class INTERFACE, 
class IMPLEMENTATION>
 
  253     return m_rep->GetEntries();
 
  256   template <
class INTERFACE, 
class IMPLEMENTATION>
 
  258     return int( m_rep->GetEntries() );
 
  261   template <
class INTERFACE, 
class IMPLEMENTATION>
 
  263     return m_rep->GetMinimum();
 
  266   template <
class INTERFACE, 
class IMPLEMENTATION>
 
  268     return m_rep->GetMaximum();
 
  271   template <
class INTERFACE, 
class IMPLEMENTATION>
 
  273     return m_rep->GetSumOfWeights();
 
  276   template <
class INTERFACE, 
class IMPLEMENTATION>
 
  278     return m_rep->GetSum();
 
  281   template <
class INTERFACE, 
class IMPLEMENTATION>
 
  283     if ( sumBinHeights() <= 0 ) 
return 0;
 
  285     m_rep->GetStats( stats );
 
  286     return stats[0] * stats[0] / stats[1];
 
  289   template <
class INTERFACE, 
class IMPLEMENTATION>
 
  291     m_rep->Scale( scaleFactor );
 
  295   template <
class INTERFACE, 
class IMPLEMENTATION>
 
  298     m_rep->Print( 
"all" );
 
  303   template <
class INTERFACE, 
class IMPLEMENTATION>
 
  306     s << 
"BinX, BinY, BinZ, Height, Error " << 
std::endl;
 
  307     for ( 
int i = 0; i < xAxis().bins(); ++i )
 
  308       for ( 
int j = 0; 
j < yAxis().bins(); ++
j )
 
  309         for ( 
int k = 0; k < zAxis().bins(); ++k )
 
  310           s << binMeanX( i, 
j, k ) << 
", " << binMeanY( i, 
j, k ) << 
", " << binMeanZ( i, 
j, k ) << 
", " 
  311             << binHeight( i, 
j, k ) << 
", " << binError( i, 
j, k ) << 
std::endl;
 
  317   template <
class INTERFACE, 
class IMPLEMENTATION>
 
  319     TFile* f      = TFile::Open( file_name, 
"RECREATE" );
 
  320     Int_t  nbytes = m_rep->Write();
 
  327 #  pragma clang diagnostic pop 
  328 #elif defined( __GNUC__ ) 
  329 #  pragma GCC diagnostic pop 
  332 #endif // GAUDIPI_GENERIC3D_H 
  
 
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.