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::stationMask( ArbitrationType type ) const
137 {
138  unsigned int totMask(0);
139  unsigned int curMask(0);
140 
141  for( std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
142  chamberMatch != muMatches_.end(); chamberMatch++ )
143  {
144  if(type == RPCHitAndTrackArbitration) {
145  if(chamberMatch->rpcMatches.empty()) continue;
146 
147  RPCDetId rollId = chamberMatch->id.rawId();
148  const int region = rollId.region();
149  int rpcIndex = 1; if (region!=0) rpcIndex = 2;
150 
151  for( std::vector<MuonRPCHitMatch>::const_iterator rpcMatch = chamberMatch->rpcMatches.begin();
152  rpcMatch != chamberMatch->rpcMatches.end(); rpcMatch++ )
153  {
154  curMask = 1<<( (chamberMatch->station()-1)+4*(rpcIndex-1) );
155 
156  // do not double count
157  if(!(totMask & curMask))
158  totMask += curMask;
159  }
160  continue;
161  }
162 
163  if(chamberMatch->segmentMatches.empty()) continue;
164  if(type == NoArbitration) {
165  curMask = 1<<( (chamberMatch->station()-1)+4*(chamberMatch->detector()-1) );
166  // do not double count
167  if(!(totMask & curMask))
168  totMask += curMask;
169  continue;
170  }
171 
172  for( std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
173  segmentMatch != chamberMatch->segmentMatches.end(); segmentMatch++ )
174  {
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  if(type > 1<<7)
203  if(segmentMatch->isMask(type)) {
204  curMask = 1<<( (chamberMatch->station()-1)+4*(chamberMatch->detector()-1) );
205  // do not double count
206  if(!(totMask & curMask))
207  totMask += curMask;
208  break;
209  }
210  }
211  }
212 
213  return totMask;
214 }
215 
216 int Muon::numberOfMatchedRPCLayers( ArbitrationType type ) const
217 {
218  int layers(0);
219 
220  unsigned int theRPCLayerMask = RPClayerMask(type);
221  // maximum ten layers because of 6 layers in barrel and 3 (4) layers in each endcap before (after) upscope
222  for(int it = 0; it < 10; ++it)
223  if (theRPCLayerMask & 1<<it)
224  ++layers;
225 
226  return layers;
227 }
228 
229 unsigned int Muon::RPClayerMask( ArbitrationType type ) const
230 {
231  unsigned int totMask(0);
232  unsigned int curMask(0);
233  for( std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
234  chamberMatch != muMatches_.end(); chamberMatch++ )
235  {
236  if(chamberMatch->rpcMatches.empty()) continue;
237 
238  RPCDetId rollId = chamberMatch->id.rawId();
239  const int region = rollId.region();
240 
241  const int layer = rollId.layer();
242  int rpcLayer = chamberMatch->station();
243  if (region==0) {
244  rpcLayer = chamberMatch->station()-1 + chamberMatch->station()*layer;
245  if ((chamberMatch->station()==2 && layer==2) || (chamberMatch->station()==4 && layer==1)) rpcLayer -= 1;
246  } else rpcLayer += 6;
247 
248  for( std::vector<MuonRPCHitMatch>::const_iterator rpcMatch = chamberMatch->rpcMatches.begin();
249  rpcMatch != chamberMatch->rpcMatches.end(); rpcMatch++ )
250  {
251  curMask = 1<<(rpcLayer-1);
252 
253  // do not double count
254  if(!(totMask & curMask))
255  totMask += curMask;
256  }
257  }
258 
259  return totMask;
260 
261 }
262 
263 unsigned int Muon::stationGapMaskDistance( float distanceCut ) const
264 {
265  unsigned int totMask(0);
266  for( int stationIndex = 1; stationIndex < 5; stationIndex++ )
267  {
268  for( int detectorIndex = 1; detectorIndex < 4; detectorIndex++ )
269  {
270  unsigned int curMask(0);
271  for( std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
272  chamberMatch != muMatches_.end(); chamberMatch++ )
273  {
274  if(!(chamberMatch->station()==stationIndex && chamberMatch->detector()==detectorIndex)) continue;
275 
276  float edgeX = chamberMatch->edgeX;
277  float edgeY = chamberMatch->edgeY;
278  if(edgeX<0 && fabs(edgeX)>fabs(distanceCut) &&
279  edgeY<0 && fabs(edgeY)>fabs(distanceCut)) // inside the chamber so negates all gaps for this station
280  {
281  curMask = 0;
282  break;
283  }
284  if( ( fabs(edgeX) < fabs(distanceCut) && edgeY < fabs(distanceCut) ) ||
285  ( fabs(edgeY) < fabs(distanceCut) && edgeX < fabs(distanceCut) ) ) // inside gap
286  curMask = 1<<( (stationIndex-1)+4*(detectorIndex-1) );
287  }
288 
289  totMask += curMask; // add to total mask
290  }
291  }
292 
293  return totMask;
294 }
295 
296 unsigned int Muon::stationGapMaskPull( float sigmaCut ) const
297 {
298  unsigned int totMask(0);
299  for( int stationIndex = 1; stationIndex < 5; stationIndex++ )
300  {
301  for( int detectorIndex = 1; detectorIndex < 4; detectorIndex++ )
302  {
303  unsigned int curMask(0);
304  for( std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
305  chamberMatch != muMatches_.end(); chamberMatch++ )
306  {
307  if(!(chamberMatch->station()==stationIndex && chamberMatch->detector()==detectorIndex)) continue;
308 
309  float edgeX = chamberMatch->edgeX;
310  float edgeY = chamberMatch->edgeY;
311  float xErr = chamberMatch->xErr+0.000001; // protect against division by zero later
312  float yErr = chamberMatch->yErr+0.000001; // protect against division by zero later
313  if(edgeX<0 && fabs(edgeX/xErr)>fabs(sigmaCut) &&
314  edgeY<0 && fabs(edgeY/yErr)>fabs(sigmaCut)) // inside the chamber so negates all gaps for this station
315  {
316  curMask = 0;
317  break;
318  }
319  if( ( fabs(edgeX/xErr) < fabs(sigmaCut) && edgeY/yErr < fabs(sigmaCut) ) ||
320  ( fabs(edgeY/yErr) < fabs(sigmaCut) && edgeX/xErr < fabs(sigmaCut) ) ) // inside gap
321  curMask = 1<<((stationIndex-1)+4*(detectorIndex-1));
322  }
323 
324  totMask += curMask; // add to total mask
325  }
326  }
327 
328  return totMask;
329 }
330 
331 int Muon::numberOfSegments( int station, int muonSubdetId, ArbitrationType type ) const
332 {
333  int segments(0);
334  for( std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
335  chamberMatch != muMatches_.end(); chamberMatch++ )
336  {
337  if(chamberMatch->segmentMatches.empty()) continue;
338  if(!(chamberMatch->station()==station && chamberMatch->detector()==muonSubdetId)) continue;
339 
340  if(type == NoArbitration) {
341  segments += chamberMatch->segmentMatches.size();
342  continue;
343  }
344 
345  for( std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
346  segmentMatch != chamberMatch->segmentMatches.end(); segmentMatch++ )
347  {
348  if(type == SegmentArbitration)
349  if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR)) {
350  segments++;
351  break;
352  }
353  if(type == SegmentAndTrackArbitration)
354  if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR) &&
355  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR)) {
356  segments++;
357  break;
358  }
359  if(type == SegmentAndTrackArbitrationCleaned)
360  if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR) &&
361  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR) &&
362  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByCleaning)) {
363  segments++;
364  break;
365  }
366  if(type > 1<<7)
367  if(segmentMatch->isMask(type)) {
368  segments++;
369  break;
370  }
371  }
372  }
373 
374  return segments;
375 }
376 
377 const std::vector<const MuonChamberMatch*> Muon::chambers( int station, int muonSubdetId ) const
378 {
379  std::vector<const MuonChamberMatch*> chambers;
380  for(std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
381  chamberMatch != muMatches_.end(); chamberMatch++)
382  if(chamberMatch->station()==station && chamberMatch->detector()==muonSubdetId)
383  chambers.push_back(&(*chamberMatch));
384  return chambers;
385 }
386 
387 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> Muon::pair( const std::vector<const MuonChamberMatch*> &chambers,
388  ArbitrationType type ) const
389 {
390  MuonChamberMatch* m = nullptr;
391  MuonSegmentMatch* s = nullptr;
392  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair(m,s);
393 
394  if(chambers.empty()) return chamberSegmentPair;
395  for( std::vector<const MuonChamberMatch*>::const_iterator chamberMatch = chambers.begin();
396  chamberMatch != chambers.end(); chamberMatch++ )
397  {
398  if((*chamberMatch)->segmentMatches.empty()) continue;
399  if(type == NoArbitration)
400  return std::make_pair(*chamberMatch, &((*chamberMatch)->segmentMatches.front()));
401 
402  for( std::vector<MuonSegmentMatch>::const_iterator segmentMatch = (*chamberMatch)->segmentMatches.begin();
403  segmentMatch != (*chamberMatch)->segmentMatches.end(); segmentMatch++ )
404  {
405  if(type == SegmentArbitration)
406  if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR))
407  return std::make_pair(*chamberMatch, &(*segmentMatch));
408  if(type == SegmentAndTrackArbitration)
409  if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR) &&
410  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR))
411  return std::make_pair(*chamberMatch, &(*segmentMatch));
412  if(type == SegmentAndTrackArbitrationCleaned)
413  if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR) &&
414  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR) &&
415  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByCleaning))
416  return std::make_pair(*chamberMatch, &(*segmentMatch));
417  if(type > 1<<7)
418  if(segmentMatch->isMask(type))
419  return std::make_pair(*chamberMatch, &(*segmentMatch));
420  }
421  }
422 
423  return chamberSegmentPair;
424 }
425 
426 float Muon::dX( int station, int muonSubdetId, ArbitrationType type ) const
427 {
428  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
429  if(chamberSegmentPair.first==nullptr || chamberSegmentPair.second==nullptr) return 999999;
430  if(! chamberSegmentPair.second->hasPhi()) return 999999;
431  return chamberSegmentPair.first->x-chamberSegmentPair.second->x;
432 }
433 
434 float Muon::dY( int station, int muonSubdetId, ArbitrationType type ) const
435 {
436  if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999; // no y information
437  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
438  if(chamberSegmentPair.first==nullptr || chamberSegmentPair.second==nullptr) return 999999;
439  if(! chamberSegmentPair.second->hasZed()) return 999999;
440  return chamberSegmentPair.first->y-chamberSegmentPair.second->y;
441 }
442 
443 float Muon::dDxDz( int station, int muonSubdetId, ArbitrationType type ) const
444 {
445  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
446  if(chamberSegmentPair.first==nullptr || chamberSegmentPair.second==nullptr) return 999999;
447  if(! chamberSegmentPair.second->hasPhi()) return 999999;
448  return chamberSegmentPair.first->dXdZ-chamberSegmentPair.second->dXdZ;
449 }
450 
451 float Muon::dDyDz( int station, int muonSubdetId, ArbitrationType type ) const
452 {
453  if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999; // no y information
454  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
455  if(chamberSegmentPair.first==nullptr || chamberSegmentPair.second==nullptr) return 999999;
456  if(! chamberSegmentPair.second->hasZed()) return 999999;
457  return chamberSegmentPair.first->dYdZ-chamberSegmentPair.second->dYdZ;
458 }
459 
460 float Muon::pullX( int station, int muonSubdetId, ArbitrationType type, bool includeSegmentError ) const
461 {
462  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
463  if(chamberSegmentPair.first==nullptr || chamberSegmentPair.second==nullptr) return 999999;
464  if(! chamberSegmentPair.second->hasPhi()) return 999999;
465  if(includeSegmentError)
466  return (chamberSegmentPair.first->x-chamberSegmentPair.second->x)/sqrt(pow(chamberSegmentPair.first->xErr,2)+pow(chamberSegmentPair.second->xErr,2));
467  return (chamberSegmentPair.first->x-chamberSegmentPair.second->x)/chamberSegmentPair.first->xErr;
468 }
469 
470 float Muon::pullY( int station, int muonSubdetId, ArbitrationType type, bool includeSegmentError) 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  if(includeSegmentError)
477  return (chamberSegmentPair.first->y-chamberSegmentPair.second->y)/sqrt(pow(chamberSegmentPair.first->yErr,2)+pow(chamberSegmentPair.second->yErr,2));
478  return (chamberSegmentPair.first->y-chamberSegmentPair.second->y)/chamberSegmentPair.first->yErr;
479 }
480 
481 float Muon::pullDxDz( int station, int muonSubdetId, ArbitrationType type, bool includeSegmentError ) const
482 {
483  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
484  if(chamberSegmentPair.first==nullptr || chamberSegmentPair.second==nullptr) return 999999;
485  if(! chamberSegmentPair.second->hasPhi()) return 999999;
486  if(includeSegmentError)
487  return (chamberSegmentPair.first->dXdZ-chamberSegmentPair.second->dXdZ)/sqrt(pow(chamberSegmentPair.first->dXdZErr,2)+pow(chamberSegmentPair.second->dXdZErr,2));
488  return (chamberSegmentPair.first->dXdZ-chamberSegmentPair.second->dXdZ)/chamberSegmentPair.first->dXdZErr;
489 }
490 
491 float Muon::pullDyDz( int station, int muonSubdetId, ArbitrationType type, bool includeSegmentError ) const
492 {
493  if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999; // no y information
494  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
495  if(chamberSegmentPair.first==nullptr || chamberSegmentPair.second==nullptr) return 999999;
496  if(! chamberSegmentPair.second->hasZed()) return 999999;
497  if(includeSegmentError)
498  return (chamberSegmentPair.first->dYdZ-chamberSegmentPair.second->dYdZ)/sqrt(pow(chamberSegmentPair.first->dYdZErr,2)+pow(chamberSegmentPair.second->dYdZErr,2));
499  return (chamberSegmentPair.first->dYdZ-chamberSegmentPair.second->dYdZ)/chamberSegmentPair.first->dYdZErr;
500 }
501 
502 float Muon::segmentX( int station, int muonSubdetId, ArbitrationType type ) const
503 {
504  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
505  if(chamberSegmentPair.first==nullptr || chamberSegmentPair.second==nullptr) return 999999;
506  if(! chamberSegmentPair.second->hasPhi()) return 999999;
507  return chamberSegmentPair.second->x;
508 }
509 
510 float Muon::segmentY( int station, int muonSubdetId, ArbitrationType type ) 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  return chamberSegmentPair.second->y;
517 }
518 
519 float Muon::segmentDxDz( int station, int muonSubdetId, ArbitrationType type ) const
520 {
521  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
522  if(chamberSegmentPair.first==nullptr || chamberSegmentPair.second==nullptr) return 999999;
523  if(! chamberSegmentPair.second->hasPhi()) return 999999;
524  return chamberSegmentPair.second->dXdZ;
525 }
526 
527 float Muon::segmentDyDz( int station, int muonSubdetId, ArbitrationType type ) const
528 {
529  if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999; // no y information
530  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
531  if(chamberSegmentPair.first==nullptr || chamberSegmentPair.second==nullptr) return 999999;
532  if(! chamberSegmentPair.second->hasZed()) return 999999;
533  return chamberSegmentPair.second->dYdZ;
534 }
535 
536 float Muon::segmentXErr( int station, int muonSubdetId, ArbitrationType type ) const
537 {
538  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
539  if(chamberSegmentPair.first==nullptr || chamberSegmentPair.second==nullptr) return 999999;
540  if(! chamberSegmentPair.second->hasPhi()) return 999999;
541  return chamberSegmentPair.second->xErr;
542 }
543 
544 float Muon::segmentYErr( int station, int muonSubdetId, ArbitrationType type ) const
545 {
546  if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999; // no y information
547  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
548  if(chamberSegmentPair.first==nullptr || chamberSegmentPair.second==nullptr) return 999999;
549  if(! chamberSegmentPair.second->hasZed()) return 999999;
550  return chamberSegmentPair.second->yErr;
551 }
552 
553 float Muon::segmentDxDzErr( int station, int muonSubdetId, ArbitrationType type ) const
554 {
555  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
556  if(chamberSegmentPair.first==nullptr || chamberSegmentPair.second==nullptr) return 999999;
557  if(! chamberSegmentPair.second->hasPhi()) return 999999;
558  return chamberSegmentPair.second->dXdZErr;
559 }
560 
561 float Muon::segmentDyDzErr( int station, int muonSubdetId, ArbitrationType type ) const
562 {
563  if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999; // no y information
564  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
565  if(chamberSegmentPair.first==nullptr || chamberSegmentPair.second==nullptr) return 999999;
566  if(! chamberSegmentPair.second->hasZed()) return 999999;
567  return chamberSegmentPair.second->dYdZErr;
568 }
569 
570 float Muon::trackEdgeX( int station, int muonSubdetId, ArbitrationType type ) const
571 {
572  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
573  if(muonChambers.empty()) return 999999;
574 
575  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
576  if(chamberSegmentPair.first==nullptr || chamberSegmentPair.second==nullptr) {
577  float dist = 999999;
578  float supVar = 999999;
579  for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
580  muonChamber != muonChambers.end(); ++muonChamber) {
581  float currDist = (*muonChamber)->dist();
582  if(currDist<dist) {
583  dist = currDist;
584  supVar = (*muonChamber)->edgeX;
585  }
586  }
587  return supVar;
588  } else return chamberSegmentPair.first->edgeX;
589 }
590 
591 float Muon::trackEdgeY( int station, int muonSubdetId, ArbitrationType type ) const
592 {
593  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
594  if(muonChambers.empty()) return 999999;
595 
596  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
597  if(chamberSegmentPair.first==nullptr || chamberSegmentPair.second==nullptr) {
598  float dist = 999999;
599  float supVar = 999999;
600  for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
601  muonChamber != muonChambers.end(); ++muonChamber) {
602  float currDist = (*muonChamber)->dist();
603  if(currDist<dist) {
604  dist = currDist;
605  supVar = (*muonChamber)->edgeY;
606  }
607  }
608  return supVar;
609  } else return chamberSegmentPair.first->edgeY;
610 }
611 
612 float Muon::trackX( int station, int muonSubdetId, ArbitrationType type ) const
613 {
614  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
615  if(muonChambers.empty()) return 999999;
616 
617  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
618  if(chamberSegmentPair.first==nullptr || chamberSegmentPair.second==nullptr) {
619  float dist = 999999;
620  float supVar = 999999;
621  for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
622  muonChamber != muonChambers.end(); ++muonChamber) {
623  float currDist = (*muonChamber)->dist();
624  if(currDist<dist) {
625  dist = currDist;
626  supVar = (*muonChamber)->x;
627  }
628  }
629  return supVar;
630  } else return chamberSegmentPair.first->x;
631 }
632 
633 float Muon::trackY( int station, int muonSubdetId, ArbitrationType type ) const
634 {
635  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
636  if(muonChambers.empty()) 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(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
643  muonChamber != muonChambers.end(); ++muonChamber) {
644  float currDist = (*muonChamber)->dist();
645  if(currDist<dist) {
646  dist = currDist;
647  supVar = (*muonChamber)->y;
648  }
649  }
650  return supVar;
651  } else return chamberSegmentPair.first->y;
652 }
653 
654 float Muon::trackDxDz( int station, int muonSubdetId, ArbitrationType type ) const
655 {
656  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
657  if(muonChambers.empty()) 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(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
664  muonChamber != muonChambers.end(); ++muonChamber) {
665  float currDist = (*muonChamber)->dist();
666  if(currDist<dist) {
667  dist = currDist;
668  supVar = (*muonChamber)->dXdZ;
669  }
670  }
671  return supVar;
672  } else return chamberSegmentPair.first->dXdZ;
673 }
674 
675 float Muon::trackDyDz( int station, int muonSubdetId, ArbitrationType type ) const
676 {
677  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
678  if(muonChambers.empty()) 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(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
685  muonChamber != muonChambers.end(); ++muonChamber) {
686  float currDist = (*muonChamber)->dist();
687  if(currDist<dist) {
688  dist = currDist;
689  supVar = (*muonChamber)->dYdZ;
690  }
691  }
692  return supVar;
693  } else return chamberSegmentPair.first->dYdZ;
694 }
695 
696 float Muon::trackXErr( int station, int muonSubdetId, ArbitrationType type ) const
697 {
698  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
699  if(muonChambers.empty()) 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(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
706  muonChamber != muonChambers.end(); ++muonChamber) {
707  float currDist = (*muonChamber)->dist();
708  if(currDist<dist) {
709  dist = currDist;
710  supVar = (*muonChamber)->xErr;
711  }
712  }
713  return supVar;
714  } else return chamberSegmentPair.first->xErr;
715 }
716 
717 float Muon::trackYErr( int station, int muonSubdetId, ArbitrationType type ) const
718 {
719  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
720  if(muonChambers.empty()) 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(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
727  muonChamber != muonChambers.end(); ++muonChamber) {
728  float currDist = (*muonChamber)->dist();
729  if(currDist<dist) {
730  dist = currDist;
731  supVar = (*muonChamber)->yErr;
732  }
733  }
734  return supVar;
735  } else return chamberSegmentPair.first->yErr;
736 }
737 
738 float Muon::trackDxDzErr( int station, int muonSubdetId, ArbitrationType type ) const
739 {
740  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
741  if(muonChambers.empty()) 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(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
748  muonChamber != muonChambers.end(); ++muonChamber) {
749  float currDist = (*muonChamber)->dist();
750  if(currDist<dist) {
751  dist = currDist;
752  supVar = (*muonChamber)->dXdZErr;
753  }
754  }
755  return supVar;
756  } else return chamberSegmentPair.first->dXdZErr;
757 }
758 
759 float Muon::trackDyDzErr( int station, int muonSubdetId, ArbitrationType type ) const
760 {
761  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
762  if(muonChambers.empty()) 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(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
769  muonChamber != muonChambers.end(); ++muonChamber) {
770  float currDist = (*muonChamber)->dist();
771  if(currDist<dist) {
772  dist = currDist;
773  supVar = (*muonChamber)->dYdZErr;
774  }
775  }
776  return supVar;
777  } else return chamberSegmentPair.first->dYdZErr;
778 }
779 
780 float Muon::trackDist( int station, int muonSubdetId, ArbitrationType type ) const
781 {
782  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
783  if(muonChambers.empty()) 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  for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
789  muonChamber != muonChambers.end(); ++muonChamber) {
790  float currDist = (*muonChamber)->dist();
791  if(currDist<dist) dist = currDist;
792  }
793  return dist;
794  } else return chamberSegmentPair.first->dist();
795 }
796 
797 float Muon::trackDistErr( int station, int muonSubdetId, ArbitrationType type ) const
798 {
799  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
800  if(muonChambers.empty()) return 999999;
801 
802  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
803  if(chamberSegmentPair.first==nullptr || chamberSegmentPair.second==nullptr) {
804  float dist = 999999;
805  float supVar = 999999;
806  for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
807  muonChamber != muonChambers.end(); ++muonChamber) {
808  float currDist = (*muonChamber)->dist();
809  if(currDist<dist) {
810  dist = currDist;
811  supVar = (*muonChamber)->distErr();
812  }
813  }
814  return supVar;
815  } else return chamberSegmentPair.first->distErr();
816 }
817 
818 void Muon::setIsolation( const MuonIsolation& isoR03, const MuonIsolation& isoR05 )
819 {
820  isolationR03_ = isoR03;
821  isolationR05_ = isoR05;
822  isolationValid_ = true;
823 }
824 
825 
826 void Muon::setPFIsolation(const std::string& label, const MuonPFIsolation& deposit)
827 {
828  if(label=="pfIsolationR03")
829  pfIsolationR03_ = deposit;
830 
831  if(label=="pfIsolationR04")
832  pfIsolationR04_ = deposit;
833 
834  if(label=="pfIsoMeanDRProfileR03")
835  pfIsoMeanDRR03_ = deposit;
836 
837  if(label=="pfIsoMeanDRProfileR04")
838  pfIsoMeanDRR04_ = deposit;
839 
840  if(label=="pfIsoSumDRProfileR03")
841  pfIsoSumDRR03_ = deposit;
842 
843  if(label=="pfIsoSumDRProfileR04")
844  pfIsoSumDRR04_ = deposit;
845 
846  pfIsolationValid_ = true;
847 }
848 
849 
850 void Muon::setPFP4( const reco::Candidate::LorentzVector& p4 )
851 {
852  pfP4_ = p4;
853  type_ = type_ | PFMuon;
854 }
855 
856 
857 
858 void Muon::setOuterTrack( const TrackRef & t ) { outerTrack_ = t; }
859 void Muon::setInnerTrack( const TrackRef & t ) { innerTrack_ = t; }
860 void Muon::setTrack( const TrackRef & t ) { setInnerTrack(t); }
861 void Muon::setStandAlone( const TrackRef & t ) { setOuterTrack(t); }
862 void Muon::setGlobalTrack( const TrackRef & t ) { globalTrack_ = t; }
863 void Muon::setCombined( const TrackRef & t ) { setGlobalTrack(t); }
864 
865 
866 bool Muon::isAValidMuonTrack(const MuonTrackType& type) const{
867  return muonTrack(type).isNonnull();
868 }
869 
870 TrackRef Muon::muonTrack(const MuonTrackType& type) const{
871  switch (type) {
872  case InnerTrack: return innerTrack();
873  case OuterTrack: return standAloneMuon();
874  case CombinedTrack: return globalTrack();
875  case TPFMS: return tpfmsTrack();
876  case Picky: return pickyTrack();
877  case DYT: return dytTrack();
878  default: return muonTrackFromMap(type);
879  }
880 }
881 
882 void Muon::setMuonTrack(const MuonTrackType& type, const TrackRef& t) {
883 
884  switch (type) {
885  case InnerTrack: setInnerTrack(t); break;
886  case OuterTrack: setStandAlone(t); break;
887  case CombinedTrack: setGlobalTrack(t); break;
888  default: refittedTrackMap_[type] = t; break;
889  }
890 
891 }
892 
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