Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-10 06:14:23

0001 #ifndef MaxConsecLostHitsTrajectoryFilter_H
0002 #define MaxConsecLostHitsTrajectoryFilter_H
0003 
0004 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0005 #include "TrackingTools/TrajectoryFiltering/interface/TrajectoryFilter.h"
0006 
0007 class MaxConsecLostHitsTrajectoryFilter final : public TrajectoryFilter {
0008 public:
0009   explicit MaxConsecLostHitsTrajectoryFilter(int maxHits = 0) : theMaxConsecLostHits(maxHits) {}
0010 
0011   explicit MaxConsecLostHitsTrajectoryFilter(const edm::ParameterSet& pset, edm::ConsumesCollector& iC)
0012       : theMaxConsecLostHits(pset.getParameter<int>("maxConsecLostHits")) {}
0013 
0014   static void fillPSetDescription(edm::ParameterSetDescription& iDesc) { iDesc.add<int>("maxConsecLostHits", 1); }
0015 
0016   bool qualityFilter(const Trajectory& traj) const override { return TrajectoryFilter::qualityFilterIfNotContributing; }
0017   bool qualityFilter(const TempTrajectory& traj) const override {
0018     return TrajectoryFilter::qualityFilterIfNotContributing;
0019   }
0020 
0021   bool toBeContinued(TempTrajectory& traj) const override { return TBC<TempTrajectory>(traj); }
0022   bool toBeContinued(Trajectory& traj) const override { return TBC<Trajectory>(traj); }
0023 
0024   std::string name() const override { return "MaxConsecLostHitsTrajectoryFilter"; }
0025 
0026 protected:
0027   template <class T>
0028   bool TBC(T& traj) const {
0029     int consecLostHit = 0;
0030     const typename T::DataContainer& tms = traj.measurements();
0031     typename T::DataContainer::size_type itm;
0032     for (itm = tms.size(); itm != 0; --itm) {
0033       if (tms[itm - 1].recHit()->isValid())
0034         break;
0035       else if (  // FIXME: restore this:   !Trajectory::inactive(tms[itm-1].recHit()->det()) &&
0036           Trajectory::lost(*tms[itm - 1].recHit()))
0037         consecLostHit++;
0038     }
0039 
0040     bool ret = consecLostHit <= theMaxConsecLostHits;
0041     if (!ret)
0042       traj.setStopReason(StopReason::MAX_CONSECUTIVE_LOST_HITS);
0043     return ret;
0044   }
0045 
0046   int theMaxConsecLostHits;
0047 };
0048 
0049 #endif