25 vector<Trajectory> smoothed;
28 vector<Trajectory> fitted = fitter()->fit(t);
29 smoothingStep(fitted, smoothed);
38 LogDebug(
"TrackFitters") <<
"In KFFittingSmoother::fit";
43 bool has_low_pixel_prob;
46 double log_pixel_probability_lower_limit = -15.0;
49 vector<Trajectory> smoothed;
50 vector<Trajectory> tmp_first;
70 has_low_pixel_prob =
false;
72 double cut = theEstimateCut;
74 double log_pixel_prob_cut = theLogPixelProbabilityCut;
77 unsigned int outlierId = 0;
80 unsigned int low_pixel_prob_Id = 0;
81 const GeomDet* low_pixel_prob_Det = 0;
84 vector<Trajectory> fitted = fitter()->fit(aSeed, myHits, firstPredTsos);
87 smoothingStep(fitted, smoothed);
91 if ( smoothed.empty() )
93 if ( rejectTracksFlag )
95 LogTrace(
"TrackFitters") <<
"smoothed.size()==0 => trajectory rejected";
100 LogTrace(
"TrackFitters") <<
"smoothed.size()==0 => returning orignal trajectory" ;
101 smoothed.swap(tmp_first);
114 if ( theEstimateCut > 0 || log_pixel_prob_cut > log_pixel_probability_lower_limit )
116 if ( smoothed[0].foundHits() < theMinNumberOfHits )
118 if ( rejectTracksFlag )
120 LogTrace(
"TrackFitters") <<
"smoothed[0].foundHits()<theMinNumberOfHits => trajectory rejected";
127 if ( !tmp_first.empty() )
129 tmp_first.swap(smoothed);
133 <<
"smoothed[0].foundHits()<theMinNumberOfHits => returning orignal trajectory with chi2="
134 << smoothed[0].chiSquared() ;
140 const std::vector<TrajectoryMeasurement> & vtm = smoothed[0].measurements();
142 double log_pixel_hit_probability = -999999.9;
144 for (std::vector<TrajectoryMeasurement>::const_iterator tm=vtm.begin(); tm!=vtm.end();tm++)
146 double estimate = tm->estimate();
149 if ( estimate > cut )
153 outlierId = tm->recHit()->geographicalId().rawId();
154 outlierDet = tm->recHit()->det();
160 if(log_pixel_prob_cut > log_pixel_probability_lower_limit){
168 unsigned int testSubDetID = ( hit->geographicalId().subdetId() );
170 if ( hit->isValid() &&
180 if ( !persistentHit == 0 &&
189 if ( pixel_hit_probability < 0.0 )
190 LogDebug(
"From KFFittingSmoother.cc")
191 <<
"Wraning : Negative pixel hit probability !!!! Will set the probability to 10^{-15} !!!" << endl;
193 if ( pixel_hit_probability <= 0.0 || log10( pixel_hit_probability ) < log_pixel_probability_lower_limit )
194 log_pixel_hit_probability = log_pixel_probability_lower_limit;
196 log_pixel_hit_probability = log10( pixel_hit_probability );
198 if ( log_pixel_hit_probability < log_pixel_prob_cut )
200 has_low_pixel_prob =
true;
201 log_pixel_prob_cut = log_pixel_hit_probability;
202 low_pixel_prob_Id = tm->recHit()->geographicalId().rawId();
203 low_pixel_prob_Det = tm->recHit()->det();
216 if ( hasoutliers || has_low_pixel_prob )
220 for (
unsigned int j=0;
j<myHits.size(); ++
j )
222 if ( hasoutliers && outlierId == myHits[
j]->geographicalId().rawId() )
224 LogTrace(
"TrackFitters") <<
"Rejecting outlier hit with estimate " << cut <<
" at position "
225 <<
j <<
" with rawId=" << myHits[
j]->geographicalId().rawId();
226 LogTrace(
"TrackFitters") <<
"The fit will be repeated without the outlier";
229 else if ( has_low_pixel_prob && low_pixel_prob_Id == myHits[
j]->geographicalId().rawId() )
231 LogTrace(
"TrackFitters") <<
"Rejecting low proability pixel hit with log_pixel_prob_cut = "
232 << log_pixel_prob_cut <<
" at position "
233 <<
j <<
" with rawId =" << myHits[
j]->geographicalId().rawId();
234 LogTrace(
"TrackFitters") <<
"The fit will be repeated without the outlier";
241 if ( breakTrajWith2ConsecutiveMissing )
243 unsigned int firstinvalid = myHits.size()-1;
244 for (
unsigned int j=0;
j<myHits.size()-1; ++
j )
250 LogTrace(
"TrackFitters") <<
"Found two consecutive missing hits. First invalid: " << firstinvalid;
257 myHits.erase(myHits.begin()+firstinvalid,myHits.end());
265 if ( ( hasoutliers ||
266 has_low_pixel_prob ) &&
270 smoothed.swap(tmp_first);
274 while ( hasoutliers || has_low_pixel_prob );
276 if ( !smoothed.empty() )
278 if ( noInvalidHitsBeginEnd )
281 if ( !smoothed[0].
empty() &&
282 !smoothed[0].lastMeasurement().recHit()->isValid() )
283 LogTrace(
"TrackFitters") <<
"Last measurement is invalid";
285 while ( !smoothed[0].
empty() &&
286 !smoothed[0].lastMeasurement().recHit()->isValid() )
290 if ( !smoothed[0].firstMeasurement().recHit()->isValid() )
292 LogTrace(
"TrackFitters") <<
"First measurement is invalid";
293 Trajectory tmpTraj(smoothed[0].seed(),smoothed[0].direction());
296 Trajectory::DataContainer::iterator it;
297 for ( it=meas.begin(); it!=meas.end(); ++it )
299 if ( !it->recHit()->isValid() )
303 tmpTraj.
push(*it,smoothed[0].chiSquared());
305 for (Trajectory::DataContainer::iterator itt=it+1; itt!=meas.end();++itt)
307 tmpTraj.
push(*itt,0);
311 smoothed.push_back(tmpTraj);
317 LogTrace(
"TrackFitters") <<
"end: returning smoothed trajectory with chi2="
318 << smoothed[0].chiSquared() ;
338 for(vector<Trajectory>::iterator it = fitted.begin(); it != fitted.end();
340 vector<Trajectory> mysmoothed = smoother()->trajectories(*it);
341 smoothed.insert(smoothed.end(), mysmoothed.begin(), mysmoothed.end());
343 LogDebug(
"TrackFitters") <<
"In KFFittingSmoother::smoothingStep "<<smoothed.size();
350 "KFFittingSmoother::fit(TrajectorySeed, <TransientTrackingRecHit>) not implemented");
352 return vector<Trajectory>();
float clusterProbability(unsigned int flags=0) const
static RecHitPointer build(const GeomDet *geom, Type type=TrackingRecHit::missing, const DetLayer *layer=0)
virtual std::vector< Trajectory > fit(const Trajectory &t) const
std::vector< TrajectoryMeasurement > DataContainer
void smoothingStep(std::vector< Trajectory > &fitted, std::vector< Trajectory > &smoothed) const
virtual ~KFFittingSmoother()
Trajectory::RecHitContainer RecHitContainer
void push(const TrajectoryMeasurement &tm)