00001 #ifndef RecoSelectors_TrackingParticleSelector_h
00002 #define RecoSelectors_TrackingParticleSelector_h
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
00012
00013 class TrackingParticleSelector {
00014
00015 public:
00016 TrackingParticleSelector(){}
00017 TrackingParticleSelector ( double ptMin,double minRapidity,double maxRapidity,
00018 double tip,double lip,int minHit, bool signalOnly, bool chargedOnly,
00019 std::vector<int> pdgId = std::vector<int>()) :
00020 ptMin_( ptMin ), minRapidity_( minRapidity ), maxRapidity_( maxRapidity ),
00021 tip_( tip ), lip_( lip ), minHit_( minHit ), signalOnly_(signalOnly), chargedOnly_(chargedOnly), pdgId_( pdgId ) { }
00022
00024 bool operator()( const TrackingParticle & tp ) const {
00025 if (chargedOnly_ && tp.charge()==0) return false;
00026 bool testId = false;
00027 unsigned int idSize = pdgId_.size();
00028 if (idSize==0) testId = true;
00029 else for (unsigned int it=0;it!=idSize;++it){
00030 if (tp.pdgId()==pdgId_[it]) testId = true;
00031 }
00032 bool signal = true;
00033 if (signalOnly_) signal = (tp.eventId().bunchCrossing()== 0 && tp.eventId().event() == 0);
00034 return (
00035 tp.matchedHit() >= minHit_ &&
00036 sqrt(tp.momentum().perp2()) >= ptMin_ &&
00037 tp.momentum().eta() >= minRapidity_ && tp.momentum().eta() <= maxRapidity_ &&
00038 sqrt(tp.vertex().perp2()) <= tip_ &&
00039 fabs(tp.vertex().z()) <= lip_ &&
00040 testId &&
00041 signal
00042 );
00043 }
00044
00045 private:
00046 double ptMin_;
00047 double minRapidity_;
00048 double maxRapidity_;
00049 double tip_;
00050 double lip_;
00051 int minHit_;
00052 bool signalOnly_;
00053 bool chargedOnly_;
00054 std::vector<int> pdgId_;
00055
00056 };
00057
00058 #include "PhysicsTools/UtilAlgos/interface/ParameterAdapter.h"
00059
00060 namespace reco {
00061 namespace modules {
00062
00063 template<>
00064 struct ParameterAdapter<TrackingParticleSelector> {
00065 static TrackingParticleSelector make( const edm::ParameterSet & cfg ) {
00066 return TrackingParticleSelector(
00067 cfg.getParameter<double>( "ptMin" ),
00068 cfg.getParameter<double>( "minRapidity" ),
00069 cfg.getParameter<double>( "maxRapidity" ),
00070 cfg.getParameter<double>( "tip" ),
00071 cfg.getParameter<double>( "lip" ),
00072 cfg.getParameter<int>( "minHit" ),
00073 cfg.getParameter<bool>( "signalOnly" ),
00074 cfg.getParameter<bool>( "chargedOnly" ),
00075 cfg.getParameter<std::vector<int> >( "pdgId" ));
00076 }
00077 };
00078
00079 }
00080 }
00081
00082 #endif