1 #ifndef GAUDISVC_GENERIC1D_H 2 #define GAUDISVC_GENERIC1D_H 1 9 #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" 34 template <
class INTERFACE,
class IMPLEMENTATION>
53 void adoptRepresentation(TObject*rep)
override;
63 AIDA::IAnnotation &
annotation()
override {
return m_annotation; }
65 const AIDA::IAnnotation &
annotation()
const override {
return m_annotation; }
69 const Axis &
axis ()
const override {
return m_axis; }
72 int entries()
const override {
return m_rep->GetEntries(); }
74 int allEntries()
const override {
return m_rep->GetEntries(); }
76 int extraEntries()
const override;
78 int binEntries (
int index )
const override;
80 virtual double binRms(
int index)
const;
82 double sumBinHeights()
const override {
return m_rep->GetSumOfWeights(); }
88 double minBinHeight()
const override {
return m_rep->GetMinimum(); }
90 double maxBinHeight()
const override {
return m_rep->GetMaximum(); }
93 virtual double equivalentBinEntries ( )
const;
95 virtual bool scale(
double scaleFactor ) ;
97 bool reset()
override;
99 bool add(
const INTERFACE & profile)
override;
101 virtual int rIndex(
int index)
const {
return m_axis.rIndex(index);}
103 double binMean(
int index)
const override;
105 double binHeight(
int index)
const override;
107 double binError(
int index)
const override;
109 double mean()
const override {
return m_rep->GetMean(); }
111 double rms ()
const override {
return m_rep->GetRMS(); }
113 int coordToIndex (
double coord )
const override{
return axis().coordToIndex(coord);}
121 int write(
const char* file_name )
const override;
136 template <
class INTERFACE,
class IMPLEMENTATION>
138 m_rep->SetTitle(title.
c_str());
139 if ( !annotation().addItem(
"Title", title ) )
140 m_annotation.setValue(
"Title" , title );
141 if ( !annotation().addItem(
"title", title ) )
142 annotation().setValue(
"title", title );
146 template <
class INTERFACE,
class IMPLEMENTATION>
148 m_rep->SetName(newName.
c_str());
149 m_annotation.setValue(
"Name", newName );
153 template <
class INTERFACE,
class IMPLEMENTATION>
155 return m_rep->GetBinError ( rIndex(index) );
158 template <
class INTERFACE,
class IMPLEMENTATION>
160 return m_rep->GetBinCenter ( rIndex(index) );
163 template <
class INTERFACE,
class IMPLEMENTATION>
165 return m_rep->GetBinContent ( rIndex(index) );
168 template <
class INTERFACE,
class IMPLEMENTATION>
170 return m_rep->GetBinError ( rIndex(index) );
173 template <
class INTERFACE,
class IMPLEMENTATION>
175 return binEntries(AIDA::IAxis::UNDERFLOW_BIN) +
176 binEntries(AIDA::IAxis::OVERFLOW_BIN);
178 template <
class INTERFACE,
class IMPLEMENTATION>
185 template <
class INTERFACE,
class IMPLEMENTATION>
187 if (sumBinHeights() <= 0)
return 0;
189 m_rep->GetStats(stats);
190 return stats[0]*stats[0]/stats[1];
193 template <
class INTERFACE,
class IMPLEMENTATION>
195 m_rep->Scale ( scaleFactor );
199 template <
class INTERFACE,
class IMPLEMENTATION>
207 throw std::runtime_error(
"Cannot add profile histograms of different implementations.");
210 template <
class INTERFACE,
class IMPLEMENTATION>
218 template <
class INTERFACE,
class IMPLEMENTATION>
220 s <<
"\n1D Histogram Table: " <<
std::endl;
222 for(
int i = 0; i < axis().bins(); ++i )
223 s << binMean( i ) <<
", " 224 << binHeight( i ) <<
", " 231 template <
class INTERFACE,
class IMPLEMENTATION>
234 TFile *f = TFile::Open(file_name,
"RECREATE");
235 Int_t nbytes = m_rep->Write();
242 #pragma clang diagnostic pop 243 #elif defined(__GNUC__) && __GNUC__ >= 5 244 #pragma GCC diagnostic pop 247 #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.