ATLAS Offline Software
CaloSamplingData.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 
8 #include <iterator>
9 #include <algorithm>
10 
16  : m_varTypePattern(0)
17 {
18  this->setupStores();
19 }
20 
21 CaloSamplingData::CaloSamplingData(unsigned int varTypePattern)
22  : m_varTypePattern(CaloVariableType::setConstMarker(varTypePattern))
23 {
24  this->setupStores();
25 }
26 
28 
29 
30 = default;
31 
33  : m_dataStore (pData->m_dataStore),
34  m_varTypePattern (pData->m_varTypePattern)
35 {
36 }
37 
39 {
40  if (this != &other) {
41  m_dataStore = other.m_dataStore;
42  m_varTypePattern = other.m_varTypePattern;
43  }
44  return *this;
45 }
46 
48 = default;
49 
50 
52 {
53  m_dataStore.swap (other.m_dataStore);
54  std::swap (m_varTypePattern, other.m_varTypePattern);
55 }
56 
57 
68 bool
70  vector_type& theData) const
71 {
72  variable_store_type::const_iterator beg =
73  m_dataStore.begin() + index (theVariable, 0);
74  theData.assign (beg, beg + fastNsamp());
75  return !theData.empty();
76 }
77 
95  const vector_type& theData)
96 {
97  return storeData (theVariable, theData.begin(), theData.end());
98 }
99 
110  sampling_key_type theSampling,
111  value_type theData)
112 {
113  bool testWrite = this->checkBitPattern(theVariable);
114  if ( testWrite )
115  {
116  m_dataStore[index(theVariable,theSampling)] = theData;
117  }
118  return testWrite;
119 }
120 
130 size_t
132 {
133  variable_store_type::const_iterator beg =
134  m_dataStore.begin() + index (theVariable, 0);
135  return size_t(std::count_if(beg, beg + fastNsamp(),
136  IsValidData()));
137 }
138 
139 bool
141 {
142  //size_t samplingSize(this->getNumberOfSamplings());
143  size_t variableSize(this->getNumberOfVariableTypes());
144  // preset store with default values (empty variable lists)
145  m_dataStore.resize(index(variableSize, 0));
146  return !m_dataStore.empty();
147 }
148 
149 bool
151 {
152  unsigned int extractBit = this->getBitPattern(theVariable);
153  m_varTypePattern = m_varTypePattern & ~extractBit ;
154  return ( m_varTypePattern & extractBit ) == 0;
155 }
156 
157 bool
159 {
160  bool testConst = this->testConstPattern();
162  if ( testConst )
164  return true;
165 }
166 
167 bool
169 {
170  if ( this->testConstPattern() ) return this->testBitPattern(theVariable);
171  m_varTypePattern = m_varTypePattern | this->getBitPattern(theVariable);
172  return true;
173 }
CaloSamplingData::swap
void swap(CaloSamplingData &other)
Definition: CaloSamplingData.cxx:51
CaloVariableType::VariableType
VariableType
Definition: CaloVariableType.h:15
CaloSamplingData::retrieveData
value_type retrieveData(variable_key_type theVariable, sampling_key_type theSampling) const
Retrieve const reference to individual variable.
Definition: CaloSamplingData.h:225
CaloSamplingData::clearBitPattern
bool clearBitPattern()
Definition: CaloSamplingData.cxx:158
CaloSamplingData::testBitPattern
bool testBitPattern(variable_key_type theVariable) const
Definition: CaloSamplingData.h:290
CaloSamplingData::storeData
bool storeData(variable_key_type theVariable, sampling_key_type theSampling, value_type theData)
}
Definition: CaloSamplingData.cxx:109
CaloSamplingData::m_varTypePattern
unsigned int m_varTypePattern
Definition: CaloSamplingData.h:117
CaloSamplingData::~CaloSamplingData
virtual ~CaloSamplingData()
Destructor.
CaloSamplingData::operator=
CaloSamplingData & operator=(const CaloSamplingData &)
Definition: CaloSamplingData.cxx:38
CaloSamplingData::getNumberOfSamplings
size_t getNumberOfSamplings() const
Set variable type pattern for this store.
Definition: CaloSamplingData.h:186
CaloSamplingData::getBitPattern
unsigned int getBitPattern(variable_key_type theVariable) const
Definition: CaloSamplingData.h:286
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
CaloSamplingData::getNumberOfVariableTypes
size_t getNumberOfVariableTypes() const
Return number of variable types.
Definition: CaloSamplingData.h:189
CaloSamplingData::fastNsamp
size_t fastNsamp() const
Definition: CaloSamplingData.h:307
WriteCalibToCool.swap
swap
Definition: WriteCalibToCool.py:94
CaloSamplingData::IsValidData
Functor to check if data is valid (non-zero)
Definition: CaloSamplingData.h:99
CaloSamplingData::setupStores
bool setupStores()
Definition: CaloSamplingData.cxx:140
CaloSamplingData::CaloSamplingData
CaloSamplingData()
Constructor.
Definition: CaloSamplingData.cxx:15
CaloVariableType::setConstMarker
static unsigned int setConstMarker(const unsigned int &bitPattern)
Definition: CaloVariableType.h:53
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
CaloSamplingData::m_dataStore
variable_store_type m_dataStore
Definition: CaloSamplingData.h:115
CaloSamplingData.h
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
CaloSamplingData::testConstPattern
bool testConstPattern() const
Definition: CaloSamplingData.h:297
CaloSamplingData
Simple data object to store all variables in calorimeter samplings.
Definition: CaloSamplingData.h:18
value_type
Definition: EDM_MasterSearch.h:11
CaloSamplingData::index
size_t index(size_t theVariable, size_t theSampling) const
Definition: CaloSamplingData.h:301
CaloSamplingData::checkBitPattern
bool checkBitPattern(variable_key_type theVariable)
Definition: CaloSamplingData.cxx:168
CaloVariableType
definition of Calorimeter Variable types in CaloCluster.
Definition: CaloVariableType.h:13
CaloSamplingData::vector_type
std::vector< value_type > vector_type
Vector type for data exchange (read/write)
Definition: CaloSamplingData.h:34