Loading [MathJax]/jax/output/SVG/config.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
RPCSimulation.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "RPCSimulation.h"
6 
9 
10 namespace L0Muon
11 {
12 
14  {
15  ATH_MSG_DEBUG("Initializing " << name() << "...");
16 
17  ATH_CHECK(m_keyRpcRdo.initialize());
20 
23 
25  if (!m_monTool.empty())
26  ATH_CHECK(m_monTool.retrieve());
27 
28  return StatusCode::SUCCESS;
29  }
30 
31  StatusCode RPCSimulation::execute(const EventContext &ctx) const
32  {
33  ATH_MSG_DEBUG("Executing " << name() << "...");
34 
35  SG::ReadHandle inputRDO(m_keyRpcRdo, ctx);
36  ATH_CHECK(inputRDO.isPresent());
37  ATH_MSG_DEBUG("Number of RPC RDO: " << inputRDO->size());
38 
40  ATH_CHECK(cablingMap.isValid());
41 
43  if (!m_monTool.empty())
44  {
45  auto n_of_RDO = Monitored::Scalar<unsigned int>("n_of_RDO", inputRDO->size());
46  }
47 
50  ATH_CHECK(outputCands.record(std::make_unique<L0Muon::BarrelCandDataContainer>()));
51 
53  const McEventCollection *mcCollptr = nullptr;
54  SG::ReadHandle<McEventCollection> mcEventCollectionHandle{m_mcEventCollectionKey, ctx};
55  if (!mcEventCollectionHandle.isValid())
56  {
57  ATH_MSG_FATAL(" McEventCollection not found: " << m_mcEventCollectionKey.key());
58  return StatusCode::FAILURE;
59  }
60  mcCollptr = mcEventCollectionHandle.cptr();
61 
63  for (unsigned int cntr = 0; cntr < mcCollptr->size(); ++cntr)
64  {
65  const HepMC::GenEvent *genEvt = (mcCollptr->at(cntr));
66 
67  for (const auto& p : *genEvt)
68  {
69  if (MC::isMuon(p))
70  {
71  // Check if the particle is in the barrel region
72  if (fabs(p->momentum().eta())>1.05)
73  continue;
74 
75  ATH_MSG_DEBUG("Found a muon with pdgId: " << p->pdg_id());
76 
77  // Create a new candidate
78  float eta = p->momentum().eta();
79  float phi = p->momentum().phi();
80  float pt = p->momentum().perp();
82  uint8_t charge = p->pdg_id() < 0 ? 0 : 1;
83 
86  uint16_t subdetectorId = eta > 0 ? 0x65 : 0x66;
87  auto cand = std::make_unique<L0Muon::BarrelCandData>(subdetectorId,
88  0, 0);
89 
90  cand->setEta(eta);
91  cand->setPhi(phi);
92  cand->setPt(pt);
93  cand->setThreshold(0);
94  cand->setCharge(charge);
95  cand->setMdtFlag(0);
96 
98  outputCands->push_back(std::move(cand));
99  }
100  }
101 
102  }
103  return StatusCode::SUCCESS;
104  }
105 } // end of namespace
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
L0Muon::RPCSimulation::m_outputCandKey
SG::WriteHandleKey< L0Muon::BarrelCandDataContainer > m_outputCandKey
Output Trigger candidates.
Definition: RPCSimulation.h:36
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
RPCSimulation.h
L0Muon::RPCSimulation::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: RPCSimulation.h:40
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
MuonRoIAuxContainer.h
test_pyathena.pt
pt
Definition: test_pyathena.py:11
L0Muon::BarrelCandData::Quality::Q_BEST
@ Q_BEST
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
L0Muon
Definition: L0MuonSmearingAlg.cxx:13
L0Muon::RPCSimulation::initialize
virtual StatusCode initialize() override
Definition: RPCSimulation.cxx:13
L0Muon::RPCSimulation::m_mcEventCollectionKey
SG::ReadHandleKey< McEventCollection > m_mcEventCollectionKey
truth container
Definition: RPCSimulation.h:43
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
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
MdtMezzExtraction.cablingMap
cablingMap
Definition: MdtMezzExtraction.py:19
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
L0Muon::RPCSimulation::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: RPCSimulation.cxx:31
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
charge
double charge(const T &p)
Definition: AtlasPID.h:931
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
L0Muon::RPCSimulation::m_cablingKey
SG::ReadCondHandleKey< Muon::RpcCablingMap > m_cablingKey
NRPC cabling map.
Definition: RPCSimulation.h:39
L0Muon::RPCSimulation::m_keyRpcRdo
SG::ReadHandleKey< xAOD::NRPCRDOContainer > m_keyRpcRdo
RPC Rdo.
Definition: RPCSimulation.h:33
SG::VarHandleBase::isPresent
bool isPresent() const
Is the referenced object present in SG?
Definition: StoreGate/src/VarHandleBase.cxx:400
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
HepMCHelpers.h
isMuon
bool isMuon(const T &p)
Definition: AtlasPID.h:194