CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
TrackingParticleSelector Class Reference

#include <TrackingParticleSelector.h>

Public Member Functions

bool operator() (const TrackingParticle &tp) const
 Operator() performs the selection: e.g. if (tPSelector(tp)) {...}. More...
 
 TrackingParticleSelector ()
 
 TrackingParticleSelector (double ptMin, double ptMax, 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 >(), double minPhi=-3.2, double maxPhi=3.2)
 

Private Attributes

bool chargedOnly_
 
bool intimeOnly_
 
double lip_
 
float maxRapidity_
 
float meanPhi_
 
int minHit_
 
float minRapidity_
 
std::vector< int > pdgId_
 
double ptMax2_
 
double ptMin2_
 
float rangePhi_
 
bool signalOnly_
 
bool stableOnly_
 
double tip2_
 

Detailed Description

Definition at line 16 of file TrackingParticleSelector.h.

Constructor & Destructor Documentation

TrackingParticleSelector::TrackingParticleSelector ( )
inline
TrackingParticleSelector::TrackingParticleSelector ( double  ptMin,
double  ptMax,
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>(),
double  minPhi = -3.2,
double  maxPhi = 3.2 
)
inline

Definition at line 20 of file TrackingParticleSelector.h.

References Exception, M_PI, trackingParticleSelector_cfi::maxPhi, and trackingParticleSelector_cfi::minPhi.

23  :
27  if(minPhi >= maxPhi) {
28  throw cms::Exception("Configuration") << "TrackingParticleSelector: minPhi (" << minPhi << ") must be smaller than maxPhi (" << maxPhi << "). The range is constructed from minPhi to maxPhi around their average.";
29  }
30  if(minPhi >= M_PI) {
31  throw cms::Exception("Configuration") << "TrackingParticleSelector: minPhi (" << minPhi << ") must be smaller than PI. The range is constructed from minPhi to maxPhi around their average.";
32  }
33  if(maxPhi <= -M_PI) {
34  throw cms::Exception("Configuration") << "TrackingParticleSelector: maxPhi (" << maxPhi << ") must be larger than -PI. The range is constructed from minPhi to maxPhi around their average.";
35  }
36  }
#define M_PI

Member Function Documentation

bool TrackingParticleSelector::operator() ( const TrackingParticle tp) const
inline

Operator() performs the selection: e.g. if (tPSelector(tp)) {...}.

Definition at line 39 of file TrackingParticleSelector.h.

References funct::abs(), EncodedEventId::bunchCrossing(), TrackingParticle::charge(), chargedOnly_, hiPixelPairStep_cff::deltaPhi, PVValHelper::eta, EncodedEventId::event(), TrackingParticle::eventId(), TrackingParticle::genParticle_begin(), TrackingParticle::genParticle_end(), intimeOnly_, lip_, maxRapidity_, meanPhi_, minHit_, minRapidity_, TrackingParticle::numberOfTrackerLayers(), AlCaHLTBitMon_ParallelJobs::p, TrackingParticle::p4(), BPhysicsValidation_cfi::pdgid, TrackingParticle::pdgId(), pdgId_, hiDetachedQuadStep_cff::pt2, ptMax2_, ptMin2_, rangePhi_, signalOnly_, stableOnly_, TrackingParticle::status(), tip2_, and TrackingParticle::vertex().

39  {
40  // signal only means no PU particles
41  if (signalOnly_ && !(tp.eventId().bunchCrossing()== 0 && tp.eventId().event() == 0)) return false;
42  // intime only means no OOT PU particles
43  if (intimeOnly_ && !(tp.eventId().bunchCrossing()==0)) return false;
44 
45  auto pdgid = tp.pdgId();
46  if(!pdgId_.empty()) {
47  bool testId = false;
48  for(auto id: pdgId_) {
49  if(id == pdgid) { testId = true; break;}
50  }
51  if(!testId) return false;
52  }
53 
54  if (chargedOnly_ && tp.charge()==0) return false;//select only if charge!=0
55 
56  // select only stable particles
57  if (stableOnly_) {
58  for( TrackingParticle::genp_iterator j = tp.genParticle_begin(); j != tp.genParticle_end(); ++ j ) {
59  if (j->get()==nullptr || j->get()->status() != 1) {
60  return false;
61  }
62  }
63  // test for remaining unstabled due to lack of genparticle pointer
64  if( tp.status() == -99 &&
65  (std::abs(pdgid) != 11 && std::abs(pdgid) != 13 && std::abs(pdgid) != 211 &&
66  std::abs(pdgid) != 321 && std::abs(pdgid) != 2212 && std::abs(pdgid) != 3112 &&
67  std::abs(pdgid) != 3222 && std::abs(pdgid) != 3312 && std::abs(pdgid) != 3334))
68  return false;
69  }
70 
71  auto etaOk = [&](const TrackingParticle& p)->bool{ float eta= etaFromXYZ(p.px(),p.py(),p.pz()); return (eta>= minRapidity_) & (eta<=maxRapidity_);};
72  auto phiOk = [&](const TrackingParticle& p) { float dphi = deltaPhi(atan2f(p.py(),p.px()), meanPhi_); return dphi >= -rangePhi_ && dphi <= rangePhi_; };
73  auto ptOk = [&](const TrackingParticle& p) { double pt2 = tp.p4().perp2(); return pt2 >= ptMin2_ && pt2 <= ptMax2_; };
74  return (
76  ptOk(tp) &&
77  etaOk(tp) &&
78  phiOk(tp) &&
79  std::abs(tp.vertex().z()) <= lip_ && // vertex last to avoid to load it if not striclty necessary...
80  tp.vertex().perp2() <= tip2_
81  );
82  }
const LorentzVector & p4() const
Four-momentum Lorentz vector. Note this is taken from the first SimTrack only.
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
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.

Member Data Documentation

bool TrackingParticleSelector::chargedOnly_
private

Definition at line 96 of file TrackingParticleSelector.h.

Referenced by operator()().

bool TrackingParticleSelector::intimeOnly_
private

Definition at line 95 of file TrackingParticleSelector.h.

Referenced by operator()().

double TrackingParticleSelector::lip_
private

Definition at line 92 of file TrackingParticleSelector.h.

Referenced by operator()().

float TrackingParticleSelector::maxRapidity_
private

Definition at line 88 of file TrackingParticleSelector.h.

Referenced by operator()().

float TrackingParticleSelector::meanPhi_
private

Definition at line 89 of file TrackingParticleSelector.h.

Referenced by operator()().

int TrackingParticleSelector::minHit_
private

Definition at line 93 of file TrackingParticleSelector.h.

Referenced by operator()().

float TrackingParticleSelector::minRapidity_
private

Definition at line 87 of file TrackingParticleSelector.h.

Referenced by operator()().

std::vector<int> TrackingParticleSelector::pdgId_
private

Definition at line 98 of file TrackingParticleSelector.h.

Referenced by operator()().

double TrackingParticleSelector::ptMax2_
private

Definition at line 86 of file TrackingParticleSelector.h.

Referenced by operator()().

double TrackingParticleSelector::ptMin2_
private

Definition at line 85 of file TrackingParticleSelector.h.

Referenced by operator()().

float TrackingParticleSelector::rangePhi_
private

Definition at line 90 of file TrackingParticleSelector.h.

Referenced by operator()().

bool TrackingParticleSelector::signalOnly_
private

Definition at line 94 of file TrackingParticleSelector.h.

Referenced by operator()().

bool TrackingParticleSelector::stableOnly_
private

Definition at line 97 of file TrackingParticleSelector.h.

Referenced by operator()().

double TrackingParticleSelector::tip2_
private

Definition at line 91 of file TrackingParticleSelector.h.

Referenced by operator()().