44 string theHitAlgoName = pset.
getParameter<
string>(
"recAlgo");
45 usePairs = !(theHitAlgoName==
"DTNoDriftAlgo");
55 const std::vector<DTRecHit1DPair>& pairs){
57 if(
debug)
cout <<
"DTCombinatorialExtendedPatternReco::reconstruct" << endl;
60 vector<DTHitPairForFit*> hitsForFit =
initHits(sl, pairs);
62 vector<DTSegmentCand*> candidates =
buildSegments(sl, hitsForFit);
64 vector<DTSegmentCand*>::const_iterator cand=candidates.begin();
65 while (cand<candidates.end()) {
74 cout<<
"Reconstructed 2D extended segments "<< result.
back() <<endl;
80 for (vector<DTHitPairForFit*>::iterator it = hitsForFit.begin(), ed = hitsForFit.end();
81 it != ed; ++it)
delete *it;
96 vector<DTHitPairForFit*>
98 const std::vector<DTRecHit1DPair>& hits){
100 vector<DTHitPairForFit*>
result;
101 for (vector<DTRecHit1DPair>::const_iterator
hit=hits.begin();
108 vector<DTSegmentCand*>
110 const std::vector<DTHitPairForFit*>& hits){
112 typedef vector<DTHitPairForFit*> hitCont;
113 typedef hitCont::const_iterator hitIter;
114 vector<DTSegmentCand*>
result;
117 cout <<
"DTCombinatorialExtendedPatternReco::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) {
141 if ( fabs((*lastHit)->id().layerId()-(*firstHit)->id().layerId())<=1 )
continue;
143 cout <<
"Selected these two hits pair " << endl;
144 cout <<
"First " << *(*firstHit) <<
" Layer Id: " << (*firstHit)->id().layerId() << endl;
145 cout <<
"Last " << *(*lastHit) <<
" Layer Id: " << (*lastHit)->id().layerId() << endl;
150 if ((sl->
id()).superlayer()==2)
156 for (
int firstLR=0; firstLR<2; ++firstLR) {
157 for (
int lastLR=0; lastLR<2; ++lastLR) {
167 float DAlpha=fabs(gvec.
theta()-gvecIP.
theta());
170 if (DAlpha<DAlphaMax) {
174 LocalPoint posIni = (*firstHit)->localPosition(codes[firstLR]);
176 ((*lastHit)->localPosition(codes[lastLR])-posIni).
unit();
181 cout <<
"compatible hits " << assHits.size() << endl;
189 cout <<
"segment " << *seg<< endl;
200 result.push_back(seg);
202 cout <<
"result is now " << result.size() << endl;
206 cout <<
"already existing" << endl;
216 for (vector<DTSegmentCand*>::const_iterator seg=result.begin();
217 seg!=result.end(); ++seg)
218 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;
237 vector<DTCombinatorialExtendedPatternReco::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) {
291 cout <<
"Already tried";
292 copy((*t).begin(), (*t).end(), ostream_iterator<int>(
std::cout));
304 if (
debug)
cout <<
"DTCombinatorialExtendedPatternReco::buildBestSegment " <<
312 vector<AssPoint> points;
316 deque<DTHitPairForFit* > pointsNoLR;
319 for (vector<AssPoint>::const_iterator
hit=hits.begin();
322 points.push_back(*
hit);
324 pointsNoLR.push_back((*hit).first);
329 cout <<
"points " << points.size() << endl;
330 cout <<
"pointsNoLR " << pointsNoLR.size() << endl;
334 vector<DTSegmentCand*> candidates ;
342 if (
debug)
cout <<
"extended candidates " << extendedCands.size() << endl;
346 vector<DTSegmentExtendedCand*>::const_iterator bestCandIter = extendedCands.end();
348 unsigned int maxNumHits=0;
349 for (vector<DTSegmentExtendedCand*>::const_iterator iter=extendedCands.begin();
350 iter!=extendedCands.end(); ++iter) {
351 if ((*iter)->nHits()==maxNumHits && (*iter)->chi2()<minChi2) {
352 minChi2=(*iter)->chi2();
354 }
else if ((*iter)->nHits()>maxNumHits) {
355 maxNumHits=(*iter)->nHits();
356 minChi2=(*iter)->chi2();
362 for (vector<DTSegmentExtendedCand*>::iterator iter=extendedCands.begin();
363 iter!=extendedCands.end(); ++iter)
364 if (iter!=bestCandIter)
delete (*iter);
367 if (bestCandIter != extendedCands.end()) {
368 return (*bestCandIter);
375 deque<DTHitPairForFit*>& pointsNoLR,
376 vector<DTSegmentCand*>& candidates,
380 cout <<
"DTCombinatorialExtendedPatternReco::buildPointsCollection " << endl;
381 cout <<
"points: " << points.size() <<
" NOLR: " << pointsNoLR.size()<< endl;
383 if (pointsNoLR.size()>0) {
387 cout <<
"Right hit" << endl;
389 pointsNoLR.pop_front();
391 pointsNoLR.push_front((unassHit));
396 cout <<
"Left hit" << endl;
398 pointsNoLR.pop_front();
400 pointsNoLR.push_front((unassHit));
405 cout <<
"The Hits were" << endl;
406 copy(points.begin(), points.end(),
407 ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
408 cout <<
"----" << endl;
409 cout <<
"All associated " << endl;
415 pointsSet.insert(points.begin(),points.end());
418 cout <<
"The Hits are" << endl;
419 copy(pointsSet.begin(), pointsSet.end(),
420 ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
421 cout <<
"----" << endl;
433 for (vector<DTSegmentCand*>::iterator cand=cands.begin();
434 cand!=cands.end(); ++cand)
435 if (*(*cand)==*seg)
return false;
439 vector<DTSegmentExtendedCand*>
442 if (
debug)
cout <<
"extendCandidates " << candidates.size() << endl;
443 vector<DTSegmentExtendedCand*>
result;
447 for (vector<DTSegmentCand*>:: const_iterator cand=candidates.begin();
448 cand!=candidates.end(); ++cand) {
452 result.push_back(extendedCand);
459 vector<DTSegmentExtendedCand::DTSLRecClusterForFit> clustersWithPos;
462 for (vector<DTSLRecCluster>::const_iterator clus=
theClusters.begin();
464 if(
debug)
cout <<
"CLUS: " << (*clus).superLayerId() << endl;
465 if ((*clus).superLayerId().superLayer()==2 &&
closeSL(sl->
id(),(*clus).superLayerId())) {
475 if (
debug)
cout <<
"closeClustersWithPos " << clustersWithPos.size() << endl;
477 for (vector<DTSegmentCand*>:: const_iterator cand=candidates.begin();
478 cand!=candidates.end(); ++cand) {
486 for (vector<DTSegmentExtendedCand::DTSLRecClusterForFit>::const_iterator
487 exClus=clustersWithPos.begin(); exClus!=clustersWithPos.end(); ++exClus) {
489 if (
debug)
cout <<
"is compatible " << endl;
491 extendedCand->
addClus(*exClus);
495 if (
debug)
cout <<
"extended cands nHits: " << extendedCand->
nHits() <<endl;
498 result.push_back(extendedCand);
500 cout <<
"Bad fit" << endl;
504 result.push_back(extendedCand);
513 if (id1==id2)
return false;
517 sec1=(sec1==14)? 10: sec1;
519 sec2=(sec2==14)? 10: sec2;
521 if (
abs(sec1-sec2)>1 &&
abs(sec1-sec2)!=11 )
return false;
T getParameter(std::string const &) const
void setClusters(const std::vector< DTSLRecCluster > &clusters)
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.
std::vector< DTSegmentCand * > clean(const std::vector< DTSegmentCand * > &inputCands) const
do the cleaning
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
Abs< T >::type abs(const T &t)
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)
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)
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