ATLAS Offline Software
Loading...
Searching...
No Matches
TrigEgammaTLAPhotonHypoAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
11
12using namespace TrigCompositeUtils;
13
15
16
17TrigEgammaTLAPhotonHypoAlg::TrigEgammaTLAPhotonHypoAlg( const std::string& name, ISvcLocator* pSvcLocator ) :
18 :: HypoBase (name, pSvcLocator) {}
19
20
22
23 ATH_CHECK( m_hypoTools.retrieve() );
24 ATH_CHECK( m_TLAPhotonsKey.initialize() );
25
26 ATH_MSG_DEBUG("Initializing TrigEgammaTLAPhotonHypoAlg");
27 return StatusCode::SUCCESS;
28
29}
30
31StatusCode TrigEgammaTLAPhotonHypoAlg::execute( const EventContext& ctx) const
32{
33 ATH_MSG_DEBUG("Executing " << name() << "...");
34
35 ATH_MSG_DEBUG("Retrieving 'HLT' decision\" " << decisionInput().key() << "\"");
36
37
38 // create handles for TLA photons
40 //make the output photon container
41 ATH_CHECK(h_TLAPhotons.record(std::make_unique<xAOD::PhotonContainer>(),
42 std::make_unique<xAOD::PhotonAuxContainer>()));
43
44
45 // retrieves the HLT decision container for the TLA photons
46 auto previousDecisionHandle = SG::makeHandle(decisionInput(), ctx);
47 ATH_CHECK(previousDecisionHandle.isValid());
48
49
50 // get a pointer to the TLA Photons
51 ATH_MSG_DEBUG("Retrieving photons from the TLA container \"" <<m_TLAPhotonsKey << "\" ");
52
53
54 // creates (via SG handle) a DecisionContainer for the output decision
56 DecisionContainer* outputDecisions = outputHandle.ptr();
57
58 // loops over previous decisions
59 int nDecision = 0;
60 for (const auto previousDecision : *previousDecisionHandle)
61 {
62
63 // get photons from the decision
64 const xAOD::Photon *photonPrev = nullptr;
66 ATH_MSG_DEBUG("This decision has " << prevPhotons.size() << " photons");
67
68
69 if (prevPhotons.size() != 1) {
70 ATH_MSG_ERROR("Did not locate exactly one photon for this Decision Object, found " << prevPhotons.size());
71 return StatusCode::FAILURE;
72 }
73
74
75 auto prevPhotonLink = prevPhotons.at(0).link;
76 ATH_CHECK(prevPhotonLink.isValid());
77 photonPrev = *prevPhotonLink;
78
79 xAOD::Photon *copiedPhoton = new xAOD::Photon();
80 h_TLAPhotons->push_back(copiedPhoton);
81 *copiedPhoton = *photonPrev;
82
83 // now go on with the normal Hypo, linking new decision with previous one
84 auto newDecision = newDecisionIn( outputDecisions, hypoAlgNodeName() );
85 TrigCompositeUtils::linkToPrevious( newDecision, previousDecision, ctx );
86 // do we need to re-link the feature?
87 newDecision->setObjectLink(featureString(), ElementLink<xAOD::PhotonContainer>(*h_TLAPhotons, h_TLAPhotons->size() - 1, ctx));
88
89
90 ATH_MSG_DEBUG("Copied photon with pT: " << copiedPhoton->pt() << " from decision " << nDecision);
91 }
92
93
94 for (const auto& tool : m_hypoTools)
95 {
96 ATH_MSG_DEBUG("Now computing decision for HypoTool: " << tool->name());
97 ATH_CHECK(tool->decide(outputDecisions));
98 }
99
100 ATH_CHECK( hypoBaseOutputProcessing(outputHandle ));
101
102
103 return StatusCode::SUCCESS;
104}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
const SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > & decisionInput() const
methods for derived classes to access handles of the base class input other read/write handles may be...
Definition HypoBase.cxx:18
const SG::WriteHandleKey< TrigCompositeUtils::DecisionContainer > & decisionOutput() const
methods for derived classes to access handles of the base class output other read/write handles may b...
Definition HypoBase.cxx:22
StatusCode hypoBaseOutputProcessing(SG::WriteHandle< TrigCompositeUtils::DecisionContainer > &outputHandle, MSG::Level lvl=MSG::DEBUG) const
Base class function to be called once slice specific code has finished. Handles debug printing and va...
Definition HypoBase.cxx:35
HypoBase(const std::string &name, ISvcLocator *pSvcLocator)
constructor, to be called by sub-class constructors
Definition HypoBase.cxx:12
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
virtual StatusCode initialize() override
TrigEgammaTLAPhotonHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteHandleKey< xAOD::PhotonContainer > m_TLAPhotonsKey
virtual StatusCode execute(const EventContext &context) const override
ToolHandleArray< TrigEgammaTLAPhotonHypoTool > m_hypoTools
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition Egamma_v1.cxx:66
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Decision * newDecisionIn(DecisionContainer *dc, const std::string &name)
Helper method to create a Decision object, place it in the container and return a pointer to it.
const std::string & featureString()
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
void findLinks(const Decision *start, const std::string &linkName, std::vector< LinkInfo< T > > &links, unsigned int behaviour=TrigDefs::allFeaturesOfType, std::set< const xAOD::TrigComposite * > *fullyExploredFrom=nullptr)
search back the TC links for the object of type T linked to the one of TC (recursively) Populates pro...
const std::string & hypoAlgNodeName()
void linkToPrevious(Decision *d, const std::string &previousCollectionKey, size_t previousIndex)
Links to the previous object, location of previous 'seed' decision supplied by hand.
static const unsigned int lastFeatureOfType
Run 3 "enum". Only return the final feature along each route through the navigation.
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
Photon_v1 Photon
Definition of the current "egamma version".