1 #ifndef GAUDISVC_GENERIC1D_H
2 #define GAUDISVC_GENERIC1D_H 1
10 #include "AIDA/IProfile1D.h"
28 template <
class INTERFACE,
class IMPLEMENTATION>
39 virtual void* cast(
const std::string& cl)
const;
43 virtual void adoptRepresentation(TObject*rep);
45 virtual std::string
title()
const {
return m_annotation.value(
"Title"); }
47 virtual bool setTitle(
const std::string & title);
49 std::string
name()
const {
return m_annotation.value(
"Name"); }
51 bool setName(
const std::string& newName );
53 virtual AIDA::IAnnotation &
annotation() {
return m_annotation; }
55 virtual const AIDA::IAnnotation &
annotation()
const {
return m_annotation; }
62 virtual int entries()
const {
return (
int)m_rep->GetEntries(); }
64 virtual int allEntries()
const {
return int(m_rep->GetEntries()); }
66 virtual int extraEntries()
const;
68 virtual int binEntries (
int index )
const;
70 virtual double binRms(
int index)
const;
72 virtual double sumBinHeights()
const {
return m_rep->GetSumOfWeights(); }
78 virtual double minBinHeight()
const {
return m_rep->GetMinimum(); }
80 virtual double maxBinHeight()
const {
return m_rep->GetMaximum(); }
83 virtual double equivalentBinEntries ( )
const;
85 virtual bool scale(
double scaleFactor );
89 virtual bool add(
const INTERFACE & profile);
91 virtual int rIndex(
int index)
const {
return m_axis.rIndex(index);}
93 virtual double binMean(
int index)
const;
95 virtual double binHeight(
int index)
const;
97 virtual double binError(
int index)
const;
99 virtual double mean()
const {
return m_rep->GetMean(); }
101 virtual double rms ()
const {
return m_rep->GetRMS(); }
103 virtual int coordToIndex (
double coord )
const {
return axis().coordToIndex(coord);}
107 virtual std::ostream& print( std::ostream&
s )
const;
109 virtual std::ostream& write( std::ostream&
s )
const;
111 virtual int write(
const char* file_name )
const;
126 template <
class INTERFACE,
class IMPLEMENTATION>
128 m_rep->SetTitle(title.c_str());
129 if ( !annotation().addItem(
"Title", title ) )
130 m_annotation.setValue(
"Title" , title );
131 if ( !annotation().addItem(
"title", title ) )
132 annotation().setValue(
"title", title );
136 template <
class INTERFACE,
class IMPLEMENTATION>
138 m_rep->SetName(newName.c_str());
139 m_annotation.setValue(
"Name", newName );
143 template <
class INTERFACE,
class IMPLEMENTATION>
145 return m_rep->GetBinError ( rIndex(index) );
148 template <
class INTERFACE,
class IMPLEMENTATION>
150 return m_rep->GetBinCenter ( rIndex(index) );
153 template <
class INTERFACE,
class IMPLEMENTATION>
155 return m_rep->GetBinContent ( rIndex(index) );
158 template <
class INTERFACE,
class IMPLEMENTATION>
160 return m_rep->GetBinError ( rIndex(index) );
163 template <
class INTERFACE,
class IMPLEMENTATION>
165 return binEntries(AIDA::IAxis::UNDERFLOW_BIN) +
166 binEntries(AIDA::IAxis::OVERFLOW_BIN);
168 template <
class INTERFACE,
class IMPLEMENTATION>
175 template <
class INTERFACE,
class IMPLEMENTATION>
177 if (sumBinHeights() <= 0)
return 0;
179 m_rep->GetStats(stats);
180 return stats[0]*stats[0]/stats[1];
183 template <
class INTERFACE,
class IMPLEMENTATION>
185 m_rep->Scale ( scaleFactor );
189 template <
class INTERFACE,
class IMPLEMENTATION>
194 m_rep->Add(p->
m_rep);
197 throw std::runtime_error(
"Cannot add profile histograms of different implementations.");
200 template <
class INTERFACE,
class IMPLEMENTATION>
208 template <
class INTERFACE,
class IMPLEMENTATION>
210 s <<
"\n1D Histogram Table: " << std::endl;
211 s <<
"Bin, Height, Error " << std::endl;
212 for(
int i = 0;
i < axis().bins(); ++
i )
213 s << binMean(
i ) <<
", "
214 << binHeight(
i ) <<
", "
215 << binError (
i ) << std::endl;
221 template <
class INTERFACE,
class IMPLEMENTATION>
224 TFile *f = TFile::Open(file_name,
"RECREATE");
225 Int_t nbytes = m_rep->Write();
231 #endif // AIDAROOT_GENERIC1D_H
virtual bool add(const INTERFACE &profile)
Modifies this IProfile1D by adding the contents of profile to it.
virtual std::string title() const
Get the title of the object.
virtual std::ostream & write(std::ostream &s) const
Write (ASCII) the histogram table into the output stream.
virtual int entries() const
Get the number or all the entries.
virtual double maxBinHeight() const
Get the maximum height of the in-range bins.
Generic1D()
Default constructor.
virtual double binError(int index) const
The error of a given bin.
virtual double binRms(int index) const
Axis & axis()
Access to axis object.
virtual std::ostream & print(std::ostream &s) const
Print (ASCII) the histogram into the output stream.
AIDA::Annotation m_annotation
Object annotations.
virtual ~Generic1D()
Default destructor.
virtual double sumExtraBinHeights() const
Get the sum of the underflow and overflow bin height.
virtual int coordToIndex(double coord) const
Get the bin number corresponding to a given coordinate along the x axis.
Implementation of the AIDA IAnnotation interface class.
IMPLEMENTATION * m_rep
Reference to underlying implementation.
Generic1D< INTERFACE, IMPLEMENTATION > Base
virtual int dimension() const
Get the Histogram's dimension.
TObject * representation() const
ROOT object implementation.
virtual const std::string & userLevelClassType() const
The AIDA user-level unterface leaf class type.
Common base class for all histograms Use is solely functional to minimize dynamic_casts inside Histog...
virtual double minBinHeight() const
Get the minimum height of the in-range bins.
virtual bool setTitle(const std::string &title)
Set the title of the object.
virtual int allEntries() const
Get the number or all the entries, both in range and underflow/overflow bins of the IProfile...
virtual double binMean(int index) const
The weighted mean of a bin.
virtual double equivalentBinEntries() const
Number of equivalent entries, i.e. SUM[ weight ] ^ 2 / SUM[ weight^2 ]
virtual int rIndex(int index) const
operator methods
virtual double binHeight(int index) const
Total height of the corresponding bin (ie the sum of the weights in this bin).
virtual int extraEntries() const
Get the number of entries in the underflow and overflow bins.
This is a number of static methods for bootstrapping the Gaudi framework.
virtual double sumAllBinHeights() const
Get the sum of all the bins heights (including underflow and overflow bin).
virtual double sumBinHeights() const
Get the sum of in range bin heights in the IProfile.
const Axis & axis() const
Get the x axis of the IHistogram1D.
An IAxis represents a binned histogram axis.
virtual bool reset()
Reset the Histogram; as if just created.
virtual AIDA::IAnnotation & annotation()
Access annotation object.
bool setName(const std::string &newName)
Set the name of the object.
virtual const AIDA::IAnnotation & annotation() const
Access annotation object (cons)
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...
virtual double rms() const
The RMS of the whole IHistogram1D.
std::string name() const
object name
Common AIDA implementation stuff for histograms and profiles using ROOT implementations.
virtual double mean() const
The mean of the whole IHistogram1D.