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

#include <EGElectronLikelihoodToolWrapper.h>

Inheritance diagram for DerivationFramework::EGElectronLikelihoodToolWrapper:
Collaboration diagram for DerivationFramework::EGElectronLikelihoodToolWrapper:

Public Member Functions

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

Private Attributes

ToolHandle< IAsgElectronLikelihoodToolm_tool
ToolHandle< IElectronPhotonShowerShapeFudgeToolm_fudgeMCTool { this, "EGammaFudgeMCTool", "", "Fudging tool" }
SG::ReadHandleKey< xAOD::EgammaContainerm_ContainerName
SG::WriteDecorHandleKey< xAOD::EgammaContainerm_decoratorPass { this, "decoratorPass", m_ContainerName, "", "" }
SG::WriteDecorHandleKey< xAOD::EgammaContainerm_decoratorIsEM { this, "decoratorIsEM", m_ContainerName, "", "" }
SG::WriteDecorHandleKey< xAOD::EgammaContainerm_decoratorResult { this, "decoratorResult", m_ContainerName, "", "" }
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainer, float > m_decoratorMultipleOutputs {this, "decoratorMultipleOutputs", m_ContainerName, {}, ""}
Gaudi::Property< std::string > m_cut {this, "CutType", ""}
Gaudi::Property< bool > m_storeTResult {this, "StoreTResult", false}
Gaudi::Property< bool > m_storeMultipleOutputs {this, "StoreMultipleOutputs", false}

Detailed Description

Definition at line 33 of file EGElectronLikelihoodToolWrapper.h.

Member Function Documentation

◆ addBranches()

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

Definition at line 41 of file EGElectronLikelihoodToolWrapper.cxx.

42 {
43 // retrieve container
44 SG::ReadHandle<xAOD::EgammaContainer> particles{ m_ContainerName, ctx };
45
46 // If we're applying corrections, the correction tools will give us
47 // copies that we need to keep track of. (We want to do all the copies
48 // before we start writing decorations, to avoid warnings about having
49 // unlocked decorations in a copy).
50 // The copies we get back from the tool will have standalone aux stores.
51 // We'll put them in a DataVector to get them deleted, but we don't
52 // need to copy the aux data to the container, so construct it with
53 // @c NEVER_TRACK_INDICES.
55 if (!m_fudgeMCTool.empty()) {
56 pCopies.reserve (particles->size());
57 for (const xAOD::Egamma* par : *particles) {
59 // apply the shower shape corrections
60 CP::CorrectionCode correctionCode = CP::CorrectionCode::Ok;
61 xAOD::Egamma* pCopy = nullptr;
62 if (type == xAOD::Type::Electron) {
63 const xAOD::Electron* eg = static_cast<const xAOD::Electron*>(par);
64 xAOD::Electron* el = nullptr;
65 correctionCode = m_fudgeMCTool->correctedCopy(*eg, el);
66 pCopy = el;
67 } else {
68 const xAOD::Photon* eg = static_cast<const xAOD::Photon*>(par);
69 xAOD::Photon* ph = nullptr;
70 correctionCode = m_fudgeMCTool->correctedCopy(*eg, ph);
71 pCopy = ph;
72 }
73 if (correctionCode == CP::CorrectionCode::Ok) { // All OK
74 } else if (correctionCode == CP::CorrectionCode::Error) {
75 Error("addBranches()",
76 "Error applying fudge factors to current photon");
77 } else if (correctionCode == CP::CorrectionCode::OutOfValidityRange) {
78 Warning(
79 "addBranches()",
80 "Current object has no valid fudge factors due to out-of-range");
81 } else {
82 Warning(
83 "addBranches()",
84 "Unknown correction code %d from ElectronPhotonShowerShapeFudgeTool",
85 (int)correctionCode);
86 }
87 pCopies.push_back (pCopy);
88 }
89 }
90 else {
91 pCopies.resize (particles->size());
92 }
93
94 // Decorators
95 SG::WriteDecorHandle<xAOD::EgammaContainer, char> decoratorPass{
97 };
98 SG::WriteDecorHandle<xAOD::EgammaContainer, unsigned int> decoratorIsEM{
100 };
101
102 std::unique_ptr<SG::WriteDecorHandle<xAOD::EgammaContainer, float>>
103 decoratorResult = nullptr;
104 if (m_storeTResult) {
105 decoratorResult =
106 std::make_unique<SG::WriteDecorHandle<xAOD::EgammaContainer, float>>(
107 m_decoratorResult, ctx);
108 }
109 std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, float>> decoratorMultipleOutputs{};
111 decoratorMultipleOutputs = m_decoratorMultipleOutputs.makeHandles(ctx);
112 }
113
114 // Write mask for each element and record to SG for subsequent selection
115 for (size_t ipar = 0; const xAOD::Egamma* par : *particles) {
116 const xAOD::Egamma* pCopy = pCopies[ipar++];
117 if (!pCopy) pCopy = par;
118 // compute the output of the selector
119 asg::AcceptData theAccept(m_tool->accept(ctx, pCopy));
120 const unsigned int isEM =
121 (unsigned int)theAccept.getCutResultInvertedBitSet()
122 .to_ulong(); // this should work for both the
123 // cut-based and the LH selectors
124
125 // decorate the original object
126 if (m_cut.empty()) {
127 const bool pass_selection = (bool)theAccept;
128 if (pass_selection) {
129 decoratorPass(*par) = 1;
130 } else {
131 decoratorPass(*par) = 0;
132 }
133 decoratorIsEM(*par) = isEM;
134 if (decoratorResult) {
135 (*decoratorResult)(*par) =
136 static_cast<float>(m_tool->calculate(ctx, pCopy));
137 }
139 // calculateMultipleOutputs only supports xAOD::Electron as input
140 const xAOD::Electron *eCopy = static_cast<const xAOD::Electron *>(pCopy);
141 std::vector<float> toolOutput = m_tool->calculateMultipleOutputs(ctx, eCopy);
142 for (size_t i = 0; i < toolOutput.size(); i++){
143 decoratorMultipleOutputs.at(i)(*par) = toolOutput.at(i);
144 }
145 }
146 } else {
147 if (theAccept.getCutResult(m_cut)) {
148 decoratorPass(*par) = 1;
149 } else {
150 decoratorPass(*par) = 0;
151 }
152 decoratorIsEM(*par) = isEM;
153 if (decoratorResult) {
154 (*decoratorResult)(*par) =
155 static_cast<float>(m_tool->calculate(ctx, pCopy));
156 }
158 // calculateMultipleOutputs only supports xAOD::Electron as input
159 const xAOD::Electron* eCopy = static_cast<const xAOD::Electron*>(pCopy);
160 std::vector<float> toolOutput = m_tool->calculateMultipleOutputs(ctx, eCopy);
161 for (size_t i = 0; i < toolOutput.size(); i++){
162 decoratorMultipleOutputs.at(i)(*par) = toolOutput.at(i);
163 }
164 }
165 }
166 }
167
168 return StatusCode::SUCCESS;
169 }
@ Error
Some error happened during the object correction.
@ OutOfValidityRange
Input object is out of validity range.
@ Ok
The correction was done successfully.
ToolHandle< IElectronPhotonShowerShapeFudgeTool > m_fudgeMCTool
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorPass
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorIsEM
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainer, float > m_decoratorMultipleOutputs
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorResult
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition Error.h:16
@ 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".
setBGCode setTAP setLVL2ErrorBits bool
EgammaContainer_v1 EgammaContainer
Definition of the current "egamma container version".
Electron_v1 Electron
Definition of the current "egamma version".

◆ initialize()

StatusCode DerivationFramework::EGElectronLikelihoodToolWrapper::initialize ( )
finaloverridevirtual

Definition at line 20 of file EGElectronLikelihoodToolWrapper.cxx.

21 {
22 ATH_CHECK(m_tool.retrieve());
23
24 if (!(m_fudgeMCTool.name().empty())) {
25 ATH_CHECK(m_fudgeMCTool.retrieve());
26 } else {
27 m_fudgeMCTool.disable();
28 }
29
30 ATH_CHECK(m_ContainerName.initialize());
31 //
32 ATH_CHECK(m_decoratorPass.initialize());
33 ATH_CHECK(m_decoratorIsEM.initialize());
34 //
37 return StatusCode::SUCCESS;
38 }
#define ATH_CHECK
Evaluate an expression and check for errors.

Member Data Documentation

◆ m_ContainerName

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

Definition at line 52 of file EGElectronLikelihoodToolWrapper.h.

52 { this,
53 "ContainerName",
54 "",
55 "Input" };

◆ m_cut

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

Definition at line 66 of file EGElectronLikelihoodToolWrapper.h.

66{this, "CutType", ""};

◆ m_decoratorIsEM

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

Definition at line 61 of file EGElectronLikelihoodToolWrapper.h.

61{ this, "decoratorIsEM", m_ContainerName, "", "" };

◆ m_decoratorMultipleOutputs

SG::WriteDecorHandleKeyArray<xAOD::EgammaContainer, float> DerivationFramework::EGElectronLikelihoodToolWrapper::m_decoratorMultipleOutputs {this, "decoratorMultipleOutputs", m_ContainerName, {}, ""}
private

Definition at line 65 of file EGElectronLikelihoodToolWrapper.h.

65{this, "decoratorMultipleOutputs", m_ContainerName, {}, ""};

◆ m_decoratorPass

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

Definition at line 59 of file EGElectronLikelihoodToolWrapper.h.

59{ this, "decoratorPass", m_ContainerName, "", "" };

◆ m_decoratorResult

SG::WriteDecorHandleKey<xAOD::EgammaContainer> DerivationFramework::EGElectronLikelihoodToolWrapper::m_decoratorResult { this, "decoratorResult", m_ContainerName, "", "" }
private

Definition at line 63 of file EGElectronLikelihoodToolWrapper.h.

63{ this, "decoratorResult", m_ContainerName, "", "" };

◆ m_fudgeMCTool

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

Definition at line 50 of file EGElectronLikelihoodToolWrapper.h.

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

◆ m_storeMultipleOutputs

Gaudi::Property<bool> DerivationFramework::EGElectronLikelihoodToolWrapper::m_storeMultipleOutputs {this, "StoreMultipleOutputs", false}
private

Definition at line 68 of file EGElectronLikelihoodToolWrapper.h.

68{this, "StoreMultipleOutputs", false};

◆ m_storeTResult

Gaudi::Property<bool> DerivationFramework::EGElectronLikelihoodToolWrapper::m_storeTResult {this, "StoreTResult", false}
private

Definition at line 67 of file EGElectronLikelihoodToolWrapper.h.

67{this, "StoreTResult", false};

◆ m_tool

ToolHandle<IAsgElectronLikelihoodTool> DerivationFramework::EGElectronLikelihoodToolWrapper::m_tool
private
Initial value:
{
this,
"EGammaElectronLikelihoodTool",
"",
"Electron Likelihood Selector"
}

Definition at line 43 of file EGElectronLikelihoodToolWrapper.h.

43 {
44 this,
45 "EGammaElectronLikelihoodTool",
46 "",
47 "Electron Likelihood Selector"
48 };

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