1 #ifndef GAUDISVC_GENERIC1D_H 2 #define GAUDISVC_GENERIC1D_H 1 4 #include "AIDA/IProfile1D.h" 15 #pragma clang diagnostic push 16 #pragma clang diagnostic ignored "-Winconsistent-missing-override" 17 #elif defined( __GNUC__ ) && __GNUC__ >= 5 18 #pragma GCC diagnostic push 19 #pragma GCC diagnostic ignored "-Wsuggest-override" 35 template <
class INTERFACE,
class IMPLEMENTATION>
57 void adoptRepresentation( TObject* rep )
override;
67 AIDA::IAnnotation&
annotation()
override {
return m_annotation; }
69 const AIDA::IAnnotation&
annotation()
const override {
return m_annotation; }
73 const Axis&
axis()
const override {
return m_axis; }
76 int entries()
const override {
return m_rep->GetEntries(); }
78 int allEntries()
const override {
return m_rep->GetEntries(); }
80 int extraEntries()
const override;
82 int binEntries(
int index )
const override;
84 virtual double binRms(
int index )
const;
86 double sumBinHeights()
const override {
return m_rep->GetSumOfWeights(); }
92 double minBinHeight()
const override {
return m_rep->GetMinimum(); }
94 double maxBinHeight()
const override {
return m_rep->GetMaximum(); }
97 virtual double equivalentBinEntries()
const;
100 virtual bool scale(
double scaleFactor );
102 bool reset()
override;
104 bool add(
const INTERFACE& profile )
override;
106 virtual int rIndex(
int index )
const {
return m_axis.rIndex( index ); }
108 double binMean(
int index )
const override;
110 double binHeight(
int index )
const override;
112 double binError(
int index )
const override;
114 double mean()
const override {
return m_rep->GetMean(); }
116 double rms()
const override {
return m_rep->GetRMS(); }
118 int coordToIndex(
double coord )
const override {
return axis().coordToIndex( coord ); }
126 int write(
const char* file_name )
const override;
141 template <
class INTERFACE,
class IMPLEMENTATION>
144 m_rep->SetTitle( title.
c_str() );
145 if ( !annotation().addItem(
"Title", title ) ) m_annotation.setValue(
"Title", title );
146 if ( !annotation().addItem(
"title", title ) ) annotation().setValue(
"title", title );
150 template <
class INTERFACE,
class IMPLEMENTATION>
153 m_rep->SetName( newName.
c_str() );
154 m_annotation.setValue(
"Name", newName );
158 template <
class INTERFACE,
class IMPLEMENTATION>
161 return m_rep->GetBinError( rIndex( index ) );
164 template <
class INTERFACE,
class IMPLEMENTATION>
167 return m_rep->GetBinCenter( rIndex( index ) );
170 template <
class INTERFACE,
class IMPLEMENTATION>
173 return m_rep->GetBinContent( rIndex( index ) );
176 template <
class INTERFACE,
class IMPLEMENTATION>
179 return m_rep->GetBinError( rIndex( index ) );
182 template <
class INTERFACE,
class IMPLEMENTATION>
185 return binEntries( AIDA::IAxis::UNDERFLOW_BIN ) + binEntries( AIDA::IAxis::OVERFLOW_BIN );
187 template <
class INTERFACE,
class IMPLEMENTATION>
195 template <
class INTERFACE,
class IMPLEMENTATION>
198 if ( sumBinHeights() <= 0 )
return 0;
200 m_rep->GetStats( stats );
201 return stats[0] * stats[0] / stats[1];
204 template <
class INTERFACE,
class IMPLEMENTATION>
207 m_rep->Scale( scaleFactor );
211 template <
class INTERFACE,
class IMPLEMENTATION>
219 throw std::runtime_error(
"Cannot add profile histograms of different implementations." );
222 template <
class INTERFACE,
class IMPLEMENTATION>
226 m_rep->Print(
"all" );
231 template <
class INTERFACE,
class IMPLEMENTATION>
234 s <<
"\n1D Histogram Table: " <<
std::endl;
236 for (
int i = 0; i < axis().bins(); ++i )
237 s << binMean( i ) <<
", " << binHeight( i ) <<
", " << binError( i ) <<
std::endl;
243 template <
class INTERFACE,
class IMPLEMENTATION>
246 TFile* f = TFile::Open( file_name,
"RECREATE" );
247 Int_t nbytes = m_rep->Write();
254 #pragma clang diagnostic pop 255 #elif defined( __GNUC__ ) && __GNUC__ >= 5 256 #pragma GCC diagnostic pop 259 #endif // AIDAROOT_GENERIC1D_H 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.
int entries() const override
Get the number or all the entries.
bool reset() override
Reset the Histogram; as if just created.
double maxBinHeight() const override
Get the maximum height of the in-range bins.
double sumBinHeights() const override
Get the sum of in range bin heights in the IProfile.
double binHeight(int index) const override
Total height of the corresponding bin (ie the sum of the weights in this bin).
double sumExtraBinHeights() const override
Get the sum of the underflow and overflow bin height.
int extraEntries() const override
Get the number of entries in the underflow and overflow bins.
double binError(int index) const override
The error of a given bin.
virtual double binRms(int index) const
const Axis & axis() const override
Get the x axis of the IHistogram1D.
Axis & axis()
Access to axis object.
std::unique_ptr< IMPLEMENTATION > m_rep
Reference to underlying implementation.
AIDA::Annotation m_annotation
Object annotations.
bool add(const INTERFACE &profile) override
Modifies this IProfile1D by adding the contents of profile to it.
bool setTitle(const std::string &title) override
Set the title of the object.
const AIDA::IAnnotation & annotation() const override
Access annotation object (cons)
int allEntries() const override
Get the number or all the entries, both in range and underflow/overflow bins of the IProfile...
double sumAllBinHeights() const override
Get the sum of all the bins heights (including underflow and overflow bin).
Generic1D(IMPLEMENTATION *p)
constructor
Implementation of the AIDA IAnnotation interface class.
int dimension() const override
Get the Histogram's dimension.
double minBinHeight() const override
Get the minimum height of the in-range bins.
double rms() const override
The RMS of the whole IHistogram1D.
virtual const std::string & userLevelClassType() const
The AIDA user-level unterface leaf class type.
std::ostream & print(std::ostream &s) const override
Print (ASCII) the histogram into the output stream.
Common base class for all histograms Use is solely functional to minimize dynamic_casts inside Histog...
TObject * representation() const override
ROOT object implementation.
double binMean(int index) const override
The weighted mean of a bin.
int coordToIndex(double coord) const override
Get the bin number corresponding to a given coordinate along the x axis.
virtual double equivalentBinEntries() const
Number of equivalent entries, i.e. SUM[ weight ] ^ 2 / SUM[ weight^2 ]
virtual int rIndex(int index) const
operator methods
AIDA::IAnnotation & annotation() override
Access annotation object.
Helper functions to set/get the application return code.
An IAxis represents a binned histogram axis.
double mean() const override
The mean of the whole IHistogram1D.
bool setName(const std::string &newName)
Set the name of the object.
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...
std::string name() const
object name
Generic1D< INTERFACE, IMPLEMENTATION > Base
Common AIDA implementation stuff for histograms and profiles using ROOT implementations.