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

 EGElectronLikelihoodToolWrapper (const std::string &t, const std::string &n, const IInterface *p)
 
virtual StatusCode initialize () override final
 
virtual StatusCode addBranches () 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", "", "" }
 
SG::WriteDecorHandleKey< xAOD::EgammaContainerm_decoratorIsEM { this, "decoratorIsEM", "", "" }
 
SG::WriteDecorHandleKey< xAOD::EgammaContainerm_decoratorResult { this, "decoratorResult", "", "" }
 
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainer, float > m_decoratorMultipleOutputs {this, "decoratorMultipleOutputs", {}, ""}
 
std::string m_cut
 
std::string m_sgName
 
bool m_storeTResult
 
std::vector< std::string > m_sgMultipleNames
 
bool m_storeMultipleOutputs
 

Detailed Description

Definition at line 36 of file EGElectronLikelihoodToolWrapper.h.

Constructor & Destructor Documentation

◆ EGElectronLikelihoodToolWrapper()

DerivationFramework::EGElectronLikelihoodToolWrapper::EGElectronLikelihoodToolWrapper ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Definition at line 22 of file EGElectronLikelihoodToolWrapper.cxx.

26  : base_class(t, n, p)
27  , m_cut("")
28  , m_sgName("")
29  , m_storeTResult(false)
30  , m_sgMultipleNames({})
31  , m_storeMultipleOutputs(false)
32 {
33  declareProperty("CutType", m_cut);
34  declareProperty("StoreGateEntryName", m_sgName);
35  declareProperty("StoreTResult", m_storeTResult);
36  declareProperty("StoreGateEntryMultipleNames", m_sgMultipleNames);
37  declareProperty("StoreMultipleOutputs", m_storeMultipleOutputs);
38 }

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::EGElectronLikelihoodToolWrapper::addBranches ( ) const
finaloverridevirtual

Definition at line 77 of file EGElectronLikelihoodToolWrapper.cxx.

78 {
79  // retrieve container
80  const EventContext& ctx = Gaudi::Hive::currentContext();
82 
83  // If we're applying corrections, the correction tools will give us
84  // copies that we need to keep track of. (We want to do all the copies
85  // before we start writing decorations, to avoid warnings about having
86  // unlocked decorations in a copy).
87  // The copies we get back from the tool will have standalone aux stores.
88  // We'll put them in a DataVector to get them deleted, but we don't
89  // need to copy the aux data to the container, so construct it with
90  // @c NEVER_TRACK_INDICES.
92  if (!m_fudgeMCTool.empty()) {
93  pCopies.reserve (particles->size());
94  for (const xAOD::Egamma* par : *particles) {
96  // apply the shower shape corrections
98  xAOD::Egamma* pCopy = nullptr;
99  if (type == xAOD::Type::Electron) {
100  const xAOD::Electron* eg = static_cast<const xAOD::Electron*>(par);
101  xAOD::Electron* el = nullptr;
102  correctionCode = m_fudgeMCTool->correctedCopy(*eg, el);
103  pCopy = el;
104  } else {
105  const xAOD::Photon* eg = static_cast<const xAOD::Photon*>(par);
106  xAOD::Photon* ph = nullptr;
107  correctionCode = m_fudgeMCTool->correctedCopy(*eg, ph);
108  pCopy = ph;
109  }
110  if (correctionCode == CP::CorrectionCode::Ok) { // All OK
111  } else if (correctionCode == CP::CorrectionCode::Error) {
112  Error("addBranches()",
113  "Error applying fudge factors to current photon");
114  } else if (correctionCode == CP::CorrectionCode::OutOfValidityRange) {
115  Warning(
116  "addBranches()",
117  "Current object has no valid fudge factors due to out-of-range");
118  } else {
119  Warning(
120  "addBranches()",
121  "Unknown correction code %d from ElectronPhotonShowerShapeFudgeTool",
122  (int)correctionCode);
123  }
124  pCopies.push_back (pCopy);
125  }
126  }
127  else {
128  pCopies.resize (particles->size());
129  }
130 
131  // Decorators
133  m_decoratorPass, ctx
134  };
136  m_decoratorIsEM, ctx
137  };
138 
139  std::unique_ptr<SG::WriteDecorHandle<xAOD::EgammaContainer, float>>
140  decoratorResult = nullptr;
141  if (m_storeTResult) {
142  decoratorResult =
143  std::make_unique<SG::WriteDecorHandle<xAOD::EgammaContainer, float>>(
144  m_decoratorResult, ctx);
145  }
146 
147  auto decoratorMultipleOutputs = m_decoratorMultipleOutputs.makeHandles();
148 
149  // Write mask for each element and record to SG for subsequent selection
150  for (size_t ipar = 0; const xAOD::Egamma* par : *particles) {
151  const xAOD::Egamma* pCopy = pCopies[ipar++];
152  if (!pCopy) pCopy = par;
153  // compute the output of the selector
154  asg::AcceptData theAccept(m_tool->accept(ctx, pCopy));
155  const unsigned int isEM =
156  (unsigned int)theAccept.getCutResultInvertedBitSet()
157  .to_ulong(); // this should work for both the
158  // cut-based and the LH selectors
159 
160  // decorate the original object
161  if (m_cut.empty()) {
162  const bool pass_selection = (bool)theAccept;
163  if (pass_selection) {
164  decoratorPass(*par) = 1;
165  } else {
166  decoratorPass(*par) = 0;
167  }
168  decoratorIsEM(*par) = isEM;
169  if (decoratorResult) {
170  (*decoratorResult)(*par) =
171  static_cast<float>(m_tool->calculate(ctx, pCopy));
172  }
174  // calculateMultipleOutputs only supports xAOD::Electron as input
175  const xAOD::Electron *eCopy = static_cast<const xAOD::Electron *>(pCopy);
176  std::vector<float> toolOutput = m_tool->calculateMultipleOutputs(ctx, eCopy);
177  for (size_t i = 0; i < toolOutput.size(); i++){
178  decoratorMultipleOutputs.at(i)(*par) = toolOutput.at(i);
179  }
180  }
181  } else {
182  if (theAccept.getCutResult(m_cut)) {
183  decoratorPass(*par) = 1;
184  } else {
185  decoratorPass(*par) = 0;
186  }
187  decoratorIsEM(*par) = isEM;
188  if (decoratorResult) {
189  static const SG::AuxElement::Decorator<float> decResult(m_sgName +
190  "Result");
191  (*decoratorResult)(*par) =
192  static_cast<float>(m_tool->calculate(ctx, pCopy));
193  }
195  // calculateMultipleOutputs only supports xAOD::Electron as input
196  const xAOD::Electron* eCopy = static_cast<const xAOD::Electron*>(pCopy);
197  std::vector<float> toolOutput = m_tool->calculateMultipleOutputs(ctx, eCopy);
198  for (size_t i = 0; i < toolOutput.size(); i++){
199  decoratorMultipleOutputs.at(i)(*par) = toolOutput.at(i);
200  }
201  }
202  }
203  }
204 
205  return StatusCode::SUCCESS;
206 }

◆ initialize()

StatusCode DerivationFramework::EGElectronLikelihoodToolWrapper::initialize ( )
finaloverridevirtual

Definition at line 41 of file EGElectronLikelihoodToolWrapper.cxx.

42 {
43  if (m_sgName.empty()) {
45  "No SG name provided for the output of EGElectronLikelihoodToolWrapper!");
46  return StatusCode::FAILURE;
47  }
48  ATH_CHECK(m_tool.retrieve());
49 
50  if (!(m_fudgeMCTool.name().empty())) {
51  ATH_CHECK(m_fudgeMCTool.retrieve());
52  } else {
53  m_fudgeMCTool.disable();
54  }
55 
56  ATH_CHECK(m_ContainerName.initialize());
57  //
59  m_decoratorIsEM = m_ContainerName.key() + "." + m_sgName + "IsEMValue";
60  ATH_CHECK(m_decoratorPass.initialize());
61  ATH_CHECK(m_decoratorIsEM.initialize());
62  //
63  if (m_storeTResult) {
64  m_decoratorResult = m_ContainerName.key() + "." + m_sgName + "Result";
66  }
68  for (auto& sgName : m_sgMultipleNames) {
69  m_decoratorMultipleOutputs.emplace_back(m_ContainerName.key() + "." + sgName);
70  }
72  }
73  return StatusCode::SUCCESS;
74 }

Member Data Documentation

◆ m_ContainerName

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

Definition at line 56 of file EGElectronLikelihoodToolWrapper.h.

◆ m_cut

std::string DerivationFramework::EGElectronLikelihoodToolWrapper::m_cut
private

Definition at line 70 of file EGElectronLikelihoodToolWrapper.h.

◆ m_decoratorIsEM

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

Definition at line 65 of file EGElectronLikelihoodToolWrapper.h.

◆ m_decoratorMultipleOutputs

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

Definition at line 69 of file EGElectronLikelihoodToolWrapper.h.

◆ m_decoratorPass

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

Definition at line 63 of file EGElectronLikelihoodToolWrapper.h.

◆ m_decoratorResult

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

Definition at line 67 of file EGElectronLikelihoodToolWrapper.h.

◆ m_fudgeMCTool

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

Definition at line 54 of file EGElectronLikelihoodToolWrapper.h.

◆ m_sgMultipleNames

std::vector<std::string> DerivationFramework::EGElectronLikelihoodToolWrapper::m_sgMultipleNames
private

Definition at line 73 of file EGElectronLikelihoodToolWrapper.h.

◆ m_sgName

std::string DerivationFramework::EGElectronLikelihoodToolWrapper::m_sgName
private

Definition at line 71 of file EGElectronLikelihoodToolWrapper.h.

◆ m_storeMultipleOutputs

bool DerivationFramework::EGElectronLikelihoodToolWrapper::m_storeMultipleOutputs
private

Definition at line 74 of file EGElectronLikelihoodToolWrapper.h.

◆ m_storeTResult

bool DerivationFramework::EGElectronLikelihoodToolWrapper::m_storeTResult
private

Definition at line 72 of file EGElectronLikelihoodToolWrapper.h.

◆ m_tool

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

Definition at line 47 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:54
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
DerivationFramework::EGElectronLikelihoodToolWrapper::m_sgName
std::string m_sgName
Definition: EGElectronLikelihoodToolWrapper.h:71
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:65
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
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
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
lumiFormat.i
int i
Definition: lumiFormat.py:85
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition: OwnershipPolicy.h:17
beamspotman.n
n
Definition: beamspotman.py:731
DerivationFramework::EGElectronLikelihoodToolWrapper::m_decoratorPass
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorPass
Definition: EGElectronLikelihoodToolWrapper.h:63
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
python.LArMinBiasAlgConfig.int
int
Definition: LArMinBiasAlgConfig.py:59
DerivationFramework::EGElectronLikelihoodToolWrapper::m_storeTResult
bool m_storeTResult
Definition: EGElectronLikelihoodToolWrapper.h:72
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
DerivationFramework::EGElectronLikelihoodToolWrapper::m_storeMultipleOutputs
bool m_storeMultipleOutputs
Definition: EGElectronLikelihoodToolWrapper.h:74
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::EGElectronLikelihoodToolWrapper::m_cut
std::string m_cut
Definition: EGElectronLikelihoodToolWrapper.h:70
DerivationFramework::EGElectronLikelihoodToolWrapper::m_ContainerName
SG::ReadHandleKey< xAOD::EgammaContainer > m_ContainerName
Definition: EGElectronLikelihoodToolWrapper.h:56
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
DerivationFramework::EGElectronLikelihoodToolWrapper::m_decoratorResult
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorResult
Definition: EGElectronLikelihoodToolWrapper.h:67
xAOD::Electron_v1
Definition: Electron_v1.h:34
DerivationFramework::EGElectronLikelihoodToolWrapper::m_tool
ToolHandle< IAsgElectronLikelihoodTool > m_tool
Definition: EGElectronLikelihoodToolWrapper.h:47
DerivationFramework::EGElectronLikelihoodToolWrapper::m_decoratorMultipleOutputs
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainer, float > m_decoratorMultipleOutputs
Definition: EGElectronLikelihoodToolWrapper.h:69
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
xAOD::Photon_v1
Definition: Photon_v1.h:37
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
DerivationFramework::EGElectronLikelihoodToolWrapper::m_sgMultipleNames
std::vector< std::string > m_sgMultipleNames
Definition: EGElectronLikelihoodToolWrapper.h:73
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