ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::BkgElectronClassification Class Reference

#include <BkgElectronClassification.h>

Inheritance diagram for DerivationFramework::BkgElectronClassification:
Collaboration diagram for DerivationFramework::BkgElectronClassification:

Public Member Functions

virtual StatusCode initialize () override final
virtual StatusCode addBranches (const EventContext &ctx) const override final

Private Attributes

ToolHandle< IMCTruthClassifier > m_mcTruthClassifier
 MCTruthClassifier.
SG::ReadHandleKey< xAOD::ElectronContainer > m_electronContainer
 input electron container
SG::ReadDecorHandleKey< xAOD::ElectronContainer > m_electronTruthParticleLink
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthContainer
 Input truth particle container.
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_truthPdgId { this, "DoNotSet_truthPdgId", m_electronContainer, "truthPdgId", "" }
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_firstEgMotherTruthType { this, "firstEgMotherTruthType", m_electronContainer, "firstEgMotherTruthType", "" }
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_firstEgMotherTruthOrigin { this, "firstEgMotherTruthOrigin", m_electronContainer, "firstEgMotherTruthOrigin", "" }
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_firstEgMotherTruthClassification
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_firstEgMotherTruthParticleLink
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_firstEgMotherPdgId { this, "firstEgMotherPdgId", m_electronContainer, "firstEgMotherPdgId", "" }
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_lastEgMotherTruthType { this, "lastEgMotherTruthType", m_electronContainer, "lastEgMotherTruthType", "" }
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_lastEgMotherTruthOrigin { this, "lastEgMotherTruthOrigin", m_electronContainer, "lastEgMotherTruthOrigin", "" }
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_lastEgMotherTruthClassification
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_lastEgMotherTruthParticleLink
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_lastEgMotherPdgId { this, "lastEgMotherPdgId", m_electronContainer, "lastEgMotherPdgId", "" }

Detailed Description

Definition at line 23 of file BkgElectronClassification.h.

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::BkgElectronClassification::addBranches ( const EventContext & ctx) const
finaloverridevirtual

Definition at line 48 of file BkgElectronClassification.cxx.

49{
50
51 SG::ReadHandle<xAOD::ElectronContainer> electrons{ m_electronContainer, ctx };
52 SG::ReadHandle<xAOD::TruthParticleContainer> truthContainer{ m_truthContainer,
53 ctx };
54
55 // Access for the pre-existing decoration
56 SG::ReadDecorHandle<xAOD::ElectronContainer,
57 ElementLink<xAOD::TruthParticleContainer>>
59
60 // pdg iD
61 SG::WriteDecorHandle<xAOD::ElectronContainer, int> tPdgID(m_truthPdgId, ctx);
62 // first mother decorations
63 SG::WriteDecorHandle<xAOD::ElectronContainer, int> firstEgMotherTT(
65 SG::WriteDecorHandle<xAOD::ElectronContainer, int> firstEgMotherTO(
67 SG::WriteDecorHandle<xAOD::ElectronContainer, unsigned int> firstEgMotherTC(
69 SG::WriteDecorHandle<xAOD::ElectronContainer, int> firstEgMotherPdgID(
71 SG::WriteDecorHandle<xAOD::ElectronContainer,
72 ElementLink<xAOD::TruthParticleContainer>>
73 firstEgMotherTPL(m_firstEgMotherTruthParticleLink, ctx);
74
75 // last mother decorations
76 SG::WriteDecorHandle<xAOD::ElectronContainer, int> lastEgMotherTT(
78 SG::WriteDecorHandle<xAOD::ElectronContainer, int> lastEgMotherTO(
80 SG::WriteDecorHandle<xAOD::ElectronContainer, unsigned int> lastEgMotherTC(
82 SG::WriteDecorHandle<xAOD::ElectronContainer, int> lastEgMotherPdgID(
84 SG::WriteDecorHandle<xAOD::ElectronContainer,
85 ElementLink<xAOD::TruthParticleContainer>>
86 lastEgMotherTPL(m_lastEgMotherTruthParticleLink, ctx);
87 //
88
89 for (const xAOD::Electron* el : *electrons) {
90 tPdgID(*el) = 0;
91 if (tPL.isPresent() && tPL(*el).isValid()) {
92 const xAOD::TruthParticle* truthEl = *tPL(*el);
93 tPdgID(*el) = truthEl->pdgId();
94 // Parents can be removed by truth thinning in e.g cases of Geant4 produced LRT electrons
95 // throw a warning in these cases so this is transparent
96 if (MC::isElectron(truthEl)) {
97 for (size_t p = 0; p < truthEl->nParents(); ++p) {
98 if (!truthEl->parent(p)) {
99 ATH_MSG_WARNING("Unresolvable truth parent link (ancestry removed by "
100 << "truth thinning) for truth electron with pt "
101 << truthEl->pt() << " MeV");
102 break;
103 }
104 }
105 }
106 }
107 // Use the Helpers for electron from electron or photon
108 // Add Extra Decoration from Egamma helpers in case of BkgElectron (Electron
109 // coming for a photon) Go back to the first/last electron/photon Generator
110 // mother and classify this one
111 // First the one entering the Geant4, the first we meet on the way back
112 firstEgMotherTT(*el) = 0;
113 firstEgMotherTO(*el) = 0;
114 firstEgMotherTC(*el) = 0;
115 firstEgMotherTPL(*el) = ElementLink<xAOD::TruthParticleContainer>();
116 firstEgMotherPdgID(*el) = 0;
117 const xAOD::TruthParticle* firstElTruth =
119
120 if (firstElTruth) {
121 auto res = m_mcTruthClassifier->particleTruthClassifier(firstElTruth, ctx);
122 firstEgMotherTT(*el) = res.first;
123 firstEgMotherTO(*el) = res.second;
124 firstEgMotherTC(*el) = std::get<0>(MCTruthPartClassifier::defOrigOfParticle(firstElTruth)); // See AGENE-2351
125 firstEgMotherPdgID(*el) = firstElTruth->pdgId();
126 ElementLink<xAOD::TruthParticleContainer> link(
127 firstElTruth, *truthContainer, ctx);
128 firstEgMotherTPL(*el) = link;
129 }
130
131 // The last electron / photon we meet on the way back towards the Generator
132 // vertex
133 lastEgMotherTT(*el) = 0;
134 lastEgMotherTO(*el) = 0;
135 lastEgMotherTC(*el) = 0;
136 lastEgMotherTPL(*el) = ElementLink<xAOD::TruthParticleContainer>();
137 lastEgMotherPdgID(*el) = 0;
138 const xAOD::TruthParticle* lastElTruth =
140
141 if (lastElTruth) {
142 auto res = m_mcTruthClassifier->particleTruthClassifier(lastElTruth, ctx);
143 lastEgMotherTT(*el) = res.first;
144 lastEgMotherTO(*el) = res.second;
145 lastEgMotherTC(*el) = std::get<0>(MCTruthPartClassifier::defOrigOfParticle(lastElTruth)); // See AGENE-2351
146 lastEgMotherPdgID(*el) = lastElTruth->pdgId();
147 ElementLink<xAOD::TruthParticleContainer> link(
148 lastElTruth, *truthContainer, ctx);
149 lastEgMotherTPL(*el) = link;
150 }
151 }
152 return StatusCode::SUCCESS;
153}
#define ATH_MSG_WARNING(x,...)
std::pair< std::vector< unsigned int >, bool > res
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_lastEgMotherTruthOrigin
SG::ReadHandleKey< xAOD::ElectronContainer > m_electronContainer
input electron container
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_truthPdgId
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_lastEgMotherTruthParticleLink
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthContainer
Input truth particle container.
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_lastEgMotherTruthClassification
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_firstEgMotherPdgId
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_firstEgMotherTruthType
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_firstEgMotherTruthOrigin
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_firstEgMotherTruthParticleLink
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_lastEgMotherTruthType
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_lastEgMotherPdgId
SG::ReadDecorHandleKey< xAOD::ElectronContainer > m_electronTruthParticleLink
ToolHandle< IMCTruthClassifier > m_mcTruthClassifier
MCTruthClassifier.
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_firstEgMotherTruthClassification
int pdgId() const
PDG ID code.
const TruthParticle_v1 * parent(size_t i) const
Retrieve the i-th mother (TruthParticle) of this TruthParticle.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
size_t nParents() const
Number of parents of this particle.
std::tuple< unsigned int, T > defOrigOfParticle(T thePart)
bool isElectron(const T &p)
pointer & link(pointer p) const
Return a reference to the link for an element.
const xAOD::TruthParticle * getBkgElectronMother(const xAOD::Electron *el, const bool allTheWayBack=true)
Helper wrapper function for calling the function above extracting the truth from a reco electron.
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
TruthParticle_v1 TruthParticle
Typedef to implementation.
Electron_v1 Electron
Definition of the current "egamma version".

◆ initialize()

StatusCode DerivationFramework::BkgElectronClassification::initialize ( )
finaloverridevirtual

Definition at line 18 of file BkgElectronClassification.cxx.

19{
20
21 ATH_MSG_DEBUG("Initializing " << name() << "...");
23 ATH_MSG_DEBUG("Retrieved tool " << m_mcTruthClassifier);
24
25 ATH_CHECK(m_electronContainer.initialize());
26 ATH_CHECK(m_truthContainer.initialize());
28 ATH_CHECK(m_truthPdgId.initialize());
29 //
34 ATH_CHECK(m_firstEgMotherPdgId.initialize());
35 //
40 ATH_CHECK(m_lastEgMotherPdgId.initialize());
41
42 ATH_MSG_DEBUG("Initialization successful");
43
44 return StatusCode::SUCCESS;
45}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)

Member Data Documentation

◆ m_electronContainer

SG::ReadHandleKey<xAOD::ElectronContainer> DerivationFramework::BkgElectronClassification::m_electronContainer
private
Initial value:
{
this,
"ElectronContainerName",
"Electrons",
"Input Electrons"
}

input electron container

Definition at line 42 of file BkgElectronClassification.h.

42 {
43 this,
44 "ElectronContainerName",
45 "Electrons",
46 "Input Electrons"
47 };

◆ m_electronTruthParticleLink

SG::ReadDecorHandleKey<xAOD::ElectronContainer> DerivationFramework::BkgElectronClassification::m_electronTruthParticleLink
private
Initial value:
{ this, "electronTruthParticleLink",
m_electronContainer, "truthParticleLink", "" }

Definition at line 49 of file BkgElectronClassification.h.

49 { this, "electronTruthParticleLink",
50 m_electronContainer, "truthParticleLink", "" }; // Decoration applied in egammaTruthAssociationAlg

◆ m_firstEgMotherPdgId

SG::WriteDecorHandleKey<xAOD::ElectronContainer> DerivationFramework::BkgElectronClassification::m_firstEgMotherPdgId { this, "firstEgMotherPdgId", m_electronContainer, "firstEgMotherPdgId", "" }
private

Definition at line 76 of file BkgElectronClassification.h.

76{ this, "firstEgMotherPdgId", m_electronContainer, "firstEgMotherPdgId", "" };

◆ m_firstEgMotherTruthClassification

SG::WriteDecorHandleKey<xAOD::ElectronContainer> DerivationFramework::BkgElectronClassification::m_firstEgMotherTruthClassification
private
Initial value:
{ this, "firstEgMotherTruthClassification",
m_electronContainer, "firstEgMotherTruthClassification", "" }

Definition at line 68 of file BkgElectronClassification.h.

68 { this, "firstEgMotherTruthClassification",
69 m_electronContainer, "firstEgMotherTruthClassification", "" };

◆ m_firstEgMotherTruthOrigin

SG::WriteDecorHandleKey<xAOD::ElectronContainer> DerivationFramework::BkgElectronClassification::m_firstEgMotherTruthOrigin { this, "firstEgMotherTruthOrigin", m_electronContainer, "firstEgMotherTruthOrigin", "" }
private

Definition at line 66 of file BkgElectronClassification.h.

66{ this, "firstEgMotherTruthOrigin", m_electronContainer, "firstEgMotherTruthOrigin", "" };

◆ m_firstEgMotherTruthParticleLink

SG::WriteDecorHandleKey<xAOD::ElectronContainer> DerivationFramework::BkgElectronClassification::m_firstEgMotherTruthParticleLink
private
Initial value:
{ this,
"firstEgMotherTruthParticleLink",
m_electronContainer, "firstEgMotherTruthParticleLink",
"" }

Definition at line 71 of file BkgElectronClassification.h.

71 { this,
72 "firstEgMotherTruthParticleLink",
73 m_electronContainer, "firstEgMotherTruthParticleLink",
74 "" };

◆ m_firstEgMotherTruthType

SG::WriteDecorHandleKey<xAOD::ElectronContainer> DerivationFramework::BkgElectronClassification::m_firstEgMotherTruthType { this, "firstEgMotherTruthType", m_electronContainer, "firstEgMotherTruthType", "" }
private

Definition at line 64 of file BkgElectronClassification.h.

64{ this, "firstEgMotherTruthType", m_electronContainer, "firstEgMotherTruthType", "" };

◆ m_lastEgMotherPdgId

SG::WriteDecorHandleKey<xAOD::ElectronContainer> DerivationFramework::BkgElectronClassification::m_lastEgMotherPdgId { this, "lastEgMotherPdgId", m_electronContainer, "lastEgMotherPdgId", "" }
private

Definition at line 90 of file BkgElectronClassification.h.

90{ this, "lastEgMotherPdgId", m_electronContainer, "lastEgMotherPdgId", "" };

◆ m_lastEgMotherTruthClassification

SG::WriteDecorHandleKey<xAOD::ElectronContainer> DerivationFramework::BkgElectronClassification::m_lastEgMotherTruthClassification
private
Initial value:
{ this, "lastEgMotherTruthClassification",
m_electronContainer, "lastEgMotherTruthClassification", "" }

Definition at line 82 of file BkgElectronClassification.h.

82 { this, "lastEgMotherTruthClassification",
83 m_electronContainer, "lastEgMotherTruthClassification", "" };

◆ m_lastEgMotherTruthOrigin

SG::WriteDecorHandleKey<xAOD::ElectronContainer> DerivationFramework::BkgElectronClassification::m_lastEgMotherTruthOrigin { this, "lastEgMotherTruthOrigin", m_electronContainer, "lastEgMotherTruthOrigin", "" }
private

Definition at line 80 of file BkgElectronClassification.h.

80{ this, "lastEgMotherTruthOrigin", m_electronContainer, "lastEgMotherTruthOrigin", "" };

◆ m_lastEgMotherTruthParticleLink

SG::WriteDecorHandleKey<xAOD::ElectronContainer> DerivationFramework::BkgElectronClassification::m_lastEgMotherTruthParticleLink
private
Initial value:
{ this,
"lastEgMotherTruthParticleLink",
m_electronContainer, "lastEgMotherTruthParticleLink",
"" }

Definition at line 85 of file BkgElectronClassification.h.

85 { this,
86 "lastEgMotherTruthParticleLink",
87 m_electronContainer, "lastEgMotherTruthParticleLink",
88 "" };

◆ m_lastEgMotherTruthType

SG::WriteDecorHandleKey<xAOD::ElectronContainer> DerivationFramework::BkgElectronClassification::m_lastEgMotherTruthType { this, "lastEgMotherTruthType", m_electronContainer, "lastEgMotherTruthType", "" }
private

Definition at line 78 of file BkgElectronClassification.h.

78{ this, "lastEgMotherTruthType", m_electronContainer, "lastEgMotherTruthType", "" };

◆ m_mcTruthClassifier

ToolHandle<IMCTruthClassifier> DerivationFramework::BkgElectronClassification::m_mcTruthClassifier
private
Initial value:
{
this,
"MCTruthClassifierTool",
"",
"Handle to the MCTruthClassifier"
}

MCTruthClassifier.

Definition at line 34 of file BkgElectronClassification.h.

34 {
35 this,
36 "MCTruthClassifierTool",
37 "",
38 "Handle to the MCTruthClassifier"
39 };

◆ m_truthContainer

SG::ReadHandleKey<xAOD::TruthParticleContainer> DerivationFramework::BkgElectronClassification::m_truthContainer
private
Initial value:
{
this,
"TruthParticleContainerName",
"TruthParticles",
"Input Truth Particles"
}

Input truth particle container.

Definition at line 53 of file BkgElectronClassification.h.

53 {
54 this,
55 "TruthParticleContainerName",
56 "TruthParticles",
57 "Input Truth Particles"
58 };

◆ m_truthPdgId

SG::WriteDecorHandleKey<xAOD::ElectronContainer> DerivationFramework::BkgElectronClassification::m_truthPdgId { this, "DoNotSet_truthPdgId", m_electronContainer, "truthPdgId", "" }
private

Definition at line 62 of file BkgElectronClassification.h.

62{ this, "DoNotSet_truthPdgId", m_electronContainer, "truthPdgId", "" };

The documentation for this class was generated from the following files: