CMS 3D CMS Logo

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