ATLAS Offline Software
Loading...
Searching...
No Matches
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
7#include <fstream>
8
9namespace LVL1 {
10 TrigT1RPCRecRoiTool::TrigT1RPCRecRoiTool( const std::string& type, const std::string& name, const IInterface* parent) :
11 base_class(type,name,parent) {
12 }
13
15 ATH_CHECK(m_DetectorManagerKey.initialize());
16 ATH_CHECK(m_idHelperSvc.retrieve() );
17 ATH_CHECK(m_rpcKey.initialize());
19 ATH_MSG_INFO("update to Run 3 bit mask");
20 updateBitMask( Run3 );
21 }
22 return StatusCode::SUCCESS;
23 }
24
25 StatusCode TrigT1RPCRecRoiTool::roiData( const unsigned int & roiWord, TrigT1MuonRecRoiData& data )const
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 }
94 StatusCode TrigT1RPCRecRoiTool::RoIsize(const unsigned int & roiWord,
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
104 ATH_CHECK( roiData(roiWord,data) );
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 if (!checkRPCId(EtaLowBorder_id, *muonMgr) || !checkRPCId(EtaHighBorder_id, *muonMgr)) {
201 return false;
202 }
203
204 const MuonGM::RpcReadoutElement* EtaLowBorder_descriptor =
205 muonMgr->getRpcReadoutElement(EtaLowBorder_id);
206 if(EtaLowBorder_descriptor==nullptr){
207 ATH_MSG_WARNING("Null pointer to the RpcReadoutElement object for EtaLowBorder.");
208 return false;
209 }
210 EtaLowBorder_pos = EtaLowBorder_descriptor->stripPos(EtaLowBorder_id);
211
212 const MuonGM::RpcReadoutElement* EtaHighBorder_descriptor =
213 muonMgr->getRpcReadoutElement(EtaHighBorder_id);
214 if(EtaHighBorder_descriptor==nullptr){
215 ATH_MSG_WARNING("Null pointer to the RpcReadoutElement object for EtaHighBorder.");
216 return false;
217 }
218 EtaHighBorder_pos = EtaHighBorder_descriptor->stripPos(EtaHighBorder_id);
219
220 etaMin=EtaLowBorder_pos.eta();
221 etaMax=EtaHighBorder_pos.eta();
222 if (etaMin>etaMax){
223 double tmp=etaMin;
224 etaMin=etaMax;
225 etaMax=tmp;
226 }
227 return true;
228 }
229
231 double& etaMin, double& etaMax) const
232 {
233 // Get the strips delimiting the RoIs from rPCcablingSvc
234 Identifier EtaLowBorder_id;
235 Identifier EtaHighBorder_id;
236 Identifier PhiLowBorder_id;
237 Identifier PhiHighBorder_id;
238 Amg::Vector3D EtaLowBorder_pos(0.,0.,0.);
239 Amg::Vector3D EtaHighBorder_pos(0.,0.,0.);
240
242 const RpcCablingCondData* rpcCab{*rpcReadHandle};
243 if (rpcCab==nullptr){
244 ATH_MSG_ERROR("Null pointer to the read RpcCablingCondData conditions object.");
245 return false;
246 }
247
248 if(!rpcCab->give_HighPt_borders_id(data.side(), data.sector(), data.roi(),
249 EtaLowBorder_id, EtaHighBorder_id,
250 PhiLowBorder_id, PhiHighBorder_id,
251 &m_idHelperSvc->rpcIdHelper())) return false;
252
254 const MuonGM::MuonDetectorManager* muonMgr = DetectorManagerHandle.cptr();
255 if(muonMgr==nullptr){
256 ATH_MSG_ERROR("Null pointer to the read MuonDetectorManager conditions object.");
257 return false;
258 }
259
260 if (!checkRPCId(EtaLowBorder_id, *muonMgr) || !checkRPCId(EtaHighBorder_id, *muonMgr)) {
261 return false;
262 }
263 const MuonGM::RpcReadoutElement* EtaLowBorder_descriptor =
264 muonMgr->getRpcReadoutElement(EtaLowBorder_id);
265 if(EtaLowBorder_descriptor==nullptr){
266 ATH_MSG_WARNING("Null pointer to the RpcReadoutElement object for EtaLowBorder.");
267 return false;
268 }
269 EtaLowBorder_pos = EtaLowBorder_descriptor->stripPos(EtaLowBorder_id);
270
271 const MuonGM::RpcReadoutElement* EtaHighBorder_descriptor =
272 muonMgr->getRpcReadoutElement(EtaHighBorder_id);
273 if(EtaHighBorder_descriptor==nullptr){
274 ATH_MSG_WARNING("Null pointer to the RpcReadoutElement object for EtaHighBorder.");
275 return false;
276 }
277 EtaHighBorder_pos = EtaHighBorder_descriptor->stripPos(EtaHighBorder_id);
278
279 etaMin=EtaLowBorder_pos.eta();
280 etaMax=EtaHighBorder_pos.eta();
281 if (etaMin>etaMax){
282 double tmp=etaMin;
283 etaMin=etaMax;
284 etaMax=tmp;
285 }
286 return true;
287 }
288
290{
291 const int detEleHash = static_cast<int>(m_idHelperSvc->detElementHash(id));
292 const int maxHash = static_cast<int>(muonMgr.nRpcRE());
293 if (detEleHash < 0 || detEleHash >= maxHash) {
294 ATH_MSG_WARNING("Legacy cabling produced invalid RPC id: "<<m_idHelperSvc->toString(id) << " with hash: " << detEleHash << ". Valid range is [0, " << maxHash-1 << "].");
295 return false;
296 }
297 const MuonGM::RpcReadoutElement* reEle = muonMgr.getRpcReadoutElement(id);
298 if (m_idHelperSvc->rpcIdHelper().doubletPhi(id) > reEle->NphiStripPanels()) {
299 ATH_MSG_WARNING("Legacy cabling produced invalid RPC id: "<<m_idHelperSvc->toString(id) << " , dbPhi out of range [1, " << reEle->NphiStripPanels() << "]:");
300 return false;
301 }
302 return true;
303};
304
305}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
virtual bool dumpRoiMap(const std::string &filename) const override
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
bool etaDimLow(const TrigT1MuonRecRoiData &data, double &etaMin, double &etaMax) const override
SG::ReadCondHandleKey< RpcCablingCondData > m_rpcKey
bool etaDimHigh(const TrigT1MuonRecRoiData &data, double &etaMin, double &etaMax) const override
virtual StatusCode RoIsize(const unsigned int &roiWord, double &etaMin, double &etaMax, double &phiMin, double &phiMax) const override
virtual StatusCode roiData(const unsigned int &roiWord, TrigT1MuonRecRoiData &data) const override
virtual StatusCode initialize() override
bool checkRPCId(const Identifier &id, const MuonGM::MuonDetectorManager &muonMgr) const
TrigT1RPCRecRoiTool(const std::string &type, const std::string &name, const IInterface *parent)
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const RpcReadoutElement * getRpcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
An RpcReadoutElement corresponds to a single RPC module; therefore typicaly a barrel muon station con...
int NphiStripPanels() const
returns the number of phi strip panels (1 or 2)
bool give_RoI_borders_id(unsigned short int SubsystemId, unsigned short int SectorId, unsigned short int RoIId, Identifier &EtaLowBorder_id, Identifier &EtaHighBorder_id, Identifier &PhiLowBorder_id, Identifier &PhiHighBorder_id, const RpcIdHelper *rpcId) const
bool give_HighPt_borders_id(unsigned short int SubsystemId, unsigned short int SectorId, unsigned short int RoIId, Identifier &EtaLowBorder_id, Identifier &EtaHighBorder_id, Identifier &PhiLowBorder_id, Identifier &PhiHighBorder_id, const RpcIdHelper *rpcId) const
bool give_LowPt_borders_id(unsigned short int SubsystemId, unsigned short int SectorId, unsigned short int RoIId, Identifier &EtaLowBorder_id, Identifier &EtaHighBorder_id, Identifier &PhiLowBorder_id, Identifier &PhiHighBorder_id, const RpcIdHelper *rpcId) const
const_pointer_type cptr()
Eigen::Matrix< double, 3, 1 > Vector3D
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
@ SubSysIDMask
Definition RecMuonRoI.h:40
@ BarrelRoIMask
Definition RecMuonRoI.h:46