ATLAS Offline Software
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
10 #include "StoreGate/StoreGateSvc.h"
15 
17 #include "SGTools/DataProxy.h"
18 
20  const std::string &name,
21  const IInterface *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->());
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);
53  theHGTDFactory.setPrintIdentifierDict(m_printIDdict);
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 
66  theExpt->addManager(m_detectorManager);
67  return StatusCode::SUCCESS;
68 }
69 
71 
72  // Release manager from the detector store
74  if (proxy) {
75  proxy->reset();
76  m_detectorManager = nullptr;
77  }
78 
79  return StatusCode::SUCCESS;
80 }
81 
82 StatusCode 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 
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
GeoModelExperiment::getPhysVol
GeoPhysVol * getPhysVol()
Destructor.
Definition: GeoModelExperiment.cxx:21
HGTD_DetectorTool::m_detectorManager
const HGTD_DetectorManager * m_detectorManager
Definition: HGTD_DetectorTool.h:50
HGTD_DetectorTool::m_geoDbTagSvc
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
Definition: HGTD_DetectorTool.h:47
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
HGTD_DetectorTool::m_athenaComps
HGTD_GeoModelAthenaComps m_athenaComps
Definition: HGTD_DetectorTool.h:52
GeoModelExperiment
Definition: GeoModelExperiment.h:32
HGTD_DetectorTool::clear
virtual StatusCode clear() override final
Definition: HGTD_DetectorTool.cxx:70
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
IGeoModelTool::align
virtual StatusCode align(IOVSVC_CALLBACK_ARGS)=0
HGTD_DetectorFactory::setPrintIdentifierDict
void setPrintIdentifierDict(bool)
Definition: HGTD_DetectorFactory.cxx:82
HGTD_DetectorManager.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
InDetDD::AthenaComps::setGeoDbTagSvc
void setGeoDbTagSvc(IGeoDbTagSvc *)
Definition: InDetDDAthenaComps.cxx:22
InDetDD::AthenaComps::setDetStore
void setDetStore(StoreGateSvc *)
Definition: InDetDDAthenaComps.cxx:17
GeoModelExperiment.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ClassID_traits.h
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
HGTD_DetectorTool::HGTD_DetectorTool
HGTD_DetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: HGTD_DetectorTool.cxx:19
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SiCommonItems.h
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AlignableTransformContainer.h
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
HGTD_DetectorFactory
Definition: HGTD_DetectorFactory.h:70
test_pyathena.parent
parent
Definition: test_pyathena.py:15
GeoModelTool
Definition: GeoModelTool.h:17
InDetDD::AthenaComps::setRDBAccessSvc
void setRDBAccessSvc(IRDBAccessSvc *)
Definition: InDetDDAthenaComps.cxx:27
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
HGTD_ID
Definition: HGTD_ID.h:47
HGTD_DetectorTool::create
virtual StatusCode create() override final
Definition: HGTD_DetectorTool.cxx:33
HGTD_DetectorTool::align
virtual StatusCode align(IOVSVC_CALLBACK_ARGS) override final
Definition: HGTD_DetectorTool.cxx:107
HGTD_DetectorTool::m_printIDdict
bool m_printIDdict
Definition: HGTD_DetectorTool.h:54
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
DataHandle
an iterator over instances of a given type in StoreGateSvc. It d-casts and caches locally the pointed...
Definition: DataHandle.h:42
GeoModelExperiment::addManager
void addManager(const GeoVDetectorManager *)
Definition: GeoModelExperiment.cxx:40
HGTD_DetectorTool::m_rdbAccessSvc
ServiceHandle< IRDBAccessSvc > m_rdbAccessSvc
Definition: HGTD_DetectorTool.h:48
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
IGeoModelTool
Definition: IGeoModelTool.h:12
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
HGTD_DetectorFactory.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
HGTD_DetectorFactory::getDetectorManager
virtual const HGTD_DetectorManager * getDetectorManager() const override
Definition: HGTD_DetectorFactory.cxx:1067
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
HGTD_GeoModelAthenaComps::setIdHelper
void setIdHelper(const HGTD_ID *idHelper)
Definition: HGTD_GeoModelAthenaComps.cxx:13
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
HGTD_DetectorTool.h
I
#define I(x, y, z)
Definition: MD5.cxx:116
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
HGTD_DetectorFactory::create
virtual void create(GeoPhysVol *world) override
Definition: HGTD_DetectorFactory.cxx:87
SG::DataProxy
Definition: DataProxy.h:44
StoreGateSvc.h
ATLAS_NOT_THREAD_SAFE
StatusCode HGTD_DetectorTool::registerCallback ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
Definition: HGTD_DetectorTool.cxx:82
DataProxy.h