11 #ifndef GAUDISVC_GENERIC1D_H 12 #define GAUDISVC_GENERIC1D_H 1 14 #include "AIDA/IProfile1D.h" 25 # pragma clang diagnostic push 26 # pragma clang diagnostic ignored "-Winconsistent-missing-override" 27 #elif defined( __GNUC__ ) && __GNUC__ >= 5 28 # pragma GCC diagnostic push 29 # pragma GCC diagnostic ignored "-Wsuggest-override" 44 template <
class INTERFACE,
class IMPLEMENTATION>
63 void adoptRepresentation( TObject* rep )
override;
73 AIDA::IAnnotation&
annotation()
override {
return m_annotation; }
75 const AIDA::IAnnotation&
annotation()
const override {
return m_annotation; }
79 const Axis&
axis()
const override {
return m_axis; }
82 int entries()
const override {
return m_rep->GetEntries(); }
84 int allEntries()
const override {
return m_rep->GetEntries(); }
86 int extraEntries()
const override;
88 int binEntries(
int index )
const override;
90 virtual double binRms(
int index )
const;
92 double sumBinHeights()
const override {
return m_rep->GetSumOfWeights(); }
98 double minBinHeight()
const override {
return m_rep->GetMinimum(); }
103 virtual double equivalentBinEntries()
const;
106 virtual bool scale(
double scaleFactor );
108 bool reset()
override;
110 bool add(
const INTERFACE& profile )
override;
112 virtual int rIndex(
int index )
const {
return m_axis.rIndex( index ); }
114 double binMean(
int index )
const override;
116 double binHeight(
int index )
const override;
118 double binError(
int index )
const override;
120 double mean()
const override {
return m_rep->GetMean(); }
122 double rms()
const override {
return m_rep->GetRMS(); }
124 int coordToIndex(
double coord )
const override {
return axis().coordToIndex( coord ); }
132 int write(
const char* file_name )
const override;
147 template <
class INTERFACE,
class IMPLEMENTATION>
149 m_rep->SetTitle( title.
c_str() );
150 if ( !annotation().addItem(
"Title", title ) ) m_annotation.setValue(
"Title", title );
151 if ( !annotation().addItem(
"title", title ) ) annotation().setValue(
"title", title );
155 template <
class INTERFACE,
class IMPLEMENTATION>
157 m_rep->SetName( newName.
c_str() );
158 m_annotation.setValue(
"Name", newName );
162 template <
class INTERFACE,
class IMPLEMENTATION>
164 return m_rep->GetBinError( rIndex( index ) );
167 template <
class INTERFACE,
class IMPLEMENTATION>
169 return m_rep->GetBinCenter( rIndex( index ) );
172 template <
class INTERFACE,
class IMPLEMENTATION>
174 return m_rep->GetBinContent( rIndex( index ) );
177 template <
class INTERFACE,
class IMPLEMENTATION>
179 return m_rep->GetBinError( rIndex( index ) );
182 template <
class INTERFACE,
class IMPLEMENTATION>
184 return binEntries( AIDA::IAxis::UNDERFLOW_BIN ) + binEntries( AIDA::IAxis::OVERFLOW_BIN );
186 template <
class INTERFACE,
class IMPLEMENTATION>
193 template <
class INTERFACE,
class IMPLEMENTATION>
195 if ( sumBinHeights() <= 0 )
return 0;
197 m_rep->GetStats( stats );
198 return stats[0] * stats[0] / stats[1];
201 template <
class INTERFACE,
class IMPLEMENTATION>
203 m_rep->Scale( scaleFactor );
207 template <
class INTERFACE,
class IMPLEMENTATION>
214 throw std::runtime_error(
"Cannot add profile histograms of different implementations." );
217 template <
class INTERFACE,
class IMPLEMENTATION>
220 m_rep->Print(
"all" );
225 template <
class INTERFACE,
class IMPLEMENTATION>
229 for (
int i = 0; i < axis().bins(); ++i )
230 s << binMean( i ) <<
", " << binHeight( i ) <<
", " << binError( i ) <<
std::endl;
236 template <
class INTERFACE,
class IMPLEMENTATION>
238 TFile* f = TFile::Open( file_name,
"RECREATE" );
239 Int_t nbytes = m_rep->Write();
246 # pragma clang diagnostic pop 247 #elif defined( __GNUC__ ) && __GNUC__ >= 5 248 # pragma GCC diagnostic pop 251 #endif // AIDAROOT_GENERIC1D_H double maxBinHeight() const override
Get the maximum height of the in-range bins.
double rms() const override
The RMS of the whole IHistogram1D.
double sumAllBinHeights() const override
Get the sum of all the bins heights (including underflow and overflow bin).
virtual double binRms(int index) const
bool reset() override
Reset the Histogram; as if just created.
std::ostream & print(std::ostream &s) const override
Print (ASCII) the histogram into the output stream.
virtual const std::string & userLevelClassType() const
The AIDA user-level unterface leaf class type.
double binMean(int index) const override
The weighted mean of a bin.
double binError(int index) const override
The error of a given bin.
int allEntries() const override
Get the number or all the entries, both in range and underflow/overflow bins of the IProfile.
Axis & axis()
Access to axis object.
std::unique_ptr< IMPLEMENTATION > m_rep
Reference to underlying implementation.
double sumBinHeights() const override
Get the sum of in range bin heights in the IProfile.
int coordToIndex(double coord) const override
Get the bin number corresponding to a given coordinate along the x axis.
AIDA::Annotation m_annotation
Object annotations.
double mean() const override
The mean of the whole IHistogram1D.
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.
double sumExtraBinHeights() const override
Get the sum of the underflow and overflow bin height.
Generic1D(IMPLEMENTATION *p)
constructor
Implementation of the AIDA IAnnotation interface class.
TObject * representation() const override
ROOT object implementation.
int dimension() const override
Get the Histogram's dimension.
int extraEntries() const override
Get the number of entries in the underflow and overflow bins.
Common base class for all histograms Use is solely functional to minimize dynamic_casts inside Histog...
virtual int rIndex(int index) const
operator methods
const Axis & axis() const override
Get the x axis of the IHistogram1D.
const AIDA::IAnnotation & annotation() const override
Access annotation object (cons)
double minBinHeight() const override
Get the minimum height of the in-range bins.
int entries() const override
Get the number or all the entries.
double binHeight(int index) const override
Total height of the corresponding bin (ie the sum of the weights in this bin).
std::ostream & write(std::ostream &s) const override
Write (ASCII) the histogram table into the output stream.
virtual double equivalentBinEntries() const
Number of equivalent entries, i.e. SUM[ weight ] ^ 2 / SUM[ weight^2 ]
AIDA::IAnnotation & annotation() override
Access annotation object.
std::string name() const
object name
std::string title() const override
Get the title of the object.
Header file for std:chrono::duration-based Counters.
An IAxis represents a binned histogram axis.
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...
Generic1D< INTERFACE, IMPLEMENTATION > Base
Common AIDA implementation stuff for histograms and profiles using ROOT implementations.