ATLAS Offline Software
StgcDataPreparator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "StgcDataPreparator.h"
6 
8  const std::string& name,
9  const IInterface* 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 
26  ATH_CHECK(m_stgcPrepContainerKey.initialize(!m_stgcPrepContainerKey.empty()));
27 
28  return StatusCode::SUCCESS;
29 }
30 
32  TrigL2MuonSA::StgcHits& stgcHits) const
33 {
34 
35  ATH_MSG_DEBUG("StgcDataPreparator::prepareData() was called.");
36 
37  stgcHits.clear();
38 
39  std::vector<const Muon::sTgcPrepDataCollection*> stgcCols;
40  std::vector<IdentifierHash> stgcHashList;
41  std::vector<IdentifierHash> stgcHashList_cache;
42 
43  // Get sTGC container
44  if(m_stgcPrepContainerKey.empty()) {
45  ATH_MSG_INFO("no stgcPrepContainerKey");
46  return StatusCode::SUCCESS;
47  }
48  auto stgcPrepContainerHandle = SG::makeHandle(m_stgcPrepContainerKey);
49  if (!stgcPrepContainerHandle.isValid()) {
50  ATH_MSG_ERROR("Cannot retrieve sTgc PRD Container key: " << m_stgcPrepContainerKey.key());
51  return StatusCode::FAILURE;
52  } else {
53  ATH_MSG_DEBUG("sTgc PRD Container retrieved with key: " << m_stgcPrepContainerKey.key());
54  }
55  const Muon::sTgcPrepDataContainer* stgcPrds = stgcPrepContainerHandle.cptr();
56 
57  if (m_use_RoIBasedDataAccess) {
58  // ATH_MSG_ERROR("RoI based data access is not available yet");
59 
60  ATH_MSG_DEBUG("Use RoI based data access");
61  const IRoiDescriptor* iroi = (IRoiDescriptor*) p_roids;
62  if (iroi) m_regionSelector->lookup( Gaudi::Hive::currentContext() )->HashIDList(*iroi, stgcHashList);
63  else {
64  TrigRoiDescriptor fullscan_roi( true );
65  m_regionSelector->lookup( Gaudi::Hive::currentContext() )->HashIDList(fullscan_roi, stgcHashList);
66  }
67  ATH_MSG_DEBUG("stgcHashList.size()=" << stgcHashList.size());
68 
69  std::vector<uint32_t> stgcRobList;
70  m_regionSelector->lookup( Gaudi::Hive::currentContext() )->ROBIDList(*iroi, stgcRobList);
71 
72  if (!stgcHashList.empty()) {
73 
74  // Get sTGC collections
75  for(const IdentifierHash& id : stgcHashList) {
76 
77  const auto* STGCcoll = stgcPrds->indexFindPtr(id);
78 
79  if( STGCcoll == nullptr ) {
80  continue;
81  }
82 
83  if( STGCcoll->size() == 0) {
84  ATH_MSG_DEBUG("Empty STGC list");
85  continue;
86  }
87 
88  stgcHashList_cache.push_back(id);
89  stgcCols.push_back(STGCcoll);
90  }
91  }
92 
93  }
94  else {
95  ATH_MSG_DEBUG("Use full data access");
96 
97  // Get sTgc collections
98  for(const auto stgccoll : *stgcPrds) {
99  stgcCols.push_back(stgccoll);
100  }
101 
102  }
103 
104  for( const Muon::sTgcPrepDataCollection* stgc : stgcCols ){
105 
106  stgcHits.reserve( stgcHits.size() + stgc->size() );
107  for( const Muon::sTgcPrepData* prepData : *stgc ) {
108 
109  // save sTGC hit data in StgcHitData
110  TrigL2MuonSA::StgcHitData lutDigit;
111 
112  lutDigit.eta = prepData->globalPosition().eta();
113  lutDigit.phi = prepData->globalPosition().phi();
114  lutDigit.r = prepData->globalPosition().perp();
115  lutDigit.z = prepData->globalPosition().z();
116  lutDigit.stationEta = m_idHelperSvc->stgcIdHelper().stationEta(prepData->identify());
117  lutDigit.stationPhi = m_idHelperSvc->stgcIdHelper().stationPhi(prepData->identify());
118  lutDigit.stationName = m_idHelperSvc->stgcIdHelper().stationName(prepData->identify());
119  lutDigit.channelType = m_idHelperSvc->stgcIdHelper().channelType(prepData->identify()); // strip=1, wire=2, pad=0
120  lutDigit.ResidualR = 999;
121  lutDigit.ResidualPhi = 999;
122  lutDigit.isOutlier = 0;
123  lutDigit.layerNumber = m_idHelperSvc->stgcIdHelper().gasGap(prepData->identify())-1 + 4*(m_idHelperSvc->stgcIdHelper().multilayer(prepData->identify())-1);
124  stgcHits.push_back(lutDigit);
125 
126  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)) );
127 
128  }
129  }
130 
131  return StatusCode::SUCCESS;
132 }
Muon::MuonPrepDataContainer
Template for Muon PRD containers (which are basically collections of MuonPrepDataCollections).
Definition: MuonPrepDataContainer.h:42
TrigL2MuonSA::StgcDataPreparator::initialize
virtual StatusCode initialize() override
Definition: StgcDataPreparator.cxx:16
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TrigL2MuonSA::StgcHitData::stationEta
int stationEta
Definition: StgcData.h:36
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TrigL2MuonSA::StgcHitData::isOutlier
int isOutlier
Definition: StgcData.h:41
StgcDataPreparator.h
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
TrigL2MuonSA::StgcHitData::phi
double phi
Definition: StgcData.h:33
TrigL2MuonSA::StgcDataPreparator::m_regionSelector
ToolHandle< IRegSelTool > m_regionSelector
Definition: StgcDataPreparator.h:34
TrigL2MuonSA::StgcDataPreparator::StgcDataPreparator
StgcDataPreparator(const std::string &type, const std::string &name, const IInterface *parent)
Definition: StgcDataPreparator.cxx:7
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TrigL2MuonSA::StgcHitData::r
double r
Definition: StgcData.h:34
TrigL2MuonSA::StgcHitData
Definition: StgcData.h:14
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IRoiDescriptor
Describes the API of the Region of Ineterest geometry.
Definition: IRoiDescriptor.h:23
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TrigL2MuonSA::StgcHitData::channelType
int channelType
Definition: StgcData.h:43
Muon::MuonPrepDataCollection
Template to hold collections of MuonPrepRawData objects.
Definition: MuonPrepDataCollection.h:46
TrigL2MuonSA::StgcHitData::stationPhi
int stationPhi
Definition: StgcData.h:37
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrigL2MuonSA::StgcHitData::stationName
int stationName
Definition: StgcData.h:38
TrigL2MuonSA::StgcHitData::ResidualPhi
double ResidualPhi
Definition: StgcData.h:40
TrigL2MuonSA::StgcHitData::ResidualR
double ResidualR
Definition: StgcData.h:39
IdentifiableContainerMT::indexFindPtr
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,...
Definition: IdentifiableContainerMT.h:289
TrigL2MuonSA::StgcHitData::layerNumber
unsigned int layerNumber
Definition: StgcData.h:42
TrigL2MuonSA::StgcDataPreparator::prepareData
StatusCode prepareData(const TrigRoiDescriptor *p_roids, TrigL2MuonSA::StgcHits &stgcHits) const
Definition: StgcDataPreparator.cxx:31
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigL2MuonSA::StgcHits
std::vector< StgcHitData > StgcHits
Definition: StgcData.h:49
TrigL2MuonSA::StgcHitData::z
double z
Definition: StgcData.h:35
TrigL2MuonSA::StgcHitData::eta
double eta
Definition: StgcData.h:29
AthAlgTool
Definition: AthAlgTool.h:26
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
Muon::sTgcPrepData
Class to represent sTgc measurements.
Definition: sTgcPrepData.h:20