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

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

24  :
26  if(minPhi >= maxPhi) {
27  throw cms::Exception("Configuration") << "CaloParticleSelector: minPhi (" << minPhi << ") must be smaller than maxPhi (" << maxPhi << "). The range is constructed from minPhi to maxPhi around their average.";
28  }
29  if(minPhi >= M_PI) {
30  throw cms::Exception("Configuration") << "CaloParticleSelector: minPhi (" << minPhi << ") must be smaller than PI. The range is constructed from minPhi to maxPhi around their average.";
31  }
32  if(maxPhi <= -M_PI) {
33  throw cms::Exception("Configuration") << "CaloParticleSelector: maxPhi (" << maxPhi << ") must be larger than -PI. The range is constructed from minPhi to maxPhi around their average.";
34  }
35  }
#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 39 of file CaloParticleSelector.h.

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

39  {
40  // signal only means no PU particles
41  if (signalOnly_ && !(tp.eventId().bunchCrossing()== 0 && tp.eventId().event() == 0)) return false;
42  // intime only means no OOT PU particles
43  if (intimeOnly_ && !(tp.eventId().bunchCrossing()==0)) return false;
44 
45  auto pdgid = tp.pdgId();
46  if(!pdgId_.empty()) {
47  bool testId = false;
48  for(auto id: pdgId_) {
49  if(id == pdgid) { testId = true; break;}
50  }
51  if(!testId) return false;
52  }
53 
54  if (chargedOnly_ && tp.charge()==0) return false;//select only if charge!=0
55 
56  // select only stable particles
57  if (stableOnly_) {
58  for( CaloParticle::genp_iterator j = tp.genParticle_begin(); j != tp.genParticle_end(); ++ j ) {
59  if (j->get()==nullptr || j->get()->status() != 1) {
60  return false;
61  }
62  }
63 
64  // test for remaining unstabled due to lack of genparticle pointer
65  std::vector<int> pdgids {11,13,211,321,2212,3112,3222,3312,3334};
66  if( tp.status() == -99 &&
67  (!std::binary_search(pdgids.begin(), pdgids.end(), std::abs(pdgid) ))
68  ){ return false; }
69  }
70 
71  auto etaOk = [&](const CaloParticle& p)->bool{ float eta= etaFromXYZ(p.px(),p.py(),p.pz()); return (eta>= minRapidity_) & (eta<=maxRapidity_);};
72  auto phiOk = [&](const CaloParticle& p) { float dphi = deltaPhi(atan2f(p.py(),p.px()), meanPhi_); return dphi >= -rangePhi_ && dphi <= rangePhi_; };
73  auto ptOk = [&](const CaloParticle& p) { double pt2 = tp.p4().perp2(); return pt2 >= ptMin2_ && pt2 <= ptMax2_; };
74 
75  return (
76  ptOk(tp) &&
77  etaOk(tp) &&
78  phiOk(tp)
79  );
80  }
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 94 of file CaloParticleSelector.h.

Referenced by operator()().

bool CaloParticleSelector::intimeOnly_
private

Definition at line 93 of file CaloParticleSelector.h.

Referenced by operator()().

double CaloParticleSelector::lip_
private

Definition at line 87 of file CaloParticleSelector.h.

float CaloParticleSelector::maxRapidity_
private

Definition at line 86 of file CaloParticleSelector.h.

Referenced by operator()().

float CaloParticleSelector::meanPhi_
private

Definition at line 89 of file CaloParticleSelector.h.

Referenced by operator()().

int CaloParticleSelector::minHit_
private

Definition at line 91 of file CaloParticleSelector.h.

float CaloParticleSelector::minRapidity_
private

Definition at line 85 of file CaloParticleSelector.h.

Referenced by operator()().

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

Definition at line 96 of file CaloParticleSelector.h.

Referenced by operator()().

double CaloParticleSelector::ptMax2_
private

Definition at line 84 of file CaloParticleSelector.h.

Referenced by operator()().

double CaloParticleSelector::ptMin2_
private

Definition at line 83 of file CaloParticleSelector.h.

Referenced by operator()().

float CaloParticleSelector::rangePhi_
private

Definition at line 90 of file CaloParticleSelector.h.

Referenced by operator()().

bool CaloParticleSelector::signalOnly_
private

Definition at line 92 of file CaloParticleSelector.h.

Referenced by operator()().

bool CaloParticleSelector::stableOnly_
private

Definition at line 95 of file CaloParticleSelector.h.

Referenced by operator()().

double CaloParticleSelector::tip2_
private

Definition at line 88 of file CaloParticleSelector.h.