ATLAS Offline Software
DataHeaderCnv_p5.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
13 #include "CxxUtils/sgkey_t.h"
14 
17 
18 //______________________________________________________________________________
20  DataHeaderElement& trans,
21  const DataHeaderForm_p5& form,
22  unsigned int entry) const
23 {
24  delete trans.m_token; trans.m_token = new Token; trans.m_ownToken = true;
25  Token* token = const_cast<Token*>(trans.m_token);
26  std::vector<unsigned int>::const_iterator intIter = form.params(entry).begin();
27  unsigned int keyIdx = 0U, aliasNum = 0U, clidNum = 0U;
28 // Translate PoolToken
29  if ((*intIter&0x0000FFFF) == 0) {
30  ++intIter;
31  keyIdx = *intIter; ++intIter;
32  aliasNum = *intIter; ++intIter;
33  clidNum = *intIter; ++intIter;
34  token->fromString(pers.m_token);
35  } else {
36  const unsigned int keyPos = (unsigned short)(*intIter>>16),
37  version = (unsigned short)(*intIter&0x0000FFFF); ++intIter;
38  const unsigned int guidIdx = (unsigned short)(*intIter>>16),
39  classIdx = (unsigned short)(*intIter&0x0000FFFF); ++intIter;
40  const unsigned int prefixIdx = (unsigned short)(*intIter>>16),
41  typeIdx = (unsigned short)(*intIter&0x0000FFFF); ++intIter;
42 // Add Technology and Offsets
43  unsigned int tech = 514;
44  if (version&0x00000001U) {
45  tech = *intIter; ++intIter;
46  }
47  unsigned int oid1 = *intIter; ++intIter;
48  if (version&0x00000010U) {
49  keyIdx = *intIter; ++intIter;
50  aliasNum = *intIter; ++intIter;
51  clidNum = *intIter; ++intIter;
52  } else {
53  keyIdx = (*intIter>>16), aliasNum = ((*intIter&0x0000FFFF)>>8), clidNum = (*intIter&0x000000FF); ++intIter;
54  }
55 // Append DbGuid
56  Guid guid(form.map()[guidIdx]);
57  token->setDb(guid);
58 // Container name, may be optimized
59  std::string cntName;
60  if (prefixIdx > 0) {
61  cntName += form.map()[prefixIdx];
62  if (typeIdx > 0) {
63  cntName += form.map()[typeIdx];
64  }
65  }
66 // Insert key
67  if (keyPos > 0) {
68  cntName += pers.m_token.substr(0, keyPos - 1) + form.map()[keyIdx] + pers.m_token.substr(keyPos - 1);
69  } else {
70  cntName += pers.m_token;
71  }
72  //token->setCont(cntName);
73 // Append ClassId
74  Guid clid(form.map()[classIdx]);
75  token->setClassID(clid);
76  token->setTechnology(tech);
77  token->setOid(Token::OID_t(oid1, pers.m_oid2));
78  }
79  unsigned int aliasCur = 0U, clidCur = 0U;
80  trans.m_key = form.map()[keyIdx];
81  trans.m_alias.clear();
82  for (std::set<std::string>::const_iterator lastAlias = trans.m_alias.begin();
83  aliasCur < aliasNum; ++aliasCur) {
84  lastAlias = trans.m_alias.insert(lastAlias, form.map()[keyIdx + aliasCur + 1]);
85  }
86  trans.m_pClid = *intIter; ++intIter;
87  trans.m_clids.clear();
88  const std::vector<unsigned int>::const_iterator intLast = form.params(entry).end();
89  for (std::set<CLID>::const_iterator lastClid = trans.m_clids.begin();
90  intIter != intLast && clidCur < clidNum; ++intIter, ++clidCur) {
91  lastClid = trans.m_clids.insert(lastClid, *intIter);
92  }
93  trans.m_hashes.clear();
94  for (; intIter != intLast; ++intIter) {
95  trans.m_hashes.push_back(*intIter);
96  }
97 }
98 //______________________________________________________________________________
100  DataHeaderElement_p5& pers,
101  DataHeaderForm_p5& form,
102  unsigned int entry) const {
103  unsigned int tech = 0U, oid1 = 0U;
104  unsigned short guidIdx = 0U, classIdx = 0U, prefixIdx = 0U, typeIdx = 0U, keyPos = 0U;
105 // Translate PoolToken
106  if (trans.getToken() != 0) {
107 // Database GUID
108  const std::string guid = trans.getToken()->dbID().toString();
109  for (std::vector<std::string>::const_iterator iter = form.map().begin(), last = form.map().end();
110  iter != last; ++iter, ++guidIdx) {
111  if (*iter == guid) break;
112  }
113  if (guidIdx == form.map().size()) {
114  form.insertMap(guid);
115  }
116 // Class GUID
117  const std::string clid = trans.getToken()->classID().toString();
118  for (std::vector<std::string>::const_iterator iter = form.map().begin(), last = form.map().end();
119  iter != last; ++iter, ++classIdx) {
120  if (*iter == clid) break;
121  }
122  if (classIdx == form.map().size()) {
123  form.insertMap(clid);
124  }
125 // Container name, can be optimized
126  pers.m_token = trans.getToken()->contID();
127 // Get Prefix
128  std::string::size_type delim = pers.m_token.find_first_of("_/(");
129  if (delim != std::string::npos) {
130  const std::string persComp1 = pers.m_token.substr(0, delim + 1);
131  for (std::vector<std::string>::const_iterator iter = form.map().begin(), last = form.map().end();
132  iter != last; ++iter, ++prefixIdx) {
133  if (*iter == persComp1) break;
134  }
135  if (prefixIdx == form.map().size()) {
136  form.insertMap(persComp1);
137  }
138  pers.m_token = pers.m_token.substr(delim + 1);
139 // Get TypeName
140 // Check whether Key only is used for placement
141  if (!pers.m_token.starts_with( trans.m_key)) {
142  std::string::size_type delim = pers.m_token.find_first_of("/()");
143  if (delim != std::string::npos) {
144  const std::string persComp2 = pers.m_token.substr(0, delim + 1);
145  for (std::vector<std::string>::const_iterator iter = form.map().begin(), last = form.map().end();
146  iter != last; ++iter, ++typeIdx) {
147  if (*iter == persComp2) break;
148  }
149  if (typeIdx == form.map().size()) {
150  form.insertMap(persComp2);
151  }
152  pers.m_token = pers.m_token.substr(delim + 1);
153  } else if (pers.m_token == "DataHeader") {
154  for (std::vector<std::string>::const_iterator iter = form.map().begin(), last = form.map().end();
155  iter != last; ++iter, ++typeIdx) {
156  if (*iter == "DataHeader") break;
157  }
158  if (typeIdx == form.map().size()) {
159  form.insertMap("DataHeader");
160  }
161  pers.m_token.clear();
162  }
163  }
164  }
165  delim = pers.m_token.rfind(trans.m_key);
166  if (delim != std::string::npos) {
167  keyPos = delim + 1;
168  pers.m_token = pers.m_token.substr(0, delim) + pers.m_token.substr(delim + trans.m_key.size());
169  }
170  tech = trans.getToken()->technology();
171  oid1 = trans.getToken()->oid().first;
172  pers.m_oid2 = trans.getToken()->oid().second;
173  }
174  unsigned int version = 0x0000FFFFU;
175  if (tech == 514) {
176  version = version&0x0000FFFEU;
177  }
178  unsigned int keyIdx = form.map().size(), aliasNum = trans.m_alias.size(), clidNum = trans.m_clids.size();
179  if (keyIdx < 0x00010000U && aliasNum < 0x00000100U && clidNum < 0x00000100U) {
180  version = version&0x0000FFEFU;
181  }
182  form.insertParam((unsigned int)(keyPos) * 0x00010000U + version, entry);
183  form.insertParam((unsigned int)(guidIdx) * 0x00010000U + (unsigned int)(classIdx), entry);
184  form.insertParam((unsigned int)(prefixIdx) * 0x00010000U + (unsigned int)(typeIdx), entry);
185  if (version&0x00000001U) {
186  form.insertParam(tech, entry);
187  }
188  form.insertParam(oid1, entry);
189  if (version&0x00000010U) {
190  form.insertParam(keyIdx, entry);
191  form.insertParam(aliasNum, entry);
192  form.insertParam(clidNum, entry);
193  } else {
194  form.insertParam(keyIdx * 0x00010000U + aliasNum * 0x00000100U + clidNum, entry);
195  }
196  form.insertMap(trans.m_key);
197  for (std::set<std::string>::const_iterator iter = trans.m_alias.begin(),
198  last = trans.m_alias.end(); iter != last; ++iter) {
199  form.insertMap(*iter);
200  }
201  form.insertParam(trans.m_pClid, entry);
202  for (std::set<CLID>::const_iterator iter = trans.m_clids.begin(),
203  last = trans.m_clids.end(); iter != last; ++iter) {
204  form.insertParam(*iter, entry);
205  }
206  for (std::vector<SG::sgkey_t>::const_iterator iter = trans.m_hashes.begin(),
207  last = trans.m_hashes.end(); iter != last; ++iter) {
208  form.insertParam(SG::sgkeyShort (*iter), entry);
209  }
210 }
211 //______________________________________________________________________________
212 //______________________________________________________________________________
215 //______________________________________________________________________________
217  DataHeader& trans,
218  const DataHeaderForm_p5& dhForm) const
219 {
220  unsigned int entry = 1;
221  const unsigned int provSize = dhForm.params(entry)[0];
222  trans.m_inputDataHeader.resize(provSize);
224  std::vector<DataHeaderElement_p5>::const_iterator pit = pers.m_dataHeader.begin();
225  for (unsigned int i = 0U; i < provSize; ++i, ++it, ++pit) {
226  ++entry;
227  m_elemCnv.persToTrans(*pit, *it, dhForm, entry);
228  }
229  trans.m_dataHeader.resize(pers.m_dataHeader.size() - provSize);
230  it = trans.m_dataHeader.begin();
231  for (std::vector<DataHeaderElement_p5>::const_iterator last = pers.m_dataHeader.end();
232  pit != last; ++it, ++pit) {
233  ++entry;
234  m_elemCnv.persToTrans(*pit, *it, dhForm, entry);
235  }
237 }
238 //______________________________________________________________________________
240  DataHeader_p5& pers,
241  DataHeaderForm_p5& dhForm) const
242 {
243  const unsigned int provSize = trans.m_inputDataHeader.size();
244  pers.m_dataHeader.resize(provSize + trans.m_dataHeader.size());
245  dhForm.resize(provSize + trans.m_dataHeader.size() + 2);
246  unsigned int entry = 1;
247  dhForm.insertParam(provSize, entry);
249  for (std::vector<DataHeaderElement>::const_iterator it = trans.m_inputDataHeader.begin(),
250  last = trans.m_inputDataHeader.end(); it != last; ++it, ++pit) {
251  ++entry;
252  m_elemCnv.transToPers(*it, *pit, dhForm, entry);
253  }
254  for (std::vector<DataHeaderElement>::const_iterator it = trans.m_dataHeader.begin(),
255  last = trans.m_dataHeader.end(); it != last; ++it, ++pit) {
256  ++entry;
257  m_elemCnv.transToPers(*it, *pit, dhForm, entry);
258  }
259 }
260 //______________________________________________________________________________
262  DataHeaderForm_p5& dhForm,
263  const std::string& key,
264  const std::string& strToken) const
265 {
266  Token* token = new Token;
267  token->fromString(strToken);
270  unsigned int entry = dhForm.size() + 1;
271  m_elemCnv.transToPers(tEle, pEle, dhForm, entry);
272  pers.m_dataHeader.push_back(pEle);
273 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
DataHeaderElementCnv_p5::transToPers
void transToPers(const DataHeaderElement &trans, DataHeaderElement_p5 &pers, DataHeaderForm_p5 &form, unsigned int entry) const
Definition: DataHeaderCnv_p5.cxx:99
DataHeaderElement_p5::m_token
std::string m_token
Definition: DataHeader_p5.h:35
DataHeaderElement::m_key
std::string m_key
string with StoreGate key.
Definition: DataHeader.h:111
xAOD::short
short
Definition: Vertex_v1.cxx:165
Token::contID
const std::string & contID() const
Access container identifier.
Definition: Token.h:67
DataHeaderCnv_p5::insertDHRef
void insertDHRef(DataHeader_p5 &pers, DataHeaderForm_p5 &dhForm, const std::string &key, const std::string &strToken) const
Definition: DataHeaderCnv_p5.cxx:261
DataHeader::Input
@ Input
Definition: DataHeader.h:126
DataHeaderElement::m_clids
std::set< CLID > m_clids
set of unsigned long to store ClassID's for symlinked container.
Definition: DataHeader.h:109
DataHeaderElement::m_pClid
CLID m_pClid
primary ClassID.
Definition: DataHeader.h:107
skel.it
it
Definition: skel.GENtoEVGEN.py:396
Token::dbID
const Guid & dbID() const
Access database identifier.
Definition: Token.h:62
DataHeaderForm_p5
This class provides storage for the constant fields of the persistent DataHeader class.
Definition: DataHeader_p5.h:42
Guid::toString
const std::string toString() const
Automatic conversion to string representation.
Definition: Guid.cxx:58
DataHeaderCnv_p5::DataHeaderCnv_p5
DataHeaderCnv_p5()
Definition: DataHeaderCnv_p5.cxx:213
DataHeaderForm_p5::map
const std::vector< std::string > & map() const
Definition: DataHeader_p5.cxx:45
DataHeaderForm_p5::resize
void resize(unsigned int size)
Definition: DataHeader_p5.cxx:65
Token::classID
const Guid & classID() const
Access database identifier.
Definition: Token.h:71
DataHeaderElement::m_ownToken
bool m_ownToken
Definition: DataHeader.h:116
DataHeaderCnv_p5::~DataHeaderCnv_p5
~DataHeaderCnv_p5()
Definition: DataHeaderCnv_p5.cxx:214
DataHeaderElementCnv_p5::DataHeaderElementCnv_p5
DataHeaderElementCnv_p5()
Definition: DataHeaderCnv_p5.cxx:15
Token
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition: Token.h:21
DataHeaderElementCnv_p5::~DataHeaderElementCnv_p5
~DataHeaderElementCnv_p5()
Definition: DataHeaderCnv_p5.cxx:16
DataHeaderForm_p5::params
const std::vector< unsigned int > & params(unsigned int entry) const
Definition: DataHeader_p5.cxx:53
Token::OID_t
Definition: Token.h:24
Token::fromString
Token & fromString(const std::string &from)
Build from the string representation of a token.
Definition: Token.cxx:133
Token::setClassID
Token & setClassID(const Guid &cl_id)
Access database identifier.
Definition: Token.h:73
DataHeaderElement
This class provides a persistent form for the TransientAddress.
Definition: DataHeader.h:36
Token::technology
int technology() const
Access technology type.
Definition: Token.h:75
DataHeaderElement::m_alias
std::set< std::string > m_alias
set of StoreGate alias string.
Definition: DataHeader.h:113
DataHeader
This class provides the layout for summary information stored for data written to POOL.
Definition: DataHeader.h:124
lumiFormat.i
int i
Definition: lumiFormat.py:85
DataHeader_p5::m_dataHeader
std::vector< DataHeaderElement_p5 > m_dataHeader
Definition: DataHeader_p5.h:84
SG::sgkeyShort
constexpr uint32_t sgkeyShort(const sgkey_t k)
Convert a sgkey to the 32-bit form used for older data.
Definition: CxxUtils/CxxUtils/sgkey_t.h:85
DataHeaderForm_p5::size
unsigned int size() const
Definition: DataHeader_p5.cxx:61
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
Token::setDb
Token & setDb(const Guid &db)
Set database name.
Definition: Token.h:64
DataHeaderCnv_p5.h
This file contains the class definition for the DataHeaderCnv_p5 and DataHeaderElementCnv_p5 classes.
DataHeaderElement_p5::m_oid2
long long int m_oid2
Definition: DataHeader_p5.h:36
Token::setTechnology
Token & setTechnology(int t)
Set technology type.
Definition: Token.h:77
DataHeader.h
This file contains the class definition for the DataHeader and DataHeaderElement classes.
DataHeaderForm_p5::insertMap
void insertMap(const std::string &element)
Definition: DataHeader_p5.cxx:49
pool_uuid.guid
guid
Definition: pool_uuid.py:112
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
DataHeader::setStatus
void setStatus(statusFlag status)
Set StatusFlag enum for DataHeader.
Definition: DataHeader.cxx:235
DataHeader::m_dataHeader
std::vector< DataHeaderElement > m_dataHeader
vector with DataHeaderElement to "DataObject".
Definition: DataHeader.h:201
Token::setOid
Token & setOid(const OID_t &oid)
Set object identifier.
Definition: Token.h:83
DataHeaderElement_p5
This class provides a persistent representation for the DataHeaderElement class.
Definition: DataHeader_p5.h:21
DataHeaderElement::m_hashes
std::vector< sgkey_t > m_hashes
hash table for ElementLink host container keys.
Definition: DataHeader.h:118
get_generator_info.version
version
Definition: get_generator_info.py:33
Guid
This class provides a encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number).
Definition: Guid.h:20
sgkey_t.h
Define the type used for hashed StoreGate key+CLID pairs.
DataHeaderCnv_p5::persToTrans
void persToTrans(const DataHeader_p5 &pers, DataHeader &trans, const DataHeaderForm_p5 &dhForm) const
Definition: DataHeaderCnv_p5.cxx:216
DataHeaderForm_p5::insertParam
void insertParam(unsigned int param, unsigned int entry)
Definition: DataHeader_p5.cxx:57
DataHeader_p5
This class provides a persistent representation for the DataHeader class.
Definition: DataHeader_p5.h:67
Token::oid
const OID_t & oid() const
Access object identifier.
Definition: Token.h:79
DataHeaderElement::m_token
const Token * m_token
pointer to transient address
Definition: DataHeader.h:115
DataHeaderCnv_p5::m_elemCnv
DataHeaderElementCnv_p5 m_elemCnv
Definition: DataHeaderCnv_p5.h:65
DataHeaderElement::getToken
const Token * getToken() const
Definition: DataHeader.cxx:135
DataHeaderElementCnv_p5::persToTrans
void persToTrans(const DataHeaderElement_p5 &pers, DataHeaderElement &trans, const DataHeaderForm_p5 &form, unsigned int entry) const
Definition: DataHeaderCnv_p5.cxx:19
DataHeaderCnv_p5::transToPers
void transToPers(const DataHeader &trans, DataHeader_p5 &pers, DataHeaderForm_p5 &dhForm) const
Definition: DataHeaderCnv_p5.cxx:239
DataHeader::m_inputDataHeader
std::vector< DataHeaderElement > m_inputDataHeader
vector with DataHeaderElement to upstream DataHeader ("Provenance").
Definition: DataHeader.h:203
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37