ATLAS Offline Software
TRT_DetectorTool.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 #include "TRT_DetectorTool.h"
8 
10 
15 
18 
20 #include "SGTools/DataProxy.h"
21 
23 //
24 TRT_DetectorTool::TRT_DetectorTool( const std::string& type, const std::string& name, const IInterface* parent )
26 {
27 }
28 
30 //
32 {
33  // Get the detector configuration.
34  ATH_CHECK( m_geoDbTagSvc.retrieve());
35 
36  // Get the straw status tool
37  ATH_CHECK(m_sumTool.retrieve());
38 
39  ServiceHandle<IRDBAccessSvc> accessSvc(m_geoDbTagSvc->getParamSvcName(),name());
40  ATH_CHECK( accessSvc.retrieve());
41 
42  // Locate the top level experiment node
43  GeoModelExperiment* theExpt{nullptr};
44  ATH_CHECK(detStore()->retrieve(theExpt,"ATLAS"));
45  GeoPhysVol *world = theExpt->getPhysVol();
46 
47  // Retrieve the Geometry DB Interface
48  ATH_CHECK( m_geometryDBSvc.retrieve() );
49 
50  // Pass athena services to factory, etc
51  m_athenaComps.setDetStore(detStore().operator->());
53  m_athenaComps.setRDBAccessSvc(accessSvc.get());
55 
56  GeoModelIO::ReadGeoModel* sqliteReader = m_geoDbTagSvc->getSqliteReader();
57  //
58  // If we are using the SQLite reader, then we are not building the raw geometry but
59  // just locating it and attaching to readout geometry and various other actions
60  // taken in this factory.
61  //
62  if (sqliteReader) {
63  ATH_MSG_INFO( " Building TRT geometry from GeoModel factory TRTDetectorFactory_Lite" );
64  TRTDetectorFactory_Lite theTRTFactory(sqliteReader,
66  m_sumTool.get(),
72  );
73 
74  theTRTFactory.create(world);
75  m_manager=theTRTFactory.getDetectorManager();
76  }
77  else {
78  DecodeVersionKey versionKey(m_geoDbTagSvc.get(), "TRT");
79 
80  ATH_MSG_INFO( "Building TRT with Version Tag: "<< versionKey.tag() << " at Node: " << versionKey.node() );
81 
82  // Print the TRT version tag:
83  std::string trtVersionTag = accessSvc->getChildTag("TRT", versionKey.tag(), versionKey.node());
84  ATH_MSG_INFO("TRT Version: " << trtVersionTag );
85 
86  // Check if version is empty. If so, then the TRT cannot be built. This may or may not be intentional. We
87  // just issue an INFO message.
88  if (trtVersionTag.empty()) {
89  ATH_MSG_INFO("No TRT Version. TRT will not be built." );
90  return StatusCode::SUCCESS;
91  }
92 
93  ATH_MSG_DEBUG( "Keys for TRT Switches are " << versionKey.tag() << " " << versionKey.node() );
94  IRDBRecordset_ptr switchSet = accessSvc->getRecordsetPtr("TRTSwitches", versionKey.tag(), versionKey.node());
95  const IRDBRecord *switches = (*switchSet)[0];
96 
97  if (switches->getInt("DC1COMPATIBLE")) {
98  ATH_MSG_ERROR( "DC1COMPATIBLE flag set in database, but DC1 is no longer supported in the code!!");
99  return StatusCode::FAILURE;
100  }
101 
102  m_DC2CompatibleBarrelCoordinates = switches->getInt("DC2COMPATIBLE");
103  m_useOldActiveGasMixture = ( switches->getInt("GASVERSION") == 0 );
104  m_initialLayout = switches->getInt("INITIALLAYOUT");
105 
106  // Check if the new switches exists:
108  if ( switches->getInt("DOARGONMIXTURE") == 0) { m_doArgonMixture = false; }
109  else if ( switches->getInt("DOARGONMIXTURE") == 1) { m_doArgonMixture = true; }
110 
111  if ( switches->getInt("DOKRYPTONMIXTURE") == 0) { m_doKryptonMixture = false; }
112  else if ( switches->getInt("DOKRYPTONMIXTURE") == 1) { m_doKryptonMixture = true; }
113  }
114 
115  ATH_MSG_INFO( "Creating the TRT" );
116  ATH_MSG_INFO( "TRT Geometry Options:" << std::boolalpha );
117  ATH_MSG_INFO( " UseOldActiveGasMixture = " << m_useOldActiveGasMixture );
118  ATH_MSG_INFO( " Do Argon = " << m_doArgonMixture );
119  ATH_MSG_INFO( " Do Krypton = " << m_doKryptonMixture );
120  ATH_MSG_INFO( " DC2CompatibleBarrelCoordinates = " << m_DC2CompatibleBarrelCoordinates );
121  ATH_MSG_INFO( " InitialLayout = " << m_initialLayout );
122  ATH_MSG_INFO( " Alignable = " << m_alignable );
123  ATH_MSG_INFO( " VersioName = " << switches->getString("VERSIONNAME") );
124 
125  ATH_MSG_INFO( " Building TRT geometry from GeoModel factory TRTDetectorFactory_Full" );
126 
127  TRTDetectorFactory_Full theTRTFactory(&m_athenaComps,
128  m_sumTool.get(),
132  m_alignable,
136  );
137  theTRTFactory.create(world);
138  m_manager=theTRTFactory.getDetectorManager();
139 
140  }
141 
142  // Register the TRTDetectorNode instance with the Transient Detector Store
143  if (!m_manager) return StatusCode::FAILURE;
144 
145  theExpt->addManager(m_manager);
146  ATH_CHECK(detStore()->record(m_manager,m_manager->getName()));
147  return StatusCode::SUCCESS;
148 }
149 
150 
151 
152 StatusCode
153 TRT_DetectorTool::registerCallback ATLAS_NOT_THREAD_SAFE () // Thread unsafe StoreGateSvc::regFcn method and DataHandle template are used.
154 {
155  // This callback is kept because the folder never changes.
156 
157  MsgStream log(msgSvc(), name());
158 
159  // If we fail to register any callbacks we return FAILURE. This just tells GeoModelSvc that
160  // no callbacks were registered. It will continue normally but without any alignments.
161  StatusCode sc = StatusCode::FAILURE;
162 
163  if (m_alignable) {
164 
165 
166  if (m_useDynamicAlignFolders){ // Regular alignment new schema
167  std::string folderName = "/TRT/AlignL1/TRT";
168  if (detStore()->contains<CondAttrListCollection>(folderName)) {
169  msg(MSG::DEBUG) << "Registering callback on global Container with folder " << folderName << endmsg;
171  StatusCode trttmp = detStore()->regFcn(&IGeoModelTool::align, dynamic_cast<IGeoModelTool*>(this), calc, folderName);
172  // We don't expect this to fail as we have already checked that the detstore contains the object.
173  if (trttmp.isFailure()) {
174  msg(MSG::ERROR) << "Problem when register callback on global Container with folder " << folderName <<endmsg;
175  } else {
176  sc = StatusCode::SUCCESS;
177  }
178  } else {
179  msg(MSG::WARNING) << "Unable to register callback on global Container with folder " << folderName <<endmsg;
180  return StatusCode::FAILURE;
181  }
182 
183  folderName = "/TRT/AlignL2";
184  if (detStore()->contains<AlignableTransformContainer>(folderName)) {
185  if(msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Registering callback on AlignableTransformContainer with folder " << folderName << endmsg;
187  StatusCode sctmp = detStore()->regFcn(&IGeoModelTool::align, dynamic_cast<IGeoModelTool *>(this), atc, folderName);
188  if(sctmp.isFailure()) {
189  msg(MSG::ERROR) << "Problem when register callback on AlignableTransformContainer with folder " << folderName <<endmsg;
190  } else {
191  sc = StatusCode::SUCCESS;
192  }
193  }
194  else {
195  msg(MSG::WARNING) << "Unable to register callback on AlignableTransformContainer with folder "
196  << folderName << endmsg;
197  return StatusCode::FAILURE;
198  }
199  }
200  else { // Regular alignment old schema
201  std::string folderName = "/TRT/Align";
202  if (detStore()->contains<AlignableTransformContainer>(folderName)) {
203  msg(MSG::DEBUG) << "Registering callback on AlignableTransformContainer with folder " << folderName << endmsg;
205  StatusCode sctmp = detStore()->regFcn(&IGeoModelTool::align, dynamic_cast<IGeoModelTool *>(this), atc, folderName);
206  // We don't expect this to fail as we have already checked that the detstore contains the object.
207  if (sctmp.isFailure()) {
208  msg(MSG::ERROR) << "Problem when register callback on AlignableTransformContainer with folder " << folderName <<endmsg;
209  } else {
210  sc = StatusCode::SUCCESS;
211  }
212  } else {
213  msg(MSG::WARNING) << "Unable to register callback on AlignableTransformContainer with folder "
214  << folderName << ", Alignments disabled! (Only if no Run2 schema is loaded)" << endmsg;
215  }
216  }
217 
218 
219  // Fine alignment
220  {
221  std::string folderName = "/TRT/Calib/DX";
222  if (detStore()->contains<TRTCond::StrawDxContainer>(folderName)) {
223  msg(MSG::DEBUG) << "Registering callback on StrawDxContainer with folder " << folderName << endmsg;
225  StatusCode sctmp = detStore()->regFcn(&IGeoModelTool::align, dynamic_cast<IGeoModelTool*>(this), sdc, folderName);
226  // We don't expect this to fail as we have already checked that the detstore contains the object.
227  if (sctmp.isFailure()) {
228  msg(MSG::ERROR) << "Problem when register callback on StrawDxContainer with folder " << folderName <<endmsg;
229  } else {
230  sc = StatusCode::SUCCESS;
231  }
232  } else {
233  msg(MSG::DEBUG) << "Unable to register callback on StrawDxContainer with folder " << folderName <<endmsg;
234  }
235  }
236 
237  } else {
238  msg(MSG::INFO) << "Alignment disabled. No callback registered" << endmsg;
239  // We return failure otherwise it will try and register
240  // a GeoModelSvc callback associated with this callback.
241  }
242 
243  return sc;
244 }
245 
247 {
249  if(proxy) {
250  proxy->reset();
251  m_manager = nullptr;
252  }
253  return StatusCode::SUCCESS;
254 }
255 
256 
257 StatusCode
259 {
260  MsgStream log(msgSvc(), name());
261  if (!m_manager) {
262  msg(MSG::WARNING) << "Manager does not exist" << endmsg;
263  return StatusCode::FAILURE;
264  }
265  if (m_alignable) {
266  return m_manager->align(I,keys);
267  } else {
268  msg(MSG::DEBUG) << "Alignment disabled. No alignments applied" << endmsg;
269  return StatusCode::SUCCESS;
270  }
271 }
IRDBRecord::getInt
virtual int getInt(const std::string &fieldName) const =0
Get int field value.
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
IRDBRecord::getString
virtual const std::string & getString(const std::string &fieldName) const =0
Get string field value.
TRTDetectorFactory_Lite::create
virtual void create(GeoPhysVol *world) override
Definition: TRTDetectorFactory_Lite.cxx:96
GeoModelExperiment
Definition: GeoModelExperiment.h:32
DecodeVersionKey::node
const std::string & node() const
Return the version node.
Definition: DecodeVersionKey.cxx:99
IOVSVC_CALLBACK_ARGS_P
#define IOVSVC_CALLBACK_ARGS_P(I, K)
short hand for IOVSvc call back argument list, to be used when access to formal arguments is needed,...
Definition: IOVSvcDefs.h:42
TRT_DetectorTool::m_alignable
Gaudi::Property< bool > m_alignable
Definition: TRT_DetectorTool.h:46
TRT_DetectorTool::m_manager
const InDetDD::TRT_DetectorManager * m_manager
Definition: TRT_DetectorTool.h:58
IGeoModelTool::align
virtual StatusCode align(IOVSVC_CALLBACK_ARGS)=0
TRT_DetectorTool::align
virtual StatusCode align(IOVSVC_CALLBACK_ARGS) override final
Definition: TRT_DetectorTool.cxx:258
TRT_DetectorTool::TRT_DetectorTool
TRT_DetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TRT_DetectorTool.cxx:24
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
TRT_DetectorTool.h
InDetDD::AthenaComps::setGeoDbTagSvc
void setGeoDbTagSvc(IGeoDbTagSvc *)
Definition: InDetDDAthenaComps.cxx:22
InDetDD::AthenaComps::setDetStore
void setDetStore(StoreGateSvc *)
Definition: InDetDDAthenaComps.cxx:17
GeoModelExperiment.h
TRTDetectorFactory_Full::getDetectorManager
virtual const InDetDD::TRT_DetectorManager * getDetectorManager() const override
Definition: TRTDetectorFactory_Full.cxx:114
TRTDetectorFactory_Full::create
virtual void create(GeoPhysVol *world) override
Definition: TRTDetectorFactory_Full.cxx:133
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
TRT_DetectorTool::m_DC2CompatibleBarrelCoordinates
Gaudi::Property< bool > m_DC2CompatibleBarrelCoordinates
Definition: TRT_DetectorTool.h:44
ClassID_traits.h
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AlignableTransformContainer.h
DecodeVersionKey
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
Definition: DecodeVersionKey.h:18
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
TRTDetectorFactory_Lite.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
DecodeVersionKey::tag
const std::string & tag() const
Return version tag.
Definition: DecodeVersionKey.cxx:93
GeoModelTool
Definition: GeoModelTool.h:17
InDetDD::AthenaComps::setRDBAccessSvc
void setRDBAccessSvc(IRDBAccessSvc *)
Definition: InDetDDAthenaComps.cxx:27
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TRT_DetectorTool::m_athenaComps
InDetDD::AthenaComps m_athenaComps
Definition: TRT_DetectorTool.h:59
ATLAS_NOT_THREAD_SAFE
StatusCode TRT_DetectorTool::registerCallback ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
Definition: TRT_DetectorTool.cxx:153
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
TRT_DetectorTool::m_initialLayout
bool m_initialLayout
Definition: TRT_DetectorTool.h:60
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
CaloCellTimeCorrFiller.folderName
string folderName
Definition: CaloCellTimeCorrFiller.py:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
InDetDD::InDetDetectorManager::align
StatusCode align(IOVSVC_CALLBACK_ARGS) const
DataHandle< CondAttrListCollection >
TRT_DetectorTool::m_overridedigversion
Gaudi::Property< int > m_overridedigversion
Definition: TRT_DetectorTool.h:45
DecodeVersionKey.h
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
IGeoModelTool
Definition: IGeoModelTool.h:12
TRT_DetectorTool::create
virtual StatusCode create() override final
Definition: TRT_DetectorTool.cxx:31
IRDBRecord
IRDBRecord is one record in the IRDBRecordset object.
Definition: IRDBRecord.h:27
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
InDetDD::AthenaComps::setGeometryDBSvc
void setGeometryDBSvc(IGeometryDBSvc *)
Definition: InDetDDAthenaComps.cxx:32
TRTDetectorFactory_Lite::getDetectorManager
virtual const InDetDD::TRT_DetectorManager * getDetectorManager() const override
Definition: TRTDetectorFactory_Lite.cxx:77
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
TRT_DetectorTool::m_doKryptonMixture
Gaudi::Property< bool > m_doKryptonMixture
Definition: TRT_DetectorTool.h:52
TRT_DetectorTool::m_useOldActiveGasMixture
Gaudi::Property< bool > m_useOldActiveGasMixture
Definition: TRT_DetectorTool.h:43
TRT_DetectorTool::m_doArgonMixture
Gaudi::Property< bool > m_doArgonMixture
Definition: TRT_DetectorTool.h:50
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
TRT_DetectorTool::m_sumTool
ToolHandle< ITRT_StrawStatusSummaryTool > m_sumTool
Definition: TRT_DetectorTool.h:56
TRTDetectorFactory_Lite
Definition: TRTDetectorFactory_Lite.h:29
TRT_DetectorTool::m_geoDbTagSvc
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
Definition: TRT_DetectorTool.h:54
TRT_DetectorTool::m_useDynamicAlignFolders
Gaudi::Property< bool > m_useDynamicAlignFolders
Definition: TRT_DetectorTool.h:47
I
#define I(x, y, z)
Definition: MD5.cxx:116
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
TRTDetectorFactory_Full
This class creates the TRT Geometry.
Definition: TRTDetectorFactory_Full.h:31
SG::DataProxy
Definition: DataProxy.h:44
TRT_DetectorTool::clear
virtual StatusCode clear() override final
Definition: TRT_DetectorTool.cxx:246
beamspotnt.calc
calc
Definition: bin/beamspotnt.py:1252
TRT_DetectorTool::m_geometryDBSvc
ServiceHandle< IGeometryDBSvc > m_geometryDBSvc
Definition: TRT_DetectorTool.h:55
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
StrawDxContainer.h
Class for storing/accessing trt endpoint corrections data.
TRTDetectorFactory_Full.h
ServiceHandle< IRDBAccessSvc >
DataProxy.h