ATLAS Offline Software
SCT_CondParameterData.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <cmath>
8 #include <limits>
9 
10 // constructor
12  clear();
13 }
14 
15 // Get the indicated value for a module identifier hash
17  return m_values[idHash][iparam];
18 }
19 
20 // Fill a user-provided vector with the values
21 void SCT_CondParameterData::getValues(std::vector<float>& userVector, const SCT_CondParameterData::ParameterIndex iparam) const {
22  for (unsigned int i{0}; i!=m_values.size(); ++i) {
23  userVector.push_back(m_values[i][iparam]);
24  }
25 }
26 
29  if (insert(idHash, iparam, value)) {
30  m_n[iparam]++;
31  m_sum[iparam] += value;
32  m_sumsq[iparam] += value*value;
33  m_min[iparam] = std::min(m_min[iparam], value);
34  m_max[iparam] = std::max(m_max[iparam], value);
35  }
36 }
37 
38 // Extended methods for data structure insertion
39 bool SCT_CondParameterData::insert(const IdentifierHash& idHash, const SCT_CondParameterData::ParameterIndex iparam, const float theValue) {
40  // theValue must be valid
41  if (not isValid(theValue, iparam)) return false;
42  std::array<float,N_PARAMETERS>& paramArray = m_values[idHash];
43  // initial value should be invalid, only insert if this is the case
44  if (not isValid(paramArray[iparam], iparam)) {
45  paramArray[iparam] = theValue;
46  return true;
47  } else {
48  return false;
49  }
50 }
51 
52 // Is a given value within acceptable limits?
53 bool SCT_CondParameterData::isValid(const float parameterValue, const SCT_CondParameterData::ParameterIndex iparam) {
54  // Second condition is to check if it is nan.
55  return !(iparam==AVG_THRESHOLD and (parameterValue!=parameterValue));
56 }
57 
58 // What is the default error value for this parameter?
59 float SCT_CondParameterData::invalid(const unsigned int iparam) {
60  float result{0.0};
61  if (iparam==AVG_THRESHOLD) {
62  result=std::numeric_limits<float>::quiet_NaN();
63  }
64  return result;
65 }
66 
67 // Get maximum value
69  return m_max[iparam];
70 }
71 
72 // Get minimum value
74  return m_min[iparam];
75 }
76 
77 // Get average value
79  return (m_n[iparam]!=0)?(m_sum[iparam]/m_n[iparam]):(std::numeric_limits<float>::quiet_NaN());
80 }
81 
82 // Get standard deviation
84  float mu{m_sum[iparam]/m_n[iparam]};
85  return std::sqrt((m_sumsq[iparam]/m_n[iparam]) - mu*mu);
86 }
87 
88 // Get the number of values
90  return m_n[iparam];
91 }
92 
93 // Clear all data members
95  std::array<float, N_PARAMETERS> init{};
96  for (unsigned int i{0}; i!=N_PARAMETERS; ++i) {
99  m_n[i] = 0;
100  m_sum[i] = 0.0;
101  m_sumsq[i] = 0.0;
102  init[i] = invalid(i);
103  }
104 
105  //initialize array
106  m_values.fill(init);
107 }
SCT_CondParameterData::m_sum
float m_sum[N_PARAMETERS]
Definition: SCT_CondParameterData.h:76
SCT_CondParameterData::m_max
float m_max[N_PARAMETERS]
Definition: SCT_CondParameterData.h:74
get_generator_info.result
result
Definition: get_generator_info.py:21
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
SCT_CondParameterData::ParameterIndex
ParameterIndex
Parameters.
Definition: SCT_CondParameterData.h:35
athena.value
value
Definition: athena.py:124
SCT_CondParameterData::m_sumsq
float m_sumsq[N_PARAMETERS]
Definition: SCT_CondParameterData.h:77
SCT_CondParameterData::clear
void clear()
Clear all data members.
Definition: SCT_CondParameterData.cxx:94
SCT_CondParameterData.h
header file for data object for SCT_ConditionsParameterTool and SCT_ConditionsParameterCondAlg.
SCT_CondParameterData::invalid
static float invalid(const unsigned int iparam)
What is the default error value for this parameter?
Definition: SCT_CondParameterData.cxx:59
SCT_CondParameterData::getValue
float getValue(const IdentifierHash &idHash, const SCT_CondParameterData::ParameterIndex iparam) const
Get the indicated value for a module identifier hash.
Definition: SCT_CondParameterData.cxx:16
lumiFormat.i
int i
Definition: lumiFormat.py:85
SCT_CondParameterData::getValues
void getValues(std::vector< float > &userVector, const SCT_CondParameterData::ParameterIndex iparam) const
Fill a user-provided vector with the values.
Definition: SCT_CondParameterData.cxx:21
SCT_CondParameterData::m_n
unsigned int m_n[N_PARAMETERS]
Definition: SCT_CondParameterData.h:75
SCT_CondParameterData::max
float max(const SCT_CondParameterData::ParameterIndex iparam) const
Get maximum value.
Definition: SCT_CondParameterData.cxx:68
SCT_CondParameterData::N_PARAMETERS
@ N_PARAMETERS
Definition: SCT_CondParameterData.h:35
SCT_CondParameterData::n
unsigned int n(const SCT_CondParameterData::ParameterIndex iparam) const
Get the number of values.
Definition: SCT_CondParameterData.cxx:89
python.PyKernel.init
def init(v_theApp, v_rootStream=None)
Definition: PyKernel.py:45
SCT_CondParameterData::avg
float avg(const SCT_CondParameterData::ParameterIndex iparam) const
Get average value.
Definition: SCT_CondParameterData.cxx:78
SCT_CondParameterData::m_values
std::array< std::array< float, N_PARAMETERS >, SCT_ConditionsData::NUMBER_OF_WAFERS > m_values
Definition: SCT_CondParameterData.h:71
SCT_CondParameterData::insert
bool insert(const IdentifierHash &idHash, const SCT_CondParameterData::ParameterIndex iparam, const float value)
Extended methods for data structure insertion.
Definition: SCT_CondParameterData.cxx:39
SCT_CondParameterData::AVG_THRESHOLD
@ AVG_THRESHOLD
Definition: SCT_CondParameterData.h:35
SCT_CondParameterData::SCT_CondParameterData
SCT_CondParameterData()
Constructor.
Definition: SCT_CondParameterData.cxx:11
SCT_CondParameterData::m_min
float m_min[N_PARAMETERS]
Definition: SCT_CondParameterData.h:73
SCT_CondParameterData::sd
float sd(const SCT_CondParameterData::ParameterIndex iparam) const
Get standard deviation.
Definition: SCT_CondParameterData.cxx:83
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
SCT_CondParameterData::isValid
static bool isValid(const float parameterValue, const SCT_CondParameterData::ParameterIndex iparam)
Is a given value within acceptable limits?
Definition: SCT_CondParameterData.cxx:53
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
SCT_CondParameterData::setValue
void setValue(const IdentifierHash &idHash, const SCT_CondParameterData::ParameterIndex iparam, const float value)
Get the indicated value for a module identifier hash.
Definition: SCT_CondParameterData.cxx:28
SCT_CondParameterData::min
float min(const SCT_CondParameterData::ParameterIndex iparam) const
Get minimum value.
Definition: SCT_CondParameterData.cxx:73