ATLAS Offline Software
xAODForwardProtonFilter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // GeneratorFilters/ForwardProtonFilter
6 //
7 // Allows the user to search for forward intact protons originating from
8 // elastic and diffractive interactions. Event passes filters if there forward
9 // proton with xi and pt in given range. If double tag option is enables, such
10 // protons are requested on both sides. single_tagA/single_tagC require protons
11 // on a given side, regardless what's happenning on the other
12 //
13 // Authors:
14 // Rafal Staszewski Jul 2011
15 
18 
19 xAODForwardProtonFilter::xAODForwardProtonFilter(const std::string &name, ISvcLocator *pSvcLocator)
20  : GenFilter(name, pSvcLocator)
21 {
22 }
23 
25 {
26  bool accepted_A = false;
27  bool accepted_C = false;
28 
29  // Retrieve TruthGen container from xAOD Gen slimmer, contains all particles witout barcode_zero and
30 // duplicated barcode ones
31  const xAOD::TruthParticleContainer* xTruthParticleContainer;
32  if (evtStore()->retrieve(xTruthParticleContainer, "TruthGen").isFailure()) {
33  ATH_MSG_ERROR("No TruthParticle collection with name " << "TruthGen" << " found in StoreGate!");
34  return StatusCode::FAILURE;
35  }
36 
37  unsigned int nPart = xTruthParticleContainer->size();
38  for (unsigned int iPart = 0; iPart < nPart; ++iPart) {
39  const xAOD::TruthParticle* pitr = (*xTruthParticleContainer)[iPart];
40 
41  // We're only interested in stable (status == 1) particles
42 
43  if (!MC::isStable(pitr))
44  continue;
45  // We are specifically looking for protons
46  const long pid = pitr->pdgId();
47  if (pid != 2212)
48  continue;
49  const double E = pitr->e();
50  const double pz = pitr->pz();
51  const double pt = pitr->pt();
52  const double xi = (m_E0 - E) / m_E0;
53 
54  if (m_xiMin <= xi && xi <= m_xiMax && m_ptMin <= pt && pt <= m_ptMax)
55  {
56  accepted_C = (pz > 0);
57  accepted_A = (pz < 0);
58  }
59  if (accepted_A)
60  ATH_MSG_DEBUG("Found a proton with xi=" << xi << " on side C");
61  if (accepted_C)
62  ATH_MSG_DEBUG("Found a proton with xi=" << xi << " on side A");
63  if (m_DoubleTag && (accepted_A && accepted_C))
64  return StatusCode::SUCCESS;
65 
66  if (!m_DoubleTag)
67 
68  // if Single tag is not requested, do or
69  if (!m_Single_tagA && !m_Single_tagC && (accepted_A || accepted_C))
70  return StatusCode::SUCCESS;
71 
72  // if single tag request - check for presence on particular side
73  if (m_Single_tagA && accepted_A)
74  return StatusCode::SUCCESS;
75  if (m_Single_tagC && accepted_C)
76  return StatusCode::SUCCESS;
77  } // end loop on particles
78 
79  // If we get here the event doesn't pass the criteria
80  setFilterPassed(false);
81  return StatusCode::SUCCESS;
82 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAODForwardProtonFilter::m_xiMin
Gaudi::Property< double > m_xiMin
Definition: xAODForwardProtonFilter.h:24
xAODForwardProtonFilter::m_E0
Gaudi::Property< double > m_E0
Definition: xAODForwardProtonFilter.h:28
xAODForwardProtonFilter::m_xiMax
Gaudi::Property< double > m_xiMax
Definition: xAODForwardProtonFilter.h:25
xAOD::TruthParticle_v1::pz
float pz() const
The z component of the particle's momentum.
test_pyathena.pt
pt
Definition: test_pyathena.py:11
xAODForwardProtonFilter::m_ptMax
Gaudi::Property< double > m_ptMax
Definition: xAODForwardProtonFilter.h:27
xAODForwardProtonFilter::m_Single_tagA
Gaudi::Property< bool > m_Single_tagA
Definition: xAODForwardProtonFilter.h:30
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
xAOD::TruthParticle_v1::e
virtual double e() const override final
The total energy of the particle.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:41
xAODForwardProtonFilter::m_DoubleTag
Gaudi::Property< bool > m_DoubleTag
Definition: xAODForwardProtonFilter.h:29
xAODForwardProtonFilter::filterEvent
virtual StatusCode filterEvent() override
Definition: xAODForwardProtonFilter.cxx:24
ParticleGun_EoverP_Config.pid
pid
Definition: ParticleGun_EoverP_Config.py:62
Amg::pz
@ pz
Definition: GeoPrimitives.h:40
xAODForwardProtonFilter::xAODForwardProtonFilter
xAODForwardProtonFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: xAODForwardProtonFilter.cxx:19
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAODForwardProtonFilter::m_ptMin
Gaudi::Property< double > m_ptMin
Definition: xAODForwardProtonFilter.h:26
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
MC::isStable
bool isStable(const T &p)
Definition: HepMCHelpers.h:30
xAOD::TruthParticle_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: TruthParticle_v1.cxx:166
xAOD::TruthParticle_v1::pdgId
int pdgId() const
PDG ID code.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAODForwardProtonFilter::m_Single_tagC
Gaudi::Property< bool > m_Single_tagC
Definition: xAODForwardProtonFilter.h:31
HepMCHelpers.h
xAODForwardProtonFilter.h