CMS 3D CMS Logo

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_
 
const bool debug_
 
std::map< unsigned short int, DTPrimitivedigimap_ [8]
 
DTGeometry const * dtGeo_
 
edm::ESGetToken< DTGeometry, MuonGeometryRecorddtGeomH
 
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::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(), createfilelist::int, LogDebug, lowerNumber_, maxdeltaAngDeg_, maxdeltaPos_, maxDistanceToWire_, minNLayerHits_, minSingleSLHitsMax_, minSingleSLHitsMin_, minUncorrelatedHits_, posbinwidth_, muonDTDigis_cfi::pset, and upperNumber_.

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

◆ ~HoughGrouping()

HoughGrouping::~HoughGrouping ( )
override

Definition at line 84 of file HoughGrouping.cc.

References LogDebug.

84  {
85  if (debug_)
86  LogDebug("HoughGrouping") << "HoughGrouping: destructor" << endl;
87 }
const bool debug_
Definition: HoughGrouping.h:78
#define LogDebug(id)

Member Function Documentation

◆ areThereEnoughHits()

bool HoughGrouping::areThereEnoughHits ( const ProtoCand tupl)
private

Definition at line 865 of file HoughGrouping.cc.

References ProtoCand::dtHits_, and LogDebug.

865  {
866  if (debug_)
867  LogDebug("HoughGrouping") << "areThereEnoughHits";
868  unsigned short int numhitssl1 = 0;
869  unsigned short int numhitssl3 = 0;
870  for (unsigned short int lay = 0; lay < 8; lay++) {
871  if ((tupl.dtHits_[lay].channelId() > 0) && (lay < 4))
872  numhitssl1++;
873  else if (tupl.dtHits_[lay].channelId() > 0)
874  numhitssl3++;
875  }
876 
877  if (debug_)
878  LogDebug("HoughGrouping") << "areThereEnoughHits - Hits in SL1: " << numhitssl1;
879  if (debug_)
880  LogDebug("HoughGrouping") << "areThereEnoughHits - Hits in SL3: " << numhitssl3;
881 
882  if ((numhitssl1 != 0) && (numhitssl3 != 0)) { // Correlated candidates
883  if ((numhitssl1 + numhitssl3) >= minNLayerHits_) {
884  if (numhitssl1 > numhitssl3) {
885  return ((numhitssl1 >= minSingleSLHitsMax_) && (numhitssl3 >= minSingleSLHitsMin_));
886  } else if (numhitssl3 > numhitssl1) {
887  return ((numhitssl3 >= minSingleSLHitsMax_) && (numhitssl1 >= minSingleSLHitsMin_));
888  } else
889  return true;
890  }
891  } else if (allowUncorrelatedPatterns_) { // Uncorrelated candidates
892  return ((numhitssl1 + numhitssl3) >= minNLayerHits_);
893  }
894  return false;
895 }
unsigned short int minNLayerHits_
Definition: HoughGrouping.h:80
DTPrimitives dtHits_
Definition: HoughGrouping.h:26
bool allowUncorrelatedPatterns_
Definition: HoughGrouping.h:79
unsigned short int minSingleSLHitsMin_
Definition: HoughGrouping.h:80
const bool debug_
Definition: HoughGrouping.h:78
unsigned short int minSingleSLHitsMax_
Definition: HoughGrouping.h:80
#define LogDebug(id)

◆ associateHits()

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

◆ doHoughTransform()

void HoughGrouping::doHoughTransform ( )
private

Definition at line 345 of file HoughGrouping.cc.

References funct::cos(), mps_fire::i, LogDebug, PVValHelper::phi, IsoPhotonEBSkim_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:92
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
unsigned short int spacebins_
Definition: HoughGrouping.h:92
const bool debug_
Definition: HoughGrouping.h:78
PointsInPlane hitvec_
double posbinwidth_
Definition: HoughGrouping.h:82
double minangle_
Definition: HoughGrouping.h:88
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
PointMap anglemap_
Definition: HoughGrouping.h:99
std::vector< std::vector< unsigned short int > > linespace_
Definition: HoughGrouping.h:97
double oneanglebin_
Definition: HoughGrouping.h:88
PointMap posmap_
unsigned short int halfanglebins_
Definition: HoughGrouping.h:92
#define LogDebug(id)

◆ findTheMaxima()

PointsInPlane HoughGrouping::findTheMaxima ( PointTuples inputvec)
private

Definition at line 437 of file HoughGrouping.cc.

References dqmdumpme::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:82
U second(std::pair< T, U > const &p)
const bool debug_
Definition: HoughGrouping.h:78
PointInPlane getAveragePoint(const PointTuples &inputvec, unsigned short int firstindex, const std::vector< unsigned short int > &indexlist)
double maxdeltaAng_
Definition: HoughGrouping.h:90
std::vector< PointInPlane > PointsInPlane
Definition: HoughGrouping.h:30
std::pair< double, double > PointInPlane
Definition: HoughGrouping.h:29
#define M_PI
#define LogDebug(id)

◆ finish()

void HoughGrouping::finish ( )
overridevirtual

Reimplemented from MotherGrouping.

Definition at line 262 of file HoughGrouping.cc.

References LogDebug.

Referenced by progressbar.ProgressBar::__next__().

262  {
263  if (debug_)
264  LogDebug("HoughGrouping") << "finish";
265  return;
266 }
const bool debug_
Definition: HoughGrouping.h:78
#define LogDebug(id)

◆ getAveragePoint()

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 JetChargeProducer_cfi::exp, dqmiodumpindices::firstindex, 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 }
auto &__restrict__ ws
const bool debug_
Definition: HoughGrouping.h:78
#define LogDebug(id)

◆ getMaximaVector()

PointsInPlane HoughGrouping::getMaximaVector ( )
private

Definition at line 391 of file HoughGrouping.cc.

References 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:80
unsigned short int anglebins_
Definition: HoughGrouping.h:92
unsigned short int upperNumber_
Definition: HoughGrouping.h:80
unsigned short int spacebins_
Definition: HoughGrouping.h:92
PointsInPlane findTheMaxima(PointTuples &inputvec)
const bool debug_
Definition: HoughGrouping.h:78
PointInPlane transformPair(const PointInPlane &inputpair)
PointMap anglemap_
Definition: HoughGrouping.h:99
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:97
PointMap posmap_
#define LogDebug(id)

◆ getTwoDelta()

PointInPlane HoughGrouping::getTwoDelta ( const PointTuple pair1,
const PointTuple pair2 
)
private

Definition at line 527 of file HoughGrouping.cc.

References funct::abs(), 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 }
const bool debug_
Definition: HoughGrouping.h:78
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define LogDebug(id)

◆ initialise()

void HoughGrouping::initialise ( const edm::EventSetup iEventSetup)
overridevirtual

Reimplemented from MotherGrouping.

Definition at line 92 of file HoughGrouping.cc.

References angle_units::operators::convertDegToRad(), relativeConstraints::geom, edm::EventSetup::get(), createfilelist::int, 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:92
double maxdeltaAngDeg_
Definition: HoughGrouping.h:82
constexpr double convertDegToRad(NumType degrees)
Definition: angle_units.h:27
DTGeometry const * dtGeo_
Definition: HoughGrouping.h:84
const bool debug_
Definition: HoughGrouping.h:78
double posbinwidth_
Definition: HoughGrouping.h:82
double minangle_
Definition: HoughGrouping.h:88
double maxdeltaAng_
Definition: HoughGrouping.h:90
T get() const
Definition: EventSetup.h:79
PointMap anglemap_
Definition: HoughGrouping.h:99
double angletan_
Definition: HoughGrouping.h:82
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomH
Definition: HoughGrouping.h:85
double anglebinwidth_
Definition: HoughGrouping.h:82
#define M_PI
double oneanglebin_
Definition: HoughGrouping.h:88
unsigned short int halfanglebins_
Definition: HoughGrouping.h:92
void resetAttributes()
#define LogDebug(id)

◆ obtainGeometricalBorders()

void HoughGrouping::obtainGeometricalBorders ( const DTLayer lay)
private

Definition at line 308 of file HoughGrouping.cc.

References funct::abs(), DTTopology::cellHeight(), DTTopology::cellWidth(), DTLayer::chamber(), 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:89
unsigned short int thestation_
Definition: HoughGrouping.h:94
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
T z() const
Definition: PV3DBase.h:61
double zhighlim_
Definition: HoughGrouping.h:89
const DTChamber * chamber() const
Definition: DTLayer.cc:45
unsigned short int spacebins_
Definition: HoughGrouping.h:92
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:79
T x() const
Definition: PV3DBase.h:59
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return the superlayer corresponding to the given id.
Definition: DTChamber.cc:53
float cellWidth() const
Returns the cell width.
Definition: DTTopology.h:69
const bool debug_
Definition: HoughGrouping.h:78
double posbinwidth_
Definition: HoughGrouping.h:82
const DTLayer * layer(const DTLayerId &id) const
Return the layer corresponding to the given id.
Definition: DTSuperLayer.cc:54
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const DTTopology & specificTopology() const
Definition: DTLayer.cc:37
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
int lastChannel() const
Returns the wire number of the last wire.
Definition: DTTopology.h:81
float cellHeight() const
Returns the cell height.
Definition: DTTopology.h:71
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:63
#define LogDebug(id)

◆ orderAndFilter()

void HoughGrouping::orderAndFilter ( std::vector< ProtoCand > &  invector,
MuonPathPtrs outMuonPath 
)
private

Definition at line 740 of file HoughGrouping.cc.

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

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

◆ resetAttributes()

void HoughGrouping::resetAttributes ( )
private

Definition at line 271 of file HoughGrouping.cc.

References l1ct::clear(), 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:89
unsigned short int thestation_
Definition: HoughGrouping.h:94
PointsInPlane maxima_
double zhighlim_
Definition: HoughGrouping.h:89
unsigned short int thesector_
Definition: HoughGrouping.h:94
unsigned short int spacebins_
Definition: HoughGrouping.h:92
unsigned short int idigi_
Definition: HoughGrouping.h:93
unsigned short int nhits_
Definition: HoughGrouping.h:93
const bool debug_
Definition: HoughGrouping.h:78
PointsInPlane hitvec_
PointMap posmap_
std::map< unsigned short int, DTPrimitive > digimap_[8]
void clear(EGIsoObj &c)
Definition: egamma.h:82
short int thewheel_
Definition: HoughGrouping.h:95
#define LogDebug(id)

◆ resetPosElementsOfLinespace()

void HoughGrouping::resetPosElementsOfLinespace ( )
private

Definition at line 299 of file HoughGrouping.cc.

References 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:92
const bool debug_
Definition: HoughGrouping.h:78
std::vector< std::vector< unsigned short int > > linespace_
Definition: HoughGrouping.h:97
#define LogDebug(id)

◆ run()

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_2023v12_cff::cands, DTTopology::cellHeight(), DTTopology::cellWidth(), DTLayer::chamber(), 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:89
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
unsigned short int thestation_
Definition: HoughGrouping.h:94
PointsInPlane maxima_
DTGeometry const * dtGeo_
Definition: HoughGrouping.h:84
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
T z() const
Definition: PV3DBase.h:61
ProtoCand associateHits(const DTChamber *thechamb, double m, double n)
double zhighlim_
Definition: HoughGrouping.h:89
void orderAndFilter(std::vector< ProtoCand > &invector, MuonPathPtrs &outMuonPath)
const DTChamber * chamber() const
Definition: DTLayer.cc:45
PointsInPlane getMaximaVector()
unsigned short int thesector_
Definition: HoughGrouping.h:94
unsigned short int idigi_
Definition: HoughGrouping.h:93
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:79
T x() const
Definition: PV3DBase.h:59
unsigned short int nhits_
Definition: HoughGrouping.h:93
T y() const
Definition: PV3DBase.h:60
float cellWidth() const
Returns the cell width.
Definition: DTTopology.h:69
const bool debug_
Definition: HoughGrouping.h:78
PointsInPlane hitvec_
void obtainGeometricalBorders(const DTLayer *lay)
const DTTopology & specificTopology() const
Definition: DTLayer.cc:37
void resetPosElementsOfLinespace()
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
DTChamberId TheChambId
Definition: HoughGrouping.h:86
std::vector< DigiType >::const_iterator const_iterator
void resetAttributes()
std::map< unsigned short int, DTPrimitive > digimap_[8]
int lastChannel() const
Returns the wire number of the last wire.
Definition: DTTopology.h:81
short int thewheel_
Definition: HoughGrouping.h:95
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:90
float cellHeight() const
Returns the cell height.
Definition: DTTopology.h:71
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:63
#define LogDebug(id)
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:96

◆ setDifferenceBetweenSL()

void HoughGrouping::setDifferenceBetweenSL ( ProtoCand tupl)
private

Definition at line 721 of file HoughGrouping.cc.

References ProtoCand::dtHits_, createfilelist::int, LogDebug, and ProtoCand::nHitsDiff_.

721  {
722  if (debug_)
723  LogDebug("HoughGrouping") << "setDifferenceBetweenSL";
724  short int absres = 0;
725  for (unsigned short int lay = 0; lay < 8; lay++) {
726  if (tupl.dtHits_[lay].channelId() > 0) {
727  if (lay <= 3)
728  absres++;
729  else
730  absres--;
731  }
732  }
733 
734  if (absres >= 0)
735  tupl.nHitsDiff_ = absres;
736  else
737  tupl.nHitsDiff_ = (unsigned short int)(-absres);
738 }
DTPrimitives dtHits_
Definition: HoughGrouping.h:26
const bool debug_
Definition: HoughGrouping.h:78
unsigned short int nHitsDiff_
Definition: HoughGrouping.h:24
#define LogDebug(id)

◆ transformPair()

PointInPlane HoughGrouping::transformPair ( const PointInPlane inputpair)
private

Definition at line 427 of file HoughGrouping.cc.

References 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
const bool debug_
Definition: HoughGrouping.h:78
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
#define LogDebug(id)

Member Data Documentation

◆ allowUncorrelatedPatterns_

bool HoughGrouping::allowUncorrelatedPatterns_
private

Definition at line 79 of file HoughGrouping.h.

Referenced by HoughGrouping().

◆ anglebins_

unsigned short int HoughGrouping::anglebins_
private

Definition at line 92 of file HoughGrouping.h.

◆ anglebinwidth_

double HoughGrouping::anglebinwidth_
private

Definition at line 82 of file HoughGrouping.h.

Referenced by HoughGrouping().

◆ anglemap_

PointMap HoughGrouping::anglemap_
private

Definition at line 99 of file HoughGrouping.h.

◆ angletan_

double HoughGrouping::angletan_
private

Definition at line 82 of file HoughGrouping.h.

Referenced by HoughGrouping().

◆ debug_

const bool HoughGrouping::debug_
private

Definition at line 78 of file HoughGrouping.h.

Referenced by HoughGrouping().

◆ digimap_

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

Definition at line 101 of file HoughGrouping.h.

◆ dtGeo_

DTGeometry const* HoughGrouping::dtGeo_
private

Definition at line 84 of file HoughGrouping.h.

◆ dtGeomH

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

Definition at line 85 of file HoughGrouping.h.

Referenced by HoughGrouping().

◆ halfanglebins_

unsigned short int HoughGrouping::halfanglebins_
private

Definition at line 92 of file HoughGrouping.h.

◆ hitvec_

PointsInPlane HoughGrouping::hitvec_
private

Definition at line 104 of file HoughGrouping.h.

◆ idigi_

unsigned short int HoughGrouping::idigi_
private

Definition at line 93 of file HoughGrouping.h.

◆ linespace_

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

Definition at line 97 of file HoughGrouping.h.

◆ lowerNumber_

unsigned short int HoughGrouping::lowerNumber_
private

Definition at line 80 of file HoughGrouping.h.

Referenced by HoughGrouping().

◆ maxdeltaAng_

double HoughGrouping::maxdeltaAng_
private

Definition at line 90 of file HoughGrouping.h.

◆ maxdeltaAngDeg_

double HoughGrouping::maxdeltaAngDeg_
private

Definition at line 82 of file HoughGrouping.h.

Referenced by HoughGrouping().

◆ maxdeltaPos_

double HoughGrouping::maxdeltaPos_
private

Definition at line 82 of file HoughGrouping.h.

Referenced by HoughGrouping().

◆ maxDistanceToWire_

double HoughGrouping::maxDistanceToWire_
private

Definition at line 82 of file HoughGrouping.h.

Referenced by HoughGrouping().

◆ maxima_

PointsInPlane HoughGrouping::maxima_
private

Definition at line 103 of file HoughGrouping.h.

◆ maxrads_

double HoughGrouping::maxrads_
private

Definition at line 88 of file HoughGrouping.h.

◆ minangle_

double HoughGrouping::minangle_
private

Definition at line 88 of file HoughGrouping.h.

◆ minNLayerHits_

unsigned short int HoughGrouping::minNLayerHits_
private

Definition at line 80 of file HoughGrouping.h.

Referenced by HoughGrouping().

◆ minSingleSLHitsMax_

unsigned short int HoughGrouping::minSingleSLHitsMax_
private

Definition at line 80 of file HoughGrouping.h.

Referenced by HoughGrouping().

◆ minSingleSLHitsMin_

unsigned short int HoughGrouping::minSingleSLHitsMin_
private

Definition at line 80 of file HoughGrouping.h.

Referenced by HoughGrouping().

◆ minUncorrelatedHits_

unsigned short int HoughGrouping::minUncorrelatedHits_
private

Definition at line 80 of file HoughGrouping.h.

Referenced by HoughGrouping().

◆ nhits_

unsigned short int HoughGrouping::nhits_
private

Definition at line 93 of file HoughGrouping.h.

◆ oneanglebin_

double HoughGrouping::oneanglebin_
private

Definition at line 88 of file HoughGrouping.h.

◆ posbinwidth_

double HoughGrouping::posbinwidth_
private

Definition at line 82 of file HoughGrouping.h.

Referenced by HoughGrouping().

◆ posmap_

PointMap HoughGrouping::posmap_
private

Definition at line 100 of file HoughGrouping.h.

◆ spacebins_

unsigned short int HoughGrouping::spacebins_
private

Definition at line 92 of file HoughGrouping.h.

◆ TheChambId

DTChamberId HoughGrouping::TheChambId
private

Definition at line 86 of file HoughGrouping.h.

◆ thesector_

unsigned short int HoughGrouping::thesector_
private

Definition at line 94 of file HoughGrouping.h.

◆ thestation_

unsigned short int HoughGrouping::thestation_
private

Definition at line 94 of file HoughGrouping.h.

◆ thewheel_

short int HoughGrouping::thewheel_
private

Definition at line 95 of file HoughGrouping.h.

◆ upperNumber_

unsigned short int HoughGrouping::upperNumber_
private

Definition at line 80 of file HoughGrouping.h.

Referenced by HoughGrouping().

◆ xhighlim_

double HoughGrouping::xhighlim_
private

Definition at line 89 of file HoughGrouping.h.

◆ xlowlim_

double HoughGrouping::xlowlim_
private

Definition at line 89 of file HoughGrouping.h.

◆ zhighlim_

double HoughGrouping::zhighlim_
private

Definition at line 89 of file HoughGrouping.h.

◆ zlowlim_

double HoughGrouping::zlowlim_
private

Definition at line 89 of file HoughGrouping.h.