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: 2012/05/17 16:12:35 $
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, bool stableOnly,
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), stableOnly_(stableOnly), pdgId_( pdgId ) { }
22 
24  bool operator()( const TrackingParticle & tp ) const {
25  if (chargedOnly_ && tp.charge()==0) return false;//select only if charge!=0
26  bool testId = false;
27  unsigned int idSize = pdgId_.size();
28  if (idSize==0) testId = true;
29  else for (unsigned int it=0;it!=idSize;++it){
30  if (tp.pdgId()==pdgId_[it]) testId = true;
31  }
32  bool signal = true;
33  if (signalOnly_) signal = (tp.eventId().bunchCrossing()== 0 && tp.eventId().event() == 0); // signal only means no PU particles
34  // select only stable particles
35  bool stable = true;
36  if (stableOnly_) {
37  if (!signal) {
38  stable = false; // we are not interested into PU particles among the stable ones
39  } else {
41  const HepMC::GenParticle * p = j->get();
42  if (!p || p->status() != 1) {
43  stable = 0; break;
44  }
45  }
46  // test for remaining unstabled due to lack of genparticle pointer
47  if(stable == 1 && tp.status() == -99 &&
48  (fabs(tp.pdgId()) != 11 && fabs(tp.pdgId()) != 13 && fabs(tp.pdgId()) != 211 &&
49  fabs(tp.pdgId()) != 321 && fabs(tp.pdgId()) != 2212 && fabs(tp.pdgId()) != 3112 &&
50  fabs(tp.pdgId()) != 3222 && fabs(tp.pdgId()) != 3312 && fabs(tp.pdgId()) != 3334)) stable = 0;
51  }
52  }
53  return (
54  tp.matchedHit() >= minHit_ &&
55  sqrt(tp.momentum().perp2()) >= ptMin_ &&
56  tp.momentum().eta() >= minRapidity_ && tp.momentum().eta() <= maxRapidity_ &&
57  sqrt(tp.vertex().perp2()) <= tip_ &&
58  fabs(tp.vertex().z()) <= lip_ &&
59  testId &&
60  signal &&
61  stable
62  );
63  }
64 
65 private:
66  double ptMin_;
67  double minRapidity_;
68  double maxRapidity_;
69  double tip_;
70  double lip_;
71  int minHit_;
75  std::vector<int> pdgId_;
76 
77 };
78 
80 
81 namespace reco {
82  namespace modules {
83 
84  template<>
88  cfg.getParameter<double>( "ptMin" ),
89  cfg.getParameter<double>( "minRapidity" ),
90  cfg.getParameter<double>( "maxRapidity" ),
91  cfg.getParameter<double>( "tip" ),
92  cfg.getParameter<double>( "lip" ),
93  cfg.getParameter<int>( "minHit" ),
94  cfg.getParameter<bool>( "signalOnly" ),
95  cfg.getParameter<bool>( "chargedOnly" ),
96  cfg.getParameter<bool>( "stableOnly" ),
97  cfg.getParameter<std::vector<int> >( "pdgId" ));
98  }
99  };
100 
101  }
102 }
103 
104 #endif
T getParameter(std::string const &) const
genp_iterator genParticle_begin() const
iterators
int event() const
get the contents of the subdetector field (should be protected?)
int charge() const
electric charge
Definition: ParticleBase.h:54
TrackingParticleSelector(double ptMin, double minRapidity, double maxRapidity, double tip, double lip, int minHit, bool signalOnly, bool chargedOnly, bool stableOnly, std::vector< int > pdgId=std::vector< int >())
int pdgId() const
PDG id, signal source, crossing number.
static const int stable
Definition: TopGenEvent.h:11
int matchedHit() const
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
T sqrt(T t)
Definition: SSEVec.h:46
int bunchCrossing() const
get the detector field from this detid
int j
Definition: DBlmapReader.cc:9
bool operator()(const TrackingParticle &tp) const
Operator() performs the selection: e.g. if (tPSelector(tp)) {...}.
int status() const
status word
Definition: ParticleBase.h:263
genp_iterator genParticle_end() const
Vector momentum() const
spatial momentum vector
Definition: ParticleBase.h:86
EncodedEventId eventId() const
static TrackingParticleSelector make(const edm::ParameterSet &cfg)
const Point & vertex() const
vertex position
Definition: ParticleBase.h:228