ATLAS Offline Software
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 
6 template<typename T>
7 TB2DProfiler<T>::TB2DProfiler()
8  : m_skipFlag(true)
9 { }
10 
11 template<typename T>
12 TB2DProfiler<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 
24 template<typename T>
25 TB2DProfiler<T>::~TB2DProfiler()
26 {
27  delete m_xBinning;
28  delete m_yBinning;
29  delete m_store;
30 }
31 
32 template<typename T>
33 void 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 
43 template<typename T>
44 bool 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 
52 template<typename T>
53 bool 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 
61 template<typename T>
62 bool 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 
70 template<typename T>
71 bool 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 
80 template<typename T>
81 bool 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 
90 template<typename T>
91 const TBProfiler<T>& TB2DProfiler<T>::getXBinning() const
92 {
93  return *m_xBinning;
94 }
95 
96 template<typename T>
97 const TBProfiler<T>& TB2DProfiler<T>::getYBinning() const
98 {
99  return *m_yBinning;
100 }
101 
102 template<typename T>
103 size_t TB2DProfiler<T>::getXIndex(const T& x) const
104 {
105  return m_xBinning->getIndex(x);
106 }
107 
108 template<typename T>
109 size_t TB2DProfiler<T>::getYIndex(const T& y) const
110 {
111  return m_yBinning->getIndex(y);
112 }
113 
114 template<typename T>
115 size_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 
120 template<typename T>
121 size_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 
129 template<typename T>
130 size_t TB2DProfiler<T>::getNumberOfChannels() const
131 {
132  return
133  m_xBinning->getNumberOfChannels() *
134  m_yBinning->getNumberOfChannels();
135 }