ATLAS Offline Software
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 
15 using 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 
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 
244 StatusCode 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 
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 
283 StatusCode 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 }
TrigIsoHPtTrackTriggerHypoTool::markPassing
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...
Definition: TrigIsoHPtTrackTriggerHypoTool.cxx:244
TrigIsoHPtTrackTriggerHypoTool::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: TrigIsoHPtTrackTriggerHypoTool.h:90
TrigIsoHPtTrackTriggerHypoTool::m_Trackd0Sig
Gaudi::Property< std::vector< float > > m_Trackd0Sig
Definition: TrigIsoHPtTrackTriggerHypoTool.h:78
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
TrigIsoHPtTrackTriggerHypoTool::TrigIsoHPtTrackTriggerHypoTool
TrigIsoHPtTrackTriggerHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TrigIsoHPtTrackTriggerHypoTool.cxx:17
TrigIsoHPtTrackTriggerHypoTool::~TrigIsoHPtTrackTriggerHypoTool
virtual ~TrigIsoHPtTrackTriggerHypoTool()
Definition: TrigIsoHPtTrackTriggerHypoTool.cxx:56
TrigCompositeUtils::addDecisionID
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
Definition: TrigCompositeUtilsRoot.cxx:61
xAOD::TrackingHelpers::d0significance
double d0significance(const xAOD::TrackParticle *tp, double d0_uncert_beam_spot_2)
Definition: TrackParticlexAODHelpers.cxx:42
test_pyathena.pt
pt
Definition: test_pyathena.py:11
xAOD::numberOfPixelHits
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
Definition: TrackingPrimitives.h:259
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TrigIsoHPtTrackTriggerHypoTool.h
empty
bool empty(TH1 *h)
Definition: computils.cxx:295
TrigIsoHPtTrackTriggerHypoTool::decide
StatusCode decide(std::vector< TrackInfo > &decisions) const
decides upon a collection of tracks
Definition: TrigIsoHPtTrackTriggerHypoTool.cxx:283
TrigIsoHPtTrackTriggerHypoTool::m_Trackd0
Gaudi::Property< std::vector< float > > m_Trackd0
Definition: TrigIsoHPtTrackTriggerHypoTool.h:77
TrigIsoHPtTrackTriggerHypoTool::m_TrackPt
Gaudi::Property< std::vector< float > > m_TrackPt
Definition: TrigIsoHPtTrackTriggerHypoTool.h:75
TrigIsoHPtTrackTriggerHypoTool::m_TrackEta
Gaudi::Property< std::vector< float > > m_TrackEta
Definition: TrigIsoHPtTrackTriggerHypoTool.h:76
TrigIsoHPtTrackTriggerHypoTool::initialize
virtual StatusCode initialize() override
Definition: TrigIsoHPtTrackTriggerHypoTool.cxx:23
TrigIsoHPtTrackTriggerHypoTool::m_multiplicity
size_t m_multiplicity
Definition: TrigIsoHPtTrackTriggerHypoTool.h:88
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TrigIsoHPtTrackTriggerHypoTool::decideOnSingleObject
bool decideOnSingleObject(const xAOD::TrackParticle_v1 *track, const xAOD::TrackParticleContainer *AllTracks, size_t cutIndex) const
Auxiluary method, single track selection.
Definition: TrigIsoHPtTrackTriggerHypoTool.cxx:58
HLT
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Definition: HLTResultReader.h:26
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
TRT::Track::d0
@ d0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:62
test_pyathena.parent
parent
Definition: test_pyathena.py:15
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
HLT::elementsInUniqueCombinations
void elementsInUniqueCombinations(const Index2DVec &indices, std::set< size_t > &participants, std::function< bool(const Index1DVec &)> &&filter)
Definition: Combinators.cxx:154
TauGNNUtils::Variables::Track::trackPt
bool trackPt(const xAOD::TauJet &, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:472
TrigIsoHPtTrackTriggerHypoTool::m_IsoPt
Gaudi::Property< std::vector< float > > m_IsoPt
Definition: TrigIsoHPtTrackTriggerHypoTool.h:85
TrigIsoHPtTrackTriggerHypoTool::m_IsoDR
Gaudi::Property< std::vector< float > > m_IsoDR
Definition: TrigIsoHPtTrackTriggerHypoTool.h:84
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrigIsoHPtTrackTriggerHypoTool::m_TrackNSCTHits
Gaudi::Property< std::vector< unsigned > > m_TrackNSCTHits
Definition: TrigIsoHPtTrackTriggerHypoTool.h:80
TrigIsoHPtTrackTriggerHypoTool::inclusiveSelection
StatusCode inclusiveSelection(std::vector< TrackInfo > &input) const
actual implementation of decide, in case of inclusive selection ( one object cut )
Definition: TrigIsoHPtTrackTriggerHypoTool.cxx:227
TrigIsoHPtTrackTriggerHypoTool::m_IsoCum
Gaudi::Property< std::vector< bool > > m_IsoCum
Definition: TrigIsoHPtTrackTriggerHypoTool.h:83
TrigIsoHPtTrackTriggerHypoTool::m_TrackNPixHits
Gaudi::Property< std::vector< unsigned > > m_TrackNPixHits
Definition: TrigIsoHPtTrackTriggerHypoTool.h:79
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
Combinators.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigIsoHPtTrackTriggerHypoTool::m_doIso
Gaudi::Property< std::vector< bool > > m_doIso
Definition: TrigIsoHPtTrackTriggerHypoTool.h:82
HLTIdentifier.h
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
TrigIsoHPtTrackTriggerHypoTool::multiplicitySelection
StatusCode multiplicitySelection(std::vector< TrackInfo > &input) const
actual implementation of decide, in case of multiple objects selection ( independentone )
Definition: TrigIsoHPtTrackTriggerHypoTool.cxx:253
xAOD::numberOfSCTHits
@ numberOfSCTHits
number of hits in SCT [unit8_t].
Definition: TrackingPrimitives.h:268
TrigIsoHPtTrackTriggerHypoTool::m_decisionId
HLT::Identifier m_decisionId
Definition: TrigIsoHPtTrackTriggerHypoTool.h:73
HLT::Index2DVec
std::vector< Index1DVec > Index2DVec
Definition: TrigCompositeUtils/TrigCompositeUtils/Combinators.h:140
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
AthAlgTool
Definition: AthAlgTool.h:26
Eta
@ Eta
Definition: RPCdef.h:8
TauGNNUtils::Variables::Track::trackEta
bool trackEta(const xAOD::TauJet &, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:477
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Identifier
Definition: IdentifierFieldParser.cxx:14