ATLAS Offline Software
CaloSamplingData.h
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef CALOEVENT_CALOSAMPLINGDATA_H
8 #define CALOEVENT_CALOSAMPLINGDATA_H
9 
10 #include "CaloGeoHelpers/CaloSampling.h"
12 #include "CxxUtils/copy_bounded.h"
13 
14 #include <vector>
15 #include <algorithm>
16 
18 {
19  public:
20 
25 
27  typedef double value_type;
29  typedef std::vector<value_type> variable_store_type;
30 
32  typedef std::vector<value_type> const_vector_type;
34  typedef std::vector<value_type> vector_type;
35 
39  CaloSamplingData(unsigned int varTypePattern);
41  explicit CaloSamplingData(const CaloSamplingData& rData);
42  explicit CaloSamplingData(const CaloSamplingData* pData);
45  virtual ~CaloSamplingData();
46 
47  void swap (CaloSamplingData& other);
48 
50 
53  size_t getNumberOfSamplings() const;
55  size_t getNumberOfSamplings(variable_key_type theVariable) const;
56 
58  size_t getNumberOfVariableTypes() const;
59 
62  sampling_key_type theSampling) const;
65  sampling_key_type theSampling);
67  bool retrieveData(variable_key_type theVariable,
68  vector_type& theData) const;
69 
71  bool removeVariable(variable_key_type theVariable,
72  sampling_key_type theSampling);
74  bool removeVariable(variable_key_type theVariable);
76  bool removeVariable(sampling_key_type theSampling);
77  /*{! \brief Clear the store */
78  bool removeVariable();
79  bool clearStore();
83  bool storeData(variable_key_type theVariable,
84  sampling_key_type theSampling,
85  value_type theData);
87  bool storeData(variable_key_type theVariable,
88  const vector_type& theData);
90  template <class Iterator>
91  bool storeData(variable_key_type theVariable, Iterator beg, Iterator end);
92 
94  bool contains(variable_key_type theVariable) const;
95 
96  protected:
97 
99  {
100  public:
101  bool operator()(value_type theData)
102  { return theData != value_type(); }
103  };
104 
105  private:
114 
116 
117  unsigned int m_varTypePattern;
118 
119  bool setupStores();
120 
121  unsigned int getBitPattern(variable_key_type theVariable) const;
122 
123  bool checkBitPattern(variable_key_type theVariable);
124  bool testBitPattern(variable_key_type theVariable) const;
125  bool clearBitPattern(variable_key_type theVariable);
126  bool clearBitPattern();
127  bool testConstPattern() const;
128 
129  size_t index (size_t theVariable, size_t theSampling) const;
130  size_t fastNsamp() const;
131 };
173 
176 // Retrieve Data Helpers //
178 
187 { return size_t(CaloSampling::getNumberOfSamplings()); }
188 
190 { return size_t(CaloVariableType::getNumberOfVariables()); }
191 
207  sampling_key_type theSampling)
208 {
209  m_varTypePattern = m_varTypePattern | this->getBitPattern(theVariable);
210  return m_dataStore[index(theVariable, theSampling)];
211 }
212 
226  sampling_key_type theSampling) const
227 {
228  return m_dataStore[index(theVariable, theSampling)];
229 }
230 
232 // Store And Erase Data Helper //
234 
235 
247 inline bool
249  sampling_key_type theSampling)
250 {
251  m_dataStore[index(theVariable,theSampling)] = value_type();
252  return true;
253 }
254 inline bool
256 {
258  m_dataStore.begin() + index (0, theSampling);
260  int nsamp = fastNsamp();
261  for (; beg < end; beg += nsamp)
262  *beg = value_type();
263  return true;
264 }
265 inline bool
267 {
268  size_t idx = index (theVariable, 0);
269  std::fill_n (m_dataStore.begin() + idx, fastNsamp(), value_type());
270  return true;
271 }
272 inline bool
274 {
275  std::fill (m_dataStore.begin(), m_dataStore.end(), value_type());
276  return this->clearBitPattern();
277 }
278 inline bool CaloSamplingData::clearStore() { return this->removeVariable(); }
281 inline bool
283 { return this->testBitPattern(theVariable); }
284 
285 inline unsigned int
287 { return CaloVariableType::getVariableBit(theVariable); }
288 
289 inline bool
291 {
292  unsigned int testBit(this->getBitPattern(theVariable));
293  if (testBit == 0) return false;
294  return ( m_varTypePattern & testBit ) == testBit;
295 }
296 
299 
300 inline
301 size_t CaloSamplingData::index (size_t theVariable, size_t theSampling) const
302 {
303  return theVariable * fastNsamp() + theSampling;
304 }
305 
306 inline
308 {
309  return (size_t)(CaloSampling::Unknown);
310 }
311 
312 
313 template <class Iterator>
315  Iterator beg, Iterator end)
316 {
317  //Check const bit and set m_varTypePattern
318  if (!this->checkBitPattern (theVariable))
319  return false;
320  if (beg == end)
321  return false;
323  m_dataStore.begin() + index(theVariable, 0);
325  return true;
326 
327 }
328 
329 #endif
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
CaloSamplingData::swap
void swap(CaloSamplingData &other)
Definition: CaloSamplingData.cxx:51
GetLCDefs::Unknown
@ Unknown
Definition: GetLCDefs.h:21
CaloVariableType::VariableType
VariableType
Definition: CaloVariableType.h:15
CaloSamplingData::CaloClusterContainerCnvTest_p7
friend class CaloClusterContainerCnvTest_p7
Definition: CaloSamplingData.h:113
CaloSamplingData::retrieveData
value_type retrieveData(variable_key_type theVariable, sampling_key_type theSampling) const
Retrieve const reference to individual variable.
Definition: CaloSamplingData.h:225
CaloSamplingDataCnv_p1
Definition: CaloSamplingDataCnv_p1.h:17
CaloSamplingData::value_type
double value_type
General data type.
Definition: CaloSamplingData.h:27
CaloSamplingData::removeVariable
bool removeVariable()
Definition: CaloSamplingData.h:273
CaloSamplingData::clearBitPattern
bool clearBitPattern()
Definition: CaloSamplingData.cxx:158
CaloSamplingData::variable_key_type
CaloVariableType::VariableType variable_key_type
Variable look-up type.
Definition: CaloSamplingData.h:24
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::variable_store_type
std::vector< value_type > variable_store_type
Sampling look-up table type, internal use only.
Definition: CaloSamplingData.h:29
CaloClusterContainerCnv_p5
Definition: CaloClusterContainerCnv_p5.h:27
CaloSamplingData::m_varTypePattern
unsigned int m_varTypePattern
Definition: CaloSamplingData.h:117
copy_bounded.h
Copy a range with bounds restriction.
CaloSamplingData::~CaloSamplingData
virtual ~CaloSamplingData()
Destructor.
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
CaloSamplingDataContainerCnv_p1
Definition: CaloSamplingDataContainerCnv_p1.h:15
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
CaloClusterContainerCnv_p6
Definition: CaloClusterContainerCnv_p6.h:27
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
CaloSamplingData::CaloSamplingData
CaloSamplingData(const CaloSamplingData &rData)
Copy constructor.
CaloVariableType::getNumberOfVariables
static unsigned int getNumberOfVariables()
Definition: CaloVariableType.h:58
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
fill
void fill(H5::Group &out_file, size_t iterations)
Definition: test-hdf5-writer.cxx:95
merge.output
output
Definition: merge.py:17
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
CaloVariableType::getVariableBit
static unsigned int getVariableBit(const VariableType &varType)
Definition: CaloVariableType.h:25
CaloSamplingData::m_dataStore
variable_store_type m_dataStore
Definition: CaloSamplingData.h:115
CaloSampling::getNumberOfSamplings
static constexpr unsigned int getNumberOfSamplings()
Get number of available samplings.
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:30
CaloVariableType::checkConst
static bool checkConst(const unsigned int &bitPattern)
Definition: CaloVariableType.h:48
CaloSamplingData::const_vector_type
std::vector< value_type > const_vector_type
Vector type for data exchange (read only)
Definition: CaloSamplingData.h:32
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
CaloSamplingData::contains
bool contains(variable_key_type theVariable) const
Check on available variable types.
Definition: CaloSamplingData.h:282
CaloClusterContainerCnv_p7
Definition: CaloClusterContainerCnv_p7.h:28
CaloSamplingData::sampling_key_type
CaloSampling::CaloSample sampling_key_type
Sampling look-up key type.
Definition: CaloSamplingData.h:22
CaloSamplingData::testConstPattern
bool testConstPattern() const
Definition: CaloSamplingData.h:297
CaloSamplingData::IsValidData::operator()
bool operator()(value_type theData)
Definition: CaloSamplingData.h:101
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
CxxUtils::copy_bounded
auto copy_bounded(const InputRange &input, OutputRange &output) -> decltype(std::begin(output))
Copy a range with bounds restriction.
Definition: copy_bounded.h:102
CaloClusterContainerCnv_p4
Definition: CaloClusterContainerCnv_p4.h:27
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::CaloClusterContainerCnvTest_p6
friend class CaloClusterContainerCnvTest_p6
Definition: CaloSamplingData.h:112
CaloVariableType.h
CaloSamplingData::checkBitPattern
bool checkBitPattern(variable_key_type theVariable)
Definition: CaloSamplingData.cxx:168
CaloSamplingData::vector_type
std::vector< value_type > vector_type
Vector type for data exchange (read/write)
Definition: CaloSamplingData.h:34
CaloSamplingData::clearStore
bool clearStore()
Definition: CaloSamplingData.h:278