ATLAS Offline Software
Loading...
Searching...
No Matches
StgcDataPreparator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8 const std::string& name,
9 const IInterface* parent):
10 AthAlgTool(type,name,parent),
11 m_regionSelector("RegSelTool/RegSelTool_STGC",this)
12{
13 declareProperty("RegSel_STGC", m_regionSelector);
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::StgcDataPreparator::prepareData(const EventContext& ctx,
32 const TrigRoiDescriptor* p_roids,
33 TrigL2MuonSA::StgcHits& stgcHits) const
34{
35
36 ATH_MSG_DEBUG("StgcDataPreparator::prepareData() was called.");
37
38 stgcHits.clear();
39
40 std::vector<const Muon::sTgcPrepDataCollection*> stgcCols;
41 std::vector<IdentifierHash> stgcHashList;
42 std::vector<IdentifierHash> stgcHashList_cache;
43
44 // Get sTGC container
45 if(m_stgcPrepContainerKey.empty()) {
46 ATH_MSG_INFO("no stgcPrepContainerKey");
47 return StatusCode::SUCCESS;
48 }
49 auto stgcPrepContainerHandle = SG::makeHandle(m_stgcPrepContainerKey, ctx);
50 if (!stgcPrepContainerHandle.isValid()) {
51 ATH_MSG_ERROR("Cannot retrieve sTgc PRD Container key: " << m_stgcPrepContainerKey.key());
52 return StatusCode::FAILURE;
53 } else {
54 ATH_MSG_DEBUG("sTgc PRD Container retrieved with key: " << m_stgcPrepContainerKey.key());
55 }
56 const Muon::sTgcPrepDataContainer* stgcPrds = stgcPrepContainerHandle.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, stgcHashList);
64 else {
65 TrigRoiDescriptor fullscan_roi( true );
66 m_regionSelector->lookup(ctx)->HashIDList(fullscan_roi, stgcHashList);
67 }
68 ATH_MSG_DEBUG("stgcHashList.size()=" << stgcHashList.size());
69
70 std::vector<uint32_t> stgcRobList;
71 m_regionSelector->lookup(ctx)->ROBIDList(*iroi, stgcRobList);
72
73 if (!stgcHashList.empty()) {
74
75 // Get sTGC collections
76 for(const IdentifierHash& id : stgcHashList) {
77
78 const auto* STGCcoll = stgcPrds->indexFindPtr(id);
79
80 if( STGCcoll == nullptr ) {
81 continue;
82 }
83
84 if( STGCcoll->size() == 0) {
85 ATH_MSG_DEBUG("Empty STGC list");
86 continue;
87 }
88
89 stgcHashList_cache.push_back(id);
90 stgcCols.push_back(STGCcoll);
91 }
92 }
93
94 }
95 else {
96 ATH_MSG_DEBUG("Use full data access");
97
98 // Get sTgc collections
99 for(const auto stgccoll : *stgcPrds) {
100 stgcCols.push_back(stgccoll);
101 }
102
103 }
104
105 for( const Muon::sTgcPrepDataCollection* stgc : stgcCols ){
106
107 stgcHits.reserve( stgcHits.size() + stgc->size() );
108 for( const Muon::sTgcPrepData* prepData : *stgc ) {
109
110 // save sTGC hit data in StgcHitData
112
113 lutDigit.eta = prepData->globalPosition().eta();
114 lutDigit.phi = prepData->globalPosition().phi();
115 lutDigit.r = prepData->globalPosition().perp();
116 lutDigit.z = prepData->globalPosition().z();
117 lutDigit.stationEta = m_idHelperSvc->stgcIdHelper().stationEta(prepData->identify());
118 lutDigit.stationPhi = m_idHelperSvc->stgcIdHelper().stationPhi(prepData->identify());
119 lutDigit.stationName = m_idHelperSvc->stgcIdHelper().stationName(prepData->identify());
120 lutDigit.channelType = m_idHelperSvc->stgcIdHelper().channelType(prepData->identify()); // strip=1, wire=2, pad=0
121 lutDigit.ResidualR = 999;
122 lutDigit.ResidualPhi = 999;
123 lutDigit.isOutlier = 0;
124 lutDigit.layerNumber = m_idHelperSvc->stgcIdHelper().gasGap(prepData->identify())-1 + 4*(m_idHelperSvc->stgcIdHelper().multilayer(prepData->identify())-1);
125 stgcHits.push_back(lutDigit);
126
127 ATH_MSG_DEBUG("StgcDataPreparator: global eta/phi/r/z station eta/phi/name channel_type layer " << lutDigit.eta << "/" << lutDigit.phi << "/" << lutDigit.r << "/" << lutDigit.z << " " << lutDigit.stationEta << "/" << lutDigit.stationPhi << "/" << lutDigit.stationName << " " << lutDigit.channelType << " " << (m_idHelperSvc->stgcIdHelper().gasGap(prepData->identify())-1 + 4*(m_idHelperSvc->stgcIdHelper().multilayer(prepData->identify())-1)) );
128
129 }
130 }
131
132 return StatusCode::SUCCESS;
133}
#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 sTgc measurements.
StatusCode prepareData(const EventContext &ctx, const TrigRoiDescriptor *p_roids, TrigL2MuonSA::StgcHits &stgcHits) const
StgcDataPreparator(const std::string &type, const std::string &name, const IInterface *parent)
ToolHandle< IRegSelTool > m_regionSelector
virtual StatusCode initialize() override
SG::ReadHandleKey< Muon::sTgcPrepDataContainer > m_stgcPrepContainerKey
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
unsigned int layerNumber
Definition StgcData.h:42
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
MuonPrepDataContainerT< sTgcPrepData > sTgcPrepDataContainer
MuonPrepDataCollection< sTgcPrepData > sTgcPrepDataCollection
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
std::vector< StgcHitData > StgcHits
Definition StgcData.h:49