ATLAS Offline Software
DataHeader.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
12 
14 #include "SGTools/DataProxy.h"
16 
17 //______________________________________________________________________________
18 DataHeaderElement::DataHeaderElement() : m_pClid(0), m_clids(), m_key(), m_alias(), m_token(0), m_ownToken(false), m_hashes() {
19 }
20 //______________________________________________________________________________
21 DataHeaderElement::DataHeaderElement(const DataHeaderElement& rhs) : m_pClid(rhs.m_pClid),
22  m_clids(rhs.m_clids),
23  m_key(rhs.m_key),
24  m_alias(rhs.m_alias),
25  m_token(0),
26  m_ownToken(false),
27  m_hashes(rhs.m_hashes) {
28  if (rhs.getToken() != 0) {
29  m_token = new Token(rhs.getToken()); m_ownToken = true;
30  }
31 }
32 //______________________________________________________________________________
33 DataHeaderElement::DataHeaderElement(const SG::TransientAddress* sgAddress, IOpaqueAddress* tokAddress,
34  const std::string& pTag)
35  : DataHeaderElement (sgAddress->clID(),
36  sgAddress->name(),
37  sgAddress->transientID(),
38  SG::DataProxy::AliasCont_t (sgAddress->alias()),
39  sgAddress->address(),
40  tokAddress, pTag)
41 {
42 }
43 //______________________________________________________________________________
44 DataHeaderElement::DataHeaderElement(const SG::DataProxy* proxy, IOpaqueAddress* tokAddress,
45  const std::string& pTag)
46  : DataHeaderElement (proxy->clID(),
47  proxy->name(),
48  proxy->transientID(),
49  proxy->alias(),
50  proxy->address(),
51  tokAddress, pTag)
52 {
53 }
54 //______________________________________________________________________________
56  const std::string& name,
57  const std::vector<CLID>& tClids,
58  std::set<std::string>&& alias,
59  IOpaqueAddress* tadAddress,
60  IOpaqueAddress* tokAddress,
61  const std::string& pTag)
62  : m_pClid(clid),
63  m_clids(tClids.begin(), tClids.end()),
64  m_key((pTag.empty()) ? name : pTag),
65  m_alias(std::move(alias)),
66  m_token(0), m_ownToken(false), m_hashes()
67 {
68  m_clids.erase(m_pClid);
69  TokenAddress* tokAddr = dynamic_cast<TokenAddress*>(tokAddress);
70  if (tokAddr != 0 && tokAddr->getToken() != 0) {
71  m_token = new Token(tokAddr->getToken()); m_ownToken = true;
72  } else {
73  tokAddr = dynamic_cast<TokenAddress*>(tadAddress);
74  if (tokAddr != 0 && tokAddr->getToken() != 0) {
75  m_token = tokAddr->getToken();
76  } else if (tokAddress != 0) {
77  Token* token = new Token;
78  m_token = token; m_ownToken = true;
79  token->fromString(*(tokAddress->par()));
80  } else if (tadAddress != 0) {
81  Token* token = new Token;
82  m_token = token; m_ownToken = true;
83  token->fromString(*(tadAddress->par()));
84  }
85  }
86 }
87 //______________________________________________________________________________
89  const std::string& key, const Token* token)
90  : m_pClid(classID), m_clids(), m_key(key), m_alias(), m_token(token), m_ownToken(true), m_hashes() {
91 }
92 //______________________________________________________________________________
94  if (m_ownToken) { delete m_token; m_token = 0; }
95 }
96 //______________________________________________________________________________
98  if (this != &rhs) {
99  m_pClid = rhs.m_pClid;
100  m_clids = rhs.m_clids;
101  m_key = rhs.m_key;
102  m_alias = rhs.m_alias;
103  if (m_ownToken) { delete m_token; m_token = 0; m_ownToken = false; }
104  if (rhs.getToken() != 0) {
105  Token* newtok = new Token;
106  m_token = newtok; m_ownToken = true;
107  rhs.getToken()->setData(newtok);
108  }
109  m_hashes = rhs.m_hashes;
110  }
111  return(*this);
112 }
113 //______________________________________________________________________________
115  if (m_pClid > 0) {
116  return(m_pClid);
117  }
118  return(*(m_clids.begin()));
119 }
120 //______________________________________________________________________________
121 const std::set<CLID> DataHeaderElement::getClassIDs() const {
122  std::set<CLID> allClids (m_clids);
123  allClids.insert(m_pClid);
124  return(allClids);
125 }
126 //______________________________________________________________________________
127 const std::string& DataHeaderElement::getKey() const {
128  return(m_key);
129 }
130 //______________________________________________________________________________
131 const std::set<std::string>& DataHeaderElement::getAlias() const {
132  return(m_alias);
133 }
134 //_____________________________________________________________________________
136  return(m_token);
137 }
138 //_____________________________________________________________________________
140  return(POOL_StorageType);
141 }
142 //_____________________________________________________________________________
143 const std::vector<DataHeaderElement::sgkey_t>&
145  return(m_hashes);
146 }
147 //______________________________________________________________________________
149  if (!m_hashes.empty()) {
150  return;
151  }
152  std::set<CLID> clids = getClassIDs();
153  for (std::set<CLID>::iterator iter = clids.begin(), last = clids.end(); iter != last; ++iter) {
154  m_hashes.push_back(pool->stringToKey(m_key, *iter));
155  }
156 }
157 //______________________________________________________________________________
158 SG::TransientAddress* DataHeaderElement::getAddress(unsigned long contextId) const {
159  return(getAddress(m_key, contextId));
160 }
161 //______________________________________________________________________________
163  unsigned long contextId) const {
164  CLID primaryClID = getPrimaryClassID();
165  Token* token = new Token(m_token);
166  TokenAddress* tokAdd = new TokenAddress(this->getStorageType(), primaryClID, "", m_key, contextId , token);
167  SG::TransientAddress* sgAddress = new SG::TransientAddress(primaryClID, key, tokAdd);
168  for (std::set<CLID>::const_iterator iter = m_clids.begin(), last = m_clids.end();
169  iter != last; ++iter) {
170  sgAddress->setTransientID(*iter);
171  }
172  sgAddress->setAlias(m_alias);
173  return(sgAddress);
174 }
175 //______________________________________________________________________________
176 void DataHeaderElement::dump(std::ostream& ostr) const
177 {
178  using namespace std;
179  ostr << "SGKey: " << getKey() << endl;
180  ostr << "CLID: " << getPrimaryClassID();
181  if( getClassIDs().size() > 1 ) {
182  ostr << " ||";
183  for( auto& c : getClassIDs() ) ostr << " " << c;
184  }
185  ostr << std::endl;
186  if( getAlias().size() > 0 ) {
187  ostr << "Alias: ";
188  for( auto& a : getAlias() ) ostr << " " << a;
189  ostr << endl;
190  }
191  if( m_token ) {
192  ostr << "Token: " << m_token->toString();
193  if( m_ownToken ) ostr << " owned";
194  ostr << endl;
195  }
196  if( m_hashes.size() ) {
197  ostr << "Hashes:";
198  for( auto h : m_hashes ) ostr << " " << h;
199  ostr << endl;
200  }
201 }
202 
203 //______________________________________________________________________________
204 //______________________________________________________________________________
205 DataHeader::DataHeader() : m_dataHeader(),
206  m_inputDataHeader(),
207  m_status(statusFlag(Other)),
208  m_processTag(),
209  m_attrList(0),
210  m_evtRefTokenStr() {
211 }
212 //______________________________________________________________________________
213 DataHeader::DataHeader(const DataHeader& rhs) : m_dataHeader(rhs.m_dataHeader),
214  m_inputDataHeader(rhs.m_inputDataHeader),
215  m_status(rhs.m_status),
216  m_processTag(rhs.m_processTag),
217  m_attrList(rhs.m_attrList),
218  m_evtRefTokenStr() {
219 }
220 //______________________________________________________________________________
222 }
223 //______________________________________________________________________________
225  if (this != &rhs) {
228  m_status = rhs.m_status;
230  m_attrList = rhs.m_attrList;
231  }
232  return(*this);
233 }
234 //______________________________________________________________________________
236  m_status = status;
237 }
238 //______________________________________________________________________________
239 bool DataHeader::isInput() const {
240  return(m_status == statusFlag(Input));
241 }
242 //______________________________________________________________________________
243 void DataHeader::setProcessTag(const std::string& processTag) {
244  m_processTag = processTag;
245 }
246 //______________________________________________________________________________
247 const std::string& DataHeader::getProcessTag() const {
248  return(m_processTag);
249 }
250 //______________________________________________________________________________
251 int DataHeader::size() const {
252  return(m_dataHeader.size());
253 }
254 //______________________________________________________________________________
255 std::vector<DataHeaderElement>::const_iterator DataHeader::begin() const {
256  return(m_dataHeader.begin());
257 }
258 //______________________________________________________________________________
259 std::vector<DataHeaderElement>::const_iterator DataHeader::end() const {
260  return(m_dataHeader.end());
261 }
262 //______________________________________________________________________________
263 const std::vector<DataHeaderElement>& DataHeader::elements() const {
264  return m_dataHeader;
265 }
266 //______________________________________________________________________________
267 void DataHeader::insert(const SG::TransientAddress* sgAddress, IOpaqueAddress* tokAddress, const std::string& pTag) {
268  if (sgAddress != 0) {
269  m_dataHeader.emplace_back(sgAddress, tokAddress, pTag);
270  }
271 }
272 //______________________________________________________________________________
273 void DataHeader::insert(const SG::DataProxy* proxy, IOpaqueAddress* tokAddress, const std::string& pTag) {
274  m_dataHeader.emplace_back(proxy, tokAddress, pTag);
275 }
276 //______________________________________________________________________________
278  m_dataHeader.push_back(dhe);
279 }
280 //______________________________________________________________________________
282  return(m_inputDataHeader.size());
283 }
284 //______________________________________________________________________________
285 std::vector<DataHeaderElement>::const_iterator DataHeader::beginProvenance() const {
286  return(m_inputDataHeader.begin());
287 }
288 //______________________________________________________________________________
289 std::vector<DataHeaderElement>::const_iterator DataHeader::endProvenance() const {
290  return(m_inputDataHeader.end());
291 }
292 //______________________________________________________________________________
294  m_inputDataHeader.push_back(dhe);
295 }
296 //______________________________________________________________________________
299  last = m_dataHeader.end(); iter != last; ++iter) {
300  iter->addHash(pool);
301  }
303  last = m_inputDataHeader.end(); iter != last; ++iter) {
304  iter->addHash(pool);
305  }
306 }
307 //______________________________________________________________________________
309  m_attrList = attrList;
310 }
311 //______________________________________________________________________________
313  return(m_attrList);
314 }
315 //______________________________________________________________________________
316 void DataHeader::setEvtRefTokenStr(const std::string& tokenStr) {
317  m_evtRefTokenStr = tokenStr;
318 }
319 //______________________________________________________________________________
320 const std::string& DataHeader::getEvtRefTokenStr() {
321  return(m_evtRefTokenStr);
322 }
323 //______________________________________________________________________________
324 #include "CoralBase/AttributeList.h"
325 #include "CoralBase/Attribute.h"
326 
327 void DataHeader::dump(std::ostream& ostr) const
328 {
329  using namespace std;
330  ostr << "--- DataHeader Dump ---" << endl;
331  for( auto& el : m_dataHeader ) {
332  el.dump(ostr);
333  }
334  for( auto& el : m_inputDataHeader ) {
335  el.dump(ostr);
336  }
337  ostr << "Status: " << m_status << endl;
338  ostr << "Proc tag: " << m_processTag << endl;
339  ostr << "evtRef: " << m_evtRefTokenStr << endl;
340  ostr << "attrListPtr: " << m_attrList << endl;
341  if( m_attrList ) ostr << "attrListSize: " << m_attrList->size() << endl;
342  ostr << "--- DataHeader End ---" << endl;
343 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
DataHeader::isInput
bool isInput() const
Check whether StatusFlag is "Input".
Definition: DataHeader.cxx:239
DataHeader::setProcessTag
void setProcessTag(const std::string &processTag)
Set ProcessTag for DataHeader.
Definition: DataHeader.cxx:243
IStringPool
Abstract interface for looking up strings/CLIDs in a pool.
Definition: IStringPool.h:28
DataHeader::endProvenance
std::vector< DataHeaderElement >::const_iterator endProvenance() const
Definition: DataHeader.cxx:289
DataHeaderElement::m_key
std::string m_key
string with StoreGate key.
Definition: DataHeader.h:111
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
DataHeaderElement::getAlias
const std::set< std::string > & getAlias() const
Definition: DataHeader.cxx:131
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
DataHeader::m_attrList
const coral::AttributeList * m_attrList
Optional pointer to AttributeList to enable writing of TAG Attributes to Payload files.
Definition: DataHeader.h:209
DataHeader::DataHeader
DataHeader()
Default Constructor.
Definition: DataHeader.cxx:205
DataHeaderElement::m_clids
std::set< CLID > m_clids
set of unsigned long to store ClassID's for symlinked container.
Definition: DataHeader.h:109
OfflineHitType::Other
@ Other
DataHeader::operator=
DataHeader & operator=(const DataHeader &rhs)
Assignment Operator.
Definition: DataHeader.cxx:224
DataHeader::dump
void dump(std::ostream &ostr) const
Definition: DataHeader.cxx:327
DataHeader::setAttributeList
void setAttributeList(const coral::AttributeList *attrList)
Definition: DataHeader.cxx:308
DataHeaderElement::m_pClid
CLID m_pClid
primary ClassID.
Definition: DataHeader.h:107
DataHeader::addHash
void addHash(IStringPool *pool)
Add new entry to hash map.
Definition: DataHeader.cxx:297
pool
pool namespace
Definition: libname.h:15
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
SG::TransientAddress::setAlias
void setAlias(const std::string &key)
set alias'
Definition: TransientAddress.h:251
DataHeader::elements
const std::vector< DataHeaderElement > & elements() const
Definition: DataHeader.cxx:263
SG::TransientAddress
Definition: TransientAddress.h:32
DataHeader::begin
std::vector< DataHeaderElement >::const_iterator begin() const
Definition: DataHeader.cxx:255
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
DataHeaderElement::m_ownToken
bool m_ownToken
Definition: DataHeader.h:116
DataHeader::statusFlag
statusFlag
Definition: DataHeader.h:126
DataHeader::insertProvenance
void insertProvenance(const DataHeaderElement &dhe)
Insert a new element into the "Provenance" vector.
Definition: DataHeader.cxx:293
empty
bool empty(TH1 *h)
Definition: computils.cxx:295
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
Token
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition: Token.h:21
TokenAddress
This class provides a Generic Transient Address for POOL tokens.
Definition: TokenAddress.h:21
DataHeaderElement::operator=
DataHeaderElement & operator=(const DataHeaderElement &rhs)
Assignment Operator.
Definition: DataHeader.cxx:97
DataHeaderElement::getKey
const std::string & getKey() const
Definition: DataHeader.cxx:127
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
Token::fromString
Token & fromString(const std::string &from)
Build from the string representation of a token.
Definition: Token.cxx:133
DataHeaderElement
This class provides a persistent form for the TransientAddress.
Definition: DataHeader.h:36
DataHeader::beginProvenance
std::vector< DataHeaderElement >::const_iterator beginProvenance() const
Definition: DataHeader.cxx:285
DataHeaderElement::m_alias
std::set< std::string > m_alias
set of StoreGate alias string.
Definition: DataHeader.h:113
IStringPool.h
Abstract interface for looking up strings/CLIDs in a pool.
DataHeaderElement::~DataHeaderElement
virtual ~DataHeaderElement()
Destructor.
Definition: DataHeader.cxx:93
DataHeader
This class provides the layout for summary information stored for data written to POOL.
Definition: DataHeader.h:124
DataHeader::size
int size() const
Definition: DataHeader.cxx:251
h
extractSporadic.h
list h
Definition: extractSporadic.py:97
COOLRates.alias
alias
Definition: COOLRates.py:1172
DataHeader::sizeProvenance
int sizeProvenance() const
Definition: DataHeader.cxx:281
DataHeaderElement::DataHeaderElement
DataHeaderElement()
Default Constructor.
Definition: DataHeader.cxx:18
DataProxy
DataProxy provides the registry services for StoreGate.
Definition: DataProxy.h:32
DataHeaderElement::dump
void dump(std::ostream &ostr) const
Definition: DataHeader.cxx:176
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
jobOptions.pTag
string pTag
Definition: jobOptions.py:28
DataHeader.h
This file contains the class definition for the DataHeader and DataHeaderElement classes.
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
DataHeaderElement::getHashes
const std::vector< sgkey_t > & getHashes() const
Definition: DataHeader.cxx:144
DataHeader::insert
void insert(const SG::TransientAddress *sgAddress, IOpaqueAddress *tokAddress=0, const std::string &pTag="")
Insert a new element into the "DataObject" vector.
Definition: DataHeader.cxx:267
DataHeader::setStatus
void setStatus(statusFlag status)
Set StatusFlag enum for DataHeader.
Definition: DataHeader.cxx:235
DataHeaderElement::getClassIDs
const std::set< CLID > getClassIDs() const
Definition: DataHeader.cxx:121
DataHeader::m_status
statusFlag m_status
StatusFlag (i.e.: Output, Primary, Input, Manual, Other).
Definition: DataHeader.h:205
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
DataHeader::end
std::vector< DataHeaderElement >::const_iterator end() const
Definition: DataHeader.cxx:259
DataHeaderElement::addHash
void addHash(IStringPool *pool)
Add new entry to hash map.
Definition: DataHeader.cxx:148
DataHeaderElement::getPrimaryClassID
CLID getPrimaryClassID() const
Definition: DataHeader.cxx:114
Token::toString
virtual const std::string toString() const
Retrieve the string representation of the token.
Definition: Token.cxx:114
SG::TransientAddress::setTransientID
void setTransientID(CLID id)
get transient CLID's
Definition: TransientAddress.cxx:142
DataHeader::m_dataHeader
std::vector< DataHeaderElement > m_dataHeader
vector with DataHeaderElement to "DataObject".
Definition: DataHeader.h:201
DataHeader::getEvtRefTokenStr
const std::string & getEvtRefTokenStr()
Definition: DataHeader.cxx:320
RTTAlgmain.address
address
Definition: RTTAlgmain.py:55
DataHeaderElement::getStorageType
long getStorageType() const
Definition: DataHeader.cxx:139
DataHeaderElement::m_hashes
std::vector< sgkey_t > m_hashes
hash table for ElementLink host container keys.
Definition: DataHeader.h:118
DataHeaderElement::getAddress
SG::TransientAddress * getAddress(unsigned long contextId=0) const
Definition: DataHeader.cxx:158
TokenAddress.h
This file contains the class definition for the TokenAddress class.
DataHeader::~DataHeader
virtual ~DataHeader()
Destructor.
Definition: DataHeader.cxx:221
DataHeader::getAttributeList
const coral::AttributeList * getAttributeList()
Definition: DataHeader.cxx:312
a
TList * a
Definition: liststreamerinfos.cxx:10
DataHeader::getProcessTag
const std::string & getProcessTag() const
Definition: DataHeader.cxx:247
TransientAddress.h
TokenAddress::getToken
Token * getToken()
Definition: TokenAddress.h:48
DataHeader::setEvtRefTokenStr
void setEvtRefTokenStr(const std::string &tokenStr)
Definition: DataHeader.cxx:316
DataHeader::m_processTag
std::string m_processTag
ProcessTag (e.g.: "StreamESD", "StreamAOD" ...).
Definition: DataHeader.h:207
merge.status
status
Definition: merge.py:17
DataHeaderElement::m_token
const Token * m_token
pointer to transient address
Definition: DataHeader.h:115
NswErrorCalibData::Input
Helper struct to be parsed to the object to derive the specific error of the cluster.
Definition: NswErrorCalibData.h:25
Token::setData
const Token & setData(Token *pToken) const
Set all the data part of the token.
Definition: Token.cxx:194
DataHeaderElement::getToken
const Token * getToken() const
Definition: DataHeader.cxx:135
SG::DataProxy
Definition: DataProxy.h:45
python.compressB64.c
def c
Definition: compressB64.py:93
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
DataHeader::m_evtRefTokenStr
std::string m_evtRefTokenStr
Optional Token String for Event Reference to enable writing of TAG to Payload files.
Definition: DataHeader.h:211
DataProxy.h