ATLAS Offline Software
Loading...
Searching...
No Matches
HGTD_DetectorTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5// includes
15
17#include "SGTools/DataProxy.h"
18
20 const std::string &name,
21 const IInterface *parent) :
22 GeoModelTool(type, name, parent),
23 m_geoDbTagSvc("GeoDbTagSvc", name),
24 m_rdbAccessSvc("RDBAccessSvc", name),
25 m_detectorManager(nullptr),
26 m_printIDdict(false) {
27 // Get parameter values from the python configuration
28 declareProperty("GeoDbTagSvc", m_geoDbTagSvc);
29 declareProperty("RDBAccessSvc", m_rdbAccessSvc);
30 declareProperty("PrintModuleNumberPerRow", m_printIDdict);
31}
32
34
35 ATH_CHECK(m_geoDbTagSvc.retrieve());
36 ATH_CHECK(m_rdbAccessSvc.retrieve());
37
38 // Get their interfaces to pass to the DetectorFactory
39 m_athenaComps.setDetStore(detStore().operator->());
40 m_athenaComps.setGeoDbTagSvc(&*m_geoDbTagSvc);
41 m_athenaComps.setRDBAccessSvc(&*m_rdbAccessSvc);
42 const HGTD_ID* idHelper{nullptr};
43 ATH_CHECK(detStore()->retrieve(idHelper, "HGTD_ID"));
44 m_athenaComps.setIdHelper(idHelper);
45
46 GeoModelExperiment *theExpt = nullptr;
47 ATH_CHECK(detStore()->retrieve(theExpt, "ATLAS"));
48
49 // The * converts a ConstPVLink to a ref to a GeoVPhysVol, the & takes the address of the GeoVPhysVol
50 GeoPhysVol *world = &*theExpt->getPhysVol();
51
52 HGTD_DetectorFactory theHGTDFactory(&m_athenaComps);
54 theHGTDFactory.create(world);
55
56 // Get the manager from the factory and store it in the detector store.
57 m_detectorManager = theHGTDFactory.getDetectorManager();
58 if (!m_detectorManager) {
59 ATH_MSG_ERROR( "HGTD_DetectorManager not found; not created in HGTD_DetectorFactory?" );
60 return(StatusCode::FAILURE);
61 }
62
63 ATH_MSG_DEBUG("Registering HGTD_DetectorManager as " << m_detectorManager->getName() );
64 ATH_CHECK( detStore()->record(m_detectorManager, m_detectorManager->getName()) );
65
67 return StatusCode::SUCCESS;
68}
69
71
72 // Release manager from the detector store
73 SG::DataProxy* proxy = detStore()->proxy(ClassID_traits< HGTD_DetectorManager >::ID(),m_detectorManager->getName());
74 if (proxy) {
75 proxy->reset();
76 m_detectorManager = nullptr;
77 }
78
79 return StatusCode::SUCCESS;
80}
81
82StatusCode HGTD_DetectorTool::registerCallback ATLAS_NOT_THREAD_SAFE () // Thread unsafe detStore()->regFcn (callback) is used.
83{
84
85 // Register call-back for software alignment
86 StatusCode sc = StatusCode::FAILURE;
87 if (m_alignable.value()) {
88 std::string folderName = "/Indet/AlignHGTD";
89 if ( detStore()->contains<AlignableTransformContainer>(folderName) ) {
90 ATH_MSG_DEBUG( "Registering callback on AlignableTransformContainer with folder " << folderName );
92 ATH_CHECK( detStore()->regFcn( &IGeoModelTool::align, dynamic_cast<IGeoModelTool *>(this), atc, folderName ) );
93 sc = StatusCode::SUCCESS;
94 }
95 else {
96 ATH_MSG_WARNING( "Unable to register callback on AlignableTransformContainer with folder " <<
97 folderName << ", Alignment disabled (only if no Run-2 scheme is loaded)!" );
98 }
99 }
100 else {
101 ATH_MSG_INFO( "Alignment disabled. No callback registered" );
102 // We return failure otherwise it will try and register a GeoModelSvc callback associated with this callback.
103 }
104 return sc;
105}
106
107StatusCode HGTD_DetectorTool::align(IOVSVC_CALLBACK_ARGS_P( I, keys ) ) {
108
109 // The call-back routine, which just calls the real call-back routine from the manager.
110
111 if ( ! m_detectorManager ) {
112 ATH_MSG_WARNING( "Manager does not exist for " << I <<" "<< keys );
113 return StatusCode::FAILURE;
114 }
115
116 ATH_MSG_INFO( "No align method yet implemented for HGTD_DetectorManager. Nothing to do." );
117
118 return StatusCode::SUCCESS;
119}
#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)
#define ATH_MSG_DEBUG(x)
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
StatusCode HGTD_DetectorTool::registerCallback ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
#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
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
static Double_t sc
#define I(x, y, z)
Definition MD5.cxx:116
an iterator over instances of a given type in StoreGateSvc.
Definition DataHandle.h:43
GeoPhysVol * getPhysVol()
Destructor.
void addManager(const GeoVDetectorManager *)
virtual void create(GeoPhysVol *world) override
virtual const HGTD_DetectorManager * getDetectorManager() const override
const HGTD_DetectorManager * m_detectorManager
HGTD_GeoModelAthenaComps m_athenaComps
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
ServiceHandle< IRDBAccessSvc > m_rdbAccessSvc
virtual StatusCode create() override final
HGTD_DetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode clear() override final
This is an Identifier helper class for the HGTD subdetector.
Definition HGTD_ID.h:47
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114