ATLAS Offline Software
Loading...
Searching...
No Matches
TrigMuonEFIdtpHypoAlg.cxx
Go to the documentation of this file.
1/*
2# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
8
9using namespace TrigCompositeUtils;
10
11// --------------------------------------------------------------------------------
12// --------------------------------------------------------------------------------
13
15 ISvcLocator* pSvcLocator ) :
16 ::HypoBase( name, pSvcLocator ) { }
17
18// --------------------------------------------------------------------------------
19// --------------------------------------------------------------------------------
20
22{
23 ATH_CHECK(m_hypoTools.retrieve());
24
26 ATH_CHECK(m_PTTracksKey.initialize());
27
29 ATH_CHECK(m_FTFTracksKey.initialize());
30
31 return StatusCode::SUCCESS;
32}
33
34// --------------------------------------------------------------------------------
35// --------------------------------------------------------------------------------
36
37StatusCode TrigMuonEFIdtpHypoAlg::execute( const EventContext& context ) const
38{
39 ATH_MSG_DEBUG("StatusCode TrigMuonEFIdtpHypoAlg::execute start");
40
41 // common for all hypos, to move in the base class
42 auto previousDecisionsHandle = SG::makeHandle( decisionInput(), context );
43 ATH_CHECK( previousDecisionsHandle.isValid() );
44 ATH_MSG_DEBUG("Running with "<< previousDecisionsHandle->size() <<" previous decisions");
45
46 // new output decisions
48 auto decisions = outputHandle.ptr();
49
50 std::vector<TrigMuonEFIdtpHypoTool::MuonEFIdperfInfo> toolInput;
51 int counter = -1;
52
53 // loop over previous decisions
54 for ( const auto previousDecision: *previousDecisionsHandle ) {
55
56 ATH_MSG_VERBOSE("--- counter: "<<++counter<<" ---");
57
58 // get view
59 auto viewEL = previousDecision->objectLink<ViewContainer>( viewString() );
60 ATH_CHECK( viewEL.isValid() );
61
62 // get ID tracks
63 auto ptTrkHandle = ViewHelper::makeHandle( *viewEL, m_PTTracksKey, context );
64 ATH_CHECK( ptTrkHandle.isValid() );
65 if( ptTrkHandle->size()==0 ) {
66 ATH_MSG_VERBOSE("No PT track handle, skipping this decision");
67 continue;
68 }
69 auto ftfTrkHandle = ViewHelper::makeHandle( *viewEL, m_FTFTracksKey, context );
70 ATH_CHECK( ftfTrkHandle.isValid() );
71 if( ftfTrkHandle->size()==0 ) {
72 ATH_MSG_VERBOSE("No FTF track handle, skipping this decision");
73 continue;
74 }
75
76 // get SA muon from the previous decision
77 const xAOD::Muon *muonSA = nullptr;
79 ATH_CHECK(prevMuInfo.size()==1);
80 auto muonSALink = prevMuInfo.at(0).link;
81 ATH_CHECK( muonSALink.isValid() );
82 muonSA = *muonSALink;
83 if( muonSA->muonType() != xAOD::Muon::MuonType::MuonStandAlone ) {
84 ATH_MSG_VERBOSE("previous decision muon is not SA, skipping this decision");
85 continue;
86 }
87 const xAOD::TrackParticle* metrack = muonSA->trackParticle( xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle );
88 ATH_MSG_VERBOSE("muonSA: muonType="<<muonSA->muonType()<<", pT="<<muonSA->pt()/1000.0<<", eta="<<muonSA->eta()<<", phi="<<muonSA->phi()<<", author="<<muonSA->author());
89
90 // select PT track
91 float dRmin = 999;
92 const xAOD::TrackParticle* thePTTrack = nullptr;
93 std::vector<ElementLink<xAOD::TrackParticleContainer>> thePTTrackLinks;
94 const xAOD::TrackParticleContainer * ptTracks = ptTrkHandle.get();
95 ATH_MSG_VERBOSE("PT tracks size: " << ptTracks->size());
96 for ( const xAOD::TrackParticle* idtrack : *ptTracks ) {
97 if (idtrack->pt()< 1*Gaudi::Units::GeV ) continue;
98 float dr = TrigMuonEFIdtpCommon::matchingMetric(metrack,idtrack);
99 if( dr < dRmin ) {
100 dRmin = dr;
101 thePTTrack = idtrack;
102 }
103 }
104 if( thePTTrack != nullptr ) {
105 auto idtrackLink = ElementLink<xAOD::TrackParticleContainer>(*ptTracks,thePTTrack->index());
106 ATH_CHECK( idtrackLink.isValid() );
107 thePTTrackLinks.push_back(idtrackLink);
108 ATH_MSG_VERBOSE("... best selected PT track pt / eta / phi / dr = " << thePTTrack->pt()/Gaudi::Units::GeV << " / " << thePTTrack->eta() << " / " << thePTTrack->phi() << " / " << dRmin << ", fitter=" << thePTTrack->trackFitter());
109 }
110
111 // FTF track
112 dRmin = 999;
113 const xAOD::TrackParticle* theFTFTrack = nullptr;
114 std::vector<ElementLink<xAOD::TrackParticleContainer>> theFTFTrackLinks;
115 const xAOD::TrackParticleContainer * ftfTracks = ftfTrkHandle.get();
116 ATH_MSG_VERBOSE("FTF tracks size: " << ftfTracks->size());
117 for ( const xAOD::TrackParticle* idtrack : *ftfTracks ) {
118 if (idtrack->pt()< 1*Gaudi::Units::GeV ) continue;
119 float dr = TrigMuonEFIdtpCommon::matchingMetric(metrack,idtrack);
120 if( dr < dRmin ) {
121 dRmin = dr;
122 theFTFTrack = idtrack;
123 }
124 }
125 if( theFTFTrack != nullptr ) {
126 auto idtrackLink = ElementLink<xAOD::TrackParticleContainer>(*ftfTracks,theFTFTrack->index());
127 ATH_CHECK( idtrackLink.isValid() );
128 theFTFTrackLinks.push_back(idtrackLink);
129 ATH_MSG_VERBOSE("... best selected FTF track pt / eta / phi / dr = " << theFTFTrack->pt()/Gaudi::Units::GeV << " / " << theFTFTrack->eta() << " / " << theFTFTrack->phi() << " / " << dRmin << ", fitter=" << theFTFTrack->trackFitter());
130 }
131
132 // create new decisions
133 auto newd = newDecisionIn( decisions, hypoAlgNodeName() );
134
135 // push_back to toolInput
136 toolInput.emplace_back( newd, muonSA, thePTTrack, theFTFTrack, previousDecision );
137
138 newd -> setObjectLink( featureString(), muonSALink );
139 newd -> addObjectCollectionLinks( m_PTTracksKey.key(), thePTTrackLinks );
140 newd -> addObjectCollectionLinks( m_FTFTracksKey.key(), theFTFTrackLinks );
141 ATH_MSG_VERBOSE("Setting object link for PT / FTF track: size="<<thePTTrackLinks.size()<<" / "<<theFTFTrackLinks.size());
142 TrigCompositeUtils::linkToPrevious( newd, previousDecision, context );
143 }
144
145 ATH_MSG_DEBUG("Found "<<toolInput.size()<<" inputs to tools");
146
147 // to TrigMuonEFIdtpHypoTool
148 StatusCode sc = StatusCode::SUCCESS;
149 for ( auto& tool: m_hypoTools ) {
150 ATH_MSG_DEBUG("Go to " << tool );
151 sc = tool->decide(toolInput);
152 if (!sc.isSuccess()) {
153 ATH_MSG_ERROR("MuonHypoTool is failed");
154 return StatusCode::FAILURE;
155 }
156 } // End of tool algorithms */
157
158 ATH_CHECK(hypoBaseOutputProcessing(outputHandle));
159
160 ATH_MSG_DEBUG("StatusCode TrigMuonEFIdtpHypoAlg::execute success");
161 return StatusCode::SUCCESS;
162}
163
164// --------------------------------------------------------------------------------
165// --------------------------------------------------------------------------------
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
DataVector< SG::View > ViewContainer
View container for recording in StoreGate.
Definition View.h:290
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)
size_type size() const noexcept
Returns the number of elements in 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
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
size_t index() const
Return the index of this element within its container.
pointer_type ptr()
Dereference the pointer.
TrigMuonEFIdtpHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
virtual StatusCode execute(const EventContext &context) const override
ToolHandleArray< TrigMuonEFIdtpHypoTool > m_hypoTools
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_PTTracksKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_FTFTracksKey
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
virtual double pt() const
The transverse momentum ( ) of the particle.
Author author() const
MuonType muonType() const
const TrackParticle * trackParticle(TrackParticleType type) const
Returns a pointer (which can be NULL) to the TrackParticle used in identification of this muon.
Definition Muon_v1.cxx:482
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .)
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
TrackFitter trackFitter() const
Returns the fitter.
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()
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.
float matchingMetric(const xAOD::TrackParticle *metrack, const xAOD::TrackParticle *idtrack)
auto makeHandle(const SG::View *view, const KEY &key, const EventContext &ctx)
Create a view handle from a handle key.
Definition ViewHelper.h:273
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
Muon_v1 Muon
Reference the current persistent version: