ATLAS Offline Software
TRT_CablingSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //
6 // Implementation file for TRT_CablingSvc class
7 //
8 
9 //#include <iostream>
10 #include "TRT_CablingSvc.h"
11 //#include <fstream>
12 
13 #include "eformat/SourceIdentifier.h" // change to new eformat v3
15  // Tool
16 #include "GaudiKernel/IToolSvc.h"
17 
18 
19 using eformat::helper::SourceIdentifier;
20 
21 
22  // Constructor
23 TRT_CablingSvc::TRT_CablingSvc( const std::string& name,
24  ISvcLocator * pSvcLocator)
25  : base_class( name, pSvcLocator ),
26  m_manager ( nullptr ),
27  m_idHelper ( nullptr ),
28  m_cabling ( nullptr ),
29  m_cablingTool_SR1_ECC ( nullptr ),
30  m_cablingTool_SR1 ( nullptr ),
31  m_cablingTool_TB ( nullptr ),
32  m_cablingTool_DC1 ( nullptr ),
33  m_cablingTool_DC2 ( nullptr ),
34  m_cablingTool_DC3 ( nullptr ),
35  m_TRTLayout ( 0 ),
36  m_numberOfStrawsInROD ( 0 ),
37  m_numberOfStrawsInBarrelROD ( 0 ),
38  m_shiftForLeftEndCapStraws ( 0 ),
39  m_shiftForLeftBarrelStraws ( 0 ),
40  m_shiftForRightBarrelStraws ( 0 ),
41  m_shiftForRightEndCapStraws ( 0 )
42 {
43  // declareInterface< ITRT_CablingSvc >( this );
44 }
45 
46  // Destructor
48 {}
49 
50 
51 
52  // Initialisation
54 {
55  StatusCode sc;
56  ATH_MSG_INFO( "TRT_CablingSvc::initialize" );
57 
58  // Retrieve Detector Store
59  ServiceHandle<StoreGateSvc> detStore("DetectorStore",name());
60  if (detStore.retrieve().isFailure())
61  {
62  ATH_MSG_FATAL( "Detector service not found !" );
63  return StatusCode::FAILURE;
64  }
65 
66 
67  // Retrieve detector manager
68  sc = detStore->retrieve(m_manager,"TRT");
69  if (sc.isFailure()) {
70  ATH_MSG_FATAL( "Cannot retrieve TRT_DetectorManager!" );
71  return StatusCode::FAILURE;
72  }
73 
74  // Get the TRT Helper
75  if (detStore->retrieve(m_idHelper, "TRT_ID").isFailure())
76  {
77  ATH_MSG_FATAL( "Could not get TRT ID helper" );
78  return StatusCode::FAILURE;
79  }
81 
82  // Get ToolSvc
83  SmartIF<IToolSvc> toolSvc{service("ToolSvc")};
84  ATH_CHECK( toolSvc.isValid() );
85 
86  // Get tool for filling of cabling data
87  std::string toolType;
88  if (m_manager->getLayout()=="TestBeam")
89  {
90  m_TRTLayout = 1;
91  toolType = "TRT_FillCablingData_TB04";
92  ATH_MSG_INFO( "TRT TB04 Cabling" );
93  if(StatusCode::SUCCESS !=toolSvc->retrieveTool(toolType,m_cablingTool_TB))
94  {
95  ATH_MSG_ERROR( " Can't get TRT_FillCablingData_TB04 tool " );
96  return StatusCode::FAILURE;
97  }
99  }
100  // DC1
101  else if ((m_manager->getLayout() == "Initial") ||
102  (m_manager->getLayout() == "Final") )
103  {
104  m_TRTLayout = 6;
105  toolType = "TRT_FillCablingData_DC3";
106  ATH_MSG_INFO( "TRT DC3 Cabling" );
107  if( StatusCode::SUCCESS !=
108  toolSvc->retrieveTool(toolType,m_cablingTool_DC3) )
109  {
110  ATH_MSG_ERROR( " Can't get TRT_FillCablingData_DC3 tool " );
111  return StatusCode::FAILURE;
112  }
113 
115 
116  }
117  else if ( m_manager->getLayout()=="SR1" ) // SR1 Barrel cosmics layout
118  {
119  m_TRTLayout = 4;
120  toolType = "TRT_FillCablingData_SR1";
121  ATH_MSG_INFO( "TRT SR1 Cabling" );
122  if(StatusCode::SUCCESS !=toolSvc->retrieveTool(toolType,m_cablingTool_SR1))
123  {
124  ATH_MSG_ERROR( " Can't get TRT_FillCablingData_SR1 tool " );
125  return StatusCode::FAILURE;
126  }
127 
129  }
130  else if ( m_manager->getLayout()=="SR1-EndcapC" ) // SR1 EC C cosmics layout
131  {
132  m_TRTLayout = 5;
133  toolType = "TRT_FillCablingData_SR1_ECC";
134  ATH_MSG_INFO( "TRT SR1 Cabling" );
135  if( StatusCode::SUCCESS !=
136  toolSvc->retrieveTool(toolType,m_cablingTool_SR1_ECC) )
137  {
138  ATH_MSG_ERROR( " Can't get TRT_FillCablingData_SR1_ECC tool " );
139  return StatusCode::FAILURE;
140  }
141 
143  }
144  else
145  {
146  ATH_MSG_FATAL( " Layout is not defined for TRT_FillCablingData (" << m_manager->getLayout() << ")! " );
147  return StatusCode::FAILURE;
148  }
149 
150  ATH_MSG_INFO( "TRT_CablingSvc::initializiation finished" );
151 
152  return sc;
153 }
154 
155 
156 std::vector<uint32_t> TRT_CablingSvc::getRobID(Identifier& id) const
157 {
158 
159  // TB Case
160  if (m_TRTLayout == 1)
161  {
162  return m_cablingTool_TB->getRobID(id);
163  }
164  // DC1 Case
165  else if (m_TRTLayout == 2)
166  {
167  return m_cablingTool_DC1->getRobID(id);
168  }
169  // DC2
170  else if ( m_TRTLayout == 3 )
171  {
172  return m_cablingTool_DC2->getRobID(id);
173  }
174  // SR1 Barrel
175  else if ( m_TRTLayout == 4 )
176  {
177  return m_cablingTool_SR1->getRobID( id );
178  }
179  // SR1 EC C
180  else if ( m_TRTLayout == 5 )
181  {
182  return m_cablingTool_SR1_ECC->getRobID( id );
183  }
184  // DC3
185  else if ( m_TRTLayout == 6 )
186  {
187  return m_cablingTool_DC3->getRobID(id);
188  }
189  else
190  {
191  // std::vector<uint32_t> *vint = new std::vector<uint32_t>;
192  // return *vint;
193 
194  std::vector<uint32_t> v;
195  return v;
196  }
197 }
198 
199 Identifier TRT_CablingSvc::getIdentifier(const eformat::SubDetector&
200  subdetector,const unsigned& rod, const int& bufferOffset,
201  IdentifierHash& hashId) const
202 {
203  int intRod = (int) rod;
204  int shift;
205 
206  // TB04, SR1 or DC3 Case
207  if ( m_TRTLayout == 1 || m_TRTLayout == 4 || m_TRTLayout == 5 || m_TRTLayout == 6 )
208  {
209  hashId = m_cabling->get_identifierHashForAllStraws(intRod, bufferOffset);
210  return m_cabling->get_identifierForAllStraws(intRod, bufferOffset);
211  }
212 
213  // DC1, DC2 Case
214  int straw = bufferOffset;
215  if (subdetector == eformat::TRT_ENDCAP_A_SIDE)
216  {
218  intRod * m_numberOfStrawsInROD + straw;
219  hashId = m_cabling->get_identifierHashForAllStraws(shift);
220  return m_cabling->get_identifierForAllStraws(shift);
221  }
222 
223  if (subdetector == eformat::TRT_BARREL_A_SIDE)
224  {
225  shift = m_shiftForLeftBarrelStraws +
227  hashId = m_cabling->get_identifierHashForAllStraws(shift);
228  return m_cabling->get_identifierForAllStraws(shift);
229  }
230 
231  if (subdetector == eformat::TRT_BARREL_C_SIDE)
232  {
235  hashId = m_cabling->get_identifierHashForAllStraws(shift);
236  return m_cabling->get_identifierForAllStraws(shift);
237  }
238 
240  intRod * m_numberOfStrawsInROD + straw;
241  hashId = m_cabling->get_identifierHashForAllStraws(shift);
242  return m_cabling->get_identifierForAllStraws(shift);
243 
244 }
245 
246 
247 
248 /*
249  * getBufferOffset( strawId ) -
250  * get Offset into ROD buffer given straw Identifier StrawId.
251  *
252  */
254 {
255 
256  // DC3 Case
257  if ( m_TRTLayout == 6 )
258  {
259  return m_cabling->get_BufferOffset( StrawId );
260  }
261  else
262  {
263  ATH_MSG_FATAL( "TRT_CablingSvc::getBufferOffset called in invalid case !" );
264  assert(0);
265  }
266 
267  return 0;
268 }
269 
270 
271 const std::vector<uint32_t>& TRT_CablingSvc::getAllRods() const
272 {
273  return m_cabling->get_allRods();
274 }
275 
276 
277 
278 #ifdef DEPRECATED
279 uint32_t TRT_CablingSvc::getRodID(Identifier& id) const
280 {
281  // DC1 Case
282  if (m_TRTLayout == 2)
283  {
284  return m_cablingTool_DC1->getRodID(id);
285  }
286  // DC2 Case
287  else
288  return m_cablingTool_DC2->getRodID(id);
289 }
290 
291 void TRT_CablingSvc::getStrawRodID(Identifier& id, uint32_t& rod_id,
292  uint32_t& straw_number) const
293 {
294  // DC1 Case
295  if (m_TRTLayout == 2)
296  {
297  m_cablingTool_DC1->getStrawRodID(id, rod_id, straw_number);
298  }
299  // DC2 Case
300  else
301  m_cablingTool_DC2->getStrawRodID(id, rod_id, straw_number);
302 }
303 
304 
305 
306 const std::vector<IdentifierHash>&
307  TRT_CablingSvc::getCollID(uint32_t rob_id)
308 {
309  return m_cabling->get_collID( rob_id );
310 }
311 
312 int TRT_CablingSvc::getNumStrawInROD(uint32_t /*rod_id*/) const //remove unused variable to avoid compiler warning
313 {
314  return m_numberOfStrawsInROD;
315 }
316 
317 
318 void TRT_CablingSvc::set_parameters()
319 {
320  int numberOfStrawsInROD;
321  int numberOfStrawsInBarrelROD;
322  int shiftForLeftEndCapStraws;
323  int shiftForLeftBarrelStraws;
324  int shiftForRightBarrelStraws;
325  int shiftForRightEndCapStraws;
326  int numberOfEndCapPhiSectors;
327  int numberOfIdentifierSectors;
328 
329  // DC1 Case
330  if (m_TRTLayout == 2)
331  {
332  m_cablingTool_DC1->get_parameters(numberOfStrawsInROD,
333  numberOfStrawsInBarrelROD,
334  shiftForLeftEndCapStraws,
335  shiftForLeftBarrelStraws,
336  shiftForRightBarrelStraws,
337  shiftForRightEndCapStraws,
338  numberOfEndCapPhiSectors,
339  numberOfIdentifierSectors);
340  }
341  // DC2 Case
342  else
343  {
344  m_cablingTool_DC2->get_parameters(numberOfStrawsInROD,
345  numberOfStrawsInBarrelROD,
346  shiftForLeftEndCapStraws,
347  shiftForLeftBarrelStraws,
348  shiftForRightBarrelStraws,
349  shiftForRightEndCapStraws,
350  numberOfEndCapPhiSectors,
351  numberOfIdentifierSectors);
352  }
353 
354  m_numberOfStrawsInROD = numberOfStrawsInROD;
355  m_numberOfStrawsInBarrelROD = numberOfStrawsInBarrelROD;
356  m_shiftForLeftEndCapStraws = shiftForLeftEndCapStraws;
357  m_shiftForLeftBarrelStraws = shiftForLeftBarrelStraws;
358  m_shiftForRightBarrelStraws = shiftForRightBarrelStraws;
359  m_shiftForRightEndCapStraws = shiftForRightEndCapStraws;
360  m_numberOfEndCapPhiSectors = numberOfEndCapPhiSectors;
361  m_numberOfIdentifierSectors = numberOfIdentifierSectors;
362 
363 }
364 #endif // DEPRACATED
TRT_CablingSvc::m_cablingTool_SR1
TRT_FillCablingData_SR1 * m_cablingTool_SR1
Definition: TRT_CablingSvc.h:72
TRT_FillCablingData_TB04::fillData
TRT_CablingData * fillData()
Definition: TRT_FillCablingData_TB04.cxx:100
TRT_FillCablingData_DC3::fillData
TRT_CablingData * fillData()
Definition: TRT_FillCablingData_DC3.cxx:135
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
TRT::Hit::straw
@ straw
Definition: HitInfo.h:82
TRT_CablingSvc::m_numberOfStrawsInROD
int m_numberOfStrawsInROD
Definition: TRT_CablingSvc.h:80
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
TRT_CablingSvc::m_shiftForLeftBarrelStraws
int m_shiftForLeftBarrelStraws
Definition: TRT_CablingSvc.h:83
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TRT_CablingSvc::~TRT_CablingSvc
virtual ~TRT_CablingSvc()
Definition: TRT_CablingSvc.cxx:47
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
TRT_CablingSvc::m_cablingTool_SR1_ECC
TRT_FillCablingData_SR1_ECC * m_cablingTool_SR1_ECC
Definition: TRT_CablingSvc.h:71
TRT_FillCablingData_TB04::getRobID
std::vector< uint32_t > getRobID(Identifier id) const
Definition: TRT_FillCablingData_TB04.cxx:407
TRT_CablingSvc::m_manager
const InDetDD::TRT_DetectorManager * m_manager
Definition: TRT_CablingSvc.h:66
TRT_CablingSvc::getAllRods
const std::vector< uint32_t > & getAllRods() const
Definition: TRT_CablingSvc.cxx:271
TRT_CablingData::get_allRods
const std::vector< uint32_t > & get_allRods() const
Definition: TRT_CablingData.cxx:187
TRT_FillCablingData_DC2::getStrawRodID
void getStrawRodID(Identifier &id, uint32_t &rod_id, uint32_t &straw_number) const
Definition: TRT_FillCablingData_DC2.cxx:904
TRT_CablingSvc::m_cablingTool_DC3
TRT_FillCablingData_DC3 * m_cablingTool_DC3
Definition: TRT_CablingSvc.h:76
TRT_FillCablingData_SR1::getRobID
std::vector< uint32_t > getRobID(Identifier id) const
Definition: TRT_FillCablingData_SR1.cxx:987
TRT_CablingData::get_collID
const std::vector< IdentifierHash > & get_collID(int shift)
Definition: TRT_CablingData.cxx:175
TRT_CablingSvc::getRobID
std::vector< uint32_t > getRobID(Identifier &id) const
Definition: TRT_CablingSvc.cxx:156
TRT_CablingSvc::m_cablingTool_DC2
TRT_FillCablingData_DC2 * m_cablingTool_DC2
Definition: TRT_CablingSvc.h:75
TRT_FillCablingData_DC3::getRobID
std::vector< uint32_t > getRobID(Identifier id) const
Definition: TRT_FillCablingData_DC3.cxx:1980
TRT_FillCablingData_DC2::get_parameters
void get_parameters(int &numberOfStrawsInROD, int &numberOfStrawsInBarrelROD, int &shiftForLeftEndCapStraws, int &shiftForLeftBarrelStraws, int &shiftForRightBarrelStraws, int &shiftForRightEndCapStraws, int &numberOfEndCapPhiSectors, int &numberOfIdentifierSectors)
Definition: TRT_FillCablingData_DC2.cxx:993
TRT_CablingSvc::TRT_CablingSvc
TRT_CablingSvc(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TRT_CablingSvc.cxx:23
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
TRT_FillCablingData_DC1::getRodID
uint32_t getRodID(Identifier &id) const
Definition: TRT_FillCablingData_DC1.cxx:841
TRT_CablingData::get_identifierHashForAllStraws
IdentifierHash get_identifierHashForAllStraws(int rod, int bufferPosition) const
Definition: TRT_CablingData.cxx:127
TRT_CablingSvc::getIdentifier
Identifier getIdentifier(const eformat::SubDetector &subdetector, const unsigned &rod, const int &bufferOffset, IdentifierHash &hashId) const
Definition: TRT_CablingSvc.cxx:199
TRT_CablingData::get_BufferOffset
uint32_t get_BufferOffset(Identifier StrawId)
Definition: TRT_CablingData.cxx:146
TRT_FillCablingData_SR1::fillData
TRT_CablingData * fillData()
Definition: TRT_FillCablingData_SR1.cxx:96
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TRT_FillCablingData_DC1::getStrawRodID
void getStrawRodID(Identifier &id, uint32_t &rod_id, uint32_t &straw_number) const
Definition: TRT_FillCablingData_DC1.cxx:902
TRT_ID::straw_layer_context
IdContext straw_layer_context(void) const
straw_layer id
Definition: TRT_ID.h:713
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
InDetDD::InDetDetectorManager::getLayout
const std::string & getLayout() const
Definition: InDetDetectorManager.cxx:38
TRT_CablingSvc.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TRT_CablingSvc::m_shiftForRightEndCapStraws
int m_shiftForRightEndCapStraws
Definition: TRT_CablingSvc.h:85
RunTileMonitoring.rod
rod
Definition: RunTileMonitoring.py:134
TRT_FillCablingData_DC2::getRodID
uint32_t getRodID(Identifier &id) const
Definition: TRT_FillCablingData_DC2.cxx:844
TRT_CablingSvc::m_cablingTool_TB
TRT_FillCablingData_TB04 * m_cablingTool_TB
Definition: TRT_CablingSvc.h:73
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TRT_CablingSvc::getBufferOffset
uint32_t getBufferOffset(const Identifier &StrawId)
Definition: TRT_CablingSvc.cxx:253
TRT_CablingSvc::m_cabling
TRT_CablingData * m_cabling
Definition: TRT_CablingSvc.h:69
TRT_CablingData::get_identifierForAllStraws
Identifier get_identifierForAllStraws(int rod, int bufferPosition) const
Definition: TRT_CablingData.cxx:120
python.PyAthena.v
v
Definition: PyAthena.py:154
TRT_FillCablingData_DC2::getRobID
std::vector< uint32_t > getRobID(Identifier &id) const
Definition: TRT_FillCablingData_DC2.cxx:788
TRT_CablingSvc::m_cntx
IdContext m_cntx
Definition: TRT_CablingSvc.h:68
TRT_CablingSvc::m_numberOfStrawsInBarrelROD
int m_numberOfStrawsInBarrelROD
Definition: TRT_CablingSvc.h:81
TRT_FillCablingData_SR1_ECC::fillData
TRT_CablingData * fillData()
Definition: TRT_FillCablingData_SR1_ECC.cxx:101
TRT_CablingSvc::m_cablingTool_DC1
TRT_FillCablingData_DC1 * m_cablingTool_DC1
Definition: TRT_CablingSvc.h:74
TRT_FillCablingData_DC1::get_parameters
void get_parameters(int &numberOfStrawsInROD, int &numberOfStrawsInBarrelROD, int &shiftForLeftEndCapStraws, int &shiftForLeftBarrelStraws, int &shiftForRightBarrelStraws, int &shiftForRightEndCapStraws, int &numberOfEndCapPhiSectors, int &numberOfIdentifierSectors)
Definition: TRT_FillCablingData_DC1.cxx:991
TRT_CablingSvc::m_TRTLayout
int m_TRTLayout
Definition: TRT_CablingSvc.h:77
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
TRT_CablingSvc::m_shiftForRightBarrelStraws
int m_shiftForRightBarrelStraws
Definition: TRT_CablingSvc.h:84
TRT_FillCablingData_SR1_ECC::getRobID
std::vector< uint32_t > getRobID(Identifier id) const
Definition: TRT_FillCablingData_SR1_ECC.cxx:1103
TRT_CablingSvc::m_shiftForLeftEndCapStraws
int m_shiftForLeftEndCapStraws
Definition: TRT_CablingSvc.h:82
TRT_FillCablingData_DC1::getRobID
std::vector< uint32_t > getRobID(Identifier &id) const
Definition: TRT_FillCablingData_DC1.cxx:786
TRT_CablingSvc::initialize
virtual StatusCode initialize()
Definition: TRT_CablingSvc.cxx:53
ServiceHandle< StoreGateSvc >
TRT_CablingSvc::m_idHelper
const TRT_ID * m_idHelper
Definition: TRT_CablingSvc.h:67
Identifier
Definition: IdentifierFieldParser.cxx:14