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