CMS 3D CMS Logo

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 intimeOnly, 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), intimeOnly_(intimeOnly), 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  // intime only means no OOT PU particles
30  if (intimeOnly_ && !(tp.eventId().bunchCrossing()==0)) return false;
31 
32  auto pdgid = tp.pdgId();
33  if(!pdgId_.empty()) {
34  bool testId = false;
35  for(auto id: pdgId_) {
36  if(id == pdgid) { testId = true; break;}
37  }
38  if(!testId) return false;
39  }
40 
41  if (chargedOnly_ && tp.charge()==0) return false;//select only if charge!=0
42 
43  // select only stable particles
44  if (stableOnly_) {
45  for( TrackingParticle::genp_iterator j = tp.genParticle_begin(); j != tp.genParticle_end(); ++ j ) {
46  if (j->get()==0 || j->get()->status() != 1) {
47  return false;
48  }
49  }
50  // test for remaining unstabled due to lack of genparticle pointer
51  if( tp.status() == -99 &&
52  (std::abs(pdgid) != 11 && std::abs(pdgid) != 13 && std::abs(pdgid) != 211 &&
53  std::abs(pdgid) != 321 && std::abs(pdgid) != 2212 && std::abs(pdgid) != 3112 &&
54  std::abs(pdgid) != 3222 && std::abs(pdgid) != 3312 && std::abs(pdgid) != 3334))
55  return false;
56  }
57 
58  auto etaOk = [&](const TrackingParticle& p)->bool{ float eta= etaFromXYZ(p.px(),p.py(),p.pz()); return (eta>= minRapidity_) & (eta<=maxRapidity_);};
59  return (
61  tp.p4().perp2() >= ptMin2_ &&
62  etaOk(tp) &&
63  std::abs(tp.vertex().z()) <= lip_ && // vertex last to avoid to load it if not striclty necessary...
64  tp.vertex().perp2() <= tip2_
65  );
66  }
67 
68 private:
69  double ptMin2_;
70  float minRapidity_;
71  float maxRapidity_;
72  double tip2_;
73  double lip_;
74  int minHit_;
79  std::vector<int> pdgId_;
80 
81 };
82 
85 
86 namespace reco {
87  namespace modules {
88 
89  template<>
93  cfg.getParameter<double>( "ptMin" ),
94  cfg.getParameter<double>( "minRapidity" ),
95  cfg.getParameter<double>( "maxRapidity" ),
96  cfg.getParameter<double>( "tip" ),
97  cfg.getParameter<double>( "lip" ),
98  cfg.getParameter<int>( "minHit" ),
99  cfg.getParameter<bool>( "signalOnly" ),
100  cfg.getParameter<bool>( "intimeOnly" ),
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
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?)
int pdgId() const
PDG ID.
int status() const
Status word.
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
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.
fixed size matrix
TrackingParticleSelector(double ptMin, double minRapidity, double maxRapidity, double tip, double lip, int minHit, bool signalOnly, bool intimeOnly, bool chargedOnly, bool stableOnly, const std::vector< int > &pdgId=std::vector< int >())
Monte Carlo truth information used for tracking validation.
static TrackingParticleSelector make(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)