ATLAS Offline Software
MmDataPreparator.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 "MmDataPreparator.h"
6 
8  const std::string& name,
9  const IInterface* parent):
11  m_regionSelector("RegSelTool/RegSelTool_MM",this)
12 {
13  declareProperty("RegSel_MM", 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_mmPrepContainerKey.initialize(!m_mmPrepContainerKey.empty()));
27 
28  return StatusCode::SUCCESS;
29 }
30 
32  TrigL2MuonSA::MmHits& mmHits) const
33 {
34 
35  ATH_MSG_DEBUG("MmDataPreparator::prepareData() was called.");
36 
37  mmHits.clear();
38 
39  std::vector<const Muon::MMPrepDataCollection*> mmCols;
40  std::vector<IdentifierHash> mmHashList;
41  std::vector<IdentifierHash> mmHashList_cache;
42 
43  // Get MM container
44  if(m_mmPrepContainerKey.empty()) {
45  ATH_MSG_INFO("no mmPrepContainerKey");
46  return StatusCode::SUCCESS;
47  }
48  auto mmPrepContainerHandle = SG::makeHandle(m_mmPrepContainerKey);
49  if (!mmPrepContainerHandle.isValid()) {
50  ATH_MSG_ERROR("Cannot retrieve MM PRD Container key: " << m_mmPrepContainerKey.key());
51  return StatusCode::FAILURE;
52  } else {
53  ATH_MSG_DEBUG("MM PRD Container retrieved with key: " << m_mmPrepContainerKey.key());
54  }
55  const Muon::MMPrepDataContainer* mmPrds = mmPrepContainerHandle.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, mmHashList);
63  else {
64  TrigRoiDescriptor fullscan_roi( true );
65  m_regionSelector->lookup( Gaudi::Hive::currentContext() )->HashIDList(fullscan_roi, mmHashList);
66  }
67  ATH_MSG_DEBUG("mmHashList.size()=" << mmHashList.size());
68 
69  std::vector<uint32_t> mmRobList;
70  m_regionSelector->lookup( Gaudi::Hive::currentContext() )->ROBIDList(*iroi, mmRobList);
71 
72  if (!mmHashList.empty()) {
73 
74  // Get MM collections
75  for(const IdentifierHash& id : mmHashList) {
76 
77  const auto* MMcoll = mmPrds->indexFindPtr(id);
78 
79  if( MMcoll == nullptr ) {
80  continue;
81  }
82 
83  if( MMcoll->size() == 0) {
84  ATH_MSG_DEBUG("Empty MM list");
85  continue;
86  }
87 
88  mmHashList_cache.push_back(id);
89  mmCols.push_back(MMcoll);
90  }
91  }
92 
93  }
94  else {
95  ATH_MSG_DEBUG("Use full data access");
96 
97  // Get MM collections
98  for(const auto mmcoll : *mmPrds) {
99  mmCols.push_back(mmcoll);
100  }
101 
102  }
103 
104 
105  for( const Muon::MMPrepDataCollection* mm : mmCols ){
106 
107  mmHits.reserve( mmHits.size() + mm->size() );
108  for( const Muon::MMPrepData* prd : *mm ) {
109 
110  // save MM hit data in MmHitData
111  TrigL2MuonSA::MmHitData lutDigit;
112 
113  lutDigit.eta = prd->globalPosition().eta();
114  lutDigit.phi = prd->globalPosition().phi();
115  lutDigit.r = prd->globalPosition().perp();
116  lutDigit.z = prd->globalPosition().z();
117  lutDigit.stationEta = m_idHelperSvc->mmIdHelper().stationEta(prd->identify());
118  lutDigit.stationPhi = m_idHelperSvc->mmIdHelper().stationPhi(prd->identify());
119  lutDigit.stationName = m_idHelperSvc->mmIdHelper().stationName(prd->identify());
120  lutDigit.ResidualR = 999;
121  lutDigit.ResidualPhi = 999;
122  lutDigit.isOutlier = 0;
123  lutDigit.layerNumber = m_idHelperSvc->mmIdHelper().gasGap(prd->identify())-1 + 4*(m_idHelperSvc->mmIdHelper().multilayer(prd->identify())-1);
124  mmHits.push_back(lutDigit);
125 
126  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);
127 
128  }
129  }
130 
131  return StatusCode::SUCCESS;
132 
133 }
Muon::MuonPrepDataContainer
Template for Muon PRD containers (which are basically collections of MuonPrepDataCollections).
Definition: MuonPrepDataContainer.h:42
Muon::MMPrepData
Class to represent MM measurements.
Definition: MMPrepData.h:22
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TrigL2MuonSA::MmHitData::isOutlier
int isOutlier
Definition: MmData.h:40
TrigL2MuonSA::MmHitData::layerNumber
unsigned int layerNumber
Definition: MmData.h:41
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TrigL2MuonSA::MmHitData::eta
double eta
Definition: MmData.h:28
TrigL2MuonSA::MmHitData::phi
double phi
Definition: MmData.h:32
TrigL2MuonSA::MmHitData::stationName
int stationName
Definition: MmData.h:37
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
TrigL2MuonSA::MmHitData::ResidualR
double ResidualR
Definition: MmData.h:38
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
TrigL2MuonSA::MmHitData::ResidualPhi
double ResidualPhi
Definition: MmData.h:39
TrigL2MuonSA::MmDataPreparator::MmDataPreparator
MmDataPreparator(const std::string &type, const std::string &name, const IInterface *parent)
Definition: MmDataPreparator.cxx:7
TrigL2MuonSA::MmHitData::r
double r
Definition: MmData.h:33
TrigL2MuonSA::MmDataPreparator::prepareData
StatusCode prepareData(const TrigRoiDescriptor *p_roids, TrigL2MuonSA::MmHits &mmHits) const
Definition: MmDataPreparator.cxx:31
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TrigL2MuonSA::MmHitData::stationPhi
int stationPhi
Definition: MmData.h:36
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
MmDataPreparator.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Muon::MuonPrepDataCollection
Template to hold collections of MuonPrepRawData objects.
Definition: MuonPrepDataCollection.h:46
TrigL2MuonSA::MmDataPreparator::m_regionSelector
ToolHandle< IRegSelTool > m_regionSelector
Definition: MmDataPreparator.h:34
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrigL2MuonSA::MmHitData
Definition: MmData.h:14
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
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::MmHits
std::vector< MmHitData > MmHits
Definition: MmData.h:47
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigL2MuonSA::MmDataPreparator::initialize
virtual StatusCode initialize() override
Definition: MmDataPreparator.cxx:16
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
TrigL2MuonSA::MmHitData::z
double z
Definition: MmData.h:34
TrigL2MuonSA::MmHitData::stationEta
int stationEta
Definition: MmData.h:35