CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Muon.cc
Go to the documentation of this file.
3 
4 using namespace reco;
5 
6 Muon::Muon( Charge q, const LorentzVector & p4, const Point & vtx ) :
7  RecoCandidate( q, p4, vtx, -13 * q ) {
8  energyValid_ = false;
9  matchesValid_ = false;
10  isolationValid_ = false;
11  pfIsolationValid_ = false;
12  qualityValid_ = false;
13  caloCompatibility_ = -9999.;
14  type_ = 0;
16 }
17 
19  energyValid_ = false;
20  matchesValid_ = false;
21  isolationValid_ = false;
22  pfIsolationValid_ = false;
23  qualityValid_ = false;
24  caloCompatibility_ = -9999.;
25  type_ = 0;
27 }
28 
29 bool Muon::overlap( const Candidate & c ) const {
30  const RecoCandidate * o = dynamic_cast<const RecoCandidate *>( & c );
31  return ( o != 0 &&
32  ( checkOverlap( track(), o->track() ) ||
35  checkOverlap( standAloneMuon(), o->track() ) ||
36  checkOverlap( combinedMuon(), o->track() ) )
37  );
38 }
39 
40 Muon * Muon::clone() const {
41  return new Muon( * this );
42 }
43 
45 {
46  int total = 0;
47  int nAll = numberOfChambers();
48  for (int iC = 0; iC < nAll; ++iC){
49  if (matches()[iC].detector() == MuonSubdetId::RPC) continue;
50  total++;
51  }
52 
53  return total;
54 }
55 
57 {
58  int matches(0);
59  for( std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
60  chamberMatch != muMatches_.end(); chamberMatch++ )
61  {
62  if(chamberMatch->segmentMatches.empty()) continue;
63  if(type == NoArbitration) {
64  matches++;
65  continue;
66  }
67 
68  for( std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
69  segmentMatch != chamberMatch->segmentMatches.end(); segmentMatch++ )
70  {
71  if(type == SegmentArbitration)
72  if(segmentMatch->isMask(MuonSegmentMatch::BestInChamberByDR)) {
73  matches++;
74  break;
75  }
76  if(type == SegmentAndTrackArbitration)
77  if(segmentMatch->isMask(MuonSegmentMatch::BestInChamberByDR) &&
78  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR)) {
79  matches++;
80  break;
81  }
83  if(segmentMatch->isMask(MuonSegmentMatch::BestInChamberByDR) &&
84  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR) &&
85  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByCleaning)) {
86  matches++;
87  break;
88  }
89  if(type > 1<<7)
90  if(segmentMatch->isMask(type)) {
91  matches++;
92  break;
93  }
94  }
95  }
96 
97  return matches;
98 }
99 
101 {
102  int stations(0);
103 
104  unsigned int theStationMask = stationMask(type);
105  // eight stations, eight bits
106  for(int it = 0; it < 8; ++it)
107  if (theStationMask & 1<<it)
108  ++stations;
109 
110  return stations;
111 }
112 
114 {
115  unsigned int totMask(0);
116  unsigned int curMask(0);
117  for( std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
118  chamberMatch != muMatches_.end(); chamberMatch++ )
119  {
120  if(chamberMatch->segmentMatches.empty()) continue;
121  if(type == NoArbitration) {
122  curMask = 1<<( (chamberMatch->station()-1)+4*(chamberMatch->detector()-1) );
123  // do not double count
124  if(!(totMask & curMask))
125  totMask += curMask;
126  continue;
127  }
128 
129  for( std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
130  segmentMatch != chamberMatch->segmentMatches.end(); segmentMatch++ )
131  {
132  if(type == SegmentArbitration)
133  if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR)) {
134  curMask = 1<<( (chamberMatch->station()-1)+4*(chamberMatch->detector()-1) );
135  // do not double count
136  if(!(totMask & curMask))
137  totMask += curMask;
138  break;
139  }
140  if(type == SegmentAndTrackArbitration)
141  if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR) &&
142  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR)) {
143  curMask = 1<<( (chamberMatch->station()-1)+4*(chamberMatch->detector()-1) );
144  // do not double count
145  if(!(totMask & curMask))
146  totMask += curMask;
147  break;
148  }
150  if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR) &&
151  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR) &&
152  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByCleaning)) {
153  curMask = 1<<( (chamberMatch->station()-1)+4*(chamberMatch->detector()-1) );
154  // do not double count
155  if(!(totMask & curMask))
156  totMask += curMask;
157  break;
158  }
159  if(type > 1<<7)
160  if(segmentMatch->isMask(type)) {
161  curMask = 1<<( (chamberMatch->station()-1)+4*(chamberMatch->detector()-1) );
162  // do not double count
163  if(!(totMask & curMask))
164  totMask += curMask;
165  break;
166  }
167  }
168  }
169 
170  return totMask;
171 }
172 
173 unsigned int Muon::stationGapMaskDistance( float distanceCut ) const
174 {
175  unsigned int totMask(0);
176  for( int stationIndex = 1; stationIndex < 5; stationIndex++ )
177  {
178  for( int detectorIndex = 1; detectorIndex < 4; detectorIndex++ )
179  {
180  unsigned int curMask(0);
181  for( std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
182  chamberMatch != muMatches_.end(); chamberMatch++ )
183  {
184  if(!(chamberMatch->station()==stationIndex && chamberMatch->detector()==detectorIndex)) continue;
185 
186  float edgeX = chamberMatch->edgeX;
187  float edgeY = chamberMatch->edgeY;
188  if(edgeX<0 && fabs(edgeX)>fabs(distanceCut) &&
189  edgeY<0 && fabs(edgeY)>fabs(distanceCut)) // inside the chamber so negates all gaps for this station
190  {
191  curMask = 0;
192  break;
193  }
194  if( ( fabs(edgeX) < fabs(distanceCut) && edgeY < fabs(distanceCut) ) ||
195  ( fabs(edgeY) < fabs(distanceCut) && edgeX < fabs(distanceCut) ) ) // inside gap
196  curMask = 1<<( (stationIndex-1)+4*(detectorIndex-1) );
197  }
198 
199  totMask += curMask; // add to total mask
200  }
201  }
202 
203  return totMask;
204 }
205 
206 unsigned int Muon::stationGapMaskPull( float sigmaCut ) const
207 {
208  unsigned int totMask(0);
209  for( int stationIndex = 1; stationIndex < 5; stationIndex++ )
210  {
211  for( int detectorIndex = 1; detectorIndex < 4; detectorIndex++ )
212  {
213  unsigned int curMask(0);
214  for( std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
215  chamberMatch != muMatches_.end(); chamberMatch++ )
216  {
217  if(!(chamberMatch->station()==stationIndex && chamberMatch->detector()==detectorIndex)) continue;
218 
219  float edgeX = chamberMatch->edgeX;
220  float edgeY = chamberMatch->edgeY;
221  float xErr = chamberMatch->xErr+0.000001; // protect against division by zero later
222  float yErr = chamberMatch->yErr+0.000001; // protect against division by zero later
223  if(edgeX<0 && fabs(edgeX/xErr)>fabs(sigmaCut) &&
224  edgeY<0 && fabs(edgeY/yErr)>fabs(sigmaCut)) // inside the chamber so negates all gaps for this station
225  {
226  curMask = 0;
227  break;
228  }
229  if( ( fabs(edgeX/xErr) < fabs(sigmaCut) && edgeY/yErr < fabs(sigmaCut) ) ||
230  ( fabs(edgeY/yErr) < fabs(sigmaCut) && edgeX/xErr < fabs(sigmaCut) ) ) // inside gap
231  curMask = 1<<((stationIndex-1)+4*(detectorIndex-1));
232  }
233 
234  totMask += curMask; // add to total mask
235  }
236  }
237 
238  return totMask;
239 }
240 
241 int Muon::numberOfSegments( int station, int muonSubdetId, ArbitrationType type ) const
242 {
243  int segments(0);
244  for( std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
245  chamberMatch != muMatches_.end(); chamberMatch++ )
246  {
247  if(chamberMatch->segmentMatches.empty()) continue;
248  if(!(chamberMatch->station()==station && chamberMatch->detector()==muonSubdetId)) continue;
249 
250  if(type == NoArbitration) {
251  segments += chamberMatch->segmentMatches.size();
252  continue;
253  }
254 
255  for( std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
256  segmentMatch != chamberMatch->segmentMatches.end(); segmentMatch++ )
257  {
258  if(type == SegmentArbitration)
259  if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR)) {
260  segments++;
261  break;
262  }
263  if(type == SegmentAndTrackArbitration)
264  if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR) &&
265  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR)) {
266  segments++;
267  break;
268  }
270  if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR) &&
271  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR) &&
272  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByCleaning)) {
273  segments++;
274  break;
275  }
276  if(type > 1<<7)
277  if(segmentMatch->isMask(type)) {
278  segments++;
279  break;
280  }
281  }
282  }
283 
284  return segments;
285 }
286 
287 const std::vector<const MuonChamberMatch*> Muon::chambers( int station, int muonSubdetId ) const
288 {
289  std::vector<const MuonChamberMatch*> chambers;
290  for(std::vector<MuonChamberMatch>::const_iterator chamberMatch = muMatches_.begin();
291  chamberMatch != muMatches_.end(); chamberMatch++)
292  if(chamberMatch->station()==station && chamberMatch->detector()==muonSubdetId)
293  chambers.push_back(&(*chamberMatch));
294  return chambers;
295 }
296 
297 std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> Muon::pair( const std::vector<const MuonChamberMatch*> &chambers,
298  ArbitrationType type ) const
299 {
300  MuonChamberMatch* m = 0;
301  MuonSegmentMatch* s = 0;
302  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair(m,s);
303 
304  if(chambers.empty()) return chamberSegmentPair;
305  for( std::vector<const MuonChamberMatch*>::const_iterator chamberMatch = chambers.begin();
306  chamberMatch != chambers.end(); chamberMatch++ )
307  {
308  if((*chamberMatch)->segmentMatches.empty()) continue;
309  if(type == NoArbitration)
310  return std::make_pair(*chamberMatch, &((*chamberMatch)->segmentMatches.front()));
311 
312  for( std::vector<MuonSegmentMatch>::const_iterator segmentMatch = (*chamberMatch)->segmentMatches.begin();
313  segmentMatch != (*chamberMatch)->segmentMatches.end(); segmentMatch++ )
314  {
315  if(type == SegmentArbitration)
316  if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR))
317  return std::make_pair(*chamberMatch, &(*segmentMatch));
318  if(type == SegmentAndTrackArbitration)
319  if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR) &&
320  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR))
321  return std::make_pair(*chamberMatch, &(*segmentMatch));
323  if(segmentMatch->isMask(MuonSegmentMatch::BestInStationByDR) &&
324  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByDR) &&
325  segmentMatch->isMask(MuonSegmentMatch::BelongsToTrackByCleaning))
326  return std::make_pair(*chamberMatch, &(*segmentMatch));
327  if(type > 1<<7)
328  if(segmentMatch->isMask(type))
329  return std::make_pair(*chamberMatch, &(*segmentMatch));
330  }
331  }
332 
333  return chamberSegmentPair;
334 }
335 
336 float Muon::dX( int station, int muonSubdetId, ArbitrationType type ) const
337 {
338  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
339  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
340  if(! chamberSegmentPair.second->hasPhi()) return 999999;
341  return chamberSegmentPair.first->x-chamberSegmentPair.second->x;
342 }
343 
344 float Muon::dY( int station, int muonSubdetId, ArbitrationType type ) const
345 {
346  if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999; // no y information
347  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
348  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
349  if(! chamberSegmentPair.second->hasZed()) return 999999;
350  return chamberSegmentPair.first->y-chamberSegmentPair.second->y;
351 }
352 
353 float Muon::dDxDz( int station, int muonSubdetId, ArbitrationType type ) const
354 {
355  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
356  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
357  if(! chamberSegmentPair.second->hasPhi()) return 999999;
358  return chamberSegmentPair.first->dXdZ-chamberSegmentPair.second->dXdZ;
359 }
360 
361 float Muon::dDyDz( int station, int muonSubdetId, ArbitrationType type ) const
362 {
363  if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999; // no y information
364  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
365  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
366  if(! chamberSegmentPair.second->hasZed()) return 999999;
367  return chamberSegmentPair.first->dYdZ-chamberSegmentPair.second->dYdZ;
368 }
369 
370 float Muon::pullX( int station, int muonSubdetId, ArbitrationType type, bool includeSegmentError ) const
371 {
372  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
373  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
374  if(! chamberSegmentPair.second->hasPhi()) return 999999;
375  if(includeSegmentError)
376  return (chamberSegmentPair.first->x-chamberSegmentPair.second->x)/sqrt(pow(chamberSegmentPair.first->xErr,2)+pow(chamberSegmentPair.second->xErr,2));
377  return (chamberSegmentPair.first->x-chamberSegmentPair.second->x)/chamberSegmentPair.first->xErr;
378 }
379 
380 float Muon::pullY( int station, int muonSubdetId, ArbitrationType type, bool includeSegmentError) const
381 {
382  if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999; // no y information
383  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
384  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
385  if(! chamberSegmentPair.second->hasZed()) return 999999;
386  if(includeSegmentError)
387  return (chamberSegmentPair.first->y-chamberSegmentPair.second->y)/sqrt(pow(chamberSegmentPair.first->yErr,2)+pow(chamberSegmentPair.second->yErr,2));
388  return (chamberSegmentPair.first->y-chamberSegmentPair.second->y)/chamberSegmentPair.first->yErr;
389 }
390 
391 float Muon::pullDxDz( int station, int muonSubdetId, ArbitrationType type, bool includeSegmentError ) const
392 {
393  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
394  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
395  if(! chamberSegmentPair.second->hasPhi()) return 999999;
396  if(includeSegmentError)
397  return (chamberSegmentPair.first->dXdZ-chamberSegmentPair.second->dXdZ)/sqrt(pow(chamberSegmentPair.first->dXdZErr,2)+pow(chamberSegmentPair.second->dXdZErr,2));
398  return (chamberSegmentPair.first->dXdZ-chamberSegmentPair.second->dXdZ)/chamberSegmentPair.first->dXdZErr;
399 }
400 
401 float Muon::pullDyDz( int station, int muonSubdetId, ArbitrationType type, bool includeSegmentError ) const
402 {
403  if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999; // no y information
404  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
405  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
406  if(! chamberSegmentPair.second->hasZed()) return 999999;
407  if(includeSegmentError)
408  return (chamberSegmentPair.first->dYdZ-chamberSegmentPair.second->dYdZ)/sqrt(pow(chamberSegmentPair.first->dYdZErr,2)+pow(chamberSegmentPair.second->dYdZErr,2));
409  return (chamberSegmentPair.first->dYdZ-chamberSegmentPair.second->dYdZ)/chamberSegmentPair.first->dYdZErr;
410 }
411 
412 float Muon::segmentX( int station, int muonSubdetId, ArbitrationType type ) const
413 {
414  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
415  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
416  if(! chamberSegmentPair.second->hasPhi()) return 999999;
417  return chamberSegmentPair.second->x;
418 }
419 
420 float Muon::segmentY( int station, int muonSubdetId, ArbitrationType type ) const
421 {
422  if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999; // no y information
423  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
424  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
425  if(! chamberSegmentPair.second->hasZed()) return 999999;
426  return chamberSegmentPair.second->y;
427 }
428 
429 float Muon::segmentDxDz( int station, int muonSubdetId, ArbitrationType type ) const
430 {
431  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
432  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
433  if(! chamberSegmentPair.second->hasPhi()) return 999999;
434  return chamberSegmentPair.second->dXdZ;
435 }
436 
437 float Muon::segmentDyDz( int station, int muonSubdetId, ArbitrationType type ) const
438 {
439  if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999; // no y information
440  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
441  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
442  if(! chamberSegmentPair.second->hasZed()) return 999999;
443  return chamberSegmentPair.second->dYdZ;
444 }
445 
446 float Muon::segmentXErr( int station, int muonSubdetId, ArbitrationType type ) const
447 {
448  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
449  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
450  if(! chamberSegmentPair.second->hasPhi()) return 999999;
451  return chamberSegmentPair.second->xErr;
452 }
453 
454 float Muon::segmentYErr( int station, int muonSubdetId, ArbitrationType type ) const
455 {
456  if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999; // no y information
457  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
458  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
459  if(! chamberSegmentPair.second->hasZed()) return 999999;
460  return chamberSegmentPair.second->yErr;
461 }
462 
463 float Muon::segmentDxDzErr( int station, int muonSubdetId, ArbitrationType type ) const
464 {
465  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
466  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
467  if(! chamberSegmentPair.second->hasPhi()) return 999999;
468  return chamberSegmentPair.second->dXdZErr;
469 }
470 
471 float Muon::segmentDyDzErr( int station, int muonSubdetId, ArbitrationType type ) const
472 {
473  if(station==4 && muonSubdetId==MuonSubdetId::DT) return 999999; // no y information
474  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(chambers(station,muonSubdetId),type);
475  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) return 999999;
476  if(! chamberSegmentPair.second->hasZed()) return 999999;
477  return chamberSegmentPair.second->dYdZErr;
478 }
479 
480 float Muon::trackEdgeX( int station, int muonSubdetId, ArbitrationType type ) const
481 {
482  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
483  if(muonChambers.empty()) return 999999;
484 
485  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
486  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
487  float dist = 999999;
488  float supVar = 999999;
489  for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
490  muonChamber != muonChambers.end(); ++muonChamber) {
491  float currDist = (*muonChamber)->dist();
492  if(currDist<dist) {
493  dist = currDist;
494  supVar = (*muonChamber)->edgeX;
495  }
496  }
497  return supVar;
498  } else return chamberSegmentPair.first->edgeX;
499 }
500 
501 float Muon::trackEdgeY( int station, int muonSubdetId, ArbitrationType type ) const
502 {
503  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
504  if(muonChambers.empty()) return 999999;
505 
506  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
507  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
508  float dist = 999999;
509  float supVar = 999999;
510  for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
511  muonChamber != muonChambers.end(); ++muonChamber) {
512  float currDist = (*muonChamber)->dist();
513  if(currDist<dist) {
514  dist = currDist;
515  supVar = (*muonChamber)->edgeY;
516  }
517  }
518  return supVar;
519  } else return chamberSegmentPair.first->edgeY;
520 }
521 
522 float Muon::trackX( int station, int muonSubdetId, ArbitrationType type ) const
523 {
524  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
525  if(muonChambers.empty()) return 999999;
526 
527  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
528  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
529  float dist = 999999;
530  float supVar = 999999;
531  for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
532  muonChamber != muonChambers.end(); ++muonChamber) {
533  float currDist = (*muonChamber)->dist();
534  if(currDist<dist) {
535  dist = currDist;
536  supVar = (*muonChamber)->x;
537  }
538  }
539  return supVar;
540  } else return chamberSegmentPair.first->x;
541 }
542 
543 float Muon::trackY( int station, int muonSubdetId, ArbitrationType type ) const
544 {
545  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
546  if(muonChambers.empty()) return 999999;
547 
548  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
549  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
550  float dist = 999999;
551  float supVar = 999999;
552  for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
553  muonChamber != muonChambers.end(); ++muonChamber) {
554  float currDist = (*muonChamber)->dist();
555  if(currDist<dist) {
556  dist = currDist;
557  supVar = (*muonChamber)->y;
558  }
559  }
560  return supVar;
561  } else return chamberSegmentPair.first->y;
562 }
563 
564 float Muon::trackDxDz( int station, int muonSubdetId, ArbitrationType type ) const
565 {
566  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
567  if(muonChambers.empty()) return 999999;
568 
569  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
570  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
571  float dist = 999999;
572  float supVar = 999999;
573  for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
574  muonChamber != muonChambers.end(); ++muonChamber) {
575  float currDist = (*muonChamber)->dist();
576  if(currDist<dist) {
577  dist = currDist;
578  supVar = (*muonChamber)->dXdZ;
579  }
580  }
581  return supVar;
582  } else return chamberSegmentPair.first->dXdZ;
583 }
584 
585 float Muon::trackDyDz( int station, int muonSubdetId, ArbitrationType type ) const
586 {
587  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
588  if(muonChambers.empty()) return 999999;
589 
590  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
591  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
592  float dist = 999999;
593  float supVar = 999999;
594  for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
595  muonChamber != muonChambers.end(); ++muonChamber) {
596  float currDist = (*muonChamber)->dist();
597  if(currDist<dist) {
598  dist = currDist;
599  supVar = (*muonChamber)->dYdZ;
600  }
601  }
602  return supVar;
603  } else return chamberSegmentPair.first->dYdZ;
604 }
605 
606 float Muon::trackXErr( int station, int muonSubdetId, ArbitrationType type ) const
607 {
608  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
609  if(muonChambers.empty()) return 999999;
610 
611  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
612  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
613  float dist = 999999;
614  float supVar = 999999;
615  for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
616  muonChamber != muonChambers.end(); ++muonChamber) {
617  float currDist = (*muonChamber)->dist();
618  if(currDist<dist) {
619  dist = currDist;
620  supVar = (*muonChamber)->xErr;
621  }
622  }
623  return supVar;
624  } else return chamberSegmentPair.first->xErr;
625 }
626 
627 float Muon::trackYErr( int station, int muonSubdetId, ArbitrationType type ) const
628 {
629  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
630  if(muonChambers.empty()) return 999999;
631 
632  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
633  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
634  float dist = 999999;
635  float supVar = 999999;
636  for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
637  muonChamber != muonChambers.end(); ++muonChamber) {
638  float currDist = (*muonChamber)->dist();
639  if(currDist<dist) {
640  dist = currDist;
641  supVar = (*muonChamber)->yErr;
642  }
643  }
644  return supVar;
645  } else return chamberSegmentPair.first->yErr;
646 }
647 
648 float Muon::trackDxDzErr( int station, int muonSubdetId, ArbitrationType type ) const
649 {
650  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
651  if(muonChambers.empty()) return 999999;
652 
653  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
654  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
655  float dist = 999999;
656  float supVar = 999999;
657  for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
658  muonChamber != muonChambers.end(); ++muonChamber) {
659  float currDist = (*muonChamber)->dist();
660  if(currDist<dist) {
661  dist = currDist;
662  supVar = (*muonChamber)->dXdZErr;
663  }
664  }
665  return supVar;
666  } else return chamberSegmentPair.first->dXdZErr;
667 }
668 
669 float Muon::trackDyDzErr( int station, int muonSubdetId, ArbitrationType type ) const
670 {
671  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
672  if(muonChambers.empty()) return 999999;
673 
674  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
675  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
676  float dist = 999999;
677  float supVar = 999999;
678  for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
679  muonChamber != muonChambers.end(); ++muonChamber) {
680  float currDist = (*muonChamber)->dist();
681  if(currDist<dist) {
682  dist = currDist;
683  supVar = (*muonChamber)->dYdZErr;
684  }
685  }
686  return supVar;
687  } else return chamberSegmentPair.first->dYdZErr;
688 }
689 
690 float Muon::trackDist( int station, int muonSubdetId, ArbitrationType type ) const
691 {
692  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
693  if(muonChambers.empty()) return 999999;
694 
695  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
696  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
697  float dist = 999999;
698  for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
699  muonChamber != muonChambers.end(); ++muonChamber) {
700  float currDist = (*muonChamber)->dist();
701  if(currDist<dist) dist = currDist;
702  }
703  return dist;
704  } else return chamberSegmentPair.first->dist();
705 }
706 
707 float Muon::trackDistErr( int station, int muonSubdetId, ArbitrationType type ) const
708 {
709  const std::vector<const MuonChamberMatch*> muonChambers = chambers(station, muonSubdetId);
710  if(muonChambers.empty()) return 999999;
711 
712  std::pair<const MuonChamberMatch*,const MuonSegmentMatch*> chamberSegmentPair = pair(muonChambers,type);
713  if(chamberSegmentPair.first==0 || chamberSegmentPair.second==0) {
714  float dist = 999999;
715  float supVar = 999999;
716  for(std::vector<const MuonChamberMatch*>::const_iterator muonChamber = muonChambers.begin();
717  muonChamber != muonChambers.end(); ++muonChamber) {
718  float currDist = (*muonChamber)->dist();
719  if(currDist<dist) {
720  dist = currDist;
721  supVar = (*muonChamber)->distErr();
722  }
723  }
724  return supVar;
725  } else return chamberSegmentPair.first->distErr();
726 }
727 
728 void Muon::setIsolation( const MuonIsolation& isoR03, const MuonIsolation& isoR05 )
729 {
730  isolationR03_ = isoR03;
731  isolationR05_ = isoR05;
732  isolationValid_ = true;
733 }
734 
735 
736 void Muon::setPFIsolation( const MuonPFIsolation& isoR03, const MuonPFIsolation& isoR04 )
737 {
738  pfIsolationR03_ = isoR03;
739  pfIsolationR04_ = isoR04;
740  pfIsolationValid_ = true;
741 }
742 
743 
745 {
746  pfP4_ = p4;
747  type_ = type_ | PFMuon;
748 }
749 
750 
751 
754 void Muon::setTrack( const TrackRef & t ) { setInnerTrack(t); }
758 
759 
761  return muonTrack(type).isNonnull();
762 }
763 
765  switch (type) {
766  case InnerTrack: return innerTrack();
767  case OuterTrack: return standAloneMuon();
768  case CombinedTrack: return globalTrack();
769  case TPFMS: return tpfmsTrack();
770  case Picky: return pickyTrack();
771  case DYT: return dytTrack();
772  default: return muonTrackFromMap(type);
773  }
774 }
775 
777 
778  switch (type) {
779  case InnerTrack: setInnerTrack(t); break;
780  case OuterTrack: setStandAlone(t); break;
781  case CombinedTrack: setGlobalTrack(t); break;
782  default: refittedTrackMap_[type] = t; break;
783  }
784 
785 }
786 
float segmentXErr(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:446
type
Definition: HCALResponse.h:22
int Charge
electric charge type
Definition: Candidate.h:36
bool checkOverlap(const R &r1, const R &r2) const
check if two components overlap
Definition: RecoCandidate.h:67
reco::Candidate::LorentzVector pfP4_
Definition: Muon.h:259
float dDyDz(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:361
virtual void setOuterTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:752
MuonIsolation isolationR05_
Definition: Muon.h:249
float trackDistErr(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:707
const std::vector< const MuonChamberMatch * > chambers(int station, int muonSubdetId) const
get vector of muon chambers for given station and detector
Definition: Muon.cc:287
TrackRef muonTrack(const MuonTrackType &) const
Definition: Muon.cc:764
float segmentDxDzErr(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:463
virtual TrackRef innerTrack() const
Definition: Muon.h:49
float caloCompatibility_
muon hypothesis compatibility with observer calorimeter energy
Definition: Muon.h:246
unsigned int type_
muon type mask
Definition: Muon.h:256
virtual void setInnerTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:753
bool isolationValid_
Definition: Muon.h:242
virtual TrackRef track() const
reference to a Track
Definition: Muon.h:50
MuonPFIsolation pfIsolationR04_
Definition: Muon.h:253
void setIsolation(const MuonIsolation &isoR03, const MuonIsolation &isoR05)
Definition: Muon.cc:728
unsigned int stationGapMaskPull(float sigmaCut=3.) const
same as above for given number of sigmas
Definition: Muon.cc:206
MuonPFIsolation pfIsolationR03_
PF Isolation information for two cones with dR=0.3 and dR=0.4.
Definition: Muon.h:252
float dY(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:344
virtual reco::TrackRef standAloneMuon() const
reference to a stand-alone muon Track
virtual TrackRef tpfmsTrack() const
Definition: Muon.h:58
static const unsigned int BestInStationByDR
float trackX(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:522
float trackEdgeX(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:480
virtual void setStandAlone(const TrackRef &t)
Definition: Muon.cc:755
virtual reco::TrackRef track() const
reference to a Track
bool isAValidMuonTrack(const MuonTrackType &type) const
Definition: Muon.cc:760
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
MuonTrackRefMap refittedTrackMap_
reference to the Global Track refitted with dedicated TeV reconstructors
Definition: Muon.h:228
std::pair< const MuonChamberMatch *, const MuonSegmentMatch * > pair(const std::vector< const MuonChamberMatch * > &, ArbitrationType type=SegmentAndTrackArbitration) const
get pointers to best segment and corresponding chamber in vector of chambers
Definition: Muon.cc:297
float segmentDyDz(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:437
TrackRef innerTrack_
reference to Track reconstructed in the tracker only
Definition: Muon.h:222
ArbitrationType
define arbitration schemes
Definition: Muon.h:173
T sqrt(T t)
Definition: SSEVec.h:46
double p4[4]
Definition: TauolaWrapper.h:92
float trackY(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:543
float segmentY(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:420
float pullDxDz(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration, bool includeSegmentError=true) const
Definition: Muon.cc:391
MuonTrackType bestTrackType_
reference to the Track chosen to assign the momentum value to the muon
Definition: Muon.h:230
virtual TrackRef pickyTrack() const
Definition: Muon.h:59
static const unsigned int BestInChamberByDR
unsigned int stationMask(ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:113
float trackXErr(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:606
bool energyValid_
Definition: Muon.h:240
void setMuonTrack(const MuonTrackType &, const TrackRef &)
Definition: Muon.cc:776
float trackDyDz(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:585
float dDxDz(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:353
float pullY(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration, bool includeSegmentError=true) const
Definition: Muon.cc:380
float segmentX(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:412
static const unsigned int BelongsToTrackByCleaning
virtual void setTrack(const TrackRef &t)
Definition: Muon.cc:754
int numberOfMatches(ArbitrationType type=SegmentAndTrackArbitration) const
get number of chambers with matched segments
Definition: Muon.cc:56
Muon * clone() const
create a clone
Definition: Muon.cc:40
float trackDxDz(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:564
float trackDyDzErr(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:669
int numberOfSegments(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
get number of segments
Definition: Muon.cc:241
virtual TrackRef combinedMuon() const
reference to a stand-alone muon Track
Definition: Muon.h:56
int numberOfChambers() const
Definition: Muon.h:179
bool pfIsolationValid_
Definition: Muon.h:243
int numberOfChambersNoRPC() const
number of chambers not including RPC matches (MuonChamberMatches include RPC rolls) ...
Definition: Muon.cc:44
static const unsigned int PFMuon
Definition: Muon.h:204
MuonIsolation isolationR03_
Isolation information for two cones with dR=0.3 and dR=0.5.
Definition: Muon.h:248
std::vector< MuonChamberMatch > & matches()
get muon matching information
Definition: Muon.h:141
float trackDxDzErr(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:648
bool qualityValid_
Definition: Muon.h:244
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:38
TrackRef outerTrack_
reference to Track reconstructed in the muon detector only
Definition: Muon.h:224
virtual TrackRef dytTrack() const
Definition: Muon.h:60
std::vector< MuonChamberMatch > muMatches_
Information on matching between tracks and segments.
Definition: Muon.h:237
float trackDist(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:690
static const unsigned int BelongsToTrackByDR
float trackEdgeY(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:501
float dX(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:336
Muon()
Definition: Muon.cc:18
float segmentDxDz(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:429
static const int RPC
Definition: MuonSubdetId.h:16
float trackYErr(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:627
int numberOfMatchedStations(ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:100
def stationIndex
Definition: plotscripts.py:353
virtual bool overlap(const Candidate &) const
check overlap with another candidate
Definition: Muon.cc:29
unsigned int type() const
Definition: Muon.h:208
virtual void setCombined(const TrackRef &t)
Definition: Muon.cc:757
math::XYZPoint Point
point in the space
Definition: Candidate.h:42
static const int DT
Definition: MuonSubdetId.h:14
bool matchesValid_
Definition: Muon.h:241
TrackRef globalTrack_
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:226
virtual void setPFP4(const reco::Candidate::LorentzVector &p4_)
Definition: Muon.cc:744
float segmentYErr(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:454
MuonTrackType
map for Global Muon refitters
Definition: Muon.h:39
float segmentDyDzErr(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration) const
Definition: Muon.cc:471
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
void setPFIsolation(const MuonPFIsolation &isoR03, const MuonPFIsolation &isoR04)
Definition: Muon.cc:736
virtual void setGlobalTrack(const TrackRef &t)
set reference to Track
Definition: Muon.cc:756
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
unsigned int stationGapMaskDistance(float distanceCut=10.) const
Definition: Muon.cc:173
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
float pullDyDz(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration, bool includeSegmentError=true) const
Definition: Muon.cc:401
TrackRef muonTrackFromMap(const MuonTrackType &type) const
Definition: Muon.h:76
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:55
float pullX(int station, int muonSubdetId, ArbitrationType type=SegmentAndTrackArbitration, bool includeSegmentError=true) const
Definition: Muon.cc:370
virtual reco::TrackRef combinedMuon() const
reference to a stand-alone muon Track
virtual TrackRef standAloneMuon() const
reference to a stand-alone muon Track
Definition: Muon.h:53