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