ATLAS Offline Software
KinematicParticleCuts.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 ///////////////////////////////////////////////////////////////////
6 // KinematicParticleCuts.icc, (c) ATLAS Detector software
7 ///////////////////////////////////////////////////////////////////
8 
9 // @TODO: probably replace this by an enum some day
10 #define ISF_UNDEF_CHARGE -99999.
11 
12 /** constructor */
13 ISF::KinematicParticleCuts::KinematicParticleCuts() :
14  m_cut_minPosEta(-99.f),
15  m_cut_maxPosEta( 99.f),
16  m_cut_minMomEta(-99.f),
17  m_cut_maxMomEta( 99.f),
18  m_cut_minMom2(-1.),
19  m_cut_maxMom2(-1.),
20  m_cut_maxEkin(-1.),
21  m_cut_charge(ISF_UNDEF_CHARGE),
22  m_cut_pdg(0)
23 {
24 }
25 
26 /** emtpy destructor */
27 ISF::KinematicParticleCuts::~KinematicParticleCuts() {
28 }
29 
30 bool ISF::KinematicParticleCuts::pass(const ISFParticle& particle) const {
31  const Amg::Vector3D& hepMom = particle.momentum();
32  const Amg::Vector3D& hepPos = particle.position();
33  double posEta = hepPos.eta();
34  double mom2 = hepMom.mag2();
35  double momEta = hepMom.eta();
36 
37  // tolerance on the charge
38  const float chargeTolerance = 1e-4f;
39 
40  bool pass = true;
41  pass &= m_cut_pdg ? (abs(particle.pdgCode()) == m_cut_pdg) : true;
42  pass &= (m_cut_charge < (ISF_UNDEF_CHARGE+1.)) || fabs(particle.charge()-m_cut_charge)<chargeTolerance;
43  pass &= (m_cut_minMom2 < 0.) || (mom2 >= m_cut_minMom2);
44  pass &= (m_cut_maxMom2 < 0.) || (mom2 <= m_cut_maxMom2);
45  pass &= (momEta >= m_cut_minMomEta);
46  pass &= (momEta <= m_cut_maxMomEta);
47  pass &= (posEta >= m_cut_minPosEta);
48  pass &= (posEta <= m_cut_maxPosEta);
49 
50  return pass;
51 }
52