ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Generators
GeneratorObjectsTPCnv
src
HepMcParticleLinkCnv_p1.cxx
Go to the documentation of this file.
1
2
3
/*
4
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
// Framework includes
8
#include "GaudiKernel/MsgStream.h"
9
#include "
AthenaKernel/proxyDictFromEventContext.h
"
10
#include "
TruthUtils/MagicNumbers.h
"
11
12
// GeneratorObjectsAthenaPool includes
13
#include "
GeneratorObjectsTPCnv/HepMcParticleLinkCnv_p1.h
"
14
#include "
GeneratorObjects/McEventCollection.h
"
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
30
void
HepMcParticleLinkCnv_p1::persToTrans
(
const
HepMcParticleLink_p1
* persObj,
31
HepMcParticleLink
* transObj,
32
MsgStream &
/*msg*/
)
const
33
{
34
HepMcParticleLink::PositionFlag
flag =
HepMcParticleLink::IS_EVENTNUM
;
35
36
if
(persObj->
m_mcEvtIndex
== 0) {
37
flag =
HepMcParticleLink::IS_POSITION
;
38
}
39
40
transObj->
setExtendedBarCode
41
(
HepMcParticleLink::ExtendedBarCode
( persObj->
m_barcode
,
42
persObj->
m_mcEvtIndex
,
43
flag,
HepMcParticleLink::IS_BARCODE
) );
// FIXME barcode-based
44
45
if
(
HepMC::BarcodeBased::is_truth_suppressed_pileup
(
static_cast<
int
>
(persObj->
m_barcode
)) ) {
46
transObj->
setTruthSuppressionType
(
EBC_PU_SUPPRESSED
);
47
}
48
}
49
50
void
HepMcParticleLinkCnv_p1::transToPers
(
const
HepMcParticleLink
* transObj,
51
HepMcParticleLink_p1
* persObj,
52
MsgStream &
msg
)
const
53
{
54
// NB This method assumes that there all GenEvents are stored in a
55
// single McEventCollection, as running with split
56
// McEventCollections is not supported in 21.0.
57
IProxyDict
* proxy =
Atlas::proxyDictFromEventContext
();
58
unsigned
short
index
{0};
59
const
HepMcParticleLink::index_type
position =
60
HepMcParticleLink::getEventPositionInCollection
(transObj->
eventIndex
(),
61
proxy).at(0);
62
if
(position!=0) {
63
index
= transObj->
eventIndex
();
64
if
(transObj->
eventIndex
()!=
static_cast<
HepMcParticleLink::index_type
>
(
index
)) {
65
msg
<< MSG::WARNING <<
"Attempting to persistify an eventIndex larger than max unsigned short!"
<<
endmsg
;
66
}
67
}
68
persObj->
m_mcEvtIndex
=
index
;
69
if
(transObj->
getTruthSuppressionType
() ==
EBC_PU_SUPPRESSED
) {
70
persObj->
m_barcode
=
HepMC::SUPPRESSED_PILEUP_BARCODE
;
71
}
72
else
{
73
persObj->
m_barcode
= transObj->
barcode
();
// FIXME in the future the barcode will need to be generated here
74
}
75
}
76
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
HepMcParticleLinkCnv_p1.h
MagicNumbers.h
EBC_PU_SUPPRESSED
@ EBC_PU_SUPPRESSED
Definition
MagicNumbers.h:31
McEventCollection.h
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
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:50
HepMcParticleLink::ExtendedBarCode
Persistent representation of a link.
Definition
HepMcParticleLink.h:93
HepMcParticleLink_p1
Definition
HepMcParticleLink_p1.h:21
HepMcParticleLink_p1::m_mcEvtIndex
unsigned short m_mcEvtIndex
name of the McEventCollection holding the HepMC::GenEvent which itself holds the HepMC::GenParticle w...
Definition
HepMcParticleLink_p1.h:51
HepMcParticleLink_p1::m_barcode
unsigned long m_barcode
barcode of the HepMC::GenParticle we are pointing to.
Definition
HepMcParticleLink_p1.h:54
HepMcParticleLink
a link optimized in size for a GenParticle in a McEventCollection
Definition
HepMcParticleLink.h:72
HepMcParticleLink::PositionFlag
PositionFlag
Definition
HepMcParticleLink.h:78
HepMcParticleLink::IS_POSITION
@ IS_POSITION
Definition
HepMcParticleLink.h:80
HepMcParticleLink::IS_EVENTNUM
@ IS_EVENTNUM
Definition
HepMcParticleLink.h:79
HepMcParticleLink::getTruthSuppressionType
EBC_SUPPRESSED_TRUTH getTruthSuppressionType() const
Return whether the truth particle has been suppressed, as an enum.
HepMcParticleLink::setExtendedBarCode
void setExtendedBarCode(const ExtendedBarCode &extBarcode)
Alter the persistent part of the link.
Definition
HepMcParticleLink.cxx:499
HepMcParticleLink::index_type
uint32_t index_type
Definition
HepMcParticleLink.h:75
HepMcParticleLink::IS_BARCODE
@ IS_BARCODE
Definition
HepMcParticleLink.h:85
HepMcParticleLink::eventIndex
index_type eventIndex() const
Return the event number of the referenced GenEvent.
Definition
HepMcParticleLink.cxx:338
HepMcParticleLink::barcode
int barcode() const
Return the barcode of the target particle.
Definition
HepMcParticleLink.cxx:311
HepMcParticleLink::getEventPositionInCollection
static std::vector< index_type > getEventPositionInCollection(index_type index, IProxyDict *sg)
Return a vector of the positions in the McEventCollection of the GenEvent(s) with a given event numbe...
Definition
HepMcParticleLink.cxx:426
HepMcParticleLink::setTruthSuppressionType
void setTruthSuppressionType(EBC_SUPPRESSED_TRUTH truthSupp)
Return whether the truth particle has been suppressed.
IProxyDict
A proxy dictionary.
Definition
AthenaKernel/AthenaKernel/IProxyDict.h:48
Atlas::proxyDictFromEventContext
IProxyDict * proxyDictFromEventContext()
Return the IProxyDict for this thread's current context.
Definition
proxyDictFromEventContext.cxx:28
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:164
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...
index
Definition
index.py:1
proxyDictFromEventContext.h
Some out-of-line helpers for ExtendedEventContext.
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0