46 string theHitAlgoName = pset.
getParameter<
string>(
"recAlgo");
47 usePairs = !(theHitAlgoName==
"DTNoDriftAlgo");
57 const std::vector<DTRecHit1DPair>& pairs){
59 if(
debug)
cout <<
"DTCombinatorialExtendedPatternReco::reconstruct" << endl;
62 vector<DTHitPairForFit*> hitsForFit =
initHits(sl, pairs);
64 vector<DTSegmentCand*> candidates =
buildSegments(sl, hitsForFit);
66 vector<DTSegmentCand*>::const_iterator cand=candidates.begin();
67 while (cand<candidates.end()) {
76 cout<<
"Reconstructed 2D extended segments "<< result.
back() <<endl;
82 for (vector<DTHitPairForFit*>::iterator it = hitsForFit.begin(), ed = hitsForFit.end();
83 it != ed; ++it)
delete *it;
98 vector<DTHitPairForFit*>
100 const std::vector<DTRecHit1DPair>& hits){
102 vector<DTHitPairForFit*>
result;
103 for (vector<DTRecHit1DPair>::const_iterator
hit=hits.begin();
110 vector<DTSegmentCand*>
112 const std::vector<DTHitPairForFit*>& hits){
114 typedef vector<DTHitPairForFit*> hitCont;
115 typedef hitCont::const_iterator hitIter;
116 vector<DTSegmentCand*>
result;
119 cout <<
"DTCombinatorialExtendedPatternReco::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) {
143 if ( fabs((*lastHit)->id().layerId()-(*firstHit)->id().layerId())<=1 )
continue;
145 cout <<
"Selected these two hits pair " << endl;
146 cout <<
"First " << *(*firstHit) <<
" Layer Id: " << (*firstHit)->id().layerId() << endl;
147 cout <<
"Last " << *(*lastHit) <<
" Layer Id: " << (*lastHit)->id().layerId() << endl;
152 if ((sl->
id()).superlayer()==2)
158 for (
int firstLR=0; firstLR<2; ++firstLR) {
159 for (
int lastLR=0; lastLR<2; ++lastLR) {
169 float DAlpha=fabs(gvec.
theta()-gvecIP.
theta());
172 if (DAlpha<DAlphaMax) {
176 LocalPoint posIni = (*firstHit)->localPosition(codes[firstLR]);
178 ((*lastHit)->localPosition(codes[lastLR])-posIni).
unit();
183 cout <<
"compatible hits " << assHits.size() << endl;
191 cout <<
"segment " << *seg<< endl;
202 result.push_back(seg);
204 cout <<
"result is now " << result.size() << endl;
208 cout <<
"already existing" << endl;
218 for (vector<DTSegmentCand*>::const_iterator seg=result.begin();
219 seg!=result.end(); ++seg)
220 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;
239 vector<DTCombinatorialExtendedPatternReco::AssPoint>
242 const vector<DTHitPairForFit*>& hits) {
243 if (
debug)
cout <<
"Pos: " << posIni <<
" Dir: "<< dirIni << endl;
248 int nCompatibleHits=0;
250 typedef vector<DTHitPairForFit*> hitCont;
251 typedef hitCont::const_iterator hitIter;
252 for (hitIter
hit=hits.begin();
hit!=hits.end(); ++
hit) {
253 pair<bool,bool> isCompatible = (*hit)->isCompatible(posIni, dirIni);
255 cout <<
"isCompatible " << isCompatible.first <<
" " <<
256 isCompatible.second << endl;
262 if (isCompatible.first && isCompatible.second) {
267 else if (isCompatible.first) {
272 else if (isCompatible.second) {
293 cout <<
"Already tried";
294 copy((*t).begin(), (*t).end(), ostream_iterator<int>(
std::cout));
306 if (
debug)
cout <<
"DTCombinatorialExtendedPatternReco::buildBestSegment " <<
314 vector<AssPoint> points;
318 deque<DTHitPairForFit* > pointsNoLR;
321 for (vector<AssPoint>::const_iterator
hit=hits.begin();
324 points.push_back(*
hit);
326 pointsNoLR.push_back((*hit).first);
331 cout <<
"points " << points.size() << endl;
332 cout <<
"pointsNoLR " << pointsNoLR.size() << endl;
336 vector<DTSegmentCand*> candidates ;
344 if (
debug)
cout <<
"extended candidates " << extendedCands.size() << endl;
348 vector<DTSegmentExtendedCand*>::const_iterator bestCandIter = extendedCands.end();
350 unsigned int maxNumHits=0;
351 for (vector<DTSegmentExtendedCand*>::const_iterator iter=extendedCands.begin();
352 iter!=extendedCands.end(); ++iter) {
353 if ((*iter)->nHits()==maxNumHits && (*iter)->chi2()<minChi2) {
354 minChi2=(*iter)->chi2();
356 }
else if ((*iter)->nHits()>maxNumHits) {
357 maxNumHits=(*iter)->nHits();
358 minChi2=(*iter)->chi2();
364 for (vector<DTSegmentExtendedCand*>::iterator iter=extendedCands.begin();
365 iter!=extendedCands.end(); ++iter)
366 if (iter!=bestCandIter)
delete (*iter);
369 if (bestCandIter != extendedCands.end()) {
370 return (*bestCandIter);
377 deque<DTHitPairForFit*>& pointsNoLR,
378 vector<DTSegmentCand*>& candidates,
382 cout <<
"DTCombinatorialExtendedPatternReco::buildPointsCollection " << endl;
383 cout <<
"points: " << points.size() <<
" NOLR: " << pointsNoLR.size()<< endl;
385 if (pointsNoLR.size()>0) {
389 cout <<
"Right hit" << endl;
391 pointsNoLR.pop_front();
393 pointsNoLR.push_front((unassHit));
398 cout <<
"Left hit" << endl;
400 pointsNoLR.pop_front();
402 pointsNoLR.push_front((unassHit));
407 cout <<
"The Hits were" << endl;
408 copy(points.begin(), points.end(),
409 ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
410 cout <<
"----" << endl;
411 cout <<
"All associated " << endl;
417 pointsSet.insert(points.begin(),points.end());
420 cout <<
"The Hits are" << endl;
421 copy(pointsSet.begin(), pointsSet.end(),
422 ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
423 cout <<
"----" << endl;
435 for (vector<DTSegmentCand*>::iterator cand=cands.begin();
436 cand!=cands.end(); ++cand)
437 if (*(*cand)==*seg)
return false;
441 vector<DTSegmentExtendedCand*>
444 if (
debug)
cout <<
"extendCandidates " << candidates.size() << endl;
445 vector<DTSegmentExtendedCand*>
result;
449 for (vector<DTSegmentCand*>:: const_iterator cand=candidates.begin();
450 cand!=candidates.end(); ++cand) {
454 result.push_back(extendedCand);
461 vector<DTSegmentExtendedCand::DTSLRecClusterForFit> clustersWithPos;
464 for (vector<DTSLRecCluster>::const_iterator clus=
theClusters.begin();
466 if(
debug)
cout <<
"CLUS: " << (*clus).superLayerId() << endl;
467 if ((*clus).superLayerId().superLayer()==2 &&
closeSL(sl->
id(),(*clus).superLayerId())) {
477 if (
debug)
cout <<
"closeClustersWithPos " << clustersWithPos.size() << endl;
479 for (vector<DTSegmentCand*>:: const_iterator cand=candidates.begin();
480 cand!=candidates.end(); ++cand) {
488 for (vector<DTSegmentExtendedCand::DTSLRecClusterForFit>::const_iterator
489 exClus=clustersWithPos.begin(); exClus!=clustersWithPos.end(); ++exClus) {
491 if (
debug)
cout <<
"is compatible " << endl;
493 extendedCand->
addClus(*exClus);
497 if (
debug)
cout <<
"extended cands nHits: " << extendedCand->
nHits() <<endl;
500 result.push_back(extendedCand);
502 cout <<
"Bad fit" << endl;
506 result.push_back(extendedCand);
515 if (id1==id2)
return false;
519 sec1=(sec1==14)? 10: sec1;
521 sec2=(sec2==14)? 10: sec2;
523 if (
abs(sec1-sec2)>1 &&
abs(sec1-sec2)!=11 )
return false;
T getParameter(std::string const &) const
std::vector< DTHitPairForFit * > initHits(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
T getUntrackedParameter(std::string const &, T const &) const
std::vector< AssPoint > findCompatibleHits(const LocalPoint &pos, const LocalVector &dir, const std::vector< DTHitPairForFit * > &hits)
DTSegmentCleaner * theCleaner
std::vector< DTSegmentCand * > buildSegments(const DTSuperLayer *sl, const std::vector< DTHitPairForFit * > &hits)
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.
virtual edm::OwnVector< DTSLRecSegment2D > reconstruct(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
this function is called in the producer
std::pair< DTHitPairForFit *, DTEnums::DTCellSide > AssPoint
DTSegmentUpdator * theUpdator
DTCellSide
Which side of the DT cell.
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
DTCombinatorialExtendedPatternReco(const edm::ParameterSet &pset)
Constructor.
bool checkDoubleCandidates(std::vector< DTSegmentCand * > &segs, DTSegmentCand *seg)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
virtual void setES(const edm::EventSetup &setup)
virtual bool good() const
Geom::Theta< T > theta() const
DTSegmentExtendedCand * buildBestSegment(std::vector< AssPoint > &assHits, const DTSuperLayer *sl)
DTSuperLayerId id() const
Return the DetId of this SL.
void buildPointsCollection(std::vector< AssPoint > &points, std::deque< DTHitPairForFit * > &pointsNoLR, std::vector< DTSegmentCand * > &candidates, const DTSuperLayer *sl)
void setES(const edm::EventSetup &setup)
set the setup
virtual ~DTCombinatorialExtendedPatternReco()
Destructor.
std::vector< std::vector< int > > theTriedPattern
int superLayer() const
Return the superlayer number.
bool fit(DTSegmentCand *seg) const
void addClus(const DTSegmentExtendedCand::DTSLRecClusterForFit &clus)
std::vector< DTSegmentExtendedCand * > extendCandidates(std::vector< DTSegmentCand * > &candidates, const DTSuperLayer *sl)
void setClusters(std::vector< DTSLRecCluster > clusters)
const DTSuperLayer * superLayer() const
the super layer on which relies
bool isCompatible(const DTSegmentExtendedCand::DTSLRecClusterForFit &clus)
virtual unsigned int nHits() const
std::set< AssPoint, AssPointLessZ > AssPointCont
std::vector< DTSLRecCluster > theClusters
bool closeSL(const DTSuperLayerId &id1, const DTSuperLayerId &id2)
std::vector< DTSegmentCand * > clean(std::vector< DTSegmentCand * > inputCands) const
do the cleaning
edm::ESHandle< DTGeometry > theDTGeometry
int wheel() const
Return the wheel number.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
unsigned int theMaxAllowedHits