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
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}
#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
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...
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