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

 EGSelectionToolWrapper (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< IAsgEGammaIsEMSelectorm_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", "", "" }
 
Gaudi::Property< std::string > m_cut { this, "CutType", "", "cut type" }
 
Gaudi::Property< std::string > m_sgName
 

Detailed Description

Definition at line 30 of file EGSelectionToolWrapper.h.

Constructor & Destructor Documentation

◆ EGSelectionToolWrapper()

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

Definition at line 20 of file EGSelectionToolWrapper.cxx.

23  : base_class(t, n, p)
24 {
25 }

Member Function Documentation

◆ addBranches()

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

Definition at line 54 of file EGSelectionToolWrapper.cxx.

55 {
56  // retrieve container
57  const EventContext& ctx = Gaudi::Hive::currentContext();
59 
60  // Decorators
62  m_decoratorPass, ctx
63  };
65  m_decoratorIsEM, ctx
66  };
67 
68  // If we're applying corrections, the correction tools will give us
69  // copies that we need to keep track of. (We want to do all the copies
70  // before we start writing decorations, to avoid warnings about having
71  // unlocked decorations in a copy).
72  // The copies we get back from the tool will have standalone aux stores.
73  // We'll put them in a DataVector to get them deleted, but we don't
74  // need to copy the aux data to the container, so construct it with
75  // @c NEVER_TRACK_INDICES.
77  if (!m_fudgeMCTool.empty()) {
78  pCopies.reserve (particles->size());
79  for (const xAOD::Egamma* par : *particles) {
81  // apply the shower shape corrections
83  xAOD::Egamma* pCopy = nullptr;
84  if (type == xAOD::Type::Electron) {
85  const xAOD::Electron* eg = static_cast<const xAOD::Electron*>(par);
86  xAOD::Electron* el = nullptr;
87  correctionCode = m_fudgeMCTool->correctedCopy(*eg, el);
88  pCopy = el;
89  } else {
90  const xAOD::Photon* eg = static_cast<const xAOD::Photon*>(par);
91  xAOD::Photon* ph = nullptr;
92  correctionCode = m_fudgeMCTool->correctedCopy(*eg, ph);
93  pCopy = ph;
94  }
95  if (correctionCode == CP::CorrectionCode::Ok) {
96  // all OK
97  } else if (correctionCode == CP::CorrectionCode::OutOfValidityRange) {
98  Warning(
99  "addBranches()",
100  "Current photon has no valid fudge factors due to out-of-range");
101  } else {
102  Warning(
103  "addBranches()",
104  "Unknown correction code %d from ElectronPhotonShowerShapeFudgeTool",
105  (int)correctionCode);
106  }
107  pCopies.push_back (pCopy);
108  }
109  }
110  else {
111  pCopies.resize (particles->size());
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 
119  // compute the output of the selector
120  asg::AcceptData theAccept(m_tool->accept(ctx, pCopy));
121  unsigned int isEM = (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 == "") {
127  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  } else {
135  if (theAccept.getCutResult(m_cut)) {
136  decoratorPass(*par) = 1;
137  } else {
138  decoratorPass(*par) = 0;
139  }
140  decoratorIsEM(*par) = isEM;
141  }
142  }
143 
144  return StatusCode::SUCCESS;
145 }

◆ initialize()

StatusCode DerivationFramework::EGSelectionToolWrapper::initialize ( )
finaloverridevirtual

Definition at line 28 of file EGSelectionToolWrapper.cxx.

29 {
30  if (m_sgName.empty()) {
32  "No SG name provided for the output of EGElectronLikelihoodToolWrapper!");
33  return StatusCode::FAILURE;
34  }
35  ATH_CHECK(m_tool.retrieve());
36 
37  if (!(m_fudgeMCTool.name().empty())) {
38  ATH_CHECK(m_fudgeMCTool.retrieve());
39  } else {
40  m_fudgeMCTool.disable();
41  }
42 
43  ATH_CHECK(m_ContainerName.initialize());
44  //
46  m_decoratorIsEM = m_ContainerName.key() + "." + m_sgName + "IsEMValue";
47  ATH_CHECK(m_decoratorPass.initialize());
48  ATH_CHECK(m_decoratorIsEM.initialize());
49 
50  return StatusCode::SUCCESS;
51 }

Member Data Documentation

◆ m_ContainerName

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

Definition at line 50 of file EGSelectionToolWrapper.h.

◆ m_cut

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

Definition at line 62 of file EGSelectionToolWrapper.h.

◆ m_decoratorIsEM

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

Definition at line 61 of file EGSelectionToolWrapper.h.

◆ m_decoratorPass

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

Definition at line 59 of file EGSelectionToolWrapper.h.

◆ m_fudgeMCTool

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

Definition at line 48 of file EGSelectionToolWrapper.h.

◆ m_sgName

Gaudi::Property<std::string> DerivationFramework::EGSelectionToolWrapper::m_sgName
private
Initial value:
{ this,
"StoreGateEntryName",
"",
"Store entry name" }

Definition at line 64 of file EGSelectionToolWrapper.h.

◆ m_tool

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

Definition at line 41 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:61
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
DerivationFramework::EGSelectionToolWrapper::m_decoratorPass
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorPass
Definition: EGSelectionToolWrapper.h:59
DerivationFramework::EGSelectionToolWrapper::m_tool
ToolHandle< IAsgEGammaIsEMSelector > m_tool
Definition: EGSelectionToolWrapper.h:41
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
DerivationFramework::EGSelectionToolWrapper::m_cut
Gaudi::Property< std::string > m_cut
Definition: EGSelectionToolWrapper.h:62
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition: CorrectionCode.h:37
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition: OwnershipPolicy.h:17
DerivationFramework::EGSelectionToolWrapper::m_sgName
Gaudi::Property< std::string > m_sgName
Definition: EGSelectionToolWrapper.h:64
beamspotman.n
n
Definition: beamspotman.py:731
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
DerivationFramework::EGSelectionToolWrapper::m_ContainerName
SG::ReadHandleKey< xAOD::EgammaContainer > m_ContainerName
Definition: EGSelectionToolWrapper.h:50
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
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:48
asg::AcceptData
Definition: AcceptData.h:30
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60