1 #ifndef GAUDISVC_GENERIC1D_H
2 #define GAUDISVC_GENERIC1D_H 1
10 #include "AIDA/IProfile1D.h"
28 template <
class INTERFACE,
class IMPLEMENTATION>
43 virtual void adoptRepresentation(TObject*rep);
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(); }
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);}
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;
212 for(
int i = 0;
i < axis().bins(); ++
i )
213 s << binMean(
i ) <<
", "
214 << binHeight(
i ) <<
", "
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