ATLAS Offline Software
Loading...
Searching...
No Matches
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
20
21CaloSamplingData::CaloSamplingData(unsigned int varTypePattern)
22 : m_varTypePattern(CaloVariableType::setConstMarker(varTypePattern))
23{
24 this->setupStores();
25}
26
28
29
30= default;
31
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
68bool
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
130size_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
139bool
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
149bool
151{
152 unsigned int extractBit = this->getBitPattern(theVariable);
153 m_varTypePattern = m_varTypePattern & ~extractBit ;
154 return ( m_varTypePattern & extractBit ) == 0;
155}
156
157bool
166
167bool
169{
170 if ( this->testConstPattern() ) return this->testBitPattern(theVariable);
171 m_varTypePattern = m_varTypePattern | this->getBitPattern(theVariable);
172 return true;
173}
Functor to check if data is valid (non-zero)
Simple data object to store all variables in calorimeter samplings.
unsigned int getBitPattern(variable_key_type theVariable) const
void swap(CaloSamplingData &other)
size_t fastNsamp() const
size_t getNumberOfSamplings() const
Set variable type pattern for this store.
std::vector< value_type > vector_type
Vector type for data exchange (read/write)
CaloVariableType::VariableType variable_key_type
Variable look-up type.
unsigned int m_varTypePattern
bool checkBitPattern(variable_key_type theVariable)
CaloSamplingData()
Constructor.
value_type retrieveData(variable_key_type theVariable, sampling_key_type theSampling) const
Retrieve const reference to individual variable.
double value_type
General data type.
bool testConstPattern() const
CaloSampling::CaloSample sampling_key_type
Sampling look-up key type.
size_t getNumberOfVariableTypes() const
Return number of variable types.
virtual ~CaloSamplingData()
Destructor.
bool testBitPattern(variable_key_type theVariable) const
bool storeData(variable_key_type theVariable, sampling_key_type theSampling, value_type theData)
}
CaloSamplingData & operator=(const CaloSamplingData &)
variable_store_type m_dataStore
Definition index.py:1
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
definition of Calorimeter Variable types in CaloCluster.
static unsigned int setConstMarker(const unsigned int &bitPattern)