43 string theHitAlgoName = pset.
getParameter<
string>(
"recAlgo");
44 usePairs = !(theHitAlgoName==
"DTNoDriftAlgo");
56 const std::vector<DTRecHit1DPair>&
pairs){
59 vector<std::shared_ptr<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;
88 vector<std::shared_ptr<DTHitPairForFit>>
90 const std::vector<DTRecHit1DPair>& hits){
92 vector<std::shared_ptr<DTHitPairForFit>>
result;
93 for (vector<DTRecHit1DPair>::const_iterator
hit=hits.begin();
95 result.push_back(std::make_shared<DTHitPairForFit>(*
hit, *sl,
theDTGeometry));
100 vector<DTSegmentCand*>
102 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 <<
"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) {
139 if ( fabs((*lastHit)->id().layerId()-(*firstHit)->id().layerId())<=1 )
continue;
141 cout <<
"Selected these two hits pair " << endl;
142 cout <<
"First " << *(*firstHit) <<
" Layer Id: " << (*firstHit)->id().layerId() << endl;
143 cout <<
"Last " << *(*lastHit) <<
" Layer Id: " << (*lastHit)->id().layerId() << endl;
148 if ((sl->
id()).superlayer()==2)
154 for (
int firstLR=0; firstLR<2; ++firstLR) {
155 for (
int lastLR=0; lastLR<2; ++lastLR) {
165 float DAlpha=fabs(gvec.
theta()-gvecIP.
theta());
168 if (DAlpha<DAlphaMax) {
172 LocalPoint posIni = (*firstHit)->localPosition(codes[firstLR]);
174 ((*lastHit)->localPosition(codes[lastLR])-posIni).
unit();
179 cout <<
"compatible hits " << assHits.size() << endl;
187 cout <<
"segment " << *seg<< endl;
198 result.push_back(seg);
200 cout <<
"result is now " << result.size() << endl;
204 cout <<
"already existing" << endl;
214 for (vector<DTSegmentCand*>::const_iterator seg=result.begin();
215 seg!=result.end(); ++seg)
216 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;
232 vector<DTSegmentCand::AssPoint>
235 const vector<std::shared_ptr<DTHitPairForFit>>& hits) {
236 if (
debug)
cout <<
"Pos: " << posIni <<
" Dir: "<< dirIni << endl;
237 vector<DTSegmentCand::AssPoint>
result;
241 int nCompatibleHits=0;
243 typedef vector<std::shared_ptr<DTHitPairForFit>>
hitCont;
244 typedef hitCont::const_iterator
hitIter;
245 for (hitIter
hit=hits.begin();
hit!=hits.end(); ++
hit) {
246 pair<bool,bool> isCompatible = (*hit)->isCompatible(posIni, dirIni);
248 cout <<
"isCompatible " << isCompatible.first <<
" " <<
249 isCompatible.second << endl;
255 if (isCompatible.first && isCompatible.second) {
260 else if (isCompatible.first) {
265 else if (isCompatible.second) {
281 if (nCompatibleHits < 3) {
283 cout <<
"Less than 3 hits " ;
294 cout <<
"NOT Already tried " ;
300 cout <<
"Already tried " ;
321 vector<DTSegmentCand::AssPoint> points;
325 deque<std::shared_ptr<DTHitPairForFit> > pointsNoLR;
328 for (vector<DTSegmentCand::AssPoint>::const_iterator
hit=hits.begin();
331 points.push_back(*
hit);
333 pointsNoLR.push_back((*hit).first);
338 cout <<
"points " << points.size() << endl;
339 cout <<
"pointsNoLR " << pointsNoLR.size() << endl;
343 vector<DTSegmentCand*> candidates ;
348 cout <<
"candidates " << candidates.size() << endl;
352 vector<DTSegmentCand*>::const_iterator bestCandIter = candidates.end();
354 unsigned int maxNumHits=0;
355 for (vector<DTSegmentCand*>::const_iterator
iter=candidates.begin();
357 if ((*iter)->nHits()==maxNumHits && (*iter)->chi2()<minChi2) {
358 minChi2=(*iter)->chi2();
360 }
else if ((*iter)->nHits()>maxNumHits) {
361 maxNumHits=(*iter)->nHits();
362 minChi2=(*iter)->chi2();
368 for (vector<DTSegmentCand*>::iterator
iter=candidates.begin();
372 if (bestCandIter != candidates.end()) {
373 return (*bestCandIter);
380 deque<std::shared_ptr<DTHitPairForFit>>& pointsNoLR,
381 vector<DTSegmentCand*>& candidates,
385 cout <<
"buildPointsCollection " << endl;
386 cout <<
"points: " << points.size() <<
" NOLR: " << pointsNoLR.size()<< endl;
388 if (pointsNoLR.size()>0) {
389 std::shared_ptr<DTHitPairForFit> unassHit = pointsNoLR.front();
392 cout <<
"Right hit" << endl;
394 pointsNoLR.pop_front();
396 pointsNoLR.push_front((unassHit));
401 cout <<
"Left hit" << endl;
403 pointsNoLR.pop_front();
405 pointsNoLR.push_front((unassHit));
410 cout <<
"The Hits were" << endl;
411 copy(points.begin(), points.end(),
412 ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
413 cout <<
"----" << endl;
414 cout <<
"All associated " << endl;
420 pointsSet.insert(points.begin(),points.end());
423 cout <<
"The Hits are" << endl;
424 copy(pointsSet.begin(), pointsSet.end(),
425 ostream_iterator<DTSegmentCand::AssPoint>(
std::cout));
426 cout <<
"----" << endl;
430 if (
theUpdator->
fit(newCand,0,0)) candidates.push_back(newCand);
438 for (vector<DTSegmentCand*>::iterator cand=cands.begin();
439 cand!=cands.end(); ++cand)
440 if (*(*cand)==*seg)
return false;
void buildPointsCollection(std::vector< DTSegmentCand::AssPoint > &points, std::deque< std::shared_ptr< DTHitPairForFit > > &pointsNoLR, std::vector< DTSegmentCand * > &candidates, const DTSuperLayer *sl)
std::pair< std::shared_ptr< DTHitPairForFit >, DTEnums::DTCellSide > AssPoint
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual void setES(const edm::EventSetup &setup)
std::vector< std::shared_ptr< DTHitPairForFit > > initHits(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
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< DTSegmentCand * > clean(const std::vector< DTSegmentCand * > &inputCands) const
do the cleaning
virtual bool good() const
std::vector< std::shared_ptr< DTHitPairForFit > > hitCont
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
virtual edm::OwnVector< DTSLRecSegment2D > reconstruct(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
this function is called in the producer
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
std::vector< DTSegmentCand * > buildSegments(const DTSuperLayer *sl, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits)
hitCont::const_iterator hitIter
DTSegmentCand * buildBestSegment(std::vector< DTSegmentCand::AssPoint > &assHits, const DTSuperLayer *sl)
virtual ~DTCombinatorialPatternReco()
Destructor.
std::vector< DTSegmentCand::AssPoint > findCompatibleHits(const LocalPoint &pos, const LocalVector &dir, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits)
void update(DTRecSegment4D *seg, const bool calcT0, bool allow3par) const
recompute hits position and refit the segment4D
TriedPatterns theTriedPattern
list pairs
sort tag files by run number
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
bool fit(DTSegmentCand *seg, bool allow3par, const bool fitdebug) const