41 string theHitAlgoName = pset.
getParameter<
string>(
"recAlgo");
42 usePairs = !(theHitAlgoName ==
"DTNoDriftAlgo");
53 const std::vector<DTRecHit1DPair>& pairs) {
55 vector<std::shared_ptr<DTHitPairForFit>> hitsForFit =
initHits(sl, pairs);
59 vector<DTSegmentCand*>::const_iterator
cand = candidates.begin();
60 while (cand < candidates.end()) {
68 cout <<
"Reconstructed 2D segments " << result.
back() << endl;
84 const std::vector<DTRecHit1DPair>&
hits) {
85 vector<std::shared_ptr<DTHitPairForFit>>
result;
86 for (vector<DTRecHit1DPair>::const_iterator
hit = hits.begin();
hit != hits.end(); ++
hit) {
87 result.push_back(std::make_shared<DTHitPairForFit>(*
hit, *sl,
theDTGeometry));
93 const DTSuperLayer* sl,
const std::vector<std::shared_ptr<DTHitPairForFit>>&
hits) {
100 typedef vector<std::shared_ptr<DTHitPairForFit>>
hitCont;
101 typedef hitCont::const_iterator
hitIter;
102 vector<DTSegmentCand*>
result;
105 cout <<
"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) {
128 if (fabs((*lastHit)->id().layerId() - (*firstHit)->id().layerId()) <= 1)
131 cout <<
"Selected these two hits pair " << endl;
132 cout <<
"First " << *(*firstHit) <<
" Layer Id: " << (*firstHit)->id().layerId() << endl;
133 cout <<
"Last " << *(*lastHit) <<
" Layer Id: " << (*lastHit)->id().layerId() << endl;
138 if ((sl->
id()).superlayer() == 2)
144 for (
int firstLR = 0; firstLR < 2; ++firstLR) {
145 for (
int lastLR = 0; lastLR < 2; ++lastLR) {
155 float DAlpha = fabs(gvec.
theta() - gvecIP.
theta());
158 if (DAlpha < DAlphaMax) {
161 LocalPoint posIni = (*firstHit)->localPosition(codes[firstLR]);
162 LocalVector dirIni = ((*lastHit)->localPosition(codes[lastLR]) - posIni).
unit();
167 cout <<
"compatible hits " << assHits.size() << endl;
175 cout <<
"segment " << *seg << endl;
185 result.push_back(seg);
187 cout <<
"result is now " << result.size() << endl;
191 cout <<
"already existing" << endl;
201 for (vector<DTSegmentCand*>::const_iterator seg = result.begin(); seg != result.end(); ++seg)
202 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;
219 cout <<
"Pos: " << posIni <<
" Dir: " << dirIni << endl;
220 vector<DTSegmentCand::AssPoint>
result;
224 int nCompatibleHits = 0;
226 typedef vector<std::shared_ptr<DTHitPairForFit>>
hitCont;
227 typedef hitCont::const_iterator
hitIter;
229 pair<bool, bool> isCompatible = (*hit)->isCompatible(posIni, dirIni);
231 cout <<
"isCompatible " << isCompatible.first <<
" " << isCompatible.second << endl;
237 if (isCompatible.first && isCompatible.second) {
241 }
else if (isCompatible.first) {
245 }
else if (isCompatible.second) {
259 if (nCompatibleHits < 3) {
261 cout <<
"Less than 3 hits ";
272 cout <<
"NOT Already tried ";
278 cout <<
"Already tried ";
291 if (hits.size() < 3) {
297 vector<DTSegmentCand::AssPoint>
points;
301 deque<std::shared_ptr<DTHitPairForFit>> pointsNoLR;
304 for (vector<DTSegmentCand::AssPoint>::const_iterator
hit = hits.begin();
hit != hits.end(); ++
hit) {
306 points.push_back(*
hit);
308 pointsNoLR.push_back((*hit).first);
313 cout <<
"points " << points.size() << endl;
314 cout <<
"pointsNoLR " << pointsNoLR.size() << endl;
323 cout <<
"candidates " << candidates.size() << endl;
327 vector<DTSegmentCand*>::const_iterator bestCandIter = candidates.end();
329 unsigned int maxNumHits = 0;
330 for (vector<DTSegmentCand*>::const_iterator iter = candidates.begin(); iter != candidates.end(); ++iter) {
331 if ((*iter)->nHits() == maxNumHits && (*iter)->chi2() <
minChi2) {
332 minChi2 = (*iter)->chi2();
334 }
else if ((*iter)->nHits() > maxNumHits) {
335 maxNumHits = (*iter)->nHits();
336 minChi2 = (*iter)->chi2();
342 for (vector<DTSegmentCand*>::iterator iter = candidates.begin(); iter != candidates.end(); ++iter)
343 if (iter != bestCandIter)
347 if (bestCandIter != candidates.end()) {
348 return (*bestCandIter);
354 deque<std::shared_ptr<DTHitPairForFit>>& pointsNoLR,
358 cout <<
"buildPointsCollection " << endl;
359 cout <<
"points: " << points.size() <<
" NOLR: " << pointsNoLR.size() << endl;
361 if (!pointsNoLR.empty()) {
362 std::shared_ptr<DTHitPairForFit> unassHit = pointsNoLR.front();
365 cout <<
"Right hit" << endl;
367 pointsNoLR.pop_front();
369 pointsNoLR.push_front((unassHit));
374 cout <<
"Left hit" << endl;
376 pointsNoLR.pop_front();
378 pointsNoLR.push_front((unassHit));
383 cout <<
"The Hits were" << endl;
384 copy(points.begin(), points.end(), ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
385 cout <<
"----" << endl;
386 cout <<
"All associated " << endl;
392 pointsSet.insert(points.begin(), points.end());
395 cout <<
"The Hits are" << endl;
396 copy(pointsSet.begin(), pointsSet.end(), ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
397 cout <<
"----" << endl;
402 candidates.push_back(newCand);
409 for (vector<DTSegmentCand*>::iterator
cand = cands.begin();
cand != cands.end(); ++
cand)
410 if (*(*
cand) == *seg)
std::pair< std::shared_ptr< DTHitPairForFit >, DTEnums::DTCellSide > AssPoint
T getParameter(std::string const &) const
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)
void push_back(short unsigned int i)
push back value, and update the hash
DTCombinatorialPatternReco(const edm::ParameterSet &pset)
Constructor.
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
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
void setES(const edm::EventSetup &setup) override
bool fit(DTSegmentCand *seg, bool allow3par, const bool fitdebug) const
Basic3DVector unit() const