ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Generators
GeneratorObjectsTPCnv
src
HepMcParticleLinkCnv_p2.cxx
Go to the documentation of this file.
1
2
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"
10
#include "
AthenaKernel/ExtendedEventContext.h
"
11
#include "
TruthUtils/MagicNumbers.h
"
12
13
#include "
GeneratorObjectsTPCnv/HepMcParticleLinkCnv_p2.h
"
14
15
16
void
HepMcParticleLinkCnv_p2::persToTrans
(
const
HepMcParticleLink_p2
* persObj,
17
HepMcParticleLink
* transObj,
18
MsgStream &
/*msg*/
)
const
19
{
20
HepMcParticleLink::PositionFlag
flag =
HepMcParticleLink::IS_EVENTNUM
;
21
22
if
(persObj->
m_mcEvtIndex
== 0) {
23
flag =
HepMcParticleLink::IS_POSITION
;
24
}
25
26
transObj->
setExtendedBarCode
27
(
HepMcParticleLink::ExtendedBarCode
( persObj->
m_barcode
,
28
persObj->
m_mcEvtIndex
,
29
flag,
HepMcParticleLink::IS_BARCODE
) );
// FIXME barcode-based
30
31
if
(
HepMC::BarcodeBased::is_truth_suppressed_pileup
(
static_cast<
int
>
(persObj->
m_barcode
)) ) {
32
transObj->
setTruthSuppressionType
(
EBC_PU_SUPPRESSED
);
33
}
34
}
35
36
void
HepMcParticleLinkCnv_p2::transToPers
(
const
HepMcParticleLink
* transObj,
37
HepMcParticleLink_p2
* persObj,
38
MsgStream &
msg
)
const
39
{
40
// In the case that the standard production workflow is being used
41
// then the first event in the McEventCollection is the only one
42
// where the eventIndex could exceed the maximum value of unsigned
43
// short. In this case we can work around the issue by using an
44
// m_mcEvtIndex of zero as a special case, in which m_mcEvtIndex
45
// should be interpreted as the position in the McEventCollection
46
// rather than the value of GenEvent::event_number().
47
const
EventContext& ctx = Gaudi::Hive::currentContext();
48
const
IProxyDict
* proxy =
Atlas::getExtendedEventContext
(ctx).proxy();
49
unsigned
short
index
{0};
50
const
HepMcParticleLink::index_type
position =
51
HepMcParticleLink::getEventPositionInCollection
(transObj->
eventIndex
(),
52
proxy).at(0);
53
if
(position!=0) {
54
index
= transObj->
eventIndex
();
55
if
(transObj->
eventIndex
()!=
static_cast<
HepMcParticleLink::index_type
>
(
index
)) {
56
msg
<< MSG::WARNING <<
"Attempting to persistify an eventIndex larger than max unsigned short!"
<<
endmsg
;
57
}
58
}
59
persObj->
m_mcEvtIndex
=
index
;
60
if
(transObj->
getTruthSuppressionType
() ==
EBC_PU_SUPPRESSED
) {
61
persObj->
m_barcode
=
HepMC::SUPPRESSED_PILEUP_BARCODE
;
62
}
63
else
{
64
persObj->
m_barcode
= transObj->
barcode
();
// FIXME in the future the barcode will need to be generated here
65
}
66
persObj->
m_evtColl
=
'a'
;
// Hard-coding as this only ever had a single value in production
67
}
68
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ExtendedEventContext.h
HepMcParticleLinkCnv_p2.h
MagicNumbers.h
EBC_PU_SUPPRESSED
@ EBC_PU_SUPPRESSED
Definition
MagicNumbers.h:31
HepMcParticleLinkCnv_p2::persToTrans
virtual void persToTrans(const HepMcParticleLink_p2 *persObj, HepMcParticleLink *transObj, MsgStream &msg) const override
Method creating the transient representation of HepMcParticleLink from its persistent representation ...
Definition
HepMcParticleLinkCnv_p2.cxx:16
HepMcParticleLinkCnv_p2::transToPers
virtual void transToPers(const HepMcParticleLink *transObj, HepMcParticleLink_p2 *persObj, MsgStream &msg) const override
Method creating the persistent representation HepMcParticleLink_p2 from its transient representation ...
Definition
HepMcParticleLinkCnv_p2.cxx:36
HepMcParticleLink::ExtendedBarCode
Persistent representation of a link.
Definition
HepMcParticleLink.h:93
HepMcParticleLink_p2
Definition
HepMcParticleLink_p2.h:17
HepMcParticleLink_p2::m_barcode
unsigned long m_barcode
barcode of the HepMC::GenParticle we are pointing to.
Definition
HepMcParticleLink_p2.h:51
HepMcParticleLink_p2::m_evtColl
char m_evtColl
Definition
HepMcParticleLink_p2.h:54
HepMcParticleLink_p2::m_mcEvtIndex
unsigned short m_mcEvtIndex
name of the McEventCollection holding the HepMC::GenEvent which itself holds the HepMC::GenParticle w...
Definition
HepMcParticleLink_p2.h:48
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:475
HepMcParticleLink::index_type
uint32_t index_type
Definition
HepMcParticleLink.h:75
HepMcParticleLink::IS_BARCODE
@ IS_BARCODE
Definition
HepMcParticleLink.h:85
HepMcParticleLink::getEventPositionInCollection
static std::vector< index_type > getEventPositionInCollection(index_type index, const IProxyDict *sg)
Return a vector of the positions in the McEventCollection of the GenEvent(s) with a given event numbe...
Definition
HepMcParticleLink.cxx:412
HepMcParticleLink::eventIndex
index_type eventIndex() const
Return the event number of the referenced GenEvent.
Definition
HepMcParticleLink.cxx:337
HepMcParticleLink::barcode
int barcode() const
Return the barcode of the target particle.
Definition
HepMcParticleLink.cxx:310
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:47
Atlas::getExtendedEventContext
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
Definition
ExtendedEventContext.cxx:32
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
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0