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< IMCTruthClassifierm_mcTruthClassifier
 MCTruthClassifier.
SG::ReadHandleKey< xAOD::ElectronContainerm_electronContainer
 input electron container
SG::ReadHandleKey< xAOD::TruthParticleContainerm_truthContainer
 Input truth particle container.
SG::WriteDecorHandleKey< xAOD::ElectronContainerm_truthPdgId { this, "DoNotSet_truthPdgId", m_electronContainer, "truthPdgId", "" }
SG::WriteDecorHandleKey< xAOD::ElectronContainerm_firstEgMotherTruthType { this, "firstEgMotherTruthType", m_electronContainer, "firstEgMotherTruthType", "" }
SG::WriteDecorHandleKey< xAOD::ElectronContainerm_firstEgMotherTruthOrigin { this, "firstEgMotherTruthOrigin", m_electronContainer, "firstEgMotherTruthOrigin", "" }
SG::WriteDecorHandleKey< xAOD::ElectronContainerm_firstEgMotherTruthParticleLink
SG::WriteDecorHandleKey< xAOD::ElectronContainerm_firstEgMotherPdgId { this, "firstEgMotherPdgId", m_electronContainer, "firstEgMotherPdgId", "" }
SG::WriteDecorHandleKey< xAOD::ElectronContainerm_lastEgMotherTruthType { this, "lastEgMotherTruthType", m_electronContainer, "lastEgMotherTruthType", "" }
SG::WriteDecorHandleKey< xAOD::ElectronContainerm_lastEgMotherTruthOrigin { this, "lastEgMotherTruthOrigin", m_electronContainer, "lastEgMotherTruthOrigin", "" }
SG::WriteDecorHandleKey< xAOD::ElectronContainerm_lastEgMotherTruthParticleLink
SG::WriteDecorHandleKey< xAOD::ElectronContainerm_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 44 of file BkgElectronClassification.cxx.

45{
46
47 SG::ReadHandle<xAOD::ElectronContainer> electrons{ m_electronContainer, ctx };
48 SG::ReadHandle<xAOD::TruthParticleContainer> truthContainer{ m_truthContainer,
49 ctx };
50
51 // Access for the already existing info
52 static const SG::AuxElement::Accessor<int> tT("truthType");
53 static const SG::AuxElement::Accessor<int> tO("truthOrigin");
54 static const SG::AuxElement::Accessor<
55 ElementLink<xAOD::TruthParticleContainer>>
56 tPL("truthParticleLink");
57
58 // pdg iD
59 SG::WriteDecorHandle<xAOD::ElectronContainer, int> tPdgID(m_truthPdgId, ctx);
60 // first mother decorations
61 SG::WriteDecorHandle<xAOD::ElectronContainer, int> firstEgMotherTT(
63 SG::WriteDecorHandle<xAOD::ElectronContainer, int> firstEgMotherTO(
65 SG::WriteDecorHandle<xAOD::ElectronContainer, int> firstEgMotherPdgID(
67 SG::WriteDecorHandle<xAOD::ElectronContainer,
68 ElementLink<xAOD::TruthParticleContainer>>
69 firstEgMotherTPL(m_firstEgMotherTruthParticleLink, ctx);
70
71 // last mother decorations
72 SG::WriteDecorHandle<xAOD::ElectronContainer, int> lastEgMotherTT(
74 SG::WriteDecorHandle<xAOD::ElectronContainer, int> lastEgMotherTO(
76 SG::WriteDecorHandle<xAOD::ElectronContainer, int> lastEgMotherPdgID(
78 SG::WriteDecorHandle<xAOD::ElectronContainer,
79 ElementLink<xAOD::TruthParticleContainer>>
80 lastEgMotherTPL(m_lastEgMotherTruthParticleLink, ctx);
81 //
82
83 for (const xAOD::Electron* el : *electrons) {
84 tPdgID(*el) = 0;
85 if (tPL.isAvailable(*el) && tPL(*el).isValid()) {
86 tPdgID(*el) = (*tPL(*el))->pdgId();
87 }
88 // Use the Helpers for electron from electron or photon
89 // Add Extra Decoration from Egamma helpers in case of BkgElectron (Electron
90 // coming for a photon) Go back to the first/last electron/photon Generator
91 // mother and classify this one
92 // First the one entering the Geant, the first we meet on the way back
93 firstEgMotherTT(*el) = 0;
94 firstEgMotherTO(*el) = 0;
95 firstEgMotherTPL(*el) = ElementLink<xAOD::TruthParticleContainer>();
96 firstEgMotherPdgID(*el) = 0;
97 const xAOD::TruthParticle* firstElTruth =
99
100 MCTruthPartClassifier::Info mcinfo(ctx);
101 if (firstElTruth) {
102 auto res = m_mcTruthClassifier->particleTruthClassifier(firstElTruth, &mcinfo);
103 firstEgMotherTT(*el) = res.first;
104 firstEgMotherTO(*el) = res.second;
105 firstEgMotherPdgID(*el) = firstElTruth->pdgId();
106 ElementLink<xAOD::TruthParticleContainer> link(
107 firstElTruth, *truthContainer, ctx);
108 firstEgMotherTPL(*el) = link;
109 }
110
111 // The last electron / photon we meet on the way back towards the Generator
112 // vertex
113 lastEgMotherTT(*el) = 0;
114 lastEgMotherTO(*el) = 0;
115 lastEgMotherTPL(*el) = ElementLink<xAOD::TruthParticleContainer>();
116 lastEgMotherPdgID(*el) = 0;
117 const xAOD::TruthParticle* lastElTruth =
119
120 if (lastElTruth) {
121 auto res = m_mcTruthClassifier->particleTruthClassifier(lastElTruth, &mcinfo);
122 lastEgMotherTT(*el) = res.first;
123 lastEgMotherTO(*el) = res.second;
124 lastEgMotherPdgID(*el) = lastElTruth->pdgId();
125 ElementLink<xAOD::TruthParticleContainer> link(
126 lastElTruth, *truthContainer, ctx);
127 lastEgMotherTPL(*el) = link;
128 }
129 }
130 return StatusCode::SUCCESS;
131}
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_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
ToolHandle< IMCTruthClassifier > m_mcTruthClassifier
MCTruthClassifier.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
int pdgId() const
PDG ID code.
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 16 of file BkgElectronClassification.cxx.

17{
18
19 ATH_MSG_DEBUG("Initializing " << name() << "...");
21 ATH_MSG_DEBUG("Retrieved tool " << m_mcTruthClassifier);
22
23 ATH_CHECK(m_electronContainer.initialize());
24 ATH_CHECK(m_truthContainer.initialize());
25
26 ATH_CHECK(m_truthPdgId.initialize());
27 //
31 ATH_CHECK(m_firstEgMotherPdgId.initialize());
32 //
36 ATH_CHECK(m_lastEgMotherPdgId.initialize());
37
38 ATH_MSG_DEBUG("Initialization successful");
39
40 return StatusCode::SUCCESS;
41}
#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_firstEgMotherPdgId

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

Definition at line 69 of file BkgElectronClassification.h.

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

◆ m_firstEgMotherTruthOrigin

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

Definition at line 62 of file BkgElectronClassification.h.

62{ 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 64 of file BkgElectronClassification.h.

64 { this,
65 "firstEgMotherTruthParticleLink",
66 m_electronContainer, "firstEgMotherTruthParticleLink",
67 "" };

◆ m_firstEgMotherTruthType

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

Definition at line 60 of file BkgElectronClassification.h.

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

◆ m_lastEgMotherPdgId

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

Definition at line 80 of file BkgElectronClassification.h.

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

◆ m_lastEgMotherTruthOrigin

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

Definition at line 73 of file BkgElectronClassification.h.

73{ 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 75 of file BkgElectronClassification.h.

75 { this,
76 "lastEgMotherTruthParticleLink",
77 m_electronContainer, "lastEgMotherTruthParticleLink",
78 "" };

◆ m_lastEgMotherTruthType

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

Definition at line 71 of file BkgElectronClassification.h.

71{ 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 49 of file BkgElectronClassification.h.

49 {
50 this,
51 "TruthParticleContainerName",
52 "TruthParticles",
53 "Input Truth Particles"
54 };

◆ m_truthPdgId

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

Definition at line 58 of file BkgElectronClassification.h.

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

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