CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonSeedOrcaPatternRecognition.cc
Go to the documentation of this file.
1 
15 
22 
25 
26 
27 // Geometry
30 
34 
35 // Framework
41 
42 // C++
43 #include <vector>
44 
45 using namespace std;
46 
47  const std::string metname = "Muon|RecoMuon|MuonSeedOrcaPatternRecognition";
48 
49 // Constructor
52  theCrackEtas(pset.getParameter<std::vector<double> >("crackEtas")),
53  theCrackWindow(pset.getParameter<double>("crackWindow"))
54 {
55 }
56 
57 
58 // reconstruct muon's seeds
60  std::vector<MuonRecHitContainer> & result)
61 {
62  // divide the RecHits by DetLayer, in order to fill the
63  // RecHitContainer like it was in ORCA
64 
65  // Muon Geometry - DT, CSC and RPC
67  eSetup.get<MuonRecoGeometryRecord>().get(muonLayers);
68 
69  // get the DT layers
70  vector<DetLayer*> dtLayers = muonLayers->allDTLayers();
71 
72  // get the CSC layers
73  vector<DetLayer*> cscForwardLayers = muonLayers->forwardCSCLayers();
74  vector<DetLayer*> cscBackwardLayers = muonLayers->backwardCSCLayers();
75 
76  // Backward (z<0) EndCap disk
77  const DetLayer* ME4Bwd = cscBackwardLayers[4];
78  const DetLayer* ME3Bwd = cscBackwardLayers[3];
79  const DetLayer* ME2Bwd = cscBackwardLayers[2];
80  const DetLayer* ME12Bwd = cscBackwardLayers[1];
81  const DetLayer* ME11Bwd = cscBackwardLayers[0];
82 
83  // Forward (z>0) EndCap disk
84  const DetLayer* ME11Fwd = cscForwardLayers[0];
85  const DetLayer* ME12Fwd = cscForwardLayers[1];
86  const DetLayer* ME2Fwd = cscForwardLayers[2];
87  const DetLayer* ME3Fwd = cscForwardLayers[3];
88  const DetLayer* ME4Fwd = cscForwardLayers[4];
89 
90  // barrel
91  const DetLayer* MB4DL = dtLayers[3];
92  const DetLayer* MB3DL = dtLayers[2];
93  const DetLayer* MB2DL = dtLayers[1];
94  const DetLayer* MB1DL = dtLayers[0];
95 
96  // instantiate the accessor
97  // Don not use RPC for seeding
100  double barreldThetaCut = 0.2;
101  // still lose good muons to a tighter cut
102  double endcapdThetaCut = 1.0;
103  MuonRecHitContainer list9 = filterSegments(muonMeasurements.recHits(MB4DL,event), barreldThetaCut);
104  MuonRecHitContainer list6 = filterSegments(muonMeasurements.recHits(MB3DL,event), barreldThetaCut);
105  MuonRecHitContainer list7 = filterSegments(muonMeasurements.recHits(MB2DL,event), barreldThetaCut);
106  MuonRecHitContainer list8 = filterSegments(muonMeasurements.recHits(MB1DL,event), barreldThetaCut);
107 
108  dumpLayer("MB4 ", list9);
109  dumpLayer("MB3 ", list6);
110  dumpLayer("MB2 ", list7);
111  dumpLayer("MB1 ", list8);
112 
113  bool* MB1 = zero(list8.size());
114  bool* MB2 = zero(list7.size());
115  bool* MB3 = zero(list6.size());
116 
117  endcapPatterns(filterSegments(muonMeasurements.recHits(ME11Bwd,event), endcapdThetaCut),
118  filterSegments(muonMeasurements.recHits(ME12Bwd,event), endcapdThetaCut),
119  filterSegments(muonMeasurements.recHits(ME2Bwd,event), endcapdThetaCut),
120  filterSegments(muonMeasurements.recHits(ME3Bwd,event), endcapdThetaCut),
121  filterSegments(muonMeasurements.recHits(ME4Bwd,event), endcapdThetaCut),
122  list8, list7, list6,
123  MB1, MB2, MB3, result);
124 
125  endcapPatterns(filterSegments(muonMeasurements.recHits(ME11Fwd,event), endcapdThetaCut),
126  filterSegments(muonMeasurements.recHits(ME12Fwd,event), endcapdThetaCut),
127  filterSegments(muonMeasurements.recHits(ME2Fwd,event), endcapdThetaCut),
128  filterSegments(muonMeasurements.recHits(ME3Fwd,event), endcapdThetaCut),
129  filterSegments(muonMeasurements.recHits(ME4Fwd,event), endcapdThetaCut),
130  list8, list7, list6,
131  MB1, MB2, MB3, result);
132 
133 
134  // ---------- Barrel only
135 
136  unsigned int counter = 0;
137  if ( list9.size() < 100 ) { // +v
138  for (MuonRecHitContainer::iterator iter=list9.begin(); iter!=list9.end(); iter++ ){
139  MuonRecHitContainer seedSegments;
140  seedSegments.push_back(*iter);
141  complete(seedSegments, list6, MB3);
142  complete(seedSegments, list7, MB2);
143  complete(seedSegments, list8, MB1);
144  if(check(seedSegments)) result.push_back(seedSegments);
145  }
146  }
147 
148 
149  if ( list6.size() < 100 ) { // +v
150  for ( counter = 0; counter<list6.size(); counter++ ){
151  if ( !MB3[counter] ) {
152  MuonRecHitContainer seedSegments;
153  seedSegments.push_back(list6[counter]);
154  complete(seedSegments, list7, MB2);
155  complete(seedSegments, list8, MB1);
156  complete(seedSegments, list9);
157  if(check(seedSegments)) result.push_back(seedSegments);
158  }
159  }
160  }
161 
162 
163  if ( list7.size() < 100 ) { // +v
164  for ( counter = 0; counter<list7.size(); counter++ ){
165  if ( !MB2[counter] ) {
166  MuonRecHitContainer seedSegments;
167  seedSegments.push_back(list7[counter]);
168  complete(seedSegments, list8, MB1);
169  complete(seedSegments, list9);
170  complete(seedSegments, list6, MB3);
171  if (seedSegments.size()>1 ||
172  (seedSegments.size()==1 && seedSegments[0]->dimension()==4) )
173  {
174  result.push_back(seedSegments);
175  }
176  }
177  }
178  }
179 
180 
181  if ( list8.size() < 100 ) { // +v
182  for ( counter = 0; counter<list8.size(); counter++ ){
183  if ( !MB1[counter] ) {
184  MuonRecHitContainer seedSegments;
185  seedSegments.push_back(list8[counter]);
186  complete(seedSegments, list9);
187  complete(seedSegments, list6, MB3);
188  complete(seedSegments, list7, MB2);
189  if (seedSegments.size()>1 ||
190  (seedSegments.size()==1 && seedSegments[0]->dimension()==4) )
191  {
192  result.push_back(seedSegments);
193  }
194  }
195  }
196  }
197 
198  if ( MB3 ) delete [] MB3;
199  if ( MB2 ) delete [] MB2;
200  if ( MB1 ) delete [] MB1;
201 
202  if(result.empty())
203  {
204  // be a little stricter with single segment seeds
205  barreldThetaCut = 0.2;
206  endcapdThetaCut = 0.2;
207 
208  MuonRecHitContainer all = muonMeasurements.recHits(ME4Bwd,event);
209  MuonRecHitContainer tmp = filterSegments(muonMeasurements.recHits(ME3Bwd,event), endcapdThetaCut);
210  copy(tmp.begin(),tmp.end(),back_inserter(all));
211 
212  tmp = filterSegments(muonMeasurements.recHits(ME2Bwd,event), endcapdThetaCut);
213  copy(tmp.begin(),tmp.end(),back_inserter(all));
214 
215  tmp = filterSegments(muonMeasurements.recHits(ME12Bwd,event), endcapdThetaCut);
216  copy(tmp.begin(),tmp.end(),back_inserter(all));
217 
218  tmp = filterSegments(muonMeasurements.recHits(ME11Bwd,event), endcapdThetaCut);
219  copy(tmp.begin(),tmp.end(),back_inserter(all));
220 
221  tmp = filterSegments(muonMeasurements.recHits(ME11Fwd,event), endcapdThetaCut);
222  copy(tmp.begin(),tmp.end(),back_inserter(all));
223 
224  tmp = filterSegments(muonMeasurements.recHits(ME12Fwd,event), endcapdThetaCut);
225  copy(tmp.begin(),tmp.end(),back_inserter(all));
226 
227  tmp = filterSegments(muonMeasurements.recHits(ME2Fwd,event), endcapdThetaCut);
228  copy(tmp.begin(),tmp.end(),back_inserter(all));
229 
230  tmp = filterSegments(muonMeasurements.recHits(ME3Fwd,event), endcapdThetaCut);
231  copy(tmp.begin(),tmp.end(),back_inserter(all));
232 
233  tmp = filterSegments(muonMeasurements.recHits(ME4Fwd,event), endcapdThetaCut);
234  copy(tmp.begin(),tmp.end(),back_inserter(all));
235 
236  tmp = filterSegments(muonMeasurements.recHits(MB4DL,event), barreldThetaCut);
237  copy(tmp.begin(),tmp.end(),back_inserter(all));
238 
239  tmp = filterSegments(muonMeasurements.recHits(MB3DL,event), barreldThetaCut);
240  copy(tmp.begin(),tmp.end(),back_inserter(all));
241 
242  tmp = filterSegments(muonMeasurements.recHits(MB2DL,event), barreldThetaCut);
243  copy(tmp.begin(),tmp.end(),back_inserter(all));
244 
245  tmp = filterSegments(muonMeasurements.recHits(MB1DL,event), barreldThetaCut);
246  copy(tmp.begin(),tmp.end(),back_inserter(all));
247 
248  LogTrace(metname)<<"Number of segments: "<<all.size();
249 
250  for(MuonRecHitContainer::const_iterator segmentItr = all.begin();
251  segmentItr != all.end(); ++segmentItr)
252  {
253  MuonRecHitContainer singleSegmentContainer;
254  singleSegmentContainer.push_back(*segmentItr);
255  result.push_back(singleSegmentContainer);
256  }
257  }
258 
259 }
260 
261 
262 bool * MuonSeedOrcaPatternRecognition::zero(unsigned listSize)
263 {
264  bool * result = 0;
265  if (listSize) {
266  result = new bool[listSize];
267  for ( size_t i=0; i<listSize; i++ ) result[i]=false;
268  }
269  return result;
270 }
271 
272 
274  const MuonRecHitContainer & me11, const MuonRecHitContainer & me12,
275  const MuonRecHitContainer & me2, const MuonRecHitContainer & me3,
276  const MuonRecHitContainer & me4, const MuonRecHitContainer & mb1,
278  bool * MB1, bool * MB2, bool * MB3,
279  std::vector<MuonRecHitContainer> & result)
280 {
281  dumpLayer("ME4 ", me4);
282  dumpLayer("ME3 ", me3);
283  dumpLayer("ME2 ", me2);
284  dumpLayer("ME12 ", me12);
285  dumpLayer("ME11 ", me11);
286 
287  std::vector<MuonRecHitContainer> patterns;
288  MuonRecHitContainer crackSegments;
289  rememberCrackSegments(me11, crackSegments);
290  rememberCrackSegments(me12, crackSegments);
291  rememberCrackSegments(me2, crackSegments);
292  rememberCrackSegments(me3, crackSegments);
293  rememberCrackSegments(me4, crackSegments);
294 
295 
296  MuonRecHitContainer list24 = me4;
297  MuonRecHitContainer list23 = me3;
298 
299  MuonRecHitContainer list12 = me2;
300 
301  MuonRecHitContainer list22 = me12;
302  MuonRecHitContainer list21 = me11;
303 
304  MuonRecHitContainer list11 = list21;
305  MuonRecHitContainer list5 = list22;
306  MuonRecHitContainer list13 = list23;
307  MuonRecHitContainer list4 = list24;
308 
309  if ( list21.size() == 0 ) {
310  list11 = list22; list5 = list21;
311  }
312 
313  if ( list24.size() < list23.size() && list24.size() > 0 ) {
314  list13 = list24; list4 = list23;
315  }
316 
317  if ( list23.size() == 0 ) {
318  list13 = list24; list4 = list23;
319  }
320 
321  MuonRecHitContainer list1 = list11;
322  MuonRecHitContainer list2 = list12;
323  MuonRecHitContainer list3 = list13;
324 
325 
326  if ( list12.size() == 0 ) {
327  list3 = list12;
328  if ( list11.size() <= list13.size() && list11.size() > 0 ) {
329  list1 = list11; list2 = list13;}
330  else { list1 = list13; list2 = list11;}
331  }
332 
333  if ( list13.size() == 0 ) {
334  if ( list11.size() <= list12.size() && list11.size() > 0 ) {
335  list1 = list11; list2 = list12;}
336  else { list1 = list12; list2 = list11;}
337  }
338 
339  if ( list12.size() != 0 && list13.size() != 0 ) {
340  if ( list11.size()<=list12.size() && list11.size()<=list13.size() && list11.size()>0 ) { // ME 1
341  if ( list12.size() > list13.size() ) {
342  list2 = list13; list3 = list12;}
343  }
344  else if ( list12.size() <= list13.size() ) { // start with ME 2
345  list1 = list12;
346  if ( list11.size() <= list13.size() && list11.size() > 0 ) {
347  list2 = list11; list3 = list13;}
348  else { list2 = list13; list3 = list11;}
349  }
350  else { // start with ME 3
351  list1 = list13;
352  if ( list11.size() <= list12.size() && list11.size() > 0 ) {
353  list2 = list11; list3 = list12;}
354  else { list2 = list12; list3 = list11;}
355  }
356  }
357 
358 
359  bool* ME2 = zero(list2.size());
360  bool* ME3 = zero(list3.size());
361  bool* ME4 = zero(list4.size());
362  bool* ME5 = zero(list5.size());
363 
364 
365  // creates list of compatible track segments
366 
367  for (MuonRecHitContainer::iterator iter = list1.begin(); iter!=list1.end(); iter++ ){
368  if ( (*iter)->recHits().size() < 4 && list3.size() > 0 ) continue; // 3p.tr-seg. are not so good for starting
369  MuonRecHitContainer seedSegments;
370  seedSegments.push_back(*iter);
371  complete(seedSegments, list2, ME2);
372  complete(seedSegments, list3, ME3);
373  complete(seedSegments, list4, ME4);
374  complete(seedSegments, list5, ME5);
375  complete(seedSegments, mb3, MB3);
376  complete(seedSegments, mb2, MB2);
377  complete(seedSegments, mb1, MB1);
378  if(check(seedSegments)) patterns.push_back(seedSegments);
379  }
380 
381 
382  unsigned int counter;
383 
384  for ( counter = 0; counter<list2.size(); counter++ ){
385 
386  if ( !ME2[counter] ) {
387  MuonRecHitContainer seedSegments;
388  seedSegments.push_back(list2[counter]);
389  complete(seedSegments, list3, ME3);
390  complete(seedSegments, list4, ME4);
391  complete(seedSegments, list5, ME5);
392  complete(seedSegments, mb3, MB3);
393  complete(seedSegments, mb2, MB2);
394  complete(seedSegments, mb1, MB1);
395  if(check(seedSegments)) patterns.push_back(seedSegments);
396  }
397  }
398 
399 
400  if ( list3.size() < 20 ) { // +v
401  for ( counter = 0; counter<list3.size(); counter++ ){
402  if ( !ME3[counter] ) {
403  MuonRecHitContainer seedSegments;
404  seedSegments.push_back(list3[counter]);
405  complete(seedSegments, list4, ME4);
406  complete(seedSegments, list5, ME5);
407  complete(seedSegments, mb3, MB3);
408  complete(seedSegments, mb2, MB2);
409  complete(seedSegments, mb1, MB1);
410  if(check(seedSegments)) patterns.push_back(seedSegments);
411  }
412  }
413  }
414 
415  if ( list4.size() < 20 ) { // +v
416  for ( counter = 0; counter<list4.size(); counter++ ){
417  if ( !ME4[counter] ) {
418  MuonRecHitContainer seedSegments;
419  seedSegments.push_back(list4[counter]);
420  complete(seedSegments, list5, ME5);
421  complete(seedSegments, mb3, MB3);
422  complete(seedSegments, mb2, MB2);
423  complete(seedSegments, mb1, MB1);
424  if(check(seedSegments)) patterns.push_back(seedSegments);
425  }
426  }
427  }
428 
429  if ( ME5 ) delete [] ME5;
430  if ( ME4 ) delete [] ME4;
431  if ( ME3 ) delete [] ME3;
432  if ( ME2 ) delete [] ME2;
433 
434  if(!patterns.empty())
435  {
436  result.insert(result.end(), patterns.begin(), patterns.end());
437  }
438  else
439  {
440  if(!crackSegments.empty())
441  {
442  // make some single-segment seeds
443  for(MuonRecHitContainer::const_iterator crackSegmentItr = crackSegments.begin();
444  crackSegmentItr != crackSegments.end(); ++crackSegmentItr)
445  {
446  MuonRecHitContainer singleSegmentPattern;
447  singleSegmentPattern.push_back(*crackSegmentItr);
448  result.push_back(singleSegmentPattern);
449  }
450  }
451  }
452 }
453 
454 
455 
457  const MuonRecHitContainer &recHits, bool* used) const {
458 
459  MuonRecHitContainer good_rhit;
460  MuonPatternRecoDumper theDumper;
461  //+v get all rhits compatible with the seed on dEta/dPhi Glob.
462 
463  ConstMuonRecHitPointer first = seedSegments[0]; // first rechit of seed
464 
465  GlobalPoint ptg2 = first->globalPosition(); // its global pos +v
466 
467  for (unsigned nr = 0; nr < recHits.size(); ++nr ){
468  MuonRecHitPointer recHit(recHits[nr]);
469  GlobalPoint ptg1(recHit->globalPosition());
470  float deta = fabs (ptg1.eta()-ptg2.eta());
471  // Geom::Phi should keep it in the range [-pi, pi]
472  float dphi = fabs( deltaPhi(ptg1.phi(), ptg2.phi()) );
473  // be a little more lenient in cracks
474  bool crack = isCrack(recHit) || isCrack(first);
475  //float detaWindow = 0.3;
476  float detaWindow = crack ? 0.25 : 0.2;
477  if ( deta > detaWindow || dphi > .25 ) {
478  continue;
479  } // +vvp!!!
480 
481  good_rhit.push_back(recHit);
482  if (used) markAsUsed(nr, recHits, used);
483  } // recHits iter
484 
485  // select the best rhit among the compatible ones (based on Dphi Glob & Dir)
486  MuonRecHitPointer best=bestMatch(first, good_rhit);
487  if(best && best->isValid() ) seedSegments.push_back(best);
488 }
489 
490 
491 
494  MuonRecHitContainer & good_rhit) const
495 {
496  MuonRecHitPointer best = 0;
497  if(good_rhit.size() == 1) return good_rhit[0];
498  double bestDiscrim = 10000.;
499  for (MuonRecHitContainer::iterator iter=good_rhit.begin();
500  iter!=good_rhit.end(); iter++)
501  {
502  double discrim = discriminator(first, *iter);
503  if(discrim < bestDiscrim)
504  {
505  bestDiscrim = discrim;
506  best = *iter;
507  }
508  }
509  return best;
510 }
511 
512 
514 {
515  GlobalPoint gp1= first->globalPosition();
516  GlobalPoint gp2= other->globalPosition();
517  GlobalVector gd1 = first->globalDirection();
518  GlobalVector gd2 = other->globalDirection();
519  if(first->isDT() || other->isDT()) {
520  return fabs(deltaPhi(gd1.phi(), gd2.phi()));
521  }
522 
523  // penalize those 3-hit segments
524  int nhits = other->recHits().size();
525  int penalty = std::max(nhits-2, 1);
526  float dphig = deltaPhi(gp1.phi(), gp2.phi());
527  // ME1A has slanted wires, so matching theta position doesn't work well.
528  if(isME1A(first) || isME1A(other)) {
529  return fabs(dphig/penalty);
530  }
531 
532  float dthetag = gp1.theta()-gp2.theta();
533  float dphid2 = fabs(deltaPhi(gd2.phi(), gp2.phi()));
534  if (dphid2 > M_PI*.5) dphid2 = M_PI - dphid2; //+v
535  float dthetad2 = gp2.theta()-gd2.theta();
536  // for CSC, make a big chi-squared of relevant variables
537  // FIXME for 100 GeV mnd above muons, this doesn't perform as well as
538  // previous methods. needs investigation.
539  float chisq = ((dphig/0.02)*(dphig/0.02)
540  + (dthetag/0.003)*(dthetag/0.003)
541  + (dphid2/0.06)*(dphid2/0.06)
542  + (dthetad2/0.08)*(dthetad2/0.08)
543  );
544  return chisq / penalty;
545 }
546 
547 
549 {
550  return (segments.size() > 1);
551 }
552 
553 
554 void MuonSeedOrcaPatternRecognition::markAsUsed(int nr, const MuonRecHitContainer &recHits, bool* used) const
555 {
556  used[nr] = true;
557  // if it's ME1A with two other segments in the container, mark the ghosts as used, too.
558  if(recHits[nr]->isCSC())
559  {
560  CSCDetId detId(recHits[nr]->geographicalId().rawId());
561  if(detId.ring() == 4)
562  {
563  std::vector<unsigned> chamberHitNs;
564  for(unsigned i = 0; i < recHits.size(); ++i)
565  {
566  if(recHits[i]->geographicalId().rawId() == detId.rawId())
567  {
568  chamberHitNs.push_back(i);
569  }
570  }
571  if(chamberHitNs.size() == 3)
572  {
573  for(unsigned i = 0; i < 3; ++i)
574  {
575  used[chamberHitNs[i]] = true;
576  }
577  }
578  }
579  }
580 }
581 
582 
584 {
585  bool result = false;
586  double absEta = fabs(segment->globalPosition().eta());
587  for(std::vector<double>::const_iterator crackItr = theCrackEtas.begin();
588  crackItr != theCrackEtas.end(); ++crackItr)
589  {
590  if(fabs(absEta-*crackItr) < theCrackWindow) {
591  result = true;
592  }
593  }
594  return result;
595 }
596 
597 
599  MuonRecHitContainer & crackSegments) const
600 {
601  for(MuonRecHitContainer::const_iterator segmentItr = segments.begin();
602  segmentItr != segments.end(); ++segmentItr)
603  {
604  if((**segmentItr).hit()->dimension() == 4 && isCrack(*segmentItr))
605  {
606  crackSegments.push_back(*segmentItr);
607  }
608  }
609 }
610 
611 
612 
613 void MuonSeedOrcaPatternRecognition::dumpLayer(const char * name, const MuonRecHitContainer & segments) const
614 {
615  MuonPatternRecoDumper theDumper;
616 
617  LogTrace(metname) << name << std::endl;
618  for(MuonRecHitContainer::const_iterator segmentItr = segments.begin();
619  segmentItr != segments.end(); ++segmentItr)
620  {
621  LogTrace(metname) << theDumper.dumpMuonId((**segmentItr).geographicalId());
622  }
623 }
624 
625 
628 {
629 MuonPatternRecoDumper theDumper;
631  for(MuonRecHitContainer::const_iterator segmentItr = segments.begin();
632  segmentItr != segments.end(); ++segmentItr)
633  {
634  double dtheta = (*segmentItr)->globalDirection().theta() - (*segmentItr)->globalPosition().theta();
635  if((*segmentItr)->isDT())
636  {
637  // only apply the cut to 4D segments
638  if((*segmentItr)->dimension() == 2 || fabs(dtheta) < dThetaCut)
639  {
640  result.push_back(*segmentItr);
641  }
642  else
643  {
644  LogTrace(metname) << "Cutting segment " << theDumper.dumpMuonId((**segmentItr).geographicalId()) << " because dtheta = " << dtheta;
645  }
646 
647  }
648  else if((*segmentItr)->isCSC())
649  {
650  if(fabs(dtheta) < dThetaCut)
651  {
652  result.push_back(*segmentItr);
653  }
654  else
655  {
656  LogTrace(metname) << "Cutting segment " << theDumper.dumpMuonId((**segmentItr).geographicalId()) << " because dtheta = " << dtheta;
657  }
658  }
659  }
661  return result;
662 }
663 
664 
666 {
667  if(segments.empty()) return;
668  MuonPatternRecoDumper theDumper;
669  // need to optimize cuts
670  double dphiCut = 0.05;
671  double detaCut = 0.05;
672  std::vector<unsigned> toKill;
673  std::vector<unsigned> me1aOverlaps;
674  // loop over all segment pairs to see if there are two that match up in eta and phi
675  // but from different chambers
676  unsigned nseg = segments.size();
677  for(unsigned i = 0; i < nseg-1; ++i)
678  {
679  GlobalPoint pg1 = segments[i]->globalPosition();
680  for(unsigned j = i+1; j < nseg; ++j)
681  {
682  GlobalPoint pg2 = segments[j]->globalPosition();
683  if(segments[i]->geographicalId().rawId() != segments[j]->geographicalId().rawId()
684  && fabs(deltaPhi(pg1.phi(), pg2.phi())) < dphiCut
685  && fabs(pg1.eta()-pg2.eta()) < detaCut)
686  {
687  LogTrace(metname) << "OVERLAP " << theDumper.dumpMuonId(segments[i]->geographicalId()) << " " <<
688  theDumper.dumpMuonId(segments[j]->geographicalId());
689  // see which one is best
690  toKill.push_back( (countHits(segments[i]) < countHits(segments[j])) ? i : j);
691  if(isME1A(segments[i]))
692  {
693  me1aOverlaps.push_back(i);
694  me1aOverlaps.push_back(j);
695  }
696  }
697  }
698  }
699 
700  if(toKill.empty()) return;
701 
702  // try to kill ghosts assigned to overlaps
703  for(unsigned i = 0; i < me1aOverlaps.size(); ++i)
704  {
705  DetId detId(segments[me1aOverlaps[i]]->geographicalId());
706  vector<unsigned> inSameChamber;
707  for(unsigned j = 0; j < nseg; ++j)
708  {
709  if(i != j && segments[j]->geographicalId() == detId)
710  {
711  inSameChamber.push_back(j);
712  }
713  }
714  if(inSameChamber.size() == 2)
715  {
716  toKill.push_back(inSameChamber[0]);
717  toKill.push_back(inSameChamber[1]);
718  }
719  }
720  // now kill the killable
722  for(unsigned i = 0; i < nseg; ++i)
723  {
724  if(std::find(toKill.begin(), toKill.end(), i) == toKill.end())
725  {
726  result.push_back(segments[i]);
727  }
728 
729  }
730  segments.swap(result);
731 }
732 
733 
735 {
736  return segment->isCSC() && CSCDetId(segment->geographicalId()).ring() == 4;
737 }
738 
739 
741  int count = 0;
742  vector<TrackingRecHit*> components = (*segment).recHits();
743  for(vector<TrackingRecHit*>::const_iterator component = components.begin();
744  component != components.end(); ++component)
745  {
746  int componentSize = (**component).recHits().size();
747  count += (componentSize == 0) ? 1 : componentSize;
748  }
749  return count;
750 }
751 
752 
int i
Definition: DBlmapReader.cc:9
MuonRecHitPointer bestMatch(const ConstMuonRecHitPointer &first, MuonRecHitContainer &good_rhit) const
const std::string metname
void filterOverlappingChambers(MuonRecHitContainer &segments) const
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
bool isCrack(const ConstMuonRecHitPointer &segment) const
bool check(const MuonRecHitContainer &segments)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::string dumpMuonId(const DetId &id) const
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
bool enableCSCMeasurement
Enable the CSC measurement.
int countHits(const MuonRecHitPointer &segment) const
const T & max(const T &a, const T &b)
void produce(const edm::Event &event, const edm::EventSetup &eSetup, std::vector< MuonRecHitContainer > &result)
void endcapPatterns(const MuonRecHitContainer &me11, const MuonRecHitContainer &me12, const MuonRecHitContainer &me2, const MuonRecHitContainer &me3, const MuonRecHitContainer &me4, const MuonRecHitContainer &mb1, const MuonRecHitContainer &mb2, const MuonRecHitContainer &mb3, bool *MB1, bool *MB2, bool *MB3, std::vector< MuonRecHitContainer > &result)
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
MuonSeedOrcaPatternRecognition(const edm::ParameterSet &pset)
void rememberCrackSegments(const MuonRecHitContainer &segments, MuonRecHitContainer &crackSegments) const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool first
Definition: L1TdeRCT.cc:94
#define LogTrace(id)
int ring() const
Definition: CSCDetId.h:77
Definition: DetId.h:20
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
#define M_PI
Definition: BFit3D.cc:3
bool isME1A(const ConstMuonRecHitPointer &segment) const
void complete(MuonRecHitContainer &seedSegments, const MuonRecHitContainer &recHits, bool *used=0) const
const T & get() const
Definition: EventSetup.h:55
std::string const & label() const
Definition: InputTag.h:42
T eta() const
Definition: PV3DBase.h:76
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void markAsUsed(int nr, const MuonRecHitContainer &recHits, bool *used) const
bool enableDTMeasurement
Enable the DT measurement.
void dumpLayer(const char *name, const MuonRecHitContainer &segments) const
double discriminator(const ConstMuonRecHitPointer &first, MuonRecHitPointer &other) const
edm::InputTag theCSCRecSegmentLabel
the name of the CSC rec hits collection
edm::InputTag theDTRecSegmentLabel
the name of the DT rec hits collection
MuonRecHitContainer filterSegments(const MuonRecHitContainer &segments, double dThetaCut) const
apply some cuts to segments before using them