CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
HoughGrouping Class Reference

#include <HoughGrouping.h>

Inheritance diagram for HoughGrouping:
MotherGrouping

Public Member Functions

void finish () override
 
 HoughGrouping (const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
 
void initialise (const edm::EventSetup &iEventSetup) override
 
void run (edm::Event &iEvent, const edm::EventSetup &iEventSetup, const DTDigiCollection &digis, MuonPathPtrs &outMpath) override
 
 ~HoughGrouping () override
 
- Public Member Functions inherited from MotherGrouping
 MotherGrouping (const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
 
virtual ~MotherGrouping ()
 

Private Member Functions

bool areThereEnoughHits (const ProtoCand &tupl)
 
ProtoCand associateHits (const DTChamber *thechamb, double m, double n)
 
void doHoughTransform ()
 
PointsInPlane findTheMaxima (PointTuples &inputvec)
 
PointInPlane getAveragePoint (const PointTuples &inputvec, unsigned short int firstindex, const std::vector< unsigned short int > &indexlist)
 
PointsInPlane getMaximaVector ()
 
PointInPlane getTwoDelta (const PointTuple &pair1, const PointTuple &pair2)
 
void obtainGeometricalBorders (const DTLayer *lay)
 
void orderAndFilter (std::vector< ProtoCand > &invector, MuonPathPtrs &outMuonPath)
 
void resetAttributes ()
 
void resetPosElementsOfLinespace ()
 
void setDifferenceBetweenSL (ProtoCand &tupl)
 
PointInPlane transformPair (const PointInPlane &inputpair)
 

Private Attributes

bool allowUncorrelatedPatterns_
 
unsigned short int anglebins_
 
double anglebinwidth_
 
PointMap anglemap_
 
double angletan_
 
bool debug_
 
std::map< unsigned short int,
DTPrimitive
digimap_ [8]
 
DTGeometry const * dtGeo_
 
edm::ESGetToken< DTGeometry,
MuonGeometryRecord
dtGeomH
 
unsigned short int halfanglebins_
 
PointsInPlane hitvec_
 
unsigned short int idigi_
 
std::vector< std::vector
< unsigned short int > > 
linespace_
 
unsigned short int lowerNumber_
 
double maxdeltaAng_
 
double maxdeltaAngDeg_
 
double maxdeltaPos_
 
double maxDistanceToWire_
 
PointsInPlane maxima_
 
double maxrads_
 
double minangle_
 
unsigned short int minNLayerHits_
 
unsigned short int minSingleSLHitsMax_
 
unsigned short int minSingleSLHitsMin_
 
unsigned short int minUncorrelatedHits_
 
unsigned short int nhits_
 
double oneanglebin_
 
double posbinwidth_
 
PointMap posmap_
 
unsigned short int spacebins_
 
DTChamberId TheChambId
 
unsigned short int thesector_
 
unsigned short int thestation_
 
short int thewheel_
 
unsigned short int upperNumber_
 
double xhighlim_
 
double xlowlim_
 
double zhighlim_
 
double zlowlim_
 

Detailed Description

Definition at line 35 of file HoughGrouping.h.

Constructor & Destructor Documentation

HoughGrouping::HoughGrouping ( const edm::ParameterSet pset,
edm::ConsumesCollector iC 
)

Definition at line 54 of file HoughGrouping.cc.

References allowUncorrelatedPatterns_, anglebinwidth_, angletan_, edm::BeginRun, debug_, dtGeomH, edm::ConsumesCollector::esConsumes(), edm::ParameterSet::getUntrackedParameter(), LogDebug, lowerNumber_, maxdeltaAngDeg_, maxdeltaPos_, maxDistanceToWire_, minNLayerHits_, minSingleSLHitsMax_, minSingleSLHitsMin_, minUncorrelatedHits_, posbinwidth_, and upperNumber_.

54  : MotherGrouping(pset, iC) {
55  // Obtention of parameters
56  debug_ = pset.getUntrackedParameter<bool>("debug");
57  if (debug_)
58  LogDebug("HoughGrouping") << "HoughGrouping: constructor";
59 
60  // HOUGH TRANSFORM CONFIGURATION
61  angletan_ = pset.getUntrackedParameter<double>("angletan");
62  anglebinwidth_ = pset.getUntrackedParameter<double>("anglebinwidth");
63  posbinwidth_ = pset.getUntrackedParameter<double>("posbinwidth");
64 
65  // MAXIMA SEARCH CONFIGURATION
66  maxdeltaAngDeg_ = pset.getUntrackedParameter<double>("maxdeltaAngDeg");
67  maxdeltaPos_ = pset.getUntrackedParameter<double>("maxdeltaPos");
68  upperNumber_ = (unsigned short int)pset.getUntrackedParameter<int>("UpperNumber");
69  lowerNumber_ = (unsigned short int)pset.getUntrackedParameter<int>("LowerNumber");
70 
71  // HITS ASSOCIATION CONFIGURATION
72  maxDistanceToWire_ = pset.getUntrackedParameter<double>("MaxDistanceToWire");
73 
74  // CANDIDATE QUALITY CONFIGURATION
75  minNLayerHits_ = (unsigned short int)pset.getUntrackedParameter<int>("minNLayerHits");
76  minSingleSLHitsMax_ = (unsigned short int)pset.getUntrackedParameter<int>("minSingleSLHitsMax");
77  minSingleSLHitsMin_ = (unsigned short int)pset.getUntrackedParameter<int>("minSingleSLHitsMin");
78  allowUncorrelatedPatterns_ = pset.getUntrackedParameter<bool>("allowUncorrelatedPatterns");
79  minUncorrelatedHits_ = (unsigned short int)pset.getUntrackedParameter<int>("minUncorrelatedHits");
80 
82 }
unsigned short int lowerNumber_
Definition: HoughGrouping.h:79
unsigned short int minNLayerHits_
Definition: HoughGrouping.h:79
T getUntrackedParameter(std::string const &, T const &) const
double maxdeltaAngDeg_
Definition: HoughGrouping.h:81
double maxDistanceToWire_
Definition: HoughGrouping.h:81
unsigned short int upperNumber_
Definition: HoughGrouping.h:79
unsigned short int minUncorrelatedHits_
Definition: HoughGrouping.h:79
bool allowUncorrelatedPatterns_
Definition: HoughGrouping.h:78
unsigned short int minSingleSLHitsMin_
Definition: HoughGrouping.h:79
double maxdeltaPos_
Definition: HoughGrouping.h:81
MotherGrouping(const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
double posbinwidth_
Definition: HoughGrouping.h:81
double angletan_
Definition: HoughGrouping.h:81
unsigned short int minSingleSLHitsMax_
Definition: HoughGrouping.h:79
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomH
Definition: HoughGrouping.h:84
double anglebinwidth_
Definition: HoughGrouping.h:81
#define LogDebug(id)
HoughGrouping::~HoughGrouping ( )
override

Definition at line 84 of file HoughGrouping.cc.

References debug_, and LogDebug.

84  {
85  if (debug_)
86  LogDebug("HoughGrouping") << "HoughGrouping: destructor" << endl;
87 }
#define LogDebug(id)

Member Function Documentation

bool HoughGrouping::areThereEnoughHits ( const ProtoCand tupl)
private

Definition at line 875 of file HoughGrouping.cc.

References debug_, ProtoCand::dtHits_, and LogDebug.

875  {
876  if (debug_)
877  LogDebug("HoughGrouping") << "areThereEnoughHits";
878  unsigned short int numhitssl1 = 0;
879  unsigned short int numhitssl3 = 0;
880  for (unsigned short int lay = 0; lay < 8; lay++) {
881  if ((tupl.dtHits_[lay].channelId() > 0) && (lay < 4))
882  numhitssl1++;
883  else if (tupl.dtHits_[lay].channelId() > 0)
884  numhitssl3++;
885  }
886 
887  if (debug_)
888  LogDebug("HoughGrouping") << "areThereEnoughHits - Hits in SL1: " << numhitssl1;
889  if (debug_)
890  LogDebug("HoughGrouping") << "areThereEnoughHits - Hits in SL3: " << numhitssl3;
891 
892  if ((numhitssl1 != 0) && (numhitssl3 != 0)) { // Correlated candidates
893  if ((numhitssl1 + numhitssl3) >= minNLayerHits_) {
894  if (numhitssl1 > numhitssl3) {
895  return ((numhitssl1 >= minSingleSLHitsMax_) && (numhitssl3 >= minSingleSLHitsMin_));
896  } else if (numhitssl3 > numhitssl1) {
897  return ((numhitssl3 >= minSingleSLHitsMax_) && (numhitssl1 >= minSingleSLHitsMin_));
898  } else
899  return true;
900  }
901  } else if (allowUncorrelatedPatterns_) { // Uncorrelated candidates
902  return ((numhitssl1 + numhitssl3) >= minNLayerHits_);
903  }
904  return false;
905 }
unsigned short int minNLayerHits_
Definition: HoughGrouping.h:79
DTPrimitives dtHits_
Definition: HoughGrouping.h:26
bool allowUncorrelatedPatterns_
Definition: HoughGrouping.h:78
unsigned short int minSingleSLHitsMin_
Definition: HoughGrouping.h:79
unsigned short int minSingleSLHitsMax_
Definition: HoughGrouping.h:79
#define LogDebug(id)
ProtoCand HoughGrouping::associateHits ( const DTChamber thechamb,
double  m,
double  n 
)
private

Definition at line 552 of file HoughGrouping.cc.

References funct::abs(), DTTopology::channel(), submitPVResolutionJobs::count, debug_, ProtoCand::dtHits_, DTTopology::firstChannel(), ProtoCand::isThereHitInLayer_, ProtoCand::isThereNeighBourHitInLayer_, cmsLHEtoEOSManager::l, DTSuperLayer::layer(), cmsdt::LEFT, LogDebug, dqmiodumpmetadata::n, ProtoCand::nHitsDiff_, ProtoCand::nLayersWithHits_, NONE, cmsdt::NUM_LAYERS_2SL, cmsdt::RIGHT, DTLayer::specificTopology(), DTChamber::superLayer(), GeomDet::toGlobal(), GeomDet::toLocal(), DTTopology::wirePosition(), PV3DBase< T, PVType, FrameType >::x(), ProtoCand::xDistToPattern_, and PV3DBase< T, PVType, FrameType >::z().

552  {
553  if (debug_)
554  LogDebug("HoughGrouping") << "associateHits";
555  LocalPoint tmpLocal, AWireLocal, AWireLocalCh, tmpLocalCh, thepoint;
556  GlobalPoint tmpGlobal, AWireGlobal;
557  double tmpx = 0;
558  double distleft = 0;
559  double distright = 0;
560  unsigned short int tmpwire = 0;
561  unsigned short int abslay = 0;
562  LATERAL_CASES lat = NONE;
563  bool isleft = false;
564  bool isright = false;
565 
566  ProtoCand returnPC;
567  for (auto l = 0; l < NUM_LAYERS_2SL; l++) {
568  returnPC.isThereHitInLayer_.push_back(false);
569  returnPC.isThereNeighBourHitInLayer_.push_back(false);
570  returnPC.xDistToPattern_.push_back(0);
571  returnPC.dtHits_.push_back(DTPrimitive());
572  }
573 
574  if (debug_)
575  LogDebug("HoughGrouping") << "associateHits - Beginning SL loop";
576  for (unsigned short int sl = 1; sl < 3 + 1; sl++) {
577  if (sl == 2)
578  continue;
579  if (debug_)
580  LogDebug("HoughGrouping") << "associateHits - SL: " << sl;
581 
582  for (unsigned short int l = 1; l < 4 + 1; l++) {
583  if (debug_)
584  LogDebug("HoughGrouping") << "associateHits - L: " << l;
585  isleft = false;
586  isright = false;
587  lat = NONE;
588  distleft = 0;
589  distright = 0;
590  if (sl == 1)
591  abslay = l - 1;
592  else
593  abslay = l + 3;
594  AWireLocal = LocalPoint(thechamb->superLayer(sl)->layer(l)->specificTopology().wirePosition(
595  thechamb->superLayer(sl)->layer(l)->specificTopology().firstChannel()),
596  0,
597  0);
598  AWireGlobal = thechamb->superLayer(sl)->layer(l)->toGlobal(AWireLocal);
599  AWireLocalCh = thechamb->toLocal(AWireGlobal);
600  tmpx = (AWireLocalCh.z() - n) / m;
601 
602  if ((tmpx <= xlowlim_) || (tmpx >= xhighlim_)) {
603  returnPC.dtHits_[abslay] = DTPrimitive(); // empty primitive
604  continue;
605  }
606 
607  thepoint = LocalPoint(tmpx, 0, AWireLocalCh.z());
608  tmpwire = thechamb->superLayer(sl)->layer(l)->specificTopology().channel(thepoint);
609  if (debug_)
610  LogDebug("HoughGrouping") << "associateHits - Wire number: " << tmpwire;
611  if (debug_)
612  LogDebug("HoughGrouping") << "associateHits - First channel in layer: "
613  << thechamb->superLayer(sl)->layer(l)->specificTopology().firstChannel();
614  if ((digimap_[abslay]).count(tmpwire)) {
615  // OK, we have a digi, let's choose the laterality, if we can:
616  tmpLocal = LocalPoint(thechamb->superLayer(sl)->layer(l)->specificTopology().wirePosition(tmpwire), 0, 0);
617  tmpGlobal = thechamb->superLayer(sl)->layer(l)->toGlobal(tmpLocal);
618  tmpLocalCh = thechamb->toLocal(tmpGlobal);
619 
620  if (abs(tmpLocalCh.x() - thepoint.x()) >= maxDistanceToWire_) {
621  // The distance where lateralities are not put is 0.03 cm, which is a conservative threshold for the resolution of the cells.
622  if ((tmpLocalCh.x() - thepoint.x()) > 0)
623  lat = LEFT;
624  else
625  lat = RIGHT;
626  }
627 
628  // Filling info
629  returnPC.nLayersWithHits_++;
630  returnPC.isThereHitInLayer_[abslay] = true;
631  returnPC.isThereNeighBourHitInLayer_[abslay] = true;
632  if (lat == LEFT)
633  returnPC.xDistToPattern_[abslay] = abs(tmpx - (tmpLocalCh.x() - 1.05));
634  else if (lat == RIGHT)
635  returnPC.xDistToPattern_[abslay] = abs(tmpx - (tmpLocalCh.x() + 1.05));
636  else
637  returnPC.xDistToPattern_[abslay] = abs(tmpx - tmpLocalCh.x());
638  returnPC.dtHits_[abslay] = DTPrimitive(digimap_[abslay][tmpwire]);
639  returnPC.dtHits_[abslay].setLaterality(lat);
640  } else {
641  if (debug_)
642  LogDebug("HoughGrouping") << "associateHits - No hit in the crossing cell";
643  if ((digimap_[abslay]).count(tmpwire - 1))
644  isleft = true;
645  if ((digimap_[abslay]).count(tmpwire + 1))
646  isright = true;
647  if (debug_)
648  LogDebug("HoughGrouping") << "associateHits - There is in the left: " << (int)isleft;
649  if (debug_)
650  LogDebug("HoughGrouping") << "associateHits - There is in the right: " << (int)isright;
651 
652  if ((isleft) && (!isright)) {
653  tmpLocal = LocalPoint(thechamb->superLayer(sl)->layer(l)->specificTopology().wirePosition(tmpwire - 1), 0, 0);
654  tmpGlobal = thechamb->superLayer(sl)->layer(l)->toGlobal(tmpLocal);
655  tmpLocalCh = thechamb->toLocal(tmpGlobal);
656 
657  // Filling info
658  returnPC.nLayersWithHits_++;
659  returnPC.isThereNeighBourHitInLayer_[abslay] = true;
660  returnPC.xDistToPattern_[abslay] = abs(tmpx - (tmpLocalCh.x() + 1.05));
661  returnPC.dtHits_[abslay] = DTPrimitive(digimap_[abslay][tmpwire - 1]);
662  returnPC.dtHits_[abslay].setLaterality(RIGHT);
663 
664  } else if ((!isleft) && (isright)) {
665  tmpLocal = LocalPoint(thechamb->superLayer(sl)->layer(l)->specificTopology().wirePosition(tmpwire + 1), 0, 0);
666  tmpGlobal = thechamb->superLayer(sl)->layer(l)->toGlobal(tmpLocal);
667  tmpLocalCh = thechamb->toLocal(tmpGlobal);
668 
669  // Filling info
670  returnPC.nLayersWithHits_++;
671  returnPC.isThereNeighBourHitInLayer_[abslay] = true;
672  returnPC.xDistToPattern_[abslay] = abs(tmpx - (tmpLocalCh.x() - 1.05));
673  returnPC.dtHits_[abslay] = DTPrimitive(digimap_[abslay][tmpwire + 1]);
674  returnPC.dtHits_[abslay].setLaterality(LEFT);
675  } else if ((isleft) && (isright)) {
676  LocalPoint tmpLocal_l =
677  LocalPoint(thechamb->superLayer(sl)->layer(l)->specificTopology().wirePosition(tmpwire - 1), 0, 0);
678  GlobalPoint tmpGlobal_l = thechamb->superLayer(sl)->layer(l)->toGlobal(tmpLocal_l);
679  LocalPoint tmpLocalCh_l = thechamb->toLocal(tmpGlobal_l);
680 
681  LocalPoint tmpLocal_r =
682  LocalPoint(thechamb->superLayer(sl)->layer(l)->specificTopology().wirePosition(tmpwire + 1), 0, 0);
683  GlobalPoint tmpGlobal_r = thechamb->superLayer(sl)->layer(l)->toGlobal(tmpLocal_r);
684  LocalPoint tmpLocalCh_r = thechamb->toLocal(tmpGlobal_r);
685 
686  distleft = std::abs(thepoint.x() - tmpLocalCh_l.x());
687  distright = std::abs(thepoint.x() - tmpLocalCh_r.x());
688 
689  // Filling info
690  returnPC.nLayersWithHits_++;
691  returnPC.isThereNeighBourHitInLayer_[abslay] = true;
692 
693  returnPC.xDistToPattern_[abslay] = abs(tmpx - (tmpLocalCh.x() - 1.05));
694  returnPC.dtHits_[abslay] = DTPrimitive(digimap_[abslay][tmpwire + 1]);
695  returnPC.dtHits_[abslay].setLaterality(LEFT);
696 
697  if (distleft < distright) {
698  returnPC.xDistToPattern_[abslay] = std::abs(tmpx - (tmpLocalCh.x() + 1.05));
699  returnPC.dtHits_[abslay] = DTPrimitive(digimap_[abslay][tmpwire - 1]);
700  returnPC.dtHits_[abslay].setLaterality(RIGHT);
701  } else {
702  returnPC.xDistToPattern_[abslay] = std::abs(tmpx - (tmpLocalCh.x() - 1.05));
703  returnPC.dtHits_[abslay] = DTPrimitive(digimap_[abslay][tmpwire + 1]);
704  returnPC.dtHits_[abslay].setLaterality(LEFT);
705  }
706  } else { // case where there are no digis
707  returnPC.dtHits_[abslay] = DTPrimitive(); // empty primitive
708  }
709  }
710  }
711  }
712 
713  setDifferenceBetweenSL(returnPC);
714  if (debug_) {
715  LogDebug("HoughGrouping") << "associateHits - Finishing with the candidate. We have found the following of it:";
716  LogDebug("HoughGrouping") << "associateHits - # of layers with hits: " << returnPC.nLayersWithHits_;
717  for (unsigned short int lay = 0; lay < 8; lay++) {
718  LogDebug("HoughGrouping") << "associateHits - For absolute layer: " << lay;
719  LogDebug("HoughGrouping") << "associateHits - # of HQ hits: " << returnPC.isThereHitInLayer_[lay];
720  LogDebug("HoughGrouping") << "associateHits - # of LQ hits: " << returnPC.isThereNeighBourHitInLayer_[lay];
721  }
722  LogDebug("HoughGrouping") << "associateHits - Abs. diff. between SL1 and SL3 hits: " << returnPC.nHitsDiff_;
723  for (unsigned short int lay = 0; lay < 8; lay++) {
724  LogDebug("HoughGrouping") << "associateHits - For absolute layer: " << lay;
725  LogDebug("HoughGrouping") << "associateHits - Abs. distance to digi: " << returnPC.xDistToPattern_[lay];
726  }
727  }
728  return returnPC;
729 }
double xhighlim_
Definition: HoughGrouping.h:88
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return the superlayer corresponding to the given id.
Definition: DTChamber.cc:53
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:59
unsigned short int nLayersWithHits_
Definition: HoughGrouping.h:20
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
void setDifferenceBetweenSL(ProtoCand &tupl)
LATERAL_CASES
Definition: constants.h:45
double maxDistanceToWire_
Definition: HoughGrouping.h:81
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
DTPrimitives dtHits_
Definition: HoughGrouping.h:26
const DTLayer * layer(const DTLayerId &id) const
Return the layer corresponding to the given id.
Definition: DTSuperLayer.cc:54
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:79
const DTTopology & specificTopology() const
Definition: DTLayer.cc:37
T z() const
Definition: PV3DBase.h:61
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< double > xDistToPattern_
Definition: HoughGrouping.h:25
unsigned short int nHitsDiff_
Definition: HoughGrouping.h:24
constexpr int NUM_LAYERS_2SL
Definition: constants.h:254
std::map< unsigned short int, DTPrimitive > digimap_[8]
int channel(const LocalPoint &p) const override
Definition: DTTopology.cc:54
std::vector< bool > isThereHitInLayer_
Definition: HoughGrouping.h:21
T x() const
Definition: PV3DBase.h:59
std::vector< bool > isThereNeighBourHitInLayer_
Definition: HoughGrouping.h:23
#define LogDebug(id)
void HoughGrouping::doHoughTransform ( )
private

Definition at line 345 of file HoughGrouping.cc.

References funct::cos(), debug_, mps_fire::i, LogDebug, PVValHelper::phi, HLT_FULL_cff::rho, and funct::sin().

345  {
346  if (debug_)
347  LogDebug("HoughGrouping") << "DoHoughTransform";
348  // First we want to obtain the number of bins in angle that we want. To do so, we will consider at first a maximum angle of
349  // (in rad.) pi/2 - arctan(0.3) (i.e. ~73º) and a resolution (width of bin angle) of 2º.
350 
351  if (debug_) {
352  LogDebug("HoughGrouping") << "DoHoughTransform - maxrads: " << maxrads_;
353  LogDebug("HoughGrouping") << "DoHoughTransform - minangle: " << minangle_;
354  LogDebug("HoughGrouping") << "DoHoughTransform - halfanglebins: " << halfanglebins_;
355  LogDebug("HoughGrouping") << "DoHoughTransform - anglebins: " << anglebins_;
356  LogDebug("HoughGrouping") << "DoHoughTransform - oneanglebin: " << oneanglebin_;
357  LogDebug("HoughGrouping") << "DoHoughTransform - spacebins: " << spacebins_;
358  }
359 
360  double rho = 0, phi = 0, sbx = 0;
361  double lowinitsb = xlowlim_ + posbinwidth_ / 2;
362 
363  // Initialisation
364  linespace_.resize(anglebins_, std::vector<unsigned short int>(spacebins_));
365  for (unsigned short int ab = 0; ab < anglebins_; ab++) {
366  sbx = lowinitsb;
367  for (unsigned short int sb = 0; sb < spacebins_; sb++) {
368  posmap_[sb] = sbx;
369  linespace_[ab][sb] = 0;
370  sbx += posbinwidth_;
371  }
372  }
373 
374  // Filling of the double array and actually doing the transform
375  for (unsigned short int i = 0; i < hitvec_.size(); i++) {
376  for (unsigned short int ab = 0; ab < anglebins_; ab++) {
377  phi = anglemap_[ab];
378  rho = hitvec_.at(i).first * cos(phi) + hitvec_.at(i).second * sin(phi);
379  sbx = lowinitsb - posbinwidth_ / 2;
380  for (unsigned short int sb = 0; sb < spacebins_; sb++) {
381  if (rho < sbx) {
382  linespace_[ab][sb]++;
383  break;
384  }
385  sbx += posbinwidth_;
386  }
387  }
388  }
389 }
unsigned short int anglebins_
Definition: HoughGrouping.h:91
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
unsigned short int spacebins_
Definition: HoughGrouping.h:91
PointsInPlane hitvec_
double posbinwidth_
Definition: HoughGrouping.h:81
double minangle_
Definition: HoughGrouping.h:87
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
PointMap anglemap_
Definition: HoughGrouping.h:98
std::vector< std::vector< unsigned short int > > linespace_
Definition: HoughGrouping.h:96
double oneanglebin_
Definition: HoughGrouping.h:87
PointMap posmap_
Definition: HoughGrouping.h:99
unsigned short int halfanglebins_
Definition: HoughGrouping.h:91
#define LogDebug(id)
PointsInPlane HoughGrouping::findTheMaxima ( PointTuples inputvec)
private

Definition at line 437 of file HoughGrouping.cc.

References debug_, first, dqmiolumiharvest::j, LogDebug, M_PI, and edm::second().

437  {
438  if (debug_)
439  LogDebug("HoughGrouping") << "findTheMaxima";
440  bool fullyreduced = false;
441  unsigned short int ind = 0;
442 
443  std::vector<unsigned short int> chosenvec;
444  PointsInPlane resultvec;
445  PointInPlane finalpair = {};
446 
447  if (debug_)
448  LogDebug("HoughGrouping") << "findTheMaxima - prewhile";
449  while (!fullyreduced) {
450  if (debug_) {
451  LogDebug("HoughGrouping") << "\nHoughGrouping::findTheMaxima - New iteration";
452  LogDebug("HoughGrouping") << "findTheMaxima - inputvec size: " << inputvec.size();
453  LogDebug("HoughGrouping") << "findTheMaxima - ind: " << ind;
454  LogDebug("HoughGrouping") << "findTheMaxima - maximum deltaang: " << maxdeltaAng_
455  << " and maximum deltapos: " << maxdeltaPos_;
456  }
457  chosenvec.clear();
458  //calculate distances and check out the ones that are near
459  if (debug_)
460  LogDebug("HoughGrouping") << "findTheMaxima - Ours have " << get<2>(inputvec.at(ind))
461  << " entries, ang.: " << get<0>(inputvec.at(ind))
462  << " and pos.: " << get<1>(inputvec.at(ind));
463 
464  for (unsigned short int j = ind + 1; j < inputvec.size(); j++) {
465  if (getTwoDelta(inputvec.at(ind), inputvec.at(j)).first <= maxdeltaAng_ &&
466  getTwoDelta(inputvec.at(ind), inputvec.at(j)).second <= maxdeltaPos_) {
467  chosenvec.push_back(j);
468  if (debug_)
469  LogDebug("HoughGrouping") << "findTheMaxima - - Adding num. " << j
470  << " with deltaang: " << getTwoDelta(inputvec.at(ind), inputvec.at(j)).first
471  << ", and deltapos: " << getTwoDelta(inputvec.at(ind), inputvec.at(j)).second
472  << " and with " << get<2>(inputvec.at(j))
473  << " entries, ang.: " << get<0>(inputvec.at(j))
474  << " and pos.: " << get<1>(inputvec.at(j));
475  } else if (debug_)
476  LogDebug("HoughGrouping") << "findTheMaxima - - Ignoring num. " << j
477  << " with deltaang: " << getTwoDelta(inputvec.at(ind), inputvec.at(j)).first
478  << ", and deltapos: " << getTwoDelta(inputvec.at(ind), inputvec.at(j)).second
479  << " and with " << get<2>(inputvec.at(j)) << " entries.";
480  }
481 
482  if (debug_)
483  LogDebug("HoughGrouping") << "findTheMaxima - chosenvecsize: " << chosenvec.size();
484 
485  if (chosenvec.empty()) {
486  if (ind + 1 >= (unsigned short int)inputvec.size())
487  fullyreduced = true;
488  if ((get<0>(inputvec.at(ind)) <= maxrads_) || (get<0>(inputvec.at(ind)) >= M_PI - maxrads_))
489  resultvec.push_back({get<0>(inputvec.at(ind)), get<1>(inputvec.at(ind))});
490  else if (debug_)
491  LogDebug("HoughGrouping") << "findTheMaxima - - Candidate dropped due to an excess in angle";
492  ind++;
493  continue;
494  }
495 
496  // Now average them
497  finalpair = getAveragePoint(inputvec, ind, chosenvec);
498 
499  // Erase the ones you used
500  inputvec.erase(inputvec.begin() + ind);
501  for (short int j = chosenvec.size() - 1; j > -1; j--) {
502  if (debug_)
503  LogDebug("HoughGrouping") << "findTheMaxima - erasing index: " << chosenvec.at(j) - 1;
504  inputvec.erase(inputvec.begin() + chosenvec.at(j) - 1);
505  }
506 
507  if (debug_)
508  LogDebug("HoughGrouping") << "findTheMaxima - inputvec size: " << inputvec.size();
509 
510  // And add the one you calculated:
511  if ((finalpair.first <= maxrads_) || (finalpair.first >= M_PI - maxrads_))
512  resultvec.push_back(finalpair);
513  else if (debug_)
514  LogDebug("HoughGrouping") << "findTheMaxima - - Candidate dropped due to an excess in angle";
515 
516  if (ind + 1 >= (unsigned short int)inputvec.size())
517  fullyreduced = true;
518  if (debug_)
519  LogDebug("HoughGrouping") << "findTheMaxima - iteration ends";
520  ind++;
521  }
522  if (debug_)
523  LogDebug("HoughGrouping") << "findTheMaxima - postwhile";
524  return resultvec;
525 }
PointInPlane getTwoDelta(const PointTuple &pair1, const PointTuple &pair2)
double maxdeltaPos_
Definition: HoughGrouping.h:81
U second(std::pair< T, U > const &p)
PointInPlane getAveragePoint(const PointTuples &inputvec, unsigned short int firstindex, const std::vector< unsigned short int > &indexlist)
double maxdeltaAng_
Definition: HoughGrouping.h:89
std::vector< PointInPlane > PointsInPlane
Definition: HoughGrouping.h:30
std::pair< double, double > PointInPlane
Definition: HoughGrouping.h:29
#define M_PI
#define LogDebug(id)
void HoughGrouping::finish ( )
overridevirtual

Reimplemented from MotherGrouping.

Definition at line 262 of file HoughGrouping.cc.

References debug_, and LogDebug.

Referenced by progressbar.ProgressBar::__next__().

262  {
263  if (debug_)
264  LogDebug("HoughGrouping") << "finish";
265  return;
266 }
#define LogDebug(id)
PointInPlane HoughGrouping::getAveragePoint ( const PointTuples inputvec,
unsigned short int  firstindex,
const std::vector< unsigned short int > &  indexlist 
)
private

Definition at line 533 of file HoughGrouping.cc.

References debug_, funct::exp(), mps_fire::i, LogDebug, Mean, and gpuVertexFinder::ws.

535  {
536  if (debug_)
537  LogDebug("HoughGrouping") << "getAveragePoint";
538  std::vector<double> xs;
539  std::vector<double> ys;
540  std::vector<double> ws;
541  xs.push_back(get<0>(inputvec.at(firstindex)));
542  ys.push_back(get<1>(inputvec.at(firstindex)));
543  ws.push_back(exp(get<2>(inputvec.at(firstindex))));
544  for (unsigned short int i = 0; i < indexlist.size(); i++) {
545  xs.push_back(get<0>(inputvec.at(indexlist.at(i))));
546  ys.push_back(get<1>(inputvec.at(indexlist.at(i))));
547  ws.push_back(exp(get<2>(inputvec.at(indexlist.at(i)))));
548  }
549  return {TMath::Mean(xs.begin(), xs.end(), ws.begin()), TMath::Mean(ys.begin(), ys.end(), ws.begin())};
550 }
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
auto &__restrict__ ws
#define LogDebug(id)
PointsInPlane HoughGrouping::getMaximaVector ( )
private

Definition at line 391 of file HoughGrouping.cc.

References debug_, mps_fire::i, and LogDebug.

391  {
392  if (debug_)
393  LogDebug("HoughGrouping") << "getMaximaVector";
394  PointTuples tmpvec;
395 
396  bool flagsearched = false;
397  unsigned short int numbertolookat = upperNumber_;
398 
399  while (!flagsearched) {
400  for (unsigned short int ab = 0; ab < anglebins_; ab++) {
401  for (unsigned short int sb = 0; sb < spacebins_; sb++) {
402  if (linespace_[ab][sb] >= numbertolookat)
403  tmpvec.push_back({anglemap_[ab], posmap_[sb], linespace_[ab][sb]});
404  }
405  }
406  if (((numbertolookat - 1) < lowerNumber_) || (!tmpvec.empty()))
407  flagsearched = true;
408  else
409  numbertolookat--;
410  }
411 
412  if (tmpvec.empty()) {
413  if (debug_)
414  LogDebug("HoughGrouping") << "GetMaximaVector - No maxima could be found";
415  PointsInPlane finalvec;
416  return finalvec;
417  } else {
418  PointsInPlane finalvec = findTheMaxima(tmpvec);
419 
420  // And now obtain the values of m and n of the lines.
421  for (unsigned short int i = 0; i < finalvec.size(); i++)
422  finalvec.at(i) = transformPair(finalvec.at(i));
423  return finalvec;
424  }
425 }
unsigned short int lowerNumber_
Definition: HoughGrouping.h:79
unsigned short int anglebins_
Definition: HoughGrouping.h:91
unsigned short int upperNumber_
Definition: HoughGrouping.h:79
unsigned short int spacebins_
Definition: HoughGrouping.h:91
PointsInPlane findTheMaxima(PointTuples &inputvec)
PointInPlane transformPair(const PointInPlane &inputpair)
PointMap anglemap_
Definition: HoughGrouping.h:98
std::vector< PointInPlane > PointsInPlane
Definition: HoughGrouping.h:30
std::vector< PointTuple > PointTuples
Definition: HoughGrouping.h:32
std::vector< std::vector< unsigned short int > > linespace_
Definition: HoughGrouping.h:96
PointMap posmap_
Definition: HoughGrouping.h:99
#define LogDebug(id)
PointInPlane HoughGrouping::getTwoDelta ( const PointTuple pair1,
const PointTuple pair2 
)
private

Definition at line 527 of file HoughGrouping.cc.

References funct::abs(), debug_, and LogDebug.

527  {
528  if (debug_)
529  LogDebug("HoughGrouping") << "getTwoDelta";
530  return {abs(get<0>(pair1) - get<0>(pair2)), abs(get<1>(pair1) - get<1>(pair2))};
531 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define LogDebug(id)
void HoughGrouping::initialise ( const edm::EventSetup iEventSetup)
overridevirtual

Reimplemented from MotherGrouping.

Definition at line 92 of file HoughGrouping.cc.

References angle_units::operators::convertDegToRad(), debug_, dtGeomH, relativeConstraints::geom, edm::EventSetup::get(), edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::get(), LogDebug, M_PI, and PVValHelper::phi.

92  {
93  if (debug_)
94  LogDebug("HoughGrouping") << "initialise";
95 
97 
98  maxrads_ = 0.5 * M_PI - atan(angletan_);
100  halfanglebins_ = round(maxrads_ / minangle_ + 1);
101  anglebins_ = (unsigned short int)2 * halfanglebins_;
103 
104  maxdeltaAng_ = maxdeltaAngDeg_ * 2 * M_PI / 360;
105 
106  // Initialisation of anglemap. Posmap depends on the size of the chamber.
107  double phi = 0;
108  anglemap_ = {};
109  for (unsigned short int ab = 0; ab < halfanglebins_; ab++) {
110  anglemap_[ab] = phi;
111  phi += oneanglebin_;
112  }
113 
114  phi = (M_PI - maxrads_);
115  for (unsigned short int ab = halfanglebins_; ab < anglebins_; ab++) {
116  anglemap_[ab] = phi;
117  phi += oneanglebin_;
118  }
119 
120  if (debug_) {
121  LogDebug("HoughGrouping")
122  << "\nHoughGrouping::ResetAttributes - Information from the initialisation of HoughGrouping:";
123  LogDebug("HoughGrouping") << "ResetAttributes - maxrads: " << maxrads_;
124  LogDebug("HoughGrouping") << "ResetAttributes - anglebinwidth: " << anglebinwidth_;
125  LogDebug("HoughGrouping") << "ResetAttributes - minangle: " << minangle_;
126  LogDebug("HoughGrouping") << "ResetAttributes - halfanglebins: " << halfanglebins_;
127  LogDebug("HoughGrouping") << "ResetAttributes - anglebins: " << anglebins_;
128  LogDebug("HoughGrouping") << "ResetAttributes - oneanglebin: " << oneanglebin_;
129  LogDebug("HoughGrouping") << "ResetAttributes - posbinwidth: " << posbinwidth_;
130  }
131 
132  const MuonGeometryRecord& geom = iEventSetup.get<MuonGeometryRecord>();
133  dtGeo_ = &geom.get(dtGeomH);
134 }
unsigned short int anglebins_
Definition: HoughGrouping.h:91
double maxdeltaAngDeg_
Definition: HoughGrouping.h:81
constexpr double convertDegToRad(NumType degrees)
Definition: angle_units.h:27
DTGeometry const * dtGeo_
Definition: HoughGrouping.h:83
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
double posbinwidth_
Definition: HoughGrouping.h:81
double minangle_
Definition: HoughGrouping.h:87
double maxdeltaAng_
Definition: HoughGrouping.h:89
PointMap anglemap_
Definition: HoughGrouping.h:98
double angletan_
Definition: HoughGrouping.h:81
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomH
Definition: HoughGrouping.h:84
double anglebinwidth_
Definition: HoughGrouping.h:81
#define M_PI
double oneanglebin_
Definition: HoughGrouping.h:87
unsigned short int halfanglebins_
Definition: HoughGrouping.h:91
void resetAttributes()
T get() const
Definition: EventSetup.h:88
#define LogDebug(id)
void HoughGrouping::obtainGeometricalBorders ( const DTLayer lay)
private

Definition at line 308 of file HoughGrouping.cc.

References funct::abs(), DTTopology::cellHeight(), DTTopology::cellWidth(), DTLayer::chamber(), debug_, DTTopology::firstChannel(), DTTopology::lastChannel(), DTSuperLayer::layer(), LogDebug, DTLayer::specificTopology(), DTChamber::superLayer(), GeomDet::toGlobal(), GeomDet::toLocal(), DTTopology::wirePosition(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::z().

308  {
309  if (debug_)
310  LogDebug("HoughGrouping") << "ObtainGeometricalBorders";
311  LocalPoint FirstWireLocal(lay->chamber()->superLayer(1)->layer(1)->specificTopology().wirePosition(
313  0,
314  0); // TAKING INFO FROM L1 OF SL1 OF THE CHOSEN CHAMBER
315  GlobalPoint FirstWireGlobal = lay->chamber()->superLayer(1)->layer(1)->toGlobal(FirstWireLocal);
316  LocalPoint FirstWireLocalCh = lay->chamber()->toLocal(FirstWireGlobal);
317 
318  LocalPoint LastWireLocal(lay->chamber()->superLayer(1)->layer(1)->specificTopology().wirePosition(
319  lay->chamber()->superLayer(1)->layer(1)->specificTopology().lastChannel()),
320  0,
321  0);
322  GlobalPoint LastWireGlobal = lay->chamber()->superLayer(1)->layer(1)->toGlobal(LastWireLocal);
323  LocalPoint LastWireLocalCh = lay->chamber()->toLocal(LastWireGlobal);
324 
325  // unsigned short int upsl = thestation == 4 ? 2 : 3;
326  unsigned short int upsl = thestation_ == 4 ? 3 : 3;
327  if (debug_)
328  LogDebug("HoughGrouping") << "ObtainGeometricalBorders - uppersuperlayer: " << upsl;
329 
330  LocalPoint FirstWireLocalUp(lay->chamber()->superLayer(upsl)->layer(4)->specificTopology().wirePosition(
331  lay->chamber()->superLayer(upsl)->layer(4)->specificTopology().firstChannel()),
332  0,
333  0); // TAKING INFO FROM L1 OF SL1 OF THE CHOSEN CHAMBER
334  GlobalPoint FirstWireGlobalUp = lay->chamber()->superLayer(upsl)->layer(4)->toGlobal(FirstWireLocalUp);
335  LocalPoint FirstWireLocalChUp = lay->chamber()->toLocal(FirstWireGlobalUp);
336 
337  xlowlim_ = FirstWireLocalCh.x() - lay->chamber()->superLayer(1)->layer(1)->specificTopology().cellWidth() / 2;
338  xhighlim_ = LastWireLocalCh.x() + lay->chamber()->superLayer(1)->layer(1)->specificTopology().cellWidth() / 2;
339  zlowlim_ = FirstWireLocalChUp.z() - lay->chamber()->superLayer(upsl)->layer(4)->specificTopology().cellHeight() / 2;
340  zhighlim_ = LastWireLocalCh.z() + lay->chamber()->superLayer(1)->layer(1)->specificTopology().cellHeight() / 2;
341 
343 }
double xhighlim_
Definition: HoughGrouping.h:88
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return the superlayer corresponding to the given id.
Definition: DTChamber.cc:53
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:59
unsigned short int thestation_
Definition: HoughGrouping.h:93
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
const DTLayer * layer(const DTLayerId &id) const
Return the layer corresponding to the given id.
Definition: DTSuperLayer.cc:54
float cellWidth() const
Returns the cell width.
Definition: DTTopology.h:69
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
double zhighlim_
Definition: HoughGrouping.h:88
unsigned short int spacebins_
Definition: HoughGrouping.h:91
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:79
int lastChannel() const
Returns the wire number of the last wire.
Definition: DTTopology.h:81
const DTTopology & specificTopology() const
Definition: DTLayer.cc:37
double posbinwidth_
Definition: HoughGrouping.h:81
T z() const
Definition: PV3DBase.h:61
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float cellHeight() const
Returns the cell height.
Definition: DTTopology.h:71
const DTChamber * chamber() const
Definition: DTLayer.cc:45
T x() const
Definition: PV3DBase.h:59
#define LogDebug(id)
void HoughGrouping::orderAndFilter ( std::vector< ProtoCand > &  invector,
MuonPathPtrs outMuonPath 
)
private

Definition at line 750 of file HoughGrouping.cc.

References debug_, filtered(), mps_fire::i, LogDebug, eostools::move(), and NONE.

750  {
751  if (debug_)
752  LogDebug("HoughGrouping") << "orderAndFilter";
753  // 0: # of layers with hits.
754  // 1: # of hits of high quality (the expected line crosses the cell).
755  // 2: # of hits of low quality (the expected line is in a neighbouring cell).
756  // 3: absolute diff. between the number of hits in SL1 and SL3.
757  // 4: absolute distance to all hits of the segment.
758  // 5: DTPrimitive of the candidate.
759 
760  std::vector<unsigned short int> elstoremove;
761  // ordering:
762  if (debug_)
763  LogDebug("HoughGrouping") << "orderAndFilter - First ordering";
764  std::sort(invector.begin(), invector.end(), HoughOrdering);
765 
766  // Now filtering:
767  unsigned short int ind = 0;
768  bool filtered = false;
769  if (debug_)
770  LogDebug("HoughGrouping") << "orderAndFilter - Entering while";
771  while (!filtered) {
772  if (debug_)
773  LogDebug("HoughGrouping") << "\nHoughGrouping::orderAndFilter - New iteration with ind: " << ind;
774  elstoremove.clear();
775  for (unsigned short int i = ind + 1; i < invector.size(); i++) {
776  if (debug_)
777  LogDebug("HoughGrouping") << "orderAndFilter - Checking index: " << i;
778  for (unsigned short int lay = 0; lay < 8; lay++) {
779  if (debug_)
780  LogDebug("HoughGrouping") << "orderAndFilter - Checking layer number: " << lay;
781  if (invector.at(i).dtHits_[lay].channelId() == invector.at(ind).dtHits_[lay].channelId() &&
782  invector.at(ind).dtHits_[lay].channelId() != -1) {
783  invector.at(i).nLayersWithHits_--;
784  invector.at(i).isThereHitInLayer_[lay] = false;
785  invector.at(i).isThereNeighBourHitInLayer_[lay] = false;
786  setDifferenceBetweenSL(invector.at(i));
787  // We check that if its a different laterality, the best candidate of the two of them changes its laterality to not-known (that is, both).
788  if (invector.at(i).dtHits_[lay].laterality() != invector.at(ind).dtHits_[lay].laterality())
789  invector.at(ind).dtHits_[lay].setLaterality(NONE);
790 
791  invector.at(i).dtHits_[lay] = DTPrimitive();
792  }
793  }
794  if (debug_)
795  LogDebug("HoughGrouping")
796  << "orderAndFilter - Finished checking all the layers, now seeing if we should remove the "
797  "candidate";
798 
799  if (!areThereEnoughHits(invector.at(i))) {
800  if (debug_)
801  LogDebug("HoughGrouping") << "orderAndFilter - This candidate shall be removed!";
802  elstoremove.push_back((unsigned short int)i);
803  }
804  }
805 
806  if (debug_)
807  LogDebug("HoughGrouping") << "orderAndFilter - We are gonna erase " << elstoremove.size() << " elements";
808 
809  for (short int el = (elstoremove.size() - 1); el > -1; el--) {
810  invector.erase(invector.begin() + elstoremove.at(el));
811  }
812 
813  if (ind + 1 == (unsigned short int)invector.size())
814  filtered = true;
815  else
816  std::sort(invector.begin() + ind + 1, invector.end(), HoughOrdering);
817  ind++;
818  }
819 
820  // Ultimate filter: if the remaining do not fill the requirements (configurable through pset arguments), they are removed also.
821  for (short int el = (invector.size() - 1); el > -1; el--) {
822  if (!areThereEnoughHits(invector.at(el))) {
823  invector.erase(invector.begin() + el);
824  }
825  }
826 
827  if (invector.empty()) {
828  if (debug_)
829  LogDebug("HoughGrouping") << "OrderAndFilter - We do not have candidates with the minimum hits required.";
830  return;
831  } else if (debug_)
832  LogDebug("HoughGrouping") << "OrderAndFilter - At the end, we have only " << invector.size() << " good paths!";
833 
834  // Packing dt primitives
835  for (unsigned short int i = 0; i < invector.size(); i++) {
836  DTPrimitivePtrs ptrPrimitive;
837  unsigned short int tmplowfill = 0;
838  unsigned short int tmpupfill = 0;
839  for (unsigned short int lay = 0; lay < 8; lay++) {
840  auto dtAux = std::make_shared<DTPrimitive>(invector.at(i).dtHits_[lay]);
841  ptrPrimitive.push_back(std::move(dtAux));
842  if (debug_) {
843  LogDebug("HoughGrouping") << "\nHoughGrouping::OrderAndFilter - cameraid: " << ptrPrimitive[lay]->cameraId();
844  LogDebug("HoughGrouping") << "OrderAndFilter - channelid (GOOD): " << ptrPrimitive[lay]->channelId();
845  LogDebug("HoughGrouping") << "OrderAndFilter - channelid (AM): " << ptrPrimitive[lay]->channelId() - 1;
846  }
847  // Fixing channel ID to AM conventions...
848  if (ptrPrimitive[lay]->channelId() != -1)
849  ptrPrimitive[lay]->setChannelId(ptrPrimitive[lay]->channelId() - 1);
850 
851  if (ptrPrimitive[lay]->cameraId() > 0) {
852  if (lay < 4)
853  tmplowfill++;
854  else
855  tmpupfill++;
856  }
857  }
858 
859  auto ptrMuonPath = std::make_shared<MuonPath>(ptrPrimitive, tmplowfill, tmpupfill);
860  outMuonPath.push_back(ptrMuonPath);
861  if (debug_) {
862  for (unsigned short int lay = 0; lay < 8; lay++) {
863  LogDebug("HoughGrouping") << "OrderAndFilter - Final cameraID: "
864  << outMuonPath.back()->primitive(lay)->cameraId();
865  LogDebug("HoughGrouping") << "OrderAndFilter - Final channelID: "
866  << outMuonPath.back()->primitive(lay)->channelId();
867  LogDebug("HoughGrouping") << "OrderAndFilter - Final time: "
868  << outMuonPath.back()->primitive(lay)->tdcTimeStamp();
869  }
870  }
871  }
872  return;
873 }
std::vector< DTPrimitivePtr > DTPrimitivePtrs
Definition: DTprimitive.h:55
void setDifferenceBetweenSL(ProtoCand &tupl)
static const TGPicture * filtered(bool iBackgroundIsBlack)
def move
Definition: eostools.py:511
bool areThereEnoughHits(const ProtoCand &tupl)
#define LogDebug(id)
void HoughGrouping::resetAttributes ( )
private

Definition at line 271 of file HoughGrouping.cc.

References clear(), debug_, and LogDebug.

271  {
272  if (debug_)
273  LogDebug("HoughGrouping") << "ResetAttributes";
274  // std::vector's:
275  maxima_.clear();
276  hitvec_.clear();
277 
278  // Integer-type variables:
279  spacebins_ = 0;
280  idigi_ = 0;
281  nhits_ = 0;
282  xlowlim_ = 0;
283  xhighlim_ = 0;
284  zlowlim_ = 0;
285  zhighlim_ = 0;
286  thestation_ = 0;
287  thesector_ = 0;
288  thewheel_ = 0;
289 
290  // Arrays:
291  // NOTE: linespace array is treated and reset separately
292 
293  // Maps (dictionaries):
294  posmap_.clear();
295  for (unsigned short int abslay = 0; abslay < 8; abslay++)
296  digimap_[abslay].clear();
297 }
double xhighlim_
Definition: HoughGrouping.h:88
unsigned short int thestation_
Definition: HoughGrouping.h:93
PointsInPlane maxima_
activeDets clear()
double zhighlim_
Definition: HoughGrouping.h:88
unsigned short int thesector_
Definition: HoughGrouping.h:93
unsigned short int spacebins_
Definition: HoughGrouping.h:91
unsigned short int idigi_
Definition: HoughGrouping.h:92
unsigned short int nhits_
Definition: HoughGrouping.h:92
PointsInPlane hitvec_
PointMap posmap_
Definition: HoughGrouping.h:99
std::map< unsigned short int, DTPrimitive > digimap_[8]
short int thewheel_
Definition: HoughGrouping.h:94
#define LogDebug(id)
void HoughGrouping::resetPosElementsOfLinespace ( )
private

Definition at line 299 of file HoughGrouping.cc.

References debug_, and LogDebug.

299  {
300  if (debug_)
301  LogDebug("HoughGrouping") << "ResetPosElementsOfLinespace";
302  for (unsigned short int ab = 0; ab < anglebins_; ab++) {
303  linespace_[ab].clear();
304  }
305  linespace_.clear();
306 }
unsigned short int anglebins_
Definition: HoughGrouping.h:91
std::vector< std::vector< unsigned short int > > linespace_
Definition: HoughGrouping.h:96
#define LogDebug(id)
void HoughGrouping::run ( edm::Event iEvent,
const edm::EventSetup iEventSetup,
const DTDigiCollection digis,
MuonPathPtrs outMpath 
)
overridevirtual

Reimplemented from MotherGrouping.

Definition at line 136 of file HoughGrouping.cc.

References HLT_FULL_cff::cands, DTTopology::cellHeight(), DTTopology::cellWidth(), DTLayer::chamber(), debug_, DTTopology::firstChannel(), DTTopology::lastChannel(), LogDebug, DTLayer::specificTopology(), GeomDet::toGlobal(), GeomDet::toLocal(), DTTopology::wirePosition(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

139  {
140  if (debug_)
141  LogDebug("HoughGrouping") << "\nHoughGrouping::run";
142 
143  resetAttributes();
144 
145  if (debug_)
146  LogDebug("HoughGrouping") << "run - Beginning digis' loop...";
147  LocalPoint wirePosInLay, wirePosInChamber;
148  GlobalPoint wirePosGlob;
149  for (DTDigiCollection::DigiRangeIterator dtLayerIdIt = digis.begin(); dtLayerIdIt != digis.end(); dtLayerIdIt++) {
150  const DTLayer* lay = dtGeo_->layer((*dtLayerIdIt).first);
151  for (DTDigiCollection::const_iterator digiIt = ((*dtLayerIdIt).second).first;
152  digiIt != ((*dtLayerIdIt).second).second;
153  digiIt++) {
154  if (debug_) {
155  LogDebug("HoughGrouping") << "\nHoughGrouping::run - Digi number " << idigi_;
156  LogDebug("HoughGrouping") << "run - Wheel: " << (*dtLayerIdIt).first.wheel();
157  LogDebug("HoughGrouping") << "run - Chamber: " << (*dtLayerIdIt).first.station();
158  LogDebug("HoughGrouping") << "run - Sector: " << (*dtLayerIdIt).first.sector();
159  LogDebug("HoughGrouping") << "run - Superlayer: " << (*dtLayerIdIt).first.superLayer();
160  LogDebug("HoughGrouping") << "run - Layer: " << (*dtLayerIdIt).first.layer();
161  LogDebug("HoughGrouping") << "run - Wire: " << (*digiIt).wire();
162  LogDebug("HoughGrouping") << "run - First wire: " << lay->specificTopology().firstChannel();
163  LogDebug("HoughGrouping") << "run - Last wire: " << lay->specificTopology().lastChannel();
164  LogDebug("HoughGrouping") << "run - First wire x: "
166  LogDebug("HoughGrouping") << "run - Last wire x: "
168  LogDebug("HoughGrouping") << "run - Cell width: " << lay->specificTopology().cellWidth();
169  LogDebug("HoughGrouping") << "run - Cell height: " << lay->specificTopology().cellHeight();
170  }
171  if ((*dtLayerIdIt).first.superLayer() == 2)
172  continue;
173 
174  wirePosInLay = LocalPoint(lay->specificTopology().wirePosition((*digiIt).wire()), 0, 0);
175  wirePosGlob = lay->toGlobal(wirePosInLay);
176  wirePosInChamber = lay->chamber()->toLocal(wirePosGlob);
177 
178  if ((*dtLayerIdIt).first.superLayer() == 3) {
179  digimap_[(*dtLayerIdIt).first.layer() + 3][(*digiIt).wire()] = DTPrimitive();
180  digimap_[(*dtLayerIdIt).first.layer() + 3][(*digiIt).wire()].setTDCTimeStamp((*digiIt).time());
181  digimap_[(*dtLayerIdIt).first.layer() + 3][(*digiIt).wire()].setChannelId((*digiIt).wire());
182  digimap_[(*dtLayerIdIt).first.layer() + 3][(*digiIt).wire()].setLayerId((*dtLayerIdIt).first.layer());
183  digimap_[(*dtLayerIdIt).first.layer() + 3][(*digiIt).wire()].setSuperLayerId((*dtLayerIdIt).first.superLayer());
184  digimap_[(*dtLayerIdIt).first.layer() + 3][(*digiIt).wire()].setCameraId((*dtLayerIdIt).first.rawId());
185  } else {
186  digimap_[(*dtLayerIdIt).first.layer() - 1][(*digiIt).wire()] = DTPrimitive();
187  digimap_[(*dtLayerIdIt).first.layer() - 1][(*digiIt).wire()].setTDCTimeStamp((*digiIt).time());
188  digimap_[(*dtLayerIdIt).first.layer() - 1][(*digiIt).wire()].setChannelId((*digiIt).wire());
189  digimap_[(*dtLayerIdIt).first.layer() - 1][(*digiIt).wire()].setLayerId((*dtLayerIdIt).first.layer());
190  digimap_[(*dtLayerIdIt).first.layer() - 1][(*digiIt).wire()].setSuperLayerId((*dtLayerIdIt).first.superLayer());
191  digimap_[(*dtLayerIdIt).first.layer() - 1][(*digiIt).wire()].setCameraId((*dtLayerIdIt).first.rawId());
192  }
193 
194  // Obtaining geometrical info of the chosen chamber
195  if (xlowlim_ == 0 && xhighlim_ == 0 && zlowlim_ == 0 && zhighlim_ == 0) {
196  thewheel_ = (*dtLayerIdIt).first.wheel();
197  thestation_ = (*dtLayerIdIt).first.station();
198  thesector_ = (*dtLayerIdIt).first.sector();
200  }
201 
202  if (debug_) {
203  LogDebug("HoughGrouping") << "run - X position of the cell (chamber frame of reference): "
204  << wirePosInChamber.x();
205  LogDebug("HoughGrouping") << "run - Y position of the cell (chamber frame of reference): "
206  << wirePosInChamber.y();
207  LogDebug("HoughGrouping") << "run - Z position of the cell (chamber frame of reference): "
208  << wirePosInChamber.z();
209  }
210 
211  hitvec_.push_back({wirePosInChamber.x() - 1.05, wirePosInChamber.z()});
212  hitvec_.push_back({wirePosInChamber.x() + 1.05, wirePosInChamber.z()});
213  nhits_ += 2;
214 
215  idigi_++;
216  }
217  }
218 
219  if (debug_) {
220  LogDebug("HoughGrouping") << "\nHoughGrouping::run - nhits: " << nhits_;
221  LogDebug("HoughGrouping") << "run - idigi: " << idigi_;
222  }
223 
224  if (hitvec_.empty()) {
225  if (debug_)
226  LogDebug("HoughGrouping") << "run - No digis present in this chamber.";
227  return;
228  }
229 
230  // Perform the Hough transform of the inputs.
232 
233  // Obtain the maxima
236 
237  if (maxima_.empty()) {
238  if (debug_)
239  LogDebug("HoughGrouping") << "run - No good maxima found in this event.";
240  return;
241  }
242 
244  const DTChamber* TheChamb = dtGeo_->chamber(TheChambId);
245  std::vector<ProtoCand> cands;
246 
247  for (unsigned short int ican = 0; ican < maxima_.size(); ican++) {
248  if (debug_)
249  LogDebug("HoughGrouping") << "\nHoughGrouping::run - Candidate number: " << ican;
250  cands.push_back(associateHits(TheChamb, maxima_.at(ican).first, maxima_.at(ican).second));
251  }
252 
253  // Now we filter them:
254  orderAndFilter(cands, outMpath);
255  if (debug_)
256  LogDebug("HoughGrouping") << "run - now we have our muonpaths! It has " << outMpath.size() << " elements";
257 
258  cands.clear();
259  return;
260 }
void doHoughTransform()
double xhighlim_
Definition: HoughGrouping.h:88
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:59
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
unsigned short int thestation_
Definition: HoughGrouping.h:93
PointsInPlane maxima_
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:90
DTGeometry const * dtGeo_
Definition: HoughGrouping.h:83
ProtoCand associateHits(const DTChamber *thechamb, double m, double n)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
T y() const
Definition: PV3DBase.h:60
float cellWidth() const
Returns the cell width.
Definition: DTTopology.h:69
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
double zhighlim_
Definition: HoughGrouping.h:88
void orderAndFilter(std::vector< ProtoCand > &invector, MuonPathPtrs &outMuonPath)
PointsInPlane getMaximaVector()
unsigned short int thesector_
Definition: HoughGrouping.h:93
unsigned short int idigi_
Definition: HoughGrouping.h:92
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:79
int lastChannel() const
Returns the wire number of the last wire.
Definition: DTTopology.h:81
const DTTopology & specificTopology() const
Definition: DTLayer.cc:37
unsigned short int nhits_
Definition: HoughGrouping.h:92
PointsInPlane hitvec_
T z() const
Definition: PV3DBase.h:61
void obtainGeometricalBorders(const DTLayer *lay)
float cellHeight() const
Returns the cell height.
Definition: DTTopology.h:71
void resetPosElementsOfLinespace()
DTChamberId TheChambId
Definition: HoughGrouping.h:85
const DTChamber * chamber() const
Definition: DTLayer.cc:45
std::vector< DigiType >::const_iterator const_iterator
void resetAttributes()
std::map< unsigned short int, DTPrimitive > digimap_[8]
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:96
T x() const
Definition: PV3DBase.h:59
short int thewheel_
Definition: HoughGrouping.h:94
#define LogDebug(id)
void HoughGrouping::setDifferenceBetweenSL ( ProtoCand tupl)
private

Definition at line 731 of file HoughGrouping.cc.

References debug_, ProtoCand::dtHits_, LogDebug, and ProtoCand::nHitsDiff_.

731  {
732  if (debug_)
733  LogDebug("HoughGrouping") << "setDifferenceBetweenSL";
734  short int absres = 0;
735  for (unsigned short int lay = 0; lay < 8; lay++) {
736  if (tupl.dtHits_[lay].channelId() > 0) {
737  if (lay <= 3)
738  absres++;
739  else
740  absres--;
741  }
742  }
743 
744  if (absres >= 0)
745  tupl.nHitsDiff_ = absres;
746  else
747  tupl.nHitsDiff_ = (unsigned short int)(-absres);
748 }
DTPrimitives dtHits_
Definition: HoughGrouping.h:26
unsigned short int nHitsDiff_
Definition: HoughGrouping.h:24
#define LogDebug(id)
PointInPlane HoughGrouping::transformPair ( const PointInPlane inputpair)
private

Definition at line 427 of file HoughGrouping.cc.

References debug_, LogDebug, funct::sin(), and funct::tan().

427  {
428  if (debug_)
429  LogDebug("HoughGrouping") << "transformPair";
430  // input: (ang, pos); output: (m, n)
431  if (inputpair.first == 0)
432  return {1000, -1000 * inputpair.second};
433  else
434  return {-1. / tan(inputpair.first), inputpair.second / sin(inputpair.first)};
435 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
#define LogDebug(id)

Member Data Documentation

bool HoughGrouping::allowUncorrelatedPatterns_
private

Definition at line 78 of file HoughGrouping.h.

Referenced by HoughGrouping().

unsigned short int HoughGrouping::anglebins_
private

Definition at line 91 of file HoughGrouping.h.

double HoughGrouping::anglebinwidth_
private

Definition at line 81 of file HoughGrouping.h.

Referenced by HoughGrouping().

PointMap HoughGrouping::anglemap_
private

Definition at line 98 of file HoughGrouping.h.

double HoughGrouping::angletan_
private

Definition at line 81 of file HoughGrouping.h.

Referenced by HoughGrouping().

bool HoughGrouping::debug_
private

Definition at line 78 of file HoughGrouping.h.

Referenced by HoughGrouping().

std::map<unsigned short int, DTPrimitive> HoughGrouping::digimap_[8]
private

Definition at line 100 of file HoughGrouping.h.

DTGeometry const* HoughGrouping::dtGeo_
private

Definition at line 83 of file HoughGrouping.h.

edm::ESGetToken<DTGeometry, MuonGeometryRecord> HoughGrouping::dtGeomH
private

Definition at line 84 of file HoughGrouping.h.

Referenced by HoughGrouping().

unsigned short int HoughGrouping::halfanglebins_
private

Definition at line 91 of file HoughGrouping.h.

PointsInPlane HoughGrouping::hitvec_
private

Definition at line 103 of file HoughGrouping.h.

unsigned short int HoughGrouping::idigi_
private

Definition at line 92 of file HoughGrouping.h.

std::vector<std::vector<unsigned short int> > HoughGrouping::linespace_
private

Definition at line 96 of file HoughGrouping.h.

unsigned short int HoughGrouping::lowerNumber_
private

Definition at line 79 of file HoughGrouping.h.

Referenced by HoughGrouping().

double HoughGrouping::maxdeltaAng_
private

Definition at line 89 of file HoughGrouping.h.

double HoughGrouping::maxdeltaAngDeg_
private

Definition at line 81 of file HoughGrouping.h.

Referenced by HoughGrouping().

double HoughGrouping::maxdeltaPos_
private

Definition at line 81 of file HoughGrouping.h.

Referenced by HoughGrouping().

double HoughGrouping::maxDistanceToWire_
private

Definition at line 81 of file HoughGrouping.h.

Referenced by HoughGrouping().

PointsInPlane HoughGrouping::maxima_
private

Definition at line 102 of file HoughGrouping.h.

double HoughGrouping::maxrads_
private

Definition at line 87 of file HoughGrouping.h.

double HoughGrouping::minangle_
private

Definition at line 87 of file HoughGrouping.h.

unsigned short int HoughGrouping::minNLayerHits_
private

Definition at line 79 of file HoughGrouping.h.

Referenced by HoughGrouping().

unsigned short int HoughGrouping::minSingleSLHitsMax_
private

Definition at line 79 of file HoughGrouping.h.

Referenced by HoughGrouping().

unsigned short int HoughGrouping::minSingleSLHitsMin_
private

Definition at line 79 of file HoughGrouping.h.

Referenced by HoughGrouping().

unsigned short int HoughGrouping::minUncorrelatedHits_
private

Definition at line 79 of file HoughGrouping.h.

Referenced by HoughGrouping().

unsigned short int HoughGrouping::nhits_
private

Definition at line 92 of file HoughGrouping.h.

double HoughGrouping::oneanglebin_
private

Definition at line 87 of file HoughGrouping.h.

double HoughGrouping::posbinwidth_
private

Definition at line 81 of file HoughGrouping.h.

Referenced by HoughGrouping().

PointMap HoughGrouping::posmap_
private

Definition at line 99 of file HoughGrouping.h.

unsigned short int HoughGrouping::spacebins_
private

Definition at line 91 of file HoughGrouping.h.

DTChamberId HoughGrouping::TheChambId
private

Definition at line 85 of file HoughGrouping.h.

unsigned short int HoughGrouping::thesector_
private

Definition at line 93 of file HoughGrouping.h.

unsigned short int HoughGrouping::thestation_
private

Definition at line 93 of file HoughGrouping.h.

short int HoughGrouping::thewheel_
private

Definition at line 94 of file HoughGrouping.h.

unsigned short int HoughGrouping::upperNumber_
private

Definition at line 79 of file HoughGrouping.h.

Referenced by HoughGrouping().

double HoughGrouping::xhighlim_
private

Definition at line 88 of file HoughGrouping.h.

double HoughGrouping::xlowlim_
private

Definition at line 88 of file HoughGrouping.h.

double HoughGrouping::zhighlim_
private

Definition at line 88 of file HoughGrouping.h.

double HoughGrouping::zlowlim_
private

Definition at line 88 of file HoughGrouping.h.