ATLAS Offline Software
HepMcParticleLinkCnv_p3.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // Framework includes
8 #include "GaudiKernel/MsgStream.h"
9 #include "GaudiKernel/ThreadLocalContext.h"
11 
13 
14 
16  HepMcParticleLink* transObj,
17  MsgStream &/*msg*/ ) const
18 {
20 
21  if (persObj->m_mcEvtIndex == 0) {
23  }
24 
25  transObj->setExtendedBarCode
27  persObj->m_mcEvtIndex,
28  flag) );
29 }
30 
32  HepMcParticleLink_p3* persObj,
33  MsgStream &msg ) const
34 {
35  // In the case that the standard production workflow is being used
36  // then the first event in the McEventCollection is the only one
37  // where the eventIndex could exceed the maximum value of unsigned
38  // short. In this case we can work around the issue by using an
39  // m_mcEvtIndex of zero as a special case, in which m_mcEvtIndex
40  // should be interpreted as the position in the McEventCollection
41  // rather than the value of GenEvent::event_number().
42  const EventContext& ctx = Gaudi::Hive::currentContext();
43  const IProxyDict* proxy = Atlas::getExtendedEventContext(ctx).proxy();
44  unsigned short index{0};
45  const HepMcParticleLink::index_type position =
47  proxy).at(0);
48  if (position!=0) {
49  index = transObj->eventIndex();
50  if(transObj->eventIndex()!=static_cast<HepMcParticleLink::index_type>(index)) {
51  msg << MSG::WARNING << "Attempting to persistify an eventIndex larger than max unsigned short!" << endmsg;
52  }
53  }
54  persObj->m_mcEvtIndex = index;
55  persObj->m_id = transObj->id();
56  persObj->m_evtColl = 'a';
57 }
58 
HepMcParticleLinkCnv_p3.h
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
HepMcParticleLinkCnv_p3::persToTrans
virtual void persToTrans(const HepMcParticleLink_p3 *persObj, HepMcParticleLink *transObj, MsgStream &msg) const override
Method creating the transient representation of HepMcParticleLink from its persistent representation ...
Definition: HepMcParticleLinkCnv_p3.cxx:15
index
Definition: index.py:1
ExtendedEventContext.h
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:51
Atlas::getExtendedEventContext
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
Definition: ExtendedEventContext.cxx:32
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
master.flag
bool flag
Definition: master.py:29
HepMcParticleLinkCnv_p3::transToPers
virtual void transToPers(const HepMcParticleLink *transObj, HepMcParticleLink_p3 *persObj, MsgStream &msg) const override
Method creating the persistent representation HepMcParticleLink_p3 from its transient representation ...
Definition: HepMcParticleLinkCnv_p3.cxx:31
DeMoScan.index
string index
Definition: DeMoScan.py:362
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7