39 debug =
pset.getUntrackedParameter<
bool>(
"debug");
42 string theHitAlgoName =
pset.getParameter<
string>(
"recAlgo");
43 usePairs = !(theHitAlgoName ==
"DTNoDriftAlgo");
54 const std::vector<DTRecHit1DPair>& pairs) {
56 vector<std::shared_ptr<DTHitPairForFit>> hitsForFit =
initHits(sl, pairs);
69 cout <<
"Reconstructed 2D segments " <<
result.back() << endl;
85 const std::vector<DTRecHit1DPair>&
hits) {
86 vector<std::shared_ptr<DTHitPairForFit>>
result;
87 for (vector<DTRecHit1DPair>::const_iterator
hit =
hits.begin();
hit !=
hits.end(); ++
hit) {
101 typedef vector<std::shared_ptr<DTHitPairForFit>>
hitCont;
102 typedef hitCont::const_iterator
hitIter;
103 vector<DTSegmentCand*>
result;
106 cout <<
"buildSegments: " << sl->
id() <<
" nHits " <<
hits.size() << endl;
116 cout <<
"Warning: this SuperLayer " << sl->
id() <<
" has too many hits : " <<
hits.size() <<
" max allowed is " 118 cout <<
"Skipping segment reconstruction... " << endl;
125 for (hitCont::const_iterator firstHit =
hits.begin(); firstHit !=
hits.end(); ++firstHit) {
126 for (hitCont::const_reverse_iterator lastHit =
hits.rbegin(); (*lastHit) != (*firstHit); ++lastHit) {
129 if (fabs((*lastHit)->id().layerId() - (*firstHit)->id().layerId()) <= 1)
132 cout <<
"Selected these two hits pair " << endl;
133 cout <<
"First " << *(*firstHit) <<
" Layer Id: " << (*firstHit)->id().layerId() << endl;
134 cout <<
"Last " << *(*lastHit) <<
" Layer Id: " << (*lastHit)->id().layerId() << endl;
139 if ((sl->
id()).superlayer() == 2)
145 for (
int firstLR = 0; firstLR < 2; ++firstLR) {
146 for (
int lastLR = 0; lastLR < 2; ++lastLR) {
156 float DAlpha = fabs(gvec.
theta() - gvecIP.
theta());
159 if (DAlpha < DAlphaMax) {
162 LocalPoint posIni = (*firstHit)->localPosition(codes[firstLR]);
163 LocalVector dirIni = ((*lastHit)->localPosition(codes[lastLR]) - posIni).
unit();
168 cout <<
"compatible hits " << assHits.size() << endl;
176 cout <<
"segment " << *seg << endl;
188 cout <<
"result is now " <<
result.size() << endl;
192 cout <<
"already existing" << endl;
202 for (vector<DTSegmentCand*>::const_iterator seg =
result.begin(); seg !=
result.end(); ++seg)
203 cout << *(*seg) << endl;
209 cout <<
"result no ghost " <<
result.size() << endl;
210 for (vector<DTSegmentCand*>::const_iterator seg =
result.begin(); seg !=
result.end(); ++seg)
211 cout << *(*seg) << endl;
220 cout <<
"Pos: " << posIni <<
" Dir: " << dirIni << endl;
221 vector<DTSegmentCand::AssPoint>
result;
225 int nCompatibleHits = 0;
227 typedef vector<std::shared_ptr<DTHitPairForFit>>
hitCont;
228 typedef hitCont::const_iterator
hitIter;
230 pair<bool, bool> isCompatible = (*hit)->isCompatible(posIni, dirIni);
232 cout <<
"isCompatible " << isCompatible.first <<
" " << isCompatible.second << endl;
238 if (isCompatible.first && isCompatible.second) {
242 }
else if (isCompatible.first) {
246 }
else if (isCompatible.second) {
260 if (nCompatibleHits < 3) {
262 cout <<
"Less than 3 hits ";
273 cout <<
"NOT Already tried ";
279 cout <<
"Already tried ";
292 if (
hits.size() < 3) {
298 vector<DTSegmentCand::AssPoint> points;
302 deque<std::shared_ptr<DTHitPairForFit>> pointsNoLR;
305 for (vector<DTSegmentCand::AssPoint>::const_iterator
hit =
hits.begin();
hit !=
hits.end(); ++
hit) {
307 points.push_back(*
hit);
309 pointsNoLR.push_back((*hit).first);
314 cout <<
"points " << points.size() << endl;
315 cout <<
"pointsNoLR " << pointsNoLR.size() << endl;
328 vector<DTSegmentCand*>::const_iterator bestCandIter =
candidates.end();
330 unsigned int maxNumHits = 0;
331 for (vector<DTSegmentCand*>::const_iterator iter =
candidates.begin(); iter !=
candidates.end(); ++iter) {
332 if ((*iter)->nHits() == maxNumHits && (*iter)->chi2() <
minChi2) {
335 }
else if ((*iter)->nHits() > maxNumHits) {
336 maxNumHits = (*iter)->nHits();
343 for (vector<DTSegmentCand*>::iterator iter =
candidates.begin(); iter !=
candidates.end(); ++iter)
344 if (iter != bestCandIter)
349 return (*bestCandIter);
355 deque<std::shared_ptr<DTHitPairForFit>>& pointsNoLR,
359 cout <<
"buildPointsCollection " << endl;
360 cout <<
"points: " << points.size() <<
" NOLR: " << pointsNoLR.size() << endl;
362 if (!pointsNoLR.empty()) {
363 std::shared_ptr<DTHitPairForFit> unassHit = pointsNoLR.front();
366 cout <<
"Right hit" << endl;
368 pointsNoLR.pop_front();
370 pointsNoLR.push_front((unassHit));
375 cout <<
"Left hit" << endl;
377 pointsNoLR.pop_front();
379 pointsNoLR.push_front((unassHit));
384 cout <<
"The Hits were" << endl;
385 copy(points.begin(), points.end(), ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
386 cout <<
"----" << endl;
387 cout <<
"All associated " << endl;
393 pointsSet.insert(points.begin(), points.end());
396 cout <<
"The Hits are" << endl;
397 copy(pointsSet.begin(), pointsSet.end(), ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
398 cout <<
"----" << endl;
411 if (*(*
cand) == *seg)
std::pair< std::shared_ptr< DTHitPairForFit >, DTEnums::DTCellSide > AssPoint
~DTCombinatorialPatternReco() override
Destructor.
std::vector< std::shared_ptr< DTHitPairForFit > > initHits(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
edm::OwnVector< DTSLRecSegment2D > reconstruct(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits) override
this function is called in the producer
DTSegmentCleaner * theCleaner
DTCellSide
Which side of the DT cell.
std::vector< DTSegmentCand * > clean(const std::vector< DTSegmentCand *> &inputCands) const
do the cleaning
DTSegmentUpdator * theUpdator
unsigned int theMaxAllowedHits
std::vector< std::shared_ptr< DTHitPairForFit > > hitCont
void update(DTRecSegment4D *seg, const bool calcT0, bool allow3par) const
recompute hits position and refit the segment4D
virtual bool good() const
void setES(const edm::EventSetup &setup)
set the setup
bool fit(DTSegmentCand *seg, bool allow3par, const bool fitdebug) const
edm::ESHandle< DTGeometry > theDTGeometry
void buildPointsCollection(std::vector< DTSegmentCand::AssPoint > &points, std::deque< std::shared_ptr< DTHitPairForFit >> &pointsNoLR, std::vector< DTSegmentCand *> &candidates, const DTSuperLayer *sl)
Basic3DVector unit() const
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
DTCombinatorialPatternReco(const edm::ParameterSet &pset, edm::ConsumesCollector)
Constructor.
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > theDTGeometryToken
std::set< AssPoint, AssPointLessZ > AssPointCont
std::vector< DTSegmentCand * > buildSegments(const DTSuperLayer *sl, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits)
hitCont::const_iterator hitIter
bool checkDoubleCandidates(std::vector< DTSegmentCand *> &segs, DTSegmentCand *seg)
DTSegmentCand * 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)
TriedPatterns theTriedPattern
void setES(const edm::EventSetup &setup) override
DTSuperLayerId id() const
Return the DetId of this SL.
Geom::Theta< T > theta() const