ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_DetectorTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "TRT_DetectorTool.h"
8
10
15
19#include "SGTools/DataProxy.h"
20
21#include <memory>
22
24//
25TRT_DetectorTool::TRT_DetectorTool( const std::string& type, const std::string& name, const IInterface* parent )
26 : GeoModelTool( type, name, parent )
27{
28}
29
31//
33{
34 // Get the detector configuration.
35 ATH_CHECK( m_geoDbTagSvc.retrieve());
36
37 ServiceHandle<IRDBAccessSvc> accessSvc(m_geoDbTagSvc->getParamSvcName(),name());
38 ATH_CHECK( accessSvc.retrieve());
39
40 // Locate the top level experiment node
41 GeoModelExperiment* theExpt{nullptr};
42 ATH_CHECK(detStore()->retrieve(theExpt,"ATLAS"));
43 GeoPhysVol *world = theExpt->getPhysVol();
44
45 // Pass athena services to factory, etc
46 m_athenaComps.setDetStore(detStore().operator->());
47 m_athenaComps.setGeoDbTagSvc(m_geoDbTagSvc.get());
48 m_athenaComps.setRDBAccessSvc(accessSvc.get());
49
50 std::unique_ptr<TRTStrawStatusAccessor> strawStatusAccessor;
51 ATH_CHECK(m_sumTool.retrieve(DisableTool{ !m_dumpStrawStatus }));
53 // Read Straw Statuses from the ASCII file
54 strawStatusAccessor = std::make_unique<TRTStrawStatusAccessor>();
55 const std::string strawStatusPath = PathResolverFindCalibFile(m_strawStatusFile);
56 if (strawStatusPath.empty()) {
57 ATH_MSG_ERROR("Failed to resolve path for StrawStatusFile: " << m_strawStatusFile << ", the job will fail now.");
58 return StatusCode::FAILURE;
59 }
60 ATH_MSG_VERBOSE("StrawStatusFile: " << m_strawStatusFile << ", resolved path: " << strawStatusPath);
61 strawStatusAccessor->fill(strawStatusPath);
62 }
63
64 GeoModelIO::ReadGeoModel* sqliteReader = m_geoDbTagSvc->getSqliteReader();
65 //
66 // If we are using the SQLite reader, then we are not building the raw geometry but
67 // just locating it and attaching to readout geometry and various other actions
68 // taken in this factory.
69 //
70 if (sqliteReader) {
71 ATH_MSG_INFO( " Building TRT geometry from GeoModel factory TRTDetectorFactory_Lite" );
72 TRTDetectorFactory_Lite theTRTFactory(sqliteReader,
74 std::move(strawStatusAccessor),
79 );
80
81 theTRTFactory.create(world);
82 m_manager=theTRTFactory.getDetectorManager();
83 }
84 else {
85 DecodeVersionKey versionKey(m_geoDbTagSvc.get(), "TRT");
86
87 ATH_MSG_INFO( "Building TRT with Version Tag: "<< versionKey.tag() << " at Node: " << versionKey.node() );
88
89 // Print the TRT version tag:
90 std::string trtVersionTag = accessSvc->getChildTag("TRT", versionKey.tag(), versionKey.node());
91 ATH_MSG_INFO("TRT Version: " << trtVersionTag );
92
93 // Check if version is empty. If so, then the TRT cannot be built. This may or may not be intentional. We
94 // just issue an INFO message.
95 if (trtVersionTag.empty()) {
96 ATH_MSG_INFO("No TRT Version. TRT will not be built." );
97 return StatusCode::SUCCESS;
98 }
99
100 ATH_MSG_DEBUG( "Keys for TRT Switches are " << versionKey.tag() << " " << versionKey.node() );
101 IRDBRecordset_ptr switchSet = accessSvc->getRecordsetPtr("TRTSwitches", versionKey.tag(), versionKey.node());
102 const IRDBRecord *switches = (*switchSet)[0];
103
104 if (switches->getInt("DC1COMPATIBLE")) {
105 ATH_MSG_ERROR( "DC1COMPATIBLE flag set in database, but DC1 is no longer supported in the code!!");
106 return StatusCode::FAILURE;
107 }
108
109 m_DC2CompatibleBarrelCoordinates = switches->getInt("DC2COMPATIBLE");
110 m_useOldActiveGasMixture = ( switches->getInt("GASVERSION") == 0 );
111 m_initialLayout = switches->getInt("INITIALLAYOUT");
112
113 // Check if the new switches exists:
115 if ( switches->getInt("DOARGONMIXTURE") == 0) { m_doArgonMixture = false; }
116 else if ( switches->getInt("DOARGONMIXTURE") == 1) { m_doArgonMixture = true; }
117
118 if ( switches->getInt("DOKRYPTONMIXTURE") == 0) { m_doKryptonMixture = false; }
119 else if ( switches->getInt("DOKRYPTONMIXTURE") == 1) { m_doKryptonMixture = true; }
120 }
121
122 ATH_MSG_INFO( "Creating the TRT" );
123 ATH_MSG_INFO( "TRT Geometry Options:" << std::boolalpha );
124 ATH_MSG_INFO( " UseOldActiveGasMixture = " << m_useOldActiveGasMixture );
125 ATH_MSG_INFO( " Do Argon = " << m_doArgonMixture );
126 ATH_MSG_INFO( " Do Krypton = " << m_doKryptonMixture );
127 ATH_MSG_INFO( " DC2CompatibleBarrelCoordinates = " << m_DC2CompatibleBarrelCoordinates );
128 ATH_MSG_INFO( " InitialLayout = " << m_initialLayout );
129 ATH_MSG_INFO( " Alignable = " << m_alignable );
130 ATH_MSG_INFO( " VersioName = " << switches->getString("VERSIONNAME") );
131
132 ATH_MSG_INFO( " Building TRT geometry from GeoModel factory TRTDetectorFactory_Full" );
133
135 m_dumpStrawStatus ? m_sumTool.get() : nullptr,
136 std::move(strawStatusAccessor),
143 );
144 theTRTFactory.create(world);
145 m_manager=theTRTFactory.getDetectorManager();
146
147 }
148
149 // Register the TRTDetectorNode instance with the Transient Detector Store
150 if (!m_manager) return StatusCode::FAILURE;
151
152 theExpt->addManager(m_manager);
153 ATH_CHECK(detStore()->record(m_manager,m_manager->getName()));
154 return StatusCode::SUCCESS;
155}
156
158{
159 SG::DataProxy* proxy = detStore()->proxy(ClassID_traits<InDetDD::TRT_DetectorManager>::ID(),m_manager->getName());
160 if(proxy) {
161 proxy->reset();
162 m_manager = nullptr;
163 }
164 return StatusCode::SUCCESS;
165}
166
167StatusCode
169//The manager align call invalidates all elements
170{
171 MsgStream log(msgSvc(), name());
172 if (!m_manager) {
173 msg(MSG::WARNING) << "Manager does not exist" << endmsg;
174 return StatusCode::FAILURE;
175 }
176 if (m_alignable) {
177 return const_cast<InDetDD::TRT_DetectorManager*>(m_manager)->align();
178 } else {
179 msg(MSG::DEBUG) << "Alignment disabled. No alignments applied" << endmsg;
180 return StatusCode::SUCCESS;
181 }
182}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Definition of the abstract IRDBAccessSvc interface.
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Class for storing/accessing trt endpoint corrections data.
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
const std::string & tag() const
Return version tag.
const std::string & node() const
Return the version node.
GeoPhysVol * getPhysVol()
Destructor.
void addManager(const GeoVDetectorManager *)
IRDBRecord is one record in the IRDBRecordset object.
Definition IRDBRecord.h:27
virtual const std::string & getString(const std::string &fieldName) const =0
Get string field value.
virtual int getInt(const std::string &fieldName) const =0
Get int field value.
The Detector Manager for all TRT Detector elements, it acts as the interface to the detector elements...
This class creates the TRT Geometry.
virtual void create(GeoPhysVol *world) override
virtual const InDetDD::TRT_DetectorManager * getDetectorManager() const override
virtual void create(GeoPhysVol *world) override
virtual const InDetDD::TRT_DetectorManager * getDetectorManager() const override
InDetDD::AthenaComps m_athenaComps
Gaudi::Property< bool > m_dumpStrawStatus
virtual StatusCode align() override final
virtual StatusCode create() override final
Gaudi::Property< bool > m_useOldActiveGasMixture
Gaudi::Property< bool > m_DC2CompatibleBarrelCoordinates
Gaudi::Property< bool > m_doArgonMixture
Gaudi::Property< bool > m_doKryptonMixture
Gaudi::Property< bool > m_alignable
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
ToolHandle< ITRT_StrawStatusSummaryTool > m_sumTool
const InDetDD::TRT_DetectorManager * m_manager
Gaudi::Property< std::string > m_strawStatusFile
Gaudi::Property< bool > m_useDynamicAlignFolders
virtual StatusCode clear() override final
TRT_DetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
MsgStream & msg
Definition testRead.cxx:32