43 string theHitAlgoName = pset.
getParameter<
string>(
"recAlgo");
44 usePairs = !(theHitAlgoName==
"DTNoDriftAlgo");
56 const std::vector<DTRecHit1DPair>& pairs){
59 vector<DTHitPairForFit*> hitsForFit =
initHits(sl, pairs);
61 vector<DTSegmentCand*> candidates =
buildSegments(sl, hitsForFit);
63 vector<DTSegmentCand*>::const_iterator cand=candidates.begin();
64 while (cand<candidates.end()) {
73 cout<<
"Reconstructed 2D segments "<< result.
back() <<endl;
79 for (vector<DTHitPairForFit*>::iterator it = hitsForFit.begin(), ed = hitsForFit.end();
80 it != ed; ++it)
delete *it;
91 vector<DTHitPairForFit*>
93 const std::vector<DTRecHit1DPair>& hits){
95 vector<DTHitPairForFit*>
result;
96 for (vector<DTRecHit1DPair>::const_iterator
hit=hits.begin();
103 vector<DTSegmentCand*>
105 const std::vector<DTHitPairForFit*>& hits){
112 typedef vector<DTHitPairForFit*> hitCont;
113 typedef hitCont::const_iterator hitIter;
114 vector<DTSegmentCand*>
result;
117 cout <<
"buildSegments: " << sl->
id() <<
" nHits " << hits.size() << endl;
118 for (vector<DTHitPairForFit*>::const_iterator
hit=hits.begin();
127 cout <<
"Warning: this SuperLayer " << sl->
id() <<
" has too many hits : "
129 cout <<
"Skipping segment reconstruction... " << endl;
136 for (hitCont::const_iterator firstHit=hits.begin(); firstHit!=hits.end();
138 for (hitCont::const_reverse_iterator lastHit=hits.rbegin();
139 (*lastHit)!=(*firstHit); ++lastHit) {
142 if ( fabs((*lastHit)->id().layerId()-(*firstHit)->id().layerId())<=1 )
continue;
144 cout <<
"Selected these two hits pair " << endl;
145 cout <<
"First " << *(*firstHit) <<
" Layer Id: " << (*firstHit)->id().layerId() << endl;
146 cout <<
"Last " << *(*lastHit) <<
" Layer Id: " << (*lastHit)->id().layerId() << endl;
151 if ((sl->
id()).superlayer()==2)
157 for (
int firstLR=0; firstLR<2; ++firstLR) {
158 for (
int lastLR=0; lastLR<2; ++lastLR) {
168 float DAlpha=fabs(gvec.
theta()-gvecIP.
theta());
171 if (DAlpha<DAlphaMax) {
175 LocalPoint posIni = (*firstHit)->localPosition(codes[firstLR]);
177 ((*lastHit)->localPosition(codes[lastLR])-posIni).
unit();
182 cout <<
"compatible hits " << assHits.size() << endl;
190 cout <<
"segment " << *seg<< endl;
201 result.push_back(seg);
203 cout <<
"result is now " << result.size() << endl;
207 cout <<
"already existing" << endl;
217 for (vector<DTSegmentCand*>::const_iterator seg=result.begin();
218 seg!=result.end(); ++seg)
219 cout << *(*seg) << endl;
225 cout <<
"result no ghost " << result.size() << endl;
226 for (vector<DTSegmentCand*>::const_iterator seg=result.begin();
227 seg!=result.end(); ++seg)
228 cout << *(*seg) << endl;
235 vector<DTCombinatorialPatternReco::AssPoint>
238 const vector<DTHitPairForFit*>& hits) {
239 if (
debug)
cout <<
"Pos: " << posIni <<
" Dir: "<< dirIni << endl;
244 int nCompatibleHits=0;
246 typedef vector<DTHitPairForFit*> hitCont;
247 typedef hitCont::const_iterator hitIter;
248 for (hitIter
hit=hits.begin();
hit!=hits.end(); ++
hit) {
249 pair<bool,bool> isCompatible = (*hit)->isCompatible(posIni, dirIni);
251 cout <<
"isCompatible " << isCompatible.first <<
" " <<
252 isCompatible.second << endl;
258 if (isCompatible.first && isCompatible.second) {
263 else if (isCompatible.first) {
268 else if (isCompatible.second) {
284 if (nCompatibleHits < 3) {
286 cout <<
"Less than 3 hits " ;
297 cout <<
"NOT Already tried " ;
303 cout <<
"Already tried " ;
324 vector<AssPoint> points;
328 deque<DTHitPairForFit* > pointsNoLR;
331 for (vector<AssPoint>::const_iterator
hit=hits.begin();
334 points.push_back(*
hit);
336 pointsNoLR.push_back((*hit).first);
341 cout <<
"points " << points.size() << endl;
342 cout <<
"pointsNoLR " << pointsNoLR.size() << endl;
346 vector<DTSegmentCand*> candidates ;
351 cout <<
"candidates " << candidates.size() << endl;
355 vector<DTSegmentCand*>::const_iterator bestCandIter = candidates.end();
357 unsigned int maxNumHits=0;
358 for (vector<DTSegmentCand*>::const_iterator iter=candidates.begin();
359 iter!=candidates.end(); ++iter) {
360 if ((*iter)->nHits()==maxNumHits && (*iter)->chi2()<minChi2) {
361 minChi2=(*iter)->chi2();
363 }
else if ((*iter)->nHits()>maxNumHits) {
364 maxNumHits=(*iter)->nHits();
365 minChi2=(*iter)->chi2();
371 for (vector<DTSegmentCand*>::iterator iter=candidates.begin();
372 iter!=candidates.end(); ++iter)
if (iter!=bestCandIter)
delete *iter;
375 if (bestCandIter != candidates.end()) {
376 return (*bestCandIter);
383 deque<DTHitPairForFit*>& pointsNoLR,
384 vector<DTSegmentCand*>& candidates,
388 cout <<
"buildPointsCollection " << endl;
389 cout <<
"points: " << points.size() <<
" NOLR: " << pointsNoLR.size()<< endl;
391 if (pointsNoLR.size()>0) {
395 cout <<
"Right hit" << endl;
397 pointsNoLR.pop_front();
399 pointsNoLR.push_front((unassHit));
404 cout <<
"Left hit" << endl;
406 pointsNoLR.pop_front();
408 pointsNoLR.push_front((unassHit));
413 cout <<
"The Hits were" << endl;
414 copy(points.begin(), points.end(),
415 ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
416 cout <<
"----" << endl;
417 cout <<
"All associated " << endl;
423 pointsSet.insert(points.begin(),points.end());
426 cout <<
"The Hits are" << endl;
427 copy(pointsSet.begin(), pointsSet.end(),
428 ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
429 cout <<
"----" << endl;
441 for (vector<DTSegmentCand*>::iterator cand=cands.begin();
442 cand!=cands.end(); ++cand)
443 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)
std::vector< DTSegmentCand * > clean(const std::vector< DTSegmentCand * > &inputCands) const
do the cleaning
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 * > 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