ATLAS Offline Software
Loading...
Searching...
No Matches
TrigIsoHPtTrackTriggerHypoTool.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*/
7
8
13#include "GaudiKernel/PhysicalConstants.h"
14
15using namespace TrigCompositeUtils;
16
18 const std::string& name,
19 const IInterface* parent )
20 : AthAlgTool( type, name, parent ),
21 m_decisionId( HLT::Identifier::fromToolName( name ) ) {}
22
24
25 if ( !m_monTool.empty() ) CHECK( m_monTool.retrieve() );
26
27 ATH_MSG_VERBOSE( "Initialization completed successfully:" );
28
29 //Track Trigger Kinematic Requirments
30 ATH_MSG_VERBOSE( "MaxTrackPt = " << m_TrackPt );
31 ATH_MSG_VERBOSE( "MaxTrackEta = " << m_TrackEta );
32 ATH_MSG_VERBOSE( "MaxTrackd0 = " << m_Trackd0 );
33 ATH_MSG_VERBOSE( "MaxTrackd0Sig = " << m_Trackd0Sig );
34 ATH_MSG_VERBOSE( "MinTrackNPixHits = " << m_TrackNPixHits );
35 ATH_MSG_VERBOSE( "MinTrackNSCTHits = " << m_TrackNSCTHits );
36 //Track Trigger Isolation Requirments
37 ATH_MSG_VERBOSE( "TrackIsoCone = " << m_IsoDR );
38 ATH_MSG_VERBOSE( "MinIsoTrackPt = " << m_IsoPt );
39 ATH_MSG_VERBOSE( "EnableTrackIsolation = " << m_doIso );
40 ATH_MSG_VERBOSE( "EnableCumulIsolation = " << m_IsoCum );
41
42 std::vector<size_t> sizes( {m_TrackPt.size(), m_TrackEta.size(), m_Trackd0.size( ), m_Trackd0Sig.size(), m_TrackNPixHits.size() , m_TrackNSCTHits.size() , m_doIso.size() , m_IsoDR.size() , m_IsoPt.size() } );
43
44
45 if ( *std::min_element( sizes.begin(), sizes.end() ) != *std::max_element( sizes.begin(), sizes.end() ) ) {
46 ATH_MSG_ERROR( "Missconfiguration, cut properties listed above ( when INFO ) have different dimensions shortest: " << *std::min_element( sizes.begin(), sizes.end() ) << " longest " << *std::max_element( sizes.begin(), sizes.end() ) );
47 return StatusCode::FAILURE;
48 }
49
50 ATH_MSG_VERBOSE( "Tool configured for chain/id: " << m_decisionId );
51
52 return StatusCode::SUCCESS;
53}
54
55
57
59 auto cutCounter = Monitored::Scalar<int>( "CutCounter", -1 );
60 auto cutIndexM = Monitored::Scalar<int>( "CutIndex", cutIndex ); // one can do 2D plots for each cut independently
61
62 auto MONtrackPt = Monitored::Scalar( "trackPt", -999. );
63 auto MONtrackd0 = Monitored::Scalar( "trackd0", -999. );
64 auto MONtrackNPixHits = Monitored::Scalar( "trackNPixHits", -999. );
65 auto MONtrackNSCTHits = Monitored::Scalar( "trackNSCTHits", -999. );
66 auto MONtrackd0Sig = Monitored::Scalar( "trackd0Sig", -999. );
67 auto MONtrackEta = Monitored::Scalar( "trackEta", -999. );
68 auto MONtrackIsoPt = Monitored::Scalar( "trackIsoPt", -999. );
69 auto MONtrackAggrIsoPt = Monitored::Scalar( "trackAggrIsoPt", -999. );
70 auto monitorIt = Monitored::Group( m_monTool, cutCounter, cutIndexM,
71 MONtrackPt, MONtrackEta,
72 MONtrackd0, MONtrackd0Sig,
73 MONtrackNPixHits, MONtrackNSCTHits,
74 MONtrackIsoPt, MONtrackAggrIsoPt
75 );
76
77
78
79
80 //Checking Track pT Requirments
81 auto trackPt= (track)->pt();
82 if( trackPt < m_TrackPt[cutIndex] ) { // Check track pT requirments
83 ATH_MSG_DEBUG( "Fails pt cut" << trackPt << " < " << m_TrackPt[cutIndex] );
84 return false;
85
86 }
87 cutCounter++;
88
89
90 //Checking Track Eta Requirments
91 auto trackEta=std::abs( (track)->p4().Eta() );
92 if( trackEta > m_TrackEta[cutIndex] ) { // Check track pT requirments
93 ATH_MSG_DEBUG( "Fails Eta cut" << trackEta << " > " << m_TrackEta[cutIndex] );
94 return false;
95
96 }
97 cutCounter++;
98
99
100
101 //Checking Track d0 Requirments
102 auto trackd0= std::abs((track)->d0());
103 if( trackd0 > m_Trackd0[cutIndex]) {
104 ATH_MSG_DEBUG( "Fails d0 cut" << trackd0 << " > " << m_Trackd0[cutIndex] );
105 return false;
106
107 }
108 cutCounter++;
109
110
111 //Checking Track d0 Sig Requirments
112 auto trackd0Sig= std::abs(xAOD::TrackingHelpers::d0significance(track));
113 if( trackd0Sig > m_Trackd0Sig[cutIndex]) {
114 ATH_MSG_DEBUG( "Fails d0 Sig cut" << trackd0Sig << " > " << m_Trackd0Sig[cutIndex] );
115 return false;
116
117 }
118 cutCounter++;
119
120
121 //Attempt to read track summary, and save info on number of pixels
122 uint8_t trackNPixHits=0;
123 if ( ! (track)->summaryValue(trackNPixHits,xAOD::numberOfPixelHits )) { // Cannot obtain the track summary
124 ATH_MSG_DEBUG( "Failed to retrieve pedigree parameters");
125 return false;
126 }
127 ATH_MSG_DEBUG( "Succesfully retrieved pedigree parameters");
128 cutCounter++;
129 //Attempt to read track summary, and save info on number of SCT hits
130 uint8_t trackNSCTHits=0;
131 if ( ! (track)->summaryValue(trackNSCTHits,xAOD::numberOfSCTHits )) { // Cannot obtain the track summary
132 ATH_MSG_DEBUG( "Failed to retrieve pedigree parameters");
133 return false;
134 }
135 ATH_MSG_DEBUG( "Succesfully retrieved pedigree parameters");
136 cutCounter++;
137
138
139
140 //Checking Track Min number of Pix Hits Requirments
141 if( trackNPixHits <= m_TrackNPixHits[cutIndex] ){
142
143 ATH_MSG_DEBUG( "Fails numperOfPixelHits cut" << trackNPixHits << " <= " << m_TrackNPixHits[cutIndex] );
144 return false;
145 }
146 cutCounter++;
147
148
149 //Checking Track Min number of SCT Hits Requirments
150 if( trackNSCTHits <= m_TrackNSCTHits[cutIndex] ){
151
152 ATH_MSG_DEBUG( "Fails numperOfSCTHits cut" << trackNSCTHits << " <= " << m_TrackNSCTHits[cutIndex] );
153 return false;
154 }
155 cutCounter++;
156
157
158 //Definning a cumlative pT variable that adds up the momentum of all tracks
159
160 //If isolation is applied, loop over all tracks, and veto the event if there is a track above a certain threshold in the isolation cone
161 if (m_doIso[cutIndex]) {
162 float CumulativePT = 0.0;
163
164 for (auto trackIter = AllTracks->begin(); trackIter != AllTracks->end(); ++trackIter){
165
166 //Skip the track that is out of DR
167 if( (*trackIter)==track) continue;
168 if (track->p4().DeltaR((*trackIter)->p4()) > m_IsoDR[cutIndex] ) continue;
169
170 //Skip the track that doens't have many Pixel and SCT Hits (Quality Check)
171 uint8_t iterPix=0;
172 if ( ! (*trackIter)->summaryValue(iterPix,xAOD::numberOfPixelHits ))
173 continue;
174 uint8_t iterSCT=0;
175 if ( ! (*trackIter)->summaryValue(iterSCT,xAOD::numberOfSCTHits ))
176 continue;
177
178 if (iterPix<=m_TrackNPixHits[cutIndex] ) continue;
179 if (iterSCT<=2 ) continue;
180
181
182 //If cumalitve, add up the momentum of the track, if it's a bove a certain threshold kill the trac
183
184 if(m_IsoCum[cutIndex]){
185 CumulativePT+=(*trackIter)->pt();
186 if(CumulativePT>=m_IsoPt[cutIndex]) {
187 MONtrackAggrIsoPt=CumulativePT;
188 ATH_MSG_DEBUG( "Fails Cum Isolation cut" );
189 return false;
190 }
191 }
192 //If not cumlaitve, veto the track only if one track is bigger then the threshold
193 else {
194 if ((*trackIter)->pt() > MONtrackIsoPt ) {
195 MONtrackIsoPt=(*trackIter)->pt();
196 }
197
198 if( (*trackIter)->pt()>=m_IsoPt[cutIndex] ) {
199 ATH_MSG_DEBUG( "Fails Isolation cut" );
200 return false;
201 }
202 }
203
204
205
206 }
207
208 MONtrackAggrIsoPt=CumulativePT;
209 cutCounter++;
210 }
211
212 //Monitorung histograms are filled at the end, only if they pass the selection. (For optimisation studies)
213 MONtrackNPixHits=trackNPixHits;
214 MONtrackNSCTHits=trackNSCTHits;
215 MONtrackPt= trackPt;
216 MONtrackEta= trackEta;
217 MONtrackd0= trackd0;
218 MONtrackd0Sig= trackd0Sig;
219
220
221
222 ATH_MSG_DEBUG( "Passed selection" );
223 return true;
224
225}
226
227StatusCode TrigIsoHPtTrackTriggerHypoTool::inclusiveSelection( std::vector<TrackInfo>& input ) const {
228 for ( auto i: input ) {
229
230 if ( i.previousDecisionsIDs.count( m_decisionId.numeric() ) == 0 ) {
231 continue;
232 }
233
234 auto objDecision = decideOnSingleObject( i.track, i.AllTracks, 0 );
235 if ( objDecision == true ) {
236
237 addDecisionID( m_decisionId.numeric(), i.decision );
238 }
239 }
240 return StatusCode::SUCCESS;
241}
242
243
244StatusCode TrigIsoHPtTrackTriggerHypoTool::markPassing( std::vector<TrackInfo>& input, const std::set<size_t>& passing ) const {
245
246 for ( auto idx: passing )
247 addDecisionID( m_decisionId.numeric(), input[idx].decision );
248 return StatusCode::SUCCESS;
249
250}
251
252
253StatusCode TrigIsoHPtTrackTriggerHypoTool::multiplicitySelection( std::vector<TrackInfo>& input ) const {
254 HLT::Index2DVec passingSelection( m_multiplicity );
255
256 for ( size_t cutIndex = 0; cutIndex < m_multiplicity; ++ cutIndex ) {
257 size_t trkIndex{ 0 };
258 for ( auto trkIter = input.begin(); trkIter != input.end(); ++trkIter, ++trkIndex ) {
259
260 if ( trkIter->previousDecisionsIDs.count( m_decisionId.numeric() ) == 0 ) {
261 continue;
262 }
263
264 if ( decideOnSingleObject( trkIter->track, trkIter->AllTracks, cutIndex ) ) {
265 passingSelection[cutIndex].push_back( trkIndex );
266
267 }
268 }
269 // checking if by chance none of the objects passed the single obj selection, if so there will be no valid combination and we can skip
270 if ( passingSelection[cutIndex].empty() ) {
271 ATH_MSG_DEBUG( "No object passed selection " << cutIndex << " rejecting" );
272 return StatusCode::SUCCESS;
273 }
274 }
275
276 std::set<size_t> passingIndices;
277 HLT::elementsInUniqueCombinations( passingSelection, passingIndices );
278 return markPassing( input, passingIndices );
279
280
281}
282
283StatusCode TrigIsoHPtTrackTriggerHypoTool::decide( std::vector<TrackInfo>& input ) const {
284 // handle the simplest and most common case ( multiplicity == 1 ) in easiest possible manner
285 if ( m_TrackPt.size() == 1 ) {
286 return inclusiveSelection( input );
287
288 } else {
289 return multiplicitySelection( input );
290 }
291
292 return StatusCode::SUCCESS;
293}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
Header file to be included by clients of the Monitored infrastructure.
@ Eta
Definition RPCdef.h:8
static const Attributes_t empty
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
TrigIsoHPtTrackTriggerHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Gaudi::Property< std::vector< float > > m_IsoDR
Gaudi::Property< std::vector< float > > m_Trackd0
Gaudi::Property< std::vector< bool > > m_doIso
StatusCode decide(std::vector< TrackInfo > &decisions) const
decides upon a collection of tracks
ToolHandle< GenericMonitoringTool > m_monTool
StatusCode markPassing(std::vector< TrackInfo > &input, const std::set< size_t > &passing) const
stores decisions for all object passing multiple cuts The passsingSelection inner vectors have to hav...
Gaudi::Property< std::vector< bool > > m_IsoCum
Gaudi::Property< std::vector< float > > m_Trackd0Sig
Gaudi::Property< std::vector< float > > m_IsoPt
Gaudi::Property< std::vector< float > > m_TrackPt
Gaudi::Property< std::vector< unsigned > > m_TrackNSCTHits
StatusCode multiplicitySelection(std::vector< TrackInfo > &input) const
actual implementation of decide, in case of multiple objects selection ( independentone )
Gaudi::Property< std::vector< float > > m_TrackEta
bool decideOnSingleObject(const xAOD::TrackParticle_v1 *track, const xAOD::TrackParticleContainer *AllTracks, size_t cutIndex) const
Auxiluary method, single track selection.
Gaudi::Property< std::vector< unsigned > > m_TrackNPixHits
StatusCode inclusiveSelection(std::vector< TrackInfo > &input) const
actual implementation of decide, in case of inclusive selection ( one object cut )
Class describing a TrackParticle.
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
void elementsInUniqueCombinations(const Index2DVec &indices, std::set< size_t > &participants, const std::function< bool(const Index1DVec &)> &filter)
std::vector< Index1DVec > Index2DVec
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
double d0significance(const xAOD::TrackParticle *tp, double d0_uncert_beam_spot_2)
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
@ numberOfSCTHits
number of hits in SCT [unit8_t].
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].