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 >(), bool invertRapidityCut=false, double minPhi=-3.2, double maxPhi=3.2)
 

Private Attributes

bool chargedOnly_
 
bool intimeOnly_
 
bool invertRapidityCut_
 
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>(),
bool  invertRapidityCut = false,
double  minPhi = -3.2,
double  maxPhi = 3.2 
)
inline

Definition at line 19 of file TrackingParticleSelector.h.

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

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

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

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

Referenced by operator()().

bool TrackingParticleSelector::intimeOnly_
private

Definition at line 138 of file TrackingParticleSelector.h.

Referenced by operator()().

bool TrackingParticleSelector::invertRapidityCut_
private

Definition at line 142 of file TrackingParticleSelector.h.

Referenced by operator()().

double TrackingParticleSelector::lip_
private

Definition at line 135 of file TrackingParticleSelector.h.

Referenced by operator()().

float TrackingParticleSelector::maxRapidity_
private

Definition at line 131 of file TrackingParticleSelector.h.

Referenced by operator()().

float TrackingParticleSelector::meanPhi_
private

Definition at line 132 of file TrackingParticleSelector.h.

Referenced by operator()().

int TrackingParticleSelector::minHit_
private

Definition at line 136 of file TrackingParticleSelector.h.

Referenced by operator()().

float TrackingParticleSelector::minRapidity_
private

Definition at line 130 of file TrackingParticleSelector.h.

Referenced by operator()().

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

Definition at line 141 of file TrackingParticleSelector.h.

Referenced by operator()().

double TrackingParticleSelector::ptMax2_
private

Definition at line 129 of file TrackingParticleSelector.h.

Referenced by operator()().

double TrackingParticleSelector::ptMin2_
private

Definition at line 128 of file TrackingParticleSelector.h.

Referenced by operator()().

float TrackingParticleSelector::rangePhi_
private

Definition at line 133 of file TrackingParticleSelector.h.

Referenced by operator()().

bool TrackingParticleSelector::signalOnly_
private

Definition at line 137 of file TrackingParticleSelector.h.

Referenced by operator()().

bool TrackingParticleSelector::stableOnly_
private

Definition at line 140 of file TrackingParticleSelector.h.

Referenced by operator()().

double TrackingParticleSelector::tip2_
private

Definition at line 134 of file TrackingParticleSelector.h.

Referenced by operator()().