34 typedef std::vector<std::shared_ptr<DTHitPairForFit>>
hitCont;
42 theAlgoName(
"DTMeantimerPatternReco")
63 const std::vector<DTRecHit1DPair>&
pairs){
66 std::vector<std::shared_ptr<DTHitPairForFit>> hitsForFit =
initHits(sl, pairs);
70 vector<DTSegmentCand*>::const_iterator cand=candidates.begin();
71 while (cand<candidates.end()) {
77 cout<<
"Reconstructed 2D segments "<<*segment<<endl;
92 vector<std::shared_ptr<DTHitPairForFit>>
94 const std::vector<DTRecHit1DPair>& hits){
97 for (vector<DTRecHit1DPair>::const_iterator
hit=hits.begin();
99 result.push_back(std::make_shared<DTHitPairForFit>(*
hit, *sl,
theDTGeometry));
104 vector<DTSegmentCand*>
106 const std::vector<std::shared_ptr<DTHitPairForFit>>& hits){
108 vector<DTSegmentCand*>
result;
112 cout <<
"buildSegments: " << sl->
id() <<
" nHits " << hits.size() << endl;
113 for (
hitIter hit=hits.begin();
hit!=hits.end(); ++
hit)
cout << **
hit<<
" wire: " << (*hit)->
id() <<
" DigiTime: " << (*hit)->digiTime() << endl;
118 cout <<
"Warning: this SuperLayer " << sl->
id() <<
" has too many hits : "
120 cout <<
"Skipping segment reconstruction... " << endl;
127 if ((sl->
id()).superlayer()==2)
134 for (hitCont::const_iterator firstHit=hits.begin(); firstHit!=hits.end();
136 for (hitCont::const_reverse_iterator lastHit=hits.rbegin();
137 (*lastHit)!=(*firstHit); ++lastHit) {
140 if (!
geometryFilter((*firstHit)->id(),(*lastHit)->id()))
continue;
144 for (hitCont::const_iterator tmpHit=firstHit+1; (*tmpHit)!=(*lastHit); tmpHit++)
146 && (
geometryFilter((*tmpHit)->id(),(*firstHit)->id()))) hitsForFit.push_back(*tmpHit);
148 for (
int firstLR=0; firstLR<2; ++firstLR) {
149 for (
int lastLR=0; lastLR<2; ++lastLR) {
159 float DAlpha=fabs(gvec.
theta()-gvecIP.
theta());
160 if (DAlpha>DAlphaMax)
continue;
168 vector<DTSegmentCand::AssPoint> assHits;
175 addHits(sl,assHits,hitsForFit,result);
183 cout <<
"Result (before cleaning): " << result.size() << endl;
184 for (vector<DTSegmentCand*>::const_iterator seg=result.begin(); seg!=result.end(); ++seg)
cout << *(*seg) << endl;
190 cout <<
"Result (after cleaning): " << result.size() << endl;
191 for (vector<DTSegmentCand*>::const_iterator seg=result.begin(); seg!=result.end(); ++seg)
cout << *(*seg) << endl;
201 vector<DTSegmentCand*> &
result) {
203 double chi2l,chi2r,t0_corrl,t0_corrr;
204 bool foundSomething =
false;
209 if (assHits.size()+hits.size()<
maxfound)
return;
212 for (hitCont::const_iterator
hit=hits.begin();
hit!=hits.end(); ++
hit) {
221 std::unique_ptr<DTSegmentCand> left_seg =
fitWithT0(sl,assHits, chi2l, t0_corrl,0);
227 std::unique_ptr<DTSegmentCand> right_seg =
fitWithT0(sl,assHits, chi2r, t0_corrr,0);
232 bool left_ok=(left_seg)?
true:
false;
233 bool right_ok=(right_seg)?
true:
false;
235 if (!left_ok && !right_ok)
continue;
237 foundSomething =
true;
241 for (hitCont::const_iterator tmpHit=
hit+1; tmpHit!=hits.end(); tmpHit++)
242 if (
geometryFilter((*tmpHit)->id(),(*hit)->id())) hitsForFit.push_back(*tmpHit);
244 reverse(hitsForFit.begin(),hitsForFit.end());
247 if (assHits.size()>3 && left_ok && right_ok) {
248 if (chi2l<chi2r-0.1) right_ok=
false;
else
249 if (chi2r<chi2l-0.1) left_ok=
false;
253 addHits(sl,assHits,hitsForFit,result);
258 addHits(sl,assHits,hitsForFit,result);
263 if (foundSomething)
return;
267 if (assHits.size()<
maxfound)
return;
270 std::unique_ptr<DTSegmentCand> seg =
fitWithT0(sl,assHits, chi2l, t0_corrl,
debug);
279 if (
debug)
cout << endl <<
" Seg t0= " << t0_corrl << endl << *seg<< endl;
282 result.push_back(seg.release());
283 if (
debug)
cout <<
" Result is now " << result.size() << endl;
285 if (
debug)
cout <<
" Exists - skipping" << endl;
295 const int layerLowerCut[4]={0,-1,-2,-2};
296 const int layerUpperCut[4]={0, 2, 2, 3};
307 if (!deltaLayer)
return false;
311 cout <<
"*** WARNING! DT Layer numbers differ by more than 3! for hits: " << endl;
312 cout <<
" " << first << endl;
313 cout <<
" " << second << endl;
318 int deltaWire=first.
wire()-second.
wire();
319 if (second.
layerId().
layer()%2==0) deltaWire=-deltaWire;
320 if ((deltaWire<=layerLowerCut[deltaLayer]) || (deltaWire>=layerUpperCut[deltaLayer]))
return false;
326 std::unique_ptr<DTSegmentCand>
331 pointsSet.insert(assHits.begin(),assHits.end());
332 std::unique_ptr<DTSegmentCand> seg(
new DTSegmentCand(pointsSet,sl));
343 if (chi2==-1.)
return nullptr;
346 if (assHits.size()==3)
return seg;
350 if (chi2<100.)
return seg;
355 if ((chi2/(assHits.size()-3)<
theMaxChi2))
return seg;
364 for (vector<DTSegmentCand*>::iterator cand=cands.begin();
365 cand!=cands.end(); ++cand) {
366 if (*(*cand)==*seg)
return false;
367 if (((*cand)->nHits()>=seg->
nHits()) && ((*cand)->chi2ndof()<seg->
chi2ndof()))
368 if ((*cand)->nSharedHitPairs(*seg)>int(seg->
nHits()-2))
return false;
378 char mark[26]={
". . . . . . . . . . . . "};
379 int wire[12]={0,0,0,0,0,0,0,0,0,0,0,0};
381 for (vector<DTSegmentCand::AssPoint>::const_iterator assHit=assHits.begin(); assHit!=assHits.end(); ++assHit) {
382 int lay = (((*assHit).first)->
id().superlayerId().superLayer()-1)*4 + ((*assHit).first)->id().layerId().layer()-1;
383 wire[lay]= ((*assHit).first)->
id().wire();
384 if ((*assHit).second==
DTEnums::Left) mark[lay*2]=
'L';
else mark[lay*2]=
'R';
387 int lay = ((*hit).id().superlayerId().superLayer()-1)*4 + (*hit).id().layerId().layer() - 1;
388 wire[lay]= (*hit).id().wire();
391 cout <<
" " << mark << endl <<
" ";
392 for (
int i=0;
i<12;
i++)
if (wire[
i])
cout << setw(2) << wire[
i];
else cout <<
" ";
std::pair< std::shared_ptr< DTHitPairForFit >, DTEnums::DTCellSide > AssPoint
std::vector< std::shared_ptr< DTHitPairForFit > > initHits(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual double chi2ndof() const
the chi2/NDOF of the fit
bool checkDoubleCandidates(std::vector< DTSegmentCand * > &segs, DTSegmentCand *seg)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
DTCellSide
Which side of the DT cell.
virtual ~DTMeantimerPatternReco()
Destructor.
int layer() const
Return the layer number.
std::vector< DTSegmentCand * > clean(const std::vector< DTSegmentCand * > &inputCands) const
do the cleaning
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
std::vector< std::shared_ptr< DTHitPairForFit > > hitCont
DTSegmentCleaner * theCleaner
Geom::Theta< T > theta() const
U second(std::pair< T, U > const &p)
DTSuperLayerId id() const
Return the DetId of this SL.
std::vector< DTSegmentCand * > buildSegments(const DTSuperLayer *sl, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits)
virtual void setES(const edm::EventSetup &setup)
void setES(const edm::EventSetup &setup)
set the setup
unsigned int theMaxAllowedHits
std::unique_ptr< DTSegmentCand > fitWithT0(const DTSuperLayer *sl, const std::vector< DTSegmentCand::AssPoint > &assHits, double &chi2, double &t0_corr, const bool fitdebug)
Abs< T >::type abs(const T &t)
int superLayer() const
Return the superlayer number.
int wire() const
Return the wire number.
void printPattern(std::vector< DTSegmentCand::AssPoint > &assHits, const DTHitPairForFit *hit)
std::set< AssPoint, AssPointLessZ > AssPointCont
void addHits(const DTSuperLayer *sl, std::vector< DTSegmentCand::AssPoint > &assHits, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits, std::vector< DTSegmentCand * > &result)
virtual unsigned int nHits() const
hitCont::const_iterator hitIter
bool geometryFilter(const DTWireId first, const DTWireId second) const
virtual edm::OwnVector< DTSLRecSegment2D > reconstruct(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
this function is called in the producer
DTLayerId layerId() const
Return the corresponding LayerId.
DTMeantimerPatternReco(const edm::ParameterSet &pset)
Constructor.
void update(DTRecSegment4D *seg, const bool calcT0, bool allow3par) const
recompute hits position and refit the segment4D
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
edm::ESHandle< DTGeometry > theDTGeometry
DTSegmentUpdator * theUpdator