CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
TrackingParticleSelector Class Reference

#include <TrackingParticleSelector.h>

Public Member Functions

bool isCharged (const TrackingParticle *tp) const
 
bool isInTime (const TrackingParticle *tp) const
 
bool isSignal (const TrackingParticle *tp) const
 
bool isStable (const TrackingParticle *tp) const
 
bool operator() (const TrackingParticle &tp) const
 
bool operator() (const TrackingParticle *tp) const
 
bool select (const TrackingParticle *tp) const
 
bool selectKinematics (const TrackingParticle *tp) const
 
bool selectParticleType (const TrackingParticle *tp) const
 
 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

Definition at line 18 of file TrackingParticleSelector.h.

18 {}
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_FULL_cff::maxPhi, and HLT_FULL_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),
43  signalOnly_(signalOnly),
44  intimeOnly_(intimeOnly),
45  chargedOnly_(chargedOnly),
46  stableOnly_(stableOnly),
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  }
constexpr float ptMin
#define M_PI
tuple invertRapidityCut

Member Function Documentation

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

Definition at line 67 of file TrackingParticleSelector.h.

References TrackingParticle::charge().

Referenced by select().

67 { return (tp->charge() == 0 ? false : true); }
float charge() const
Electric charge. Note this is taken from the first SimTrack only.
bool TrackingParticleSelector::isInTime ( const TrackingParticle tp) const
inline

Definition at line 69 of file TrackingParticleSelector.h.

References EncodedEventId::bunchCrossing(), and TrackingParticle::eventId().

Referenced by select().

69 { return (tp->eventId().bunchCrossing() == 0); }
int bunchCrossing() const
get the detector field from this detid
EncodedEventId eventId() const
Signal source, crossing number.
bool TrackingParticleSelector::isSignal ( const TrackingParticle tp) const
inline

Definition at line 71 of file TrackingParticleSelector.h.

References EncodedEventId::bunchCrossing(), EncodedEventId::event(), and TrackingParticle::eventId().

Referenced by select().

71  {
72  return (tp->eventId().bunchCrossing() == 0 && tp->eventId().event() == 0);
73  }
int event() const
get the contents of the subdetector field (should be protected?)
int bunchCrossing() const
get the detector field from this detid
EncodedEventId eventId() const
Signal source, crossing number.
bool TrackingParticleSelector::isStable ( const TrackingParticle tp) const
inline

Definition at line 75 of file TrackingParticleSelector.h.

References funct::abs(), TrackingParticle::genParticle_begin(), TrackingParticle::genParticle_end(), dqmiolumiharvest::j, TrackingParticle::pdgId(), and TrackingParticle::status().

Referenced by select().

75  {
77  if (j->get() == nullptr || j->get()->status() != 1) {
78  return false;
79  }
80  }
81  // test for remaining unstabled due to lack of genparticle pointer
82  int pdgid = std::abs(tp->pdgId());
83  if (tp->status() == -99 && (pdgid != 11 && pdgid != 13 && pdgid != 211 && pdgid != 321 && pdgid != 2212 &&
84  pdgid != 3112 && pdgid != 3222 && pdgid != 3312 && pdgid != 3334)) {
85  return false;
86  }
87  return true;
88  }
genp_iterator genParticle_begin() const
iterators
int pdgId() const
PDG ID.
int status() const
Status word.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
genp_iterator genParticle_end() const
bool TrackingParticleSelector::operator() ( const TrackingParticle tp) const
inline

Operator() performs the selection: e.g. if (tPSelector(tp)) {...} https://stackoverflow.com/questions/14466620/c-template-specialization-calling-methods-on-types-that-could-be-pointers-or/14466705

Definition at line 92 of file TrackingParticleSelector.h.

References select().

92 { return select(&tp); }
bool select(const TrackingParticle *tp) const
bool TrackingParticleSelector::operator() ( const TrackingParticle tp) const
inline

Definition at line 93 of file TrackingParticleSelector.h.

References select().

93 { return select(tp); }
bool select(const TrackingParticle *tp) const
bool TrackingParticleSelector::select ( const TrackingParticle tp) const
inline

Definition at line 95 of file TrackingParticleSelector.h.

References chargedOnly_, intimeOnly_, isCharged(), isInTime(), isSignal(), isStable(), selectKinematics(), selectParticleType(), signalOnly_, and stableOnly_.

Referenced by operator()().

95  {
96  // signal only means no PU particles
97  if (signalOnly_ && !isSignal(tp))
98  return false;
99  // intime only means no OOT PU particles
100  if (intimeOnly_ && !isInTime(tp))
101  return false;
102 
103  // select only if charge!=0
104  if (chargedOnly_ && !isCharged(tp))
105  return false;
106 
107  // select for particle type
108  if (!selectParticleType(tp)) {
109  return false;
110  }
111 
112  // select only stable particles
113  if (stableOnly_ && !isStable(tp)) {
114  return false;
115  }
116 
117  return selectKinematics(tp);
118  }
bool isInTime(const TrackingParticle *tp) const
bool isSignal(const TrackingParticle *tp) const
bool selectParticleType(const TrackingParticle *tp) const
bool isCharged(const TrackingParticle *tp) const
bool selectKinematics(const TrackingParticle *tp) const
bool isStable(const TrackingParticle *tp) const
bool TrackingParticleSelector::selectKinematics ( const TrackingParticle tp) const
inline

Definition at line 120 of file TrackingParticleSelector.h.

References funct::abs(), srCondWrite_cfg::deltaPhi, PVValHelper::eta, invertRapidityCut_, lip_, maxRapidity_, meanPhi_, minHit_, minRapidity_, TrackingParticle::numberOfTrackerLayers(), AlCaHLTBitMon_ParallelJobs::p, TrackingParticle::p4(), ptMax2_, ptMin2_, rangePhi_, tip2_, and TrackingParticle::vertex().

Referenced by select().

120  {
121  auto etaOk = [&](const TrackingParticle *p) -> bool {
122  float eta = etaFromXYZ(p->px(), p->py(), p->pz());
123  if (!invertRapidityCut_)
124  return (eta >= minRapidity_) && (eta <= maxRapidity_);
125  else
126  return (eta < minRapidity_ || eta > maxRapidity_);
127  };
128  auto phiOk = [&](const TrackingParticle *p) {
129  float dphi = deltaPhi(atan2f(p->py(), p->px()), meanPhi_);
130  return dphi >= -rangePhi_ && dphi <= rangePhi_;
131  };
132  auto ptOk = [&](const TrackingParticle *p) {
133  double pt2 = tp->p4().perp2();
134  return pt2 >= ptMin2_ && pt2 <= ptMax2_;
135  };
136  return (tp->numberOfTrackerLayers() >= minHit_ && ptOk(tp) && etaOk(tp) && phiOk(tp) &&
137  std::abs(tp->vertex().z()) <= lip_ && // vertex last to avoid to load it if not striclty
138  // necessary...
139  tp->vertex().perp2() <= tip2_);
140  }
const LorentzVector & p4() const
Four-momentum Lorentz vector. Note this is taken from the first SimTrack only.
int numberOfTrackerLayers() const
The number of tracker layers with a hit.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Point vertex() const
Parent vertex position.
Monte Carlo truth information used for tracking validation.
bool TrackingParticleSelector::selectParticleType ( const TrackingParticle tp) const
inline

Definition at line 142 of file TrackingParticleSelector.h.

References TrackingParticle::pdgId(), and pdgId_.

Referenced by select().

142  {
143  auto pdgid = tp->pdgId();
144  if (!pdgId_.empty()) {
145  for (auto id : pdgId_) {
146  if (id == pdgid) {
147  return true;
148  }
149  }
150  } else {
151  return true;
152  }
153  return false;
154  }
int pdgId() const
PDG ID.

Member Data Documentation

bool TrackingParticleSelector::chargedOnly_
private

Definition at line 168 of file TrackingParticleSelector.h.

Referenced by select().

bool TrackingParticleSelector::intimeOnly_
private

Definition at line 167 of file TrackingParticleSelector.h.

Referenced by select().

bool TrackingParticleSelector::invertRapidityCut_
private

Definition at line 171 of file TrackingParticleSelector.h.

Referenced by selectKinematics().

double TrackingParticleSelector::lip_
private

Definition at line 164 of file TrackingParticleSelector.h.

Referenced by selectKinematics().

float TrackingParticleSelector::maxRapidity_
private

Definition at line 160 of file TrackingParticleSelector.h.

Referenced by selectKinematics().

float TrackingParticleSelector::meanPhi_
private

Definition at line 161 of file TrackingParticleSelector.h.

Referenced by selectKinematics().

int TrackingParticleSelector::minHit_
private

Definition at line 165 of file TrackingParticleSelector.h.

Referenced by selectKinematics().

float TrackingParticleSelector::minRapidity_
private

Definition at line 159 of file TrackingParticleSelector.h.

Referenced by selectKinematics().

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

Definition at line 170 of file TrackingParticleSelector.h.

Referenced by selectParticleType().

double TrackingParticleSelector::ptMax2_
private

Definition at line 158 of file TrackingParticleSelector.h.

Referenced by selectKinematics().

double TrackingParticleSelector::ptMin2_
private

Definition at line 157 of file TrackingParticleSelector.h.

Referenced by selectKinematics().

float TrackingParticleSelector::rangePhi_
private

Definition at line 162 of file TrackingParticleSelector.h.

Referenced by selectKinematics().

bool TrackingParticleSelector::signalOnly_
private

Definition at line 166 of file TrackingParticleSelector.h.

Referenced by select().

bool TrackingParticleSelector::stableOnly_
private

Definition at line 169 of file TrackingParticleSelector.h.

Referenced by select().

double TrackingParticleSelector::tip2_
private

Definition at line 163 of file TrackingParticleSelector.h.

Referenced by selectKinematics().