CMS 3D CMS Logo

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

#include <DTCombinatorialExtendedPatternReco.h>

Inheritance diagram for DTCombinatorialExtendedPatternReco:
DTRecSegment2DBaseAlgo

Public Member Functions

std::string algoName () const override
 return the algo name More...
 
 DTCombinatorialExtendedPatternReco (const edm::ParameterSet &pset, edm::ConsumesCollector)
 Constructor. More...
 
edm::OwnVector< DTSLRecSegment2Dreconstruct (const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits) override
 this function is called in the producer More...
 
void setClusters (const std::vector< DTSLRecCluster > &clusters)
 
void setES (const edm::EventSetup &setup) override
 
 ~DTCombinatorialExtendedPatternReco () override
 Destructor. More...
 

Private Member Functions

DTSegmentExtendedCandbuildBestSegment (std::vector< DTSegmentCand::AssPoint > &assHits, const DTSuperLayer *sl)
 
void buildPointsCollection (std::vector< DTSegmentCand::AssPoint > &points, std::deque< std::shared_ptr< DTHitPairForFit >> &pointsNoLR, std::vector< DTSegmentCand *> &candidates, const DTSuperLayer *sl)
 
std::vector< DTSegmentCand * > buildSegments (const DTSuperLayer *sl, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits)
 
bool checkDoubleCandidates (std::vector< DTSegmentCand *> &segs, DTSegmentCand *seg)
 
bool closeSL (const DTSuperLayerId &id1, const DTSuperLayerId &id2)
 
std::vector< DTSegmentExtendedCand * > extendCandidates (std::vector< DTSegmentCand *> &candidates, const DTSuperLayer *sl)
 
std::vector< DTSegmentCand::AssPointfindCompatibleHits (const LocalPoint &pos, const LocalVector &dir, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits)
 
std::vector< std::shared_ptr< DTHitPairForFit > > initHits (const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
 
- Private Member Functions inherited from DTRecSegment2DBaseAlgo
 DTRecSegment2DBaseAlgo (const edm::ParameterSet &)
 Constructor. More...
 
virtual ~DTRecSegment2DBaseAlgo ()
 Destructor. More...
 

Private Attributes

bool debug
 
std::string theAlgoName
 
double theAlphaMaxPhi
 
double theAlphaMaxTheta
 
DTSegmentCleanertheCleaner
 
std::vector< DTSLRecClustertheClusters
 
edm::ESHandle< DTGeometrytheDTGeometry
 
edm::ESGetToken< DTGeometry, MuonGeometryRecordtheDTGeometryToken
 
unsigned int theMaxAllowedHits
 
std::vector< std::vector< int > > theTriedPattern
 
DTSegmentUpdatortheUpdator
 
bool usePairs
 

Detailed Description

Algo for reconstructing 2d segment in DT using a combinatorial approach

Author
Stefano Lacaprara - INFN Legnaro stefa.nosp@m.no.l.nosp@m.acapr.nosp@m.ara@.nosp@m.pd.in.nosp@m.fn.i.nosp@m.t
Riccardo Bellan - INFN TO ricca.nosp@m.rdo..nosp@m.bella.nosp@m.n@ce.nosp@m.rn.ch

Definition at line 46 of file DTCombinatorialExtendedPatternReco.h.

Constructor & Destructor Documentation

◆ DTCombinatorialExtendedPatternReco()

DTCombinatorialExtendedPatternReco::DTCombinatorialExtendedPatternReco ( const edm::ParameterSet pset,
edm::ConsumesCollector  cc 
)

Constructor.

Definition at line 34 of file DTCombinatorialExtendedPatternReco.cc.

References gpuPixelDoublets::cc, debug, muonDTDigis_cfi::pset, theAlphaMaxPhi, theAlphaMaxTheta, theCleaner, theMaxAllowedHits, theUpdator, and usePairs.

37  theAlgoName("DTCombinatorialExtendedPatternReco"),
38  theDTGeometryToken(cc.esConsumes()) {
39  theMaxAllowedHits = pset.getParameter<unsigned int>("MaxAllowedHits"); // 100
40  theAlphaMaxTheta = pset.getParameter<double>("AlphaMaxTheta"); // 0.1 ;
41  theAlphaMaxPhi = pset.getParameter<double>("AlphaMaxPhi"); // 1.0 ;
42  debug = pset.getUntrackedParameter<bool>("debug"); //true;
45  string theHitAlgoName = pset.getParameter<string>("recAlgo");
46  usePairs = !(theHitAlgoName == "DTNoDriftAlgo");
47 }
DTRecSegment2DBaseAlgo(const edm::ParameterSet &)
Constructor.
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
edm::ESGetToken< DTGeometry, MuonGeometryRecord > theDTGeometryToken

◆ ~DTCombinatorialExtendedPatternReco()

DTCombinatorialExtendedPatternReco::~DTCombinatorialExtendedPatternReco ( )
override

Destructor.

Definition at line 50 of file DTCombinatorialExtendedPatternReco.cc.

50 {}

Member Function Documentation

◆ algoName()

std::string DTCombinatorialExtendedPatternReco::algoName ( ) const
inlineoverridevirtual

return the algo name

Implements DTRecSegment2DBaseAlgo.

Definition at line 61 of file DTCombinatorialExtendedPatternReco.h.

References theAlgoName.

◆ buildBestSegment()

DTSegmentExtendedCand * DTCombinatorialExtendedPatternReco::buildBestSegment ( std::vector< DTSegmentCand::AssPoint > &  assHits,
const DTSuperLayer sl 
)
private

Definition at line 274 of file DTCombinatorialExtendedPatternReco.cc.

References buildPointsCollection(), HLT_2024v11_cff::candidates, gather_cfg::cout, debug, extendCandidates(), hfClusterShapes_cfi::hits, MTVHistoProducerAlgoForTrackerBlock_cfi::minChi2, hiPixelPairStep_cff::points, and DTEnums::undefLR.

Referenced by buildSegments().

275  {
276  if (debug)
277  cout << "DTCombinatorialExtendedPatternReco::buildBestSegment " << hits.size() << endl;
278  if (hits.size() < 3) {
279  //cout << "buildBestSegment: hits " << hits.size()<< endl;
280  return nullptr; // a least 3 point
281  }
282 
283  // hits with defined LR
284  vector<DTSegmentCand::AssPoint> points;
285 
286  // without: I store both L and R, a deque since I need front insertion and
287  // deletion
288  deque<std::shared_ptr<DTHitPairForFit>> pointsNoLR;
289 
290  // first add only the hits with LR assigned
291  for (vector<DTSegmentCand::AssPoint>::const_iterator hit = hits.begin(); hit != hits.end(); ++hit) {
292  if ((*hit).second != DTEnums::undefLR) {
293  points.push_back(*hit);
294  } else { // then also for the undef'd one
295  pointsNoLR.push_back((*hit).first);
296  }
297  }
298 
299  if (debug) {
300  cout << "points " << points.size() << endl;
301  cout << "pointsNoLR " << pointsNoLR.size() << endl;
302  }
303 
304  // build all possible candidates using L/R ambiguity
305  vector<DTSegmentCand*> candidates;
306 
307  buildPointsCollection(points, pointsNoLR, candidates, sl);
308 
309  // here I try to add the external clusters and build a set of "extended
310  // segment candidate
311  vector<DTSegmentExtendedCand*> extendedCands = extendCandidates(candidates, sl);
312  if (debug)
313  cout << "extended candidates " << extendedCands.size() << endl;
314 
315  // so now I have build a given number of segments, I should find the best one,
316  // by #hits and chi2.
317  vector<DTSegmentExtendedCand*>::const_iterator bestCandIter = extendedCands.end();
318  double minChi2 = 999999.;
319  unsigned int maxNumHits = 0;
320  for (vector<DTSegmentExtendedCand*>::const_iterator iter = extendedCands.begin(); iter != extendedCands.end();
321  ++iter) {
322  if ((*iter)->nHits() == maxNumHits && (*iter)->chi2() < minChi2) {
323  minChi2 = (*iter)->chi2();
324  bestCandIter = iter;
325  } else if ((*iter)->nHits() > maxNumHits) {
326  maxNumHits = (*iter)->nHits();
327  minChi2 = (*iter)->chi2();
328  bestCandIter = iter;
329  }
330  }
331 
332  // delete all candidates but the best one!
333  for (vector<DTSegmentExtendedCand*>::iterator iter = extendedCands.begin(); iter != extendedCands.end(); ++iter)
334  if (iter != bestCandIter)
335  delete (*iter);
336 
337  // return the best candate if any
338  if (bestCandIter != extendedCands.end()) {
339  return (*bestCandIter);
340  }
341  return nullptr;
342 }
std::vector< DTSegmentExtendedCand * > extendCandidates(std::vector< DTSegmentCand *> &candidates, const DTSuperLayer *sl)
void buildPointsCollection(std::vector< DTSegmentCand::AssPoint > &points, std::deque< std::shared_ptr< DTHitPairForFit >> &pointsNoLR, std::vector< DTSegmentCand *> &candidates, const DTSuperLayer *sl)

◆ buildPointsCollection()

void DTCombinatorialExtendedPatternReco::buildPointsCollection ( std::vector< DTSegmentCand::AssPoint > &  points,
std::deque< std::shared_ptr< DTHitPairForFit >> &  pointsNoLR,
std::vector< DTSegmentCand *> &  candidates,
const DTSuperLayer sl 
)
private

build collection of compatible hits for L/R hits: the candidates is updated with the segment candidates found

Definition at line 344 of file DTCombinatorialExtendedPatternReco.cc.

References HLT_2024v11_cff::candidates, filterCSVwithJSON::copy, gather_cfg::cout, debug, DTSegmentUpdator::fit(), DTEnums::Left, hiPixelPairStep_cff::points, DTEnums::Right, and theUpdator.

Referenced by buildBestSegment().

347  {
348  if (debug) {
349  cout << "DTCombinatorialExtendedPatternReco::buildPointsCollection " << endl;
350  cout << "points: " << points.size() << " NOLR: " << pointsNoLR.size() << endl;
351  }
352  if (!pointsNoLR.empty()) { // still unassociated points!
353  std::shared_ptr<DTHitPairForFit> unassHit = pointsNoLR.front();
354  // try with the right
355  if (debug)
356  cout << "Right hit" << endl;
357  points.push_back(DTSegmentCand::AssPoint(unassHit, DTEnums::Right));
358  pointsNoLR.pop_front();
359  buildPointsCollection(points, pointsNoLR, candidates, sl);
360  pointsNoLR.push_front((unassHit));
361  points.pop_back();
362 
363  // try with the left
364  if (debug)
365  cout << "Left hit" << endl;
366  points.push_back(DTSegmentCand::AssPoint(unassHit, DTEnums::Left));
367  pointsNoLR.pop_front();
368  buildPointsCollection(points, pointsNoLR, candidates, sl);
369  pointsNoLR.push_front((unassHit));
370  points.pop_back();
371  } else { // all associated
372 
373  if (debug) {
374  cout << "The Hits were" << endl;
375  copy(points.begin(), points.end(), ostream_iterator<DTSegmentCand::AssPoint>(std::cout));
376  cout << "----" << endl;
377  cout << "All associated " << endl;
378  }
379  DTSegmentCand::AssPointCont pointsSet;
380 
381  // for (vector<DTSegmentCand::AssPoint>::const_iterator point=points.begin();
382  // point!=points.end(); ++point)
383  pointsSet.insert(points.begin(), points.end());
384 
385  if (debug) {
386  cout << "The Hits are" << endl;
387  copy(pointsSet.begin(), pointsSet.end(), ostream_iterator<DTSegmentCand::AssPoint>(std::cout));
388  cout << "----" << endl;
389  }
390 
391  DTSegmentCand* newCand = new DTSegmentCand(pointsSet, sl);
392  if (theUpdator->fit(newCand, false, false))
393  candidates.push_back(newCand);
394  else
395  delete newCand; // bad seg, too few hits
396  }
397 }
std::pair< std::shared_ptr< DTHitPairForFit >, DTEnums::DTCellSide > AssPoint
Definition: DTSegmentCand.h:36
bool fit(DTSegmentCand *seg, bool allow3par, const bool fitdebug) const
std::set< AssPoint, AssPointLessZ > AssPointCont
Definition: DTSegmentCand.h:38
void buildPointsCollection(std::vector< DTSegmentCand::AssPoint > &points, std::deque< std::shared_ptr< DTHitPairForFit >> &pointsNoLR, std::vector< DTSegmentCand *> &candidates, const DTSuperLayer *sl)

◆ buildSegments()

vector< DTSegmentCand * > DTCombinatorialExtendedPatternReco::buildSegments ( const DTSuperLayer sl,
const std::vector< std::shared_ptr< DTHitPairForFit >> &  hits 
)
private

get two hits in different layers and see if there are other / hits

Definition at line 98 of file DTCombinatorialExtendedPatternReco.cc.

References buildBestSegment(), checkDoubleCandidates(), DTSegmentCleaner::clean(), gather_cfg::cout, debug, findCompatibleHits(), DTSegmentExtendedCand::good(), hfClusterShapes_cfi::hits, DTSuperLayer::id(), listHistos::IP, DTEnums::Left, mps_fire::result, DTEnums::Right, theAlphaMaxPhi, theAlphaMaxTheta, theCleaner, theMaxAllowedHits, PV3DBase< T, PVType, FrameType >::theta(), GeomDet::toGlobal(), unit(), and trackerHitRTTI::vector.

Referenced by reconstruct().

99  {
100  typedef vector<std::shared_ptr<DTHitPairForFit>> hitCont;
101  typedef hitCont::const_iterator hitIter;
102  vector<DTSegmentCand*> result;
103 
104  if (debug) {
105  cout << "DTCombinatorialExtendedPatternReco::buildSegments: " << sl->id() << " nHits " << hits.size() << endl;
106  for (vector<std::shared_ptr<DTHitPairForFit>>::const_iterator hit = hits.begin(); hit != hits.end(); ++hit)
107  cout << **hit << endl;
108  }
109 
110  // 10-Mar-2004 SL
111  // put a protection against heavily populated chambers, for which the segment
112  // building could lead to infinite memory usage...
113  if (hits.size() > theMaxAllowedHits) {
114  if (debug) {
115  cout << "Warning: this SuperLayer " << sl->id() << " has too many hits : " << hits.size() << " max allowed is "
116  << theMaxAllowedHits << endl;
117  cout << "Skipping segment reconstruction... " << endl;
118  }
119  return result;
120  }
121 
123  // compatible with them
124  for (hitCont::const_iterator firstHit = hits.begin(); firstHit != hits.end(); ++firstHit) {
125  for (hitCont::const_reverse_iterator lastHit = hits.rbegin(); (*lastHit) != (*firstHit); ++lastHit) {
126  // hits must nor in the same nor in adiacent layers
127  if (fabs((*lastHit)->id().layerId() - (*firstHit)->id().layerId()) <= 1)
128  continue;
129  if (debug) {
130  cout << "Selected these two hits pair " << endl;
131  cout << "First " << *(*firstHit) << " Layer Id: " << (*firstHit)->id().layerId() << endl;
132  cout << "Last " << *(*lastHit) << " Layer Id: " << (*lastHit)->id().layerId() << endl;
133  }
134 
135  GlobalPoint IP;
136  float DAlphaMax;
137  if ((sl->id()).superlayer() == 2) // Theta SL
138  DAlphaMax = theAlphaMaxTheta;
139  else // Phi SL
140  DAlphaMax = theAlphaMaxPhi;
141 
143  for (int firstLR = 0; firstLR < 2; ++firstLR) {
144  for (int lastLR = 0; lastLR < 2; ++lastLR) {
145  // TODO move the global transformation in the DTHitPairForFit class
146  // when it will be moved I will able to remove the sl from the input parameter
147  GlobalPoint gposFirst = sl->toGlobal((*firstHit)->localPosition(codes[firstLR]));
148  GlobalPoint gposLast = sl->toGlobal((*lastHit)->localPosition(codes[lastLR]));
149 
150  GlobalVector gvec = gposLast - gposFirst;
151  GlobalVector gvecIP = gposLast - IP;
152 
153  // difference in angle measured
154  float DAlpha = fabs(gvec.theta() - gvecIP.theta());
155 
156  // cout << "DAlpha " << DAlpha << endl;
157  if (DAlpha < DAlphaMax) {
158  // create a segment hypotesis
159  // I don't need a true segment, just direction and position
160  LocalPoint posIni = (*firstHit)->localPosition(codes[firstLR]);
161  LocalVector dirIni = ((*lastHit)->localPosition(codes[lastLR]) - posIni).unit();
162 
163  // search for other compatible hits, with or without the L/R solved
164  vector<DTSegmentCand::AssPoint> assHits = findCompatibleHits(posIni, dirIni, hits);
165  if (debug)
166  cout << "compatible hits " << assHits.size() << endl;
167 
168  // here return an extended candidate (which _has_ the original
169  // segment)
170  DTSegmentExtendedCand* seg = buildBestSegment(assHits, sl);
171 
172  if (seg) {
173  if (debug)
174  cout << "segment " << *seg << endl;
175 
176  // check if the chi2 and #hits are ok
177  if (!seg->good()) { // good is reimplmented in extended segment
178  delete seg;
179  } else {
180  // remove duplicated segments
181  if (checkDoubleCandidates(result, seg)) {
182  // add to the vector of hypotesis
183  // still work with extended segments
184  result.push_back(seg);
185  if (debug)
186  cout << "result is now " << result.size() << endl;
187  } else { // delete it!
188  delete seg;
189  if (debug)
190  cout << "already existing" << endl;
191  }
192  }
193  }
194  }
195  }
196  }
197  }
198  }
199  if (debug) {
200  for (vector<DTSegmentCand*>::const_iterator seg = result.begin(); seg != result.end(); ++seg)
201  cout << *(*seg) << endl;
202  }
203 
204  // now I have a couple of segment hypotesis, should check for ghost
205  // still with extended candidates
207  if (debug) {
208  cout << "result no ghost " << result.size() << endl;
209  for (vector<DTSegmentCand*>::const_iterator seg = result.begin(); seg != result.end(); ++seg)
210  cout << *(*seg) << endl;
211  }
212 
213  // here, finally, I have to return the set of _original_ segments, not the
214  // extended ones.
215  return result;
216 }
DTCellSide
Which side of the DT cell.
Definition: DTEnums.h:15
std::vector< DTSegmentCand * > clean(const std::vector< DTSegmentCand *> &inputCands) const
do the cleaning
std::vector< std::shared_ptr< DTHitPairForFit > > hitCont
bool good() const override
bool checkDoubleCandidates(std::vector< DTSegmentCand *> &segs, DTSegmentCand *seg)
Basic3DVector unit() const
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
hitCont::const_iterator hitIter
DTSegmentExtendedCand * buildBestSegment(std::vector< DTSegmentCand::AssPoint > &assHits, const DTSuperLayer *sl)
std::vector< DTSegmentCand::AssPoint > findCompatibleHits(const LocalPoint &pos, const LocalVector &dir, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits)
DTSuperLayerId id() const
Return the DetId of this SL.
Definition: DTSuperLayer.cc:34
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72

◆ checkDoubleCandidates()

bool DTCombinatorialExtendedPatternReco::checkDoubleCandidates ( std::vector< DTSegmentCand *> &  segs,
DTSegmentCand seg 
)
private

Definition at line 399 of file DTCombinatorialExtendedPatternReco.cc.

References HLT_2024v11_cff::cands.

Referenced by buildSegments().

399  {
400  for (vector<DTSegmentCand*>::iterator cand = cands.begin(); cand != cands.end(); ++cand)
401  if (*(*cand) == *seg)
402  return false;
403  return true;
404 }

◆ closeSL()

bool DTCombinatorialExtendedPatternReco::closeSL ( const DTSuperLayerId id1,
const DTSuperLayerId id2 
)
private

Definition at line 481 of file DTCombinatorialExtendedPatternReco.cc.

References funct::abs(), globals_cff::id1, and globals_cff::id2.

Referenced by extendCandidates().

481  {
482  if (id1 == id2)
483  return false;
484  if (abs(id1.wheel() - id2.wheel()) > 1)
485  return false;
486  // take into account also sector 13 and 14
487  int sec1 = (id1.sector() == 13) ? 4 : id1.sector();
488  sec1 = (sec1 == 14) ? 10 : sec1;
489  int sec2 = (id2.sector() == 13) ? 4 : id2.sector();
490  sec2 = (sec2 == 14) ? 10 : sec2;
491  // take into account also sector 1/12
492  if (abs(sec1 - sec2) > 1 && abs(sec1 - sec2) != 11)
493  return false;
494  //if (abs(id1.station()-id2.station())>1 ) return false;
495  return true;
496 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ extendCandidates()

vector< DTSegmentExtendedCand * > DTCombinatorialExtendedPatternReco::extendCandidates ( std::vector< DTSegmentCand *> &  candidates,
const DTSuperLayer sl 
)
private

extend the candidates with clusters from external SL

Definition at line 406 of file DTCombinatorialExtendedPatternReco.cc.

References DTSegmentExtendedCand::addClus(), HLT_2024v11_cff::candidates, closeSL(), gather_cfg::cout, debug, submitPVResolutionJobs::err, DTSegmentUpdator::fit(), DTSuperLayer::id(), DTSegmentExtendedCand::isCompatible(), DTSegmentExtendedCand::nHits(), mps_fire::result, DTSuperLayerId::superLayer(), DTSegmentCand::superLayer(), DTGeometry::superLayer(), theClusters, theDTGeometry, theUpdator, GeomDet::toGlobal(), and GeomDet::toLocal().

Referenced by buildBestSegment().

407  {
408  if (debug)
409  cout << "extendCandidates " << candidates.size() << endl;
410  vector<DTSegmentExtendedCand*> result;
411 
412  // in case of phi SL just return
413  if (sl->id().superLayer() != 2) {
414  for (vector<DTSegmentCand*>::const_iterator cand = candidates.begin(); cand != candidates.end(); ++cand) {
415  DTSegmentExtendedCand* extendedCand = new DTSegmentExtendedCand(*cand);
416  // and delete the original candidate
417  delete *cand;
418  result.push_back(extendedCand);
419  }
420  return result;
421  }
422 
423  // first I have to select the cluster which are compatible with the actual
424  // candidate, namely +/-1 sector/station/wheel
425  vector<DTSegmentExtendedCand::DTSLRecClusterForFit> clustersWithPos;
426  if (debug)
427  cout << "AllClustersWithPos " << theClusters.size() << endl;
428  if (debug)
429  cout << "SL: " << sl->id() << endl;
430  for (vector<DTSLRecCluster>::const_iterator clus = theClusters.begin(); clus != theClusters.end(); ++clus) {
431  if (debug)
432  cout << "CLUS: " << (*clus).superLayerId() << endl;
433  if ((*clus).superLayerId().superLayer() == 2 && closeSL(sl->id(), (*clus).superLayerId())) {
434  // and then get their pos in the actual SL frame
435  const DTSuperLayer* clusSl = theDTGeometry->superLayer((*clus).superLayerId());
436  LocalPoint pos = sl->toLocal(clusSl->toGlobal((*clus).localPosition()));
437  //LocalError err=sl->toLocal(clusSl->toGlobal((*clus).localPositionError()));
438  LocalError err = (*clus).localPositionError();
439  clustersWithPos.push_back(DTSegmentExtendedCand::DTSLRecClusterForFit(*clus, pos, err));
440  }
441  }
442  if (debug)
443  cout << "closeClustersWithPos " << clustersWithPos.size() << endl;
444 
445  for (vector<DTSegmentCand*>::const_iterator cand = candidates.begin(); cand != candidates.end(); ++cand) {
446  // create an extended candidate
447  DTSegmentExtendedCand* extendedCand = new DTSegmentExtendedCand(*cand);
448  // and delete the original candidate
449  delete *cand;
450  // do this only for theta SL
451  if (extendedCand->superLayer()->id().superLayer() == 2) {
452  // first check compatibility between cand and clusForFit
453  for (vector<DTSegmentExtendedCand::DTSLRecClusterForFit>::const_iterator exClus = clustersWithPos.begin();
454  exClus != clustersWithPos.end();
455  ++exClus) {
456  if (extendedCand->isCompatible(*exClus)) {
457  if (debug)
458  cout << "is compatible " << endl;
459  // add compatible cluster
460  extendedCand->addClus(*exClus);
461  }
462  }
463  // fit the segment
464  if (debug)
465  cout << "extended cands nHits: " << extendedCand->nHits() << endl;
466  if (theUpdator->fit(extendedCand, false, false)) {
467  // add to result
468  result.push_back(extendedCand);
469  } else {
470  cout << "Bad fit" << endl;
471  delete extendedCand;
472  }
473  } else { // Phi SuperLayer
474  result.push_back(extendedCand);
475  }
476  }
477 
478  return result;
479 }
int superLayer() const
Return the superlayer number.
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
const DTSuperLayer * superLayer() const
the super layer on which relies
Definition: DTSegmentCand.h:76
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return a DTSuperLayer given its id.
Definition: DTGeometry.cc:92
bool fit(DTSegmentCand *seg, bool allow3par, const bool fitdebug) const
unsigned int nHits() const override
void addClus(const DTSegmentExtendedCand::DTSLRecClusterForFit &clus)
bool isCompatible(const DTSegmentExtendedCand::DTSLRecClusterForFit &clus)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
bool closeSL(const DTSuperLayerId &id1, const DTSuperLayerId &id2)
DTSuperLayerId id() const
Return the DetId of this SL.
Definition: DTSuperLayer.cc:34

◆ findCompatibleHits()

vector< DTSegmentCand::AssPoint > DTCombinatorialExtendedPatternReco::findCompatibleHits ( const LocalPoint pos,
const LocalVector dir,
const std::vector< std::shared_ptr< DTHitPairForFit >> &  hits 
)
private

Definition at line 218 of file DTCombinatorialExtendedPatternReco.cc.

References filterCSVwithJSON::copy, gather_cfg::cout, debug, spr::find(), hfClusterShapes_cfi::hits, DTEnums::Left, mps_fire::result, DTEnums::Right, submitPVValidationJobs::t, theTriedPattern, printsummarytable::tried, DTEnums::undefLR, and usePairs.

Referenced by buildSegments().

219  {
220  if (debug)
221  cout << "Pos: " << posIni << " Dir: " << dirIni << endl;
222  vector<DTSegmentCand::AssPoint> result;
223 
224  // counter to early-avoid double counting in hits pattern
225  vector<int> tried;
226  int nCompatibleHits = 0;
227 
228  typedef vector<std::shared_ptr<DTHitPairForFit>> hitCont;
229  typedef hitCont::const_iterator hitIter;
230  for (hitIter hit = hits.begin(); hit != hits.end(); ++hit) {
231  pair<bool, bool> isCompatible = (*hit)->isCompatible(posIni, dirIni);
232  if (debug)
233  cout << "isCompatible " << isCompatible.first << " " << isCompatible.second << endl;
234 
235  // if only one of the two is compatible, then the LR is assigned,
236  // otherwise is undefined
237 
238  DTEnums::DTCellSide lrcode;
239  if (isCompatible.first && isCompatible.second) {
240  usePairs ? lrcode = DTEnums::undefLR : lrcode = DTEnums::Left; // if not usePairs then only use single side
241  tried.push_back(3);
242  nCompatibleHits++;
243  } else if (isCompatible.first) {
244  lrcode = DTEnums::Left;
245  tried.push_back(2);
246  nCompatibleHits++;
247  } else if (isCompatible.second) {
248  lrcode = DTEnums::Right;
249  tried.push_back(1);
250  nCompatibleHits++;
251  } else {
252  tried.push_back(0);
253  continue; // neither is compatible
254  }
255  result.push_back(DTSegmentCand::AssPoint(*hit, lrcode));
256  }
257 
258  // check if too few associated hits or pattern already tried
259  if (nCompatibleHits < 3 || find(theTriedPattern.begin(), theTriedPattern.end(), tried) == theTriedPattern.end()) {
260  theTriedPattern.push_back(tried);
261  } else {
262  if (debug) {
263  vector<vector<int>>::const_iterator t = find(theTriedPattern.begin(), theTriedPattern.end(), tried);
264  cout << "Already tried";
265  copy((*t).begin(), (*t).end(), ostream_iterator<int>(std::cout));
266  cout << endl;
267  }
268  // empty the result vector
269  result.clear();
270  }
271  return result;
272 }
std::pair< std::shared_ptr< DTHitPairForFit >, DTEnums::DTCellSide > AssPoint
Definition: DTSegmentCand.h:36
DTCellSide
Which side of the DT cell.
Definition: DTEnums.h:15
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< std::shared_ptr< DTHitPairForFit > > hitCont
std::vector< std::vector< int > > theTriedPattern
hitCont::const_iterator hitIter

◆ initHits()

vector< std::shared_ptr< DTHitPairForFit > > DTCombinatorialExtendedPatternReco::initHits ( const DTSuperLayer sl,
const std::vector< DTRecHit1DPair > &  hits 
)
private

Definition at line 89 of file DTCombinatorialExtendedPatternReco.cc.

References hfClusterShapes_cfi::hits, mps_fire::result, and theDTGeometry.

Referenced by reconstruct().

90  {
91  vector<std::shared_ptr<DTHitPairForFit>> result;
92  for (vector<DTRecHit1DPair>::const_iterator hit = hits.begin(); hit != hits.end(); ++hit) {
93  result.push_back(std::make_shared<DTHitPairForFit>(*hit, *sl, theDTGeometry));
94  }
95  return result;
96 }

◆ reconstruct()

edm::OwnVector< DTSLRecSegment2D > DTCombinatorialExtendedPatternReco::reconstruct ( const DTSuperLayer sl,
const std::vector< DTRecHit1DPair > &  hits 
)
overridevirtual

this function is called in the producer

Implements DTRecSegment2DBaseAlgo.

Definition at line 53 of file DTCombinatorialExtendedPatternReco.cc.

References buildSegments(), HLT_2024v11_cff::candidates, gather_cfg::cout, debug, initHits(), mps_fire::result, theTriedPattern, theUpdator, and DTSegmentUpdator::update().

Referenced by DTRecSegment2DExtendedProducer::produce().

54  {
55  if (debug)
56  cout << "DTCombinatorialExtendedPatternReco::reconstruct" << endl;
57  theTriedPattern.clear();
59  vector<std::shared_ptr<DTHitPairForFit>> hitsForFit = initHits(sl, pairs);
60 
61  vector<DTSegmentCand*> candidates = buildSegments(sl, hitsForFit);
62 
63  vector<DTSegmentCand*>::const_iterator cand = candidates.begin();
64  while (cand < candidates.end()) {
65  DTSLRecSegment2D* segment = (**cand);
66 
67  theUpdator->update(segment, false);
68 
69  result.push_back(segment);
70 
71  if (debug) {
72  cout << "Reconstructed 2D extended segments " << result.back() << endl;
73  }
74 
75  delete *(cand++); // delete the candidate!
76  }
77 
78  return result;
79 }
std::vector< DTSegmentCand * > buildSegments(const DTSuperLayer *sl, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits)
void update(DTRecSegment4D *seg, const bool calcT0, bool allow3par) const
recompute hits position and refit the segment4D
std::vector< std::shared_ptr< DTHitPairForFit > > initHits(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
std::vector< std::vector< int > > theTriedPattern

◆ setClusters()

void DTCombinatorialExtendedPatternReco::setClusters ( const std::vector< DTSLRecCluster > &  clusters)

◆ setES()

void DTCombinatorialExtendedPatternReco::setES ( const edm::EventSetup setup)
overridevirtual

Through this function the EventSetup is percolated to the objs which request it

Implements DTRecSegment2DBaseAlgo.

Definition at line 81 of file DTCombinatorialExtendedPatternReco.cc.

References DTSegmentUpdator::setES(), singleTopDQM_cfi::setup, theDTGeometry, theDTGeometryToken, and theUpdator.

Referenced by DTRecSegment2DExtendedProducer::produce().

81  {
82  // Get the DT Geometry
85 }
void setES(const edm::EventSetup &setup)
set the setup
edm::ESGetToken< DTGeometry, MuonGeometryRecord > theDTGeometryToken

Member Data Documentation

◆ debug

bool DTCombinatorialExtendedPatternReco::debug
private

◆ theAlgoName

std::string DTCombinatorialExtendedPatternReco::theAlgoName
private

Definition at line 103 of file DTCombinatorialExtendedPatternReco.h.

Referenced by algoName().

◆ theAlphaMaxPhi

double DTCombinatorialExtendedPatternReco::theAlphaMaxPhi
private

◆ theAlphaMaxTheta

double DTCombinatorialExtendedPatternReco::theAlphaMaxTheta
private

◆ theCleaner

DTSegmentCleaner* DTCombinatorialExtendedPatternReco::theCleaner
private

◆ theClusters

std::vector<DTSLRecCluster> DTCombinatorialExtendedPatternReco::theClusters
private

Definition at line 117 of file DTCombinatorialExtendedPatternReco.h.

Referenced by extendCandidates(), and setClusters().

◆ theDTGeometry

edm::ESHandle<DTGeometry> DTCombinatorialExtendedPatternReco::theDTGeometry
private

Definition at line 112 of file DTCombinatorialExtendedPatternReco.h.

Referenced by extendCandidates(), initHits(), and setES().

◆ theDTGeometryToken

edm::ESGetToken<DTGeometry, MuonGeometryRecord> DTCombinatorialExtendedPatternReco::theDTGeometryToken
private

Definition at line 113 of file DTCombinatorialExtendedPatternReco.h.

Referenced by setES().

◆ theMaxAllowedHits

unsigned int DTCombinatorialExtendedPatternReco::theMaxAllowedHits
private

◆ theTriedPattern

std::vector<std::vector<int> > DTCombinatorialExtendedPatternReco::theTriedPattern
private

Definition at line 116 of file DTCombinatorialExtendedPatternReco.h.

Referenced by findCompatibleHits(), and reconstruct().

◆ theUpdator

DTSegmentUpdator* DTCombinatorialExtendedPatternReco::theUpdator
private

◆ usePairs

bool DTCombinatorialExtendedPatternReco::usePairs
private