ATLAS Offline Software
Loading...
Searching...
No Matches
EGSelectionToolWrapper.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Author: Giovanni Marchiori (giovanni.marchiori@cern.ch)
6//
7
13#include "xAODEgamma/Electron.h"
14#include "xAODEgamma/Photon.h"
15
16namespace DerivationFramework {
17
20{
21 ATH_CHECK(m_tool.retrieve());
22
23 ATH_CHECK(m_ContainerName.initialize());
25
26 ATH_CHECK(m_decoratorPass.initialize());
27 ATH_CHECK(m_decoratorIsEM.initialize());
28
29 return StatusCode::SUCCESS;
30}
31
32StatusCode
33EGSelectionToolWrapper::addBranches(const EventContext& ctx) const
34{
35 // retrieve container
37 if(!m_fudgedContainerName.empty()){
39 particles = std::move(fudged);
40 } else {
42 particles = std::move(egammas);
43 }
44
45 // Decorators
48 };
51 };
52
53 for (const auto& egamma : *particles) {
54 // compute the output of the selector with the fudged object
55 asg::AcceptData theAccept(m_tool->accept(ctx, egamma));
56 // this should work for both the
57 // cut-based and the LH selectors
58 unsigned int isEM =
59 static_cast<unsigned int>(theAccept.getCutResultInvertedBitSet()
60 .to_ulong());
61
62 // decorate the original object
63 const xAOD::IParticle* original = m_fudgedContainerName.empty() ?
65 if (m_cut == "") {
66 bool pass_selection = static_cast<bool>(theAccept);
67 decoratorPass(*original) = pass_selection ? 1 : 0;
68 } else {
69 decoratorPass(*original) = theAccept.getCutResult(m_cut) ? 1 : 0;
70 }
71 decoratorIsEM(*original) = isEM;
72 }
73
74 return StatusCode::SUCCESS;
75}
76}
#define ATH_CHECK
Evaluate an expression and check for errors.
virtual StatusCode initialize() override final
ToolHandle< IAsgEGammaIsEMSelector > m_tool
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorIsEM
SG::ReadHandleKey< xAOD::EgammaContainer > m_ContainerName
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorPass
SG::ReadHandleKey< xAOD::EgammaContainer > m_fudgedContainerName
virtual StatusCode addBranches(const EventContext &ctx) const override final
Handle class for adding a decoration to an object.
std::bitset< NBITS > getCutResultInvertedBitSet() const
Get an inverted bitset of the cut result.
Definition AcceptData.h:120
bool getCutResult(std::string_view cutName) const
Get the result of a cut, based on the cut name (safer).
Definition AcceptData.h:99
elec/gamma data class.
Definition egamma.h:59
Class providing the definition of the 4-vector interface.
THE reconstruction tool.
::StatusCode StatusCode
StatusCode definition for legacy code.
const IParticle * getOriginalObject(const IParticle &copy)
This function can be used to conveniently get a pointer back to the original object from which a copy...