1 #ifndef GAUDISVC_GENERIC1D_H 2 #define GAUDISVC_GENERIC1D_H 1 11 #include "AIDA/IProfile1D.h" 17 #pragma clang diagnostic push 18 #pragma clang diagnostic ignored "-Winconsistent-missing-override" 19 #elif defined(__GNUC__) && __GNUC__ >= 5 20 #pragma GCC diagnostic push 21 #pragma GCC diagnostic ignored "-Wsuggest-override" 36 template <
class INTERFACE,
class IMPLEMENTATION>
55 void adoptRepresentation(TObject*rep)
override;
65 AIDA::IAnnotation &
annotation()
override {
return m_annotation; }
67 const AIDA::IAnnotation &
annotation()
const override {
return m_annotation; }
71 const Axis &
axis ()
const override {
return m_axis; }
74 int entries()
const override {
return m_rep->GetEntries(); }
76 int allEntries()
const override {
return m_rep->GetEntries(); }
78 int extraEntries()
const override;
80 int binEntries (
int index )
const override;
82 virtual double binRms(
int index)
const;
84 double sumBinHeights()
const override {
return m_rep->GetSumOfWeights(); }
90 double minBinHeight()
const override {
return m_rep->GetMinimum(); }
92 double maxBinHeight()
const override {
return m_rep->GetMaximum(); }
95 virtual double equivalentBinEntries ( )
const;
97 virtual bool scale(
double scaleFactor ) ;
99 bool reset()
override;
101 bool add(
const INTERFACE & profile)
override;
103 virtual int rIndex(
int index)
const {
return m_axis.rIndex(index);}
105 double binMean(
int index)
const override;
107 double binHeight(
int index)
const override;
109 double binError(
int index)
const override;
111 double mean()
const override {
return m_rep->GetMean(); }
113 double rms ()
const override {
return m_rep->GetRMS(); }
115 int coordToIndex (
double coord )
const override{
return axis().coordToIndex(coord);}
123 int write(
const char* file_name )
const override;
138 template <
class INTERFACE,
class IMPLEMENTATION>
140 m_rep->SetTitle(title.
c_str());
141 if ( !annotation().addItem(
"Title", title ) )
142 m_annotation.setValue(
"Title" , title );
143 if ( !annotation().addItem(
"title", title ) )
144 annotation().setValue(
"title", title );
148 template <
class INTERFACE,
class IMPLEMENTATION>
150 m_rep->SetName(newName.
c_str());
151 m_annotation.setValue(
"Name", newName );
155 template <
class INTERFACE,
class IMPLEMENTATION>
157 return m_rep->GetBinError ( rIndex(index) );
160 template <
class INTERFACE,
class IMPLEMENTATION>
162 return m_rep->GetBinCenter ( rIndex(index) );
165 template <
class INTERFACE,
class IMPLEMENTATION>
167 return m_rep->GetBinContent ( rIndex(index) );
170 template <
class INTERFACE,
class IMPLEMENTATION>
172 return m_rep->GetBinError ( rIndex(index) );
175 template <
class INTERFACE,
class IMPLEMENTATION>
177 return binEntries(AIDA::IAxis::UNDERFLOW_BIN) +
178 binEntries(AIDA::IAxis::OVERFLOW_BIN);
180 template <
class INTERFACE,
class IMPLEMENTATION>
187 template <
class INTERFACE,
class IMPLEMENTATION>
189 if (sumBinHeights() <= 0)
return 0;
191 m_rep->GetStats(stats);
192 return stats[0]*stats[0]/stats[1];
195 template <
class INTERFACE,
class IMPLEMENTATION>
197 m_rep->Scale ( scaleFactor );
201 template <
class INTERFACE,
class IMPLEMENTATION>
209 throw std::runtime_error(
"Cannot add profile histograms of different implementations.");
212 template <
class INTERFACE,
class IMPLEMENTATION>
220 template <
class INTERFACE,
class IMPLEMENTATION>
222 s <<
"\n1D Histogram Table: " <<
std::endl;
224 for(
int i = 0; i < axis().bins(); ++i )
225 s << binMean( i ) <<
", " 226 << binHeight( i ) <<
", " 233 template <
class INTERFACE,
class IMPLEMENTATION>
236 TFile *f = TFile::Open(file_name,
"RECREATE");
237 Int_t nbytes = m_rep->Write();
244 #pragma clang diagnostic pop 245 #elif defined(__GNUC__) && __GNUC__ >= 5 246 #pragma GCC diagnostic pop 249 #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.
Generic1D< INTERFACE, IMPLEMENTATION > Base
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
Common AIDA implementation stuff for histograms and profiles using ROOT implementations.