ATLAS Offline Software
DecayTimeFilter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <limits> // std::numeric_limits
7 
8 
9 DecayTimeFilter::DecayTimeFilter(const std::string& name, ISvcLocator* pSvcLocator)
10  : GenFilter(name, pSvcLocator)
11 {
12  declareProperty("LifetimeLow",m_lifetimeLow = std::numeric_limits<float>::lowest(), "proper decay time value in ps");
13  declareProperty("LifetimeHigh",m_lifetimeHigh = std::numeric_limits<float>::max(), "proper decay time value in ps");
15 }
16 
17 
19  ATH_MSG_INFO("lifetimeLow=" << m_lifetimeLow);
20  ATH_MSG_INFO("lifetimeHigh=" << m_lifetimeHigh);
21  for(int pdg : m_particleID){
22  ATH_MSG_INFO("PDG codes=" << pdg);
23  }
24  return StatusCode::SUCCESS;
25 }
26 
27 double calcmag(const HepMC::FourVector& vect){
28  return std::sqrt(vect.x() * vect.x() + vect.y() * vect.y() + vect.z() * vect.z());
29 }
30 
32  auto startpos = ptr->production_vertex()->position ();
33  auto endpos = ptr->end_vertex() ->position ();
34  HepMC::FourVector diff(endpos.x() - startpos.x(), endpos.y() - startpos.y(), endpos.z() - startpos.z(), endpos.t() - startpos.t());
35  double mag = calcmag(diff);
36  double length = mag;
37  HepMC::FourVector p = ptr->momentum ();
38  return (1000./299.792458) * (length * ptr->generated_mass() / calcmag(p));
39 }
40 
42  int nPassPDG = 0;
43  bool passed = true;
44  for (McEventCollection::const_iterator itr = events()->begin(); itr != events()->end(); ++itr) {
45  const HepMC::GenEvent* genEvt = *itr;
46  for (const auto& part: *genEvt){
47  for (int pdg : m_particleID){
48  if(pdg == part->pdg_id()){
49  nPassPDG++;
50  double calctau = tau(part);
51  passed &= calctau < m_lifetimeHigh && calctau > m_lifetimeLow;
52  }
53  }
54  }
55  }
56  setFilterPassed((nPassPDG > 0) & passed);
57  return StatusCode::SUCCESS;
58 }
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
max
#define max(a, b)
Definition: cfImp.cxx:41
TrigCompositeUtils::passed
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
Definition: TrigCompositeUtilsRoot.cxx:117
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
DecayTimeFilter::m_particleID
std::vector< int > m_particleID
Definition: DecayTimeFilter.h:22
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
mc.diff
diff
Definition: mc.SFGenPy8_MuMu_DD.py:14
calcmag
double calcmag(const HepMC::FourVector &vect)
Definition: DecayTimeFilter.cxx:27
python.DataFormatRates.events
events
Definition: DataFormatRates.py:105
DecayTimeFilter.h
DecayTimeFilter::m_lifetimeHigh
float m_lifetimeHigh
Definition: DecayTimeFilter.h:21
GenFilter
Base class for event generator filtering modules.
Definition: GenFilter.h:30
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DecayTimeFilter::filterEvent
virtual StatusCode filterEvent()
Definition: DecayTimeFilter.cxx:41
DecayTimeFilter::m_lifetimeLow
float m_lifetimeLow
Definition: DecayTimeFilter.h:20
DecayTimeFilter::tau
double tau(const HepMC::ConstGenParticlePtr &ptr) const
Definition: DecayTimeFilter.cxx:31
DecayTimeFilter::DecayTimeFilter
DecayTimeFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: DecayTimeFilter.cxx:9
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
mag
Scalar mag() const
mag method
Definition: AmgMatrixBasePlugin.h:25
DecayTimeFilter::filterInitialize
virtual StatusCode filterInitialize()
Definition: DecayTimeFilter.cxx:18