ATLAS Offline Software
TrigT1RPCRecRoiTool.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 "TrigT1RPCRecRoiTool.h"
7 #include <fstream>
8 
9 namespace LVL1 {
10  TrigT1RPCRecRoiTool::TrigT1RPCRecRoiTool( const std::string& type, const std::string& name, const IInterface* parent) :
11  base_class(type,name,parent) {
12  }
13 
16  ATH_CHECK(m_idHelperSvc.retrieve() );
18  if(m_useRun3Config){
19  ATH_MSG_INFO("update to Run 3 bit mask");
20  updateBitMask( Run3 );
21  }
22  return StatusCode::SUCCESS;
23  }
24 
26  {
27 
28  // subsystem ID and sector ID
29  data.set_side( getBitMaskValue(&roiWord,SubSysIDMask()) );
30  data.set_sector( getBitMaskValue(&roiWord,BarrelSectorIDMask()) );
31  // RoI
32  data.set_roi( getBitMaskValue(&roiWord,BarrelRoIMask()) );
33 
34  // Get the strips delimiting the RoIs from rPCcablingSvc
35  Identifier EtaLowBorder_id;
36  Identifier EtaHighBorder_id;
37  Identifier PhiLowBorder_id;
38  Identifier PhiHighBorder_id;
39 
40  Amg::Vector3D EtaLowBorder_pos(0.,0.,0.);
41  Amg::Vector3D EtaHighBorder_pos(0.,0.,0.);
42  Amg::Vector3D PhiLowBorder_pos(0.,0.,0.);
43  Amg::Vector3D PhiHighBorder_pos(0.,0.,0.);
44 
46  const RpcCablingCondData* rpcCab{*rpcReadHandle};
47  if (rpcCab==nullptr){
48  ATH_MSG_ERROR("Null pointer to the read RpcCablingCondData conditions object.");
49  return StatusCode::FAILURE;
50  }
51 
52  if(rpcCab->give_RoI_borders_id(data.side(), data.sector(), data.roi(),
53  EtaLowBorder_id, EtaHighBorder_id,
54  PhiLowBorder_id, PhiHighBorder_id, &m_idHelperSvc->rpcIdHelper()))
55  {
56 
58  const MuonGM::MuonDetectorManager* muonMgr = DetectorManagerHandle.cptr();
59  if(muonMgr==nullptr){
60  ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object.");
61  return StatusCode::FAILURE;
62  }
63 
64 
65  const MuonGM::RpcReadoutElement* EtaLowBorder_descriptor =
66  muonMgr->getRpcReadoutElement(EtaLowBorder_id);
67  EtaLowBorder_pos = EtaLowBorder_descriptor->stripPos(EtaLowBorder_id);
68 
69  const MuonGM::RpcReadoutElement* EtaHighBorder_descriptor =
70  muonMgr->getRpcReadoutElement(EtaHighBorder_id);
71  EtaHighBorder_pos = EtaHighBorder_descriptor->stripPos(EtaHighBorder_id);
72 
73  const MuonGM::RpcReadoutElement* PhiLowBorder_descriptor =
74  muonMgr->getRpcReadoutElement(PhiLowBorder_id);
75  PhiLowBorder_pos = PhiLowBorder_descriptor->stripPos(PhiLowBorder_id);
76 
77  const MuonGM::RpcReadoutElement* PhiHighBorder_descriptor =
78  muonMgr->getRpcReadoutElement(PhiHighBorder_id);
79  PhiHighBorder_pos = PhiHighBorder_descriptor->stripPos(PhiHighBorder_id);
80 
81  data.set_etaMin( EtaLowBorder_pos.eta() );
82  data.set_etaMax( EtaHighBorder_pos.eta() );
83  data.set_eta( (data.etaMin()+data.etaMax())/2. );
84 
85  data.set_phiMin( PhiLowBorder_pos.phi() );
86  data.set_phiMax( PhiHighBorder_pos.phi() );
87  data.set_phi( (data.phiMin()+data.phiMax())/2. );
88 
89  data.update();
90 
91  }
92  return StatusCode::SUCCESS;
93  }
95  double & etaMin_LowHigh, double & etaMax_LowHigh,
96  double & phiMin_LowHigh, double & phiMax_LowHigh) const
97  {
98  double etaMin_Low=0;
99  double etaMin_High=0;
100  double etaMax_Low=0;
101  double etaMax_High=0;
102 
105  phiMin_LowHigh=data.phiMin();
106  phiMax_LowHigh=data.phiMax();
107 
108  bool low = etaDimLow(data,etaMin_Low,etaMax_Low);
109  bool high = etaDimHigh(data,etaMin_High,etaMax_High);
110 
111  if (low&&high) {
112  etaMin_LowHigh=std::min(etaMin_Low,etaMin_High);
113  etaMax_LowHigh=std::max(etaMax_Low,etaMax_High);
114  } else if (low) {
115  etaMin_LowHigh =std::min(etaMin_Low,data.etaMin());
116  etaMax_LowHigh =std::max(etaMax_Low,data.etaMax());
117  } else if (high) {
118  etaMin_LowHigh =std::min(etaMin_High,data.etaMin());
119  etaMax_LowHigh =std::max(etaMax_High,data.etaMax());
120  } else {
121  etaMin_LowHigh = data.etaMin();
122  etaMax_LowHigh = data.etaMax();
123  }
124  return StatusCode::SUCCESS;
125  }
126 
127  bool TrigT1RPCRecRoiTool::dumpRoiMap(const std::string& filename) const
128  {
129  const unsigned int maxSubsystem = 2;
130  const unsigned int maxLogicSector = 32;
131  const unsigned int maxRoI = 32;
132 
133  std::ofstream roi_map;
134  roi_map.open(filename.c_str(), std::ios::out );
135  if(!roi_map){
136  ATH_MSG_WARNING( "Unable to open ROI_Mapping file!" );
137  } else {
138  roi_map <<"# side sector roi etaMin etaMax phiMin phiMax etaMinLow etaMaxLow etaMinHigh etaMaxHigh "<< std::endl;
139  roi_map <<"# ------------------------------------------------------------------------------------------------------------------------------ "<< std::endl;
140  for(unsigned int side=0;side < maxSubsystem; side++){
141  for(unsigned int sector=0;sector < maxLogicSector; sector++){
142  for (unsigned int roi=0; roi<maxRoI; roi++){
143  unsigned long int roIWord = (m_useRun3Config) ? (roi+(side<<21)+(sector<<22)) : ((roi<<2)+(side<<14)+(sector<<15));
145  if(!roiData(roIWord,data).isSuccess())continue;
146  double etaMinLow(0),etaMaxLow(0),etaMinHigh(0),etaMaxHigh(0);
147  etaDimLow (data,etaMinLow, etaMaxLow);
148  etaDimHigh(data,etaMinHigh,etaMaxHigh);
149  roi_map << std::setw(8) << side << " "
150  << std::setw(8) << sector << " "
151  << std::setw(8) << roi << " "
152  << std::setw(12) << data.etaMin() << " "
153  << std::setw(12) << data.etaMax() << " "
154  << std::setw(12) << data.phiMin() << " "
155  << std::setw(12) << data.phiMax() << " "
156  << std::setw(8) << etaMinLow << " "
157  << std::setw(8) << etaMaxLow << " "
158  << std::setw(8) << etaMinHigh << " "
159  << std::setw(8) << etaMaxHigh << std::endl;
160  }
161  }
162  }
163  roi_map.close();
164  }
165  return true;
166  }
167 
168 
170  double& etaMin, double& etaMax) const
171  {
172  // Get the strips delimiting the RoIs from rPCcablingSvc
173  Identifier EtaLowBorder_id;
174  Identifier EtaHighBorder_id;
175  Identifier PhiLowBorder_id;
176  Identifier PhiHighBorder_id;
177  Amg::Vector3D EtaLowBorder_pos(0.,0.,0.);
178  Amg::Vector3D EtaHighBorder_pos(0.,0.,0.);
179 
181  const RpcCablingCondData* rpcCab{*rpcReadHandle};
182  if (rpcCab==nullptr){
183  ATH_MSG_ERROR("Null pointer to the read RpcCablingCondData conditions object.");
184  return false;
185  }
186 
187  if(!rpcCab->give_LowPt_borders_id(data.side(), data.sector(), data.roi(),
188  EtaLowBorder_id, EtaHighBorder_id,
189  PhiLowBorder_id, PhiHighBorder_id,
190  &m_idHelperSvc->rpcIdHelper())) return false;
191 
192 
194  const MuonGM::MuonDetectorManager* muonMgr = DetectorManagerHandle.cptr();
195  if(muonMgr==nullptr){
196  ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object.");
197  return false;
198  }
199 
200 
201  const MuonGM::RpcReadoutElement* EtaLowBorder_descriptor =
202  muonMgr->getRpcReadoutElement(EtaLowBorder_id);
203  if(EtaLowBorder_descriptor==nullptr){
204  ATH_MSG_WARNING("Null pointer to the RpcReadoutElement object for EtaLowBorder.");
205  return false;
206  }
207  EtaLowBorder_pos = EtaLowBorder_descriptor->stripPos(EtaLowBorder_id);
208 
209  const MuonGM::RpcReadoutElement* EtaHighBorder_descriptor =
210  muonMgr->getRpcReadoutElement(EtaHighBorder_id);
211  if(EtaHighBorder_descriptor==nullptr){
212  ATH_MSG_WARNING("Null pointer to the RpcReadoutElement object for EtaHighBorder.");
213  return false;
214  }
215  EtaHighBorder_pos = EtaHighBorder_descriptor->stripPos(EtaHighBorder_id);
216 
217  etaMin=EtaLowBorder_pos.eta();
218  etaMax=EtaHighBorder_pos.eta();
219  if (etaMin>etaMax){
220  double tmp=etaMin;
221  etaMin=etaMax;
222  etaMax=tmp;
223  }
224  return true;
225  }
226 
228  double& etaMin, double& etaMax) const
229  {
230  // Get the strips delimiting the RoIs from rPCcablingSvc
231  Identifier EtaLowBorder_id;
232  Identifier EtaHighBorder_id;
233  Identifier PhiLowBorder_id;
234  Identifier PhiHighBorder_id;
235  Amg::Vector3D EtaLowBorder_pos(0.,0.,0.);
236  Amg::Vector3D EtaHighBorder_pos(0.,0.,0.);
237 
239  const RpcCablingCondData* rpcCab{*rpcReadHandle};
240  if (rpcCab==nullptr){
241  ATH_MSG_ERROR("Null pointer to the read RpcCablingCondData conditions object.");
242  return false;
243  }
244 
245  if(!rpcCab->give_HighPt_borders_id(data.side(), data.sector(), data.roi(),
246  EtaLowBorder_id, EtaHighBorder_id,
247  PhiLowBorder_id, PhiHighBorder_id,
248  &m_idHelperSvc->rpcIdHelper())) return false;
249 
251  const MuonGM::MuonDetectorManager* muonMgr = DetectorManagerHandle.cptr();
252  if(muonMgr==nullptr){
253  ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object.");
254  return false;
255  }
256 
257  const MuonGM::RpcReadoutElement* EtaLowBorder_descriptor =
258  muonMgr->getRpcReadoutElement(EtaLowBorder_id);
259  if(EtaLowBorder_descriptor==nullptr){
260  ATH_MSG_WARNING("Null pointer to the RpcReadoutElement object for EtaLowBorder.");
261  return false;
262  }
263  EtaLowBorder_pos = EtaLowBorder_descriptor->stripPos(EtaLowBorder_id);
264 
265  const MuonGM::RpcReadoutElement* EtaHighBorder_descriptor =
266  muonMgr->getRpcReadoutElement(EtaHighBorder_id);
267  if(EtaHighBorder_descriptor==nullptr){
268  ATH_MSG_WARNING("Null pointer to the RpcReadoutElement object for EtaHighBorder.");
269  return false;
270  }
271  EtaHighBorder_pos = EtaHighBorder_descriptor->stripPos(EtaHighBorder_id);
272 
273  etaMin=EtaLowBorder_pos.eta();
274  etaMax=EtaHighBorder_pos.eta();
275  if (etaMin>etaMax){
276  double tmp=etaMin;
277  etaMin=etaMax;
278  etaMax=tmp;
279  }
280  return true;
281  }
282 
283 
284 }
MuonGM::MuonDetectorManager::getRpcReadoutElement
const RpcReadoutElement * getRpcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:168
LVL1::TrigT1RPCRecRoiTool::etaDimHigh
bool etaDimHigh(const TrigT1MuonRecRoiData &data, double &etaMin, double &etaMax) const override
Definition: TrigT1RPCRecRoiTool.cxx:227
LVL1::TrigT1MuonRecRoiData
Definition: TrigT1MuonRecRoiData.h:10
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
max
#define max(a, b)
Definition: cfImp.cxx:41
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
xAOD::etaMax
etaMax
Definition: HIEventShape_v2.cxx:46
MuonGM::RpcReadoutElement
An RpcReadoutElement corresponds to a single RPC module; therefore typicaly a barrel muon station con...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/RpcReadoutElement.h:54
LVL1::SubSysIDMask
@ SubSysIDMask
Definition: RecMuonRoI.h:40
LVL1::TrigT1RPCRecRoiTool::etaDimLow
bool etaDimLow(const TrigT1MuonRecRoiData &data, double &etaMin, double &etaMax) const override
Definition: TrigT1RPCRecRoiTool.cxx:169
LVL1::TrigT1RPCRecRoiTool::dumpRoiMap
virtual bool dumpRoiMap(const std::string &filename) const override
Definition: TrigT1RPCRecRoiTool.cxx:127
LVL1::TrigT1RPCRecRoiTool::roiData
virtual StatusCode roiData(const unsigned int &roiWord, TrigT1MuonRecRoiData &data) const override
Definition: TrigT1RPCRecRoiTool.cxx:25
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
RpcCablingCondData
Definition: RpcCablingCondData.h:21
LVL1::BarrelRoIMask
@ BarrelRoIMask
Definition: RecMuonRoI.h:46
TRT::Hit::side
@ side
Definition: HitInfo.h:83
xAOD::roiWord
roiWord
Definition: TrigMissingET_v1.cxx:36
LVL1::TrigT1RPCRecRoiTool::m_useRun3Config
BooleanProperty m_useRun3Config
Definition: TrigT1RPCRecRoiTool.h:39
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LVL1::TrigT1RPCRecRoiTool::initialize
virtual StatusCode initialize() override
Definition: TrigT1RPCRecRoiTool.cxx:14
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
test_pyathena.parent
parent
Definition: test_pyathena.py:15
LVL1::TrigT1RPCRecRoiTool::m_rpcKey
SG::ReadCondHandleKey< RpcCablingCondData > m_rpcKey
Definition: TrigT1RPCRecRoiTool.h:43
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
TrigConf::name
Definition: HLTChainList.h:35
min
#define min(a, b)
Definition: cfImp.cxx:40
MuonGM::RpcReadoutElement::stripPos
Amg::Vector3D stripPos(const Identifier &id) const
Definition: MuonDetDescr/MuonReadoutGeometry/src/RpcReadoutElement.cxx:177
LVL1::TrigT1RPCRecRoiTool::RoIsize
virtual StatusCode RoIsize(const unsigned int &roiWord, double &etaMin, double &etaMax, double &phiMin, double &phiMax) const override
Definition: TrigT1RPCRecRoiTool.cxx:94
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
LVL1::TrigT1RPCRecRoiTool::TrigT1RPCRecRoiTool
TrigT1RPCRecRoiTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TrigT1RPCRecRoiTool.cxx:10
TrigT1RPCRecRoiTool.h
LVL1::TrigT1RPCRecRoiTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: TrigT1RPCRecRoiTool.h:41
LArCellBinning.etaMin
etaMin
Definition: LArCellBinning.py:84
LVL1::TrigT1RPCRecRoiTool::m_DetectorManagerKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
Definition: TrigT1RPCRecRoiTool.h:42
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:49
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
RpcReadoutElement.h