35 typedef std::vector<std::shared_ptr<DTHitPairForFit>>
hitCont;
42 theAlgoName(
"DTMeantimerPatternReco"),
48 debug =
pset.getUntrackedParameter<
bool>(
"debug");
62 const std::vector<DTRecHit1DPair>& pairs) {
64 std::vector<std::shared_ptr<DTHitPairForFit>> hitsForFit =
initHits(sl, pairs);
74 cout <<
"Reconstructed 2D segments " << *segment << endl;
90 const std::vector<DTRecHit1DPair>&
hits) {
92 for (vector<DTRecHit1DPair>::const_iterator
hit =
hits.begin();
hit !=
hits.end(); ++
hit) {
100 vector<DTSegmentCand*>
result;
104 cout <<
"buildSegments: " << sl->
id() <<
" nHits " <<
hits.size() << endl;
106 cout << **
hit <<
" wire: " << (*hit)->
id() <<
" DigiTime: " << (*hit)->digiTime() << endl;
111 cout <<
"Warning: this SuperLayer " << sl->
id() <<
" has too many hits : " <<
hits.size() <<
" max allowed is " 113 cout <<
"Skipping segment reconstruction... " << endl;
120 if ((sl->
id()).superlayer() == 2)
127 for (hitCont::const_iterator firstHit =
hits.begin(); firstHit !=
hits.end(); ++firstHit) {
128 for (hitCont::const_reverse_iterator lastHit =
hits.rbegin(); (*lastHit) != (*firstHit); ++lastHit) {
135 for (hitCont::const_iterator tmpHit = firstHit + 1; (*tmpHit) != (*lastHit); tmpHit++)
137 hitsForFit.push_back(*tmpHit);
139 for (
int firstLR = 0; firstLR < 2; ++firstLR) {
140 for (
int lastLR = 0; lastLR < 2; ++lastLR) {
149 float DAlpha = fabs(gvec.
theta() - gvecIP.
theta());
150 if (DAlpha > DAlphaMax)
160 auto segCand = std::make_unique<DTSegmentCand>(pointSet, sl);
161 segCand->add(*firstHit, codes[firstLR]);
162 segCand->add(*lastHit, codes[lastLR]);
174 cout <<
"Result (before cleaning): " <<
result.size() << endl;
175 for (vector<DTSegmentCand*>::const_iterator seg =
result.begin(); seg !=
result.end(); ++seg)
176 cout << *(*seg) << endl;
182 cout <<
"Result (after cleaning): " <<
result.size() << endl;
183 for (vector<DTSegmentCand*>::const_iterator seg =
result.begin(); seg !=
result.end(); ++seg)
184 cout << *(*seg) << endl;
191 const vector<std::shared_ptr<DTHitPairForFit>>&
hits,
192 vector<DTSegmentCand*>&
result) {
193 double chi2l, chi2r, t0l, t0r;
194 bool foundSomething =
false;
197 cout <<
" DTMeantimerPatternReco::addHit " << endl
198 <<
" Picked " << segCand->
nHits() <<
" hits, " <<
hits.size() <<
" left." << endl;
215 chi2l = segCand->
chi2();
221 chi2r = segCand->
chi2();
227 cout <<
" Left: t0= " << t0l <<
" chi2/nHits= " << chi2l <<
"/" <<
nHits <<
" ok: " << left_ok << endl;
228 cout <<
" Right: t0= " << t0r <<
" chi2/nHits= " << chi2r <<
"/" <<
nHits <<
" ok: " << right_ok << endl;
231 if (!left_ok && !right_ok)
234 foundSomething =
true;
238 for (hitCont::const_iterator tmpHit =
hit + 1; tmpHit !=
hits.end(); tmpHit++)
240 hitsForFit.push_back(*tmpHit);
242 reverse(hitsForFit.begin(), hitsForFit.end());
245 if (segCand->
nHits() > 3 && left_ok && right_ok) {
246 if (chi2l < chi2r - 0.1)
248 else if (chi2r < chi2l - 0.1)
278 if (!segCand->
good()) {
286 cout << endl <<
" Seg t0= " << segCand->
t0() << endl << *segCand << endl;
291 cout <<
" Result is now " <<
result.size() << endl;
294 cout <<
" Exists - skipping" << endl;
301 const int layerLowerCut[4] = {0, -1, -2, -2};
302 const int layerUpperCut[4] = {0, 2, 2, 3};
307 if (
first.layerId().superlayerId().superLayer() !=
second.layerId().superlayerId().superLayer())
310 int deltaLayer =
abs(
first.layerId().layer() -
second.layerId().layer());
317 if (deltaLayer > 3) {
318 cout <<
"*** WARNING! DT Layer numbers differ by more than 3! for hits: " << endl;
326 if (
second.layerId().layer() % 2 == 0)
327 deltaWire = -deltaWire;
328 if ((deltaWire <= layerLowerCut[deltaLayer]) || (deltaWire >= layerUpperCut[deltaLayer]))
346 if (seg->
nHits() == 3)
350 if (seg->
t0() == 0) {
366 if (*(*
cand) == *seg)
368 if (((*cand)->nHits() >= seg->
nHits()) && ((*cand)->chi2ndof() < seg->
chi2ndof()))
369 if ((*cand)->nSharedHitPairs(*seg) >
int(seg->
nHits() - 2))
376 char mark[26] = {
". . . . . . . . . . . . "};
377 int wire[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
379 for (vector<DTSegmentCand::AssPoint>::const_iterator assHit = assHits.begin(); assHit != assHits.end(); ++assHit) {
381 (((*assHit).first)->
id().superlayerId().superLayer() - 1) * 4 + ((*assHit).first)->id().layerId().layer() - 1;
382 wire[lay] = ((*assHit).first)->
id().wire();
389 int lay = ((*hit).id().superlayerId().superLayer() - 1) * 4 + (*hit).id().layerId().layer() - 1;
390 wire[lay] = (*hit).id().wire();
394 for (
int i = 0;
i < 12;
i++)
std::pair< std::shared_ptr< DTHitPairForFit >, DTEnums::DTCellSide > AssPoint
std::vector< std::shared_ptr< DTHitPairForFit > > initHits(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
edm::OwnVector< DTSLRecSegment2D > reconstruct(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits) override
this function is called in the producer
void setES(const edm::EventSetup &setup) override
uint32_t cc[maxCellsPerHit]
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > theDTGeometryToken
DTCellSide
Which side of the DT cell.
std::vector< DTSegmentCand * > clean(const std::vector< DTSegmentCand *> &inputCands) const
do the cleaning
void addHits(DTSegmentCand *segCand, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits, std::vector< DTSegmentCand *> &result)
virtual unsigned int nHits() const
std::vector< std::shared_ptr< DTHitPairForFit > > hitCont
DTSegmentCleaner * theCleaner
void update(DTRecSegment4D *seg, const bool calcT0, bool allow3par) const
recompute hits position and refit the segment4D
virtual double chi2ndof() const
the chi2/NDOF of the fit
U second(std::pair< T, U > const &p)
virtual bool good() const
DTSegmentCand * fitWithT0(DTSegmentCand *seg, const bool fitdebug)
std::vector< DTSegmentCand * > buildSegments(const DTSuperLayer *sl, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits)
void setES(const edm::EventSetup &setup)
set the setup
virtual void add(AssPoint newHit)
add hits to the hit list.
unsigned int theMaxAllowedHits
bool fit(DTSegmentCand *seg, bool allow3par, const bool fitdebug) const
bool checkDoubleCandidates(std::vector< DTSegmentCand *> &segs, DTSegmentCand *seg)
Abs< T >::type abs(const T &t)
virtual double chi2() const
the chi2 (NOT chi2/NDOF) of the fit
~DTMeantimerPatternReco() override
Destructor.
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
void printPattern(std::vector< DTSegmentCand::AssPoint > &assHits, const DTHitPairForFit *hit)
std::set< AssPoint, AssPointLessZ > AssPointCont
hitCont::const_iterator hitIter
DTMeantimerPatternReco(const edm::ParameterSet &pset, edm::ConsumesCollector cc)
Constructor.
bool geometryFilter(const DTWireId first, const DTWireId second) const
virtual void removeHit(AssPoint hit)
remove hit from the candidate
virtual double t0() const
the t0 of the segment
TupleMultiplicity< TrackerTraits > const *__restrict__ uint32_t nHits
DTSuperLayerId id() const
Return the DetId of this SL.
Geom::Theta< T > theta() const
edm::ESHandle< DTGeometry > theDTGeometry
DTSegmentUpdator * theUpdator