ATLAS Offline Software
HepMcParticleLinkCnv_p1.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // Framework includes
8 #include "GaudiKernel/MsgStream.h"
9 #include "GaudiKernel/ThreadLocalContext.h"
11 
12 // GeneratorObjectsAthenaPool includes
15 
19 
20 
21 // In the 21.0 branch an eventIndex of zero means that the transient
22 // HepMcParticleLink looks at the first event in the
23 // McEventCollection, otherwise the eventIndex represents the
24 // GenEvent::event_number of a GenEvent in the McEventCollection and
25 // this is used to find the appropriate GenEvent.
26 // NB There is a weakness here that if more than one GenEvent has
27 // the same event number all links will point to the first GenEvent
28 // which matches.
29 
31  HepMcParticleLink* transObj,
32  MsgStream &/*msg*/ ) const
33 {
35 
36  if (persObj->m_mcEvtIndex == 0) {
38  }
39 
40  transObj->setExtendedBarCode
42  persObj->m_mcEvtIndex,
43  flag, HepMcParticleLink::IS_BARCODE) ); // FIXME barcode-based
44 }
45 
47  HepMcParticleLink_p1* persObj,
48  MsgStream &msg ) const
49 {
50  // NB This method assumes that there all GenEvents are stored in a
51  // single McEventCollection, as running with split
52  // McEventCollections is not supported in 21.0.
53  const EventContext& ctx = Gaudi::Hive::currentContext();
54  const IProxyDict* proxy = Atlas::getExtendedEventContext(ctx).proxy();
55  unsigned short index{0};
56  const HepMcParticleLink::index_type position =
58  proxy).at(0);
59  if (position!=0) {
60  index = transObj->eventIndex();
61  if(transObj->eventIndex()!=static_cast<HepMcParticleLink::index_type>(index)) {
62  msg << MSG::WARNING << "Attempting to persistify an eventIndex larger than max unsigned short!" << endmsg;
63  }
64  }
65  persObj->m_mcEvtIndex = index;
66  persObj->m_barcode = transObj->barcode();
67 }
68 
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
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
McEventCollection.h
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
master.flag
bool flag
Definition: master.py:29
HepMcParticleLinkCnv_p1.h
HepMcParticleLinkCnv_p1::transToPers
virtual void transToPers(const HepMcParticleLink *transObj, HepMcParticleLink_p1 *persObj, MsgStream &msg) const override
Method creating the persistent representation HepMcParticleLink_p1 from its transient representation ...
Definition: HepMcParticleLinkCnv_p1.cxx:46
DeMoScan.index
string index
Definition: DeMoScan.py:362
HepMcParticleLinkCnv_p1::persToTrans
virtual void persToTrans(const HepMcParticleLink_p1 *persObj, HepMcParticleLink *transObj, MsgStream &msg) const override
Method creating the transient representation of HepMcParticleLink from its persistent representation ...
Definition: HepMcParticleLinkCnv_p1.cxx:30
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7