ATLAS Offline Software
Loading...
Searching...
No Matches
MmDataPreparator.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 "MmDataPreparator.h"
6
8 const std::string& name,
9 const IInterface* parent):
10 AthAlgTool(type,name,parent),
11 m_regionSelector("RegSelTool/RegSelTool_MM",this)
12{
14}
15
17{
18
19 // Locate RegionSelector
20 ATH_CHECK( m_regionSelector.retrieve() );
21 ATH_MSG_DEBUG("Retrieved service RegionSelector");
22
23 ATH_CHECK(m_idHelperSvc.retrieve());
24 ATH_MSG_DEBUG("Retrieved " << m_idHelperSvc);
25
27
28 return StatusCode::SUCCESS;
29}
30
31StatusCode TrigL2MuonSA::MmDataPreparator::prepareData(const EventContext& ctx,
32 const TrigRoiDescriptor* p_roids,
33 TrigL2MuonSA::MmHits& mmHits) const
34{
35
36 ATH_MSG_DEBUG("MmDataPreparator::prepareData() was called.");
37
38 mmHits.clear();
39
40 std::vector<const Muon::MMPrepDataCollection*> mmCols;
41 std::vector<IdentifierHash> mmHashList;
42 std::vector<IdentifierHash> mmHashList_cache;
43
44 // Get MM container
45 if(m_mmPrepContainerKey.empty()) {
46 ATH_MSG_INFO("no mmPrepContainerKey");
47 return StatusCode::SUCCESS;
48 }
49 auto mmPrepContainerHandle = SG::makeHandle(m_mmPrepContainerKey, ctx);
50 if (!mmPrepContainerHandle.isValid()) {
51 ATH_MSG_ERROR("Cannot retrieve MM PRD Container key: " << m_mmPrepContainerKey.key());
52 return StatusCode::FAILURE;
53 } else {
54 ATH_MSG_DEBUG("MM PRD Container retrieved with key: " << m_mmPrepContainerKey.key());
55 }
56 const Muon::MMPrepDataContainer* mmPrds = mmPrepContainerHandle.cptr();
57
59 // ATH_MSG_ERROR("RoI based data access is not available yet");
60
61 ATH_MSG_DEBUG("Use RoI based data access");
62 const IRoiDescriptor* iroi = static_cast<const IRoiDescriptor*> (p_roids);
63 if (iroi) m_regionSelector->lookup(ctx)->HashIDList(*iroi, mmHashList);
64 else {
65 TrigRoiDescriptor fullscan_roi( true );
66 m_regionSelector->lookup(ctx)->HashIDList(fullscan_roi, mmHashList);
67 }
68 ATH_MSG_DEBUG("mmHashList.size()=" << mmHashList.size());
69
70 std::vector<uint32_t> mmRobList;
71 m_regionSelector->lookup(ctx)->ROBIDList(*iroi, mmRobList);
72
73 if (!mmHashList.empty()) {
74
75 // Get MM collections
76 for(const IdentifierHash& id : mmHashList) {
77
78 const auto* MMcoll = mmPrds->indexFindPtr(id);
79
80 if( MMcoll == nullptr ) {
81 continue;
82 }
83
84 if( MMcoll->size() == 0) {
85 ATH_MSG_DEBUG("Empty MM list");
86 continue;
87 }
88
89 mmHashList_cache.push_back(id);
90 mmCols.push_back(MMcoll);
91 }
92 }
93
94 }
95 else {
96 ATH_MSG_DEBUG("Use full data access");
97
98 // Get MM collections
99 for(const auto mmcoll : *mmPrds) {
100 mmCols.push_back(mmcoll);
101 }
102
103 }
104
105
106 for( const Muon::MMPrepDataCollection* mm : mmCols ){
107
108 mmHits.reserve( mmHits.size() + mm->size() );
109 for( const Muon::MMPrepData* prd : *mm ) {
110
111 // save MM hit data in MmHitData
113
114 lutDigit.eta = prd->globalPosition().eta();
115 lutDigit.phi = prd->globalPosition().phi();
116 lutDigit.r = prd->globalPosition().perp();
117 lutDigit.z = prd->globalPosition().z();
118 lutDigit.stationEta = m_idHelperSvc->mmIdHelper().stationEta(prd->identify());
119 lutDigit.stationPhi = m_idHelperSvc->mmIdHelper().stationPhi(prd->identify());
120 lutDigit.stationName = m_idHelperSvc->mmIdHelper().stationName(prd->identify());
121 lutDigit.ResidualR = 999;
122 lutDigit.ResidualPhi = 999;
123 lutDigit.isOutlier = 0;
124 lutDigit.layerNumber = m_idHelperSvc->mmIdHelper().gasGap(prd->identify())-1 + 4*(m_idHelperSvc->mmIdHelper().multilayer(prd->identify())-1);
125 mmHits.push_back(lutDigit);
126
127 ATH_MSG_DEBUG("MmDataPreparator: global eta/phi/r/z station eta/phi/name channel/layer " << lutDigit.eta << "/" << lutDigit.phi << "/" << lutDigit.r << "/" << lutDigit.z << " " << lutDigit.stationEta << "/" << lutDigit.stationPhi << "/" << lutDigit.stationName << " " << m_idHelperSvc->mmIdHelper().channel(prd->identify()) << "/" << lutDigit.layerNumber);
128
129 }
130 }
131
132 return StatusCode::SUCCESS;
133
134}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Describes the API of the Region of Ineterest geometry.
virtual const T * indexFindPtr(IdentifierHash hashId) const override final
return pointer on the found entry or null if out of range using hashed index - fast version,...
This is a "hash" representation of an Identifier.
Class to represent MM measurements.
Definition MMPrepData.h:22
StatusCode prepareData(const EventContext &ctx, const TrigRoiDescriptor *p_roids, TrigL2MuonSA::MmHits &mmHits) const
MmDataPreparator(const std::string &type, const std::string &name, const IInterface *parent)
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
virtual StatusCode initialize() override
ToolHandle< IRegSelTool > m_regionSelector
SG::ReadHandleKey< Muon::MMPrepDataContainer > m_mmPrepContainerKey
unsigned int layerNumber
Definition MmData.h:41
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
MuonPrepDataCollection< MMPrepData > MMPrepDataCollection
MuonPrepDataContainerT< MMPrepData > MMPrepDataContainer
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
std::vector< MmHitData > MmHits
Definition MmData.h:47