ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
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
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
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
96  m_decoratorPass, ctx
97  };
99  m_decoratorIsEM, ctx
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  }

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

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.

◆ m_cut

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

Definition at line 66 of file EGElectronLikelihoodToolWrapper.h.

◆ m_decoratorIsEM

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

Definition at line 61 of file EGElectronLikelihoodToolWrapper.h.

◆ m_decoratorMultipleOutputs

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

Definition at line 65 of file EGElectronLikelihoodToolWrapper.h.

◆ m_decoratorPass

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

Definition at line 59 of file EGElectronLikelihoodToolWrapper.h.

◆ m_decoratorResult

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

Definition at line 63 of file EGElectronLikelihoodToolWrapper.h.

◆ m_fudgeMCTool

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

Definition at line 50 of file EGElectronLikelihoodToolWrapper.h.

◆ m_storeMultipleOutputs

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

Definition at line 68 of file EGElectronLikelihoodToolWrapper.h.

◆ m_storeTResult

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

Definition at line 67 of file EGElectronLikelihoodToolWrapper.h.

◆ m_tool

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

Definition at line 43 of file EGElectronLikelihoodToolWrapper.h.


The documentation for this class was generated from the following files:
DerivationFramework::EGElectronLikelihoodToolWrapper::m_fudgeMCTool
ToolHandle< IElectronPhotonShowerShapeFudgeTool > m_fudgeMCTool
Definition: EGElectronLikelihoodToolWrapper.h:50
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
ParticleTest.eg
eg
Definition: ParticleTest.py:29
ObjectType
ObjectType
Definition: BaseObject.h:11
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
SG::NEVER_TRACK_INDICES
@ NEVER_TRACK_INDICES
Never track indices, regardless of the setting of the ownership policy.
Definition: IndexTrackingPolicy.h:46
DerivationFramework::EGElectronLikelihoodToolWrapper::m_decoratorIsEM
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorIsEM
Definition: EGElectronLikelihoodToolWrapper.h:61
DerivationFramework::EGElectronLikelihoodToolWrapper::m_storeTResult
Gaudi::Property< bool > m_storeTResult
Definition: EGElectronLikelihoodToolWrapper.h:67
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition: CorrectionCode.h:37
CP::CorrectionCode::Error
@ Error
Some error happened during the object correction.
Definition: CorrectionCode.h:36
lumiFormat.i
int i
Definition: lumiFormat.py:85
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition: OwnershipPolicy.h:17
DerivationFramework::EGElectronLikelihoodToolWrapper::m_decoratorPass
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorPass
Definition: EGElectronLikelihoodToolWrapper.h:59
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
python.getProblemFolderFromLogs.el
dictionary el
Definition: getProblemFolderFromLogs.py:48
DerivationFramework::EGElectronLikelihoodToolWrapper::m_ContainerName
SG::ReadHandleKey< xAOD::EgammaContainer > m_ContainerName
Definition: EGElectronLikelihoodToolWrapper.h:52
DataVector
Derived DataVector<T>.
Definition: DataVector.h:795
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:28
DerivationFramework::EGElectronLikelihoodToolWrapper::m_decoratorResult
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorResult
Definition: EGElectronLikelihoodToolWrapper.h:63
xAOD::Electron_v1
Definition: Electron_v1.h:34
DerivationFramework::EGElectronLikelihoodToolWrapper::m_tool
ToolHandle< IAsgElectronLikelihoodTool > m_tool
Definition: EGElectronLikelihoodToolWrapper.h:43
DerivationFramework::EGElectronLikelihoodToolWrapper::m_decoratorMultipleOutputs
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainer, float > m_decoratorMultipleOutputs
Definition: EGElectronLikelihoodToolWrapper.h:65
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
DerivationFramework::EGElectronLikelihoodToolWrapper::m_cut
Gaudi::Property< std::string > m_cut
Definition: EGElectronLikelihoodToolWrapper.h:66
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
xAOD::Photon_v1
Definition: Photon_v1.h:37
DerivationFramework::EGElectronLikelihoodToolWrapper::m_storeMultipleOutputs
Gaudi::Property< bool > m_storeMultipleOutputs
Definition: EGElectronLikelihoodToolWrapper.h:68
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16
asg::AcceptData
Definition: AcceptData.h:30
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60