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, unsigned int maxSimClusters, 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 &cp, std::vector< SimVertex > const &simVertices) const
 

Private Attributes

bool chargedOnly_
 
bool intimeOnly_
 
double lip_
 
float maxRapidity_
 
unsigned int maxSimClusters_
 
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 10 of file CaloParticleSelector.h.

Constructor & Destructor Documentation

◆ CaloParticleSelector() [1/2]

CaloParticleSelector::CaloParticleSelector ( )
inline

Definition at line 12 of file CaloParticleSelector.h.

12 {}

◆ CaloParticleSelector() [2/2]

CaloParticleSelector::CaloParticleSelector ( double  ptMin,
double  ptMax,
double  minRapidity,
double  maxRapidity,
double  lip,
double  tip,
int  minHit,
unsigned int  maxSimClusters,
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 13 of file CaloParticleSelector.h.

28  : ptMin2_(ptMin * ptMin),
29  ptMax2_(ptMax * ptMax),
32  lip_(lip),
33  tip2_(tip * tip),
34  meanPhi_((minPhi + maxPhi) / 2.),
35  rangePhi_((maxPhi - minPhi) / 2.),
36  minHit_(minHit),
37  maxSimClusters_(maxSimClusters),
42  pdgId_(pdgId) {
43  if (minPhi >= maxPhi) {
44  throw cms::Exception("Configuration")
45  << "CaloParticleSelector: minPhi (" << minPhi << ") must be smaller than maxPhi (" << maxPhi
46  << "). The range is constructed from minPhi to maxPhi around their average.";
47  }
48  if (minPhi >= M_PI) {
49  throw cms::Exception("Configuration")
50  << "CaloParticleSelector: minPhi (" << minPhi
51  << ") must be smaller than PI. The range is constructed from minPhi to maxPhi around their average.";
52  }
53  if (maxPhi <= -M_PI) {
54  throw cms::Exception("Configuration")
55  << "CaloParticleSelector: maxPhi (" << maxPhi
56  << ") must be larger than -PI. The range is constructed from minPhi to maxPhi around their average.";
57  }
58  }

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

Member Function Documentation

◆ operator()()

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

Definition at line 62 of file CaloParticleSelector.h.

62  {
63  // signal only means no PU particles
64  if (signalOnly_ && !(cp.eventId().bunchCrossing() == 0 && cp.eventId().event() == 0))
65  return false;
66  // intime only means no OOT PU particles
67  if (intimeOnly_ && !(cp.eventId().bunchCrossing() == 0))
68  return false;
69 
70  if (cp.simClusters().size() > maxSimClusters_)
71  return false;
72 
73  auto pdgid = cp.pdgId();
74  if (!pdgId_.empty()) {
75  bool testId = false;
76  for (auto id : pdgId_) {
77  if (id == pdgid) {
78  testId = true;
79  break;
80  }
81  }
82  if (!testId)
83  return false;
84  }
85 
86  if (chargedOnly_ && cp.charge() == 0)
87  return false; //select only if charge!=0
88 
89  // select only stable particles
90  if (stableOnly_) {
91  for (CaloParticle::genp_iterator j = cp.genParticle_begin(); j != cp.genParticle_end(); ++j) {
92  if (j->get() == nullptr || j->get()->status() != 1) {
93  return false;
94  }
95  }
96 
97  // test for remaining unstabled due to lack of genparticle pointer
98  std::vector<int> pdgids{11, 13, 211, 321, 2212, 3112, 3222, 3312, 3334};
99  if (cp.status() == -99 && (!std::binary_search(pdgids.begin(), pdgids.end(), std::abs(pdgid)))) {
100  return false;
101  }
102  }
103 
104  auto etaOk = [&](const CaloParticle& p) -> bool {
105  float eta = etaFromXYZ(p.px(), p.py(), p.pz());
106  return (eta >= minRapidity_) & (eta <= maxRapidity_);
107  };
108  auto phiOk = [&](const CaloParticle& p) {
109  float dphi = deltaPhi(atan2f(p.py(), p.px()), meanPhi_);
110  return dphi >= -rangePhi_ && dphi <= rangePhi_;
111  };
112  auto ptOk = [&](const CaloParticle& p) {
113  double pt2 = cp.p4().perp2();
114  return pt2 >= ptMin2_ && pt2 <= ptMax2_;
115  };
116 
117  return (ptOk(cp) && etaOk(cp) && phiOk(cp));
118  }

References funct::abs(), chargedOnly_, CommonMethods::cp(), SiPixelRawToDigiRegional_cfi::deltaPhi, PVValHelper::eta, intimeOnly_, dqmiolumiharvest::j, maxRapidity_, maxSimClusters_, meanPhi_, minRapidity_, AlCaHLTBitMon_ParallelJobs::p, EgammaValidation_cff::pdgid, pdgId_, ntuple::pdgids, HLT_2018_cff::pt2, ptMax2_, ptMin2_, rangePhi_, signalOnly_, and stableOnly_.

Member Data Documentation

◆ chargedOnly_

bool CaloParticleSelector::chargedOnly_
private

Definition at line 133 of file CaloParticleSelector.h.

Referenced by operator()().

◆ intimeOnly_

bool CaloParticleSelector::intimeOnly_
private

Definition at line 132 of file CaloParticleSelector.h.

Referenced by operator()().

◆ lip_

double CaloParticleSelector::lip_
private

Definition at line 125 of file CaloParticleSelector.h.

◆ maxRapidity_

float CaloParticleSelector::maxRapidity_
private

Definition at line 124 of file CaloParticleSelector.h.

Referenced by operator()().

◆ maxSimClusters_

unsigned int CaloParticleSelector::maxSimClusters_
private

Definition at line 130 of file CaloParticleSelector.h.

Referenced by operator()().

◆ meanPhi_

float CaloParticleSelector::meanPhi_
private

Definition at line 127 of file CaloParticleSelector.h.

Referenced by operator()().

◆ minHit_

int CaloParticleSelector::minHit_
private

Definition at line 129 of file CaloParticleSelector.h.

◆ minRapidity_

float CaloParticleSelector::minRapidity_
private

Definition at line 123 of file CaloParticleSelector.h.

Referenced by operator()().

◆ pdgId_

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

Definition at line 135 of file CaloParticleSelector.h.

Referenced by operator()().

◆ ptMax2_

double CaloParticleSelector::ptMax2_
private

Definition at line 122 of file CaloParticleSelector.h.

Referenced by operator()().

◆ ptMin2_

double CaloParticleSelector::ptMin2_
private

Definition at line 121 of file CaloParticleSelector.h.

Referenced by operator()().

◆ rangePhi_

float CaloParticleSelector::rangePhi_
private

Definition at line 128 of file CaloParticleSelector.h.

Referenced by operator()().

◆ signalOnly_

bool CaloParticleSelector::signalOnly_
private

Definition at line 131 of file CaloParticleSelector.h.

Referenced by operator()().

◆ stableOnly_

bool CaloParticleSelector::stableOnly_
private

Definition at line 134 of file CaloParticleSelector.h.

Referenced by operator()().

◆ tip2_

double CaloParticleSelector::tip2_
private

Definition at line 126 of file CaloParticleSelector.h.

trackingParticleSelector_cfi.signalOnly
signalOnly
Definition: trackingParticleSelector_cfi.py:9
HLT_2018_cff.pt2
pt2
Definition: HLT_2018_cff.py:8552
qcdUeDQM_cfi.minRapidity
minRapidity
Definition: qcdUeDQM_cfi.py:24
qcdUeDQM_cfi.maxRapidity
maxRapidity
Definition: qcdUeDQM_cfi.py:27
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
ptMin
constexpr float ptMin
Definition: PhotonIDValueMapProducer.cc:153
CaloParticleSelector::meanPhi_
float meanPhi_
Definition: CaloParticleSelector.h:127
CaloParticleSelector::intimeOnly_
bool intimeOnly_
Definition: CaloParticleSelector.h:132
CaloParticleSelector::rangePhi_
float rangePhi_
Definition: CaloParticleSelector.h:128
qcdUeDQM_cfi.lip
lip
Definition: qcdUeDQM_cfi.py:25
HLT_2018_cff.minPhi
minPhi
Definition: HLT_2018_cff.py:51486
CaloParticleSelector::chargedOnly_
bool chargedOnly_
Definition: CaloParticleSelector.h:133
AlignmentTrackSelector_cfi.ptMax
ptMax
Definition: AlignmentTrackSelector_cfi.py:12
HLT_2018_cff.maxPhi
maxPhi
Definition: HLT_2018_cff.py:51498
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
PVValHelper::eta
Definition: PVValidationHelpers.h:69
CaloParticleSelector::minRapidity_
float minRapidity_
Definition: CaloParticleSelector.h:123
qcdUeDQM_cfi.tip
tip
Definition: qcdUeDQM_cfi.py:23
trackingParticleSelector_cfi.intimeOnly
intimeOnly
Definition: trackingParticleSelector_cfi.py:10
CaloParticle
Definition: CaloParticle.h:16
genCandidates_cfi.stableOnly
stableOnly
Definition: genCandidates_cfi.py:6
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
CaloParticleSelector::tip2_
double tip2_
Definition: CaloParticleSelector.h:126
EgammaValidation_cff.pdgId
pdgId
Definition: EgammaValidation_cff.py:118
qcdUeDQM_cfi.minHit
minHit
Definition: qcdUeDQM_cfi.py:33
CaloParticleSelector::lip_
double lip_
Definition: CaloParticleSelector.h:125
CaloParticleSelector::maxRapidity_
float maxRapidity_
Definition: CaloParticleSelector.h:124
Exception
Definition: hltDiff.cc:246
edm::RefVectorIterator
Definition: EDProductfwd.h:33
cosmictrackingParticleSelector_cfi.chargedOnly
chargedOnly
Definition: cosmictrackingParticleSelector_cfi.py:5
CaloParticleSelector::maxSimClusters_
unsigned int maxSimClusters_
Definition: CaloParticleSelector.h:130
CaloParticleSelector::signalOnly_
bool signalOnly_
Definition: CaloParticleSelector.h:131
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ntuple.pdgids
pdgids
Definition: ntuple.py:98
CaloParticleSelector::stableOnly_
bool stableOnly_
Definition: CaloParticleSelector.h:134
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
CaloParticleSelector::ptMin2_
double ptMin2_
Definition: CaloParticleSelector.h:121
CaloParticleSelector::ptMax2_
double ptMax2_
Definition: CaloParticleSelector.h:122
EgammaValidation_cff.pdgid
pdgid
Definition: EgammaValidation_cff.py:30
CommonMethods.cp
def cp(fromDir, toDir, listOfFiles, overwrite=False, smallList=False)
Definition: CommonMethods.py:192
CaloParticleSelector::minHit_
int minHit_
Definition: CaloParticleSelector.h:129
CaloParticleSelector::pdgId_
std::vector< int > pdgId_
Definition: CaloParticleSelector.h:135