CMS 3D CMS Logo

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

#include <CaloParticleSelector.h>

Public Member Functions

 CaloParticleSelector ()
 
 CaloParticleSelector (double ptMin, double ptMax, double minRapidity, double maxRapidity, double lip, double tip, 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)
 
bool operator() (const CaloParticle &tp, std::vector< SimVertex > const &simVertices) const
 

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 17 of file CaloParticleSelector.h.

Constructor & Destructor Documentation

CaloParticleSelector::CaloParticleSelector ( )
inline
CaloParticleSelector::CaloParticleSelector ( double  ptMin,
double  ptMax,
double  minRapidity,
double  maxRapidity,
double  lip,
double  tip,
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 CaloParticleSelector.h.

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

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

Member Function Documentation

bool CaloParticleSelector::operator() ( const CaloParticle tp,
std::vector< SimVertex > const &  simVertices 
) const
inline

Definition at line 67 of file CaloParticleSelector.h.

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

67  {
68  // signal only means no PU particles
69  if (signalOnly_ && !(tp.eventId().bunchCrossing() == 0 && tp.eventId().event() == 0))
70  return false;
71  // intime only means no OOT PU particles
72  if (intimeOnly_ && !(tp.eventId().bunchCrossing() == 0))
73  return false;
74 
75  auto pdgid = tp.pdgId();
76  if (!pdgId_.empty()) {
77  bool testId = false;
78  for (auto id : pdgId_) {
79  if (id == pdgid) {
80  testId = true;
81  break;
82  }
83  }
84  if (!testId)
85  return false;
86  }
87 
88  if (chargedOnly_ && tp.charge() == 0)
89  return false; //select only if charge!=0
90 
91  // select only stable particles
92  if (stableOnly_) {
94  if (j->get() == nullptr || j->get()->status() != 1) {
95  return false;
96  }
97  }
98 
99  // test for remaining unstabled due to lack of genparticle pointer
100  std::vector<int> pdgids{11, 13, 211, 321, 2212, 3112, 3222, 3312, 3334};
101  if (tp.status() == -99 && (!std::binary_search(pdgids.begin(), pdgids.end(), std::abs(pdgid)))) {
102  return false;
103  }
104  }
105 
106  auto etaOk = [&](const CaloParticle& p) -> bool {
107  float eta = etaFromXYZ(p.px(), p.py(), p.pz());
108  return (eta >= minRapidity_) & (eta <= maxRapidity_);
109  };
110  auto phiOk = [&](const CaloParticle& p) {
111  float dphi = deltaPhi(atan2f(p.py(), p.px()), meanPhi_);
112  return dphi >= -rangePhi_ && dphi <= rangePhi_;
113  };
114  auto ptOk = [&](const CaloParticle& p) {
115  double pt2 = tp.p4().perp2();
116  return pt2 >= ptMin2_ && pt2 <= ptMax2_;
117  };
118 
119  return (ptOk(tp) && etaOk(tp) && phiOk(tp));
120  }
int event() const
get the contents of the subdetector field (should be protected?)
EncodedEventId eventId() const
Signal source, crossing number.
Definition: CaloParticle.h:54
float charge() const
Electric charge. Note this is taken from the first SimTrack only.
Definition: CaloParticle.h:79
int status() const
Status word.
Definition: CaloParticle.h:155
genp_iterator genParticle_begin() const
iterators
Definition: CaloParticle.h:63
pdgids
Definition: ntuple.py:98
const math::XYZTLorentzVectorF & p4() const
Four-momentum Lorentz vector. Note this is taken from the first SimTrack only.
Definition: CaloParticle.h:85
int bunchCrossing() const
get the detector field from this detid
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int pdgId() const
PDG ID.
Definition: CaloParticle.h:43
std::vector< int > pdgId_
genp_iterator genParticle_end() const
Definition: CaloParticle.h:64

Member Data Documentation

bool CaloParticleSelector::chargedOnly_
private

Definition at line 134 of file CaloParticleSelector.h.

Referenced by operator()().

bool CaloParticleSelector::intimeOnly_
private

Definition at line 133 of file CaloParticleSelector.h.

Referenced by operator()().

double CaloParticleSelector::lip_
private

Definition at line 127 of file CaloParticleSelector.h.

float CaloParticleSelector::maxRapidity_
private

Definition at line 126 of file CaloParticleSelector.h.

Referenced by operator()().

float CaloParticleSelector::meanPhi_
private

Definition at line 129 of file CaloParticleSelector.h.

Referenced by operator()().

int CaloParticleSelector::minHit_
private

Definition at line 131 of file CaloParticleSelector.h.

float CaloParticleSelector::minRapidity_
private

Definition at line 125 of file CaloParticleSelector.h.

Referenced by operator()().

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

Definition at line 136 of file CaloParticleSelector.h.

Referenced by operator()().

double CaloParticleSelector::ptMax2_
private

Definition at line 124 of file CaloParticleSelector.h.

Referenced by operator()().

double CaloParticleSelector::ptMin2_
private

Definition at line 123 of file CaloParticleSelector.h.

Referenced by operator()().

float CaloParticleSelector::rangePhi_
private

Definition at line 130 of file CaloParticleSelector.h.

Referenced by operator()().

bool CaloParticleSelector::signalOnly_
private

Definition at line 132 of file CaloParticleSelector.h.

Referenced by operator()().

bool CaloParticleSelector::stableOnly_
private

Definition at line 135 of file CaloParticleSelector.h.

Referenced by operator()().

double CaloParticleSelector::tip2_
private

Definition at line 128 of file CaloParticleSelector.h.