ATLAS Offline Software
EGPhotonCleaningWrapper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // EGPhotonCleaningWrapper.cxx, (c) ATLAS Detector software
8 // Author: Giovanni Marchiori (giovanni.marchiori@cern.ch)
9 //
10 
12 #include "xAODEgamma/Photon.h"
14 
15 namespace DerivationFramework {
16 
18  const std::string& n,
19  const IInterface* p)
20  : AthAlgTool(t, n, p)
21  , m_sgName("DFCommonPhotonsCleaning")
22 {
23  declareInterface<DerivationFramework::IAugmentationTool>(this);
24  declareProperty("StoreGateEntryName", m_sgName);
25 }
26 
29 {
30  if (m_sgName.empty()) {
32  "No SG name provided for the output of EGPhotonCleaningWrapper");
33  return StatusCode::FAILURE;
34  }
35  if (!m_fudgeMCTool.name().empty()) {
36  CHECK(m_fudgeMCTool.retrieve());
37  }
38  ATH_CHECK(m_containerName.initialize());
40  m_decoratorPassDelayed = m_containerName.key() + "." + m_sgName + "NoTime";
41  ATH_CHECK(m_decoratorPass.initialize());
42  ATH_CHECK(m_decoratorPassDelayed.initialize());
43 
44  return StatusCode::SUCCESS;
45 }
46 
49 {
50 
51  const EventContext& ctx = Gaudi::Hive::currentContext();
54  m_decoratorPass, ctx
55  };
58  };
59 
60  // Write mask for each element and record to SG for subsequent selection
61  for (const xAOD::Photon* photon : *photons) {
62 
63  bool passSelection = false;
64  bool passSelectionDelayed = false;
65  bool applyFF = (!m_fudgeMCTool.empty());
66 
67  if (!applyFF) {
68  passSelection = PhotonHelpers::passOQquality(*photon);
69  passSelectionDelayed = PhotonHelpers::passOQqualityDelayed(*photon);
70  } else {
71  // apply the shower shape corrections
73  xAOD::Photon* ph = nullptr;
74  correctionCode = m_fudgeMCTool->correctedCopy(*photon, ph);
75  if (correctionCode == CP::CorrectionCode::Ok) {
76  passSelection = PhotonHelpers::passOQquality(*ph);
77  passSelectionDelayed = PhotonHelpers::passOQqualityDelayed(*ph);
78  } else if (correctionCode == CP::CorrectionCode::Error) {
79  Error("addBranches()",
80  "Error applying fudge factors to current photon");
81  } else if (correctionCode == CP::CorrectionCode::OutOfValidityRange) {
82  Warning(
83  "addBranches()",
84  "Current photon has no valid fudge factors due to out-of-range");
85  } else {
86  Warning("addBranches()",
87  "Unknown correction code %d from "
88  "ElectronPhotonShowerShapeFudgeTool",
89  (int)correctionCode);
90  }
91  delete ph;
92  }
93 
94  // decorate the original object
95  if (passSelection) {
96  decoratorPass(*photon) = 1;
97  } else {
98  decoratorPass(*photon) = 0;
99  }
100  if (passSelectionDelayed) {
101  decoratorPassDelayed(*photon) = 1;
102  } else {
103  decoratorPassDelayed(*photon) = 0;
104  }
105  }
106  return StatusCode::SUCCESS;
107 }
108 } // end namespace DerivationFramework
DerivationFramework::EGPhotonCleaningWrapper::m_fudgeMCTool
ToolHandle< IElectronPhotonShowerShapeFudgeTool > m_fudgeMCTool
Definition: EGPhotonCleaningWrapper.h:40
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
PhotonHelpers.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
DerivationFramework::EGPhotonCleaningWrapper::m_decoratorPass
SG::WriteDecorHandleKey< xAOD::PhotonContainer > m_decoratorPass
Definition: EGPhotonCleaningWrapper.h:53
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
PhotonHelpers::passOQquality
bool passOQquality(const xAOD::Photon &ph)
Helper to ease the implemmantation of the pass Quality requirements.
Definition: PhotonHelpers.cxx:12
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
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DerivationFramework::EGPhotonCleaningWrapper::initialize
virtual StatusCode initialize() override final
Definition: EGPhotonCleaningWrapper.cxx:28
beamspotman.n
n
Definition: beamspotman.py:731
Photon.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:99
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
DerivationFramework::EGPhotonCleaningWrapper::addBranches
virtual StatusCode addBranches() const override final
Pass the thinning service
Definition: EGPhotonCleaningWrapper.cxx:48
DerivationFramework::EGPhotonCleaningWrapper::m_decoratorPassDelayed
SG::WriteDecorHandleKey< xAOD::PhotonContainer > m_decoratorPassDelayed
Definition: EGPhotonCleaningWrapper.h:55
EGPhotonCleaningWrapper.h
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
xAOD::photon
@ photon
Definition: TrackingPrimitives.h:199
xAOD::Photon_v1
Definition: Photon_v1.h:37
DerivationFramework::EGPhotonCleaningWrapper::EGPhotonCleaningWrapper
EGPhotonCleaningWrapper(const std::string &t, const std::string &n, const IInterface *p)
Definition: EGPhotonCleaningWrapper.cxx:17
DerivationFramework::EGPhotonCleaningWrapper::m_containerName
SG::ReadHandleKey< xAOD::PhotonContainer > m_containerName
Definition: EGPhotonCleaningWrapper.h:46
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
PhotonHelpers::passOQqualityDelayed
bool passOQqualityDelayed(const xAOD::Photon &ph)
Helpers to ease the implementation of the pass Quality requirements.
Definition: PhotonHelpers.cxx:29
AthAlgTool
Definition: AthAlgTool.h:26
DerivationFramework::EGPhotonCleaningWrapper::m_sgName
std::string m_sgName
Definition: EGPhotonCleaningWrapper.h:56