37 theAlgoName(
"DTCombinatorialExtendedPatternReco"),
42 debug =
pset.getUntrackedParameter<
bool>(
"debug");
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);
72 cout <<
"Reconstructed 2D extended segments " <<
result.back() << endl;
91 vector<std::shared_ptr<DTHitPairForFit>>
result;
92 for (vector<DTRecHit1DPair>::const_iterator
hit =
hits.begin();
hit !=
hits.end(); ++
hit) {
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;
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;
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;
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) {
295 pointsNoLR.push_back((*hit).first);
301 cout <<
"pointsNoLR " << pointsNoLR.size() << endl;
313 cout <<
"extended candidates " << extendedCands.size() << endl;
317 vector<DTSegmentExtendedCand*>::const_iterator bestCandIter = extendedCands.end();
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) {
325 }
else if ((*iter)->nHits() > maxNumHits) {
326 maxNumHits = (*iter)->nHits();
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;
376 cout <<
"----" << endl;
377 cout <<
"All associated " << endl;
386 cout <<
"The Hits are" << endl;
387 copy(pointsSet.begin(), pointsSet.end(), ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
388 cout <<
"----" << endl;
401 if (*(*
cand) == *seg)
410 vector<DTSegmentExtendedCand*>
result;
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;
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);
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;
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)
int superLayer() const
Return the superlayer number.
DTSegmentCleaner * theCleaner
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
std::vector< DTSegmentExtendedCand * > extendCandidates(std::vector< DTSegmentCand *> &candidates, const DTSuperLayer *sl)
std::vector< DTSegmentCand * > buildSegments(const DTSuperLayer *sl, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits)
DTSegmentUpdator * theUpdator
DTCellSide
Which side of the DT cell.
std::vector< DTSegmentCand * > clean(const std::vector< DTSegmentCand *> &inputCands) const
do the cleaning
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< std::shared_ptr< DTHitPairForFit > > hitCont
const DTSuperLayer * superLayer() const
the super layer on which relies
bool good() const override
void update(DTRecSegment4D *seg, const bool calcT0, bool allow3par) const
recompute hits position and refit the segment4D
bool checkDoubleCandidates(std::vector< DTSegmentCand *> &segs, DTSegmentCand *seg)
void setES(const edm::EventSetup &setup)
set the setup
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return a DTSuperLayer given its id.
DTCombinatorialExtendedPatternReco(const edm::ParameterSet &pset, edm::ConsumesCollector)
Constructor.
bool fit(DTSegmentCand *seg, bool allow3par, const bool fitdebug) const
unsigned int nHits() const override
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)
void addClus(const DTSegmentExtendedCand::DTSLRecClusterForFit &clus)
Basic3DVector unit() const
void setES(const edm::EventSetup &setup) override
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.
edm::ESGetToken< DTGeometry, MuonGeometryRecord > theDTGeometryToken
std::set< AssPoint, AssPointLessZ > AssPointCont
hitCont::const_iterator hitIter
std::vector< DTSLRecCluster > theClusters
bool closeSL(const DTSuperLayerId &id1, const DTSuperLayerId &id2)
void buildPointsCollection(std::vector< DTSegmentCand::AssPoint > &points, std::deque< std::shared_ptr< DTHitPairForFit >> &pointsNoLR, std::vector< DTSegmentCand *> &candidates, const DTSuperLayer *sl)
DTSegmentExtendedCand * buildBestSegment(std::vector< DTSegmentCand::AssPoint > &assHits, const DTSuperLayer *sl)
edm::ESHandle< DTGeometry > theDTGeometry
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
DTSuperLayerId id() const
Return the DetId of this SL.
Geom::Theta< T > theta() const