ATLAS Offline Software
Classes | Public Member Functions | List of all members
CaloSamplingDataContainerCnv_p1 Class Reference

#include <CaloSamplingDataContainerCnv_p1.h>

Collaboration diagram for CaloSamplingDataContainerCnv_p1:

Classes

struct  State
 

Public Member Functions

void persToTrans (const CaloSamplingDataContainer_p1 *pers, CaloSamplingData *trans, State &state) const
 
void transToPers (const CaloSamplingData *trans, CaloSamplingDataContainer_p1 *pers, MsgStream &log) const
 
bool setState (const CaloSamplingDataContainer_p1 *pers, unsigned int ncluster, State &state) const
 

Detailed Description

Definition at line 15 of file CaloSamplingDataContainerCnv_p1.h.

Member Function Documentation

◆ persToTrans()

void CaloSamplingDataContainerCnv_p1::persToTrans ( const CaloSamplingDataContainer_p1 pers,
CaloSamplingData trans,
State state 
) const

Definition at line 29 of file CaloSamplingDataContainerCnv_p1.cxx.

32 {
33  //Convert m_varTypePattern
34  trans->m_varTypePattern=*(state.m_varTypePatternsIterator++);
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);
46  std::copy (state.m_samplingStoreIterator,
47  state.m_samplingStoreIterator + nCopySamplings,
48  pos);
49  if (state.m_nPersSamplings < nSamplings)
50  std::fill (pos + state.m_nPersSamplings, pos + nSamplings, 0);
51  state.m_samplingStoreIterator += state.m_nPersSamplings;
52  }
53  else //variable not present, set to zero
54  trans->removeVariable (static_cast<vartype>(i));
55  }//end for loop over varTypes
56 }

◆ setState()

bool CaloSamplingDataContainerCnv_p1::setState ( const CaloSamplingDataContainer_p1 pers,
unsigned int  ncluster,
State state 
) const

Definition at line 59 of file CaloSamplingDataContainerCnv_p1.cxx.

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 }

◆ transToPers()

void CaloSamplingDataContainerCnv_p1::transToPers ( const CaloSamplingData trans,
CaloSamplingDataContainer_p1 pers,
MsgStream &  log 
) const

Definition at line 9 of file CaloSamplingDataContainerCnv_p1.cxx.

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 }

The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
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
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
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
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
CaloSamplingData::m_dataStore
variable_store_type m_dataStore
Definition: CaloSamplingData.h:115
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
CaloSamplingDataContainer_p1::m_dataStore
std::vector< float > m_dataStore
Definition: CaloSamplingDataContainer_p1.h:15
calibdata.copy
bool copy
Definition: calibdata.py:27
CaloSamplingData::index
size_t index(size_t theVariable, size_t theSampling) const
Definition: CaloSamplingData.h:301