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" 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;
96 virtual bool scale(
double scaleFactor );
98 bool reset()
override;
100 bool add(
const INTERFACE& profile )
override;
102 virtual int rIndex(
int index )
const {
return m_axis.rIndex( index ); }
104 double binMean(
int index )
const override;
106 double binHeight(
int index )
const override;
108 double binError(
int index )
const override;
110 double mean()
const override {
return m_rep->GetMean(); }
112 double rms()
const override {
return m_rep->GetRMS(); }
114 int coordToIndex(
double coord )
const override {
return axis().coordToIndex( coord ); }
122 int write(
const char* file_name )
const override;
137 template <
class INTERFACE,
class IMPLEMENTATION>
139 m_rep->SetTitle( title.
c_str() );
140 if ( !annotation().addItem(
"Title", title ) ) m_annotation.setValue(
"Title", title );
141 if ( !annotation().addItem(
"title", title ) ) annotation().setValue(
"title", title );
145 template <
class INTERFACE,
class IMPLEMENTATION>
147 m_rep->SetName( newName.
c_str() );
148 m_annotation.setValue(
"Name", newName );
152 template <
class INTERFACE,
class IMPLEMENTATION>
154 return m_rep->GetBinError( rIndex( index ) );
157 template <
class INTERFACE,
class IMPLEMENTATION>
159 return m_rep->GetBinCenter( rIndex( index ) );
162 template <
class INTERFACE,
class IMPLEMENTATION>
164 return m_rep->GetBinContent( rIndex( index ) );
167 template <
class INTERFACE,
class IMPLEMENTATION>
169 return m_rep->GetBinError( rIndex( index ) );
172 template <
class INTERFACE,
class IMPLEMENTATION>
174 return binEntries( AIDA::IAxis::UNDERFLOW_BIN ) + binEntries( AIDA::IAxis::OVERFLOW_BIN );
176 template <
class INTERFACE,
class IMPLEMENTATION>
183 template <
class INTERFACE,
class IMPLEMENTATION>
185 if ( sumBinHeights() <= 0 )
return 0;
187 m_rep->GetStats( stats );
188 return stats[0] * stats[0] / stats[1];
191 template <
class INTERFACE,
class IMPLEMENTATION>
193 m_rep->Scale( scaleFactor );
197 template <
class INTERFACE,
class IMPLEMENTATION>
204 throw std::runtime_error(
"Cannot add profile histograms of different implementations." );
207 template <
class INTERFACE,
class IMPLEMENTATION>
210 m_rep->Print(
"all" );
215 template <
class INTERFACE,
class IMPLEMENTATION>
217 s <<
"\n1D Histogram Table: " <<
std::endl;
219 for (
int i = 0; i < axis().bins(); ++i )
220 s << binMean( i ) <<
", " << binHeight( i ) <<
", " << binError( i ) <<
std::endl;
226 template <
class INTERFACE,
class IMPLEMENTATION>
228 TFile* f = TFile::Open( file_name,
"RECREATE" );
229 Int_t nbytes = m_rep->Write();
236 # pragma clang diagnostic pop 237 #elif defined( __GNUC__ ) && __GNUC__ >= 5 238 # pragma GCC diagnostic pop 241 #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.