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<std::shared_ptr<DTHitPairForFit>> hitsForFit =
initHits(sl, pairs);
64 vector<DTSegmentCand*>::const_iterator
cand=candidates.begin();
65 while (cand<candidates.end()) {
74 cout<<
"Reconstructed 2D extended segments "<< result.
back() <<endl;
93 vector<std::shared_ptr<DTHitPairForFit>>
95 const std::vector<DTRecHit1DPair>&
hits){
97 vector<std::shared_ptr<DTHitPairForFit>>
result;
98 for (vector<DTRecHit1DPair>::const_iterator
hit=hits.begin();
100 result.push_back(std::make_shared<DTHitPairForFit>(*
hit, *sl,
theDTGeometry));
105 vector<DTSegmentCand*>
107 const std::vector<std::shared_ptr<DTHitPairForFit>>&
hits){
109 typedef vector<std::shared_ptr<DTHitPairForFit>>
hitCont;
110 typedef hitCont::const_iterator
hitIter;
111 vector<DTSegmentCand*>
result;
114 cout <<
"DTCombinatorialExtendedPatternReco::buildSegments: " << sl->
id() <<
" nHits " <<
hits.size() << endl;
115 for (vector<std::shared_ptr<DTHitPairForFit>>::const_iterator
hit=
hits.begin();
124 cout <<
"Warning: this SuperLayer " << sl->
id() <<
" has too many hits : " 126 cout <<
"Skipping segment reconstruction... " << endl;
133 for (hitCont::const_iterator firstHit=
hits.begin(); firstHit!=
hits.end();
135 for (hitCont::const_reverse_iterator lastHit=
hits.rbegin();
136 (*lastHit)!=(*firstHit); ++lastHit) {
138 if ( fabs((*lastHit)->id().layerId()-(*firstHit)->id().layerId())<=1 )
continue;
140 cout <<
"Selected these two hits pair " << endl;
141 cout <<
"First " << *(*firstHit) <<
" Layer Id: " << (*firstHit)->id().layerId() << endl;
142 cout <<
"Last " << *(*lastHit) <<
" Layer Id: " << (*lastHit)->id().layerId() << endl;
147 if ((sl->
id()).superlayer()==2)
153 for (
int firstLR=0; firstLR<2; ++firstLR) {
154 for (
int lastLR=0; lastLR<2; ++lastLR) {
164 float DAlpha=fabs(gvec.
theta()-gvecIP.
theta());
167 if (DAlpha<DAlphaMax) {
171 LocalPoint posIni = (*firstHit)->localPosition(codes[firstLR]);
173 ((*lastHit)->localPosition(codes[lastLR])-posIni).
unit();
178 cout <<
"compatible hits " << assHits.size() << endl;
186 cout <<
"segment " << *seg<< endl;
197 result.push_back(seg);
199 cout <<
"result is now " << result.size() << endl;
203 cout <<
"already existing" << endl;
213 for (vector<DTSegmentCand*>::const_iterator seg=result.begin();
214 seg!=result.end(); ++seg)
215 cout << *(*seg) << endl;
222 cout <<
"result no ghost " << result.size() << endl;
223 for (vector<DTSegmentCand*>::const_iterator seg=result.begin();
224 seg!=result.end(); ++seg)
225 cout << *(*seg) << endl;
234 vector<DTSegmentCand::AssPoint>
237 const vector<std::shared_ptr<DTHitPairForFit>>&
hits) {
238 if (
debug)
cout <<
"Pos: " << posIni <<
" Dir: "<< dirIni << endl;
239 vector<DTSegmentCand::AssPoint>
result;
243 int nCompatibleHits=0;
245 typedef vector<std::shared_ptr<DTHitPairForFit>>
hitCont;
246 typedef hitCont::const_iterator
hitIter;
248 pair<bool,bool> isCompatible = (*hit)->isCompatible(posIni, dirIni);
250 cout <<
"isCompatible " << isCompatible.first <<
" " <<
251 isCompatible.second << endl;
257 if (isCompatible.first && isCompatible.second) {
262 else if (isCompatible.first) {
267 else if (isCompatible.second) {
288 cout <<
"Already tried";
289 copy((*t).begin(), (*t).end(), ostream_iterator<int>(
std::cout));
301 if (
debug)
cout <<
"DTCombinatorialExtendedPatternReco::buildBestSegment " <<
309 vector<DTSegmentCand::AssPoint>
points;
313 deque<std::shared_ptr<DTHitPairForFit>> pointsNoLR;
316 for (vector<DTSegmentCand::AssPoint>::const_iterator
hit=hits.begin();
319 points.push_back(*
hit);
321 pointsNoLR.push_back((*hit).first);
326 cout <<
"points " << points.size() << endl;
327 cout <<
"pointsNoLR " << pointsNoLR.size() << endl;
339 if (
debug)
cout <<
"extended candidates " << extendedCands.size() << endl;
343 vector<DTSegmentExtendedCand*>::const_iterator bestCandIter = extendedCands.end();
345 unsigned int maxNumHits=0;
346 for (vector<DTSegmentExtendedCand*>::const_iterator iter=extendedCands.begin();
347 iter!=extendedCands.end(); ++iter) {
348 if ((*iter)->nHits()==maxNumHits && (*iter)->chi2()<
minChi2) {
349 minChi2=(*iter)->chi2();
351 }
else if ((*iter)->nHits()>maxNumHits) {
352 maxNumHits=(*iter)->nHits();
353 minChi2=(*iter)->chi2();
359 for (vector<DTSegmentExtendedCand*>::iterator iter=extendedCands.begin();
360 iter!=extendedCands.end(); ++iter)
361 if (iter!=bestCandIter)
delete (*iter);
364 if (bestCandIter != extendedCands.end()) {
365 return (*bestCandIter);
372 deque<std::shared_ptr<DTHitPairForFit>>& pointsNoLR,
377 cout <<
"DTCombinatorialExtendedPatternReco::buildPointsCollection " << endl;
378 cout <<
"points: " << points.size() <<
" NOLR: " << pointsNoLR.size()<< endl;
380 if (pointsNoLR.size()>0) {
381 std::shared_ptr<DTHitPairForFit> unassHit = pointsNoLR.front();
384 cout <<
"Right hit" << endl;
386 pointsNoLR.pop_front();
388 pointsNoLR.push_front((unassHit));
393 cout <<
"Left hit" << endl;
395 pointsNoLR.pop_front();
397 pointsNoLR.push_front((unassHit));
402 cout <<
"The Hits were" << endl;
403 copy(points.begin(), points.end(),
404 ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
405 cout <<
"----" << endl;
406 cout <<
"All associated " << endl;
412 pointsSet.insert(points.begin(),points.end());
415 cout <<
"The Hits are" << endl;
416 copy(pointsSet.begin(), pointsSet.end(),
417 ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
418 cout <<
"----" << endl;
422 if (
theUpdator->
fit(newCand,0,0)) candidates.push_back(newCand);
430 for (vector<DTSegmentCand*>::iterator
cand=cands.begin();
432 if (*(*
cand)==*seg)
return false;
436 vector<DTSegmentExtendedCand*>
439 if (
debug)
cout <<
"extendCandidates " << candidates.size() << endl;
440 vector<DTSegmentExtendedCand*>
result;
444 for (vector<DTSegmentCand*>:: const_iterator
cand=candidates.begin();
449 result.push_back(extendedCand);
456 vector<DTSegmentExtendedCand::DTSLRecClusterForFit> clustersWithPos;
459 for (vector<DTSLRecCluster>::const_iterator clus=
theClusters.begin();
461 if(
debug)
cout <<
"CLUS: " << (*clus).superLayerId() << endl;
462 if ((*clus).superLayerId().superLayer()==2 &&
closeSL(sl->
id(),(*clus).superLayerId())) {
472 if (
debug)
cout <<
"closeClustersWithPos " << clustersWithPos.size() << endl;
474 for (vector<DTSegmentCand*>:: const_iterator
cand=candidates.begin();
483 for (vector<DTSegmentExtendedCand::DTSLRecClusterForFit>::const_iterator
484 exClus=clustersWithPos.begin(); exClus!=clustersWithPos.end(); ++exClus) {
486 if (
debug)
cout <<
"is compatible " << endl;
488 extendedCand->
addClus(*exClus);
492 if (
debug)
cout <<
"extended cands nHits: " << extendedCand->
nHits() <<endl;
495 result.push_back(extendedCand);
497 cout <<
"Bad fit" << endl;
501 result.push_back(extendedCand);
510 if (id1==id2)
return false;
514 sec1=(sec1==14)? 10: sec1;
516 sec2=(sec2==14)? 10: sec2;
518 if (
abs(sec1-sec2)>1 &&
abs(sec1-sec2)!=11 )
return false;
std::pair< std::shared_ptr< DTHitPairForFit >, DTEnums::DTCellSide > AssPoint
T getParameter(std::string const &) const
void setClusters(const std::vector< DTSLRecCluster > &clusters)
T getUntrackedParameter(std::string const &, T const &) const
DTSegmentCleaner * theCleaner
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
std::vector< DTSegmentCand * > buildSegments(const DTSuperLayer *sl, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits)
virtual edm::OwnVector< DTSLRecSegment2D > reconstruct(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
this function is called in the producer
DTSegmentUpdator * theUpdator
DTCellSide
Which side of the DT cell.
def setup(process, global_tag, zero_tesla=False)
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)
std::vector< std::shared_ptr< DTHitPairForFit > > hitCont
virtual void setES(const edm::EventSetup &setup)
virtual bool good() const
Geom::Theta< T > theta() const
DTSuperLayerId id() const
Return the DetId of this SL.
void setES(const edm::EventSetup &setup)
set the setup
void buildPointsCollection(std::vector< DTSegmentCand::AssPoint > &points, std::deque< std::shared_ptr< DTHitPairForFit >> &pointsNoLR, std::vector< DTSegmentCand * > &candidates, const DTSuperLayer *sl)
std::vector< std::shared_ptr< DTHitPairForFit > > initHits(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
virtual ~DTCombinatorialExtendedPatternReco()
Destructor.
std::vector< std::vector< int > > theTriedPattern
Abs< T >::type abs(const T &t)
int superLayer() const
Return the superlayer number.
void addClus(const DTSegmentExtendedCand::DTSLRecClusterForFit &clus)
std::vector< DTSegmentExtendedCand * > extendCandidates(std::vector< DTSegmentCand * > &candidates, const DTSuperLayer *sl)
const DTSuperLayer * superLayer(DTSuperLayerId id) const
Return a DTSuperLayer given its id.
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
hitCont::const_iterator hitIter
std::vector< DTSLRecCluster > theClusters
bool closeSL(const DTSuperLayerId &id1, const DTSuperLayerId &id2)
void update(DTRecSegment4D *seg, const bool calcT0, bool allow3par) const
recompute hits position and refit the segment4D
DTSegmentExtendedCand * buildBestSegment(std::vector< DTSegmentCand::AssPoint > &assHits, const DTSuperLayer *sl)
edm::ESHandle< DTGeometry > theDTGeometry
int wheel() const
Return the wheel number.
std::vector< DTSegmentCand::AssPoint > findCompatibleHits(const LocalPoint &pos, const LocalVector &dir, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits)
unsigned int theMaxAllowedHits
bool fit(DTSegmentCand *seg, bool allow3par, const bool fitdebug) const