ATLAS Offline Software
Loading...
Searching...
No Matches
TrigJetEJsHypoAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <algorithm>
6#include "TrigJetEJsHypoAlg.h"
10
11using namespace TrigCompositeUtils;
12
16
17
18TrigJetEJsHypoAlg::TrigJetEJsHypoAlg( const std::string& name,
19 ISvcLocator* pSvcLocator ) :
20 ::HypoBase( name, pSvcLocator ) { }
21
22
24
25 CHECK( m_hypoTools.retrieve() );
26 CHECK( m_tracksKey.initialize() );
27 CHECK( m_PV.initialize() );
28
29 return StatusCode::SUCCESS;
30}
31
32
33StatusCode TrigJetEJsHypoAlg::execute( const EventContext& context ) const {
34
35 ATH_MSG_DEBUG ( "Executing " << name() << "..." );
36
37 // get the HLT decision container for the previous decisions (one per jet in the original collection)
38
39 ATH_MSG_DEBUG("Retrieving HLT decision \"" << decisionInput().key() << "\"");
40 auto previousDecisionsHandle = SG::makeHandle(decisionInput(), context );
41 ATH_CHECK(previousDecisionsHandle.isValid());
42 const DecisionContainer* prevDecisions = previousDecisionsHandle.get();
43
44 // read in tracks container
45 ATH_MSG_DEBUG("Retrieving tracks from the track container \"" << m_tracksKey << "\"");
46 auto TracksHandle = SG::makeHandle(m_tracksKey, context );
47 ATH_CHECK(TracksHandle.isValid());
48 const TrackParticleContainer* tracks = TracksHandle.get();
49
50 // read in primary vertex container
51 ATH_MSG_DEBUG("Retrieving PV from the vertex container \"" << m_PV << "\"");
52 auto PVHandle = SG::makeHandle(m_PV, context );
53 ATH_CHECK(PVHandle.isValid());
54 const VertexContainer* vertices = PVHandle.get();
55 const xAOD::Vertex_v1 *PV = vertices->at(0);
56
57
58 std::vector<TrigJetEJsHypoTool::JetInfo> hypoToolInput;
60 DecisionContainer* outputDecisions = outputHandle.ptr();
61
62 for (const Decision* previousDecision : *prevDecisions) {
65 TrigCompositeUtils::decisionIDs(previousDecision, previousDecisionIDs);
66 Decision* newDecision = newDecisionIn(outputDecisions, previousDecision, hypoAlgNodeName(), context);
67 newDecision->setObjectLink<xAOD::JetContainer>(featureString(), myFeature.link);
68 hypoToolInput.emplace_back(TrigJetEJsHypoTool::JetInfo{newDecision, *(myFeature.link), tracks, PV, previousDecisionIDs});
69 }//end loop on previous decisions
70
71
72 for (const auto& tool: m_hypoTools) {
73 ATH_MSG_DEBUG("Now computing decision for " << tool->name());
74 CHECK(tool->decide(hypoToolInput));
75 }//end loop on hypoTools
76
77
78 DecisionContainer::iterator it = outputDecisions->begin();
79 while(it != outputDecisions->end()) {
80 if (allFailed( *it )) {
81 it = outputDecisions->erase(it);
82 } else {
83 ++it;
84 }
85 }//end loop on output decisios
86
87 return StatusCode::SUCCESS;
88
89}//end execute
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
iterator erase(iterator position)
Remove element at a given position.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
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
HypoBase(const std::string &name, ISvcLocator *pSvcLocator)
constructor, to be called by sub-class constructors
Definition HypoBase.cxx:12
pointer_type ptr()
Dereference the pointer.
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_tracksKey
TrigJetEJsHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode execute(const EventContext &context) const override
SG::ReadHandleKey< xAOD::VertexContainer > m_PV
ToolHandleArray< TrigJetEJsHypoTool > m_hypoTools
virtual StatusCode initialize() override
bool setObjectLink(const std::string &name, const ElementLink< CONTAINER > &link)
Set the link to an object.
Class describing a Vertex.
Definition Vertex_v1.h:42
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()
std::set< DecisionID > DecisionIDContainer
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
const std::string & hypoAlgNodeName()
bool allFailed(const Decision *d)
return true if there is no positive decision stored
LinkInfo< T > findLink(const Decision *start, const std::string &linkName, const bool suppressMultipleLinksWarning=false)
Perform a recursive search for ElementLinks of type T and name 'linkName', starting from Decision obj...
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition LinkInfo.h:22
ElementLink< T > link
Link to the feature.
Definition LinkInfo.h:55