ATLAS Offline Software
CaloSamplingDataContainerCnv_p1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
11  MsgStream& /*log*/) const
12 {
13  pers->m_varTypePatterns.push_back(trans->m_varTypePattern);
14  typedef CaloSamplingData::variable_store_type::size_type var_size_type;
15  //The sampling data store gets resized to nVariables x nSamplings by its constructor
16  size_t nVar=trans->getNumberOfVariableTypes();
17  size_t nSamplings=trans->fastNsamp();
18  for (var_size_type i=0;i<nVar;++i) {
19  //Copy only if filled
20  if (trans->m_varTypePattern & (0x1U<<i)) {
21  CaloSamplingData::variable_store_type::const_iterator pos =
22  trans->m_dataStore.begin() + trans->index (i, 0);
23  pers->m_dataStore.insert (pers->m_dataStore.end(),
24  pos, pos + nSamplings);
25  }
26  }//loop over variable types
27 }
28 
30  CaloSamplingData* trans,
31  State& state) const
32 {
33  //Convert m_varTypePattern
35  size_t nVar=trans->getNumberOfVariableTypes();
36  size_t nSamplings=trans->fastNsamp();
38 
39  size_t nCopySamplings = std::min (nSamplings, state.m_nPersSamplings);
40 
41  for (size_t i=0;i<nVar;++i) {
42  //Copy only if filled
43  if (trans->m_varTypePattern & (0x1U<<i)) {
45  trans->m_dataStore.begin() + trans->index (i, 0);
47  state.m_samplingStoreIterator + nCopySamplings,
48  pos);
49  if (state.m_nPersSamplings < nSamplings)
50  std::fill (pos + state.m_nPersSamplings, pos + nSamplings, 0);
52  }
53  else //variable not present, set to zero
54  trans->removeVariable (static_cast<vartype>(i));
55  }//end for loop over varTypes
56 }
57 
58 
60  unsigned int ncluster,
61  State& state) const
62 {
63  state.m_samplingStoreIterator=pers->m_dataStore.begin();
64  state.m_varTypePatternsIterator=pers->m_varTypePatterns.begin();
65 
66  // Previous versions of the code could have written one more sampling
67  // than actually exists. Count the number of variables that were written,
68  // then divide the persistent vector by that to get the number of samplings
69  // that were actually written.
70  std::vector<unsigned int>::const_iterator it =
71  pers->m_varTypePatterns.begin();
72  std::vector<unsigned int>::const_iterator end =
73  pers->m_varTypePatterns.end();
74  size_t nPersVars = 0;
75  for (; it != end; ++it) {
76  unsigned int mask = (*it & CaloVariableType::getAllVariableBits());
77  while (mask != 0) {
78  if ((mask & 1) != 0)
79  ++nPersVars;
80  mask >>= 1;
81  }
82  }
83 
84  if (nPersVars == 0)
85  state.m_nPersSamplings = 0;
86  else
87  state.m_nPersSamplings = pers->m_dataStore.size() / nPersVars;
88 
89  if (ncluster != pers->m_varTypePatterns.size()) {
90  REPORT_MESSAGE_WITH_CONTEXT(MSG::WARNING, "CaloSamplingDataContainerCnv_p1")
91  << "Corrupted persistent data seen: "
92  << ncluster << " clusters != "
93  << pers->m_varTypePatterns.size() << " stored vartype patterns.";
94  return false;
95  }
96 
97  if (nPersVars == 0 && pers->m_dataStore.empty())
98  {} // ok
99  else if (nPersVars == 0 || (pers->m_dataStore.size() % nPersVars) != 0) {
100  REPORT_MESSAGE_WITH_CONTEXT(MSG::WARNING, "CaloSamplingDataContainerCnv_p1")
101  << "Corrupted persistent data seen: "
102  << pers->m_dataStore.size() << " stored values is not a multiple of "
103  << nPersVars << " stored variables.";
104  return false;
105  }
106 
107  return true;
108 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
CaloSamplingDataContainer_p1
Definition: CaloSamplingDataContainer_p1.h:11
CaloVariableType::VariableType
VariableType
Definition: CaloVariableType.h:15
CaloVariableType::getAllVariableBits
static unsigned int getAllVariableBits()
Definition: CaloVariableType.h:63
CaloSamplingDataContainer_p1::m_varTypePatterns
std::vector< unsigned int > m_varTypePatterns
Definition: CaloSamplingDataContainer_p1.h:14
CaloSamplingDataContainerCnv_p1::State::m_nPersSamplings
size_t m_nPersSamplings
Definition: CaloSamplingDataContainerCnv_p1.h:21
CaloSamplingDataContainerCnv_p1::persToTrans
void persToTrans(const CaloSamplingDataContainer_p1 *pers, CaloSamplingData *trans, State &state) const
Definition: CaloSamplingDataContainerCnv_p1.cxx:29
skel.it
it
Definition: skel.GENtoEVGEN.py:396
CaloSamplingData::m_varTypePattern
unsigned int m_varTypePattern
Definition: CaloSamplingData.h:117
CaloSamplingData::removeVariable
bool removeVariable(variable_key_type theVariable, sampling_key_type theSampling)
Remove a certain variable.
Definition: CaloSamplingData.h:248
CaloSamplingDataContainerCnv_p1::State::m_varTypePatternsIterator
std::vector< unsigned int >::const_iterator m_varTypePatternsIterator
Definition: CaloSamplingDataContainerCnv_p1.h:20
CaloSamplingDataContainerCnv_p1::State::m_samplingStoreIterator
CaloSamplingDataContainer_p1::const_iterator m_samplingStoreIterator
Definition: CaloSamplingDataContainerCnv_p1.h:19
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloSamplingData::getNumberOfVariableTypes
size_t getNumberOfVariableTypes() const
Return number of variable types.
Definition: CaloSamplingData.h:189
CaloSamplingDataContainerCnv_p1::State
Definition: CaloSamplingDataContainerCnv_p1.h:18
CaloSamplingData::fastNsamp
size_t fastNsamp() const
Definition: CaloSamplingData.h:307
min
#define min(a, b)
Definition: cfImp.cxx:40
fill
void fill(H5::Group &out_file, size_t iterations)
Definition: test-hdf5-writer.cxx:95
REPORT_MESSAGE_WITH_CONTEXT
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:345
errorcheck.h
Helpers for checking error return status codes and reporting errors.
CaloSamplingDataContainerCnv_p1::transToPers
void transToPers(const CaloSamplingData *trans, CaloSamplingDataContainer_p1 *pers, MsgStream &log) const
Definition: CaloSamplingDataContainerCnv_p1.cxx:9
CaloSamplingData::m_dataStore
variable_store_type m_dataStore
Definition: CaloSamplingData.h:115
CaloSamplingDataContainerCnv_p1.h
CaloSamplingData.h
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
CaloSamplingDataContainerCnv_p1::setState
bool setState(const CaloSamplingDataContainer_p1 *pers, unsigned int ncluster, State &state) const
Definition: CaloSamplingDataContainerCnv_p1.cxx:59
CaloSamplingDataContainer_p1::m_dataStore
std::vector< float > m_dataStore
Definition: CaloSamplingDataContainer_p1.h:15
calibdata.copy
bool copy
Definition: calibdata.py:27
CaloSamplingData
Simple data object to store all variables in calorimeter samplings.
Definition: CaloSamplingData.h:18
CaloSamplingData::index
size_t index(size_t theVariable, size_t theSampling) const
Definition: CaloSamplingData.h:301