ATLAS Offline Software
Loading...
Searching...
No Matches
TB2DProfiler.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6template<typename T>
7TB2DProfiler<T>::TB2DProfiler()
8 : m_skipFlag(true)
9{ }
10
11template<typename T>
12TB2DProfiler<T>::TB2DProfiler(size_t xBins, const T& xLow, const T& xHigh,
13 size_t yBins, const T& yLow, const T& yHigh)
14 : m_skipFlag(false)
15{
16 // prepare internal stores
17 m_xBinning = new TBProfiler<T>(xBins,xLow,xHigh);
18 m_yBinning = new TBProfiler<T>(yBins,yLow,yHigh);
19
20 // common store
21 m_store = new TBProfiler<T>(xBins*yBins);
22}
23
24template<typename T>
25TB2DProfiler<T>::~TB2DProfiler()
26{
27 delete m_xBinning;
28 delete m_yBinning;
29 delete m_store;
30}
31
32template<typename T>
33void TB2DProfiler<T>::addData(const T& xPos, const T& yPos, const T& theData )
34{
35 // get the combined index
36 size_t theIndex = this->getIndex(xPos,yPos);
37 if ( theIndex == size_t(-1) ) return;
38
39 // store
40 m_store->addData(theIndex,theData);
41}
42
43template<typename T>
44bool TB2DProfiler<T>::getAverages(size_t i, size_t j, T& theData) const
45{
46 size_t theIndex = this->getIndex(i,j);
47 return theIndex != size_t(-1)
48 ? m_store->getAverages(theIndex,theData)
49 : false;
50}
51
52template<typename T>
53bool TB2DProfiler<T>::getStandardDevs(size_t i, size_t j, T& theData) const
54{
55 size_t theIndex = this->getIndex(i,j);
56 return theIndex != size_t(-1)
57 ? m_store->getStandardDevs(theIndex,theData)
58 : false;
59}
60
61template<typename T>
62bool TB2DProfiler<T>::getErrors(size_t i, size_t j, T& theData) const
63{
64 size_t theIndex = this->getIndex(i,j);
65 return theIndex != size_t(-1)
66 ? m_store->getErrors(theIndex,theData)
67 : false;
68}
69
70template<typename T>
71bool TB2DProfiler<T>::getBinEntries(size_t i, size_t j,
72 size_t& theEntries ) const
73{
74 size_t theIndex = this->getIndex(i,j);
75 return ( theIndex != size_t(-1) )
76 ? m_store->getBinEntries(theIndex,theEntries)
77 : false;
78}
79
80template<typename T>
81bool TB2DProfiler<T>::getBinEntries(const T& x, const T& y,
82 size_t& theEntries) const
83{
84 size_t theIndex = this->getIndex(x,y);
85 return ( theIndex != size_t(-1) )
86 ? m_store->getBinEntries(theIndex,theEntries)
87 : false;
88}
89
90template<typename T>
91const TBProfiler<T>& TB2DProfiler<T>::getXBinning() const
92{
93 return *m_xBinning;
94}
95
96template<typename T>
97const TBProfiler<T>& TB2DProfiler<T>::getYBinning() const
98{
99 return *m_yBinning;
100}
101
102template<typename T>
103size_t TB2DProfiler<T>::getXIndex(const T& x) const
104{
105 return m_xBinning->getIndex(x);
106}
107
108template<typename T>
109size_t TB2DProfiler<T>::getYIndex(const T& y) const
110{
111 return m_yBinning->getIndex(y);
112}
113
114template<typename T>
115size_t TB2DProfiler<T>::getIndex(const T& xPos, const T& yPos) const
116{
117 return this->getIndex(m_xBinning->getIndex(xPos),m_yBinning->getIndex(yPos));
118}
119
120template<typename T>
121size_t TB2DProfiler<T>::getIndex(size_t i,size_t j) const
122{
123 return ( i < m_xBinning->getNumberOfChannels() &&
124 j < m_yBinning->getNumberOfChannels() )
125 ? i + j * m_xBinning->getNumberOfChannels()
126 : size_t(-1);
127}
128
129template<typename T>
130size_t TB2DProfiler<T>::getNumberOfChannels() const
131{
132 return
133 m_xBinning->getNumberOfChannels() *
134 m_yBinning->getNumberOfChannels();
135}