ATLAS Offline Software
Loading...
Searching...
No Matches
EGPhotonCleaningWrapper.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Author: Giovanni Marchiori (giovanni.marchiori@cern.ch)
6
8#include "xAODEgamma/Photon.h"
10
11namespace DerivationFramework {
12
15{
16 if (!m_fudgeMCTool.name().empty()) {
17 CHECK(m_fudgeMCTool.retrieve());
18 }
19 ATH_CHECK(m_containerName.initialize());
20 ATH_CHECK(m_decoratorPass.initialize());
22
23 return StatusCode::SUCCESS;
24}
25
26StatusCode
27EGPhotonCleaningWrapper::addBranches(const EventContext& ctx) const
28{
29
31
32 // If we're applying corrections, the correction tools will give us
33 // copies that we need to keep track of. (We want to do all the copies
34 // before we start writing decorations, to avoid warnings about having
35 // unlocked decorations in a copy).
36 // The copies we get back from the tool will have standalone aux stores.
37 // We'll put them in a DataVector to get them deleted, but we don't
38 // need to copy the aux data to the container, so construct it with
39 // @c NEVER_TRACK_INDICES.
41 if (!m_fudgeMCTool.empty()) {
42 pCopies.reserve (photons->size());
43 for (const xAOD::Photon* photon : *photons) {
44 // apply the shower shape corrections
46 xAOD::Photon* ph = nullptr;
47 correctionCode = m_fudgeMCTool->correctedCopy(*photon, ph);
48 if (correctionCode == CP::CorrectionCode::Ok) {
49 } else if (correctionCode == CP::CorrectionCode::Error) {
50 Error("addBranches()",
51 "Error applying fudge factors to current photon");
52 } else if (correctionCode == CP::CorrectionCode::OutOfValidityRange) {
53 Warning(
54 "addBranches()",
55 "Current photon has no valid fudge factors due to out-of-range");
56 } else {
57 Warning("addBranches()",
58 "Unknown correction code %d from "
59 "ElectronPhotonShowerShapeFudgeTool",
60 (int)correctionCode);
61 }
62 pCopies.push_back (ph);
63 }
64 }
65 else {
66 pCopies.resize (photons->size());
67 }
68
71 };
74 };
75
76 // Write mask for each element and record to SG for subsequent selection
77 for (size_t ipar = 0; const xAOD::Photon* photon : *photons) {
78
79 const xAOD::Photon* pCopy = pCopies[ipar++];
80 if (!pCopy) pCopy = photon;
81
82 // decorate the original object
83 decoratorPass(*photon) = static_cast<int> (PhotonHelpers::passOQquality(*pCopy));
84 decoratorPassDelayed(*photon) = static_cast<int> (PhotonHelpers::passOQqualityDelayed(*pCopy));
85 }
86 return StatusCode::SUCCESS;
87}
88} // end namespace DerivationFramework
#define ATH_CHECK
Evaluate an expression and check for errors.
#define CHECK(...)
Evaluate an expression and check for errors.
Return value from object correction CP tools.
@ Error
Some error happened during the object correction.
@ OutOfValidityRange
Input object is out of validity range.
@ Ok
The correction was done successfully.
void resize(size_type sz)
Resizes the collection to the specified number of elements.
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::WriteDecorHandleKey< xAOD::PhotonContainer > m_decoratorPassDelayed
SG::WriteDecorHandleKey< xAOD::PhotonContainer > m_decoratorPass
SG::ReadHandleKey< xAOD::PhotonContainer > m_containerName
ToolHandle< IElectronPhotonShowerShapeFudgeTool > m_fudgeMCTool
virtual StatusCode addBranches(const EventContext &ctx) const override final
Handle class for adding a decoration to an object.
THE reconstruction tool.
::StatusCode StatusCode
StatusCode definition for legacy code.
bool passOQqualityDelayed(const xAOD::Photon &ph)
Helpers to ease the implementation of the pass Quality requirements.
bool passOQquality(const xAOD::Photon &ph)
Helper to ease the implemmantation of the pass Quality requirements.
@ NEVER_TRACK_INDICES
Never track indices, regardless of the setting of the ownership policy.
@ OWN_ELEMENTS
this data object owns its elements
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
Photon_v1 Photon
Definition of the current "egamma version".