CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuonSeedOrcaPatternRecognition Class Reference

#include <MuonSeedOrcaPatternRecognition.h>

Inheritance diagram for MuonSeedOrcaPatternRecognition:
MuonSeedVPatternRecognition

Public Member Functions

 MuonSeedOrcaPatternRecognition (const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
 
void produce (const edm::Event &event, const edm::EventSetup &eSetup, std::vector< MuonRecHitContainer > &result) override
 
- Public Member Functions inherited from MuonSeedVPatternRecognition
 MuonSeedVPatternRecognition (const edm::ParameterSet &pset)
 
virtual ~MuonSeedVPatternRecognition ()
 

Private Member Functions

MuonRecHitPointer bestMatch (const ConstMuonRecHitPointer &first, MuonRecHitContainer &good_rhit) const
 
bool check (const MuonRecHitContainer &segments)
 
void complete (MuonRecHitContainer &seedSegments, const MuonRecHitContainer &recHits, bool *used=0) const
 
int countHits (const MuonRecHitPointer &segment) const
 
double discriminator (const ConstMuonRecHitPointer &first, MuonRecHitPointer &other) const
 
void dumpLayer (const char *name, const MuonRecHitContainer &segments) const
 
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)
 
void filterOverlappingChambers (MuonRecHitContainer &segments) const
 
MuonRecHitContainer filterSegments (const MuonRecHitContainer &segments, double dThetaCut) const
 apply some cuts to segments before using them More...
 
bool isCrack (const ConstMuonRecHitPointer &segment) const
 
bool isME1A (const ConstMuonRecHitPointer &segment) const
 
void markAsUsed (int nr, const MuonRecHitContainer &recHits, bool *used) const
 
void rememberCrackSegments (const MuonRecHitContainer &segments, MuonRecHitContainer &crackSegments) const
 
bool * zero (unsigned listSize)
 

Private Attributes

MuonDetLayerMeasurementsmuonMeasurements
 
std::vector< double > theCrackEtas
 
double theCrackWindow
 
double theDeltaCrackWindow
 
double theDeltaEtaWindow
 
double theDeltaPhiWindow
 

Additional Inherited Members

- Public Types inherited from MuonSeedVPatternRecognition
typedef MuonTransientTrackingRecHit::ConstMuonRecHitPointer ConstMuonRecHitPointer
 
typedef MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
 
typedef MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer
 
- Protected Attributes inherited from MuonSeedVPatternRecognition
bool enableCSCMeasurement
 Enable the CSC measurement. More...
 
bool enableDTMeasurement
 Enable the DT measurement. More...
 
bool enableME0Measurement
 Enable the ME0 measurement. More...
 
edm::InputTag theCSCRecSegmentLabel
 the name of the CSC rec hits collection More...
 
edm::InputTag theDTRecSegmentLabel
 the name of the DT rec hits collection More...
 
edm::InputTag theME0RecSegmentLabel
 the name of the ME0 rec hits collection More...
 

Detailed Description

Definition at line 8 of file MuonSeedOrcaPatternRecognition.h.

Constructor & Destructor Documentation

MuonSeedOrcaPatternRecognition::MuonSeedOrcaPatternRecognition ( const edm::ParameterSet pset,
edm::ConsumesCollector iC 
)
explicit

Definition at line 46 of file MuonSeedOrcaPatternRecognition.cc.

References MuonSeedVPatternRecognition::enableCSCMeasurement, MuonSeedVPatternRecognition::enableDTMeasurement, MuonSeedVPatternRecognition::enableME0Measurement, HLT_2018_cff::InputTag, edm::InputTag::label(), muonMeasurements, MuonSeedVPatternRecognition::theCSCRecSegmentLabel, MuonSeedVPatternRecognition::theDTRecSegmentLabel, and MuonSeedVPatternRecognition::theME0RecSegmentLabel.

49  theCrackEtas(pset.getParameter<std::vector<double> >("crackEtas")),
50  theCrackWindow(pset.getParameter<double>("crackWindow")),
52  pset.existsAs<double>("deltaPhiSearchWindow") ? pset.getParameter<double>("deltaPhiSearchWindow") : 0.25),
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 }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:160
bool enableME0Measurement
Enable the ME0 measurement.
bool enableCSCMeasurement
Enable the CSC measurement.
MuonSeedVPatternRecognition(const edm::ParameterSet &pset)
edm::InputTag theME0RecSegmentLabel
the name of the ME0 rec hits collection
std::string const & label() const
Definition: InputTag.h:36
bool enableDTMeasurement
Enable the DT measurement.
edm::InputTag theCSCRecSegmentLabel
the name of the CSC rec hits collection
edm::InputTag theDTRecSegmentLabel
the name of the DT rec hits collection

Member Function Documentation

MuonSeedOrcaPatternRecognition::MuonRecHitPointer MuonSeedOrcaPatternRecognition::bestMatch ( const ConstMuonRecHitPointer first,
MuonRecHitContainer good_rhit 
) const
private

Definition at line 556 of file MuonSeedOrcaPatternRecognition.cc.

References discriminator().

Referenced by complete().

557  {
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 }
MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer
double discriminator(const ConstMuonRecHitPointer &first, MuonRecHitPointer &other) const
bool MuonSeedOrcaPatternRecognition::check ( const MuonRecHitContainer segments)
private

Definition at line 604 of file MuonSeedOrcaPatternRecognition.cc.

Referenced by endcapPatterns(), and produce().

604 { return (segments.size() > 1); }
void MuonSeedOrcaPatternRecognition::complete ( MuonRecHitContainer seedSegments,
const MuonRecHitContainer recHits,
bool *  used = 0 
) const
private

Definition at line 523 of file MuonSeedOrcaPatternRecognition.cc.

References PV3DBase< T, PVType, FrameType >::barePhi(), bestMatch(), SiPixelRawToDigiRegional_cfi::deltaPhi, PV3DBase< T, PVType, FrameType >::eta(), dqmdumpme::first, isCrack(), markAsUsed(), EgHLTOffHistBins_cfi::nr, rpcPointValidation_cfi::recHit, theDeltaCrackWindow, theDeltaEtaWindow, and theDeltaPhiWindow.

Referenced by endcapPatterns(), and produce().

525  {
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 }
MuonRecHitPointer bestMatch(const ConstMuonRecHitPointer &first, MuonRecHitContainer &good_rhit) const
MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer
bool isCrack(const ConstMuonRecHitPointer &segment) const
T barePhi() const
Definition: PV3DBase.h:65
T eta() const
Definition: PV3DBase.h:73
void markAsUsed(int nr, const MuonRecHitContainer &recHits, bool *used) const
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
MuonTransientTrackingRecHit::ConstMuonRecHitPointer ConstMuonRecHitPointer
int MuonSeedOrcaPatternRecognition::countHits ( const MuonRecHitPointer segment) const
private

Definition at line 757 of file MuonSeedOrcaPatternRecognition.cc.

References makeMuonMisalignmentScenario::components, and KineDebug3::count().

Referenced by filterOverlappingChambers().

757  {
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 }
double MuonSeedOrcaPatternRecognition::discriminator ( const ConstMuonRecHitPointer first,
MuonRecHitPointer other 
) const
private

Definition at line 572 of file MuonSeedOrcaPatternRecognition.cc.

References PV3DBase< T, PVType, FrameType >::barePhi(), SiPixelRawToDigiRegional_cfi::deltaPhi, isME1A(), M_PI, SiStripPI::max, nhits, and PV3DBase< T, PVType, FrameType >::theta().

Referenced by bestMatch().

573  {
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 }
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
T barePhi() const
Definition: PV3DBase.h:65
#define M_PI
bool isME1A(const ConstMuonRecHitPointer &segment) const
void MuonSeedOrcaPatternRecognition::dumpLayer ( const char *  name,
const MuonRecHitContainer segments 
) const
private

Definition at line 652 of file MuonSeedOrcaPatternRecognition.cc.

References MuonPatternRecoDumper::dumpMuonId(), LogTrace, and metname.

Referenced by endcapPatterns(), and produce().

652  {
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 }
const std::string metname
std::string dumpMuonId(const DetId &id) const
#define LogTrace(id)
void MuonSeedOrcaPatternRecognition::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 
)
private

Definition at line 315 of file MuonSeedOrcaPatternRecognition.cc.

References check(), complete(), filterCSVwithJSON::copy, counter, dumpLayer(), hlt_dqm_clientPB-live_cfg::me2, rememberCrackSegments(), and zero().

Referenced by produce().

327  {
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 }
bool check(const MuonRecHitContainer &segments)
void rememberCrackSegments(const MuonRecHitContainer &segments, MuonRecHitContainer &crackSegments) const
void complete(MuonRecHitContainer &seedSegments, const MuonRecHitContainer &recHits, bool *used=0) const
static std::atomic< unsigned int > counter
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
void dumpLayer(const char *name, const MuonRecHitContainer &segments) const
void MuonSeedOrcaPatternRecognition::filterOverlappingChambers ( MuonRecHitContainer segments) const
private

Definition at line 696 of file MuonSeedOrcaPatternRecognition.cc.

References PV3DBase< T, PVType, FrameType >::barePhi(), countHits(), SiPixelRawToDigiRegional_cfi::deltaPhi, MuonPatternRecoDumper::dumpMuonId(), PV3DBase< T, PVType, FrameType >::eta(), spr::find(), mps_fire::i, isME1A(), dqmiolumiharvest::j, LogTrace, metname, and mps_fire::result.

Referenced by filterSegments().

696  {
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 }
const std::string metname
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::string dumpMuonId(const DetId &id) const
T barePhi() const
Definition: PV3DBase.h:65
int countHits(const MuonRecHitPointer &segment) const
#define LogTrace(id)
Definition: DetId.h:17
bool isME1A(const ConstMuonRecHitPointer &segment) const
T eta() const
Definition: PV3DBase.h:73
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
MuonSeedOrcaPatternRecognition::MuonRecHitContainer MuonSeedOrcaPatternRecognition::filterSegments ( const MuonRecHitContainer segments,
double  dThetaCut 
) const
private

apply some cuts to segments before using them

Definition at line 661 of file MuonSeedOrcaPatternRecognition.cc.

References MuonPatternRecoDumper::dumpMuonId(), filterOverlappingChambers(), LogTrace, metname, and mps_fire::result.

Referenced by produce().

662  {
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 }
const std::string metname
void filterOverlappingChambers(MuonRecHitContainer &segments) const
std::string dumpMuonId(const DetId &id) const
#define LogTrace(id)
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
bool MuonSeedOrcaPatternRecognition::isCrack ( const ConstMuonRecHitPointer segment) const
private

Definition at line 627 of file MuonSeedOrcaPatternRecognition.cc.

References mps_fire::result, theCrackEtas, and theCrackWindow.

Referenced by complete(), and rememberCrackSegments().

627  {
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 }
bool MuonSeedOrcaPatternRecognition::isME1A ( const ConstMuonRecHitPointer segment) const
private

Definition at line 753 of file MuonSeedOrcaPatternRecognition.cc.

References relativeConstraints::ring.

Referenced by discriminator(), and filterOverlappingChambers().

753  {
754  return segment->isCSC() && CSCDetId(segment->geographicalId()).ring() == 4;
755 }
void MuonSeedOrcaPatternRecognition::markAsUsed ( int  nr,
const MuonRecHitContainer recHits,
bool *  used 
) const
private

Definition at line 606 of file MuonSeedOrcaPatternRecognition.cc.

References mps_fire::i, GeomDetEnumerators::isCSC(), EgHLTOffHistBins_cfi::nr, DetId::rawId(), and CSCDetId::ring().

Referenced by complete().

606  {
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 }
bool isCSC(GeomDetEnumerators::SubDetector m)
void MuonSeedOrcaPatternRecognition::produce ( const edm::Event event,
const edm::EventSetup eSetup,
std::vector< MuonRecHitContainer > &  result 
)
overridevirtual

Implements MuonSeedVPatternRecognition.

Definition at line 72 of file MuonSeedOrcaPatternRecognition.cc.

References Vispa.Plugins.EdmBrowser.EdmDataAccessor::all(), MuonDetLayerGeometry::allDTLayers(), MuonDetLayerGeometry::backwardCSCLayers(), MuonDetLayerGeometry::backwardME0Layers(), check(), complete(), filterCSVwithJSON::copy, dumpLayer(), endcapPatterns(), filterSegments(), MuonDetLayerGeometry::forwardCSCLayers(), MuonDetLayerGeometry::forwardME0Layers(), edm::EventSetup::get(), LogTrace, metname, muonMeasurements, MuonDetLayerMeasurements::recHits(), createJobs::tmp, and zero().

74  {
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 }
const std::string metname
bool check(const MuonRecHitContainer &segments)
const std::vector< const DetLayer * > & forwardME0Layers() const
return the forward (+Z) ME0 DetLayers, inside-out
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)
MuonRecHitContainer recHits(const DetLayer *layer, const edm::Event &iEvent)
returns the rechits which are on the layer
#define LogTrace(id)
const std::vector< const DetLayer * > & allDTLayers() const
return the DT DetLayers (barrel), inside-out
const std::vector< const DetLayer * > & backwardME0Layers() const
return the backward (-Z) ME0 DetLayers, inside-out
void complete(MuonRecHitContainer &seedSegments, const MuonRecHitContainer &recHits, bool *used=0) const
const std::vector< const DetLayer * > & forwardCSCLayers() const
return the forward (+Z) CSC DetLayers, inside-out
T get() const
Definition: EventSetup.h:73
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
const std::vector< const DetLayer * > & backwardCSCLayers() const
return the backward (-Z) CSC DetLayers, inside-out
void dumpLayer(const char *name, const MuonRecHitContainer &segments) const
tmp
align.sh
Definition: createJobs.py:716
MuonRecHitContainer filterSegments(const MuonRecHitContainer &segments, double dThetaCut) const
apply some cuts to segments before using them
void MuonSeedOrcaPatternRecognition::rememberCrackSegments ( const MuonRecHitContainer segments,
MuonRecHitContainer crackSegments 
) const
private

Definition at line 639 of file MuonSeedOrcaPatternRecognition.cc.

References funct::abs(), and isCrack().

Referenced by endcapPatterns().

640  {
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 }
bool isCrack(const ConstMuonRecHitPointer &segment) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool * MuonSeedOrcaPatternRecognition::zero ( unsigned  listSize)
private

Definition at line 305 of file MuonSeedOrcaPatternRecognition.cc.

References mps_fire::i, and mps_fire::result.

Referenced by endcapPatterns(), and produce().

305  {
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 }

Member Data Documentation

MuonDetLayerMeasurements* MuonSeedOrcaPatternRecognition::muonMeasurements
private

Definition at line 55 of file MuonSeedOrcaPatternRecognition.h.

Referenced by MuonSeedOrcaPatternRecognition(), and produce().

std::vector<double> MuonSeedOrcaPatternRecognition::theCrackEtas
private

Definition at line 53 of file MuonSeedOrcaPatternRecognition.h.

Referenced by isCrack().

double MuonSeedOrcaPatternRecognition::theCrackWindow
private

Definition at line 54 of file MuonSeedOrcaPatternRecognition.h.

Referenced by isCrack().

double MuonSeedOrcaPatternRecognition::theDeltaCrackWindow
private

Definition at line 58 of file MuonSeedOrcaPatternRecognition.h.

Referenced by complete().

double MuonSeedOrcaPatternRecognition::theDeltaEtaWindow
private

Definition at line 57 of file MuonSeedOrcaPatternRecognition.h.

Referenced by complete().

double MuonSeedOrcaPatternRecognition::theDeltaPhiWindow
private

Definition at line 56 of file MuonSeedOrcaPatternRecognition.h.

Referenced by complete().