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

#include <EGPhotonBDTToolWrapper.h>

Inheritance diagram for DerivationFramework::EGPhotonBDTToolWrapper:
Collaboration diagram for DerivationFramework::EGPhotonBDTToolWrapper:

Public Member Functions

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

Private Attributes

ToolHandle< IAsgEGammaIsEMSelectorm_selectorTool {this, "PhotonBDTSelectionTool", "", "Selector tool",}
ToolHandle< IPhotonObservableToolm_observableTool {this, "PhotonObservableTool", "", "Observable tool",}
ToolHandle< IElectronPhotonShowerShapeFudgeToolm_fudgeMCTool { this, "EGammaFudgeMCTool", "", "Fudging tool" }
SG::ReadHandleKey< xAOD::EgammaContainerm_ContainerName { this, "ContainerName", "", "Input" }
SG::WriteDecorHandleKey< xAOD::EgammaContainerm_decoratorPass
SG::WriteDecorHandleKey< xAOD::EgammaContainerm_decoratorIsEM
SG::WriteDecorHandleKey< xAOD::EgammaContainerm_decoratorScore
Gaudi::Property< std::string > m_cut { this, "CutType", "", "cut type" }

Detailed Description

Definition at line 25 of file EGPhotonBDTToolWrapper.h.

Member Function Documentation

◆ addBranches()

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

Definition at line 35 of file EGPhotonBDTToolWrapper.cxx.

36{
37 // retrieve container
38 SG::ReadHandle<xAOD::EgammaContainer> particles{ m_ContainerName, ctx };
39
40 // Decorators
41 SG::WriteDecorHandle<xAOD::EgammaContainer, char> decoratorPass{
43 };
44 SG::WriteDecorHandle<xAOD::EgammaContainer, unsigned int> decoratorIsEM{
46 };
47 SG::WriteDecorHandle<xAOD::EgammaContainer, float> decoratorScore{
49 };
50
51 // If we're applying corrections, the correction tools will give us
52 // copies that we need to keep track of. (We want to do all the copies
53 // before we start writing decorations, to avoid warnings about having
54 // unlocked decorations in a copy).
55 // The copies we get back from the tool will have standalone aux stores.
56 // We'll put them in a DataVector to get them deleted, but we don't
57 // need to copy the aux data to the container, so construct it with
58 // @c NEVER_TRACK_INDICES.
60 if (!m_fudgeMCTool.empty()) {
61 pCopies.reserve (particles->size());
62 for (const xAOD::Egamma* par : *particles) {
64 // apply the shower shape corrections
65 CP::CorrectionCode correctionCode = CP::CorrectionCode::Ok;
66 xAOD::Egamma* pCopy = nullptr;
67 if (type == xAOD::Type::Electron) {
68 const xAOD::Electron* eg = static_cast<const xAOD::Electron*>(par);
69 xAOD::Electron* el = nullptr;
70 correctionCode = m_fudgeMCTool->correctedCopy(*eg, el);
71 pCopy = el;
72 } else {
73 const xAOD::Photon* eg = static_cast<const xAOD::Photon*>(par);
74 xAOD::Photon* ph = nullptr;
75 correctionCode = m_fudgeMCTool->correctedCopy(*eg, ph);
76 pCopy = ph;
77 }
78 if (correctionCode == CP::CorrectionCode::Ok) {
79 // all OK
80 } else if (correctionCode == CP::CorrectionCode::OutOfValidityRange) {
81 Warning(
82 "addBranches()",
83 "Current photon has no valid fudge factors due to out-of-range");
84 } else {
85 Warning(
86 "addBranches()",
87 "Unknown correction code %d from ElectronPhotonShowerShapeFudgeTool",
88 (int)correctionCode);
89 }
90 pCopies.push_back (pCopy);
91 }
92 }
93 else {
94 pCopies.resize (particles->size());
95 }
96
97 // Write mask for each element and record to SG for subsequent selection
98 for (size_t ipar = 0; ipar < particles->size(); ipar++) {
99 const xAOD::Egamma* par = particles->at(ipar);
100 const xAOD::Egamma* pCopy = pCopies[ipar];
101 if (!pCopy) pCopy = par;
102
103 // compute the output of the selector
104 asg::AcceptData theAccept(m_selectorTool->accept(ctx, pCopy));
105 // compute the is EM word
106 unsigned int isEM = 0;
107 ATH_CHECK(m_selectorTool->execute(ctx, pCopy, isEM));
108 // compute the BDT score
109 const float score = m_observableTool->evaluate(pCopy);
110
111 // decorate the original object
112 if (m_cut.empty()) {
113 decoratorPass(*par) = static_cast<bool>(theAccept) ? 1 : 0;
114 } else {
115 decoratorPass(*par) = theAccept.getCutResult(m_cut) ? 1 : 0;
116 }
117 decoratorIsEM(*par) = isEM;
118 decoratorScore(*par) = score;
119 }
120
121 return StatusCode::SUCCESS;
122}
#define ATH_CHECK
Evaluate an expression and check for errors.
@ OutOfValidityRange
Input object is out of validity range.
@ Ok
The correction was done successfully.
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorPass
SG::ReadHandleKey< xAOD::EgammaContainer > m_ContainerName
ToolHandle< IAsgEGammaIsEMSelector > m_selectorTool
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorIsEM
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorScore
ToolHandle< IElectronPhotonShowerShapeFudgeTool > m_fudgeMCTool
ToolHandle< IPhotonObservableTool > m_observableTool
@ NEVER_TRACK_INDICES
Never track indices, regardless of the setting of the ownership policy.
@ OWN_ELEMENTS
this data object owns its elements
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition ObjectType.h:32
@ Electron
The object is an electron.
Definition ObjectType.h:46
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition Egamma.h:17
Photon_v1 Photon
Definition of the current "egamma version".
EgammaContainer_v1 EgammaContainer
Definition of the current "egamma container version".
Electron_v1 Electron
Definition of the current "egamma version".

◆ initialize()

StatusCode DerivationFramework::EGPhotonBDTToolWrapper::initialize ( )
finaloverridevirtual

Definition at line 15 of file EGPhotonBDTToolWrapper.cxx.

16{
17 ATH_CHECK(m_selectorTool.retrieve());
18 ATH_CHECK(m_observableTool.retrieve());
19
20 if (!(m_fudgeMCTool.name().empty())) {
21 ATH_CHECK(m_fudgeMCTool.retrieve());
22 } else {
23 m_fudgeMCTool.disable();
24 }
25
26 ATH_CHECK(m_ContainerName.initialize());
27 ATH_CHECK(m_decoratorPass.initialize());
28 ATH_CHECK(m_decoratorIsEM.initialize());
29 ATH_CHECK(m_decoratorScore.initialize());
30
31 return StatusCode::SUCCESS;
32}

Member Data Documentation

◆ m_ContainerName

SG::ReadHandleKey<xAOD::EgammaContainer> DerivationFramework::EGPhotonBDTToolWrapper::m_ContainerName { this, "ContainerName", "", "Input" }
private

Definition at line 42 of file EGPhotonBDTToolWrapper.h.

42{ this, "ContainerName", "", "Input" };

◆ m_cut

Gaudi::Property<std::string> DerivationFramework::EGPhotonBDTToolWrapper::m_cut { this, "CutType", "", "cut type" }
private

Definition at line 52 of file EGPhotonBDTToolWrapper.h.

52{ this, "CutType", "", "cut type" };

◆ m_decoratorIsEM

SG::WriteDecorHandleKey<xAOD::EgammaContainer> DerivationFramework::EGPhotonBDTToolWrapper::m_decoratorIsEM
private
Initial value:
{ this,
"decoratorIsEM", m_ContainerName, "", "" }

Definition at line 48 of file EGPhotonBDTToolWrapper.h.

48 { this,
49 "decoratorIsEM", m_ContainerName, "", "" };

◆ m_decoratorPass

SG::WriteDecorHandleKey<xAOD::EgammaContainer> DerivationFramework::EGPhotonBDTToolWrapper::m_decoratorPass
private
Initial value:
{ this,
"decoratorPass", m_ContainerName, "", "" }

Definition at line 46 of file EGPhotonBDTToolWrapper.h.

46 { this,
47 "decoratorPass", m_ContainerName, "", "" };

◆ m_decoratorScore

SG::WriteDecorHandleKey<xAOD::EgammaContainer> DerivationFramework::EGPhotonBDTToolWrapper::m_decoratorScore
private
Initial value:
{ this,
"decoratorScore", m_ContainerName, "", "" }

Definition at line 50 of file EGPhotonBDTToolWrapper.h.

50 { this,
51 "decoratorScore", m_ContainerName, "", "" };

◆ m_fudgeMCTool

ToolHandle<IElectronPhotonShowerShapeFudgeTool> DerivationFramework::EGPhotonBDTToolWrapper::m_fudgeMCTool { this, "EGammaFudgeMCTool", "", "Fudging tool" }
private

Definition at line 40 of file EGPhotonBDTToolWrapper.h.

40{ this, "EGammaFudgeMCTool", "", "Fudging tool" };

◆ m_observableTool

ToolHandle<IPhotonObservableTool> DerivationFramework::EGPhotonBDTToolWrapper::m_observableTool {this, "PhotonObservableTool", "", "Observable tool",}
private

Definition at line 38 of file EGPhotonBDTToolWrapper.h.

38{this, "PhotonObservableTool", "", "Observable tool",};

◆ m_selectorTool

ToolHandle<IAsgEGammaIsEMSelector> DerivationFramework::EGPhotonBDTToolWrapper::m_selectorTool {this, "PhotonBDTSelectionTool", "", "Selector tool",}
private

Definition at line 36 of file EGPhotonBDTToolWrapper.h.

36{this, "PhotonBDTSelectionTool", "", "Selector tool",};

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