CMS 3D CMS Logo

Muon.cc
Go to the documentation of this file.
6 
7 using namespace reco;
8 
9 Muon::Muon(Charge q, const LorentzVector& p4, const Point& vtx) : RecoCandidate(q, p4, vtx, -13 * q) {
10  energyValid_ = false;
11  matchesValid_ = false;
12  isolationValid_ = false;
13  pfIsolationValid_ = false;
14  qualityValid_ = false;
15  caloCompatibility_ = -9999.;
16  type_ = 0;
17  bestTunePTrackType_ = reco::Muon::None;
18  bestTrackType_ = reco::Muon::None;
19  selectors_ = 0;
20 }
21 
22 Muon::Muon() {
23  energyValid_ = false;
24  matchesValid_ = false;
25  isolationValid_ = false;
26  pfIsolationValid_ = false;
27  qualityValid_ = false;
28  caloCompatibility_ = -9999.;
29  type_ = 0;
30  bestTrackType_ = reco::Muon::None;
31  bestTunePTrackType_ = reco::Muon::None;
32  selectors_ = 0;
33 }
34 
35 bool Muon::overlap(const Candidate& c) const {
36  const RecoCandidate* o = dynamic_cast<const RecoCandidate*>(&c);
37  return (o != nullptr && (checkOverlap(track(), o->track()) || checkOverlap(standAloneMuon(), o->standAloneMuon()) ||
38  checkOverlap(combinedMuon(), o->combinedMuon()) ||
39  checkOverlap(standAloneMuon(), o->track()) || checkOverlap(combinedMuon(), o->track())));
40 }
41 
42 Muon* Muon::clone() const { return new Muon(*this); }
43 
44 int Muon::numberOfChambersCSCorDT() const {
45  int total = 0;
46  int nAll = numberOfChambers();
47  for (int iC = 0; iC < nAll; ++iC) {
49  total++;
50  }
51 
52  return total;
53 }
54 
55 int Muon::numberOfMatches(ArbitrationType type) const {
56  int matches(0);
57  for (auto& chamberMatch : muMatches_) {
58  if (type == RPCHitAndTrackArbitration) {
59  if (chamberMatch.rpcMatches.empty())
60  continue;
61  matches += chamberMatch.rpcMatches.size();
62  continue;
63  }
64  if (type == ME0SegmentAndTrackArbitration) {
65  if (chamberMatch.me0Matches.empty())
66  continue;
67  matches += chamberMatch.me0Matches.size();
68  continue;
69  }
70  if (type == GEMSegmentAndTrackArbitration) {
71  if (chamberMatch.gemMatches.empty())
72  continue;
73  matches += chamberMatch.gemMatches.size();
74  continue;
75  }
76 
77  if (chamberMatch.segmentMatches.empty())
78  continue;
79  if (type == NoArbitration) {
80  matches++;
81  continue;
82  }
83 
84  for (auto& segmentMatch : chamberMatch.segmentMatches) {
85  if (type == SegmentArbitration)
86  if (segmentMatch.isMask(MuonSegmentMatch::BestInChamberByDR)) {
87  matches++;
88  break;
89  }
90  if (type == SegmentAndTrackArbitration)
91  if (segmentMatch.isMask(MuonSegmentMatch::BestInChamberByDR) &&
92  segmentMatch.isMask(MuonSegmentMatch::BelongsToTrackByDR)) {
93  matches++;
94  break;
95  }
96  if (type == SegmentAndTrackArbitrationCleaned)
97  if (segmentMatch.isMask(MuonSegmentMatch::BestInChamberByDR) &&
98  segmentMatch.isMask(MuonSegmentMatch::BelongsToTrackByDR) &&
99  segmentMatch.isMask(MuonSegmentMatch::BelongsToTrackByCleaning)) {
100  matches++;
101  break;
102  }
103  }
104  }
105 
106  return matches;
107 }
108 
109 int Muon::numberOfMatchedStations(ArbitrationType type) const {
110  int stations(0);
111 
112  unsigned int theStationMask = stationMask(type);
113  // eight stations, eight bits
114  for (int it = 0; it < 8; ++it)
115  if (theStationMask & 1 << it)
116  ++stations;
117 
118  return stations;
119 }
120 
121 unsigned int Muon::expectedNnumberOfMatchedStations(float minDistanceFromEdge) const {
122  unsigned int stationMask = 0;
123  minDistanceFromEdge = std::abs(minDistanceFromEdge);
124  for (auto& chamberMatch : muMatches_) {
125  if (chamberMatch.detector() != MuonSubdetId::DT && chamberMatch.detector() != MuonSubdetId::CSC)
126  continue;
127  float edgeX = chamberMatch.edgeX;
128  float edgeY = chamberMatch.edgeY;
129  // check we if the trajectory is well within the acceptance
130  if (edgeX < 0 && -edgeX > minDistanceFromEdge && edgeY < 0 && -edgeY > minDistanceFromEdge)
131  stationMask |= 1 << ((chamberMatch.station() - 1) + 4 * (chamberMatch.detector() - 1));
132  }
133  unsigned int n = 0;
134  for (unsigned int i = 0; i < 8; ++i)
135  if (stationMask & (1 << i))
136  n++;
137  return n;
138 }
139 
140 unsigned int Muon::stationMask(ArbitrationType type) const {
141  unsigned int totMask(0);
142  unsigned int curMask(0);
143 
144  for (auto& chamberMatch : muMatches_) {
145  if (type == RPCHitAndTrackArbitration) {
146  if (chamberMatch.rpcMatches.empty())
147  continue;
148  RPCDetId rollId = chamberMatch.id.rawId();
149  int rpcIndex = rollId.region() == 0 ? 1 : 2;
150  curMask = 1 << ((chamberMatch.station() - 1) + 4 * (rpcIndex - 1));
151  // do not double count
152  if (!(totMask & curMask))
153  totMask += curMask;
154  continue;
155  }
156 
157  if (chamberMatch.segmentMatches.empty())
158  continue;
159  if (type == NoArbitration) {
160  curMask = 1 << ((chamberMatch.station() - 1) + 4 * (chamberMatch.detector() - 1));
161  // do not double count
162  if (!(totMask & curMask))
163  totMask += curMask;
164  continue;
165  }
166 
167  for (auto& segmentMatch : chamberMatch.segmentMatches) {
168  if (type == SegmentArbitration)
169  if (segmentMatch.isMask(MuonSegmentMatch::BestInStationByDR)) {
170  curMask = 1 << ((chamberMatch.station() - 1) + 4 * (chamberMatch.detector() - 1));
171  // do not double count
172  if (!(totMask & curMask))
173  totMask += curMask;
174  break;
175  }
176  if (type == SegmentAndTrackArbitration)
177  if (segmentMatch.isMask(MuonSegmentMatch::BestInStationByDR) &&
178  segmentMatch.isMask(MuonSegmentMatch::BelongsToTrackByDR)) {
179  curMask = 1 << ((chamberMatch.station() - 1) + 4 * (chamberMatch.detector() - 1));
180  // do not double count
181  if (!(totMask & curMask))
182  totMask += curMask;
183  break;
184  }
185  if (type == SegmentAndTrackArbitrationCleaned)
186  if (segmentMatch.isMask(MuonSegmentMatch::BestInStationByDR) &&
187  segmentMatch.isMask(MuonSegmentMatch::BelongsToTrackByDR) &&
188  segmentMatch.isMask(MuonSegmentMatch::BelongsToTrackByCleaning)) {
189  curMask = 1 << ((chamberMatch.station() - 1) + 4 * (chamberMatch.detector() - 1));
190  // do not double count
191  if (!(totMask & curMask))
192  totMask += curMask;
193  break;
194  }
195  }
196  }
197 
198  return totMask;
199 }
200 
201 int Muon::numberOfMatchedRPCLayers(ArbitrationType type) const {
202  int layers(0);
203 
204  unsigned int theRPCLayerMask = RPClayerMask(type);
205  // maximum ten layers because of 6 layers in barrel and 3 (4) layers in each endcap before (after) upscope
206  for (int it = 0; it < 10; ++it)
207  if (theRPCLayerMask & 1 << it)
208  ++layers;
209 
210  return layers;
211 }
212 
213 unsigned int Muon::RPClayerMask(ArbitrationType type) const {
214  unsigned int totMask(0);
215  unsigned int curMask(0);
216  for (auto& chamberMatch : muMatches_) {
217  if (chamberMatch.rpcMatches.empty())
218  continue;
219 
220  RPCDetId rollId = chamberMatch.id.rawId();
221  const int region = rollId.region();
222  const int stationIndex = chamberMatch.station();
223  int rpcLayer = stationIndex;
224  if (region == 0) {
225  const int layer = rollId.layer();
226  rpcLayer = stationIndex - 1 + stationIndex * layer;
227  if ((stationIndex == 2 && layer == 2) || (stationIndex == 4 && layer == 1))
228  rpcLayer -= 1;
229  } else
230  rpcLayer += 6;
231 
232  curMask = 1 << (rpcLayer - 1);
233  // do not double count
234  if (!(totMask & curMask))
235  totMask += curMask;
236  }
237 
238  return totMask;
239 }
240 
241 unsigned int Muon::stationGapMaskDistance(float distanceCut) const {
242  unsigned int totMask(0);
243  distanceCut = std::abs(distanceCut);
244  for (auto& chamberMatch : muMatches_) {
245  unsigned int curMask(0);
246  const int detectorIndex = chamberMatch.detector();
247  if (detectorIndex < 1 || detectorIndex >= 4)
248  continue;
249  const int stationIndex = chamberMatch.station();
250  if (stationIndex < 1 || stationIndex >= 5)
251  continue;
252 
253  float edgeX = chamberMatch.edgeX;
254  float edgeY = chamberMatch.edgeY;
255  if (edgeX < 0 && -edgeX > distanceCut && edgeY < 0 &&
256  -edgeY > distanceCut) // inside the chamber so negates all gaps for this station
257  continue;
258 
259  if ((std::abs(edgeX) < distanceCut && edgeY < distanceCut) ||
260  (std::abs(edgeY) < distanceCut && edgeX < distanceCut)) // inside gap
261  curMask = 1 << ((stationIndex - 1) + 4 * (detectorIndex - 1));
262  totMask += curMask; // add to total mask
263  }
264 
265  return totMask;
266 }
267 
268 unsigned int Muon::stationGapMaskPull(float sigmaCut) const {
269  sigmaCut = std::abs(sigmaCut);
270  unsigned int totMask(0);
271  for (auto& chamberMatch : muMatches_) {
272  unsigned int curMask(0);
273  const int detectorIndex = chamberMatch.detector();
274  if (detectorIndex < 1 || detectorIndex >= 4)
275  continue;
276  const int stationIndex = chamberMatch.station();
277  if (stationIndex < 1 || stationIndex >= 5)
278  continue;
279 
280  float edgeX = chamberMatch.edgeX;
281  float edgeY = chamberMatch.edgeY;
282  float xErr = chamberMatch.xErr + 0.000001; // protect against division by zero later
283  float yErr = chamberMatch.yErr + 0.000001; // protect against division by zero later
284  if (edgeX < 0 && std::abs(edgeX / xErr) > sigmaCut && edgeY < 0 &&
285  std::abs(edgeY / yErr) > sigmaCut) // inside the chamber so negates all gaps for this station
286  continue;
287 
288  if ((std::abs(edgeX / xErr) < sigmaCut && edgeY < sigmaCut * yErr) ||
289  (std::abs(edgeY / yErr) < sigmaCut && edgeX < sigmaCut * xErr)) // inside gap
290  curMask = 1 << ((stationIndex - 1) + 4 * (detectorIndex - 1));
291  totMask += curMask; // add to total mask
292  }
293 
294  return totMask;
295 }
296 
297 int Muon::nDigisInStation(int station, int muonSubdetId) const {
298  int nDigis(0);
299  std::map<int, int> me11DigisPerCh;
300 
301  if (muonSubdetId != MuonSubdetId::CSC && muonSubdetId != MuonSubdetId::DT)
302  return 0;
303 
304  for (auto& match : muMatches_) {
305  if (match.detector() != muonSubdetId || match.station() != station)
306  continue;
307 
308  int nDigisInCh = match.nDigisInRange;
309 
310  if (muonSubdetId == MuonSubdetId::CSC && station == 1) {
311  CSCDetId id(match.id.rawId());
312 
313  int chamber = id.chamber();
314  int ring = id.ring();
315 
316  if (ring == 1 || ring == 4) // merge ME1/1a and ME1/1b digis
317  {
318  if (me11DigisPerCh.find(chamber) == me11DigisPerCh.end())
319  me11DigisPerCh[chamber] = 0;
320 
321  me11DigisPerCh[chamber] += nDigisInCh;
322 
323  continue;
324  }
325  }
326 
327  if (nDigisInCh > nDigis)
328  nDigis = nDigisInCh;
329  }
330 
331  for (const auto& me11DigisInCh : me11DigisPerCh) {
332  int nMe11DigisInCh = me11DigisInCh.second;
333  if (nMe11DigisInCh > nDigis)
334  nDigis = nMe11DigisInCh;
335  }
336 
337  return nDigis;
338 }
339 
340 bool Muon::hasShowerInStation(int station, int muonSubdetId, int nDtDigisCut, int nCscDigisCut) const {
341  if (muonSubdetId != MuonSubdetId::DT && muonSubdetId != MuonSubdetId::CSC)
342  return false;
343  auto nDigisCut = muonSubdetId == MuonSubdetId::DT ? nDtDigisCut : nCscDigisCut;
344 
345  return nDigisInStation(station, muonSubdetId) >= nDigisCut;
346 }
347 
348 int Muon::numberOfShowers(int nDtDigisCut, int nCscDigisCut) const {
349  int nShowers = 0;
350  for (int station = 1; station < 5; ++station) {
351  if (hasShowerInStation(station, MuonSubdetId::DT, nDtDigisCut, nCscDigisCut))
352  nShowers++;
353  if (hasShowerInStation(station, MuonSubdetId::CSC, nDtDigisCut, nCscDigisCut))
354  nShowers++;
355  }
356 
357  return nShowers;
358 }
359 
360 int Muon::numberOfSegments(int station, int muonSubdetId, ArbitrationType type) const {
361  int segments(0);
362  for (auto& chamberMatch : muMatches_) {
363  if (chamberMatch.segmentMatches.empty())
364  continue;
365  if (chamberMatch.detector() != muonSubdetId || chamberMatch.station() != station)
366  continue;
367 
368  if (type == NoArbitration) {
369  segments += chamberMatch.segmentMatches.size();
370  continue;
371  }
372 
373  for (auto& segmentMatch : chamberMatch.segmentMatches) {
374  if (type == SegmentArbitration)
375  if (segmentMatch.isMask(MuonSegmentMatch::BestInStationByDR)) {
376  segments++;
377  break;
378  }
379  if (type == SegmentAndTrackArbitration)
380  if (segmentMatch.isMask(MuonSegmentMatch::BestInStationByDR) &&
381  segmentMatch.isMask(MuonSegmentMatch::BelongsToTrackByDR)) {
382  segments++;
383  break;
384  }
385  if (type == SegmentAndTrackArbitrationCleaned)
386  if (segmentMatch.isMask(MuonSegmentMatch::BestInStationByDR) &&
387  segmentMatch.isMask(MuonSegmentMatch::BelongsToTrackByDR) &&
388  segmentMatch.isMask(MuonSegmentMatch::BelongsToTrackByCleaning)) {
389  segments++;
390  break;
391  }
392  }
393  }
394 
395  return segments;
396 }
397 
398 const std::vector<const MuonChamberMatch*> Muon::chambers(int station, int muonSubdetId) const {
399  std::vector<const MuonChamberMatch*> chambers;
400  for (std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
401  chamberMatch != muMatches_.end();
402  chamberMatch++)
403  if (chamberMatch->detector() == muonSubdetId && chamberMatch->station() == station)
404  chambers.push_back(&(*chamberMatch));
405  return chambers;
406 }
407 
408 std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> Muon::pair(
409  const std::vector<const MuonChamberMatch*>& chambers, ArbitrationType type) const {
410  MuonChamberMatch* m = nullptr;
411  MuonSegmentMatch* s = nullptr;
412  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair(m, s);
413 
414  if (chambers.empty())
415  return chamberSegmentPair;
416  for (std::vector<const MuonChamberMatch*>::const_iterator chamberMatch = chambers.begin();
417  chamberMatch != chambers.end();
418  chamberMatch++) {
419  if ((*chamberMatch)->segmentMatches.empty())
420  continue;
421  if (type == NoArbitration)
422  return std::make_pair(*chamberMatch, &((*chamberMatch)->segmentMatches.front()));
423 
424  for (std::vector<MuonSegmentMatch>::const_iterator segmentMatch = (*chamberMatch)->segmentMatches.begin();
425  segmentMatch != (*chamberMatch)->segmentMatches.end();
426  segmentMatch++) {
427  if (type == SegmentArbitration)
428  if (segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR))
429  return std::make_pair(*chamberMatch, &(*segmentMatch));
430  if (type == SegmentAndTrackArbitration)
431  if (segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR) &&
432  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR))
433  return std::make_pair(*chamberMatch, &(*segmentMatch));
434  if (type == SegmentAndTrackArbitrationCleaned)
435  if (segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR) &&
436  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR) &&
437  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByCleaning))
438  return std::make_pair(*chamberMatch, &(*segmentMatch));
439  }
440  }
441 
442  return chamberSegmentPair;
443 }
444 
445 float Muon::dX(int station, int muonSubdetId, ArbitrationType type) const {
446  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair =
447  pair(chambers(station, muonSubdetId), type);
448  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr)
449  return 999999;
450  if (!chamberSegmentPair.second->hasPhi())
451  return 999999;
452  return chamberSegmentPair.first->x - chamberSegmentPair.second->x;
453 }
454 
455 float Muon::dY(int station, int muonSubdetId, ArbitrationType type) const {
456  if (station == 4 && muonSubdetId == MuonSubdetId::DT)
457  return 999999; // no y information
458  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair =
459  pair(chambers(station, muonSubdetId), type);
460  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr)
461  return 999999;
462  if (!chamberSegmentPair.second->hasZed())
463  return 999999;
464  return chamberSegmentPair.first->y - chamberSegmentPair.second->y;
465 }
466 
467 float Muon::dDxDz(int station, int muonSubdetId, ArbitrationType type) const {
468  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair =
469  pair(chambers(station, muonSubdetId), type);
470  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr)
471  return 999999;
472  if (!chamberSegmentPair.second->hasPhi())
473  return 999999;
474  return chamberSegmentPair.first->dXdZ - chamberSegmentPair.second->dXdZ;
475 }
476 
477 float Muon::dDyDz(int station, int muonSubdetId, ArbitrationType type) const {
478  if (station == 4 && muonSubdetId == MuonSubdetId::DT)
479  return 999999; // no y information
480  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair =
481  pair(chambers(station, muonSubdetId), type);
482  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr)
483  return 999999;
484  if (!chamberSegmentPair.second->hasZed())
485  return 999999;
486  return chamberSegmentPair.first->dYdZ - chamberSegmentPair.second->dYdZ;
487 }
488 
489 float Muon::pullX(int station, int muonSubdetId, ArbitrationType type, bool includeSegmentError) const {
490  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair =
491  pair(chambers(station, muonSubdetId), type);
492  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr)
493  return 999999;
494  if (!chamberSegmentPair.second->hasPhi())
495  return 999999;
496  if (includeSegmentError)
497  return (chamberSegmentPair.first->x - chamberSegmentPair.second->x) /
498  sqrt(std::pow(chamberSegmentPair.first->xErr, 2) + std::pow(chamberSegmentPair.second->xErr, 2));
499  return (chamberSegmentPair.first->x - chamberSegmentPair.second->x) / chamberSegmentPair.first->xErr;
500 }
501 
502 float Muon::pullY(int station, int muonSubdetId, ArbitrationType type, bool includeSegmentError) const {
503  if (station == 4 && muonSubdetId == MuonSubdetId::DT)
504  return 999999; // no y information
505  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair =
506  pair(chambers(station, muonSubdetId), type);
507  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr)
508  return 999999;
509  if (!chamberSegmentPair.second->hasZed())
510  return 999999;
511  if (includeSegmentError)
512  return (chamberSegmentPair.first->y - chamberSegmentPair.second->y) /
513  sqrt(std::pow(chamberSegmentPair.first->yErr, 2) + std::pow(chamberSegmentPair.second->yErr, 2));
514  return (chamberSegmentPair.first->y - chamberSegmentPair.second->y) / chamberSegmentPair.first->yErr;
515 }
516 
517 float Muon::pullDxDz(int station, int muonSubdetId, ArbitrationType type, bool includeSegmentError) const {
518  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair =
519  pair(chambers(station, muonSubdetId), type);
520  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr)
521  return 999999;
522  if (!chamberSegmentPair.second->hasPhi())
523  return 999999;
524  if (includeSegmentError)
525  return (chamberSegmentPair.first->dXdZ - chamberSegmentPair.second->dXdZ) /
526  sqrt(std::pow(chamberSegmentPair.first->dXdZErr, 2) + std::pow(chamberSegmentPair.second->dXdZErr, 2));
527  return (chamberSegmentPair.first->dXdZ - chamberSegmentPair.second->dXdZ) / chamberSegmentPair.first->dXdZErr;
528 }
529 
530 float Muon::pullDyDz(int station, int muonSubdetId, ArbitrationType type, bool includeSegmentError) const {
531  if (station == 4 && muonSubdetId == MuonSubdetId::DT)
532  return 999999; // no y information
533  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair =
534  pair(chambers(station, muonSubdetId), type);
535  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr)
536  return 999999;
537  if (!chamberSegmentPair.second->hasZed())
538  return 999999;
539  if (includeSegmentError)
540  return (chamberSegmentPair.first->dYdZ - chamberSegmentPair.second->dYdZ) /
541  sqrt(std::pow(chamberSegmentPair.first->dYdZErr, 2) + std::pow(chamberSegmentPair.second->dYdZErr, 2));
542  return (chamberSegmentPair.first->dYdZ - chamberSegmentPair.second->dYdZ) / chamberSegmentPair.first->dYdZErr;
543 }
544 
545 float Muon::segmentX(int station, int muonSubdetId, ArbitrationType type) const {
546  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair =
547  pair(chambers(station, muonSubdetId), type);
548  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr)
549  return 999999;
550  if (!chamberSegmentPair.second->hasPhi())
551  return 999999;
552  return chamberSegmentPair.second->x;
553 }
554 
555 float Muon::segmentY(int station, int muonSubdetId, ArbitrationType type) const {
556  if (station == 4 && muonSubdetId == MuonSubdetId::DT)
557  return 999999; // no y information
558  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair =
559  pair(chambers(station, muonSubdetId), type);
560  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr)
561  return 999999;
562  if (!chamberSegmentPair.second->hasZed())
563  return 999999;
564  return chamberSegmentPair.second->y;
565 }
566 
567 float Muon::segmentDxDz(int station, int muonSubdetId, ArbitrationType type) const {
568  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair =
569  pair(chambers(station, muonSubdetId), type);
570  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr)
571  return 999999;
572  if (!chamberSegmentPair.second->hasPhi())
573  return 999999;
574  return chamberSegmentPair.second->dXdZ;
575 }
576 
577 float Muon::segmentDyDz(int station, int muonSubdetId, ArbitrationType type) const {
578  if (station == 4 && muonSubdetId == MuonSubdetId::DT)
579  return 999999; // no y information
580  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair =
581  pair(chambers(station, muonSubdetId), type);
582  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr)
583  return 999999;
584  if (!chamberSegmentPair.second->hasZed())
585  return 999999;
586  return chamberSegmentPair.second->dYdZ;
587 }
588 
589 float Muon::segmentXErr(int station, int muonSubdetId, ArbitrationType type) const {
590  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair =
591  pair(chambers(station, muonSubdetId), type);
592  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr)
593  return 999999;
594  if (!chamberSegmentPair.second->hasPhi())
595  return 999999;
596  return chamberSegmentPair.second->xErr;
597 }
598 
599 float Muon::segmentYErr(int station, int muonSubdetId, ArbitrationType type) const {
600  if (station == 4 && muonSubdetId == MuonSubdetId::DT)
601  return 999999; // no y information
602  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair =
603  pair(chambers(station, muonSubdetId), type);
604  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr)
605  return 999999;
606  if (!chamberSegmentPair.second->hasZed())
607  return 999999;
608  return chamberSegmentPair.second->yErr;
609 }
610 
611 float Muon::segmentDxDzErr(int station, int muonSubdetId, ArbitrationType type) const {
612  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair =
613  pair(chambers(station, muonSubdetId), type);
614  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr)
615  return 999999;
616  if (!chamberSegmentPair.second->hasPhi())
617  return 999999;
618  return chamberSegmentPair.second->dXdZErr;
619 }
620 
621 float Muon::segmentDyDzErr(int station, int muonSubdetId, ArbitrationType type) const {
622  if (station == 4 && muonSubdetId == MuonSubdetId::DT)
623  return 999999; // no y information
624  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair =
625  pair(chambers(station, muonSubdetId), type);
626  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr)
627  return 999999;
628  if (!chamberSegmentPair.second->hasZed())
629  return 999999;
630  return chamberSegmentPair.second->dYdZErr;
631 }
632 
633 float Muon::trackEdgeX(int station, int muonSubdetId, ArbitrationType type) const {
634  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
635  if (muonChambers.empty())
636  return 999999;
637 
638  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers, type);
639  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr) {
640  float dist = 999999;
641  float supVar = 999999;
642  for (const MuonChamberMatch* muonChamber : muonChambers) {
643  float currDist = muonChamber->dist();
644  if (currDist < dist) {
645  dist = currDist;
646  supVar = muonChamber->edgeX;
647  }
648  }
649  return supVar;
650  } else
651  return chamberSegmentPair.first->edgeX;
652 }
653 
654 float Muon::trackEdgeY(int station, int muonSubdetId, ArbitrationType type) const {
655  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
656  if (muonChambers.empty())
657  return 999999;
658 
659  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers, type);
660  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr) {
661  float dist = 999999;
662  float supVar = 999999;
663  for (const MuonChamberMatch* muonChamber : muonChambers) {
664  float currDist = muonChamber->dist();
665  if (currDist < dist) {
666  dist = currDist;
667  supVar = muonChamber->edgeY;
668  }
669  }
670  return supVar;
671  } else
672  return chamberSegmentPair.first->edgeY;
673 }
674 
675 float Muon::trackX(int station, int muonSubdetId, ArbitrationType type) const {
676  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
677  if (muonChambers.empty())
678  return 999999;
679 
680  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers, type);
681  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr) {
682  float dist = 999999;
683  float supVar = 999999;
684  for (const MuonChamberMatch* muonChamber : muonChambers) {
685  float currDist = muonChamber->dist();
686  if (currDist < dist) {
687  dist = currDist;
688  supVar = muonChamber->x;
689  }
690  }
691  return supVar;
692  } else
693  return chamberSegmentPair.first->x;
694 }
695 
696 float Muon::trackY(int station, int muonSubdetId, ArbitrationType type) const {
697  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
698  if (muonChambers.empty())
699  return 999999;
700 
701  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers, type);
702  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr) {
703  float dist = 999999;
704  float supVar = 999999;
705  for (const MuonChamberMatch* muonChamber : muonChambers) {
706  float currDist = muonChamber->dist();
707  if (currDist < dist) {
708  dist = currDist;
709  supVar = muonChamber->y;
710  }
711  }
712  return supVar;
713  } else
714  return chamberSegmentPair.first->y;
715 }
716 
717 float Muon::trackDxDz(int station, int muonSubdetId, ArbitrationType type) const {
718  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
719  if (muonChambers.empty())
720  return 999999;
721 
722  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers, type);
723  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr) {
724  float dist = 999999;
725  float supVar = 999999;
726  for (const MuonChamberMatch* muonChamber : muonChambers) {
727  float currDist = muonChamber->dist();
728  if (currDist < dist) {
729  dist = currDist;
730  supVar = muonChamber->dXdZ;
731  }
732  }
733  return supVar;
734  } else
735  return chamberSegmentPair.first->dXdZ;
736 }
737 
738 float Muon::trackDyDz(int station, int muonSubdetId, ArbitrationType type) const {
739  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
740  if (muonChambers.empty())
741  return 999999;
742 
743  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers, type);
744  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr) {
745  float dist = 999999;
746  float supVar = 999999;
747  for (const MuonChamberMatch* muonChamber : muonChambers) {
748  float currDist = muonChamber->dist();
749  if (currDist < dist) {
750  dist = currDist;
751  supVar = muonChamber->dYdZ;
752  }
753  }
754  return supVar;
755  } else
756  return chamberSegmentPair.first->dYdZ;
757 }
758 
759 float Muon::trackXErr(int station, int muonSubdetId, ArbitrationType type) const {
760  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
761  if (muonChambers.empty())
762  return 999999;
763 
764  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers, type);
765  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr) {
766  float dist = 999999;
767  float supVar = 999999;
768  for (const MuonChamberMatch* muonChamber : muonChambers) {
769  float currDist = muonChamber->dist();
770  if (currDist < dist) {
771  dist = currDist;
772  supVar = muonChamber->xErr;
773  }
774  }
775  return supVar;
776  } else
777  return chamberSegmentPair.first->xErr;
778 }
779 
780 float Muon::trackYErr(int station, int muonSubdetId, ArbitrationType type) const {
781  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
782  if (muonChambers.empty())
783  return 999999;
784 
785  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers, type);
786  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr) {
787  float dist = 999999;
788  float supVar = 999999;
789  for (const MuonChamberMatch* muonChamber : muonChambers) {
790  float currDist = muonChamber->dist();
791  if (currDist < dist) {
792  dist = currDist;
793  supVar = muonChamber->yErr;
794  }
795  }
796  return supVar;
797  } else
798  return chamberSegmentPair.first->yErr;
799 }
800 
801 float Muon::trackDxDzErr(int station, int muonSubdetId, ArbitrationType type) const {
802  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
803  if (muonChambers.empty())
804  return 999999;
805 
806  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers, type);
807  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr) {
808  float dist = 999999;
809  float supVar = 999999;
810  for (const MuonChamberMatch* muonChamber : muonChambers) {
811  float currDist = muonChamber->dist();
812  if (currDist < dist) {
813  dist = currDist;
814  supVar = muonChamber->dXdZErr;
815  }
816  }
817  return supVar;
818  } else
819  return chamberSegmentPair.first->dXdZErr;
820 }
821 
822 float Muon::trackDyDzErr(int station, int muonSubdetId, ArbitrationType type) const {
823  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
824  if (muonChambers.empty())
825  return 999999;
826 
827  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers, type);
828  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr) {
829  float dist = 999999;
830  float supVar = 999999;
831  for (const MuonChamberMatch* muonChamber : muonChambers) {
832  float currDist = muonChamber->dist();
833  if (currDist < dist) {
834  dist = currDist;
835  supVar = muonChamber->dYdZErr;
836  }
837  }
838  return supVar;
839  } else
840  return chamberSegmentPair.first->dYdZErr;
841 }
842 
843 float Muon::trackDist(int station, int muonSubdetId, ArbitrationType type) const {
844  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
845  if (muonChambers.empty())
846  return 999999;
847 
848  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers, type);
849  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr) {
850  float dist = 999999;
851  for (const MuonChamberMatch* muonChamber : muonChambers) {
852  float currDist = muonChamber->dist();
853  if (currDist < dist)
854  dist = currDist;
855  }
856  return dist;
857  } else
858  return chamberSegmentPair.first->dist();
859 }
860 
861 float Muon::trackDistErr(int station, int muonSubdetId, ArbitrationType type) const {
862  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
863  if (muonChambers.empty())
864  return 999999;
865 
866  std::pair<const MuonChamberMatch*, const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers, type);
867  if (chamberSegmentPair.first == nullptr || chamberSegmentPair.second == nullptr) {
868  float dist = 999999;
869  float supVar = 999999;
870  for (const MuonChamberMatch* muonChamber : muonChambers) {
871  float currDist = muonChamber->dist();
872  if (currDist < dist) {
873  dist = currDist;
874  supVar = muonChamber->distErr();
875  }
876  }
877  return supVar;
878  } else
879  return chamberSegmentPair.first->distErr();
880 }
881 
882 void Muon::setIsolation(const MuonIsolation& isoR03, const MuonIsolation& isoR05) {
883  isolationR03_ = isoR03;
884  isolationR05_ = isoR05;
885  isolationValid_ = true;
886 }
887 
888 void Muon::setPFIsolation(const std::string& label, const MuonPFIsolation& deposit) {
889  if (label == "pfIsolationR03")
890  pfIsolationR03_ = deposit;
891 
892  if (label == "pfIsolationR04")
893  pfIsolationR04_ = deposit;
894 
895  if (label == "pfIsoMeanDRProfileR03")
896  pfIsoMeanDRR03_ = deposit;
897 
898  if (label == "pfIsoMeanDRProfileR04")
899  pfIsoMeanDRR04_ = deposit;
900 
901  if (label == "pfIsoSumDRProfileR03")
902  pfIsoSumDRR03_ = deposit;
903 
904  if (label == "pfIsoSumDRProfileR04")
905  pfIsoSumDRR04_ = deposit;
906 
907  pfIsolationValid_ = true;
908 }
909 
910 void Muon::setPFP4(const reco::Candidate::LorentzVector& p4) {
911  pfP4_ = p4;
912  type_ = type_ | PFMuon;
913 }
914 
915 void Muon::setOuterTrack(const TrackRef& t) { outerTrack_ = t; }
916 void Muon::setInnerTrack(const TrackRef& t) { innerTrack_ = t; }
917 void Muon::setTrack(const TrackRef& t) { setInnerTrack(t); }
918 void Muon::setStandAlone(const TrackRef& t) { setOuterTrack(t); }
919 void Muon::setGlobalTrack(const TrackRef& t) { globalTrack_ = t; }
920 void Muon::setCombined(const TrackRef& t) { setGlobalTrack(t); }
921 
922 bool Muon::isAValidMuonTrack(const MuonTrackType& type) const { return muonTrack(type).isNonnull(); }
923 
924 TrackRef Muon::muonTrack(const MuonTrackType& type) const {
925  switch (type) {
926  case InnerTrack:
927  return innerTrack();
928  case OuterTrack:
929  return standAloneMuon();
930  case CombinedTrack:
931  return globalTrack();
932  case TPFMS:
933  return tpfmsTrack();
934  case Picky:
935  return pickyTrack();
936  case DYT:
937  return dytTrack();
938  default:
939  return muonTrackFromMap(type);
940  }
941 }
942 
943 void Muon::setMuonTrack(const MuonTrackType& type, const TrackRef& t) {
944  switch (type) {
945  case InnerTrack:
946  setInnerTrack(t);
947  break;
948  case OuterTrack:
949  setStandAlone(t);
950  break;
951  case CombinedTrack:
952  setGlobalTrack(t);
953  break;
954  default:
955  refittedTrackMap_[type] = t;
956  break;
957  }
958 }
cutBasedMuonId_MuonPOG_V0_cff.globalTrack
globalTrack
Definition: cutBasedMuonId_MuonPOG_V0_cff.py:135
MuonSubdetId::CSC
static constexpr int CSC
Definition: MuonSubdetId.h:12
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
Muon.h
RPCDetId::region
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
relativeConstraints.station
station
Definition: relativeConstraints.py:67
reco::Muon::Muon
Muon()
ME0DetId.h
RPCDetId
Definition: RPCDetId.h:16
oniaPATMuonsWithTrigger_cff.matches
matches
Definition: oniaPATMuonsWithTrigger_cff.py:77
reco::LeafCandidate::clone
LeafCandidate * clone() const override
returns a clone of the Candidate object
Definition: LeafCandidate.h:195
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
reco::MuonIsolation
Definition: MuonIsolation.h:5
Muon
Definition: Muon.py:1
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:42
edm::Ref
Definition: AssociativeIterator.h:58
alignCSCRings.s
s
Definition: alignCSCRings.py:92
reco::MuonSegmentMatch
Definition: MuonSegmentMatch.h:12
reco::LeafCandidate::overlap
bool overlap(const Candidate &) const override
check overlap with another Candidate
Definition: LeafCandidate.cc:25
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
MuonSubdetId::DT
static constexpr int DT
Definition: MuonSubdetId.h:11
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RPCDetId.h
Point
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:57
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
CSCDetId
Definition: CSCDetId.h:26
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88271
g4TestGeometry_cfi.checkOverlap
def checkOverlap(process)
Definition: g4TestGeometry_cfi.py:3
reco::LeafCandidate::p4
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:114
p4
double p4[4]
Definition: TauolaWrapper.h:92
susybsm::HSCParticleType::innerTrack
Definition: HSCParticle.h:20
chambers
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
reco::RecoCandidate
Definition: RecoCandidate.h:20
reco::MuonChamberMatch
Definition: MuonChamberMatch.h:10
MuonSubdetId.h
reco::Candidate
Definition: Candidate.h:27
reco::MuonPFIsolation
Definition: MuonPFIsolation.h:5
GEMDetId.h
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:18
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
LorentzVector
math::XYZTLorentzVector LorentzVector
Definition: HLTMuonMatchAndPlot.h:49
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
PixelTestBeamValidation_cfi.Charge
Charge
Definition: PixelTestBeamValidation_cfi.py:91
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
dqmMemoryStats.total
total
Definition: dqmMemoryStats.py:152
hgcalTestNeighbor_cfi.detector
detector
Definition: hgcalTestNeighbor_cfi.py:6
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
reco::Muon::None
Definition: Muon.h:36
l1t::Muon::Muon
Muon()
Definition: Muon.cc:3
RPCDetId::layer
int layer() const
Definition: RPCDetId.h:85
susybsm::HSCParticleType::standAloneMuon
Definition: HSCParticle.h:20
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
plotscripts.stationIndex
def stationIndex(name)
Definition: plotscripts.py:355
label
const char * label
Definition: PFTauDecayModeTools.cc:11
hgcalTopologyTester_cfi.layers
layers
Definition: hgcalTopologyTester_cfi.py:8
reco::MuonTrackType
MuonTrackType
Definition: MuonTrackType.h:28