CMS 3D CMS Logo

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

#include <DTCombinatorialExtendedPatternReco.h>

Inheritance diagram for DTCombinatorialExtendedPatternReco:
DTRecSegment2DBaseAlgo

Public Member Functions

virtual std::string algoName () const
 return the algo name More...
 
 DTCombinatorialExtendedPatternReco (const edm::ParameterSet &pset)
 Constructor. More...
 
virtual edm::OwnVector
< DTSLRecSegment2D
reconstruct (const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
 this function is called in the producer More...
 
void setClusters (const std::vector< DTSLRecCluster > &clusters)
 
virtual void setES (const edm::EventSetup &setup)
 
virtual ~DTCombinatorialExtendedPatternReco ()
 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::AssPoint
findCompatibleHits (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
 
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 42 of file DTCombinatorialExtendedPatternReco.h.

Constructor & Destructor Documentation

DTCombinatorialExtendedPatternReco::DTCombinatorialExtendedPatternReco ( const edm::ParameterSet pset)

Constructor.

Definition at line 35 of file DTCombinatorialExtendedPatternReco.cc.

References debug, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), theAlphaMaxPhi, theAlphaMaxTheta, theCleaner, theMaxAllowedHits, theUpdator, and usePairs.

35  :
36 DTRecSegment2DBaseAlgo(pset), theAlgoName("DTCombinatorialExtendedPatternReco")
37 {
38  theMaxAllowedHits = pset.getParameter<unsigned int>("MaxAllowedHits"); // 100
39  theAlphaMaxTheta = pset.getParameter<double>("AlphaMaxTheta");// 0.1 ;
40  theAlphaMaxPhi = pset.getParameter<double>("AlphaMaxPhi");// 1.0 ;
41  debug = pset.getUntrackedParameter<bool>("debug"); //true;
42  theUpdator = new DTSegmentUpdator(pset);
43  theCleaner = new DTSegmentCleaner(pset);
44  string theHitAlgoName = pset.getParameter<string>("recAlgo");
45  usePairs = !(theHitAlgoName=="DTNoDriftAlgo");
46 }
DTRecSegment2DBaseAlgo(const edm::ParameterSet &)
Constructor.
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
DTCombinatorialExtendedPatternReco::~DTCombinatorialExtendedPatternReco ( )
virtual

Destructor.

Definition at line 49 of file DTCombinatorialExtendedPatternReco.cc.

49  {
50 }

Member Function Documentation

virtual std::string DTCombinatorialExtendedPatternReco::algoName ( void  ) const
inlinevirtual

return the algo name

Implements DTRecSegment2DBaseAlgo.

Definition at line 60 of file DTCombinatorialExtendedPatternReco.h.

References theAlgoName.

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

Definition at line 299 of file DTCombinatorialExtendedPatternReco.cc.

References buildPointsCollection(), gather_cfg::cout, debug, extendCandidates(), getDQMSummary::iter, and DTEnums::undefLR.

Referenced by buildSegments().

300  {
301  if (debug) cout << "DTCombinatorialExtendedPatternReco::buildBestSegment " <<
302  hits.size() << endl;
303  if (hits.size()<3) {
304  //cout << "buildBestSegment: hits " << hits.size()<< endl;
305  return 0; // a least 3 point
306  }
307 
308  // hits with defined LR
309  vector<DTSegmentCand::AssPoint> points;
310 
311  // without: I store both L and R, a deque since I need front insertion and
312  // deletion
313  deque<std::shared_ptr<DTHitPairForFit>> pointsNoLR;
314 
315  // first add only the hits with LR assigned
316  for (vector<DTSegmentCand::AssPoint>::const_iterator hit=hits.begin();
317  hit!=hits.end(); ++hit) {
318  if ((*hit).second != DTEnums::undefLR) {
319  points.push_back(*hit);
320  } else { // then also for the undef'd one
321  pointsNoLR.push_back((*hit).first);
322  }
323  }
324 
325  if(debug) {
326  cout << "points " << points.size() << endl;
327  cout << "pointsNoLR " << pointsNoLR.size() << endl;
328  }
329 
330  // build all possible candidates using L/R ambiguity
331  vector<DTSegmentCand*> candidates ;
332 
333  buildPointsCollection(points, pointsNoLR, candidates, sl);
334 
335  // here I try to add the external clusters and build a set of "extended
336  // segment candidate
337  vector<DTSegmentExtendedCand*> extendedCands = extendCandidates(candidates,
338  sl);
339  if (debug) cout << "extended candidates " << extendedCands.size() << endl;
340 
341  // so now I have build a given number of segments, I should find the best one,
342  // by #hits and chi2.
343  vector<DTSegmentExtendedCand*>::const_iterator bestCandIter = extendedCands.end();
344  double minChi2=999999.;
345  unsigned int maxNumHits=0;
346  for (vector<DTSegmentExtendedCand*>::const_iterator iter=extendedCands.begin();
347  iter!=extendedCands.end(); ++iter) {
348  if ((*iter)->nHits()==maxNumHits && (*iter)->chi2()<minChi2) {
349  minChi2=(*iter)->chi2();
350  bestCandIter=iter;
351  } else if ((*iter)->nHits()>maxNumHits) {
352  maxNumHits=(*iter)->nHits();
353  minChi2=(*iter)->chi2();
354  bestCandIter=iter;
355  }
356  }
357 
358  // delete all candidates but the best one!
359  for (vector<DTSegmentExtendedCand*>::iterator iter=extendedCands.begin();
360  iter!=extendedCands.end(); ++iter)
361  if (iter!=bestCandIter) delete (*iter);
362 
363  // return the best candate if any
364  if (bestCandIter != extendedCands.end()) {
365  return (*bestCandIter);
366  }
367  return 0;
368 }
void buildPointsCollection(std::vector< DTSegmentCand::AssPoint > &points, std::deque< std::shared_ptr< DTHitPairForFit >> &pointsNoLR, std::vector< DTSegmentCand * > &candidates, const DTSuperLayer *sl)
std::vector< DTSegmentExtendedCand * > extendCandidates(std::vector< DTSegmentCand * > &candidates, const DTSuperLayer *sl)
tuple cout
Definition: gather_cfg.py:121
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 371 of file DTCombinatorialExtendedPatternReco.cc.

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

Referenced by buildBestSegment().

374  {
375 
376  if(debug) {
377  cout << "DTCombinatorialExtendedPatternReco::buildPointsCollection " << endl;
378  cout << "points: " << points.size() << " NOLR: " << pointsNoLR.size()<< endl;
379  }
380  if (pointsNoLR.size()>0) { // still unassociated points!
381  std::shared_ptr<DTHitPairForFit> unassHit = pointsNoLR.front();
382  // try with the right
383  if(debug)
384  cout << "Right hit" << endl;
385  points.push_back(DTSegmentCand::AssPoint(unassHit, DTEnums::Right));
386  pointsNoLR.pop_front();
387  buildPointsCollection(points, pointsNoLR, candidates, sl);
388  pointsNoLR.push_front((unassHit));
389  points.pop_back();
390 
391  // try with the left
392  if(debug)
393  cout << "Left hit" << endl;
394  points.push_back(DTSegmentCand::AssPoint(unassHit, DTEnums::Left));
395  pointsNoLR.pop_front();
396  buildPointsCollection(points, pointsNoLR, candidates, sl);
397  pointsNoLR.push_front((unassHit));
398  points.pop_back();
399  } else { // all associated
400 
401  if(debug) {
402  cout << "The Hits were" << endl;
403  copy(points.begin(), points.end(),
404  ostream_iterator<DTSegmentCand::AssPoint>(std::cout));
405  cout << "----" << endl;
406  cout << "All associated " << endl;
407  }
408  DTSegmentCand::AssPointCont pointsSet;
409 
410  // for (vector<DTSegmentCand::AssPoint>::const_iterator point=points.begin();
411  // point!=points.end(); ++point)
412  pointsSet.insert(points.begin(),points.end());
413 
414  if(debug) {
415  cout << "The Hits are" << endl;
416  copy(pointsSet.begin(), pointsSet.end(),
417  ostream_iterator<DTSegmentCand::AssPoint>(std::cout));
418  cout << "----" << endl;
419  }
420 
421  DTSegmentCand* newCand = new DTSegmentCand(pointsSet,sl);
422  if (theUpdator->fit(newCand,0,0)) candidates.push_back(newCand);
423  else delete newCand; // bad seg, too few hits
424  }
425 }
std::pair< std::shared_ptr< DTHitPairForFit >, DTEnums::DTCellSide > AssPoint
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)
std::set< AssPoint, AssPointLessZ > AssPointCont
Definition: DTSegmentCand.h:40
tuple cout
Definition: gather_cfg.py:121
bool fit(DTSegmentCand *seg, bool allow3par, const bool fitdebug) const
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 106 of file DTCombinatorialExtendedPatternReco.cc.

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

Referenced by reconstruct().

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

Definition at line 428 of file DTCombinatorialExtendedPatternReco.cc.

Referenced by buildSegments().

429  {
430  for (vector<DTSegmentCand*>::iterator cand=cands.begin();
431  cand!=cands.end(); ++cand)
432  if (*(*cand)==*seg) return false;
433  return true;
434 }
bool DTCombinatorialExtendedPatternReco::closeSL ( const DTSuperLayerId id1,
const DTSuperLayerId id2 
)
private

Definition at line 508 of file DTCombinatorialExtendedPatternReco.cc.

References funct::abs(), DTChamberId::sector(), and DTChamberId::wheel().

Referenced by extendCandidates().

509  {
510  if (id1==id2) return false;
511  if (abs(id1.wheel()-id2.wheel())>1 ) return false;
512  // take into account also sector 13 and 14
513  int sec1 = ( id1.sector()==13 ) ? 4: id1.sector();
514  sec1=(sec1==14)? 10: sec1;
515  int sec2 = ( id2.sector()==13 ) ? 4: id2.sector();
516  sec2=(sec2==14)? 10: sec2;
517  // take into account also sector 1/12
518  if (abs(sec1-sec2)>1 && abs(sec1-sec2)!=11 ) return false;
519  //if (abs(id1.station()-id2.station())>1 ) return false;
520  return true;
521 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int sector() const
Definition: DTChamberId.h:61
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
vector< DTSegmentExtendedCand * > DTCombinatorialExtendedPatternReco::extendCandidates ( std::vector< DTSegmentCand * > &  candidates,
const DTSuperLayer sl 
)
private

extend the candidates with clusters from external SL

Definition at line 437 of file DTCombinatorialExtendedPatternReco.cc.

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

Referenced by buildBestSegment().

438  {
439  if (debug) cout << "extendCandidates " << candidates.size() << endl;
440  vector<DTSegmentExtendedCand*> result;
441 
442  // in case of phi SL just return
443  if (sl->id().superLayer() != 2 ) {
444  for (vector<DTSegmentCand*>:: const_iterator cand=candidates.begin();
445  cand!=candidates.end(); ++cand) {
446  DTSegmentExtendedCand* extendedCand = new DTSegmentExtendedCand(*cand);
447  // and delete the original candidate
448  delete *cand;
449  result.push_back(extendedCand);
450  }
451  return result;
452  }
453 
454  // first I have to select the cluster which are compatible with the actual
455  // candidate, namely +/-1 sector/station/wheel
456  vector<DTSegmentExtendedCand::DTSLRecClusterForFit> clustersWithPos;
457  if (debug) cout << "AllClustersWithPos " << theClusters.size() << endl;
458  if(debug) cout << "SL: " << sl->id() << endl;
459  for (vector<DTSLRecCluster>::const_iterator clus=theClusters.begin();
460  clus!=theClusters.end(); ++clus) {
461  if(debug) cout << "CLUS: " << (*clus).superLayerId() << endl;
462  if ((*clus).superLayerId().superLayer()==2 && closeSL(sl->id(),(*clus).superLayerId())) {
463  // and then get their pos in the actual SL frame
464  const DTSuperLayer* clusSl =
465  theDTGeometry->superLayer((*clus).superLayerId());
466  LocalPoint pos=sl->toLocal(clusSl->toGlobal((*clus).localPosition()));
467  //LocalError err=sl->toLocal(clusSl->toGlobal((*clus).localPositionError()));
468  LocalError err=(*clus).localPositionError();
469  clustersWithPos.push_back(DTSegmentExtendedCand::DTSLRecClusterForFit(*clus, pos, err) );
470  }
471  }
472  if (debug) cout << "closeClustersWithPos " << clustersWithPos.size() << endl;
473 
474  for (vector<DTSegmentCand*>:: const_iterator cand=candidates.begin();
475  cand!=candidates.end(); ++cand) {
476  // create an extended candidate
477  DTSegmentExtendedCand* extendedCand = new DTSegmentExtendedCand(*cand);
478  // and delete the original candidate
479  delete *cand;
480  // do this only for theta SL
481  if (extendedCand->superLayer()->id().superLayer() == 2 ) {
482  // first check compatibility between cand and clusForFit
483  for (vector<DTSegmentExtendedCand::DTSLRecClusterForFit>::const_iterator
484  exClus=clustersWithPos.begin(); exClus!=clustersWithPos.end(); ++exClus) {
485  if (extendedCand->isCompatible(*exClus)) {
486  if (debug) cout << "is compatible " << endl;
487  // add compatible cluster
488  extendedCand->addClus(*exClus);
489  }
490  }
491  // fit the segment
492  if (debug) cout << "extended cands nHits: " << extendedCand->nHits() <<endl;
493  if (theUpdator->fit(extendedCand,0,0)) {
494  // add to result
495  result.push_back(extendedCand);
496  } else {
497  cout << "Bad fit" << endl;
498  delete extendedCand;
499  }
500  } else { // Phi SuperLayer
501  result.push_back(extendedCand);
502  }
503  }
504 
505  return result;
506 }
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:62
DTSuperLayerId id() const
Return the DetId of this SL.
Definition: DTSuperLayer.cc:36
tuple result
Definition: query.py:137
int superLayer() const
Return the superlayer number.
void addClus(const DTSegmentExtendedCand::DTSLRecClusterForFit &clus)
const DTSuperLayer * superLayer() const
the super layer on which relies
Definition: DTSegmentCand.h:79
bool isCompatible(const DTSegmentExtendedCand::DTSLRecClusterForFit &clus)
virtual unsigned int nHits() const
bool closeSL(const DTSuperLayerId &id1, const DTSuperLayerId &id2)
tuple cout
Definition: gather_cfg.py:121
bool fit(DTSegmentCand *seg, bool allow3par, const bool fitdebug) const
vector< DTSegmentCand::AssPoint > DTCombinatorialExtendedPatternReco::findCompatibleHits ( const LocalPoint pos,
const LocalVector dir,
const std::vector< std::shared_ptr< DTHitPairForFit >> &  hits 
)
private

Definition at line 235 of file DTCombinatorialExtendedPatternReco.cc.

References filterCSVwithJSON::copy, gather_cfg::cout, debug, spr::find(), DTEnums::Left, query::result, DTEnums::Right, edmStreamStallGrapher::t, theTriedPattern, DTEnums::undefLR, and usePairs.

Referenced by buildSegments().

237  {
238  if (debug) cout << "Pos: " << posIni << " Dir: "<< dirIni << endl;
239  vector<DTSegmentCand::AssPoint> result;
240 
241  // counter to early-avoid double counting in hits pattern
242  vector<int> tried;
243  int nCompatibleHits=0;
244 
245  typedef vector<std::shared_ptr<DTHitPairForFit>> hitCont;
246  typedef hitCont::const_iterator hitIter;
247  for (hitIter hit=hits.begin(); hit!=hits.end(); ++hit) {
248  pair<bool,bool> isCompatible = (*hit)->isCompatible(posIni, dirIni);
249  if (debug)
250  cout << "isCompatible " << isCompatible.first << " " <<
251  isCompatible.second << endl;
252 
253  // if only one of the two is compatible, then the LR is assigned,
254  // otherwise is undefined
255 
256  DTEnums::DTCellSide lrcode;
257  if (isCompatible.first && isCompatible.second) {
258  usePairs ? lrcode=DTEnums::undefLR : lrcode=DTEnums::Left ; // if not usePairs then only use single side
259  tried.push_back(3);
260  nCompatibleHits++;
261  }
262  else if (isCompatible.first) {
263  lrcode=DTEnums::Left;
264  tried.push_back(2);
265  nCompatibleHits++;
266  }
267  else if (isCompatible.second) {
268  lrcode=DTEnums::Right;
269  tried.push_back(1);
270  nCompatibleHits++;
271  }
272  else {
273  tried.push_back(0);
274  continue; // neither is compatible
275  }
276  result.push_back(DTSegmentCand::AssPoint(*hit, lrcode));
277  }
278 
279 
280  // check if too few associated hits or pattern already tried
281  if ( nCompatibleHits < 3 || find(theTriedPattern.begin(), theTriedPattern.end(),tried) == theTriedPattern.end()) {
282  theTriedPattern.push_back(tried);
283  } else {
284  if (debug) {
285  vector<vector<int> >::const_iterator t=find(theTriedPattern.begin(),
286  theTriedPattern.end(),
287  tried);
288  cout << "Already tried";
289  copy((*t).begin(), (*t).end(), ostream_iterator<int>(std::cout));
290  cout << endl;
291  }
292  // empty the result vector
293  result.clear();
294  }
295  return result;
296 }
std::pair< std::shared_ptr< DTHitPairForFit >, DTEnums::DTCellSide > AssPoint
Definition: DTSegmentCand.h:38
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:7
std::vector< std::shared_ptr< DTHitPairForFit > > hitCont
std::vector< std::vector< int > > theTriedPattern
tuple result
Definition: query.py:137
hitCont::const_iterator hitIter
tuple cout
Definition: gather_cfg.py:121
vector< std::shared_ptr< DTHitPairForFit > > DTCombinatorialExtendedPatternReco::initHits ( const DTSuperLayer sl,
const std::vector< DTRecHit1DPair > &  hits 
)
private

Definition at line 94 of file DTCombinatorialExtendedPatternReco.cc.

References query::result, and theDTGeometry.

Referenced by reconstruct().

95  {
96 
97  vector<std::shared_ptr<DTHitPairForFit>> result;
98  for (vector<DTRecHit1DPair>::const_iterator hit=hits.begin();
99  hit!=hits.end(); ++hit) {
100  result.push_back(std::make_shared<DTHitPairForFit>(*hit, *sl, theDTGeometry));
101  }
102  return result;
103 }
tuple result
Definition: query.py:137
edm::OwnVector< DTSLRecSegment2D > DTCombinatorialExtendedPatternReco::reconstruct ( const DTSuperLayer sl,
const std::vector< DTRecHit1DPair > &  hits 
)
virtual

this function is called in the producer

Implements DTRecSegment2DBaseAlgo.

Definition at line 54 of file DTCombinatorialExtendedPatternReco.cc.

References edm::OwnVector< T, P >::back(), buildSegments(), gather_cfg::cout, debug, initHits(), edm::OwnVector< T, P >::push_back(), query::result, theTriedPattern, theUpdator, and DTSegmentUpdator::update().

55  {
56 
57  if(debug) cout << "DTCombinatorialExtendedPatternReco::reconstruct" << endl;
58  theTriedPattern.clear();
60  vector<std::shared_ptr<DTHitPairForFit>> hitsForFit = initHits(sl, pairs);
61 
62  vector<DTSegmentCand*> candidates = buildSegments(sl, hitsForFit);
63 
64  vector<DTSegmentCand*>::const_iterator cand=candidates.begin();
65  while (cand<candidates.end()) {
66 
67  DTSLRecSegment2D *segment = (**cand);
68 
69  theUpdator->update(segment,0);
70 
71  result.push_back(segment);
72 
73  if (debug) {
74  cout<<"Reconstructed 2D extended segments "<< result.back() <<endl;
75  }
76 
77  delete *(cand++); // delete the candidate!
78  }
79 
80  return result;
81 }
reference back()
Definition: OwnVector.h:321
std::vector< DTSegmentCand * > buildSegments(const DTSuperLayer *sl, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits)
void push_back(D *&d)
Definition: OwnVector.h:274
std::vector< std::shared_ptr< DTHitPairForFit > > initHits(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
std::vector< std::vector< int > > theTriedPattern
tuple result
Definition: query.py:137
tuple cout
Definition: gather_cfg.py:121
void update(DTRecSegment4D *seg, const bool calcT0, bool allow3par) const
recompute hits position and refit the segment4D
list pairs
sort tag files by run number
void DTCombinatorialExtendedPatternReco::setClusters ( const std::vector< DTSLRecCluster > &  clusters)

Definition at line 89 of file DTCombinatorialExtendedPatternReco.cc.

References theClusters.

89  {
90  theClusters = clusters;
91 }
void DTCombinatorialExtendedPatternReco::setES ( const edm::EventSetup setup)
virtual

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

Implements DTRecSegment2DBaseAlgo.

Definition at line 83 of file DTCombinatorialExtendedPatternReco.cc.

References edm::EventSetup::get(), DTSegmentUpdator::setES(), theDTGeometry, and theUpdator.

83  {
84  // Get the DT Geometry
85  setup.get<MuonGeometryRecord>().get(theDTGeometry);
86  theUpdator->setES(setup);
87 }
void setES(const edm::EventSetup &setup)
set the setup
const T & get() const
Definition: EventSetup.h:55

Member Data Documentation

bool DTCombinatorialExtendedPatternReco::debug
private
std::string DTCombinatorialExtendedPatternReco::theAlgoName
private

Definition at line 108 of file DTCombinatorialExtendedPatternReco.h.

Referenced by algoName().

double DTCombinatorialExtendedPatternReco::theAlphaMaxPhi
private
double DTCombinatorialExtendedPatternReco::theAlphaMaxTheta
private
DTSegmentCleaner* DTCombinatorialExtendedPatternReco::theCleaner
private
std::vector<DTSLRecCluster> DTCombinatorialExtendedPatternReco::theClusters
private

Definition at line 122 of file DTCombinatorialExtendedPatternReco.h.

Referenced by extendCandidates(), and setClusters().

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

Definition at line 117 of file DTCombinatorialExtendedPatternReco.h.

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

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

Definition at line 121 of file DTCombinatorialExtendedPatternReco.h.

Referenced by findCompatibleHits(), and reconstruct().

DTSegmentUpdator* DTCombinatorialExtendedPatternReco::theUpdator
private
bool DTCombinatorialExtendedPatternReco::usePairs
private