Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:40

0001 #ifndef SeedExtensionTrajectoryFilter_H
0002 #define SeedExtensionTrajectoryFilter_H
0003 
0004 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0005 #include "TrackingTools/TrajectoryFiltering/interface/TrajectoryFilter.h"
0006 
0007 class SeedExtensionTrajectoryFilter final : public TrajectoryFilter {
0008 public:
0009   explicit SeedExtensionTrajectoryFilter() {}
0010 
0011   explicit SeedExtensionTrajectoryFilter(edm::ParameterSet const& pset, edm::ConsumesCollector&)
0012       : theStrict(pset.getParameter<bool>("strictSeedExtension")),
0013         thePixel(pset.getParameter<bool>("pixelSeedExtension")),
0014         theExtension(pset.getParameter<int>("seedExtension")) {}
0015 
0016   static void fillPSetDescription(edm::ParameterSetDescription& iDesc) {
0017     iDesc.add<bool>("strictSeedExtension", false);
0018     iDesc.add<bool>("pixelSeedExtension", false);
0019     iDesc.add<int>("seedExtension", 0);
0020   }
0021 
0022   bool qualityFilter(const Trajectory& traj) const override { return QF(traj); }
0023   bool qualityFilter(const TempTrajectory& traj) const override { return QF(traj); }
0024 
0025   bool toBeContinued(TempTrajectory& traj) const override { return TBC<TempTrajectory>(traj); }
0026   bool toBeContinued(Trajectory& traj) const override { return TBC<Trajectory>(traj); }
0027 
0028   std::string name() const override { return "LostHitsFractionTrajectoryFilter"; }
0029 
0030 private:
0031   template <class T>
0032   bool QF(const T& traj) const {
0033     return traj.stopReason() != StopReason::SEED_EXTENSION;  // reject tracks killed by seed extension
0034   }
0035 
0036   template <class T>
0037   bool TBC(T& traj) const {
0038     if (theExtension <= 0)
0039       return true;  // skipping checks explicitly when intended to be disabled is the safest way
0040     const bool ret = theStrict ? strictTBC(traj) : looseTBC(traj);
0041     if (!ret)
0042       traj.setStopReason(StopReason::SEED_EXTENSION);
0043     return ret;
0044   }
0045   template <class T>
0046   bool looseTBC(const T& traj) const;
0047   template <class T>
0048   bool strictTBC(const T& traj) const;
0049 
0050   bool theStrict = false;
0051   bool thePixel = false;
0052   int theExtension = 0;
0053 };
0054 
0055 template <class T>
0056 bool SeedExtensionTrajectoryFilter::looseTBC(const T& traj) const {
0057   int nhits = 0;
0058   if (thePixel) {
0059     for (const auto& tm : traj.measurements()) {
0060       if (Trajectory::pixel(*(tm.recHit())))
0061         ++nhits;
0062     }
0063   } else {
0064     nhits = traj.measurements().size();
0065   }
0066   return (nhits > int(traj.seedNHits()) + theExtension) || (0 == traj.lostHits());
0067 }
0068 
0069 // strict case as a real seeding: do not allow even inactive
0070 template <class T>
0071 bool SeedExtensionTrajectoryFilter::strictTBC(const T& traj) const {
0072   const int nhits = thePixel ? traj.foundPixelHits() : traj.foundHits();
0073   return nhits >= int(traj.seedNHits()) + theExtension;
0074 }
0075 
0076 #endif