1 #ifndef GAUDISVC_GENERIC2D_H
2 #define GAUDISVC_GENERIC2D_H 1
7 #include "AIDA/IProfile2D.h"
29 template <
class INTERFACE,
class IMPLEMENTATION>
42 virtual void adoptRepresentation(TObject* rep);
52 virtual AIDA::IAnnotation &
annotation() {
return m_annotation; }
54 virtual const AIDA::IAnnotation &
annotation()
const {
return m_annotation; }
57 virtual const AIDA::IAxis &
xAxis()
const {
return m_xAxis; }
59 virtual const AIDA::IAxis &
yAxis()
const {
return m_yAxis; }
61 virtual int rIndexX(
int index)
const {
return m_xAxis.rIndex(index); }
63 virtual int rIndexY(
int index)
const {
return m_yAxis.rIndex(index); }
66 virtual int entries()
const;
68 virtual int allEntries()
const;
70 virtual int extraEntries()
const;
72 virtual double sumBinHeights()
const;
74 virtual double sumAllBinHeights()
const;
78 virtual double minBinHeight()
const;
80 virtual double maxBinHeight()
const;
83 virtual double binMeanX(
int indexX,
int indexY)
const;
85 virtual double binMeanY(
int indexX,
int indexY)
const;
87 virtual int binEntries (
int indexX,
int indexY )
const;
89 virtual int binEntriesX(
int indexX)
const;
91 virtual int binEntriesY(
int indexY)
const;
93 virtual double binHeight(
int indexX,
int indexY)
const;
95 virtual double binHeightX(
int indexX)
const;
97 virtual double binHeightY(
int indexY)
const;
99 virtual double binError(
int indexX,
int indexY)
const;
101 virtual double binRms(
int indexX,
int indexY)
const;
103 virtual double meanX()
const;
105 virtual double meanY()
const;
107 virtual double rmsX()
const;
109 virtual double rmsY()
const;
111 virtual int coordToIndexX(
double coordX)
const;
113 virtual int coordToIndexY(
double coordY)
const;
115 virtual double equivalentBinEntries ( )
const;
117 virtual bool scale(
double scaleFactor );
119 virtual bool add(
const INTERFACE & h);
133 virtual int write(
const char* file_name )
const;
150 template <
class INTERFACE,
class IMPLEMENTATION>
152 m_rep->SetTitle(title.c_str());
153 if ( !annotation().addItem(
"Title", title ) )
154 m_annotation.setValue(
"Title" , title );
155 if ( !annotation().addItem(
"title", title ) )
156 annotation().setValue(
"title", title );
160 template <
class INTERFACE,
class IMPLEMENTATION>
162 m_rep->SetName(newName.c_str());
163 m_annotation.setValue(
"Name", newName );
167 template <
class INTERFACE,
class IMPLEMENTATION>
169 return (
int)m_rep->GetEntries();
172 template <
class INTERFACE,
class IMPLEMENTATION>
174 return int(m_rep->GetEntries());
177 template <
class INTERFACE,
class IMPLEMENTATION>
179 return m_rep->GetMinimum();
182 template <
class INTERFACE,
class IMPLEMENTATION>
184 return m_rep->GetMaximum();
187 template <
class INTERFACE,
class IMPLEMENTATION>
189 return m_rep->GetSumOfWeights();
192 template <
class INTERFACE,
class IMPLEMENTATION>
194 return m_rep->GetSum();
197 template <
class INTERFACE,
class IMPLEMENTATION>
199 return m_rep->GetBinError ( rIndexX(indexX), rIndexY(indexY) );
202 template <
class INTERFACE,
class IMPLEMENTATION>
204 return (m_rep->GetXaxis())->GetBinCenter( rIndexX(indexX) );
207 template <
class INTERFACE,
class IMPLEMENTATION>
209 return (m_rep->GetYaxis())->GetBinCenter( rIndexY(indexY) );
212 template <
class INTERFACE,
class IMPLEMENTATION>
215 for (
int iY = -2; iY < yAxis().bins(); ++iY)
216 n += binEntries(index,iY);
220 template <
class INTERFACE,
class IMPLEMENTATION>
223 for (
int iX = -2; iX < xAxis().bins(); ++iX)
224 n += binEntries(iX,index);
228 template <
class INTERFACE,
class IMPLEMENTATION>
230 return m_rep->GetBinContent ( rIndexX(indexX), rIndexY(indexY) );
233 template <
class INTERFACE,
class IMPLEMENTATION>
236 for (
int iY = -2; iY < yAxis().bins(); ++iY) {
237 s += binHeight(index,iY);
242 template <
class INTERFACE,
class IMPLEMENTATION>
245 for (
int iX = -2; iX < xAxis().bins(); ++iX)
246 s += binHeight(iX,index);
250 template <
class INTERFACE,
class IMPLEMENTATION>
252 return m_rep->GetBinError ( rIndexX(indexX), rIndexY(indexY ) );
255 template <
class INTERFACE,
class IMPLEMENTATION>
257 return m_rep->GetMean(1);
260 template <
class INTERFACE,
class IMPLEMENTATION>
262 return m_rep->GetMean(2);
265 template <
class INTERFACE,
class IMPLEMENTATION>
267 return m_rep->GetRMS(1);
270 template <
class INTERFACE,
class IMPLEMENTATION>
272 return m_rep->GetRMS(2);
275 template <
class INTERFACE,
class IMPLEMENTATION>
277 return xAxis().coordToIndex(coord);
280 template <
class INTERFACE,
class IMPLEMENTATION>
282 return yAxis().coordToIndex(coord);
285 template <
class INTERFACE,
class IMPLEMENTATION>
287 const Base* p =
dynamic_cast<const Base*
>(&hist);
289 m_rep->Add(p->
m_rep);
292 throw std::runtime_error(
"Cannot add profile histograms of different implementations.");
295 template <
class INTERFACE,
class IMPLEMENTATION>
298 binEntries(AIDA::IAxis::UNDERFLOW_BIN,AIDA::IAxis::UNDERFLOW_BIN) +
299 binEntries(AIDA::IAxis::UNDERFLOW_BIN,AIDA::IAxis::OVERFLOW_BIN) +
300 binEntries(AIDA::IAxis::OVERFLOW_BIN,AIDA::IAxis::UNDERFLOW_BIN) +
301 binEntries(AIDA::IAxis::OVERFLOW_BIN,AIDA::IAxis::OVERFLOW_BIN);
304 template <
class INTERFACE,
class IMPLEMENTATION>
306 if (sumBinHeights() <= 0)
return 0;
308 m_rep->GetStats(stats);
309 return stats[0]*stats[0]/stats[1];
312 template <
class INTERFACE,
class IMPLEMENTATION>
314 m_rep->Scale ( scaleFactor );
318 template <
class INTERFACE,
class IMPLEMENTATION>
325 template <
class INTERFACE,
class IMPLEMENTATION>
334 template <
class INTERFACE,
class IMPLEMENTATION>
338 s <<
"BinX, BinY, Height, Error " <<
std::endl;
339 for (
int i = 0;
i < xAxis().bins(); ++
i ) {
340 for (
int j = 0; j < yAxis().bins(); ++j ) {
341 s << binMeanX(
i, j ) <<
", "
342 << binMeanY(
i, j ) <<
", "
343 << binHeight(
i, j ) <<
", "
352 template <
class INTERFACE,
class IMPLEMENTATION>
355 TFile *f = TFile::Open(file_name,
"RECREATE");
356 Int_t nbytes = m_rep->Write();
361 #endif // GAUDIPI_GENERIC2D_H