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);
60 vector<DTSegmentCand*>::const_iterator cand = candidates.begin();
61 while (cand < candidates.end()) {
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) {
88 result.push_back(std::make_shared<DTHitPairForFit>(*
hit, *sl,
theDTGeometry));
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;
107 for (
vector<std::shared_ptr<DTHitPairForFit>>::const_iterator
hit = hits.begin();
hit != hits.end(); ++
hit)
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;
186 result.push_back(seg);
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;
229 for (hitIter
hit = hits.begin();
hit != hits.end(); ++
hit) {
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;
324 cout <<
"candidates " << candidates.size() << endl;
328 vector<DTSegmentCand*>::const_iterator bestCandIter = candidates.end();
329 double minChi2 = 999999.;
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) {
333 minChi2 = (*iter)->chi2();
335 }
else if ((*iter)->nHits() > maxNumHits) {
336 maxNumHits = (*iter)->nHits();
337 minChi2 = (*iter)->chi2();
343 for (vector<DTSegmentCand*>::iterator iter = candidates.begin(); iter != candidates.end(); ++iter)
344 if (iter != bestCandIter)
348 if (bestCandIter != candidates.end()) {
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;
403 candidates.push_back(newCand);
410 for (vector<DTSegmentCand*>::iterator cand = cands.begin(); cand != cands.end(); ++cand)
411 if (*(*cand) == *seg)
std::pair< std::shared_ptr< DTHitPairForFit >, DTEnums::DTCellSide > AssPoint
T getUntrackedParameter(std::string const &, T const &) const
~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
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
DTSegmentCleaner * theCleaner
DTCellSide
Which side of the DT cell.
DTSegmentUpdator * theUpdator
unsigned int theMaxAllowedHits
std::vector< DTSegmentCand * > clean(const std::vector< DTSegmentCand * > &inputCands) const
do the cleaning
virtual bool good() const
std::vector< std::shared_ptr< DTHitPairForFit > > hitCont
const_iterator begin() const
bool checkDoubleCandidates(std::vector< DTSegmentCand * > &segs, DTSegmentCand *seg)
Geom::Theta< T > theta() const
DTSuperLayerId id() const
Return the DetId of this SL.
void setES(const edm::EventSetup &setup)
set the setup
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)
DTCombinatorialPatternReco(const edm::ParameterSet &pset, edm::ConsumesCollector)
Constructor.
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > theDTGeometryToken
void push_back(short unsigned int i)
push back value, and update the hash
std::set< AssPoint, AssPointLessZ > AssPointCont
const_iterator end() const
std::vector< DTSegmentCand * > buildSegments(const DTSuperLayer *sl, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits)
hitCont::const_iterator hitIter
T getParameter(std::string const &) const
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)
void update(DTRecSegment4D *seg, const bool calcT0, bool allow3par) const
recompute hits position and refit the segment4D
TriedPatterns theTriedPattern
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
void setES(const edm::EventSetup &setup) override
bool fit(DTSegmentCand *seg, bool allow3par, const bool fitdebug) const
Basic3DVector unit() const