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

#include <EGSelectionToolWrapper.h>

Inheritance diagram for DerivationFramework::EGSelectionToolWrapper:
Collaboration diagram for DerivationFramework::EGSelectionToolWrapper:

Public Member Functions

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

Private Attributes

ToolHandle< IAsgEGammaIsEMSelectorm_tool
ToolHandle< IElectronPhotonShowerShapeFudgeToolm_fudgeMCTool { this, "EGammaFudgeMCTool", "", "Fudging tool" }
SG::ReadHandleKey< xAOD::EgammaContainerm_ContainerName
SG::WriteDecorHandleKey< xAOD::EgammaContainerm_decoratorPass
SG::WriteDecorHandleKey< xAOD::EgammaContainerm_decoratorIsEM
Gaudi::Property< std::string > m_cut { this, "CutType", "", "cut type" }

Detailed Description

Definition at line 26 of file EGSelectionToolWrapper.h.

Member Function Documentation

◆ addBranches()

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

Definition at line 36 of file EGSelectionToolWrapper.cxx.

37{
38 // retrieve container
39 SG::ReadHandle<xAOD::EgammaContainer> particles{ m_ContainerName, ctx };
40
41 // Decorators
42 SG::WriteDecorHandle<xAOD::EgammaContainer, char> decoratorPass{
44 };
45 SG::WriteDecorHandle<xAOD::EgammaContainer, unsigned int> decoratorIsEM{
47 };
48
49 // If we're applying corrections, the correction tools will give us
50 // copies that we need to keep track of. (We want to do all the copies
51 // before we start writing decorations, to avoid warnings about having
52 // unlocked decorations in a copy).
53 // The copies we get back from the tool will have standalone aux stores.
54 // We'll put them in a DataVector to get them deleted, but we don't
55 // need to copy the aux data to the container, so construct it with
56 // @c NEVER_TRACK_INDICES.
58 if (!m_fudgeMCTool.empty()) {
59 pCopies.reserve (particles->size());
60 for (const xAOD::Egamma* par : *particles) {
62 // apply the shower shape corrections
63 CP::CorrectionCode correctionCode = CP::CorrectionCode::Ok;
64 xAOD::Egamma* pCopy = nullptr;
65 if (type == xAOD::Type::Electron) {
66 const xAOD::Electron* eg = static_cast<const xAOD::Electron*>(par);
67 xAOD::Electron* el = nullptr;
68 correctionCode = m_fudgeMCTool->correctedCopy(*eg, el);
69 pCopy = el;
70 } else {
71 const xAOD::Photon* eg = static_cast<const xAOD::Photon*>(par);
72 xAOD::Photon* ph = nullptr;
73 correctionCode = m_fudgeMCTool->correctedCopy(*eg, ph);
74 pCopy = ph;
75 }
76 if (correctionCode == CP::CorrectionCode::Ok) {
77 // all OK
78 } else if (correctionCode == CP::CorrectionCode::OutOfValidityRange) {
79 Warning(
80 "addBranches()",
81 "Current photon has no valid fudge factors due to out-of-range");
82 } else {
83 Warning(
84 "addBranches()",
85 "Unknown correction code %d from ElectronPhotonShowerShapeFudgeTool",
86 (int)correctionCode);
87 }
88 pCopies.push_back (pCopy);
89 }
90 }
91 else {
92 pCopies.resize (particles->size());
93 }
94
95 // Write mask for each element and record to SG for subsequent selection
96 for (size_t ipar = 0; const xAOD::Egamma* par : *particles) {
97 const xAOD::Egamma* pCopy = pCopies[ipar++];
98 if (!pCopy) pCopy = par;
99
100 // compute the output of the selector
101 asg::AcceptData theAccept(m_tool->accept(ctx, pCopy));
102 unsigned int isEM = (unsigned int)theAccept.getCutResultInvertedBitSet()
103 .to_ulong(); // this should work for both the
104 // cut-based and the LH selectors
105
106 // decorate the original object
107 if (m_cut == "") {
108 bool pass_selection = (bool)theAccept;
109 if (pass_selection) {
110 decoratorPass(*par) = 1;
111 } else {
112 decoratorPass(*par) = 0;
113 }
114 decoratorIsEM(*par) = isEM;
115 } else {
116 if (theAccept.getCutResult(m_cut)) {
117 decoratorPass(*par) = 1;
118 } else {
119 decoratorPass(*par) = 0;
120 }
121 decoratorIsEM(*par) = isEM;
122 }
123 }
124
125 return StatusCode::SUCCESS;
126}
@ OutOfValidityRange
Input object is out of validity range.
@ Ok
The correction was done successfully.
ToolHandle< IAsgEGammaIsEMSelector > m_tool
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorIsEM
ToolHandle< IElectronPhotonShowerShapeFudgeTool > m_fudgeMCTool
SG::ReadHandleKey< xAOD::EgammaContainer > m_ContainerName
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorPass
@ 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::EGSelectionToolWrapper::initialize ( )
finaloverridevirtual

Definition at line 18 of file EGSelectionToolWrapper.cxx.

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

Member Data Documentation

◆ m_ContainerName

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

Definition at line 45 of file EGSelectionToolWrapper.h.

45 { this,
46 "ContainerName", "", "Input" };

◆ m_cut

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

Definition at line 54 of file EGSelectionToolWrapper.h.

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

◆ m_decoratorIsEM

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

Definition at line 52 of file EGSelectionToolWrapper.h.

52 { this,
53 "decoratorIsEM", m_ContainerName, "", "" };

◆ m_decoratorPass

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

Definition at line 50 of file EGSelectionToolWrapper.h.

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

◆ m_fudgeMCTool

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

Definition at line 43 of file EGSelectionToolWrapper.h.

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

◆ m_tool

ToolHandle<IAsgEGammaIsEMSelector> DerivationFramework::EGSelectionToolWrapper::m_tool
private
Initial value:
{
this,
"EGammaSelectionTool",
"",
"Selector tool",
}

Definition at line 36 of file EGSelectionToolWrapper.h.

36 {
37 this,
38 "EGammaSelectionTool",
39 "",
40 "Selector tool",
41 };

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