ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
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
40 
41  // Decorators
43  m_decoratorPass, ctx
44  };
46  m_decoratorIsEM, ctx
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
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 }

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

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.

◆ m_cut

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

Definition at line 54 of file EGSelectionToolWrapper.h.

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

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

◆ m_fudgeMCTool

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

Definition at line 43 of file EGSelectionToolWrapper.h.

◆ m_tool

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

Definition at line 36 of file EGSelectionToolWrapper.h.


The documentation for this class was generated from the following files:
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::EGSelectionToolWrapper::m_decoratorIsEM
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorIsEM
Definition: EGSelectionToolWrapper.h:52
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
DerivationFramework::EGSelectionToolWrapper::m_decoratorPass
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorPass
Definition: EGSelectionToolWrapper.h:50
DerivationFramework::EGSelectionToolWrapper::m_tool
ToolHandle< IAsgEGammaIsEMSelector > m_tool
Definition: EGSelectionToolWrapper.h:36
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
DerivationFramework::EGSelectionToolWrapper::m_cut
Gaudi::Property< std::string > m_cut
Definition: EGSelectionToolWrapper.h:54
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition: CorrectionCode.h:37
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition: OwnershipPolicy.h:17
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:54
DataVector
Derived DataVector<T>.
Definition: DataVector.h:795
DerivationFramework::EGSelectionToolWrapper::m_ContainerName
SG::ReadHandleKey< xAOD::EgammaContainer > m_ContainerName
Definition: EGSelectionToolWrapper.h:45
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:28
xAOD::Electron_v1
Definition: Electron_v1.h:34
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
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::EGSelectionToolWrapper::m_fudgeMCTool
ToolHandle< IElectronPhotonShowerShapeFudgeTool > m_fudgeMCTool
Definition: EGSelectionToolWrapper.h:43
asg::AcceptData
Definition: AcceptData.h:30
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60