ATLAS Offline Software
HepMcParticleLinkCnv_p1.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // Framework includes
8 #include "GaudiKernel/MsgStream.h"
9 #include "GaudiKernel/ThreadLocalContext.h"
12 
13 // GeneratorObjectsAthenaPool includes
16 
20 
21 
22 // In the 21.0 branch an eventIndex of zero means that the transient
23 // HepMcParticleLink looks at the first event in the
24 // McEventCollection, otherwise the eventIndex represents the
25 // GenEvent::event_number of a GenEvent in the McEventCollection and
26 // this is used to find the appropriate GenEvent.
27 // NB There is a weakness here that if more than one GenEvent has
28 // the same event number all links will point to the first GenEvent
29 // which matches.
30 
32  HepMcParticleLink* transObj,
33  MsgStream &/*msg*/ ) const
34 {
36 
37  if (persObj->m_mcEvtIndex == 0) {
39  }
40 
41  transObj->setExtendedBarCode
43  persObj->m_mcEvtIndex,
44  flag, HepMcParticleLink::IS_BARCODE) ); // FIXME barcode-based
45 
46  if ( HepMC::BarcodeBased::is_truth_suppressed_pileup(static_cast<int>(persObj->m_barcode)) ) {
48  }
49 }
50 
52  HepMcParticleLink_p1* persObj,
53  MsgStream &msg ) const
54 {
55  // NB This method assumes that there all GenEvents are stored in a
56  // single McEventCollection, as running with split
57  // McEventCollections is not supported in 21.0.
58  const EventContext& ctx = Gaudi::Hive::currentContext();
59  const IProxyDict* proxy = Atlas::getExtendedEventContext(ctx).proxy();
60  unsigned short index{0};
61  const HepMcParticleLink::index_type position =
63  proxy).at(0);
64  if (position!=0) {
65  index = transObj->eventIndex();
66  if(transObj->eventIndex()!=static_cast<HepMcParticleLink::index_type>(index)) {
67  msg << MSG::WARNING << "Attempting to persistify an eventIndex larger than max unsigned short!" << endmsg;
68  }
69  }
70  persObj->m_mcEvtIndex = index;
71  if (transObj->getTruthSuppressionType() == EBC_PU_SUPPRESSED) {
73  }
74  else {
75  persObj->m_barcode = transObj->barcode(); // FIXME in the future the barcode will need to be generated here
76  }
77 }
78 
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:47
Atlas::getExtendedEventContext
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
Definition: ExtendedEventContext.cxx:32
HepMC::SUPPRESSED_PILEUP_BARCODE
constexpr int SUPPRESSED_PILEUP_BARCODE(std::numeric_limits< int32_t >::max())
This barcode is used by objects matched to particles from pile-up interactions in standard MC Product...
McEventCollection.h
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
master.flag
bool flag
Definition: master.py:29
HepMcParticleLinkCnv_p1.h
MagicNumbers.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:51
HepMC::BarcodeBased::is_truth_suppressed_pileup
bool is_truth_suppressed_pileup(const T &p)
Method to establish if a particle (or barcode) corresponds to truth-suppressed pile-up.
Definition: MagicNumbers.h:184
DeMoScan.index
string index
Definition: DeMoScan.py:364
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:31
EBC_PU_SUPPRESSED
@ EBC_PU_SUPPRESSED
Definition: MagicNumbers.h:29
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7