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