Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef MaxHitsTrajectoryFilter_H
0002 #define MaxHitsTrajectoryFilter_H
0003 
0004 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0005 #include "TrackingTools/TrajectoryFiltering/interface/TrajectoryFilter.h"
0006 
0007 class MaxHitsTrajectoryFilter final : public TrajectoryFilter {
0008 public:
0009   explicit MaxHitsTrajectoryFilter(int maxHits = 10000) : theMaxHits(maxHits) {}
0010 
0011   explicit MaxHitsTrajectoryFilter(const edm::ParameterSet& pset, edm::ConsumesCollector& iC)
0012       : theMaxHits(pset.getParameter<int>("maxNumberOfHits")) {
0013     if (theMaxHits < 0)
0014       theMaxHits = 10000;
0015   }
0016 
0017   static void fillPSetDescription(edm::ParameterSetDescription& iDesc) { iDesc.add<int>("maxNumberOfHits", 100); }
0018 
0019   bool qualityFilter(const Trajectory& traj) const override { return TrajectoryFilter::qualityFilterIfNotContributing; }
0020   bool qualityFilter(const TempTrajectory& traj) const override {
0021     return TrajectoryFilter::qualityFilterIfNotContributing;
0022   }
0023 
0024   bool toBeContinued(TempTrajectory& traj) const override { return TBC<TempTrajectory>(traj); }
0025   bool toBeContinued(Trajectory& traj) const override { return TBC<Trajectory>(traj); }
0026 
0027   std::string name() const override { return "MaxHitsTrajectoryFilter"; }
0028 
0029 protected:
0030   template <class T>
0031   bool TBC(T& traj) const {
0032     bool ret = traj.foundHits() < theMaxHits;
0033     if (!ret)
0034       traj.setStopReason(StopReason::MAX_HITS);
0035     return ret;
0036   }
0037 
0038   int theMaxHits;
0039 };
0040 
0041 #endif