ATLAS Offline Software
Loading...
Searching...
No Matches
NSWSimulation.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "NSWSimulation.h"
6
7namespace L0Muon {
8
10 ATH_MSG_DEBUG("Initializing " << name() << "...");
11
12 ATH_CHECK(m_keyMmDigit.initialize());
13 ATH_CHECK(m_keySTgcDigit.initialize());
14
16 ATH_CHECK(m_outputKey.initialize());
17
19 if (!m_monTool.empty()) ATH_CHECK(m_monTool.retrieve());
20
21 return StatusCode::SUCCESS;
22 }
23
24 StatusCode NSWSimulation::execute(const EventContext& ctx) const {
25 ATH_MSG_DEBUG ("Executing " << name() << "...");
26
28 if( !mmDigits.isValid() ){
29 ATH_MSG_ERROR("Cannot retrieve MmDigitContainer");
30 return StatusCode::FAILURE;
31 }
32
34 if(!stgcDigits.isValid()) {
35 ATH_MSG_ERROR("Failed to retrieve the sTGC Digit container");
36 return StatusCode::FAILURE;
37 }
38
39 ATH_MSG_DEBUG("Number of MM Digits: " << mmDigits->size());
40 ATH_MSG_DEBUG("Number of sTGC Digits: " << stgcDigits->size());
41 ATH_MSG_DEBUG("Number of NSW Digits: " << (mmDigits->size() + stgcDigits->size()));
42
44 auto nMMDigits = Monitored::Scalar<unsigned int>("nMMDigits", mmDigits->size() );
45 auto nsTGCDigits = Monitored::Scalar<unsigned int>("nsTGCDigits", stgcDigits->size() );
46 Monitored::Group(m_monTool, nMMDigits, nsTGCDigits);
47
49
50 auto container = std::make_unique<xAOD::NSWCandDataContainer>();
51 auto auxContainer = std::make_unique<xAOD::NSWCandDataAuxContainer>();
52 container->setStore(auxContainer.get());
53
55 xAOD::NSWCandData* cand = container->push_back(std::make_unique<xAOD::NSWCandData>());
56 cand->setBCID(ctx.eventID().bunch_crossing_id());
57 cand->setNSegments(2);
58 cand->setOverflow(false);
59 cand->setBoardId(1);
60 cand->setFiberId(0);
61
62 // Push Segment #0
63 cand->addSegment(100, 50, 2, 4);
64
65 // Push Segment #1
66 cand->addSegment(250, 120, 5, 3);
67
68 // Read Segment #0 properties (Index 0)
69 uint16_t eta0 = cand->segEtaIndex(0);
70 uint16_t phi0 = cand->segPhiIndex(0);
71 uint8_t dth0 = cand->segDeltaThetaIndex(0);
72 uint8_t qual0 = cand->segQuality(0);
73
74 // Read Segment #1 properties (Index 1)
75 uint16_t eta1 = cand->segEtaIndex(1);
76 uint16_t phi1 = cand->segPhiIndex(1);
77 uint8_t dth1 = cand->segDeltaThetaIndex(1);
78 uint8_t qual1 = cand->segQuality(1);
79
80 ATH_MSG_DEBUG("Verification check:"
81 << "\n Seg0 -> Eta: " << eta0 << ", Phi: " << phi0
82 << ", DeltaTheta: " << static_cast<int>(dth0) << ", Quality: " << static_cast<int>(qual0)
83 << "\n Seg1 -> Eta: " << eta1 << ", Phi: " << phi1
84 << ", DeltaTheta: " << static_cast<int>(dth1) << ", Quality: " << static_cast<int>(qual1));
85
86 ATH_MSG_DEBUG(*cand);
87
88 cand->clearSegments();
89 cand->addSegment(200, 100, 2, 3);
90 cand->setNSegments(1);
91
92 ATH_MSG_DEBUG(*cand);
93
94 ATH_CHECK(output.record(std::move(container), std::move(auxContainer)));
95
96 ATH_MSG_DEBUG( "Recorded NSW candidate container with " << output->size() << " candidate(s)");
97
98 return StatusCode::SUCCESS;
99 }
100
101} // end of namespace L0Muon
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
SG::WriteHandleKey< xAOD::NSWCandDataContainer > m_outputKey
Output NSW trigger candidate container.
ToolHandle< GenericMonitoringTool > m_monTool
SG::ReadHandleKey< sTgcDigitContainer > m_keySTgcDigit
sTGC digits
virtual StatusCode initialize() override
SG::ReadHandleKey< MmDigitContainer > m_keyMmDigit
MM Digit container.
virtual StatusCode execute(const EventContext &ctx) const override
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
void setStore(SG::IAuxStore *store)
Set the store associated with this object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
void setBCID(uint16_t bcid)
Setters.
void setFiberId(uint8_t fiber)
Set the fiber id.
uint16_t segEtaIndex(size_t i) const
Element-by-Element Index.
void setNSegments(uint8_t nseg)
Set the total number of segments sent from NSW-TP to Sector Logic.
void clearSegments()
Clear all recorded segment vectors.
void addSegment(uint16_t etaIndex, uint16_t phiIndex, uint8_t deltaThetaIndex, uint8_t quality)
Pack and append a single segment.
uint16_t segPhiIndex(size_t i) const
Retrieve the phi index for a specific segment.
uint8_t segDeltaThetaIndex(size_t i) const
Retrieve the delta theta index for a specific segment.
void setBoardId(uint8_t board)
Set the board id.
void setOverflow(bool ovf)
Set the segment total capacity overflow state flag.
uint8_t segQuality(size_t i) const
Retrieve the quality flag for a specific segment.
NSWCandData_v1 NSWCandData
Definition NSWCandData.h:12