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>
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;
98 virtual bool scale(
double scaleFactor );
100 bool reset()
override;
102 bool add(
const INTERFACE& profile )
override;
104 virtual int rIndex(
int index )
const {
return m_axis.rIndex( index ); }
106 double binMean(
int index )
const override;
108 double binHeight(
int index )
const override;
110 double binError(
int index )
const override;
112 double mean()
const override {
return m_rep->GetMean(); }
114 double rms()
const override {
return m_rep->GetRMS(); }
116 int coordToIndex(
double coord )
const override {
return axis().coordToIndex( coord ); }
124 int write(
const char* file_name )
const override;
139 template <
class INTERFACE,
class IMPLEMENTATION>
142 m_rep->SetTitle( title.
c_str() );
143 if ( !annotation().addItem(
"Title", title ) ) m_annotation.setValue(
"Title", title );
144 if ( !annotation().addItem(
"title", title ) ) annotation().setValue(
"title", title );
148 template <
class INTERFACE,
class IMPLEMENTATION>
151 m_rep->SetName( newName.
c_str() );
152 m_annotation.setValue(
"Name", newName );
156 template <
class INTERFACE,
class IMPLEMENTATION>
159 return m_rep->GetBinError( rIndex( index ) );
162 template <
class INTERFACE,
class IMPLEMENTATION>
165 return m_rep->GetBinCenter( rIndex( index ) );
168 template <
class INTERFACE,
class IMPLEMENTATION>
171 return m_rep->GetBinContent( rIndex( index ) );
174 template <
class INTERFACE,
class IMPLEMENTATION>
177 return m_rep->GetBinError( rIndex( index ) );
180 template <
class INTERFACE,
class IMPLEMENTATION>
183 return binEntries( AIDA::IAxis::UNDERFLOW_BIN ) + binEntries( AIDA::IAxis::OVERFLOW_BIN );
185 template <
class INTERFACE,
class IMPLEMENTATION>
193 template <
class INTERFACE,
class IMPLEMENTATION>
196 if ( sumBinHeights() <= 0 )
return 0;
198 m_rep->GetStats( stats );
199 return stats[0] * stats[0] / stats[1];
202 template <
class INTERFACE,
class IMPLEMENTATION>
205 m_rep->Scale( scaleFactor );
209 template <
class INTERFACE,
class IMPLEMENTATION>
217 throw std::runtime_error(
"Cannot add profile histograms of different implementations." );
220 template <
class INTERFACE,
class IMPLEMENTATION>
224 m_rep->Print(
"all" );
229 template <
class INTERFACE,
class IMPLEMENTATION>
232 s <<
"\n1D Histogram Table: " <<
std::endl;
234 for (
int i = 0; i < axis().bins(); ++i )
235 s << binMean( i ) <<
", " << binHeight( i ) <<
", " << binError( i ) <<
std::endl;
241 template <
class INTERFACE,
class IMPLEMENTATION>
244 TFile* f = TFile::Open( file_name,
"RECREATE" );
245 Int_t nbytes = m_rep->Write();
252 #pragma clang diagnostic pop 253 #elif defined( __GNUC__ ) && __GNUC__ >= 5 254 #pragma GCC diagnostic pop 257 #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.