39 debug =
pset.getUntrackedParameter<
bool>(
"debug");
42 string theHitAlgoName =
pset.getParameter<
string>(
"recAlgo");
43 usePairs = !(theHitAlgoName ==
"DTNoDriftAlgo");
51 const DTSuperLayer* sl,
const std::vector<DTRecHit1DPair>& pairs) {
53 cout <<
"DTCombinatorialExtendedPatternReco::reconstruct" << endl;
56 vector<std::shared_ptr<DTHitPairForFit>> hitsForFit =
initHits(sl, pairs);
69 cout <<
"Reconstructed 2D extended segments " <<
result.back() << endl;
88 vector<std::shared_ptr<DTHitPairForFit>>
result;
89 for (vector<DTRecHit1DPair>::const_iterator
hit =
hits.begin();
hit !=
hits.end(); ++
hit) {
96 const DTSuperLayer* sl,
const std::vector<std::shared_ptr<DTHitPairForFit>>&
hits) {
97 typedef vector<std::shared_ptr<DTHitPairForFit>>
hitCont;
98 typedef hitCont::const_iterator
hitIter;
99 vector<DTSegmentCand*>
result;
102 cout <<
"DTCombinatorialExtendedPatternReco::buildSegments: " << sl->
id() <<
" nHits " <<
hits.size() << endl;
103 for (vector<std::shared_ptr<DTHitPairForFit>>::const_iterator
hit =
hits.begin();
hit !=
hits.end(); ++
hit)
112 cout <<
"Warning: this SuperLayer " << sl->
id() <<
" has too many hits : " <<
hits.size() <<
" max allowed is "
114 cout <<
"Skipping segment reconstruction... " << endl;
121 for (hitCont::const_iterator firstHit =
hits.begin(); firstHit !=
hits.end(); ++firstHit) {
122 for (hitCont::const_reverse_iterator lastHit =
hits.rbegin(); (*lastHit) != (*firstHit); ++lastHit) {
124 if (fabs((*lastHit)->id().layerId() - (*firstHit)->id().layerId()) <= 1)
127 cout <<
"Selected these two hits pair " << endl;
128 cout <<
"First " << *(*firstHit) <<
" Layer Id: " << (*firstHit)->id().layerId() << endl;
129 cout <<
"Last " << *(*lastHit) <<
" Layer Id: " << (*lastHit)->id().layerId() << endl;
134 if ((sl->
id()).superlayer() == 2)
140 for (
int firstLR = 0; firstLR < 2; ++firstLR) {
141 for (
int lastLR = 0; lastLR < 2; ++lastLR) {
151 float DAlpha = fabs(gvec.
theta() - gvecIP.
theta());
154 if (DAlpha < DAlphaMax) {
157 LocalPoint posIni = (*firstHit)->localPosition(codes[firstLR]);
158 LocalVector dirIni = ((*lastHit)->localPosition(codes[lastLR]) - posIni).
unit();
163 cout <<
"compatible hits " << assHits.size() << endl;
171 cout <<
"segment " << *seg << endl;
183 cout <<
"result is now " <<
result.size() << endl;
187 cout <<
"already existing" << endl;
197 for (vector<DTSegmentCand*>::const_iterator seg =
result.begin(); seg !=
result.end(); ++seg)
198 cout << *(*seg) << endl;
205 cout <<
"result no ghost " <<
result.size() << endl;
206 for (vector<DTSegmentCand*>::const_iterator seg =
result.begin(); seg !=
result.end(); ++seg)
207 cout << *(*seg) << endl;
218 cout <<
"Pos: " << posIni <<
" Dir: " << dirIni << endl;
219 vector<DTSegmentCand::AssPoint>
result;
223 int nCompatibleHits = 0;
225 typedef vector<std::shared_ptr<DTHitPairForFit>>
hitCont;
226 typedef hitCont::const_iterator
hitIter;
228 pair<bool, bool> isCompatible = (*hit)->isCompatible(posIni, dirIni);
230 cout <<
"isCompatible " << isCompatible.first <<
" " << isCompatible.second << endl;
236 if (isCompatible.first && isCompatible.second) {
240 }
else if (isCompatible.first) {
244 }
else if (isCompatible.second) {
261 cout <<
"Already tried";
262 copy((*t).begin(), (*t).end(), ostream_iterator<int>(
std::cout));
274 cout <<
"DTCombinatorialExtendedPatternReco::buildBestSegment " <<
hits.size() << endl;
275 if (
hits.size() < 3) {
281 vector<DTSegmentCand::AssPoint>
points;
285 deque<std::shared_ptr<DTHitPairForFit>> pointsNoLR;
288 for (vector<DTSegmentCand::AssPoint>::const_iterator
hit =
hits.begin();
hit !=
hits.end(); ++
hit) {
292 pointsNoLR.push_back((*hit).first);
298 cout <<
"pointsNoLR " << pointsNoLR.size() << endl;
310 cout <<
"extended candidates " << extendedCands.size() << endl;
314 vector<DTSegmentExtendedCand*>::const_iterator bestCandIter = extendedCands.end();
316 unsigned int maxNumHits = 0;
317 for (vector<DTSegmentExtendedCand*>::const_iterator iter = extendedCands.begin(); iter != extendedCands.end();
319 if ((*iter)->nHits() == maxNumHits && (*iter)->chi2() <
minChi2) {
322 }
else if ((*iter)->nHits() > maxNumHits) {
323 maxNumHits = (*iter)->nHits();
330 for (vector<DTSegmentExtendedCand*>::iterator iter = extendedCands.begin(); iter != extendedCands.end(); ++iter)
331 if (iter != bestCandIter)
335 if (bestCandIter != extendedCands.end()) {
336 return (*bestCandIter);
342 deque<std::shared_ptr<DTHitPairForFit>>& pointsNoLR,
346 cout <<
"DTCombinatorialExtendedPatternReco::buildPointsCollection " << endl;
347 cout <<
"points: " <<
points.size() <<
" NOLR: " << pointsNoLR.size() << endl;
349 if (!pointsNoLR.empty()) {
350 std::shared_ptr<DTHitPairForFit> unassHit = pointsNoLR.front();
353 cout <<
"Right hit" << endl;
355 pointsNoLR.pop_front();
357 pointsNoLR.push_front((unassHit));
362 cout <<
"Left hit" << endl;
364 pointsNoLR.pop_front();
366 pointsNoLR.push_front((unassHit));
371 cout <<
"The Hits were" << endl;
373 cout <<
"----" << endl;
374 cout <<
"All associated " << endl;
383 cout <<
"The Hits are" << endl;
384 copy(pointsSet.begin(), pointsSet.end(), ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
385 cout <<
"----" << endl;
398 if (*(*
cand) == *seg)
407 vector<DTSegmentExtendedCand*>
result;
415 result.push_back(extendedCand);
422 vector<DTSegmentExtendedCand::DTSLRecClusterForFit> clustersWithPos;
426 cout <<
"SL: " << sl->
id() << endl;
427 for (vector<DTSLRecCluster>::const_iterator clus =
theClusters.begin(); clus !=
theClusters.end(); ++clus) {
429 cout <<
"CLUS: " << (*clus).superLayerId() << endl;
430 if ((*clus).superLayerId().superLayer() == 2 &&
closeSL(sl->
id(), (*clus).superLayerId())) {
440 cout <<
"closeClustersWithPos " << clustersWithPos.size() << endl;
450 for (vector<DTSegmentExtendedCand::DTSLRecClusterForFit>::const_iterator exClus = clustersWithPos.begin();
451 exClus != clustersWithPos.end();
455 cout <<
"is compatible " << endl;
457 extendedCand->
addClus(*exClus);
462 cout <<
"extended cands nHits: " << extendedCand->
nHits() << endl;
465 result.push_back(extendedCand);
467 cout <<
"Bad fit" << endl;
471 result.push_back(extendedCand);
484 int sec1 = (
id1.sector() == 13) ? 4 :
id1.sector();
485 sec1 = (sec1 == 14) ? 10 : sec1;
486 int sec2 = (
id2.sector() == 13) ? 4 :
id2.sector();
487 sec2 = (sec2 == 14) ? 10 : sec2;
489 if (
abs(sec1 - sec2) > 1 &&
abs(sec1 - sec2) != 11)