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 = 0xffffffff;
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) ) &&
141 tm->recHit()->det()!=
nullptr
145 outlierId = tm->recHit()->geographicalId().rawId();
146 outlierDet = tm->recHit()->det();
152 if(log_pixel_prob_cut > log_pixel_probability_lower_limit){
160 unsigned int testSubDetID = ( hit->geographicalId().subdetId() );
162 if ( hit->isValid() &&
171 if ( !persistentHit == 0 &&
180 if ( pixel_hit_probability < 0.0 )
181 LogDebug(
"From KFFittingSmoother.cc")
182 <<
"Wraning : Negative pixel hit probability !!!! Will set the probability to 10^{-15} !!!" << endl;
184 if ( pixel_hit_probability <= 0.0 || log10( pixel_hit_probability ) < log_pixel_probability_lower_limit )
185 log_pixel_hit_probability = log_pixel_probability_lower_limit;
187 log_pixel_hit_probability = log10( pixel_hit_probability );
189 int qbin = (int)pixhit->
qBin();
191 if ( ( log_pixel_hit_probability < log_pixel_prob_cut ) &&
194 has_low_pixel_prob =
true;
195 log_pixel_prob_cut = log_pixel_hit_probability;
196 low_pixel_prob_Id = tm->recHit()->geographicalId().rawId();
197 low_pixel_prob_Det = tm->recHit()->det();
209 if ( hasoutliers || has_low_pixel_prob ) {
212 for (
unsigned int j=0;
j<myHits.size(); ++
j ) {
213 if ( hasoutliers && outlierId == myHits[
j]->geographicalId().rawId() )
215 LogTrace(
"TrackFitters") <<
"Rejecting outlier hit with estimate " << cut <<
" at position "
216 <<
j <<
" with rawId=" << myHits[
j]->geographicalId().rawId();
217 LogTrace(
"TrackFitters") <<
"The fit will be repeated without the outlier";
220 else if ( has_low_pixel_prob && low_pixel_prob_Id == myHits[
j]->geographicalId().rawId() ){
221 LogTrace(
"TrackFitters") <<
"Rejecting low proability pixel hit with log_pixel_prob_cut = "
222 << log_pixel_prob_cut <<
" at position "
223 <<
j <<
" with rawId =" << myHits[
j]->geographicalId().rawId();
224 LogTrace(
"TrackFitters") <<
"The fit will be repeated without the outlier";
231 if ( breakTrajWith2ConsecutiveMissing ) {
232 unsigned int firstinvalid = myHits.size();
233 for (
unsigned int j=0;
j<myHits.size()-1; ++
j )
239 LogTrace(
"TrackFitters") <<
"Found two consecutive missing hits. First invalid: " << firstinvalid;
246 if (firstinvalid != myHits.size()) myHits.erase(myHits.begin()+firstinvalid,myHits.end());
254 if ( ( hasoutliers ||
255 has_low_pixel_prob ) &&
258 std::swap(smoothed,tmp_first); firstTry=
false;
262 while ( hasoutliers || has_low_pixel_prob );
265 if ( noInvalidHitsBeginEnd
270 LogTrace(
"TrackFitters") <<
"Last measurement is invalid";
277 LogTrace(
"TrackFitters") <<
"First measurement is in`valid";
280 auto it = meas.begin();
281 for ( ; it!=meas.end(); ++it )
282 if ( it->recHitR().isValid() )
break;
283 tmpTraj.push(std::move(*it),smoothed.
chiSquared());
285 for (
auto itt=it+1; itt!=meas.end();++itt)
286 tmpTraj.push(std::move(*itt),0);
294 LogTrace(
"TrackFitters") <<
"end: returning smoothed trajectory with chi2="
315 "KFFittingSmoother::fit(TrajectorySeed, <TransientTrackingRecHit>) not implemented");
bool empty() const
True if trajectory has no measurements.
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