Go to the documentation of this file.
11 #ifndef GAUDISVC_GENERIC2D_H
12 #define GAUDISVC_GENERIC2D_H 1
16 #include <AIDA/IProfile2D.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 <
class INTERFACE,
class IMPLEMENTATION>
70 AIDA::IAnnotation&
annotation()
override {
return m_annotation; }
72 const AIDA::IAnnotation&
annotation()
const override {
return m_annotation; }
75 const AIDA::IAxis&
xAxis()
const override {
return m_xAxis; }
77 const AIDA::IAxis&
yAxis()
const override {
return m_yAxis; }
101 double binMeanX(
int indexX,
int indexY )
const override;
103 double binMeanY(
int indexX,
int indexY )
const override;
111 double binHeight(
int indexX,
int indexY )
const override;
117 double binError(
int indexX,
int indexY )
const override;
119 virtual double binRms(
int indexX,
int indexY )
const;
136 virtual bool scale(
double scaleFactor );
138 bool add(
const INTERFACE&
h )
override;
152 int write(
const char* file_name )
const override;
166 int m_sumEntries = 0;
169 template <
class INTERFACE,
class IMPLEMENTATION>
171 m_rep->SetTitle( title.
c_str() );
172 if ( !annotation().addItem(
"Title", title ) ) m_annotation.setValue(
"Title", title );
173 if ( !annotation().addItem(
"title", title ) ) annotation().setValue(
"title", title );
177 template <
class INTERFACE,
class IMPLEMENTATION>
179 m_rep->SetName( newName.
c_str() );
180 m_annotation.setValue(
"Name", newName );
184 template <
class INTERFACE,
class IMPLEMENTATION>
186 return m_rep->GetEntries();
189 template <
class INTERFACE,
class IMPLEMENTATION>
191 return m_rep->GetEntries();
194 template <
class INTERFACE,
class IMPLEMENTATION>
196 return m_rep->GetMinimum();
199 template <
class INTERFACE,
class IMPLEMENTATION>
201 return m_rep->GetMaximum();
204 template <
class INTERFACE,
class IMPLEMENTATION>
206 return m_rep->GetSumOfWeights();
209 template <
class INTERFACE,
class IMPLEMENTATION>
211 return m_rep->GetSum();
214 template <
class INTERFACE,
class IMPLEMENTATION>
216 return m_rep->GetBinError( rIndexX( indexX ), rIndexY( indexY ) );
219 template <
class INTERFACE,
class IMPLEMENTATION>
221 return m_rep->GetXaxis()->GetBinCenter( rIndexX( indexX ) );
224 template <
class INTERFACE,
class IMPLEMENTATION>
226 return m_rep->GetYaxis()->GetBinCenter( rIndexY( indexY ) );
229 template <
class INTERFACE,
class IMPLEMENTATION>
232 for (
int iY = -2; iY < yAxis().bins(); ++iY )
n += binEntries(
index, iY );
236 template <
class INTERFACE,
class IMPLEMENTATION>
239 for (
int iX = -2; iX < xAxis().bins(); ++iX )
n += binEntries( iX,
index );
243 template <
class INTERFACE,
class IMPLEMENTATION>
245 return m_rep->GetBinContent( rIndexX( indexX ), rIndexY( indexY ) );
248 template <
class INTERFACE,
class IMPLEMENTATION>
251 for (
int iY = -2; iY < yAxis().bins(); ++iY ) {
s += binHeight(
index, iY ); }
255 template <
class INTERFACE,
class IMPLEMENTATION>
258 for (
int iX = -2; iX < xAxis().bins(); ++iX )
s += binHeight( iX,
index );
262 template <
class INTERFACE,
class IMPLEMENTATION>
264 return m_rep->GetBinError( rIndexX( indexX ), rIndexY( indexY ) );
267 template <
class INTERFACE,
class IMPLEMENTATION>
269 return m_rep->GetMean( 1 );
272 template <
class INTERFACE,
class IMPLEMENTATION>
274 return m_rep->GetMean( 2 );
277 template <
class INTERFACE,
class IMPLEMENTATION>
279 return m_rep->GetRMS( 1 );
282 template <
class INTERFACE,
class IMPLEMENTATION>
284 return m_rep->GetRMS( 2 );
287 template <
class INTERFACE,
class IMPLEMENTATION>
289 return xAxis().coordToIndex( coord );
292 template <
class INTERFACE,
class IMPLEMENTATION>
294 return yAxis().coordToIndex( coord );
297 template <
class INTERFACE,
class IMPLEMENTATION>
299 const Base* p =
dynamic_cast<const Base*
>( &hist );
300 if ( !p )
throw std::runtime_error(
"Cannot add profile histograms of different implementations." );
305 template <
class INTERFACE,
class IMPLEMENTATION>
307 return binEntries( AIDA::IAxis::UNDERFLOW_BIN, AIDA::IAxis::UNDERFLOW_BIN ) +
308 binEntries( AIDA::IAxis::UNDERFLOW_BIN, AIDA::IAxis::OVERFLOW_BIN ) +
309 binEntries( AIDA::IAxis::OVERFLOW_BIN, AIDA::IAxis::UNDERFLOW_BIN ) +
310 binEntries( AIDA::IAxis::OVERFLOW_BIN, AIDA::IAxis::OVERFLOW_BIN );
313 template <
class INTERFACE,
class IMPLEMENTATION>
315 if ( sumBinHeights() <= 0 )
return 0;
317 m_rep->GetStats( stats );
318 return stats[0] * stats[0] / stats[1];
321 template <
class INTERFACE,
class IMPLEMENTATION>
323 m_rep->Scale( scaleFactor );
327 template <
class INTERFACE,
class IMPLEMENTATION>
334 template <
class INTERFACE,
class IMPLEMENTATION>
337 m_rep->Print(
"all" );
342 template <
class INTERFACE,
class IMPLEMENTATION>
345 s <<
"BinX, BinY, Height, Error " <<
std::endl;
346 for (
int i = 0; i < xAxis().bins(); ++i ) {
347 for (
int j = 0;
j < yAxis().bins(); ++
j ) {
348 s << binMeanX( i,
j ) <<
", " << binMeanY( i,
j ) <<
", " << binHeight( i,
j ) <<
", " << binError( i,
j )
357 template <
class INTERFACE,
class IMPLEMENTATION>
359 TFile* f = TFile::Open( file_name,
"RECREATE" );
360 Int_t nbytes = m_rep->Write();
367 # pragma clang diagnostic pop
368 #elif defined( __GNUC__ )
369 # pragma GCC diagnostic pop
372 #endif // GAUDIPI_GENERIC2D_H
Generic2D< INTERFACE, IMPLEMENTATION > Base
int extraEntries() const override
Get the number of entries in the underflow and overflow bins.
double minBinHeight() const override
Get the minimum height of the in-range bins.
int dimension() const override
Get the Histogram's dimension.
double binMeanX(int indexX, int indexY) const override
The weighted mean along x of a given bin.
bool setName(const std::string &newName)
Set the name of the object.
TObject * representation() const override
ROOT object implementation.
const AIDA::IAxis & xAxis() const override
Return the X axis.
AIDA::Annotation m_annotation
Object annotations.
Implementation of the AIDA IAnnotation interface class.
int coordToIndexY(double coordY) const override
Convenience method, equivalent to yAxis().coordToIndex(coord).
double binHeightY(int indexY) const override
Equivalent to projectionY().binHeight(indexY).
int binEntriesX(int indexX) const override
Equivalent to projectionX().binEntries(indexX).
virtual int rIndexY(int index) const
operator methods
int coordToIndexX(double coordX) const override
Convenience method, equivalent to xAxis().coordToIndex(coord).
int write(const char *file_name) const override
Write (ASCII) the histogram table into a file.
virtual int rIndexX(int index) const
operator methods
int binEntriesY(int indexY) const override
Equivalent to projectionY().binEntries(indexY).
bool setTitle(const std::string &title) override
Set the title of the object.
double rmsY() const override
Returns the rms of the profile as calculated on filling-time projected on the Y axis.
double maxBinHeight() const override
Get the maximum height of the in-range bins.
void * cast(const std::string &className) const override
Introspection method.
double binMeanY(int indexX, int indexY) const override
The weighted mean along y of a given bin.
AIDA::IAnnotation & annotation() override
Access annotation object.
int binEntries(int indexX, int indexY) const override
The number of entries (ie the number of times fill was called for this bin).
Generic2D(IMPLEMENTATION *p)
constructor
void adoptRepresentation(TObject *rep) override
Adopt ROOT histogram representation.
const AIDA::IAnnotation & annotation() const override
Access annotation object (cons)
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 g...
int allEntries() const override
Get the number or all the entries, both in range and underflow/overflow bins of the IProfile.
Axis m_yAxis
Y axis member.
std::string m_classType
class type
bool add(const INTERFACE &h) override
Modifies this profile by adding the contents of profile to it.
double binHeightX(int indexX) const override
Equivalent to projectionX().binHeight(indexX).
const std::string & userLevelClassType() const
The AIDA user-level unterface leaf class type.
double sumAllBinHeights() const override
Get the sum of all the bins heights (including underflow and overflow bin).
const AIDA::IAxis & yAxis() const override
Return the Y axis.
Axis m_xAxis
X axis member.
double meanX() const override
Returns the mean of the profile, as calculated on filling-time projected on the X axis.
std::string title() const override
Get the title of the object.
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
virtual double binRms(int indexX, int indexY) const
The spread (RMS) of this bin.
An IAxis represents a binned histogram axis.
double rmsX() const override
Returns the rms of the profile as calculated on filling-time projected on the X axis.
std::string name() const
object name
std::unique_ptr< IMPLEMENTATION > m_rep
Reference to underlying implementation.
double binHeight(int indexX, int indexY) const override
Total height of the corresponding bin (ie the sum of the weights in this bin).
int entries() const override
Get the number or all the entries.
double binError(int indexX, int indexY) const override
The error on this bin.
double sumExtraBinHeights() const override
Get the sum of the underflow and overflow bin height.
double sumBinHeights() const override
Get the sum of in range bin heights in the IProfile.
std::ostream & write(std::ostream &s) const override
Write (ASCII) the histogram table into the output stream.
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...
std::ostream & print(std::ostream &s) const override
Print (ASCII) the histogram into the output stream.
double meanY() const override
Returns the mean of the profile, as calculated on filling-time projected on the Y axis.
virtual double equivalentBinEntries() const
Number of equivalent entries, i.e. SUM[ weight ] ^ 2 / SUM[ weight^2 ]