37 theAlgoName(
"DTCombinatorialExtendedPatternReco"),
45 string theHitAlgoName = pset.
getParameter<
string>(
"recAlgo");
46 usePairs = !(theHitAlgoName ==
"DTNoDriftAlgo");
54 const DTSuperLayer* sl,
const std::vector<DTRecHit1DPair>& pairs) {
56 cout <<
"DTCombinatorialExtendedPatternReco::reconstruct" << endl;
59 vector<std::shared_ptr<DTHitPairForFit>> hitsForFit =
initHits(sl, pairs);
63 vector<DTSegmentCand*>::const_iterator cand = candidates.begin();
64 while (cand < candidates.end()) {
72 cout <<
"Reconstructed 2D extended segments " << result.
back() << endl;
90 const DTSuperLayer* sl,
const std::vector<DTRecHit1DPair>& hits) {
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));
100 typedef vector<std::shared_ptr<DTHitPairForFit>>
hitCont;
101 typedef hitCont::const_iterator
hitIter;
102 vector<DTSegmentCand*>
result;
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)
115 cout <<
"Warning: this SuperLayer " << sl->
id() <<
" has too many hits : " << hits.size() <<
" max allowed is "
117 cout <<
"Skipping segment reconstruction... " << endl;
124 for (hitCont::const_iterator firstHit = hits.begin(); firstHit != hits.end(); ++firstHit) {
125 for (hitCont::const_reverse_iterator lastHit = hits.rbegin(); (*lastHit) != (*firstHit); ++lastHit) {
127 if (fabs((*lastHit)->id().layerId() - (*firstHit)->id().layerId()) <= 1)
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;
137 if ((sl->
id()).superlayer() == 2)
143 for (
int firstLR = 0; firstLR < 2; ++firstLR) {
144 for (
int lastLR = 0; lastLR < 2; ++lastLR) {
154 float DAlpha = fabs(gvec.
theta() - gvecIP.
theta());
157 if (DAlpha < DAlphaMax) {
160 LocalPoint posIni = (*firstHit)->localPosition(codes[firstLR]);
161 LocalVector dirIni = ((*lastHit)->localPosition(codes[lastLR]) - posIni).
unit();
166 cout <<
"compatible hits " << assHits.size() << endl;
174 cout <<
"segment " << *seg << endl;
184 result.push_back(seg);
186 cout <<
"result is now " << result.size() << endl;
190 cout <<
"already existing" << endl;
200 for (vector<DTSegmentCand*>::const_iterator seg = result.begin(); seg != result.end(); ++seg)
201 cout << *(*seg) << endl;
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;
221 cout <<
"Pos: " << posIni <<
" Dir: " << dirIni << endl;
222 vector<DTSegmentCand::AssPoint>
result;
226 int nCompatibleHits = 0;
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);
233 cout <<
"isCompatible " << isCompatible.first <<
" " << isCompatible.second << endl;
239 if (isCompatible.first && isCompatible.second) {
243 }
else if (isCompatible.first) {
247 }
else if (isCompatible.second) {
264 cout <<
"Already tried";
265 copy((*t).begin(), (*t).end(), ostream_iterator<int>(
std::cout));
277 cout <<
"DTCombinatorialExtendedPatternReco::buildBestSegment " << hits.size() << endl;
278 if (hits.size() < 3) {
284 vector<DTSegmentCand::AssPoint> points;
288 deque<std::shared_ptr<DTHitPairForFit>> pointsNoLR;
291 for (vector<DTSegmentCand::AssPoint>::const_iterator
hit = hits.begin();
hit != hits.end(); ++
hit) {
293 points.push_back(*
hit);
295 pointsNoLR.push_back((*hit).first);
300 cout <<
"points " << points.size() << endl;
301 cout <<
"pointsNoLR " << pointsNoLR.size() << endl;
311 vector<DTSegmentExtendedCand*> extendedCands =
extendCandidates(candidates, sl);
313 cout <<
"extended candidates " << extendedCands.size() << endl;
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();
322 if ((*iter)->nHits() == maxNumHits && (*iter)->chi2() < minChi2) {
323 minChi2 = (*iter)->chi2();
325 }
else if ((*iter)->nHits() > maxNumHits) {
326 maxNumHits = (*iter)->nHits();
327 minChi2 = (*iter)->chi2();
333 for (vector<DTSegmentExtendedCand*>::iterator iter = extendedCands.begin(); iter != extendedCands.end(); ++iter)
334 if (iter != bestCandIter)
338 if (bestCandIter != extendedCands.end()) {
339 return (*bestCandIter);
345 deque<std::shared_ptr<DTHitPairForFit>>& pointsNoLR,
349 cout <<
"DTCombinatorialExtendedPatternReco::buildPointsCollection " << endl;
350 cout <<
"points: " << points.size() <<
" NOLR: " << pointsNoLR.size() << endl;
352 if (!pointsNoLR.empty()) {
353 std::shared_ptr<DTHitPairForFit> unassHit = pointsNoLR.front();
356 cout <<
"Right hit" << endl;
358 pointsNoLR.pop_front();
360 pointsNoLR.push_front((unassHit));
365 cout <<
"Left hit" << endl;
367 pointsNoLR.pop_front();
369 pointsNoLR.push_front((unassHit));
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;
383 pointsSet.insert(points.begin(), points.end());
386 cout <<
"The Hits are" << endl;
387 copy(pointsSet.begin(), pointsSet.end(), ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
388 cout <<
"----" << endl;
393 candidates.push_back(newCand);
400 for (vector<DTSegmentCand*>::iterator cand = cands.begin(); cand != cands.end(); ++cand)
401 if (*(*cand) == *seg)
409 cout <<
"extendCandidates " << candidates.size() << endl;
410 vector<DTSegmentExtendedCand*>
result;
414 for (vector<DTSegmentCand*>::const_iterator cand = candidates.begin(); cand != candidates.end(); ++cand) {
418 result.push_back(extendedCand);
425 vector<DTSegmentExtendedCand::DTSLRecClusterForFit> clustersWithPos;
429 cout <<
"SL: " << sl->
id() << endl;
430 for (vector<DTSLRecCluster>::const_iterator clus =
theClusters.begin(); clus !=
theClusters.end(); ++clus) {
432 cout <<
"CLUS: " << (*clus).superLayerId() << endl;
433 if ((*clus).superLayerId().superLayer() == 2 &&
closeSL(sl->
id(), (*clus).superLayerId())) {
443 cout <<
"closeClustersWithPos " << clustersWithPos.size() << endl;
445 for (vector<DTSegmentCand*>::const_iterator cand = candidates.begin(); cand != candidates.end(); ++cand) {
453 for (vector<DTSegmentExtendedCand::DTSLRecClusterForFit>::const_iterator exClus = clustersWithPos.begin();
454 exClus != clustersWithPos.end();
458 cout <<
"is compatible " << endl;
460 extendedCand->
addClus(*exClus);
465 cout <<
"extended cands nHits: " << extendedCand->
nHits() << endl;
468 result.push_back(extendedCand);
470 cout <<
"Bad fit" << endl;
474 result.push_back(extendedCand);
488 sec1 = (sec1 == 14) ? 10 : sec1;
490 sec2 = (sec2 == 14) ? 10 : sec2;
492 if (
abs(sec1 - sec2) > 1 &&
abs(sec1 - sec2) != 11)
std::pair< std::shared_ptr< DTHitPairForFit >, DTEnums::DTCellSide > AssPoint
edm::OwnVector< DTSLRecSegment2D > reconstruct(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits) override
this function is called in the producer
void setClusters(const std::vector< DTSLRecCluster > &clusters)
T getUntrackedParameter(std::string const &, T const &) const
DTSegmentCleaner * theCleaner
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
std::vector< DTSegmentCand * > buildSegments(const DTSuperLayer *sl, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits)
DTSegmentUpdator * theUpdator
DTCellSide
Which side of the DT cell.
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
std::vector< DTSegmentCand * > clean(const std::vector< DTSegmentCand * > &inputCands) const
do the cleaning
bool checkDoubleCandidates(std::vector< DTSegmentCand * > &segs, DTSegmentCand *seg)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< std::shared_ptr< DTHitPairForFit > > hitCont
bool good() const override
Geom::Theta< T > theta() const
DTSuperLayerId id() const
Return the DetId of this SL.
void setES(const edm::EventSetup &setup)
set the setup
DTCombinatorialExtendedPatternReco(const edm::ParameterSet &pset, edm::ConsumesCollector)
Constructor.
unsigned int nHits() const override
void buildPointsCollection(std::vector< DTSegmentCand::AssPoint > &points, std::deque< std::shared_ptr< DTHitPairForFit >> &pointsNoLR, std::vector< DTSegmentCand * > &candidates, const DTSuperLayer *sl)
std::vector< std::shared_ptr< DTHitPairForFit > > initHits(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
std::vector< std::vector< int > > theTriedPattern
Abs< T >::type abs(const T &t)
int superLayer() const
Return the superlayer number.
void addClus(const DTSegmentExtendedCand::DTSLRecClusterForFit &clus)
std::vector< DTSegmentExtendedCand * > extendCandidates(std::vector< DTSegmentCand * > &candidates, const DTSuperLayer *sl)
void setES(const edm::EventSetup &setup) override
const DTSuperLayer * superLayer() const
the super layer on which relies
bool isCompatible(const DTSegmentExtendedCand::DTSLRecClusterForFit &clus)
edm::ESGetToken< DTGeometry, MuonGeometryRecord > theDTGeometryToken
std::set< AssPoint, AssPointLessZ > AssPointCont
hitCont::const_iterator hitIter
std::vector< DTSLRecCluster > theClusters
T getParameter(std::string const &) const
bool closeSL(const DTSuperLayerId &id1, const DTSuperLayerId &id2)
void update(DTRecSegment4D *seg, const bool calcT0, bool allow3par) const
recompute hits position and refit the segment4D
DTSegmentExtendedCand * buildBestSegment(std::vector< DTSegmentCand::AssPoint > &assHits, const DTSuperLayer *sl)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
edm::ESHandle< DTGeometry > theDTGeometry
int wheel() const
Return the wheel number.
std::vector< DTSegmentCand::AssPoint > findCompatibleHits(const LocalPoint &pos, const LocalVector &dir, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits)
~DTCombinatorialExtendedPatternReco() override
Destructor.
unsigned int theMaxAllowedHits
bool fit(DTSegmentCand *seg, bool allow3par, const bool fitdebug) const
Basic3DVector unit() const