CMS 3D CMS Logo

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() [1/2]

TrackingParticleSelector::TrackingParticleSelector ( )
inline

Definition at line 18 of file TrackingParticleSelector.h.

18 {}

◆ TrackingParticleSelector() [2/2]

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_2022v15_cff::maxPhi, and HLT_2022v15_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  }
constexpr float ptMin
#define M_PI

Member Function Documentation

◆ isCharged()

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

Definition at line 67 of file TrackingParticleSelector.h.

References funct::false, and cmsswSequenceInfo::tp.

Referenced by select().

67 { return (tp->charge() == 0 ? false : true); }

◆ isInTime()

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

Definition at line 69 of file TrackingParticleSelector.h.

References cmsswSequenceInfo::tp.

Referenced by select().

69 { return (tp->eventId().bunchCrossing() == 0); }

◆ isSignal()

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

Definition at line 71 of file TrackingParticleSelector.h.

References cmsswSequenceInfo::tp.

Referenced by select().

71  {
72  return (tp->eventId().bunchCrossing() == 0 && tp->eventId().event() == 0);
73  }

◆ isStable()

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

Definition at line 75 of file TrackingParticleSelector.h.

References funct::abs(), dqmiolumiharvest::j, EgammaValidation_cff::pdgid, and cmsswSequenceInfo::tp.

Referenced by select().

75  {
76  for (TrackingParticle::genp_iterator j = tp->genParticle_begin(); j != tp->genParticle_end(); ++j) {
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  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ operator()() [1/2]

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

◆ operator()() [2/2]

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

Definition at line 93 of file TrackingParticleSelector.h.

References select(), and cmsswSequenceInfo::tp.

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

◆ select()

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_, stableOnly_, and cmsswSequenceInfo::tp.

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

◆ selectKinematics()

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

Definition at line 120 of file TrackingParticleSelector.h.

References funct::abs(), SiPixelRawToDigiRegional_cfi::deltaPhi, PVValHelper::eta, invertRapidityCut_, lip_, maxRapidity_, meanPhi_, minHit_, minRapidity_, AlCaHLTBitMon_ParallelJobs::p, HLT_2022v15_cff::pt2, ptMax2_, ptMin2_, rangePhi_, tip2_, and cmsswSequenceInfo::tp.

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  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Monte Carlo truth information used for tracking validation.

◆ selectParticleType()

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

Definition at line 142 of file TrackingParticleSelector.h.

References EgammaValidation_cff::pdgid, pdgId_, and cmsswSequenceInfo::tp.

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  }

Member Data Documentation

◆ chargedOnly_

bool TrackingParticleSelector::chargedOnly_
private

Definition at line 168 of file TrackingParticleSelector.h.

Referenced by select().

◆ intimeOnly_

bool TrackingParticleSelector::intimeOnly_
private

Definition at line 167 of file TrackingParticleSelector.h.

Referenced by select().

◆ invertRapidityCut_

bool TrackingParticleSelector::invertRapidityCut_
private

Definition at line 171 of file TrackingParticleSelector.h.

Referenced by selectKinematics().

◆ lip_

double TrackingParticleSelector::lip_
private

Definition at line 164 of file TrackingParticleSelector.h.

Referenced by selectKinematics().

◆ maxRapidity_

float TrackingParticleSelector::maxRapidity_
private

Definition at line 160 of file TrackingParticleSelector.h.

Referenced by selectKinematics().

◆ meanPhi_

float TrackingParticleSelector::meanPhi_
private

Definition at line 161 of file TrackingParticleSelector.h.

Referenced by selectKinematics().

◆ minHit_

int TrackingParticleSelector::minHit_
private

Definition at line 165 of file TrackingParticleSelector.h.

Referenced by selectKinematics().

◆ minRapidity_

float TrackingParticleSelector::minRapidity_
private

Definition at line 159 of file TrackingParticleSelector.h.

Referenced by selectKinematics().

◆ pdgId_

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

Definition at line 170 of file TrackingParticleSelector.h.

Referenced by selectParticleType().

◆ ptMax2_

double TrackingParticleSelector::ptMax2_
private

Definition at line 158 of file TrackingParticleSelector.h.

Referenced by selectKinematics().

◆ ptMin2_

double TrackingParticleSelector::ptMin2_
private

Definition at line 157 of file TrackingParticleSelector.h.

Referenced by selectKinematics().

◆ rangePhi_

float TrackingParticleSelector::rangePhi_
private

Definition at line 162 of file TrackingParticleSelector.h.

Referenced by selectKinematics().

◆ signalOnly_

bool TrackingParticleSelector::signalOnly_
private

Definition at line 166 of file TrackingParticleSelector.h.

Referenced by select().

◆ stableOnly_

bool TrackingParticleSelector::stableOnly_
private

Definition at line 169 of file TrackingParticleSelector.h.

Referenced by select().

◆ tip2_

double TrackingParticleSelector::tip2_
private

Definition at line 163 of file TrackingParticleSelector.h.

Referenced by selectKinematics().