5 #ifndef TRT_CALIBDATA__IDENTIFIEDPROFILEHISTOGRAM_H
6 #define TRT_CALIBDATA__IDENTIFIEDPROFILEHISTOGRAM_H
27 #include "CLHEP/Matrix/SymMatrix.h"
28 #include "CLHEP/Matrix/Vector.h"
29 #include <CLHEP/Matrix/Matrix.h>
33 template <
typename SomeIDTag>
39 const float& a_loweredge,
const float& a_upperedge,
40 const float& a_lowerlimit = 0.0,
const float& a_upperlimit = 0.0);
42 const float& a_loweredge,
const float& a_upperedge,
43 const std::vector<float>& a_lowerlimit,
const std::vector<float>& a_upperlimit );
49 const std::string&
title()
const;
55 const std::vector<float>&
content(
const SomeIDTag&
ident)
const;
60 const std::vector<float>
abcissa()
const;
62 const std::vector<float>
average(
const SomeIDTag&
ident)
const;
63 const std::vector<float>
rms(
const SomeIDTag&
ident)
const;
89 template <
typename SomeIDTag>
92 template <
typename SomeIDTag>
95 template <
typename SomeIDTag>
98 template <
typename SomeIDTag>
101 template <
typename SomeIDTag>
104 template <
typename SomeIDTag>
107 template <
typename SomeIDTag>
110 template <
typename SomeIDTag>
113 template <
typename SomeIDTag>
116 template <
typename SomeIDTag>
120 for (
typename ArrayStore<SomeIDTag, std::vector<int> >::map_citr itr=m_NumberOfEntries.
cbegin();itr!=m_NumberOfEntries.cend();++itr)
121 i=
std::accumulate(m_NumberOfEntries[itr->first].begin(),m_NumberOfEntries[itr->first].end(),
i);
125 template <
typename SomeIDTag>
128 return m_NumberOfEntries.existID(
ident) ?
132 template <
typename SomeIDTag>
134 const std::vector<float>
result(m_NumberOfBins, m_BinWidth/sqrt(12.0));
138 template <
typename SomeIDTag>
140 return globalNumberOfEntries(
ident)>0 ?
144 template <
typename SomeIDTag>
146 return globalNumberOfEntries(
ident)>0 ?
148 (
float)globalNumberOfEntries(
ident)-globalAverage(
ident)*globalAverage(
ident)) : 0.0;
151 template <
typename SomeIDTag>
153 return globalNumberOfEntries(
ident)>0 ?
154 globalRMS(
ident)/sqrt((
float)globalNumberOfEntries(
ident)) : 0.0;
157 #ifndef TRT_ALIGNDATA__IDENTIFIEDPROFILEHISTOGRAM_ICC
158 #define TRT_ALIGNDATA__IDENTIFIEDPROFILEHISTOGRAM_ICC
160 template <
typename SomeIDTag>
162 const unsigned int& a_numberofbins,
163 const float& a_loweredge,
const float& a_upperedge,
164 const float& a_lowerlimit,
const float& a_upperlimit) :
165 m_NumberOfBins(a_numberofbins),m_LowerEdge(a_loweredge),
166 m_BinWidth((a_upperedge-a_loweredge)/(
float)a_numberofbins),
167 m_LowerLimit(a_numberofbins,a_lowerlimit),m_UpperLimit(a_numberofbins,a_upperlimit),
168 m_NumberOfEntries(a_title) {}
170 template <
typename SomeIDTag>
172 const unsigned int& a_numberofbins,
173 const float& a_loweredge,
const float& a_upperedge,
174 const std::vector<float>& a_lowerlimit,
175 const std::vector<float>& a_upperlimit ) :
176 m_NumberOfBins(a_numberofbins),m_LowerEdge(a_loweredge),
177 m_BinWidth((a_upperedge-a_loweredge)/(
float)a_numberofbins),
178 m_LowerLimit(a_lowerlimit), m_UpperLimit(a_upperlimit),m_NumberOfEntries(a_title){
179 if (a_lowerlimit.size()!=a_upperlimit.size()&& a_lowerlimit.size()!=a_numberofbins) {
180 std::cout<<
"Inconsistent vector(s) of limits passed to IdentifiedProfileHistogram: "
181 << a_title <<
" -- limits ignored..." <<std::endl;
189 template <
typename SomeIDTag>
191 std::vector<float>
result(m_NumberOfBins, m_BinWidth);
192 result[0]=m_LowerEdge+m_BinWidth/2.0;
193 for (
int i=1;
i<m_NumberOfBins;
i++)
198 template <
typename SomeIDTag>
200 std::vector<float>
result(m_NumberOfBins, 0.0);
201 if (!m_NumberOfEntries.existID(
ident))
204 for (
int i=0;
i<m_NumberOfBins;
i++)
209 template <
typename SomeIDTag>
211 std::vector<float>
result(m_NumberOfBins, 0.0);
212 if (!m_NumberOfEntries.existID(
ident))
215 for (
int i=0;
i<m_NumberOfBins;
i++)
220 template <
typename SomeIDTag>
222 std::vector<float>
result(m_NumberOfBins, 0.0);
223 if (!m_NumberOfEntries.existID(
ident))
226 for (
int i=0;
i<m_NumberOfBins;
i++)
231 template <
typename SomeIDTag>
233 if (abcissa<m_LowerEdge||abcissa>m_LowerEdge+m_BinWidth*(
float)m_NumberOfBins||m_NumberOfBins==0)
235 int bin=
int((abcissa-m_LowerEdge)/m_BinWidth);
236 if (m_LowerLimit[
bin]<m_UpperLimit[
bin]&&(ordinate<m_LowerLimit[
bin]||ordinate>m_UpperLimit[
bin]))
238 if (!m_NumberOfEntries.existID(
ident)){
239 m_NumberOfEntries.push_back(
ident,std::vector<int>(m_NumberOfBins,0));
240 m_Content.push_back(
ident, std::vector<float>(m_NumberOfBins, 0.0));
241 m_ContentSquared.push_back(
ident, std::vector<float>(m_NumberOfBins, 0.0));
249 #endif // TRT_CALIBDATA__IDENTIFIEDPROFILEHISTOGRAM_ICC
251 #endif // TRT_CALIBDATA__IDENTIFIEDPROFILEHISTOGRAM_H