CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/TrackingTools/TrajectoryFiltering/interface/ThresholdPtTrajectoryFilter.h

Go to the documentation of this file.
00001 #ifndef ThresholdPtTrajectoryFilter_H
00002 #define ThresholdPtTrajectoryFilter_H
00003 
00004 #include "TrackingTools/TrajectoryFiltering/interface/TrajectoryFilter.h"
00005 #include "TrackingTools/PatternTools/interface/Trajectory.h"
00006 #include "TrackingTools/PatternTools/interface/TempTrajectory.h"
00007 
00008 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00009 #include "TrackingTools/TrajectoryParametrization/interface/CurvilinearTrajectoryError.h"
00010 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateAccessor.h"
00011 
00018 class ThresholdPtTrajectoryFilter : public TrajectoryFilter {
00019 public:
00020 
00021   explicit ThresholdPtTrajectoryFilter( double ptThreshold, float nSigma = 5.F, int nH=3): thePtThreshold( ptThreshold), theNSigma(nSigma), theMinHits(nH) {}
00022 
00023   explicit ThresholdPtTrajectoryFilter( const edm::ParameterSet & pset) :
00024     thePtThreshold(pset.getParameter<double>("thresholdPt")),
00025     theNSigma(pset.getParameter<double>("nSigmaThresholdPt")),
00026     theMinHits(pset.getParameter<int>("minHitsThresholdPt"))
00027       {}
00028 
00029   virtual bool qualityFilter( const Trajectory& traj) const { return !test(traj.lastMeasurement(),traj.foundHits());}
00030   virtual bool qualityFilter( const TempTrajectory& traj) const { return !test(traj.lastMeasurement(),traj.foundHits());}
00031    
00032   virtual bool toBeContinued( Trajectory& traj) const { return test(traj.lastMeasurement(),traj.foundHits()); }
00033   virtual bool toBeContinued( TempTrajectory& traj) const { return test(traj.lastMeasurement(),traj.foundHits()); }
00034   
00035   virtual std::string name() const {return "ThresholdPtTrajectoryFilter";}
00036 
00037  protected:
00038 
00039   bool test( const TrajectoryMeasurement & tm, int foundHits) const 
00040   {
00041     //first check min number of hits 
00042     if (foundHits < theMinHits ){ return true;}
00043 
00044     // check for momentum below limit
00045     const FreeTrajectoryState& fts = *tm.updatedState().freeTrajectoryState();
00046 
00047     //avoid doing twice the check in TBC and QF
00048     static bool answerMemory=false;
00049     static FreeTrajectoryState ftsMemory;
00050     if (ftsMemory.parameters().vector() == fts.parameters().vector()) { return answerMemory;}
00051     ftsMemory=fts;
00052 
00053     //if p_T is way too small: stop
00054     double pT = fts.momentum().perp();
00055     if (pT<0.010) {answerMemory=false; return false;}
00056     //if error is way too big: stop
00057     double invError = TrajectoryStateAccessor(fts).inversePtError();
00058     if (invError > 1.e10) {answerMemory=false;return false;}
00059 
00060     //calculate the actual pT cut: 
00061     if ((1/pT + theNSigma*invError ) < 1/thePtThreshold ) {answerMemory=false; return false;}
00062     //    first term is the minimal value of pT (pT-N*sigma(pT))
00063     //    secon term is the cut
00064 
00065     answerMemory=true; return true;
00066   }
00067 
00068   double thePtThreshold;
00069   double theNSigma;
00070   int theMinHits;
00071 
00072 };
00073 
00074 #endif