19 return smoothingStep(theFitter->fitOne(t,type));
25 const std::vector<TrajectoryMeasurement> & vtm = theTraj.
measurements();
26 for (std::vector<TrajectoryMeasurement>::const_iterator tm=vtm.begin(); tm!=vtm.end();tm++) {
42 LogDebug(
"TrackFitters") <<
"In KFFittingSmoother::fit";
46 bool hasoutliers=
false;
47 bool has_low_pixel_prob=
false;
50 double log_pixel_probability_lower_limit = -15.0;
69 has_low_pixel_prob =
false;
71 double cut = theEstimateCut;
73 double log_pixel_prob_cut = theLogPixelProbabilityCut;
76 unsigned int outlierId = 0;
79 unsigned int low_pixel_prob_Id = 0;
80 const GeomDet* low_pixel_prob_Det = 0;
83 smoothed = smoothingStep(theFitter->fitOne(aSeed, myHits, firstPredTsos));
88 if ( rejectTracksFlag ) {
89 LogTrace(
"TrackFitters") <<
"smoothed invalid => trajectory rejected";
92 LogTrace(
"TrackFitters") <<
"smoothed invalid => returning orignal trajectory" ;
106 if (!checkForNans(smoothed)) {
112 if ( theEstimateCut > 0 || log_pixel_prob_cut > log_pixel_probability_lower_limit ) {
113 if ( smoothed.
foundHits() < theMinNumberOfHits ) {
114 if ( rejectTracksFlag ) {
115 LogTrace(
"TrackFitters") <<
"smoothed.foundHits()<theMinNumberOfHits => trajectory rejected";
125 <<
"smoothed.foundHits()<theMinNumberOfHits => returning orignal trajectory with chi2="
132 const std::vector<TrajectoryMeasurement> & vtm = smoothed.
measurements();
134 double log_pixel_hit_probability = -999999.9;
136 for (std::vector<TrajectoryMeasurement>::const_iterator tm=vtm.begin(); tm!=vtm.end();tm++) {
137 double estimate = tm->estimate();
140 if ( estimate > cut && theEstimateCut > 0 ) {
143 outlierId = tm->recHit()->geographicalId().rawId();
144 outlierDet = tm->recHit()->det();
150 if(log_pixel_prob_cut > log_pixel_probability_lower_limit){
158 unsigned int testSubDetID = ( hit->geographicalId().subdetId() );
160 if ( hit->isValid() &&
169 if ( !persistentHit == 0 &&
178 if ( pixel_hit_probability < 0.0 )
179 LogDebug(
"From KFFittingSmoother.cc")
180 <<
"Wraning : Negative pixel hit probability !!!! Will set the probability to 10^{-15} !!!" << endl;
182 if ( pixel_hit_probability <= 0.0 || log10( pixel_hit_probability ) < log_pixel_probability_lower_limit )
183 log_pixel_hit_probability = log_pixel_probability_lower_limit;
185 log_pixel_hit_probability = log10( pixel_hit_probability );
187 int qbin = (int)pixhit->
qBin();
189 if ( ( log_pixel_hit_probability < log_pixel_prob_cut ) &&
192 has_low_pixel_prob =
true;
193 log_pixel_prob_cut = log_pixel_hit_probability;
194 low_pixel_prob_Id = tm->recHit()->geographicalId().rawId();
195 low_pixel_prob_Det = tm->recHit()->det();
207 if ( hasoutliers || has_low_pixel_prob ) {
210 for (
unsigned int j=0;
j<myHits.size(); ++
j ) {
211 if ( hasoutliers && outlierId == myHits[
j]->geographicalId().rawId() )
213 LogTrace(
"TrackFitters") <<
"Rejecting outlier hit with estimate " << cut <<
" at position "
214 <<
j <<
" with rawId=" << myHits[
j]->geographicalId().rawId();
215 LogTrace(
"TrackFitters") <<
"The fit will be repeated without the outlier";
218 else if ( has_low_pixel_prob && low_pixel_prob_Id == myHits[
j]->geographicalId().rawId() ){
219 LogTrace(
"TrackFitters") <<
"Rejecting low proability pixel hit with log_pixel_prob_cut = "
220 << log_pixel_prob_cut <<
" at position "
221 <<
j <<
" with rawId =" << myHits[
j]->geographicalId().rawId();
222 LogTrace(
"TrackFitters") <<
"The fit will be repeated without the outlier";
229 if ( breakTrajWith2ConsecutiveMissing ) {
230 unsigned int firstinvalid = myHits.size();
231 for (
unsigned int j=0;
j<myHits.size()-1; ++
j )
237 LogTrace(
"TrackFitters") <<
"Found two consecutive missing hits. First invalid: " << firstinvalid;
244 if (firstinvalid != myHits.size()) myHits.erase(myHits.begin()+firstinvalid,myHits.end());
252 if ( ( hasoutliers ||
253 has_low_pixel_prob ) &&
256 std::swap(smoothed,tmp_first); firstTry=
false;
260 while ( hasoutliers || has_low_pixel_prob );
263 if ( noInvalidHitsBeginEnd ) {
266 LogTrace(
"TrackFitters") <<
"Last measurement is invalid";
273 LogTrace(
"TrackFitters") <<
"First measurement is in`valid";
276 auto it = meas.begin();
277 for ( ; it!=meas.end(); ++it )
278 if ( it->recHitR().isValid() )
break;
279 tmpTraj.push(std::move(*it),smoothed.
chiSquared());
281 for (
auto itt=it+1; itt!=meas.end();++itt)
282 tmpTraj.push(std::move(*itt),0);
290 LogTrace(
"TrackFitters") <<
"end: returning smoothed trajectory with chi2="
311 "KFFittingSmoother::fit(TrajectorySeed, <TransientTrackingRecHit>) not implemented");
float clusterProbability(unsigned int flags=0) const
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
bool checkForNans(const Trajectory &theTraj) const
Method to check that the trajectory has no NaN in the states and chi2.
PropagationDirection const & direction() const
DataContainer const & measurements() const
std::vector< TrajectoryMeasurement > DataContainer
Trajectory fitOne(const Trajectory &t, fitType type) const
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
TrajectoryMeasurement const & lastMeasurement() const
virtual TrackingRecHit const * hit() const
TrajectoryMeasurement const & firstMeasurement() const
ROOT::Math::SVector< double, 5 > AlgebraicVector5
TrackingRecHit const & recHitR() const
Trajectory::RecHitContainer RecHitContainer