ATLAS Offline Software
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 */
8 #include "AthViews/ViewHelper.h"
10 #include "GaudiKernel/SystemOfUnits.h"
11 
26 
28  ISvcLocator* pSvcLocator ) :
29  ::HypoBase( name, pSvcLocator ) {}
30 
31 
33  CHECK( m_hypoTools.retrieve() );
35 
36  return StatusCode::SUCCESS;
37 }
38 
39 StatusCode 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 
62  TrigCompositeUtils::DecisionIDContainer previousDecisionIDs;
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 
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 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
TrigCompositeUtils::DecisionContainer
xAOD::TrigCompositeContainer DecisionContainer
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigCompositeContainer.h:21
TrigCompositeUtils.h
TrigIsoHPtTrackTriggerHypoAlg::TrigIsoHPtTrackTriggerHypoAlg
TrigIsoHPtTrackTriggerHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigIsoHPtTrackTriggerHypoAlg.cxx:27
TrigIsoHPtTrackTriggerHypoAlg::m_hypoTools
ToolHandleArray< TrigIsoHPtTrackTriggerHypoTool > m_hypoTools
Definition: TrigIsoHPtTrackTriggerHypoAlg.h:31
TrigCompositeUtils::newDecisionIn
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.
Definition: TrigCompositeUtilsRoot.cxx:46
hist_file_dump.d
d
Definition: hist_file_dump.py:137
TrigCompositeUtils::hypoAlgNodeName
const std::string & hypoAlgNodeName()
Definition: TrigCompositeUtilsRoot.cxx:906
skel.it
it
Definition: skel.GENtoEVGEN.py:423
DataVector::get
const T * get(size_type n) const
Access an element, as an rvalue.
HypoBase::decisionInput
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:16
TrigCompositeUtils::createAndStore
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
Definition: TrigCompositeUtilsRoot.cxx:30
ViewHelper.h
HypoBase::decisionOutput
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:20
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
TrigIsoHPtTrackTriggerHypoAlg::m_trackKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackKey
Definition: TrigIsoHPtTrackTriggerHypoAlg.h:33
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
HypoBase::hypoBaseOutputProcessing
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:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
DataVector< xAOD::TrackParticle_v1 >
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:81
TrigCompositeUtils::DecisionAuxContainer
xAOD::TrigCompositeAuxContainer DecisionAuxContainer
Definition: TrigCompositeAuxContainer.h:20
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:886
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
HypoBase
Hypothesis algorithms take the output of reco algorithms and the decision from the preceeding InputMa...
Definition: HypoBase.h:13
TrigCompositeUtils::Decision
xAOD::TrigComposite Decision
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:20
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
TrigIsoHPtTrackTriggerHypoAlg.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
TrigCompositeUtils::linkToPrevious
void linkToPrevious(Decision *d, const std::string &previousCollectionKey, size_t previousIndex)
Links to the previous object, location of previous 'seed' decision supplied by hand.
Definition: TrigCompositeUtilsRoot.cxx:139
TrigCompositeUtils::LinkInfo
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition: LinkInfo.h:28
TrigCompositeUtils::DecisionIDContainer
std::set< DecisionID > DecisionIDContainer
Definition: TrigComposite_v1.h:28
TrigCompositeUtils::findLink
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...
TrigCompositeUtils::allFailed
bool allFailed(const Decision *d)
return true if there is no positive decision stored
Definition: TrigCompositeUtilsRoot.cxx:103
TrigCompositeUtils::decisionIDs
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
Definition: TrigCompositeUtilsRoot.cxx:67
TrigIsoHPtTrackTriggerHypoAlg::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: TrigIsoHPtTrackTriggerHypoAlg.cxx:39
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
TrigIsoHPtTrackTriggerHypoTool::TrackInfo
Definition: TrigIsoHPtTrackTriggerHypoTool.h:35
TrigIsoHPtTrackTriggerHypoAlg::initialize
virtual StatusCode initialize() override
Definition: TrigIsoHPtTrackTriggerHypoAlg.cxx:32
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
TrigCompositeUtils::viewString
const std::string & viewString()
Definition: TrigCompositeUtilsRoot.cxx:882