ATLAS Offline Software
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
CaloSamplingData Class Reference

Simple data object to store all variables in calorimeter samplings. More...

#include <CaloSamplingData.h>

Collaboration diagram for CaloSamplingData:

Classes

class  IsValidData
 Functor to check if data is valid (non-zero) More...
 

Public Types

typedef CaloSampling::CaloSample sampling_key_type
 Sampling look-up key type. More...
 
typedef CaloVariableType::VariableType variable_key_type
 Variable look-up type. More...
 
typedef double value_type
 General data type. More...
 
typedef std::vector< value_typevariable_store_type
 Sampling look-up table type, internal use only. More...
 
typedef std::vector< value_typeconst_vector_type
 Vector type for data exchange (read only) More...
 
typedef std::vector< value_typevector_type
 Vector type for data exchange (read/write) More...
 

Public Member Functions

 CaloSamplingData ()
 Constructor. More...
 
 CaloSamplingData (unsigned int varTypePattern)
 Alternative constructor with variable type pattern. More...
 
 CaloSamplingData (const CaloSamplingData &rData)
 Copy constructor. More...
 
 CaloSamplingData (const CaloSamplingData *pData)
 
CaloSamplingDataoperator= (const CaloSamplingData &)
 
virtual ~CaloSamplingData ()
 Destructor. More...
 
void swap (CaloSamplingData &other)
 
size_t getNumberOfSamplings () const
 Set variable type pattern for this store. More...
 
size_t getNumberOfSamplings (variable_key_type theVariable) const
 Return number of samplings stored for a given variable type. More...
 
size_t getNumberOfVariableTypes () const
 Return number of variable types. More...
 
value_type retrieveData (variable_key_type theVariable, sampling_key_type theSampling) const
 Retrieve const reference to individual variable. More...
 
value_typeretrieveData (variable_key_type theVariable, sampling_key_type theSampling)
 Retrieve non-cont reference to individual variable. More...
 
bool retrieveData (variable_key_type theVariable, vector_type &theData) const
 Retrieve set of variables into a vector. More...
 
bool removeVariable (variable_key_type theVariable, sampling_key_type theSampling)
 Remove a certain variable. More...
 
bool removeVariable (variable_key_type theVariable)
 Remove all variables of the same type. More...
 
bool removeVariable (sampling_key_type theSampling)
 Remove all variables from a certain sampling. More...
 
bool removeVariable ()
 
bool clearStore ()
 
bool storeData (variable_key_type theVariable, sampling_key_type theSampling, value_type theData)
 } More...
 
bool storeData (variable_key_type theVariable, const vector_type &theData)
 Store vector of data. More...
 
template<class Iterator >
bool storeData (variable_key_type theVariable, Iterator beg, Iterator end)
 Store range of data. More...
 
bool contains (variable_key_type theVariable) const
 Check on available variable types. More...
 

Private Member Functions

bool setupStores ()
 
unsigned int getBitPattern (variable_key_type theVariable) const
 
bool checkBitPattern (variable_key_type theVariable)
 
bool testBitPattern (variable_key_type theVariable) const
 
bool clearBitPattern (variable_key_type theVariable)
 
bool clearBitPattern ()
 
bool testConstPattern () const
 
size_t index (size_t theVariable, size_t theSampling) const
 
size_t fastNsamp () const
 

Private Attributes

variable_store_type m_dataStore
 
unsigned int m_varTypePattern
 

Friends

class CaloSamplingDataCnv_p1
 
class CaloSamplingDataContainerCnv_p1
 
class CaloClusterContainerCnv_p4
 
class CaloClusterContainerCnv_p5
 
class CaloClusterContainerCnv_p6
 
class CaloClusterContainerCnv_p7
 
class CaloClusterContainerCnvTest_p6
 
class CaloClusterContainerCnvTest_p7
 

Detailed Description

Simple data object to store all variables in calorimeter samplings.

Simple data object to store all variables in calorimeter samplings. The underlying store is compressed in that only variables indexed by the sampling indicator and the variable type are actually stored. The store is dynamic as it adds the appropriate data words for a given samping and variable type, if those are not existing yet. Already existing data words are replaced (overwritten). Note that whenever an interface involving a vector of data words is used to set the variables, the store for the given variable type is completely cleared before insertion of new data words from the vector (all 0's are ignored in this process, and the vector index is translated into a sampling indicator).

This was orginally a vector<vector<double> >. But it was always strictly a rectangular array, so it was rewritten to store the data as a flat vector to avoid multiple memory allocations.

Definition at line 17 of file CaloSamplingData.h.

Member Typedef Documentation

◆ const_vector_type

Vector type for data exchange (read only)

Definition at line 32 of file CaloSamplingData.h.

◆ sampling_key_type

Sampling look-up key type.

Definition at line 22 of file CaloSamplingData.h.

◆ value_type

General data type.

Definition at line 27 of file CaloSamplingData.h.

◆ variable_key_type

Variable look-up type.

Definition at line 24 of file CaloSamplingData.h.

◆ variable_store_type

Sampling look-up table type, internal use only.

Definition at line 29 of file CaloSamplingData.h.

◆ vector_type

Vector type for data exchange (read/write)

Definition at line 34 of file CaloSamplingData.h.

Constructor & Destructor Documentation

◆ CaloSamplingData() [1/4]

CaloSamplingData::CaloSamplingData ( )

Constructor.

Generates an empty but complete store by default (all values are indexed and defaulted, i.e.

= 0.).

Definition at line 15 of file CaloSamplingData.cxx.

16  : m_varTypePattern(0)
17 {
18  this->setupStores();
19 }

◆ CaloSamplingData() [2/4]

CaloSamplingData::CaloSamplingData ( unsigned int  varTypePattern)

Alternative constructor with variable type pattern.

Definition at line 21 of file CaloSamplingData.cxx.

23 {
24  this->setupStores();
25 }

◆ CaloSamplingData() [3/4]

CaloSamplingData::CaloSamplingData ( const CaloSamplingData rData)
explicitdefault

Copy constructor.

◆ CaloSamplingData() [4/4]

CaloSamplingData::CaloSamplingData ( const CaloSamplingData pData)
explicit

Definition at line 32 of file CaloSamplingData.cxx.

33  : m_dataStore (pData->m_dataStore),
35 {
36 }

◆ ~CaloSamplingData()

CaloSamplingData::~CaloSamplingData ( )
virtualdefault

Destructor.

Member Function Documentation

◆ checkBitPattern()

bool CaloSamplingData::checkBitPattern ( variable_key_type  theVariable)
private

Definition at line 168 of file CaloSamplingData.cxx.

169 {
170  if ( this->testConstPattern() ) return this->testBitPattern(theVariable);
171  m_varTypePattern = m_varTypePattern | this->getBitPattern(theVariable);
172  return true;
173 }

◆ clearBitPattern() [1/2]

bool CaloSamplingData::clearBitPattern ( )
private

Definition at line 158 of file CaloSamplingData.cxx.

159 {
160  bool testConst = this->testConstPattern();
162  if ( testConst )
164  return true;
165 }

◆ clearBitPattern() [2/2]

bool CaloSamplingData::clearBitPattern ( variable_key_type  theVariable)
private

Definition at line 150 of file CaloSamplingData.cxx.

151 {
152  unsigned int extractBit = this->getBitPattern(theVariable);
153  m_varTypePattern = m_varTypePattern & ~extractBit ;
154  return ( m_varTypePattern & extractBit ) == 0;
155 }

◆ clearStore()

bool CaloSamplingData::clearStore ( )
inline

Definition at line 278 of file CaloSamplingData.h.

278 { return this->removeVariable(); }

◆ contains()

bool CaloSamplingData::contains ( variable_key_type  theVariable) const
inline

Check on available variable types.

}

Definition at line 282 of file CaloSamplingData.h.

283 { return this->testBitPattern(theVariable); }

◆ fastNsamp()

size_t CaloSamplingData::fastNsamp ( ) const
inlineprivate

Definition at line 307 of file CaloSamplingData.h.

308 {
309  return (size_t)(CaloSampling::Unknown);
310 }

◆ getBitPattern()

unsigned int CaloSamplingData::getBitPattern ( variable_key_type  theVariable) const
inlineprivate

Definition at line 286 of file CaloSamplingData.h.

287 { return CaloVariableType::getVariableBit(theVariable); }

◆ getNumberOfSamplings() [1/2]

size_t CaloSamplingData::getNumberOfSamplings ( ) const
inline

Set variable type pattern for this store.

Returns the maximum number of possible calo samplings, which also delimits the numerical range for the calo sampling indicator to [0,getNumberOfSamples()-1].

Return number of samplings stored

Useful for sizing the data vectors holding sampling variables.

Definition at line 186 of file CaloSamplingData.h.

187 { return size_t(CaloSampling::getNumberOfSamplings()); }

◆ getNumberOfSamplings() [2/2]

size_t CaloSamplingData::getNumberOfSamplings ( variable_key_type  theVariable) const

Return number of samplings stored for a given variable type.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
theVariablereference to non-modifiable variable type

This is a run time calculation. It returns the number of samplings with data content for a given variable type. Note the difference to the getNumberOfSamplings() method.

Definition at line 131 of file CaloSamplingData.cxx.

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 }

◆ getNumberOfVariableTypes()

size_t CaloSamplingData::getNumberOfVariableTypes ( ) const
inline

Return number of variable types.

Definition at line 189 of file CaloSamplingData.h.

190 { return size_t(CaloVariableType::getNumberOfVariables()); }

◆ index()

size_t CaloSamplingData::index ( size_t  theVariable,
size_t  theSampling 
) const
inlineprivate

Definition at line 301 of file CaloSamplingData.h.

302 {
303  return theVariable * fastNsamp() + theSampling;
304 }

◆ operator=()

CaloSamplingData & CaloSamplingData::operator= ( const CaloSamplingData other)

Definition at line 38 of file CaloSamplingData.cxx.

39 {
40  if (this != &other) {
41  m_dataStore = other.m_dataStore;
42  m_varTypePattern = other.m_varTypePattern;
43  }
44  return *this;
45 }

◆ removeVariable() [1/4]

bool CaloSamplingData::removeVariable ( )
inline

Definition at line 273 of file CaloSamplingData.h.

274 {
275  std::fill (m_dataStore.begin(), m_dataStore.end(), value_type());
276  return this->clearBitPattern();
277 }

◆ removeVariable() [2/4]

bool CaloSamplingData::removeVariable ( sampling_key_type  theSampling)
inline

Remove all variables from a certain sampling.

Definition at line 255 of file CaloSamplingData.h.

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 }

◆ removeVariable() [3/4]

bool CaloSamplingData::removeVariable ( variable_key_type  theVariable)
inline

Remove all variables of the same type.

Definition at line 266 of file CaloSamplingData.h.

267 {
268  size_t idx = index (theVariable, 0);
269  std::fill_n (m_dataStore.begin() + idx, fastNsamp(), value_type());
270  return true;
271 }

◆ removeVariable() [4/4]

bool CaloSamplingData::removeVariable ( variable_key_type  theVariable,
sampling_key_type  theSampling 
)
inline

Remove a certain variable.

{

Parameters
theVariablereference to a non-modifiable variable type
theSamplingreference to a non-modifiable sampling indicator

Removing a variable in this implementation means to set it to the default value generated by its constructor, e.g. double() generates 0. The data word is left in store. This is an artifact of the underlying storage model, which cannot use maps. Several interfaces are available for data removal, starting from the removal of individual data words to the removal of all words of a given variable type or sampling.

Definition at line 248 of file CaloSamplingData.h.

250 {
251  m_dataStore[index(theVariable,theSampling)] = value_type();
252  return true;
253 }

◆ retrieveData() [1/3]

CaloSamplingData::value_type & CaloSamplingData::retrieveData ( variable_key_type  theVariable,
sampling_key_type  theSampling 
)
inline

Retrieve non-cont reference to individual variable.

Parameters
theVariablereference to variable key, non-modifiable
theSamplingreference to sampling key, non-modifiable

Retrieval of a modifiable indexed data word.

The enumerator ranges prevent illegal data access out of the valid index space. The internal data matrix is dimensioned as ([valid_number_of_variables]+1) * ([valid_number_of_samplings]+1). This allows valid response to the CaloSampling::Unknown and CaloVariableType::NO_OF_TYPES enumerators.

Definition at line 206 of file CaloSamplingData.h.

208 {
209  m_varTypePattern = m_varTypePattern | this->getBitPattern(theVariable);
210  return m_dataStore[index(theVariable, theSampling)];
211 }

◆ retrieveData() [2/3]

CaloSamplingData::value_type CaloSamplingData::retrieveData ( variable_key_type  theVariable,
sampling_key_type  theSampling 
) const
inline

Retrieve const reference to individual variable.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
theVariablereference to variable key, non-modifiable
theSamplingreference to sampling key, non-modifiable

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Retrieval of a non-modifiable indexed data word.

Definition at line 225 of file CaloSamplingData.h.

227 {
228  return m_dataStore[index(theVariable, theSampling)];
229 }

◆ retrieveData() [3/3]

bool CaloSamplingData::retrieveData ( variable_key_type  theVariable,
vector_type theData 
) const

Retrieve set of variables into a vector.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
theVariablereference to variable key, non-modifiable
theDatavector of data words

Retrieves all data for a given variable type into a vector. This vector is referenced on input, and is cleared in any case. Returns true if vector is not empty on output.

Definition at line 69 of file CaloSamplingData.cxx.

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 }

◆ setupStores()

bool CaloSamplingData::setupStores ( )
private

Definition at line 140 of file CaloSamplingData.cxx.

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 }

◆ storeData() [1/3]

bool CaloSamplingData::storeData ( variable_key_type  theVariable,
const vector_type theData 
)

Store vector of data.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
theVariablereference to a non-modifiable variable type indicator
theDatavector of data words

Returns true only if input data vector is empty. Note that the vector index is translated into a calo sampling indicator. Only up to theData.size() words are overwritten in the store. If this number is smaller than the store size, the original data beyond the corresponding index is not changed.

If theData.size() is larger than the store size, only the first store size words are copied from theData. If theData.size() is 0, the store is unchanged.

Definition at line 94 of file CaloSamplingData.cxx.

96 {
97  return storeData (theVariable, theData.begin(), theData.end());
98 }

◆ storeData() [2/3]

template<class Iterator >
bool CaloSamplingData::storeData ( variable_key_type  theVariable,
Iterator  beg,
Iterator  end 
)

Store range of data.

Definition at line 314 of file CaloSamplingData.h.

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 }

◆ storeData() [3/3]

bool CaloSamplingData::storeData ( variable_key_type  theVariable,
sampling_key_type  theSampling,
value_type  theData 
)

}

Store individual data word

Parameters
theVariablereference to non-modifiable variable type indicator
theSamplingreference to non-modifiable calo sampling indicator
theDatareference to non-modifiable data word

Returns true if data is succesfully stored. Note that previously stored data with the same indices are overwritten without warning.

Definition at line 109 of file CaloSamplingData.cxx.

112 {
113  bool testWrite = this->checkBitPattern(theVariable);
114  if ( testWrite )
115  {
116  m_dataStore[index(theVariable,theSampling)] = theData;
117  }
118  return testWrite;
119 }

◆ swap()

void CaloSamplingData::swap ( CaloSamplingData other)

Definition at line 51 of file CaloSamplingData.cxx.

52 {
53  m_dataStore.swap (other.m_dataStore);
54  std::swap (m_varTypePattern, other.m_varTypePattern);
55 }

◆ testBitPattern()

bool CaloSamplingData::testBitPattern ( variable_key_type  theVariable) const
inlineprivate

Definition at line 290 of file CaloSamplingData.h.

291 {
292  unsigned int testBit(this->getBitPattern(theVariable));
293  if (testBit == 0) return false;
294  return ( m_varTypePattern & testBit ) == testBit;
295 }

◆ testConstPattern()

bool CaloSamplingData::testConstPattern ( ) const
inlineprivate

Definition at line 297 of file CaloSamplingData.h.

Friends And Related Function Documentation

◆ CaloClusterContainerCnv_p4

friend class CaloClusterContainerCnv_p4
friend

Definition at line 108 of file CaloSamplingData.h.

◆ CaloClusterContainerCnv_p5

friend class CaloClusterContainerCnv_p5
friend

Definition at line 109 of file CaloSamplingData.h.

◆ CaloClusterContainerCnv_p6

friend class CaloClusterContainerCnv_p6
friend

Definition at line 110 of file CaloSamplingData.h.

◆ CaloClusterContainerCnv_p7

friend class CaloClusterContainerCnv_p7
friend

Definition at line 111 of file CaloSamplingData.h.

◆ CaloClusterContainerCnvTest_p6

friend class CaloClusterContainerCnvTest_p6
friend

Definition at line 112 of file CaloSamplingData.h.

◆ CaloClusterContainerCnvTest_p7

friend class CaloClusterContainerCnvTest_p7
friend

Definition at line 113 of file CaloSamplingData.h.

◆ CaloSamplingDataCnv_p1

friend class CaloSamplingDataCnv_p1
friend

Definition at line 106 of file CaloSamplingData.h.

◆ CaloSamplingDataContainerCnv_p1

friend class CaloSamplingDataContainerCnv_p1
friend

Definition at line 107 of file CaloSamplingData.h.

Member Data Documentation

◆ m_dataStore

variable_store_type CaloSamplingData::m_dataStore
private

Definition at line 115 of file CaloSamplingData.h.

◆ m_varTypePattern

unsigned int CaloSamplingData::m_varTypePattern
private

Definition at line 117 of file CaloSamplingData.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
GetLCDefs::Unknown
@ Unknown
Definition: GetLCDefs.h:21
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::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
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
CaloSamplingData::getBitPattern
unsigned int getBitPattern(variable_key_type theVariable) const
Definition: CaloSamplingData.h:286
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
CaloVariableType::getNumberOfVariables
static unsigned int getNumberOfVariables()
Definition: CaloVariableType.h:58
WriteCalibToCool.swap
swap
Definition: WriteCalibToCool.py:94
CaloSamplingData::setupStores
bool setupStores()
Definition: CaloSamplingData.cxx:140
merge.output
output
Definition: merge.py:17
CaloVariableType::setConstMarker
static unsigned int setConstMarker(const unsigned int &bitPattern)
Definition: CaloVariableType.h:53
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
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
lumiFormat.fill
fill
Definition: lumiFormat.py:111
CaloSamplingData::testConstPattern
bool testConstPattern() const
Definition: CaloSamplingData.h:297
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
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