ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
DataHeaderCnv_p6 Class Reference

This class provides the converter to customize the saving of DataHeader_p6. More...

#include <DataHeaderCnv_p6.h>

Collaboration diagram for DataHeaderCnv_p6:

Public Member Functions

 DataHeaderCnv_p6 ()
 
DataHeadercreateTransient (const DataHeader_p6 *persObj, const DataHeaderForm_p6 &form, const Token *dhToken)
 
DataHeader_p6createPersistent (const DataHeader *transObj, DataHeaderForm_p6 &form)
 
void elemToPers (const DataHeaderElement *trans, DataHeader_p6 *pers, DataHeaderForm_p6 &form)
 convert single DH element to persistent represenation More...
 
bool persToElem (const DataHeader_p6 *pers, unsigned p_idx, DataHeaderElement *trans, const DataHeaderForm_p6 &form)
 restore single DH element from persistent represenation return false if p_idx is out of bounds for the Form More...
 
void insertDHRef (DataHeader_p6 *pers_dh, const std::string &key, const std::string &dh_tokstr, DataHeaderForm_p6 &dh_form)
 insert DH self reference as one of the DHElements. Contains the stream Key More...
 
void setSGAliasFiltering (bool doFiltering)
 

Public Attributes

bool m_SGAliasFiltering { true }
 

Detailed Description

This class provides the converter to customize the saving of DataHeader_p6.

Definition at line 22 of file DataHeaderCnv_p6.h.

Constructor & Destructor Documentation

◆ DataHeaderCnv_p6()

DataHeaderCnv_p6::DataHeaderCnv_p6 ( )
inline

Definition at line 24 of file DataHeaderCnv_p6.h.

24 {}

Member Function Documentation

◆ createPersistent()

DataHeader_p6 * DataHeaderCnv_p6::createPersistent ( const DataHeader transObj,
DataHeaderForm_p6 form 
)

Definition at line 136 of file DataHeaderCnv_p6.cxx.

137 {
138  DataHeader_p6* pers = new DataHeader_p6();
139  const unsigned int provSize = trans->m_inputDataHeader.size();
140  pers->m_provenanceSize = provSize;
141 
142  pers->m_shortElements.reserve( provSize + trans->m_dataHeader.size() );
143  form.resize(provSize + trans->m_dataHeader.size() + 1);
144  for( const auto& transElem: trans->m_dataHeader ) {
145  elemToPers( &transElem, pers, form );
146  }
147  for( const auto& transElem: trans->m_inputDataHeader ) {
148  elemToPers( &transElem, pers, form );
149  }
150  return pers;
151 }

◆ createTransient()

DataHeader * DataHeaderCnv_p6::createTransient ( const DataHeader_p6 persObj,
const DataHeaderForm_p6 form,
const Token dhToken 
)

Definition at line 61 of file DataHeaderCnv_p6.cxx.

64 {
65  DataHeader* trans = new DataHeader();
66  const unsigned int provSize = pers->m_provenanceSize;
67  trans->m_inputDataHeader.resize(provSize);
68  // DataHeaders with a self Reference at the end have the list longer by 1 element
69  int hasSelfRefSizeCorrection = (form.version() == DataHeaderForm_p6::DHverFormRef? 1 : 0);
70  trans->m_dataHeader.resize( pers->m_shortElements.size() - hasSelfRefSizeCorrection - provSize );
71 
72  // convert all elements - transient vectors need to have the right sizes
73  unsigned i = 0;
74  for( auto& elem : trans->m_dataHeader ) {
75  persToElem( pers, i++, &elem, form );
76  }
77  for( auto& elem : trans->m_inputDataHeader ) {
78  persToElem( pers, i++, &elem, form );
79  }
80  // Add the self reference
81  trans->m_dataHeader.resize( trans->m_dataHeader.size() + 1 );
82  auto& elem = trans->m_dataHeader.back();
83  // convert the self ref that was stored at the end of the element list
84  persToElem( pers, i++, &elem, form );
85 
86  if( elem.getToken()->contID().find("DataHeader") == std::string::npos ) {
87  // discard wrong element
88  trans->m_dataHeader.pop_back();
89  }
91  trans->setEvtRefTokenStr( dhToken->toString() );
92  return trans;
93 }

◆ elemToPers()

void DataHeaderCnv_p6::elemToPers ( const DataHeaderElement trans,
DataHeader_p6 pers,
DataHeaderForm_p6 form 
)

convert single DH element to persistent represenation

Definition at line 97 of file DataHeaderCnv_p6.cxx.

100 {
101  // Translate PoolToken
102  const Token *token = trans->getToken();
103  if( !token ) {
104  // store marker for NO Token
105  pers->m_shortElements.push_back( INT32_MIN );
106  } else {
107  // Database GUID & Technology
108  DataHeaderForm_p6::DbRecord db_rec( token->dbID(), token->technology() );
109  unsigned db_idx = form.insertDb( db_rec );
110  // StoreGate Type/Key & persistent Class GUID
111  DataHeaderForm_p6::ObjRecord transObj( token->classID(), token->contID(), trans->m_key,
112  trans->m_pClid, token->oid().first );
113  unsigned obj_idx = form.insertObj(transObj, trans->m_alias, m_SGAliasFiltering,
114  trans->m_clids, trans->m_hashes);
115  unsigned long long oid2 = token->oid().second;
116 
117  // first element sets the common DB
118  if( pers->m_shortElements.empty() ) {
119  // first element - set the common DB and OID2 values
120  pers->m_commonDbIndex = db_idx;
121  pers->m_commonOID2 = oid2;
122  }
123  if( db_idx == pers->m_commonDbIndex && oid2 == pers->m_commonOID2 ) {
124  // Can use short DH element
125  pers->m_shortElements.push_back( obj_idx );
126  } else {
127  // need to use full DH element
128  // store the index (as negative) to the full element in the short vector
129  pers->m_shortElements.push_back( -1 - pers->m_fullElements.size() );
130  pers->m_fullElements.push_back( FullElement(oid2, db_idx, obj_idx) );
131  }
132  }
133 }

◆ insertDHRef()

void DataHeaderCnv_p6::insertDHRef ( DataHeader_p6 pers_dh,
const std::string &  key,
const std::string &  dh_tokstr,
DataHeaderForm_p6 dh_form 
)

insert DH self reference as one of the DHElements. Contains the stream Key

Definition at line 154 of file DataHeaderCnv_p6.cxx.

157 {
158  Token* token = new Token();
159  token->fromString( tokstr );
161  elemToPers( &tEle, pers, form );
162 }

◆ persToElem()

bool DataHeaderCnv_p6::persToElem ( const DataHeader_p6 pers,
unsigned  p_idx,
DataHeaderElement trans,
const DataHeaderForm_p6 form 
)

restore single DH element from persistent represenation return false if p_idx is out of bounds for the Form

Definition at line 18 of file DataHeaderCnv_p6.cxx.

20 {
21  delete trans->m_token; trans->m_token = nullptr;
22  int obj_idx = pers->m_shortElements[p_idx];
23  if( obj_idx == INT32_MIN ) return true;
24 
25  Token* token = new Token;
26  trans->m_token = token;
27  trans->m_ownToken = true;
28  unsigned db_idx = 0;
29  unsigned long long oid2 = 0;
30  if( obj_idx >= 0 ) {
31  db_idx = pers->m_commonDbIndex;
32  oid2 = pers->m_commonOID2;
33  } else {
34  const FullElement &full_el = pers->m_fullElements[ -1 - obj_idx ];
35  db_idx = full_el.dbIdx;
36  obj_idx = full_el.objIdx;
37  oid2 = full_el.oid2;
38  }
39 
40  if( form.sizeDb() > db_idx ) {
41  // Append DbGuid
42  token->setDb( form.getDbGuid( db_idx ) );
43  token->setTechnology( form.getDbTech( db_idx ) );
44  }
45  if( form.sizeObj() > (size_t)obj_idx ) {
46  token->setCont( form.getObjContainer( obj_idx ) );
47  // Append ClassId
48  token->setClassID( form.getObjClassId(obj_idx) );
49  token->setOid( Token::OID_t( form.getObjOid1(obj_idx), oid2) );
50  // StoreGate
51  trans->m_key = form.getObjKey( obj_idx );
52  trans->m_alias = form.getObjAlias( obj_idx );
53  trans->m_pClid = form.getObjType( obj_idx );
54  trans->m_clids = form.getObjSymLinks( obj_idx );
55  trans->m_hashes = form.getObjHashes( obj_idx );
56  }
57  return form.sizeDb() > db_idx and form.sizeObj() > (size_t)obj_idx;
58 }

◆ setSGAliasFiltering()

void DataHeaderCnv_p6::setSGAliasFiltering ( bool  doFiltering)
inline

Definition at line 41 of file DataHeaderCnv_p6.h.

41 { m_SGAliasFiltering = doFiltering; }

Member Data Documentation

◆ m_SGAliasFiltering

bool DataHeaderCnv_p6::m_SGAliasFiltering { true }

Definition at line 43 of file DataHeaderCnv_p6.h.


The documentation for this class was generated from the following files:
DataHeaderElement::m_key
std::string m_key
string with StoreGate key.
Definition: DataHeader.h:111
DataHeaderCnv_p6::elemToPers
void elemToPers(const DataHeaderElement *trans, DataHeader_p6 *pers, DataHeaderForm_p6 &form)
convert single DH element to persistent represenation
Definition: DataHeaderCnv_p6.cxx:97
Token::contID
const std::string & contID() const
Access container identifier.
Definition: Token.h:67
DataHeaderCnv_p6::m_SGAliasFiltering
bool m_SGAliasFiltering
Definition: DataHeaderCnv_p6.h:43
DataHeaderCnv_p6::persToElem
bool persToElem(const DataHeader_p6 *pers, unsigned p_idx, DataHeaderElement *trans, const DataHeaderForm_p6 &form)
restore single DH element from persistent represenation return false if p_idx is out of bounds for th...
Definition: DataHeaderCnv_p6.cxx:18
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
DataHeader_p6::FullElement
Definition: DataHeader_p6.h:120
DataHeaderElement::m_pClid
CLID m_pClid
primary ClassID.
Definition: DataHeader.h:107
DataHeaderForm_p6::DbRecord
Definition: DataHeader_p6.h:33
Token::dbID
const Guid & dbID() const
Access database identifier.
Definition: Token.h:62
DataHeaderForm_p6::version
unsigned version() const
Definition: DataHeader_p6.h:86
Token::classID
const Guid & classID() const
Access database identifier.
Definition: Token.h:71
DataHeader_p6::m_provenanceSize
unsigned int m_provenanceSize
Definition: DataHeader_p6.h:139
DataHeaderElement::m_ownToken
bool m_ownToken
Definition: DataHeader.h:116
DataHeader_p6::m_commonOID2
unsigned long long m_commonOID2
Definition: DataHeader_p6.h:135
DataHeader_p6::m_shortElements
std::vector< int > m_shortElements
Definition: DataHeader_p6.h:137
DataHeaderForm_p6::getObjOid1
long long getObjOid1(unsigned int index) const
Definition: DataHeader_p6.h:74
DataHeader_p6::m_fullElements
std::vector< FullElement > m_fullElements
Definition: DataHeader_p6.h:138
Token
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition: Token.h:21
DataHeader_p6::FullElement::dbIdx
unsigned int dbIdx
Definition: DataHeader_p6.h:124
DataHeaderForm_p6::DHverFormRef
@ DHverFormRef
Definition: DataHeader_p6.h:50
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
DataHeaderForm_p6::getObjType
unsigned int getObjType(unsigned int index) const
Definition: DataHeader_p6.cxx:114
DataHeaderElement
This class provides a persistent form for the TransientAddress.
Definition: DataHeader.h:36
DataHeaderForm_p6::getObjContainer
std::string getObjContainer(unsigned int index) const
Definition: DataHeader_p6.cxx:106
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
DataHeaderForm_p6::getObjClassId
Guid getObjClassId(unsigned int index) const
Definition: DataHeader_p6.cxx:118
DataHeaderForm_p6::getDbGuid
Guid getDbGuid(unsigned int index) const
Definition: DataHeader_p6.cxx:57
FullElement
DataHeader_p6::FullElement FullElement
Definition: DataHeaderCnv_p6.cxx:15
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
Token::setTechnology
Token & setTechnology(int t)
Set technology type.
Definition: Token.h:77
DataHeader_p6
This class provides a persistent representation for the DataHeader class.
Definition: DataHeader_p6.h:116
DataHeaderForm_p6::insertObj
unsigned int insertObj(const ObjRecord &rec, const std::set< std::string > &alias=std::set< std::string >(), bool doAliasFiletering=true, const std::set< unsigned int > &symLinks=std::set< unsigned int >(), const std::vector< sgkey_t > &hashes=std::vector< sgkey_t >())
Definition: DataHeader_p6.cxx:65
DataHeader_p6::FullElement::objIdx
unsigned int objIdx
Definition: DataHeader_p6.h:125
DataHeaderForm_p6::getObjSymLinks
std::set< unsigned int > getObjSymLinks(unsigned int index) const
Definition: DataHeader_p6.cxx:126
DataHeaderForm_p6::sizeDb
std::size_t sizeDb() const
Definition: DataHeader_p6.cxx:53
DataHeader::setStatus
void setStatus(statusFlag status)
Set StatusFlag enum for DataHeader.
Definition: DataHeader.cxx:235
DataHeaderForm_p6::getObjHashes
std::vector< sgkey_t > getObjHashes(unsigned int index) const
Definition: DataHeader_p6.cxx:131
Token::toString
virtual const std::string toString() const
Retrieve the string representation of the token.
Definition: Token.cxx:114
DataHeaderForm_p6::sizeObj
std::size_t sizeObj() const
Definition: DataHeader_p6.cxx:102
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::m_hashes
std::vector< sgkey_t > m_hashes
hash table for ElementLink host container keys.
Definition: DataHeader.h:118
DataHeaderForm_p6::resize
void resize(unsigned int size)
Definition: DataHeader_p6.cxx:152
DataHeaderForm_p6::getObjKey
std::string getObjKey(unsigned int index) const
Definition: DataHeader_p6.cxx:110
DataHeader_p6::FullElement::oid2
unsigned long long oid2
Definition: DataHeader_p6.h:123
Token::oid
const OID_t & oid() const
Access object identifier.
Definition: Token.h:79
DataHeader_p6::m_commonDbIndex
unsigned m_commonDbIndex
common DB entry index used by all short DH elements
Definition: DataHeader_p6.h:134
DataHeader::setEvtRefTokenStr
void setEvtRefTokenStr(const std::string &tokenStr)
Definition: DataHeader.cxx:316
Token::setCont
Token & setCont(const std::string &cnt)
Set container name.
Definition: Token.h:69
DataHeaderElement::m_token
const Token * m_token
pointer to transient address
Definition: DataHeader.h:115
DataHeaderForm_p6::getDbTech
unsigned int getDbTech(unsigned int index) const
Definition: DataHeader_p6.cxx:61
DataHeaderForm_p6::insertDb
unsigned int insertDb(const DbRecord &rec)
Definition: DataHeader_p6.cxx:40
DataHeaderElement::getToken
const Token * getToken() const
Definition: DataHeader.cxx:135
DataHeaderForm_p6::getObjAlias
std::set< std::string > getObjAlias(unsigned int index) const
Definition: DataHeader_p6.cxx:122
DataHeader::m_inputDataHeader
std::vector< DataHeaderElement > m_inputDataHeader
vector with DataHeaderElement to upstream DataHeader ("Provenance").
Definition: DataHeader.h:203
DataHeaderForm_p6::ObjRecord
Definition: DataHeader_p6.h:39
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37