ATLAS Offline Software
xAODTTbarWithJpsimumuFilter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
5 
6 #include "GaudiKernel/MsgStream.h"
7 
8 //--------------------------------------------------------------------------
10  ISvcLocator *pSvcLocator)
11  : GenFilter(fname, pSvcLocator)
12 
13 {
14  declareProperty("SelectJpsi", m_selectJpsi = true);
15  declareProperty("JpsipTMinCut", m_JpsiPtMinCut = 0.);
16  declareProperty("JpsietaMaxCut", m_JpsiEtaMaxCut = 5.);
17 }
18 
19 //--------------------------------------------------------------------------
21 {
23 }
24 
25 //---------------------------------------------------------------------------
27 {
28  ATH_MSG_INFO("Initialized");
29  return StatusCode::SUCCESS;
30 }
31 
32 //---------------------------------------------------------------------------
34 {
35  ATH_MSG_INFO(" Events out of " << m_nPass + m_nFail << " passed the filter");
36  return StatusCode::SUCCESS;
37 }
38 
39 //---------------------------------------------------------------------------
41 {
42  //---------------------------------------------------------------------------
43 
44  bool pass = false;
45  bool isjpsi = false;
46 // Retrieve TruthGen container from xAOD Gen slimmer, contains all particles witout barcode_zero and
47 // duplicated barcode ones
48  const xAOD::TruthParticleContainer* xTruthParticleContainer;
49  if (evtStore()->retrieve(xTruthParticleContainer, "TruthGen").isFailure()) {
50  ATH_MSG_ERROR("No TruthParticle collection with name " << "TruthGen" << " found in StoreGate!");
51  return StatusCode::FAILURE;
52  }
53 
54  // Loop over all truth particles in the container
55  unsigned int nPart = xTruthParticleContainer->size();
56  for (unsigned int iPart = 0; iPart < nPart; ++iPart) {
57  const xAOD::TruthParticle* pitr = (*xTruthParticleContainer)[iPart];
58  if (std::abs(pitr->pdgId())!=443) continue;
59  if (HepMC::is_simulation_particle(pitr)) continue;
60  if(!isLeptonDecay(pitr, 13)) continue;
61  if (!passJpsiSelection(pitr)) continue;
62  isjpsi = true;
63 
64  }
65 
66 
67  if (m_selectJpsi && isjpsi)
68  pass = true;
69 
70  setFilterPassed(pass);
71  return StatusCode::SUCCESS;
72 }
73 
74 // ========================================================
76 {
77  auto end = part->decayVtx();
78  if (!end)
79  return true;
80  for (size_t thisChild_id = 0; thisChild_id < end->nOutgoingParticles(); thisChild_id++)
81  {
82  auto p = end->outgoingParticle(thisChild_id);
83  if (std::abs(p->pdgId()) != type)
84  return false;
85  }
86  return true;
87 }
88 
89 // ========================================================
91 {
92  double pt = part->pt();
93  double eta = std::abs(part->eta());
94 
95  if (pt < m_JpsiPtMinCut)
96  return false;
97  if (eta > m_JpsiEtaMaxCut)
98  return false;
99 
100  return true;
101 }
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAODTTbarWithJpsimumuFilter::m_JpsiPtMinCut
double m_JpsiPtMinCut
Definition: xAODTTbarWithJpsimumuFilter.h:36
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
xAODTTbarWithJpsimumuFilter::m_JpsiEtaMaxCut
double m_JpsiEtaMaxCut
Definition: xAODTTbarWithJpsimumuFilter.h:37
test_pyathena.pt
pt
Definition: test_pyathena.py:11
xAODTTbarWithJpsimumuFilter::filterInitialize
virtual StatusCode filterInitialize()
Definition: xAODTTbarWithJpsimumuFilter.cxx:26
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
xAODTTbarWithJpsimumuFilter::passJpsiSelection
bool passJpsiSelection(const xAOD::TruthParticle *part) const
Definition: xAODTTbarWithJpsimumuFilter.cxx:90
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
GenFilter
Base class for event generator filtering modules.
Definition: GenFilter.h:30
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
HepMC::is_simulation_particle
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
Definition: MagicNumbers.h:299
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:41
xAODTTbarWithJpsimumuFilter::isLeptonDecay
bool isLeptonDecay(const xAOD::TruthParticle *part, int type) const
Definition: xAODTTbarWithJpsimumuFilter.cxx:75
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
GenFilter::m_nPass
int m_nPass
Definition: GenFilter.h:65
xAODTTbarWithJpsimumuFilter::xAODTTbarWithJpsimumuFilter
xAODTTbarWithJpsimumuFilter(const std::string &fname, ISvcLocator *pSvcLocator)
Definition: xAODTTbarWithJpsimumuFilter.cxx:9
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:67
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
GenFilter::m_nFail
int m_nFail
Definition: GenFilter.h:66
xAODTTbarWithJpsimumuFilter::~xAODTTbarWithJpsimumuFilter
virtual ~xAODTTbarWithJpsimumuFilter()
Definition: xAODTTbarWithJpsimumuFilter.cxx:20
xAODTTbarWithJpsimumuFilter.h
xAODTTbarWithJpsimumuFilter::filterFinalize
virtual StatusCode filterFinalize()
Definition: xAODTTbarWithJpsimumuFilter.cxx:33
xAOD::TruthParticle_v1::pdgId
int pdgId() const
PDG ID code.
xAODTTbarWithJpsimumuFilter::m_selectJpsi
bool m_selectJpsi
properties
Definition: xAODTTbarWithJpsimumuFilter.h:33
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAODTTbarWithJpsimumuFilter::filterEvent
virtual StatusCode filterEvent()
Definition: xAODTTbarWithJpsimumuFilter.cxx:40