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
SG::ReadHandleKey< xAOD::EgammaContainerm_ContainerName
SG::ReadHandleKey< xAOD::EgammaContainerm_fudgedContainerName
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 32 of file EGElectronLikelihoodToolWrapper.h.

Member Function Documentation

◆ addBranches()

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

Definition at line 37 of file EGElectronLikelihoodToolWrapper.cxx.

38 {
39 // retrieve container
40 SG::ReadHandle<xAOD::EgammaContainer> particles;
41 if(!m_fudgedContainerName.empty()){
42 SG::ReadHandle<xAOD::EgammaContainer> fudged{ m_fudgedContainerName, ctx };
43 particles = std::move(fudged);
44 } else {
45 SG::ReadHandle<xAOD::EgammaContainer> egammas{ m_ContainerName, ctx };
46 particles = std::move(egammas);
47 }
48
49 // Decorators
50 SG::WriteDecorHandle<xAOD::EgammaContainer, char> decoratorPass{
52 };
53 SG::WriteDecorHandle<xAOD::EgammaContainer, unsigned int> decoratorIsEM{
55 };
56
57 std::unique_ptr<SG::WriteDecorHandle<xAOD::EgammaContainer, float>>
58 decoratorResult = nullptr;
59 if (m_storeTResult) {
60 decoratorResult =
61 std::make_unique<SG::WriteDecorHandle<xAOD::EgammaContainer, float>>(
63 }
64 std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, float>> decoratorMultipleOutputs{};
66 decoratorMultipleOutputs = m_decoratorMultipleOutputs.makeHandles(ctx);
67 }
68
69 // Write mask for each element and record to SG for subsequent selection
70 for (const auto& egamma : *particles) {
71 // compute the output of the selector
72 asg::AcceptData theAccept(m_tool->accept(ctx, egamma));
73 // this should work for both the
74 // cut-based and the LH selectors
75 const unsigned int isEM =
76 static_cast<unsigned int>(theAccept.getCutResultInvertedBitSet()
77 .to_ulong());
78
79 // decorate the original object
80 const xAOD::IParticle* original = m_fudgedContainerName.empty() ?
82 if (m_cut.empty()) {
83 const bool pass_selection = static_cast<bool>(theAccept);
84 decoratorPass(*original) = pass_selection ? 1 : 0;
85 } else {
86 decoratorPass(*original) = theAccept.getCutResult(m_cut) ? 1 : 0;
87 }
88 decoratorIsEM(*original) = isEM;
89 if (decoratorResult) {
90 (*decoratorResult)(*original) =
91 static_cast<float>(m_tool->calculate(ctx, egamma));
92 }
94 // calculateMultipleOutputs only supports xAOD::Electron as input
95 const xAOD::Electron *eCopy = static_cast<const xAOD::Electron *>(egamma);
96 std::vector<float> toolOutput = m_tool->calculateMultipleOutputs(ctx, eCopy);
97 for (size_t i = 0; i < toolOutput.size(); i++){
98 decoratorMultipleOutputs.at(i)(*original) = toolOutput.at(i);
99 }
100 }
101 }
102
103 return StatusCode::SUCCESS;
104 }
SG::ReadHandleKey< xAOD::EgammaContainer > m_fudgedContainerName
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
const IParticle * getOriginalObject(const IParticle &copy)
This function can be used to conveniently get a pointer back to the original object from which a copy...
Electron_v1 Electron
Definition of the current "egamma version".

◆ initialize()

StatusCode DerivationFramework::EGElectronLikelihoodToolWrapper::initialize ( )
finaloverridevirtual

Definition at line 21 of file EGElectronLikelihoodToolWrapper.cxx.

22 {
23 ATH_CHECK(m_tool.retrieve());
24
25 ATH_CHECK(m_ContainerName.initialize());
27 //
28 ATH_CHECK(m_decoratorPass.initialize());
29 ATH_CHECK(m_decoratorIsEM.initialize());
30 //
33 return StatusCode::SUCCESS;
34 }
#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 to decorate" }

Definition at line 49 of file EGElectronLikelihoodToolWrapper.h.

49 { this,
50 "ContainerName",
51 "",
52 "Input to decorate" };

◆ 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_fudgedContainerName

SG::ReadHandleKey<xAOD::EgammaContainer> DerivationFramework::EGElectronLikelihoodToolWrapper::m_fudgedContainerName
private
Initial value:
{ this,
"FudgedContainerName", "", "Input with fudge factors applied" }

Definition at line 53 of file EGElectronLikelihoodToolWrapper.h.

53 { this,
54 "FudgedContainerName", "", "Input with fudge factors applied" };

◆ 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 42 of file EGElectronLikelihoodToolWrapper.h.

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

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