CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackingParticleSelector.h
Go to the documentation of this file.
1 #ifndef RecoSelectors_TrackingParticleSelector_h
2 #define RecoSelectors_TrackingParticleSelector_h
3 /* \class TrackingParticleSelector
4  *
5  * \author Giuseppe Cerati, INFN
6  *
7  * $Date: 2008/08/09 14:31:09 $
8  * $Revision: 1.4 $
9  *
10  */
12 
14 
15 public:
17  TrackingParticleSelector ( double ptMin,double minRapidity,double maxRapidity,
18  double tip,double lip,int minHit, bool signalOnly, bool chargedOnly,
19  std::vector<int> pdgId = std::vector<int>()) :
20  ptMin_( ptMin ), minRapidity_( minRapidity ), maxRapidity_( maxRapidity ),
21  tip_( tip ), lip_( lip ), minHit_( minHit ), signalOnly_(signalOnly), chargedOnly_(chargedOnly), pdgId_( pdgId ) { }
22 
24  bool operator()( const TrackingParticle & tp ) const {
25 
26  //quickly reject if it is from pile-up
27  if (signalOnly_ && !(tp.eventId().bunchCrossing()==0 && tp.eventId().event()==0) )return false;
28 
29  if (chargedOnly_ && tp.charge()==0) return false;//select only if charge!=0
30  bool testId = false;
31  unsigned int idSize = pdgId_.size();
32  if (idSize==0) testId = true;
33  else for (unsigned int it=0;it!=idSize;++it){
34  if (tp.pdgId()==pdgId_[it]) testId = true;
35  }
36  return (
37  tp.matchedHit() >= minHit_ &&
38  sqrt(tp.momentum().perp2()) >= ptMin_ &&
39  tp.momentum().eta() >= minRapidity_ && tp.momentum().eta() <= maxRapidity_ &&
40  sqrt(tp.vertex().perp2()) <= tip_ &&
41  fabs(tp.vertex().z()) <= lip_ &&
42  testId
43  );
44  }
45 
46 private:
47  double ptMin_;
48  double minRapidity_;
49  double maxRapidity_;
50  double tip_;
51  double lip_;
52  int minHit_;
55  std::vector<int> pdgId_;
56 
57 };
58 
60 
61 namespace reco {
62  namespace modules {
63 
64  template<>
68  cfg.getParameter<double>( "ptMin" ),
69  cfg.getParameter<double>( "minRapidity" ),
70  cfg.getParameter<double>( "maxRapidity" ),
71  cfg.getParameter<double>( "tip" ),
72  cfg.getParameter<double>( "lip" ),
73  cfg.getParameter<int>( "minHit" ),
74  cfg.getParameter<bool>( "signalOnly" ),
75  cfg.getParameter<bool>( "chargedOnly" ),
76  cfg.getParameter<std::vector<int> >( "pdgId" ));
77  }
78  };
79 
80  }
81 }
82 
83 #endif
T getParameter(std::string const &) const
int event() const
get the contents of the subdetector field (should be protected?)
int charge() const
electric charge
Definition: ParticleBase.h:55
int pdgId() const
PDG id, signal source, crossing number.
int matchedHit() const
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
T sqrt(T t)
Definition: SSEVec.h:28
int bunchCrossing() const
get the detector field from this detid
bool operator()(const TrackingParticle &tp) const
Operator() performs the selection: e.g. if (tPSelector(tp)) {...}.
Vector momentum() const
spatial momentum vector
Definition: ParticleBase.h:87
EncodedEventId eventId() const
TrackingParticleSelector(double ptMin, double minRapidity, double maxRapidity, double tip, double lip, int minHit, bool signalOnly, bool chargedOnly, std::vector< int > pdgId=std::vector< int >())
static TrackingParticleSelector make(const edm::ParameterSet &cfg)
const Point & vertex() const
vertex position
Definition: ParticleBase.h:229