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 19 of file TrackingParticleSelector.h.

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

33  : ptMin2_(ptMin * ptMin),
34  ptMax2_(ptMax * ptMax),
37  meanPhi_((minPhi + maxPhi) / 2.),
38  rangePhi_((maxPhi - minPhi) / 2.),
39  tip2_(tip * tip),
40  lip_(lip),
41  minHit_(minHit),
46  pdgId_(pdgId) {
47  if (minPhi >= maxPhi) {
48  throw cms::Exception("Configuration")
49  << "TrackingParticleSelector: minPhi (" << minPhi << ") must be smaller than maxPhi (" << maxPhi
50  << "). The range is constructed from minPhi to maxPhi around their "
51  "average.";
52  }
53  if (minPhi >= M_PI) {
54  throw cms::Exception("Configuration") << "TrackingParticleSelector: minPhi (" << minPhi
55  << ") must be smaller than PI. The range is constructed from minPhi "
56  "to maxPhi around their average.";
57  }
58  if (maxPhi <= -M_PI) {
59  throw cms::Exception("Configuration") << "TrackingParticleSelector: maxPhi (" << maxPhi
60  << ") must be larger than -PI. The range is constructed from minPhi "
61  "to maxPhi around their average.";
62  }
63  }
#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 66 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().

66  {
67  // signal only means no PU particles
68  if (signalOnly_ && !(tp.eventId().bunchCrossing() == 0 && tp.eventId().event() == 0))
69  return false;
70  // intime only means no OOT PU particles
71  if (intimeOnly_ && !(tp.eventId().bunchCrossing() == 0))
72  return false;
73 
74  auto pdgid = tp.pdgId();
75  if (!pdgId_.empty()) {
76  bool testId = false;
77  for (auto id : pdgId_) {
78  if (id == pdgid) {
79  testId = true;
80  break;
81  }
82  }
83  if (!testId)
84  return false;
85  }
86 
87  if (chargedOnly_ && tp.charge() == 0)
88  return false; // select only if charge!=0
89 
90  // select only stable particles
91  if (stableOnly_) {
93  if (j->get() == nullptr || j->get()->status() != 1) {
94  return false;
95  }
96  }
97  // test for remaining unstabled due to lack of genparticle pointer
98  if (tp.status() == -99 && (std::abs(pdgid) != 11 && std::abs(pdgid) != 13 && std::abs(pdgid) != 211 &&
99  std::abs(pdgid) != 321 && std::abs(pdgid) != 2212 && std::abs(pdgid) != 3112 &&
100  std::abs(pdgid) != 3222 && std::abs(pdgid) != 3312 && std::abs(pdgid) != 3334))
101  return false;
102  }
103 
104  auto etaOk = [&](const TrackingParticle &p) -> bool {
105  float eta = etaFromXYZ(p.px(), p.py(), p.pz());
106  return (eta >= minRapidity_) & (eta <= maxRapidity_);
107  };
108  auto phiOk = [&](const TrackingParticle &p) {
109  float dphi = deltaPhi(atan2f(p.py(), p.px()), meanPhi_);
110  return dphi >= -rangePhi_ && dphi <= rangePhi_;
111  };
112  auto ptOk = [&](const TrackingParticle &p) {
113  double pt2 = tp.p4().perp2();
114  return pt2 >= ptMin2_ && pt2 <= ptMax2_;
115  };
116  return (tp.numberOfTrackerLayers() >= minHit_ && ptOk(tp) && etaOk(tp) && phiOk(tp) &&
117  std::abs(tp.vertex().z()) <= lip_ && // vertex last to avoid to load it if not striclty
118  // necessary...
119  tp.vertex().perp2() <= tip2_);
120  }
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 134 of file TrackingParticleSelector.h.

Referenced by operator()().

bool TrackingParticleSelector::intimeOnly_
private

Definition at line 133 of file TrackingParticleSelector.h.

Referenced by operator()().

double TrackingParticleSelector::lip_
private

Definition at line 130 of file TrackingParticleSelector.h.

Referenced by operator()().

float TrackingParticleSelector::maxRapidity_
private

Definition at line 126 of file TrackingParticleSelector.h.

Referenced by operator()().

float TrackingParticleSelector::meanPhi_
private

Definition at line 127 of file TrackingParticleSelector.h.

Referenced by operator()().

int TrackingParticleSelector::minHit_
private

Definition at line 131 of file TrackingParticleSelector.h.

Referenced by operator()().

float TrackingParticleSelector::minRapidity_
private

Definition at line 125 of file TrackingParticleSelector.h.

Referenced by operator()().

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

Definition at line 136 of file TrackingParticleSelector.h.

Referenced by operator()().

double TrackingParticleSelector::ptMax2_
private

Definition at line 124 of file TrackingParticleSelector.h.

Referenced by operator()().

double TrackingParticleSelector::ptMin2_
private

Definition at line 123 of file TrackingParticleSelector.h.

Referenced by operator()().

float TrackingParticleSelector::rangePhi_
private

Definition at line 128 of file TrackingParticleSelector.h.

Referenced by operator()().

bool TrackingParticleSelector::signalOnly_
private

Definition at line 132 of file TrackingParticleSelector.h.

Referenced by operator()().

bool TrackingParticleSelector::stableOnly_
private

Definition at line 135 of file TrackingParticleSelector.h.

Referenced by operator()().

double TrackingParticleSelector::tip2_
private

Definition at line 129 of file TrackingParticleSelector.h.

Referenced by operator()().