ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_CablingSvc.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5//
6// Implementation file for TRT_CablingSvc class
7//
8
9#include "TRT_CablingSvc.h"
10
11#include "eformat/SourceIdentifier.h" // change to new eformat v3
13 // Tool
14#include "GaudiKernel/IToolSvc.h"
15
16
17using eformat::helper::SourceIdentifier;
18
19// Constructor
20TRT_CablingSvc::TRT_CablingSvc( const std::string& name,
21 ISvcLocator * pSvcLocator)
22 : base_class( name, pSvcLocator )
23{
24}
25
26// Initialisation
28{
29 StatusCode sc;
30 ATH_MSG_INFO( "TRT_CablingSvc::initialize" );
31
32 // Retrieve Detector Store
33 ServiceHandle<StoreGateSvc> detStore("DetectorStore",name());
34 ATH_CHECK(detStore.retrieve());
35 ATH_CHECK(detStore->retrieve(m_manager,"TRT"));
36
37 // Get ToolSvc
38 SmartIF<IToolSvc> toolSvc{service("ToolSvc")};
39 ATH_CHECK( toolSvc.isValid() );
40
41 // Get tool for filling of cabling data
42 std::string toolType;
43 if (m_manager->getLayout()=="TestBeam")
44 {
45 m_TRTLayout = 1;
46 toolType = "TRT_FillCablingData_TB04";
47 ATH_MSG_INFO( "TRT TB04 Cabling" );
48 if(StatusCode::SUCCESS !=toolSvc->retrieveTool(toolType,m_cablingTool_TB))
49 {
50 ATH_MSG_ERROR( " Can't get TRT_FillCablingData_TB04 tool " );
51 return StatusCode::FAILURE;
52 }
53 m_cabling = m_cablingTool_TB->fillData();
54 }
55 // DC1
56 else if ((m_manager->getLayout() == "Initial") ||
57 (m_manager->getLayout() == "Final") )
58 {
59 m_TRTLayout = 6;
60 toolType = "TRT_FillCablingData_DC3";
61 ATH_MSG_INFO( "TRT DC3 Cabling" );
62 if( StatusCode::SUCCESS !=
63 toolSvc->retrieveTool(toolType,m_cablingTool_DC3) )
64 {
65 ATH_MSG_ERROR( " Can't get TRT_FillCablingData_DC3 tool " );
66 return StatusCode::FAILURE;
67 }
68
69 m_cabling = m_cablingTool_DC3->fillData();
70
71 }
72 else if ( m_manager->getLayout()=="SR1" ) // SR1 Barrel cosmics layout
73 {
74 m_TRTLayout = 4;
75 toolType = "TRT_FillCablingData_SR1";
76 ATH_MSG_INFO( "TRT SR1 Cabling" );
77 if(StatusCode::SUCCESS !=toolSvc->retrieveTool(toolType,m_cablingTool_SR1))
78 {
79 ATH_MSG_ERROR( " Can't get TRT_FillCablingData_SR1 tool " );
80 return StatusCode::FAILURE;
81 }
82
83 m_cabling = m_cablingTool_SR1->fillData();
84 }
85 else if ( m_manager->getLayout()=="SR1-EndcapC" ) // SR1 EC C cosmics layout
86 {
87 m_TRTLayout = 5;
88 toolType = "TRT_FillCablingData_SR1_ECC";
89 ATH_MSG_INFO( "TRT SR1 Cabling" );
90 if( StatusCode::SUCCESS !=
91 toolSvc->retrieveTool(toolType,m_cablingTool_SR1_ECC) )
92 {
93 ATH_MSG_ERROR( " Can't get TRT_FillCablingData_SR1_ECC tool " );
94 return StatusCode::FAILURE;
95 }
96
97 m_cabling = m_cablingTool_SR1_ECC->fillData();
98 }
99 else
100 {
101 ATH_MSG_FATAL( " Layout is not defined for TRT_FillCablingData (" << m_manager->getLayout() << ")! " );
102 return StatusCode::FAILURE;
103 }
104
105 ATH_MSG_INFO( "TRT_CablingSvc::initializiation finished" );
106
107 return sc;
108}
109
110
111std::vector<uint32_t> TRT_CablingSvc::getRobID(Identifier& id) const
112{
113 // TB Case
114 if (m_TRTLayout == 1)
115 {
116 return m_cablingTool_TB->getRobID(id);
117 }
118 // SR1 Barrel
119 else if ( m_TRTLayout == 4 )
120 {
121 return m_cablingTool_SR1->getRobID( id );
122 }
123 // SR1 EC C
124 else if ( m_TRTLayout == 5 )
125 {
126 return m_cablingTool_SR1_ECC->getRobID( id );
127 }
128 // DC3
129 else if ( m_TRTLayout == 6 )
130 {
131 return m_cablingTool_DC3->getRobID(id);
132 }
133 else
134 {
135 std::vector<uint32_t> v;
136 return v;
137 }
138}
139
140Identifier TRT_CablingSvc::getIdentifier(const eformat::SubDetector&,
141 const unsigned& rod, const int& bufferOffset,
142 IdentifierHash& hashId) const
143{
144 int intRod = (int) rod;
145
146 // TB04, SR1 or DC3 Case
147 hashId = m_cabling->get_identifierHashForAllStraws(intRod, bufferOffset);
148 return m_cabling->get_identifierForAllStraws(intRod, bufferOffset);
149}
150
151/*
152 * getBufferOffset( strawId ) -
153 * get Offset into ROD buffer given straw Identifier StrawId.
154 *
155 */
157{
158
159 // DC3 Case
160 if ( m_TRTLayout == 6 )
161 {
162 return m_cabling->get_BufferOffset( StrawId );
163 }
164 else
165 {
166 ATH_MSG_FATAL( "TRT_CablingSvc::getBufferOffset called in invalid case !" );
167 assert(0);
168 }
169
170 return 0;
171}
172
173const std::vector<uint32_t>& TRT_CablingSvc::getAllRods() const
174{
175 return m_cabling->get_allRods();
176}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
static Double_t sc
This is a "hash" representation of an Identifier.
TRT_FillCablingData_TB04 * m_cablingTool_TB
TRT_FillCablingData_DC3 * m_cablingTool_DC3
virtual uint32_t getBufferOffset(const Identifier &StrawId) override
TRT_CablingSvc(const std::string &name, ISvcLocator *pSvcLocator)
virtual const std::vector< uint32_t > & getAllRods() const override
TRT_FillCablingData_SR1 * m_cablingTool_SR1
TRT_CablingData * m_cabling
const InDetDD::TRT_DetectorManager * m_manager
TRT_FillCablingData_SR1_ECC * m_cablingTool_SR1_ECC
virtual Identifier getIdentifier(const eformat::SubDetector &subdetector, const unsigned &rod, const int &bufferOffset, IdentifierHash &hashId) const override
virtual StatusCode initialize() override
virtual std::vector< uint32_t > getRobID(Identifier &id) const override