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