ATLAS Offline Software
MuonMatchingTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <utility>
6 #include "MuonMatchingTool.h"
8 
9 const static double ZERO_LIMIT = 1.e-5;
10 
11 MuonMatchingTool :: MuonMatchingTool(const std::string& type, const std::string& name, const IInterface* parent)
13 {}
14 
15 
17 
18  ATH_CHECK( m_trigDec.retrieve() );
19  ATH_CHECK( m_thresholdTool.retrieve() );
21  ATH_CHECK( m_extrapolator.retrieve() );
22  }
33 
34  return StatusCode::SUCCESS;
35 }
36 
37 
39  const xAOD::TrackParticle* track = mu->primaryTrackParticle();
40  std::unique_ptr<const Trk::TrackParameters> extPars(extTrackToPivot(track));
41  return extPars ? extPars->position() : Amg::Vector3D(0.,0.,0.);
42 }
43 
44 
45 template<>
46 std::tuple<bool, double,double> MuonMatchingTool :: trigPosForMatch<xAOD::L2StandAloneMuon>(const xAOD::L2StandAloneMuon *trig){
47  return std::forward_as_tuple(true, trig->roiEta(), trig->roiPhi());
48 }
49 
50 
51 std::tuple<bool, double,double> MuonMatchingTool :: trigPosForMatchSATrack(const xAOD::Muon *mu){
52  return mu->muonType() == xAOD::Muon::MuonType::MuonStandAlone ? std::forward_as_tuple(true, mu->eta(), mu->phi()) : std::forward_as_tuple(false, 0., 0.);
53 }
54 
55 std::tuple<bool, double,double> MuonMatchingTool :: trigPosForMatchCBTrack(const xAOD::Muon *mu){
56  return mu->muonType() == xAOD::Muon::MuonType::Combined ? std::forward_as_tuple(true, mu->eta(), mu->phi()) : std::forward_as_tuple(false, 0., 0.);
57 }
58 
59 std::tuple<bool, double,double> MuonMatchingTool :: PosForMatchSATrack(const xAOD::Muon *mu){
60  const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::ExtrapolatedMuonSpectrometerTrackParticle);
61  return MuonTrack ? std::forward_as_tuple(true, MuonTrack->eta(), MuonTrack->phi()) : std::forward_as_tuple(false, 0., 0.);
62 }
63 
64 std::tuple<bool, double,double> MuonMatchingTool :: PosForMatchCBTrack(const xAOD::Muon *mu){
65  const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::CombinedTrackParticle);
66  return MuonTrack ? std::forward_as_tuple(true, MuonTrack->eta(), MuonTrack->phi()) : std::forward_as_tuple(false, 0., 0.);
67 }
68 
69 
70 const xAOD::Muon* MuonMatchingTool :: matchEFSA(const xAOD::Muon *mu, std::string trig, bool &pass) const {
71  ATH_MSG_DEBUG("MuonMonitoring::matchEFSA()");
72  const xAOD::TrackParticle* MuonTrack = nullptr;
73  using Type = xAOD::Muon::TrackParticleType;
74  std::vector<Type> types { Type::ExtrapolatedMuonSpectrometerTrackParticle,
75  Type::MSOnlyExtrapolatedMuonSpectrometerTrackParticle,
76  Type::MuonSpectrometerTrackParticle};
77  for (Type type : types){
78  MuonTrack = mu->trackParticle(type);
79  ATH_MSG_DEBUG("HLT_Muons_RoI SA Muon");
80  if (MuonTrack) break;
81  }
82  return MuonTrack ? match<xAOD::Muon>(MuonTrack, std::move(trig), m_EFreqdR, pass, "HLT_Muons_RoI.*", &MuonMatchingTool::trigPosForMatchSATrack) : nullptr;
83 }
84 
85 const xAOD::Muon* MuonMatchingTool :: matchEFSA(const xAOD::TruthParticle *mu, std::string trig, bool &pass) const {
86  ATH_MSG_DEBUG("MuonMonitoring::matchEFSA() for truth particle");
87  return mu ? match<xAOD::Muon>(mu, std::move(trig), m_EFreqdR, pass, "HLT_Muons_RoI.*", &MuonMatchingTool::trigPosForMatchSATrack) : nullptr;
88 }
89 
91  ATH_MSG_DEBUG("MuonMonitoring::matchEFSALinkInfo()");
92  bool pass = false;
94  const xAOD::TrackParticle* MuonTrack = nullptr;
95  using Type = xAOD::Muon::TrackParticleType;
96  std::vector<Type> types { Type::ExtrapolatedMuonSpectrometerTrackParticle,
97  Type::MSOnlyExtrapolatedMuonSpectrometerTrackParticle,
98  Type::MuonSpectrometerTrackParticle};
99  for (Type type : types){
100  MuonTrack = mu->trackParticle(type);
101  if (MuonTrack) break;
102  }
103  return MuonTrack ? matchLinkInfo<xAOD::Muon>(MuonTrack, std::move(trig), m_EFreqdR, pass, "HLT_Muons_RoI.*", &MuonMatchingTool::trigPosForMatchSATrack) : muonLinkInfo;
104 }
105 
106 const xAOD::Muon* MuonMatchingTool :: matchEFSAReadHandle( const EventContext& ctx, const xAOD::Muon *mu) const {
107  ATH_MSG_DEBUG("MuonMonitoring::matchEFSAReadHandle()");
108  const xAOD::TrackParticle* MuonTrack = nullptr;
109  using Type = xAOD::Muon::TrackParticleType;
110  std::vector<Type> types { Type::ExtrapolatedMuonSpectrometerTrackParticle,
111  Type::MSOnlyExtrapolatedMuonSpectrometerTrackParticle,
112  Type::MuonSpectrometerTrackParticle};
113  for (Type type : types){
114  MuonTrack = mu->trackParticle(type);
115  if (MuonTrack) break;
116  }
117  return MuonTrack ? matchReadHandle<xAOD::Muon>( MuonTrack, m_EFreqdR, m_EFSAMuonContainerKey, ctx, &MuonMatchingTool::trigPosForMatchSATrack) : nullptr;
118 }
119 
120 const xAOD::Muon* MuonMatchingTool :: matchEFCB( const xAOD::TruthParticle *mu, std::string trig, bool &pass) const {
121  ATH_MSG_DEBUG("MuonMonitoring::matchEFCB() for TruthParticle");
122  return mu ? match<xAOD::Muon>( mu, std::move(trig), m_EFreqdR, pass, "HLT_MuonsCB_RoI*.*", &MuonMatchingTool::trigPosForMatchCBTrack) : nullptr;
123 }
124 
125 const xAOD::Muon* MuonMatchingTool :: matchEFCB( const xAOD::Muon *mu, std::string trig, bool &pass) const {
126  ATH_MSG_DEBUG("MuonMonitoring::matchEFCB()");
127  const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::Primary);
128  ATH_MSG_DEBUG("HLT_Muons_RoI CB Muon");
129  return MuonTrack ? match<xAOD::Muon>( MuonTrack, std::move(trig), m_EFreqdR, pass, "HLT_MuonsCB_RoI*.*", &MuonMatchingTool::trigPosForMatchCBTrack) : nullptr;
130 }
131 
133  ATH_MSG_DEBUG("MuonMonitoring::matchEFCBLinkInfo()");
134  bool pass = false;
136  const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::Primary);
137  return MuonTrack ? matchLinkInfo<xAOD::Muon>(MuonTrack, std::move(trig), m_EFreqdR, pass, "HLT_MuonsCB_RoI*.*", &MuonMatchingTool::trigPosForMatchCBTrack) : muonLinkInfo;
138 }
139 
140 const xAOD::Muon* MuonMatchingTool :: matchEFCBReadHandle( const EventContext& ctx, const xAOD::Muon *mu) const {
141  ATH_MSG_DEBUG("MuonMonitoring::matchEFCBReadHandle()");
142  const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::Primary);
143  return MuonTrack ? matchReadHandle<xAOD::Muon>( MuonTrack, m_EFreqdR, m_EFCBMuonContainerKey, ctx, &MuonMatchingTool::trigPosForMatchCBTrack) : nullptr;
144 }
145 
146 const xAOD::Muon* MuonMatchingTool :: matchEFSAFS(const xAOD::Muon *mu, std::string trig, bool &pass) const {
147  ATH_MSG_DEBUG("MuonMonitoring::matchEFSAFS()");
148  const xAOD::TrackParticle* MuonTrack = nullptr;
149  using Type = xAOD::Muon::TrackParticleType;
150  std::vector<Type> types { Type::ExtrapolatedMuonSpectrometerTrackParticle,
151  Type::MSOnlyExtrapolatedMuonSpectrometerTrackParticle,
152  Type::MuonSpectrometerTrackParticle};
153  for (Type type : types){
154  MuonTrack = mu->trackParticle(type);
155  ATH_MSG_DEBUG("HLT_Muons_FS SA Muon");
156  if (MuonTrack) break;
157  }
158  return MuonTrack ? match<xAOD::Muon>(MuonTrack, std::move(trig), m_EFreqdR, pass, "HLT_Muons_FS.*", &MuonMatchingTool::trigPosForMatchSATrack) : nullptr;
159 }
160 
161 const xAOD::Muon* MuonMatchingTool :: matchEFSAFS(const xAOD::TruthParticle *mu, std::string trig, bool &pass) const {
162  ATH_MSG_DEBUG("MuonMonitoring::matchEFSAFS() for truth particle");
163  return mu ? match<xAOD::Muon>(mu, std::move(trig), m_EFreqdR, pass, "HLT_Muons_FS.*", &MuonMatchingTool::trigPosForMatchSATrack) : nullptr;
164 }
165 
167  ATH_MSG_DEBUG("MuonMonitoring::matchEFSAFSLinkInfo()");
168  bool pass = false;
170  const xAOD::TrackParticle* MuonTrack = nullptr;
171  using Type = xAOD::Muon::TrackParticleType;
172  std::vector<Type> types { Type::ExtrapolatedMuonSpectrometerTrackParticle,
173  Type::MSOnlyExtrapolatedMuonSpectrometerTrackParticle,
174  Type::MuonSpectrometerTrackParticle};
175  for (Type type : types){
176  MuonTrack = mu->trackParticle(type);
177  if (MuonTrack) break;
178  }
179  return MuonTrack ? matchLinkInfo<xAOD::Muon>(MuonTrack, std::move(trig), m_EFreqdR, pass, "HLT_Muons_FS.*", &MuonMatchingTool::trigPosForMatchSATrack) : muonLinkInfo;
180 }
181 
182 const xAOD::Muon* MuonMatchingTool :: matchEFSAFSReadHandle( const EventContext& ctx, const xAOD::Muon *mu) const {
183  ATH_MSG_DEBUG("MuonMonitoring::matchEFSAFSReadHandle()");
184  const xAOD::TrackParticle* MuonTrack = nullptr;
185  using Type = xAOD::Muon::TrackParticleType;
186  std::vector<Type> types { Type::ExtrapolatedMuonSpectrometerTrackParticle,
187  Type::MSOnlyExtrapolatedMuonSpectrometerTrackParticle,
188  Type::MuonSpectrometerTrackParticle};
189  for (Type type : types){
190  MuonTrack = mu->trackParticle(type);
191  if (MuonTrack) break;
192  }
193  return MuonTrack ? matchReadHandle<xAOD::Muon>( MuonTrack, m_EFreqdR, m_EFSAFSMuonContainerKey, ctx, &MuonMatchingTool::trigPosForMatchSATrack) : nullptr;
194 }
195 
196 const xAOD::Muon* MuonMatchingTool :: matchEFCBFS( const xAOD::TruthParticle *mu, std::string trig, bool &pass) const {
197  ATH_MSG_DEBUG("MuonMonitoring::matchEFCBFS() for TruthParticle");
198  return mu ? match<xAOD::Muon>( mu, std::move(trig), m_EFreqdR, pass, "HLT_MuonsCB_FS.*", &MuonMatchingTool::trigPosForMatchCBTrack) : nullptr;
199 }
200 
201 const xAOD::Muon* MuonMatchingTool :: matchEFCBFS( const xAOD::Muon *mu, std::string trig, bool &pass) const {
202  ATH_MSG_DEBUG("MuonMonitoring::matchEFCBFS()");
203  const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::Primary);
204  ATH_MSG_DEBUG("HLT_Muons_FS CB Muon");
205  return MuonTrack ? match<xAOD::Muon>( MuonTrack, std::move(trig), m_EFreqdR, pass, "HLT_MuonsCB_FS.*", &MuonMatchingTool::trigPosForMatchCBTrack) : nullptr;
206 }
207 
209  ATH_MSG_DEBUG("MuonMonitoring::matchEFCBFSLinkInfo()");
210  bool pass = false;
212  const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::Primary);
213  return MuonTrack ? matchLinkInfo<xAOD::Muon>(MuonTrack, std::move(trig), m_EFreqdR, pass, "HLT_MuonsCB_FS.*", &MuonMatchingTool::trigPosForMatchCBTrack) : muonLinkInfo;
214 }
215 
216 const xAOD::Muon* MuonMatchingTool :: matchEFCBFSReadHandle( const EventContext& ctx, const xAOD::Muon *mu) const {
217  ATH_MSG_DEBUG("MuonMonitoring::matchEFCBFSReadHandle()");
218  const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::Primary);
219  return MuonTrack ? matchReadHandle<xAOD::Muon>( MuonTrack, m_EFreqdR, m_EFCBFSMuonContainerKey, ctx, &MuonMatchingTool::trigPosForMatchCBTrack) : nullptr;
220 }
221 
222 const xAOD::Muon* MuonMatchingTool :: matchEFIso( const xAOD::Muon *mu, std::string trig, bool &pass) const {
223  ATH_MSG_DEBUG("MuonMonitoring::matchEFIso()");
224  const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::Primary);
225  return MuonTrack ? match<xAOD::Muon>( MuonTrack, std::move(trig), m_EFreqdR, pass, "HLT_MuonsIso", &MuonMatchingTool::trigPosForMatchCBTrack) : nullptr;
226 }
227 
228 const xAOD::Muon* MuonMatchingTool :: matchEFIso( const xAOD::TruthParticle *mu, std::string trig, bool &pass) const {
229  ATH_MSG_DEBUG("MuonMonitoring::matchEFIso() for truth particle");
230  return mu ? match<xAOD::Muon>( mu, std::move(trig), m_EFreqdR, pass, "HLT_MuonsIso", &MuonMatchingTool::trigPosForMatchCBTrack) : nullptr;
231 }
232 
233 
235  const xAOD::TrackParticle* MatchedTrack = nullptr;
236  const ElementLink<xAOD::MuonContainer> muEL = muLinkInfo.link;
237  float EFEta = (*muEL)->eta();
238  float EFPhi = (*muEL)->phi();
239  float mindR = 999.;
240 
241  SG::ReadHandle<xAOD::TrackParticleContainer> trackHandle(ReadHandleKey, ctx);
242  if ( !trackHandle.isValid() ) return MatchedTrack;
243 
244  const auto track = m_trigDec->associateToEventView<xAOD::TrackParticleContainer>(trackHandle, muLinkInfo);
247 
249 
250  float deta = EFEta - (*it)->eta();
251  float dphi = xAOD::P4Helpers::deltaPhi(EFPhi, (*it)->phi() );
252  float dR = std::sqrt(deta*deta + dphi*dphi);
253 
254  if( dR< mindR ){
255  mindR = dR;
256  MatchedTrack = (*it);
257  }
258  }
259 
260  return MatchedTrack;
261 
262 }
263 
265  ATH_MSG_DEBUG("MuonMonitoring::matchEFCBLinkInfo()");
266  bool pass = false;
268  const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::Primary);
269  return MuonTrack ? matchLinkInfo<xAOD::Muon>(MuonTrack, std::move(trig), m_EFreqdR, pass, "HLT_MuonsIso", &MuonMatchingTool::trigPosForMatchCBTrack) : muonLinkInfo;
270 }
271 
272 
273 const xAOD::L2StandAloneMuon* MuonMatchingTool :: matchL2SA( const xAOD::Muon *mu, const std::string& trig, bool &pass) const {
274  ATH_MSG_DEBUG("MuonMonitoring::matchL2SA()");
275  float reqdR = m_L2SAreqdR;
276  if(m_use_extrapolator){
277  reqdR = reqdRL1byPt(mu->pt());
278  const Amg::Vector3D extPos = offlineMuonAtPivot(mu);
279  if(extPos.norm()>ZERO_LIMIT){
280  return match<xAOD::L2StandAloneMuon>( &extPos, trig, reqdR, pass);
281  }
282  }
283  return match<xAOD::L2StandAloneMuon>( mu, trig, reqdR, pass, "HLT_MuonL2SAInfo");
284 }
285 
287  ATH_MSG_DEBUG("MuonMonitoring::searchL2SALinkInfo()");
288  bool pass = false;
289  return matchLinkInfo<xAOD::L2StandAloneMuon>( mu, std::move(trig), 1000., pass, "HLT_MuonL2SAInfo");
290 }
291 
292 const xAOD::L2StandAloneMuon* MuonMatchingTool :: matchL2SAReadHandle( const EventContext& ctx, const xAOD::Muon *mu) const {
293  ATH_MSG_DEBUG("MuonMonitoring::matchL2SAReadHandle()");
294  float reqdR = m_L2SAreqdR;
295  if(m_use_extrapolator){
296  reqdR = reqdRL1byPt(mu->pt());
297  const Amg::Vector3D extPos = offlineMuonAtPivot(mu);
298  if(extPos.norm()>ZERO_LIMIT){
299  return matchReadHandle<xAOD::L2StandAloneMuon>( &extPos, reqdR, m_L2MuonSAContainerKey, ctx);
300  }
301  }
302  const xAOD::TrackParticle* MuonTrack = nullptr;
303  using Type = xAOD::Muon::TrackParticleType;
304  std::vector<Type> types { Type::ExtrapolatedMuonSpectrometerTrackParticle,
305  Type::MSOnlyExtrapolatedMuonSpectrometerTrackParticle,
306  Type::MuonSpectrometerTrackParticle};
307  for (Type type : types){
308  MuonTrack = mu->trackParticle(type);
309  if (MuonTrack) break;
310  }
311  return MuonTrack ? matchReadHandle<xAOD::L2StandAloneMuon>( MuonTrack, reqdR, m_L2MuonSAContainerKey, ctx) : nullptr;
312 }
313 
314 
315 const xAOD::L2CombinedMuon* MuonMatchingTool :: matchL2CB( const xAOD::Muon *mu, std::string trig, bool &pass) const {
316  ATH_MSG_DEBUG("MuonMonitoring::matchL2CB()");
317  return match<xAOD::L2CombinedMuon>( mu, std::move(trig), m_L2CBreqdR, pass, "HLT_MuonL2CBInfo");
318 }
319 
321  ATH_MSG_DEBUG("MuonMonitoring::searchL2CBLinkInfo()");
322  bool pass = false;
323  return matchLinkInfo<xAOD::L2CombinedMuon>( mu, std::move(trig), 1000., pass, "HLT_MuonL2CBInfo");
324 }
325 
326 const xAOD::L2CombinedMuon* MuonMatchingTool :: matchL2CBReadHandle( const EventContext& ctx, const xAOD::Muon *mu) const {
327  ATH_MSG_DEBUG("MuonMonitoring::matchL2CBReadHandle()");
328  const xAOD::TrackParticle* MuonTrack = mu->trackParticle(xAOD::Muon::TrackParticleType::Primary);
329  return MuonTrack ? matchReadHandle<xAOD::L2CombinedMuon>( MuonTrack, m_L2CBreqdR, m_L2muCombContainerKey, ctx) : nullptr;
330 }
331 
332 const xAOD::MuonRoI* MuonMatchingTool :: matchL1( double refEta, double refPhi, double reqdR, const std::string& trig, bool &pass) const {
333 
335  const TrigConf::HLTChain* chainCfg = m_trigDec->ExperimentalAndExpertMethods().getChainConfigurationDetails(trig);
336  const std::string L1toMatch = chainCfg->lower_chain_name().substr(3);
337 
339  const xAOD::MuonRoI *closest = nullptr;
340 
341  for (const xAOD::MuonRoI* l1muon : *L1rois){
342 
343  // get all L1 thresholds from the L1 menu along with whether the L1roi passed each of those or not
344  const std::vector<std::pair<std::shared_ptr<TrigConf::L1Threshold>, bool> > L1thr_list = m_thresholdTool-> getThresholdDecisions(
345  l1muon->roiWord(), Gaudi::Hive::currentContext());
346 
347  // check the L1 threshold we are looking for
348  bool L1thr_isMatch = false;
349  for(const std::pair<std::shared_ptr<TrigConf::L1Threshold>, bool>& L1thr : L1thr_list){
350  std::shared_ptr<TrigConf::L1Threshold_MU> thr = std::static_pointer_cast<TrigConf::L1Threshold_MU>(L1thr.first);
351  if (L1toMatch == thr->name()){
352  L1thr_isMatch = L1thr.second;
353  break;
354  }
355  }
356  if (!L1thr_isMatch) continue;
357 
358  double l1muonEta = l1muon->eta();
359  double l1muonPhi = l1muon->phi();
360 
361  double deta = refEta - l1muonEta;
362  double dphi = xAOD::P4Helpers::deltaPhi(refPhi, l1muonPhi);
363  double dR = std::sqrt(deta*deta + dphi*dphi);
364  ATH_MSG_DEBUG("L1 muon candidate eta=" << l1muonEta << " phi=" << l1muonPhi << " dR=" << dR);
365  if( dR<reqdR ){
366  reqdR = dR;
367  pass = true;
368  closest = l1muon;
369  ATH_MSG_DEBUG("*** L1 muon eta=" << l1muonEta << " phi=" << l1muonPhi << " dR=" << dR << " isPassed=true" );
370  }
371  else{
372  ATH_MSG_DEBUG("*** L1 muon eta=" << l1muonEta << " phi=" << l1muonPhi << " dR=" << dR << " isPassed=false" );
373  }
374  }
375  return closest;
376 }
377 
378 const xAOD::MuonRoI* MuonMatchingTool :: matchL1( const xAOD::Muon *mu, const std::string& trig, bool &pass) const {
379  double refEta = mu->eta();
380  double refPhi = mu->phi();
381  double reqdR = 0.25;
382 
383  if(m_use_extrapolator){
384  reqdR = reqdRL1byPt(mu->pt());
385  const Amg::Vector3D extPos = offlineMuonAtPivot(mu);
386  if(extPos.norm()>ZERO_LIMIT){
387  refEta = extPos.eta();
388  refPhi = extPos.phi();
389  }
390  }
391  return matchL1(refEta, refPhi, reqdR, trig, pass);
392 }
393 
394 const xAOD::MuonRoI* MuonMatchingTool :: matchL1( const xAOD::TruthParticle *mu, const std::string& trig, bool &pass) const {
395  double refEta = mu->eta();
396  double refPhi = mu->phi();
397  double reqdR = 0.25;
398  return matchL1(refEta, refPhi, reqdR, trig, pass);
399 }
400 
401 const xAOD::Muon* MuonMatchingTool :: matchL2SAtoOff( const EventContext& ctx, const xAOD::L2StandAloneMuon* samu) const {
403 }
404 
405 const xAOD::Muon* MuonMatchingTool :: matchL2CBtoOff( const EventContext& ctx, const xAOD::L2CombinedMuon* cbmu) const {
407 }
408 
409 
411  float offlEta = mu->eta();
412  float offlPhi = mu->phi();
413  float trigEta = samu->roiEta();
414  float trigPhi = samu->roiPhi();
415 
416  float deta = offlEta - trigEta;
417  float dphi = xAOD::P4Helpers::deltaPhi(offlPhi, trigPhi);
418  float dR = sqrt(deta*deta + dphi*dphi);
419  return dR < m_L2SAreqdR;
420 }
421 
423  float dR = xAOD::P4Helpers::deltaR(cbmu, mu, false);
424  return dR < m_L2CBreqdR;
425 }
426 
428  float dR = xAOD::P4Helpers::deltaR(cbiomu, mu, false);
429  return dR < m_L2InsideOutreqdR;
430 }
431 
432 double MuonMatchingTool :: FermiFunction(double x, double x0, double w) {
433  return 1/(1+TMath::Exp(-10*(x-x0)/w));
434 }
435 
436 
437 
439 
440  const Trk::TrackParameters *extRPC = nullptr;
441  const Trk::TrackParameters *extTGC = nullptr;
442 
443  if(!track) return extTGC;
444  double trkEta = track->eta();
445  double extEta =0.;
446  bool isBarrel = true;
447 
448  if( fabs(trkEta)<1.05){
449  extRPC = extTrackToRPC(track);
450  if(!extRPC){
451  isBarrel = false;
452  extTGC = extTrackToTGC(track);
453  }
454  else{
455  isBarrel = true;
456  extEta = extRPC->position().eta();
457  if(fabs(extEta)>=1.05){
458  extTGC = extTrackToTGC(track);
459  isBarrel = (extTGC) == nullptr;
460  }
461  }
462  }
463  else if( fabs(trkEta)>=1.05 ){
464  extTGC = extTrackToTGC(track);
465  if(!extTGC){
466  isBarrel = true;
467  extRPC = extTrackToRPC(track);
468  }
469  else{
470  isBarrel = false;
471  extEta = extTGC->position().eta();
472  if(fabs(extEta)<1.05){
473  extRPC = extTrackToRPC(track);
474  isBarrel = (extRPC) != nullptr;
475  }
476  }
477  }
478 
479  ATH_MSG_DEBUG("extTGC=" << extTGC << " extRPC=" << extRPC << " isBarrel=" << isBarrel);
480  if( isBarrel) delete extTGC;
481  else if(!isBarrel) delete extRPC;
482  return (isBarrel) ? extRPC : extTGC;
483 }
484 
485 
486 
488  ATH_MSG_DEBUG("extTrackToTGC");
489  if(!trk) return nullptr;
490  double TGC_Z = ( trk->eta()>0 )? 15153.0:-15153.0;
492  //object pointed by matrix will be deleted in destructer of DiscSurface, therefore release it
493  std::unique_ptr<Trk::DiscSurface> disc(new Trk::DiscSurface( matrix, 0., 15000.));
494  const bool boundaryCheck = true;
495 
496  const Trk::TrackParameters* param = m_extrapolator->extrapolate(Gaudi::Hive::currentContext(),
497  trk->perigeeParameters(),
498  *disc,
500  boundaryCheck,
501  Trk::muon).release();
502 
503  ATH_MSG_DEBUG("param=" << param
504  << " eta=" << ((param) ? param->position().eta() : 0)
505  << " phi=" << ((param) ? param->position().phi() : 0));;
506  return param;
507 }
508 
509 
510 
512  ATH_MSG_DEBUG("extTrackToRPC");
513  if(!trk) return nullptr;
514  std::unique_ptr<Trk::CylinderSurface> barrel(new Trk::CylinderSurface( 7478., 15000. ));
515  const bool boundaryCheck = true;
516 
517  const Trk::TrackParameters* param = m_extrapolator->extrapolate(Gaudi::Hive::currentContext(),
518  trk->perigeeParameters(),
519  *barrel,
521  boundaryCheck,
522  Trk::muon).release();
523  return param;
524 }
525 
526 
527 
528 double MuonMatchingTool :: reqdRL1byPt( double mupt){
529  double dR = 0.08;
530  if( mupt < 10000. ) {
531  dR = -0.00001*mupt + 0.18;
532  }
533  return dR;
534 }
MuonMatchingTool::matchEFIso
const xAOD::Muon * matchEFIso(const xAOD::Muon *mu, std::string trigger, bool &pass) const
Function that searches for an EF isolation muon (EFIso) candidate and judges if it is matched to a gi...
Definition: MuonMatchingTool.cxx:222
Trk::anyDirection
@ anyDirection
Definition: PropDirection.h:22
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
TrigCompositeUtils::LinkInfo::link
ElementLink< T > link
Link to the feature.
Definition: LinkInfo.h:59
MuonMatchingTool::searchL2SALinkInfo
const TrigCompositeUtils::LinkInfo< xAOD::L2StandAloneMuonContainer > searchL2SALinkInfo(const xAOD::Muon *mu, std::string trigger) const
Function that searches for the L2 standalone muon (L2MuonSA) candidate closest to a given offline muo...
Definition: MuonMatchingTool.cxx:286
MuonMatchingTool::m_L2CBreqdR
const float m_L2CBreqdR
Definition: MuonMatchingTool.h:363
xAOD::L2StandAloneMuon_v2
Class describing standalone muons reconstructed in the LVL2 trigger.
Definition: L2StandAloneMuon_v2.h:36
Trk::ParametersBase::position
const Amg::Vector3D & position() const
Access method for the position.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
MuonRoIContainer.h
xAOD::TrackParticle_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: TrackParticle_v1.cxx:78
MuonMatchingTool::m_EFreqdR
const float m_EFreqdR
Definition: MuonMatchingTool.h:365
MuonMatchingTool::m_extrapolator
PublicToolHandle< Trk::IExtrapolator > m_extrapolator
Definition: MuonMatchingTool.h:459
MuonMatchingTool::m_MStrackContainerKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_MStrackContainerKey
Definition: MuonMatchingTool.h:448
TrigConf::HLTChain::lower_chain_name
const std::string & lower_chain_name() const
Definition: TrigConfHLTData/TrigConfHLTData/HLTChain.h:78
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
skel.it
it
Definition: skel.GENtoEVGEN.py:407
MuonMatchingTool::searchL2CBLinkInfo
const TrigCompositeUtils::LinkInfo< xAOD::L2CombinedMuonContainer > searchL2CBLinkInfo(const xAOD::Muon *mu, std::string trigger) const
Function that searches for the L2 combined muon (L2muComb) candidate closest to a given offline muon.
Definition: MuonMatchingTool.cxx:320
MuonMatchingTool::matchEFCBReadHandle
const xAOD::Muon * matchEFCBReadHandle(const EventContext &ctx, const xAOD::Muon *mu) const
Function that searches for an EF combined muon (EFCB) candidate by ReadHandle and judges if it is mat...
Definition: MuonMatchingTool.cxx:140
xAOD::P4Helpers::deltaPhi
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Definition: xAODP4Helpers.h:69
MuonMatchingTool::trigPosForMatchSATrack
static std::tuple< bool, double, double > trigPosForMatchSATrack(const xAOD::Muon *mu)
Definition: MuonMatchingTool.cxx:51
MuonMatchingTool::m_EFCBFSMuonContainerKey
SG::ReadHandleKey< xAOD::MuonContainer > m_EFCBFSMuonContainerKey
Definition: MuonMatchingTool.h:447
Trk::DiscSurface
Definition: DiscSurface.h:54
MuonMatchingTool::isMatchedL2SA
bool isMatchedL2SA(const xAOD::L2StandAloneMuon *, const xAOD::Muon *) const
Definition: MuonMatchingTool.cxx:410
MuonMatchingTool::extTrackToRPC
const Trk::TrackParameters * extTrackToRPC(const xAOD::TrackParticle *track) const
Definition: MuonMatchingTool.cxx:511
SG::ReadHandleKey< xAOD::TrackParticleContainer >
TrigConf::HLTChain
HLT chain configuration information.
Definition: TrigConfHLTData/TrigConfHLTData/HLTChain.h:35
MuonMatchingTool::matchL2SAReadHandle
const xAOD::L2StandAloneMuon * matchL2SAReadHandle(const EventContext &ctx, const xAOD::Muon *mu) const
Function that searches for an L2 standalone muon (L2MuonSA) candidate by ReadHandle and judges if it ...
Definition: MuonMatchingTool.cxx:292
x
#define x
MuonMatchingTool::matchEFSAFSLinkInfo
const TrigCompositeUtils::LinkInfo< xAOD::MuonContainer > matchEFSAFSLinkInfo(const xAOD::Muon *mu, std::string trig) const
Function that searches for an EF standalone muon (EFSAFS) candidate and judges if it is matched to a ...
Definition: MuonMatchingTool.cxx:166
MuonMatchingTool::matchL2CB
const xAOD::L2CombinedMuon * matchL2CB(const xAOD::Muon *mu, std::string trigger, bool &pass) const
Function that searches for an L2 combined muon (L2muComb) candidate and judges if it is matched to a ...
Definition: MuonMatchingTool.cxx:315
MuonMatchingTool::matchL2SAtoOff
const xAOD::Muon * matchL2SAtoOff(const EventContext &ctx, const xAOD::L2StandAloneMuon *samu) const
Function that searches for an offline muon matched to L2SA muon.
Definition: MuonMatchingTool.cxx:401
MuonMatchingTool::PosForMatchSATrack
static std::tuple< bool, double, double > PosForMatchSATrack(const xAOD::Muon *mu)
Definition: MuonMatchingTool.cxx:59
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
MuonMatchingTool::m_thresholdTool
ToolHandle< LVL1::ITrigThresholdDecisionTool > m_thresholdTool
Definition: MuonMatchingTool.h:455
MuonMatchingTool::extTrackToPivot
const Trk::TrackParameters * extTrackToPivot(const xAOD::TrackParticle *track) const
Function to extrapolate a Inner Detector track to the pivot plane i.e.
Definition: MuonMatchingTool.cxx:438
MuonMatchingTool::m_CBtrackContainerKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_CBtrackContainerKey
Definition: MuonMatchingTool.h:449
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
xAOD::L2CombinedMuon_v1
Class describing combined muon reconstructed in the LVL2 trigger.
Definition: L2CombinedMuon_v1.h:41
InDet::ExclusiveOrigin::Primary
@ Primary
Definition: InDetTrackTruthOriginDefs.h:163
MuonMatchingTool::FermiFunction
static double FermiFunction(double x, double x0, double w)
Definition: MuonMatchingTool.cxx:432
MuonMatchingTool::matchL2CBReadHandle
const xAOD::L2CombinedMuon * matchL2CBReadHandle(const EventContext &ctx, const xAOD::Muon *mu) const
Function that searches for an L2 combined muon (L2muComb) candidate by ReadHandle and judges if it is...
Definition: MuonMatchingTool.cxx:326
MuonMatchingTool::m_L2MuonSAContainerKey
SG::ReadHandleKey< xAOD::L2StandAloneMuonContainer > m_L2MuonSAContainerKey
Definition: MuonMatchingTool.h:442
xAOD::TrackParticle_v1::perigeeParameters
const Trk::Perigee & perigeeParameters() const
Returns the Trk::MeasuredPerigee track parameters.
Definition: TrackParticle_v1.cxx:486
IBLCalibrationConfig.thr
thr
Definition: IBLCalibrationConfig.py:39
MuonMatchingTool::m_EFSAFSMuonContainerKey
SG::ReadHandleKey< xAOD::MuonContainer > m_EFSAFSMuonContainerKey
Definition: MuonMatchingTool.h:446
xAOD::L2StandAloneMuon_v2::roiPhi
float roiPhi() const
Get and set RoI phi.
MuonMatchingTool.h
xAOD::P4Helpers::deltaR
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
Definition: xAODP4Helpers.h:150
MuonMatchingTool::matchL2CBtoOff
const xAOD::Muon * matchL2CBtoOff(const EventContext &ctx, const xAOD::L2CombinedMuon *cbmu) const
Function that searches for an offline muon matched to L2CB muon.
Definition: MuonMatchingTool.cxx:405
MuonMatchingTool::isMatchedL2CB
bool isMatchedL2CB(const xAOD::L2CombinedMuon *, const xAOD::Muon *) const
Definition: MuonMatchingTool.cxx:422
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
Trk::CylinderSurface
Definition: CylinderSurface.h:55
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
MuonMatchingTool::m_L2InsideOutreqdR
const float m_L2InsideOutreqdR
Definition: MuonMatchingTool.h:364
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
MuonMatchingTool::m_L2muCombContainerKey
SG::ReadHandleKey< xAOD::L2CombinedMuonContainer > m_L2muCombContainerKey
Definition: MuonMatchingTool.h:443
MuonMatchingTool::m_trigDec
PublicToolHandle< Trig::TrigDecisionTool > m_trigDec
Definition: MuonMatchingTool.h:458
MuonMatchingTool::initialize
virtual StatusCode initialize() override
Definition: MuonMatchingTool.cxx:16
xAOD::MuonRoI_v1
Class describing a LVL1 muon region of interest.
Definition: MuonRoI_v1.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
MuonMatchingTool::matchL1
const xAOD::MuonRoI * matchL1(const xAOD::Muon *mu, const std::string &trigger, bool &pass) const
Function that searches for a Level 1 muon candidate and judges if it is matched to a given offline mu...
Definition: MuonMatchingTool.cxx:378
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::ParametersBase
Definition: ParametersBase.h:55
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
Trk::muon
@ muon
Definition: ParticleHypothesis.h:31
xAODType
Definition: ObjectType.h:13
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
ZERO_LIMIT
const float ZERO_LIMIT
Definition: VP1TriggerHandleL2.cxx:37
Trk::Combined
@ Combined
Definition: TrackSummaryTool.h:32
MuonMatchingTool::matchEFCBFSReadHandle
const xAOD::Muon * matchEFCBFSReadHandle(const EventContext &ctx, const xAOD::Muon *mu) const
Function that searches for an EF combined muon (EFCBFS) candidate by ReadHandle and judges if it is m...
Definition: MuonMatchingTool.cxx:216
MuonMatchingTool::matchEFCBFS
const xAOD::Muon * matchEFCBFS(const xAOD::Muon *mu, std::string trigger, bool &pass) const
Function that searches for an EF combined muon (EFCBFS) candidate and judges if it is matched to a gi...
Definition: MuonMatchingTool.cxx:201
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
MuonMatchingTool::offlineMuonAtPivot
const Amg::Vector3D offlineMuonAtPivot(const xAOD::Muon *mu) const
Definition: MuonMatchingTool.cxx:38
MuonMatchingTool::MuonMatchingTool
MuonMatchingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: MuonMatchingTool.cxx:11
MuonMatchingTool::m_use_extrapolator
Gaudi::Property< bool > m_use_extrapolator
Definition: MuonMatchingTool.h:452
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonMatchingTool::matchEFSA
const xAOD::Muon * matchEFSA(const xAOD::Muon *mu, std::string trigger, bool &pass) const
Function that searches for an EF standalone muon (EFSA) candidate and judges if it is matched to a gi...
Definition: MuonMatchingTool.cxx:70
MuonMatchingTool::m_MuonContainerKey
SG::ReadHandleKey< xAOD::MuonContainer > m_MuonContainerKey
Definition: MuonMatchingTool.h:441
MuonMatchingTool::PosForMatchCBTrack
static std::tuple< bool, double, double > PosForMatchCBTrack(const xAOD::Muon *mu)
Definition: MuonMatchingTool.cxx:64
python.testIfMatch.matrix
matrix
Definition: testIfMatch.py:63
TrigCompositeUtils::LinkInfo
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition: LinkInfo.h:29
MuonMatchingTool::trigPosForMatchCBTrack
static std::tuple< bool, double, double > trigPosForMatchCBTrack(const xAOD::Muon *mu)
Definition: MuonMatchingTool.cxx:55
MuonMatchingTool::matchEFSAReadHandle
const xAOD::Muon * matchEFSAReadHandle(const EventContext &ctx, const xAOD::Muon *mu) const
Function that searches for an EF standalone muon (EFSA) candidate by ReadHandle and judges if it is m...
Definition: MuonMatchingTool.cxx:106
MuonMatchingTool::m_EFCBMuonContainerKey
SG::ReadHandleKey< xAOD::MuonContainer > m_EFCBMuonContainerKey
Definition: MuonMatchingTool.h:445
MuonMatchingTool::matchEFCB
const xAOD::Muon * matchEFCB(const xAOD::Muon *mu, std::string trigger, bool &pass) const
Function that searches for an EF combined muon (EFCB) candidate and judges if it is matched to a give...
Definition: MuonMatchingTool.cxx:125
xAOD::L2StandAloneMuon_v2::roiEta
float roiEta() const
Get and set RoI eta.
MuonMatchingTool::matchL2SA
const xAOD::L2StandAloneMuon * matchL2SA(const xAOD::Muon *mu, const std::string &trigger, bool &pass) const
Function that searches for an L2 standalone muon (L2MuonSA) candidate and judges if it is matched to ...
Definition: MuonMatchingTool.cxx:273
MuonMatchingTool::SearchEFTrack
const xAOD::TrackParticle * SearchEFTrack(const EventContext &ctx, const TrigCompositeUtils::LinkInfo< xAOD::MuonContainer > &muLinkInfo, const SG::ReadHandleKey< xAOD::TrackParticleContainer > &ReadHandleKey) const
Function that searches for an EF muon track (e.g.
Definition: MuonMatchingTool.cxx:234
MuonMatchingTool::isMatchedL2InsideOut
bool isMatchedL2InsideOut(const xAOD::L2CombinedMuon *, const xAOD::Muon *) const
Definition: MuonMatchingTool.cxx:427
DetectorZone::barrel
@ barrel
python.LArCondContChannels.isBarrel
isBarrel
Definition: LArCondContChannels.py:659
MuonMatchingTool::matchEFCBLinkInfo
const TrigCompositeUtils::LinkInfo< xAOD::MuonContainer > matchEFCBLinkInfo(const xAOD::Muon *mu, std::string trig) const
Function that searches for an EF combined muon (EFCB) candidate and judges if it is matched to a give...
Definition: MuonMatchingTool.cxx:132
MuonMatchingTool::extTrackToTGC
const Trk::TrackParameters * extTrackToTGC(const xAOD::TrackParticle *track) const
Definition: MuonMatchingTool.cxx:487
MuonMatchingTool::matchEFCBFSLinkInfo
const TrigCompositeUtils::LinkInfo< xAOD::MuonContainer > matchEFCBFSLinkInfo(const xAOD::Muon *mu, std::string trig) const
Function that searches for an EF combined muon (EFCBFS) candidate and judges if it is matched to a gi...
Definition: MuonMatchingTool.cxx:208
MuonMatchingTool::m_EFSAMuonContainerKey
SG::ReadHandleKey< xAOD::MuonContainer > m_EFSAMuonContainerKey
Definition: MuonMatchingTool.h:444
MuonMatchingTool::matchEFSALinkInfo
const TrigCompositeUtils::LinkInfo< xAOD::MuonContainer > matchEFSALinkInfo(const xAOD::Muon *mu, std::string trig) const
Function that searches for an EF standalone muon (EFSA) candidate and judges if it is matched to a gi...
Definition: MuonMatchingTool.cxx:90
xAOD::track
@ track
Definition: TrackingPrimitives.h:513
MuonMatchingTool::matchEFIsoLinkInfo
const TrigCompositeUtils::LinkInfo< xAOD::MuonContainer > matchEFIsoLinkInfo(const xAOD::Muon *mu, std::string trig) const
Function that searches for an EF isolation muon (EFIso) candidate and judges if it is matched to a gi...
Definition: MuonMatchingTool.cxx:264
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
MuonMatchingTool::m_L2SAreqdR
const float m_L2SAreqdR
Definition: MuonMatchingTool.h:362
AthAlgTool
Definition: AthAlgTool.h:26
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:198
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:51
TriggerTest.L1rois
L1rois
Definition: TriggerTest.py:20
MuonMatchingTool::matchOff
const xAOD::Muon * matchOff(const EventContext &ctx, const T *trig, float reqdR, std::tuple< bool, double, double >(*offlinePosForMatchFunc)(const xAOD::Muon *), std::tuple< bool, double, double >(*trigPosForMatchFunc)(const T *)=&MuonMatchingTool::trigPosForMatch< T >) const
Function that searches for an offline muon candidate matched to online muon of type T.
MuonMatchingTool::matchEFSAFSReadHandle
const xAOD::Muon * matchEFSAFSReadHandle(const EventContext &ctx, const xAOD::Muon *mu) const
Function that searches for an EF standalone muon (EFSAFS) candidate by ReadHandle and judges if it is...
Definition: MuonMatchingTool.cxx:182
MuonMatchingTool::m_MuonRoIContainerKey
SG::ReadHandleKey< xAOD::MuonRoIContainer > m_MuonRoIContainerKey
Definition: MuonMatchingTool.h:440
xAOD::TrackParticle_v1::phi
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .)
MuonMatchingTool::reqdRL1byPt
static double reqdRL1byPt(double mupt)
Function compute dR used for matching offline muons and level 1 RoIs at the pivot plane.
Definition: MuonMatchingTool.cxx:528
MuonMatchingTool::matchEFSAFS
const xAOD::Muon * matchEFSAFS(const xAOD::Muon *mu, std::string trigger, bool &pass) const
Function that searches for an EF FS standalone muon (EFSAFS) candidate and judges if it is matched to...
Definition: MuonMatchingTool.cxx:146