ATLAS Offline Software
GenParticleLifetimeFilter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // GenParticleLifetimeFilter.cxx, (c) ATLAS Detector software
8 
9 // class header include
11 
12 // HepMC includes
13 #include "AtlasHepMC/GenParticle.h"
14 #include "AtlasHepMC/GenVertex.h"
15 
16 // CLHEP includes
17 #include "CLHEP/Vector/LorentzVector.h"
18 
21  const std::string& n,
22  const IInterface* p )
23  : base_class(t,n,p)
24 {
25  declareProperty("MinimumLifetime", m_minLifetime, "");
26 }
27 
28 
30 #ifdef HEPMC3
32  // the GenParticle end vertex
33  auto endVtx = particle->end_vertex();
34 #else
36  // the GenParticle end vertex
37  auto endVtx = particle.end_vertex();
38 #endif
39  // no end vertex?
40  if (!endVtx) {
41  ATH_MSG_DEBUG("GenParticle does not have an end vertex, this is fine");
42  return true;
43  }
44  // (x,y,z) end position
45  const auto& end4Vec = endVtx->position();
46 
47  // the GenParticle production vertex
48 #ifdef HEPMC3
49  auto prodVtx = particle->production_vertex();
50 #else
51  auto prodVtx = particle.production_vertex();
52 #endif
53  // no production vertex?
54  if (!prodVtx) {
55  ATH_MSG_DEBUG("GenParticle does not have a production vertex, filtering it out");
56  return false;
57  }
58  // (x,y,z) production position
59  const auto& prod4Vec = prodVtx->position();
60  const CLHEP::HepLorentzVector lv0 ( prod4Vec.x(), prod4Vec.y(), prod4Vec.z(), prod4Vec.t() );
61  const CLHEP::HepLorentzVector lv1 ( end4Vec.x(), end4Vec.y(), end4Vec.z(), end4Vec.t() );
62  return ((lv1-lv0).mag()>m_minLifetime);
63 }
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
GenVertex.h
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
GenParticle.h
beamspotman.n
n
Definition: beamspotman.py:731
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ISF::GenParticleLifetimeFilter::pass
bool pass(const HepMC::GenParticle &particle) const
does the given particle pass the filter?
Definition: GenParticleLifetimeFilter.cxx:35
GenParticleLifetimeFilter.h
ISF::GenParticleLifetimeFilter::GenParticleLifetimeFilter
GenParticleLifetimeFilter(const std::string &t, const std::string &n, const IInterface *p)
Constructor.
Definition: GenParticleLifetimeFilter.cxx:20
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
ISF::GenParticleLifetimeFilter::m_minLifetime
double m_minLifetime
Definition: GenParticleLifetimeFilter.h:44
mag
Scalar mag() const
mag method
Definition: AmgMatrixBasePlugin.h:25
GenParticle
@ GenParticle
Definition: TruthClasses.h:30