CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
- 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 &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
 

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...
 
edm::InputTag theCSCRecSegmentLabel
 the name of the CSC rec hits collection More...
 
edm::InputTag theDTRecSegmentLabel
 the name of the DT rec hits collection More...
 

Detailed Description

Definition at line 9 of file MuonSeedOrcaPatternRecognition.h.

Constructor & Destructor Documentation

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

Definition at line 47 of file MuonSeedOrcaPatternRecognition.cc.

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

49  theCrackEtas(pset.getParameter<std::vector<double> >("crackEtas")),
50  theCrackWindow(pset.getParameter<double>("crackWindow"))
51 {
53  iC,
55 }
T getParameter(std::string const &) const
bool enableCSCMeasurement
Enable the CSC measurement.
MuonSeedVPatternRecognition(const edm::ParameterSet &pset)
std::string const & label() const
Definition: InputTag.h:42
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 492 of file MuonSeedOrcaPatternRecognition.cc.

References discriminator().

Referenced by complete().

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

Definition at line 547 of file MuonSeedOrcaPatternRecognition.cc.

Referenced by endcapPatterns(), and produce().

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

Definition at line 455 of file MuonSeedOrcaPatternRecognition.cc.

References bestMatch(), SiPixelRawToDigiRegional_cfi::deltaPhi, PV3DBase< T, PVType, FrameType >::eta(), first, isCrack(), markAsUsed(), and PV3DBase< T, PVType, FrameType >::phi().

Referenced by endcapPatterns(), and produce().

456  {
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 }
MuonRecHitPointer bestMatch(const ConstMuonRecHitPointer &first, MuonRecHitContainer &good_rhit) const
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
bool isCrack(const ConstMuonRecHitPointer &segment) const
bool first
Definition: L1TdeRCT.cc:79
T eta() const
Definition: PV3DBase.h:76
void markAsUsed(int nr, const MuonRecHitContainer &recHits, bool *used) const
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
int MuonSeedOrcaPatternRecognition::countHits ( const MuonRecHitPointer segment) const
private

Definition at line 739 of file MuonSeedOrcaPatternRecognition.cc.

References makeMuonMisalignmentScenario::components, and prof2calltree::count.

Referenced by filterOverlappingChambers().

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

Definition at line 512 of file MuonSeedOrcaPatternRecognition.cc.

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

Referenced by bestMatch().

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 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
const T & max(const T &a, const T &b)
#define M_PI
Definition: BFit3D.cc:3
bool isME1A(const ConstMuonRecHitPointer &segment) const
void MuonSeedOrcaPatternRecognition::dumpLayer ( const char *  name,
const MuonRecHitContainer segments 
) const
private

Definition at line 612 of file MuonSeedOrcaPatternRecognition.cc.

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

Referenced by endcapPatterns(), and produce().

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 }
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 mb1,
const MuonRecHitContainer mb2,
const MuonRecHitContainer mb3,
bool *  MB1,
bool *  MB2,
bool *  MB3,
std::vector< MuonRecHitContainer > &  result 
)
private

Definition at line 272 of file MuonSeedOrcaPatternRecognition.cc.

References check(), complete(), counter, dumpLayer(), rememberCrackSegments(), and zero().

Referenced by produce().

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 }
bool check(const MuonRecHitContainer &segments)
tuple result
Definition: query.py:137
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 664 of file MuonSeedOrcaPatternRecognition.cc.

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

Referenced by filterSegments().

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 }
int i
Definition: DBlmapReader.cc:9
const std::string metname
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::string dumpMuonId(const DetId &id) const
int countHits(const MuonRecHitPointer &segment) const
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
#define LogTrace(id)
Definition: DetId.h:18
bool isME1A(const ConstMuonRecHitPointer &segment) const
T eta() const
Definition: PV3DBase.h:76
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 626 of file MuonSeedOrcaPatternRecognition.cc.

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

Referenced by produce().

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 }
const std::string metname
void filterOverlappingChambers(MuonRecHitContainer &segments) const
std::string dumpMuonId(const DetId &id) const
tuple result
Definition: query.py:137
#define LogTrace(id)
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
bool MuonSeedOrcaPatternRecognition::isCrack ( const ConstMuonRecHitPointer segment) const
private

Definition at line 582 of file MuonSeedOrcaPatternRecognition.cc.

References query::result, theCrackEtas, and theCrackWindow.

Referenced by complete(), and rememberCrackSegments().

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 }
tuple result
Definition: query.py:137
bool MuonSeedOrcaPatternRecognition::isME1A ( const ConstMuonRecHitPointer segment) const
private

Definition at line 733 of file MuonSeedOrcaPatternRecognition.cc.

References CSCDetId, and relativeConstraints::ring.

Referenced by discriminator(), and filterOverlappingChambers().

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

Definition at line 553 of file MuonSeedOrcaPatternRecognition.cc.

References i, DetId::rawId(), and CSCDetId::ring().

Referenced by complete().

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 }
int i
Definition: DBlmapReader.cc:9
void MuonSeedOrcaPatternRecognition::produce ( const edm::Event event,
const edm::EventSetup eSetup,
std::vector< MuonRecHitContainer > &  result 
)
virtual

Implements MuonSeedVPatternRecognition.

Definition at line 59 of file MuonSeedOrcaPatternRecognition.cc.

References cond::ecalcond::all, check(), complete(), filterCSVwithJSON::copy, counter, dumpLayer(), endcapPatterns(), filterSegments(), edm::EventSetup::get(), LogTrace, metname, muonMeasurements, MuonDetLayerMeasurements::recHits(), tmp, and zero().

61 {
62  // divide the RecHits by DetLayer, in order to fill the
63  // RecHitContainer like it was in ORCA
64 
65  // Muon Geometry - DT, CSC and RPC
67  eSetup.get<MuonRecoGeometryRecord>().get(muonLayers);
68 
69  // get the DT layers
70  vector<DetLayer*> dtLayers = muonLayers->allDTLayers();
71 
72  // get the CSC layers
73  vector<DetLayer*> cscForwardLayers = muonLayers->forwardCSCLayers();
74  vector<DetLayer*> cscBackwardLayers = muonLayers->backwardCSCLayers();
75 
76  // Backward (z<0) EndCap disk
77  const DetLayer* ME4Bwd = cscBackwardLayers[4];
78  const DetLayer* ME3Bwd = cscBackwardLayers[3];
79  const DetLayer* ME2Bwd = cscBackwardLayers[2];
80  const DetLayer* ME12Bwd = cscBackwardLayers[1];
81  const DetLayer* ME11Bwd = cscBackwardLayers[0];
82 
83  // Forward (z>0) EndCap disk
84  const DetLayer* ME11Fwd = cscForwardLayers[0];
85  const DetLayer* ME12Fwd = cscForwardLayers[1];
86  const DetLayer* ME2Fwd = cscForwardLayers[2];
87  const DetLayer* ME3Fwd = cscForwardLayers[3];
88  const DetLayer* ME4Fwd = cscForwardLayers[4];
89 
90  // barrel
91  const DetLayer* MB4DL = dtLayers[3];
92  const DetLayer* MB3DL = dtLayers[2];
93  const DetLayer* MB2DL = dtLayers[1];
94  const DetLayer* MB1DL = dtLayers[0];
95 
96  // instantiate the accessor
97  // Don not use RPC for seeding
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 }
const std::string metname
bool check(const MuonRecHitContainer &segments)
MuonRecHitContainer recHits(const DetLayer *layer, const edm::Event &iEvent)
returns the rechits which are on the layer
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
#define LogTrace(id)
void complete(MuonRecHitContainer &seedSegments, const MuonRecHitContainer &recHits, bool *used=0) const
const T & get() const
Definition: EventSetup.h:55
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
static std::atomic< unsigned int > counter
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
void dumpLayer(const char *name, const MuonRecHitContainer &segments) const
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 597 of file MuonSeedOrcaPatternRecognition.cc.

References isCrack().

Referenced by endcapPatterns().

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 }
bool isCrack(const ConstMuonRecHitPointer &segment) const
bool * MuonSeedOrcaPatternRecognition::zero ( unsigned  listSize)
private

Definition at line 261 of file MuonSeedOrcaPatternRecognition.cc.

References i, and query::result.

Referenced by endcapPatterns(), and produce().

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 }
int i
Definition: DBlmapReader.cc:9
tuple result
Definition: query.py:137

Member Data Documentation

MuonDetLayerMeasurements* MuonSeedOrcaPatternRecognition::muonMeasurements
private

Definition at line 56 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().