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  */
14 
16 
17 public:
19  TrackingParticleSelector ( double ptMin,double minRapidity,double maxRapidity,
20  double tip,double lip,int minHit, bool signalOnly, bool chargedOnly, bool stableOnly,
21  const std::vector<int>& pdgId = std::vector<int>()) :
22  ptMin_( ptMin ), minRapidity_( minRapidity ), maxRapidity_( maxRapidity ),
23  tip_( tip ), lip_( lip ), minHit_( minHit ), signalOnly_(signalOnly), chargedOnly_(chargedOnly), stableOnly_(stableOnly), pdgId_( pdgId ) { }
24 
26  bool operator()( const TrackingParticle & tp ) const {
27  auto pdgid = tp.pdgId();
28  if (chargedOnly_ && tp.charge()==0) return false;//select only if charge!=0
29 
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 (pdgid==pdgId_[it]) { testId = true; break;}
35  }
36 
37  bool signal = true;
38  if (signalOnly_) signal = (tp.eventId().bunchCrossing()== 0 && tp.eventId().event() == 0); // signal only means no PU particles
39 
40  // select only stable particles
41  bool stable = true;
42  if (stableOnly_) {
43  if (!signal) {
44  stable = false; // we are not interested into PU particles among the stable ones
45  } else {
47  if (j->get()==0 || j->get()->status() != 1) {
48  stable = false; break;
49  }
50  }
51  // test for remaining unstabled due to lack of genparticle pointer
52  if( (stable & (tp.status() == -99) ) &&
53  (std::abs(pdgid) != 11 && std::abs(pdgid) != 13 && std::abs(pdgid) != 211 &&
54  std::abs(pdgid) != 321 && std::abs(pdgid) != 2212 && std::abs(pdgid) != 3112 &&
55  std::abs(pdgid) != 3222 && std::abs(pdgid) != 3312 && std::abs(pdgid) != 3334)) stable = false;
56  }
57  }
58 
59  auto etaOk = [&](const TrackingParticle::Vector& p)->bool{ float eta= etaFromXYZ(p.x(),p.y(),p.z()); return (eta>= minRapidity_) & (eta<=maxRapidity_);};
60  return (
61  (testId & signal & stable) &&
63  tp.momentum().perp2() >= ptMin_*ptMin_ &&
64  etaOk(tp.momentum()) &&
65  std::abs(tp.vertex().z()) <= lip_ && // vertex last to avoid to load it if not striclty necessary...
66  tp.vertex().perp2() <= tip_*tip_
67  );
68  }
69 
70 private:
71  double ptMin_;
72  float minRapidity_;
73  float maxRapidity_;
74  double tip_;
75  double lip_;
76  int minHit_;
80  std::vector<int> pdgId_;
81 
82 };
83 
86 
87 namespace reco {
88  namespace modules {
89 
90  template<>
94  cfg.getParameter<double>( "ptMin" ),
95  cfg.getParameter<double>( "minRapidity" ),
96  cfg.getParameter<double>( "maxRapidity" ),
97  cfg.getParameter<double>( "tip" ),
98  cfg.getParameter<double>( "lip" ),
99  cfg.getParameter<int>( "minHit" ),
100  cfg.getParameter<bool>( "signalOnly" ),
101  cfg.getParameter<bool>( "chargedOnly" ),
102  cfg.getParameter<bool>( "stableOnly" ),
103  cfg.getParameter<std::vector<int> >( "pdgId" ));
104  }
105  };
106 
107  }
108 }
109 
110 #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.
static const int stable
Definition: TopGenEvent.h:11
T eta() const
int status() const
Status word.
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
float charge() const
Gives charge in unit of quark charge (should be 3 time the abaove)
int bunchCrossing() const
get the detector field from this detid
int numberOfTrackerLayers() const
The number of tracker layers with a hit.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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
Point vertex() const
EncodedEventId eventId() const
Signal source, crossing number.
Vector momentum() const
spatial momentum vector
Monte Carlo truth information used for tracking validation.
math::XYZVectorD Vector
point in the space
static TrackingParticleSelector make(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)