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 SimTracker_Common_TrackingParticleSelector_h
2 #define SimTracker_Common_TrackingParticleSelector_h
3 /* \class TrackingParticleSelector
4  *
5  * \author Giuseppe Cerati, INFN
6  *
7  * $Date: 2013/05/14 15:46:46 $
8  * $Revision: 1.5.4.2 $
9  *
10  */
13 
15 
16 public:
18  TrackingParticleSelector ( double ptMin,double minRapidity,double maxRapidity,
19  double tip,double lip,int minHit, bool signalOnly, bool chargedOnly, bool stableOnly,
20  const std::vector<int>& pdgId = std::vector<int>()) :
21  ptMin_( ptMin ), minRapidity_( minRapidity ), maxRapidity_( maxRapidity ),
22  tip_( tip ), lip_( lip ), minHit_( minHit ), signalOnly_(signalOnly), chargedOnly_(chargedOnly), stableOnly_(stableOnly), pdgId_( pdgId ) { }
23 
25  bool operator()( const TrackingParticle & tp ) const {
26  if (chargedOnly_ && tp.charge()==0) return false;//select only if charge!=0
27  bool testId = false;
28  unsigned int idSize = pdgId_.size();
29  if (idSize==0) testId = true;
30  else for (unsigned int it=0;it!=idSize;++it){
31  if (tp.pdgId()==pdgId_[it]) testId = true;
32  }
33  bool signal = true;
34  if (signalOnly_) signal = (tp.eventId().bunchCrossing()== 0 && tp.eventId().event() == 0); // signal only means no PU particles
35  // select only stable particles
36  bool stable = true;
37  if (stableOnly_) {
38  if (!signal) {
39  stable = false; // we are not interested into PU particles among the stable ones
40  } else {
42  if (j->get()==0 || j->get()->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 (
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 
81 
82 namespace reco {
83  namespace modules {
84 
85  template<>
89  cfg.getParameter<double>( "ptMin" ),
90  cfg.getParameter<double>( "minRapidity" ),
91  cfg.getParameter<double>( "maxRapidity" ),
92  cfg.getParameter<double>( "tip" ),
93  cfg.getParameter<double>( "lip" ),
94  cfg.getParameter<int>( "minHit" ),
95  cfg.getParameter<bool>( "signalOnly" ),
96  cfg.getParameter<bool>( "chargedOnly" ),
97  cfg.getParameter<bool>( "stableOnly" ),
98  cfg.getParameter<std::vector<int> >( "pdgId" ));
99  }
100  };
101 
102  }
103 }
104 
105 #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?)
TrackingParticleSelector(double ptMin, double minRapidity, double maxRapidity, double tip, double lip, int minHit, bool signalOnly, bool chargedOnly, bool stableOnly, const std::vector< int > &pdgId=std::vector< int >())
int pdgId() const
PDG ID.
Point vertex() const
Parent vertex position.
static const int stable
Definition: TopGenEvent.h:11
int status() const
Status word.
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
T sqrt(T t)
Definition: SSEVec.h:48
int bunchCrossing() const
get the detector field from this detid
int numberOfTrackerLayers() const
The number of tracker layers with a hit.
int j
Definition: DBlmapReader.cc:9
bool operator()(const TrackingParticle &tp) const
Operator() performs the selection: e.g. if (tPSelector(tp)) {...}.
genp_iterator genParticle_end() const
EncodedEventId eventId() const
Signal source, crossing number.
Vector momentum() const
spatial momentum vector
Monte Carlo truth information used for tracking validation.
int charge() const
Electric charge. Note this is taken from the first SimTrack only.
static TrackingParticleSelector make(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)