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:
20  double tip,double lip,int minHit, bool signalOnly, bool chargedOnly, bool stableOnly,
21  const std::vector<int>& pdgId = std::vector<int>()) :
22  ptMin2_( ptMin*ptMin ), minRapidity_( minRapidity ), maxRapidity_( maxRapidity ),
23  tip2_( tip*tip ), lip_( lip ), minHit_( minHit ), signalOnly_(signalOnly), chargedOnly_(chargedOnly), stableOnly_(stableOnly), pdgId_( pdgId ) { }
24 
26  bool operator()( const TrackingParticle & tp ) const {
27  // signal only means no PU particles
28  if (signalOnly_ && !(tp.eventId().bunchCrossing()== 0 && tp.eventId().event() == 0)) return false;
29 
30  auto pdgid = tp.pdgId();
31  if(!pdgId_.empty()) {
32  bool testId = false;
33  for(auto id: pdgId_) {
34  if(id == pdgid) { testId = true; break;}
35  }
36  if(!testId) return false;
37  }
38 
39  if (chargedOnly_ && tp.charge()==0) return false;//select only if charge!=0
40 
41  // select only stable particles
42  if (stableOnly_) {
44  if (j->get()==0 || j->get()->status() != 1) {
45  return false;
46  }
47  }
48  // test for remaining unstabled due to lack of genparticle pointer
49  if( tp.status() == -99 &&
50  (std::abs(pdgid) != 11 && std::abs(pdgid) != 13 && std::abs(pdgid) != 211 &&
51  std::abs(pdgid) != 321 && std::abs(pdgid) != 2212 && std::abs(pdgid) != 3112 &&
52  std::abs(pdgid) != 3222 && std::abs(pdgid) != 3312 && std::abs(pdgid) != 3334))
53  return false;
54  }
55 
56  auto etaOk = [&](const TrackingParticle& p)->bool{ float eta= etaFromXYZ(p.px(),p.py(),p.pz()); return (eta>= minRapidity_) & (eta<=maxRapidity_);};
57  return (
59  tp.p4().perp2() >= ptMin2_ &&
60  etaOk(tp) &&
61  std::abs(tp.vertex().z()) <= lip_ && // vertex last to avoid to load it if not striclty necessary...
62  tp.vertex().perp2() <= tip2_
63  );
64  }
65 
66 private:
67  double ptMin2_;
68  float minRapidity_;
69  float maxRapidity_;
70  double tip2_;
71  double lip_;
72  int minHit_;
76  std::vector<int> pdgId_;
77 
78 };
79 
82 
83 namespace reco {
84  namespace modules {
85 
86  template<>
90  cfg.getParameter<double>( "ptMin" ),
91  cfg.getParameter<double>( "minRapidity" ),
92  cfg.getParameter<double>( "maxRapidity" ),
93  cfg.getParameter<double>( "tip" ),
94  cfg.getParameter<double>( "lip" ),
95  cfg.getParameter<int>( "minHit" ),
96  cfg.getParameter<bool>( "signalOnly" ),
97  cfg.getParameter<bool>( "chargedOnly" ),
98  cfg.getParameter<bool>( "stableOnly" ),
99  cfg.getParameter<std::vector<int> >( "pdgId" ));
100  }
101  };
102 
103  }
104 }
105 
106 #endif
const LorentzVector & p4() const
Four-momentum Lorentz vector. Note this is taken from the first SimTrack only.
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?)
tuple cfg
Definition: looper.py:259
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.
int status() const
Status word.
SingleObjectSelector< TrackingParticleCollection,::TrackingParticleSelector > TrackingParticleSelector
float charge() const
Electric charge. Note this is taken from the first SimTrack only.
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
Parent vertex position.
EncodedEventId eventId() const
Signal source, crossing number.
Monte Carlo truth information used for tracking validation.
static TrackingParticleSelector make(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)