ATLAS Offline Software
Loading...
Searching...
No Matches
TrigIsoHPtTrackTriggerHypoAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
4 * Trigger Hypo Tool, that is aimed at triggering high pt isolated tracks
5 * author Ismet Siral <ismet.siral@cern.ch> - University of Oregon
6*/
10#include "GaudiKernel/SystemOfUnits.h"
11
26
28 ISvcLocator* pSvcLocator ) :
29 ::HypoBase( name, pSvcLocator ) {}
30
31
33 CHECK( m_hypoTools.retrieve() );
34 CHECK( m_trackKey.initialize() );
35
36 return StatusCode::SUCCESS;
37}
38
39StatusCode TrigIsoHPtTrackTriggerHypoAlg::execute( const EventContext& context ) const {
40 ATH_MSG_DEBUG ( "Executing " << name() << "..." );
41 auto previousDecisionsHandle = SG::makeHandle( decisionInput(), context );
42 ATH_CHECK( previousDecisionsHandle.isValid() );
43
44
45
46 ATH_MSG_DEBUG( "Creating new output decision handle");
47 // new output decisions
49 auto decisions = outputHandle.ptr();
50
51 // prepare imput for tools
52 std::vector<TrigIsoHPtTrackTriggerHypoTool::TrackInfo> hypoToolInput;
53
54 ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" previous decisions");
55 if(previousDecisionsHandle->size()!=1) {
56 ATH_MSG_ERROR("Previous decision handle size isn't 1. It is"<<previousDecisionsHandle->size()<<". This means there is something seriously different the way track desicions are handled and this Isolated High Pt Track Trigger hypo might need re-work");
57 return StatusCode::FAILURE;
58
59 }
60 const Decision * previousDecision = previousDecisionsHandle->at(0);
61
63 TrigCompositeUtils::decisionIDs(previousDecision, previousDecisionIDs);
64
65 ATH_MSG_DEBUG( "Getting Track Handle "<<m_trackKey);
66 // get tracks from the key :
67 auto trackHandle = SG::makeHandle(m_trackKey, context );
68
69 ATH_CHECK( trackHandle.isValid() );
70 ATH_MSG_DEBUG ( "track handle size: " << trackHandle->size() << "..." );
71
72 const xAOD::TrackParticleContainer * AllTracks = trackHandle.get(); //Later this could be updated to run with tracks above a certain threshold
73
74 // Loop over all tracks above 1GeV and get a track decision associated with it and create the input
75 for ( const xAOD::TrackParticle_v1* track : *AllTracks) {
76
77 if (track->pt()< 1*Gaudi::Units::GeV ) continue;
78
79 //The decision tool has been moved inside the Tool, to save time on CPU. (There are too many tracks to make a dicision object. Instead we only make a decision object for events with tracks.
80
81 auto d = newDecisionIn( decisions , previousDecision, hypoAlgNodeName(), context);
82 d->setObjectLink( featureString(), ElementLink<xAOD::TrackParticleContainer>( *AllTracks, track->index() ) );
83
84 hypoToolInput.emplace_back( TrigIsoHPtTrackTriggerHypoTool::TrackInfo{ d, track, AllTracks, previousDecisionIDs} );
85 }
86
87 //Loop over all hypoToolinputs and get their decisions
88 for ( auto & tool: m_hypoTools ) {
89 ATH_CHECK( tool->decide( hypoToolInput ) );
90 }
91
92
93
94
95 DecisionContainer::iterator it = decisions->begin();
96 while(it != decisions->end()) {
97 if (allFailed( *it )) {
98 it = decisions->erase(it);
99 } else {
100 ++it;
101 }
102 }
103
104
105
106
107
108
109 ATH_CHECK( hypoBaseOutputProcessing(outputHandle) );
110
111
112
113
114 return StatusCode::SUCCESS;
115}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
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.
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()
const std::string & featureString()
bool allFailed(const Decision *d)
return true if there is no positive decision stored
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
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
pointer_type ptr()
Dereference the pointer.
ToolHandleArray< TrigIsoHPtTrackTriggerHypoTool > m_hypoTools
TrigIsoHPtTrackTriggerHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackKey
virtual StatusCode execute(const EventContext &context) const override
Class describing a TrackParticle.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
const std::string & viewString()
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()
xAOD::TrigCompositeAuxContainer DecisionAuxContainer
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()
void linkToPrevious(Decision *d, const std::string &previousCollectionKey, size_t previousIndex)
Links to the previous object, location of previous 'seed' decision supplied by hand.
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.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition LinkInfo.h:22