17 KFFittingSmoother::~KFFittingSmoother()
25 return smoothingStep(fitter()->fitOne(t,type));
28 bool KFFittingSmoother::checkForNans(
const Trajectory & theTraj)
const
31 const std::vector<TrajectoryMeasurement> & vtm = theTraj.
measurements();
32 for (std::vector<TrajectoryMeasurement>::const_iterator tm=vtm.begin(); tm!=vtm.end();tm++) {
44 const RecHitContainer& hits,
48 LogDebug(
"TrackFitters") <<
"In KFFittingSmoother::fit";
52 bool hasoutliers=
false;
53 bool has_low_pixel_prob=
false;
56 double log_pixel_probability_lower_limit = -15.0;
58 RecHitContainer myHits = hits;
75 has_low_pixel_prob =
false;
77 double cut = theEstimateCut;
79 double log_pixel_prob_cut = theLogPixelProbabilityCut;
82 unsigned int outlierId = 0;
85 unsigned int low_pixel_prob_Id = 0;
86 const GeomDet* low_pixel_prob_Det = 0;
89 smoothed = smoothingStep(fitter()->fitOne(aSeed, myHits, firstPredTsos));
94 if ( rejectTracksFlag ) {
95 LogTrace(
"TrackFitters") <<
"smoothed invalid => trajectory rejected";
98 LogTrace(
"TrackFitters") <<
"smoothed invalid => returning orignal trajectory" ;
112 if (!checkForNans(smoothed)) {
118 if ( theEstimateCut > 0 || log_pixel_prob_cut > log_pixel_probability_lower_limit ) {
119 if ( smoothed.
foundHits() < theMinNumberOfHits ) {
120 if ( rejectTracksFlag ) {
121 LogTrace(
"TrackFitters") <<
"smoothed.foundHits()<theMinNumberOfHits => trajectory rejected";
131 <<
"smoothed.foundHits()<theMinNumberOfHits => returning orignal trajectory with chi2="
138 const std::vector<TrajectoryMeasurement> & vtm = smoothed.
measurements();
140 double log_pixel_hit_probability = -999999.9;
142 for (std::vector<TrajectoryMeasurement>::const_iterator tm=vtm.begin(); tm!=vtm.end();tm++) {
143 double estimate = tm->estimate();
146 if ( estimate > cut && theEstimateCut > 0 ) {
149 outlierId = tm->recHit()->geographicalId().rawId();
150 outlierDet = tm->recHit()->det();
156 if(log_pixel_prob_cut > log_pixel_probability_lower_limit){
164 unsigned int testSubDetID = ( hit->geographicalId().subdetId() );
166 if ( hit->isValid() &&
175 if ( !persistentHit == 0 &&
182 double pixel_hit_probability = (float)pixhit->clusterProbability(0);
184 if ( pixel_hit_probability < 0.0 )
185 LogDebug(
"From KFFittingSmoother.cc")
186 <<
"Wraning : Negative pixel hit probability !!!! Will set the probability to 10^{-15} !!!" << endl;
188 if ( pixel_hit_probability <= 0.0 || log10( pixel_hit_probability ) < log_pixel_probability_lower_limit )
189 log_pixel_hit_probability = log_pixel_probability_lower_limit;
191 log_pixel_hit_probability = log10( pixel_hit_probability );
193 int qbin = (int)pixhit->qBin();
195 if ( ( log_pixel_hit_probability < log_pixel_prob_cut ) &&
198 has_low_pixel_prob =
true;
199 log_pixel_prob_cut = log_pixel_hit_probability;
200 low_pixel_prob_Id = tm->recHit()->geographicalId().rawId();
201 low_pixel_prob_Det = tm->recHit()->det();
213 if ( hasoutliers || has_low_pixel_prob ) {
216 for (
unsigned int j=0;
j<myHits.size(); ++
j ) {
217 if ( hasoutliers && outlierId == myHits[
j]->geographicalId().rawId() )
219 LogTrace(
"TrackFitters") <<
"Rejecting outlier hit with estimate " << cut <<
" at position "
220 <<
j <<
" with rawId=" << myHits[
j]->geographicalId().rawId();
221 LogTrace(
"TrackFitters") <<
"The fit will be repeated without the outlier";
224 else if ( has_low_pixel_prob && low_pixel_prob_Id == myHits[
j]->geographicalId().rawId() ){
225 LogTrace(
"TrackFitters") <<
"Rejecting low proability pixel hit with log_pixel_prob_cut = "
226 << log_pixel_prob_cut <<
" at position "
227 <<
j <<
" with rawId =" << myHits[
j]->geographicalId().rawId();
228 LogTrace(
"TrackFitters") <<
"The fit will be repeated without the outlier";
235 if ( breakTrajWith2ConsecutiveMissing ) {
236 unsigned int firstinvalid = myHits.size();
237 for (
unsigned int j=0;
j<myHits.size()-1; ++
j )
243 LogTrace(
"TrackFitters") <<
"Found two consecutive missing hits. First invalid: " << firstinvalid;
250 if (firstinvalid != myHits.size()) myHits.erase(myHits.begin()+firstinvalid,myHits.end());
258 if ( ( hasoutliers ||
259 has_low_pixel_prob ) &&
262 std::swap(smoothed,tmp_first); firstTry=
false;
266 while ( hasoutliers || has_low_pixel_prob );
269 if ( noInvalidHitsBeginEnd ) {
272 LogTrace(
"TrackFitters") <<
"Last measurement is invalid";
279 LogTrace(
"TrackFitters") <<
"First measurement is in`valid";
283 Trajectory::DataContainer::const_iterator it;
284 for ( it=meas.begin(); it!=meas.end(); ++it )
285 if ( it->recHitR().isValid() )
break;
288 for (Trajectory::DataContainer::const_iterator itt=it+1; itt!=meas.end();++itt)
289 tmpTraj.push(*itt,0);
297 LogTrace(
"TrackFitters") <<
"end: returning smoothed trajectory with chi2="
315 const RecHitContainer& hits,fitType type)
const{
318 "KFFittingSmoother::fit(TrajectorySeed, <TransientTrackingRecHit>) not implemented");
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
PropagationDirection const & direction() const
DataContainer const & measurements() const
std::vector< TrajectoryMeasurement > DataContainer
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
TrajectoryMeasurement const & lastMeasurement() const
TrajectoryMeasurement const & firstMeasurement() const
ROOT::Math::SVector< double, 5 > AlgebraicVector5
ConstRecHitPointer::element_type const & recHitR() const
double chiSquared() const