45 string theHitAlgoName = pset.
getParameter<
string>(
"recAlgo");
46 usePairs = !(theHitAlgoName==
"DTNoDriftAlgo");
58 const std::vector<DTRecHit1DPair>& pairs){
61 vector<DTHitPairForFit*> hitsForFit =
initHits(sl, pairs);
63 vector<DTSegmentCand*> candidates =
buildSegments(sl, hitsForFit);
65 vector<DTSegmentCand*>::const_iterator cand=candidates.begin();
66 while (cand<candidates.end()) {
75 cout<<
"Reconstructed 2D segments "<< result.
back() <<endl;
81 for (vector<DTHitPairForFit*>::iterator it = hitsForFit.begin(), ed = hitsForFit.end();
82 it != ed; ++it)
delete *it;
93 vector<DTHitPairForFit*>
95 const std::vector<DTRecHit1DPair>& hits){
97 vector<DTHitPairForFit*>
result;
98 for (vector<DTRecHit1DPair>::const_iterator
hit=hits.begin();
105 vector<DTSegmentCand*>
107 const std::vector<DTHitPairForFit*>& hits){
114 typedef vector<DTHitPairForFit*> hitCont;
115 typedef hitCont::const_iterator hitIter;
116 vector<DTSegmentCand*>
result;
119 cout <<
"buildSegments: " << sl->
id() <<
" nHits " << hits.size() << endl;
120 for (vector<DTHitPairForFit*>::const_iterator
hit=hits.begin();
129 cout <<
"Warning: this SuperLayer " << sl->
id() <<
" has too many hits : "
131 cout <<
"Skipping segment reconstruction... " << endl;
138 for (hitCont::const_iterator firstHit=hits.begin(); firstHit!=hits.end();
140 for (hitCont::const_reverse_iterator lastHit=hits.rbegin();
141 (*lastHit)!=(*firstHit); ++lastHit) {
144 if ( fabs((*lastHit)->id().layerId()-(*firstHit)->id().layerId())<=1 )
continue;
146 cout <<
"Selected these two hits pair " << endl;
147 cout <<
"First " << *(*firstHit) <<
" Layer Id: " << (*firstHit)->id().layerId() << endl;
148 cout <<
"Last " << *(*lastHit) <<
" Layer Id: " << (*lastHit)->id().layerId() << endl;
153 if ((sl->
id()).superlayer()==2)
159 for (
int firstLR=0; firstLR<2; ++firstLR) {
160 for (
int lastLR=0; lastLR<2; ++lastLR) {
170 float DAlpha=fabs(gvec.
theta()-gvecIP.
theta());
173 if (DAlpha<DAlphaMax) {
177 LocalPoint posIni = (*firstHit)->localPosition(codes[firstLR]);
179 ((*lastHit)->localPosition(codes[lastLR])-posIni).
unit();
184 cout <<
"compatible hits " << assHits.size() << endl;
192 cout <<
"segment " << *seg<< endl;
203 result.push_back(seg);
205 cout <<
"result is now " << result.size() << endl;
209 cout <<
"already existing" << endl;
219 for (vector<DTSegmentCand*>::const_iterator seg=result.begin();
220 seg!=result.end(); ++seg)
221 cout << *(*seg) << endl;
227 cout <<
"result no ghost " << result.size() << endl;
228 for (vector<DTSegmentCand*>::const_iterator seg=result.begin();
229 seg!=result.end(); ++seg)
230 cout << *(*seg) << endl;
237 vector<DTCombinatorialPatternReco::AssPoint>
240 const vector<DTHitPairForFit*>& hits) {
241 if (
debug)
cout <<
"Pos: " << posIni <<
" Dir: "<< dirIni << endl;
246 int nCompatibleHits=0;
248 typedef vector<DTHitPairForFit*> hitCont;
249 typedef hitCont::const_iterator hitIter;
250 for (hitIter
hit=hits.begin();
hit!=hits.end(); ++
hit) {
251 pair<bool,bool> isCompatible = (*hit)->isCompatible(posIni, dirIni);
253 cout <<
"isCompatible " << isCompatible.first <<
" " <<
254 isCompatible.second << endl;
260 if (isCompatible.first && isCompatible.second) {
265 else if (isCompatible.first) {
270 else if (isCompatible.second) {
286 if (nCompatibleHits < 3) {
288 cout <<
"Less than 3 hits " ;
299 cout <<
"NOT Already tried " ;
305 cout <<
"Already tried " ;
326 vector<AssPoint> points;
330 deque<DTHitPairForFit* > pointsNoLR;
333 for (vector<AssPoint>::const_iterator
hit=hits.begin();
336 points.push_back(*
hit);
338 pointsNoLR.push_back((*hit).first);
343 cout <<
"points " << points.size() << endl;
344 cout <<
"pointsNoLR " << pointsNoLR.size() << endl;
348 vector<DTSegmentCand*> candidates ;
353 cout <<
"candidates " << candidates.size() << endl;
357 vector<DTSegmentCand*>::const_iterator bestCandIter = candidates.end();
359 unsigned int maxNumHits=0;
360 for (vector<DTSegmentCand*>::const_iterator iter=candidates.begin();
361 iter!=candidates.end(); ++iter) {
362 if ((*iter)->nHits()==maxNumHits && (*iter)->chi2()<minChi2) {
363 minChi2=(*iter)->chi2();
365 }
else if ((*iter)->nHits()>maxNumHits) {
366 maxNumHits=(*iter)->nHits();
367 minChi2=(*iter)->chi2();
373 for (vector<DTSegmentCand*>::iterator iter=candidates.begin();
374 iter!=candidates.end(); ++iter)
if (iter!=bestCandIter)
delete *iter;
377 if (bestCandIter != candidates.end()) {
378 return (*bestCandIter);
385 deque<DTHitPairForFit*>& pointsNoLR,
386 vector<DTSegmentCand*>& candidates,
390 cout <<
"buildPointsCollection " << endl;
391 cout <<
"points: " << points.size() <<
" NOLR: " << pointsNoLR.size()<< endl;
393 if (pointsNoLR.size()>0) {
397 cout <<
"Right hit" << endl;
399 pointsNoLR.pop_front();
401 pointsNoLR.push_front((unassHit));
406 cout <<
"Left hit" << endl;
408 pointsNoLR.pop_front();
410 pointsNoLR.push_front((unassHit));
415 cout <<
"The Hits were" << endl;
416 copy(points.begin(), points.end(),
417 ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
418 cout <<
"----" << endl;
419 cout <<
"All associated " << endl;
425 pointsSet.insert(points.begin(),points.end());
428 cout <<
"The Hits are" << endl;
429 copy(pointsSet.begin(), pointsSet.end(),
430 ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
431 cout <<
"----" << endl;
443 for (vector<DTSegmentCand*>::iterator cand=cands.begin();
444 cand!=cands.end(); ++cand)
445 if (*(*cand)==*seg)
return false;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< DTHitPairForFit * > initHits(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
virtual void setES(const edm::EventSetup &setup)
void update(DTRecSegment4D *seg, const bool calcT0=false) const
recompute hits position and refit the segment4D
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< AssPoint > findCompatibleHits(const LocalPoint &pos, const LocalVector &dir, const std::vector< DTHitPairForFit * > &hits)
virtual bool good() const
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
bool fit(DTSegmentCand *seg) const
virtual edm::OwnVector< DTSLRecSegment2D > reconstruct(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
this function is called in the producer
void buildPointsCollection(std::vector< AssPoint > &points, std::deque< 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
virtual ~DTCombinatorialPatternReco()
Destructor.
std::vector< DTSegmentCand * > clean(std::vector< DTSegmentCand * > inputCands) const
do the cleaning
std::vector< DTSegmentCand * > buildSegments(const DTSuperLayer *sl, const std::vector< DTHitPairForFit * > &hits)
TriedPatterns theTriedPattern
DTSegmentCand * buildBestSegment(std::vector< AssPoint > &assHits, const DTSuperLayer *sl)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
std::pair< DTHitPairForFit *, DTEnums::DTCellSide > AssPoint