diff --git a/DetectorDescription/DetDescrCnvSvc/CMakeLists.txt b/DetectorDescription/DetDescrCnvSvc/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..4c554ff2279f6eaf7b0ebd504c762b6c222917ab --- /dev/null +++ b/DetectorDescription/DetDescrCnvSvc/CMakeLists.txt @@ -0,0 +1,27 @@ +################################################################################ +# Package: DetDescrCnvSvc +################################################################################ + +# Declare the package name: +atlas_subdir( DetDescrCnvSvc ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + GaudiKernel + PRIVATE + Control/StoreGate ) + +# Component(s) in the package: +atlas_add_library( DetDescrCnvSvcLib + src/*.cxx + PUBLIC_HEADERS DetDescrCnvSvc + LINK_LIBRARIES GaudiKernel StoreGateLib SGtests ) + +atlas_add_component( DetDescrCnvSvc + src/components/*.cxx + LINK_LIBRARIES GaudiKernel StoreGateLib SGtests DetDescrCnvSvcLib ) + +# Install files from the package: +atlas_install_python_modules( python/*.py ) +atlas_install_joboptions( share/*.py ) + diff --git a/DetectorDescription/DetDescrCnvSvc/DetDescrCnvSvc/DetDescrAddress.h b/DetectorDescription/DetDescrCnvSvc/DetDescrCnvSvc/DetDescrAddress.h new file mode 100755 index 0000000000000000000000000000000000000000..a2fb9587ec2405090d36a3368e31b2639ffb95b9 --- /dev/null +++ b/DetectorDescription/DetDescrCnvSvc/DetDescrCnvSvc/DetDescrAddress.h @@ -0,0 +1,64 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +//==================================================================== +// DetDescrAddress.h +//-------------------------------------------------------------------- +// +// Package : DetDescrCnvSvc +// +// Description: Definition of detector description address class +// This class for the moment has just the +// funtionality of a GenericAddress. It provides the +// conversion service type but nothing more. It thus +// just holds the clid and the class name. It is +// created for later expansion. +// Author : RD Schaffer +//==================================================================== +#ifndef DETDESCRCNVSVC_DETDESCRADDRESS_H +#define DETDESCRCNVSVC_DETDESCRADDRESS_H + +// C/C++ include files +#include <string> + +// Framework include files +#include "GaudiKernel/Kernel.h" +#include "GaudiKernel/GenericAddress.h" +#include "GaudiKernel/StatusCode.h" + +extern long DetDescr_StorageType; + +class DetDescrAddress : public GenericAddress { +public: + + + /// Standard Destructor + virtual ~DetDescrAddress() {}; //doesn't own event + + /// Standard Constructor + DetDescrAddress(const CLID& clid, const std::string& fname, + const std::string& cname ); + + DetDescrAddress(const CLID& clid ) ; + + const std::string& payload() const; + + /// write technology-specific part of address to string + StatusCode toString(std::string& refString) const; + + /// initialize technology-specific part of IOA from stringifiedIOA + StatusCode fromString(const std::string& stringifiedIOA); + + +private: + + std::string m_payload; + +}; +#endif + + + + + diff --git a/DetectorDescription/DetDescrCnvSvc/DetDescrCnvSvc/DetDescrCnvSvc.h b/DetectorDescription/DetDescrCnvSvc/DetDescrCnvSvc/DetDescrCnvSvc.h new file mode 100755 index 0000000000000000000000000000000000000000..0089037427d456a703724fab8d84c71874fdf682 --- /dev/null +++ b/DetectorDescription/DetDescrCnvSvc/DetDescrCnvSvc/DetDescrCnvSvc.h @@ -0,0 +1,130 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef DETDESCRCNVSVC_DETDESCRCNVSVC_H +#define DETDESCRCNVSVC_DETDESCRCNVSVC_H + +#include "GaudiKernel/ConversionSvc.h" + +// Forward declarations +template <class TYPE> class SvcFactory; + +class IOpaqueAddress; +class StatusCode; +class ActiveStoreSvc; +class StoreGateSvc; +// namespace SG { +// class TransientAddress; +// } + +// class DetDescrCnvSvc : +// public ConversionSvc, +// public virtual IAddressProvider { + +class DetDescrCnvSvc : public ConversionSvc { + /// Allow the factory class access to the constructor + friend class SvcFactory<DetDescrCnvSvc>; +public: + + /// Initialize the service. + virtual StatusCode initialize(); + virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvInterface); + + /// Add new address to the Detector Store + virtual StatusCode addToDetStore(const CLID& clid, const std::string& name) const; + + /// Basic create address + virtual StatusCode createAddress( long svc_type, + const CLID& clid, + const std::string* par, + const unsigned long* ip, + IOpaqueAddress*& refpAddress); + + /// Create address from string form + virtual StatusCode createAddress( long svc_type, + const CLID& clid, + const std::string& refAddress, + IOpaqueAddress*& refpAddress); + + /// Convert address to string form + virtual StatusCode convertAddress( const IOpaqueAddress* pAddress, + std::string& refAddress); + + /// Provide access to Detector Store + StoreGateSvc * detStore() const; + +// /// AddressProvider interface +// typedef IAddressProvider::tadList tadList; +// typedef IAddressProvider::tadListIterator tadListIterator; + +// /// get all addresses that the provider wants to preload in SG +// /// maps before the event loop +// virtual StatusCode preLoadAddresses( StoreID::type storeID, +// tadList& list ); + +// /// get all new addresses from Provider for this Event. +// virtual StatusCode loadAddresses( StoreID::type storeID, +// tadList& list ); + +// /// update a transient Address +// virtual StatusCode updateAddress( SG::TransientAddress* tad ); + + +protected: + /**@name: Object implementation */ + //@{ + /// Standard Constructor + DetDescrCnvSvc(const std::string& name, ISvcLocator* svc); + + /// Standard Destructor + virtual ~DetDescrCnvSvc(); + + +private: + + StatusCode fillTDSRefs(); + +// SG::TransientAddress* loadAddress(const CLID& clid, +// const std::string& key); + + void initTDSItems(); + + StoreGateSvc * m_detStore; + StringArrayProperty m_detMgrs; + StringArrayProperty m_detNodes; + BooleanProperty m_decodeIdDict; + BooleanProperty m_idDictFromRDB; + StringProperty m_idDictName; + StringProperty m_idDictGlobalTag; + StringProperty m_idDictATLASName; + StringProperty m_idDictInDetName; + StringProperty m_idDictLArName; + StringProperty m_idDictTileName; + StringProperty m_idDictLVL1Name; + StringProperty m_idDictMuonName; + StringProperty m_idDictLArHighVoltageName; + StringProperty m_idDictLArElectrodeName; + StringProperty m_idDictForwardName; + StringProperty m_fcal2dNeighborsName; + StringProperty m_fcal3dNeighborsNextName; + StringProperty m_fcal3dNeighborsPrevName; + StringProperty m_tileNeighborsName; + StringProperty m_fullAtlasNeighborsName; + BooleanProperty m_fromRoot; + BooleanProperty m_fromNova; + BooleanProperty m_detElemsfromDetNodes; + BooleanProperty m_compact_ids_only; + BooleanProperty m_do_checks; + BooleanProperty m_do_neighbours; +}; +#endif + + + + + + + + + diff --git a/DetectorDescription/DetDescrCnvSvc/DetDescrCnvSvc/DetDescrConverter.h b/DetectorDescription/DetDescrCnvSvc/DetDescrCnvSvc/DetDescrConverter.h new file mode 100755 index 0000000000000000000000000000000000000000..79dcc09927a1361d4e24c5bcba88cfa2ad63bc68 --- /dev/null +++ b/DetectorDescription/DetDescrCnvSvc/DetDescrCnvSvc/DetDescrConverter.h @@ -0,0 +1,64 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/*************************************************************************** + Detector description conversion service package + ----------------------------------------------- + Copyright (C) 2002 by ATLAS Collaboration + ***************************************************************************/ + +//<doc><file> $Id: DetDescrConverter.h,v 1.6 2008-12-14 02:24:44 ssnyder Exp $ +//<version> $Name: not supported by cvs2svn $ + +#ifndef DETDESCRCNVSVC_DETDESCRCONVERTER_H +# define DETDESCRCNVSVC_DETDESCRCONVERTER_H + +//<<<<<< INCLUDES >>>>>> + +#include "GaudiKernel/Converter.h" + +//<<<<<< PUBLIC TYPES >>>>>> + +class DetDescrCnvSvc; +class DetDescrAddress; +class DataObject; +class StoreGateSvc; + +// Abstract factory to create the converter +template <class TYPE> class CnvFactory; + +//<<<<<< CLASS DECLARATIONS >>>>>> + +class DetDescrConverter: public Converter { + +public: + virtual StatusCode initialize(); + virtual StatusCode finalize(); + virtual StatusCode createObj(IOpaqueAddress* pAddr, DataObject*& pObj) = 0; + virtual StatusCode fillObjRefs(IOpaqueAddress* pAddr, DataObject* pObj); + virtual StatusCode createRep(DataObject* pObj, IOpaqueAddress*& pAddr); + virtual StatusCode fillRepRefs(IOpaqueAddress* pAddr, DataObject* pObj); + + /// Storage type for all DetDescrConverters + static long storageType(); + +protected: + + DetDescrConverter(const CLID& myCLID, ISvcLocator* svcloc); +// StatusCode addToDetStore(const CLID& clid, const std::string& name) const; + + /// Provide access to Detector Store + StoreGateSvc * detStore() const; + + +private: + DetDescrCnvSvc* m_cnvSvc; + //const CLID m_CLID; +}; + + +//<<<<<< INLINE PUBLIC FUNCTIONS >>>>>> +//<<<<<< INLINE MEMBER FUNCTIONS >>>>>> + +#endif // DETDESCRCNVSVC_DETDESCRCONVERTER_H diff --git a/DetectorDescription/DetDescrCnvSvc/DetDescrCnvSvc/IDetDescrCnvSvc.h b/DetectorDescription/DetDescrCnvSvc/DetDescrCnvSvc/IDetDescrCnvSvc.h new file mode 100755 index 0000000000000000000000000000000000000000..ad13f82f9409bdc983239bb92d1f7f89cc1996b9 --- /dev/null +++ b/DetectorDescription/DetDescrCnvSvc/DetDescrCnvSvc/IDetDescrCnvSvc.h @@ -0,0 +1,47 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/*************************************************************************** + Detector description conversion service package + ----------------------------------------------- + Copyright (C) 2002 by ATLAS Collaboration + ***************************************************************************/ + +//<doc><file> $Id: IDetDescrCnvSvc.h,v 1.1 2002-07-10 13:44:41 schaffer Exp $ +//<version> $Name: not supported by cvs2svn $ + +#ifndef DETDESCRCNVSVC_IDETDESCRCNVSVC_H +# define DETDESCRCNVSVC_IDETDESCRCNVSVC_H + +//<<<<<< INCLUDES >>>>>> + +#include "GaudiKernel/IInterface.h" +#include "GaudiKernel/IConversionSvc.h" +#include "GaudiKernel/StatusCode.h" +#include <string> + +//<<<<<< PUBLIC DEFINES >>>>>> +//<<<<<< PUBLIC CONSTANTS >>>>>> +//<<<<<< PUBLIC TYPES >>>>>> + +static const InterfaceID IID_IDetDescrCnvSvc(340,0,0) ; + +//<<<<<< PUBLIC VARIABLES >>>>>> +//<<<<<< PUBLIC FUNCTIONS >>>>>> +//<<<<<< CLASS DECLARATIONS >>>>>> + +class IDetDescrCnvSvc : virtual public IConversionSvc +{ + +public: + + virtual StatusCode addToDetStore(const CLID& clid, std::string& name) = 0; + +}; + +//<<<<<< INLINE PUBLIC FUNCTIONS >>>>>> +//<<<<<< INLINE MEMBER FUNCTIONS >>>>>> + +#endif // DETDESCRCNVSVC_IDETDESCRCNVSVC_H + diff --git a/DetectorDescription/DetDescrCnvSvc/cmt/requirements b/DetectorDescription/DetDescrCnvSvc/cmt/requirements new file mode 100755 index 0000000000000000000000000000000000000000..0c70796eda8b15039b790cca25d6ad8b00b4dbc8 --- /dev/null +++ b/DetectorDescription/DetDescrCnvSvc/cmt/requirements @@ -0,0 +1,16 @@ +package DetDescrCnvSvc + +author RD Schaffer <R.D.Schaffer@cern.ch> + +use AtlasPolicy AtlasPolicy-* +use GaudiInterface GaudiInterface-* External + +private +use StoreGate StoreGate-* Control +end_private + +apply_pattern dual_use_library files=" *.cxx " + +# Install job options +apply_pattern declare_joboptions files="-s=../share *.py" +apply_pattern declare_python_modules files="*.py" diff --git a/DetectorDescription/DetDescrCnvSvc/python/DetStoreConfig.py b/DetectorDescription/DetDescrCnvSvc/python/DetStoreConfig.py new file mode 100755 index 0000000000000000000000000000000000000000..bd28efe427e00b512c96fa5149459594d1be8461 --- /dev/null +++ b/DetectorDescription/DetDescrCnvSvc/python/DetStoreConfig.py @@ -0,0 +1,36 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# +# Joboptions for bootstrapping the loading of the DetectorStore with +# the DetDescrCnvSvc +# + +def _setupDetStoreConfig(): + from AthenaCommon.AppMgr import theApp + from AthenaCommon.AppMgr import ServiceMgr as svcMgr + + # first, make sure we create a DetectorStore + import AthenaCommon.AtlasUnixStandardJob + #theApp.CreateSvc += [ svcMgr.DetectorStore.getFullName() ] + + # now configure the Detector Description converter service + from DetDescrCnvSvc.DetDescrCnvSvcConf import DetDescrCnvSvc + # Create DetDescrCnvSvc and add to SvcMgr + # Specify primary Identifier dictionary to be used + svcMgr += DetDescrCnvSvc(IdDictName = "IdDictParser/ATLAS_IDS.xml") + + #theApp.CreateSvc += [ svcMgr.DetDescrCnvSvc.getFullName() ] + svcMgr.EventPersistencySvc.CnvServices += [ "DetDescrCnvSvc" ] + + # Always include the IdDict jobOptions + from AthenaCommon.Include import include + include( "IdDictDetDescrCnv/IdDictDetDescrCnv_joboptions.py" ) + + pass + +# run this function at module's load +_setupDetStoreConfig() + +# avoid running this method multiple times +del _setupDetStoreConfig + diff --git a/DetectorDescription/DetDescrCnvSvc/python/__init__.py b/DetectorDescription/DetDescrCnvSvc/python/__init__.py new file mode 100755 index 0000000000000000000000000000000000000000..74583d364ec2ca794156596c7254d9b234a940c6 --- /dev/null +++ b/DetectorDescription/DetDescrCnvSvc/python/__init__.py @@ -0,0 +1,2 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + diff --git a/DetectorDescription/DetDescrCnvSvc/share/DetStore.py b/DetectorDescription/DetDescrCnvSvc/share/DetStore.py new file mode 100755 index 0000000000000000000000000000000000000000..f232011fb67cf4c938a4b406d74a18089366d4c8 --- /dev/null +++ b/DetectorDescription/DetDescrCnvSvc/share/DetStore.py @@ -0,0 +1,25 @@ +# +# Joboptions for bootstrapping the loading of the DetectorStore with +# the DetDescrCnvSvc +# + +# Adds and instantiates the DetDescrCnvSvc service. It is assumed that +# a view of the application manager is available as 'theApp' + + +from AthenaCommon.AppMgr import theApp +theApp.Dlls += [ 'DetDescrCnvSvc' ] +theApp.ExtSvc += [ 'DetDescrCnvSvc' ] + +# Create service and add to list of conversion services +# +# NOTE: the following does not yet work for the detector store +# theApp.ExtSvc += { "DetPersistencySvc/DetectorPersistencySvc", +# "DetDescrCnvSvc" }; +#DetectorPersistencySvc.CnvServices += { "DetDescrCnvSvc" }; +DetDescrCnvSvc = Service( "DetDescrCnvSvc" ) +EventPersistencySvc.CnvServices = [ "DetDescrCnvSvc" ] + +# Specify primary Identifier dictionary to be used +DetDescrCnvSvc.IdDictName = "IdDictParser/ATLAS_IDS.xml"; + diff --git a/DetectorDescription/DetDescrCnvSvc/share/DetStore_joboptions.py b/DetectorDescription/DetDescrCnvSvc/share/DetStore_joboptions.py new file mode 100755 index 0000000000000000000000000000000000000000..d4955980d316cc7e89af8419f41dce7fcf21e0a9 --- /dev/null +++ b/DetectorDescription/DetDescrCnvSvc/share/DetStore_joboptions.py @@ -0,0 +1,25 @@ +# +# Joboptions for bootstrapping the loading of the DetectorStore with +# the DetDescrCnvSvc +# +# DLLs +theApp.Dlls += [ "DetDescrCnvSvc" ] + +# Must create the service +theApp.CreateSvc += [ "DetDescrCnvSvc" ] + +# Set DetDescrCnvSvc to be a proxy/address provider +#ProxyProviderSvc.ProviderNames += { "DetDescrCnvSvc" }; +EventPersistencySvc = Service( "EventPersistencySvc" ) +EventPersistencySvc.CnvServices += [ "DetDescrCnvSvc" ] + +# Specify primary Identifier dictionary to be used +DetDescrCnvSvc = Service( "DetDescrCnvSvc" ) +DetDescrCnvSvc.IdDictName = "IdDictParser/ATLAS_IDS.xml" + +# Specify the tag to be used +# DetDescrCnvSvc.IdDictGlobalTag = "initial_layout" + +# Always include the IdDict jobOptions +include( "IdDictDetDescrCnv/IdDictDetDescrCnv_joboptions.py" ) + diff --git a/DetectorDescription/DetDescrCnvSvc/src/DetDescrAddress.cxx b/DetectorDescription/DetDescrCnvSvc/src/DetDescrAddress.cxx new file mode 100755 index 0000000000000000000000000000000000000000..bbff6ef758d62df58da1764ad694068a3120e8a2 --- /dev/null +++ b/DetectorDescription/DetDescrCnvSvc/src/DetDescrAddress.cxx @@ -0,0 +1,63 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +//==================================================================== +// DetDescrAddress implementation +//-------------------------------------------------------------------- +// +// Package : DetDescrCnvSvc +// +// Description: Detector description address implementation +// +// Author : RD Schaffer +// created : June 2002 +// History : +//==================================================================== + +//own +#include "DetDescrCnvSvc/DetDescrAddress.h" + +// Framework include files +#include "GaudiKernel/GenericAddress.h" +#include "GaudiKernel/MsgStream.h" + +// Externals +extern long DetDescr_StorageType; + + +/// Standard Constructor +DetDescrAddress::DetDescrAddress(const CLID& clid, +const std::string& fname , const std::string& cname) + : GenericAddress(DetDescr_StorageType, clid,fname,cname) +{ +} + +DetDescrAddress::DetDescrAddress(const CLID& clid) + : GenericAddress(DetDescr_StorageType, clid,"","") +{ + +} + +const std::string& +DetDescrAddress::payload() const +{ + return m_payload; +} + +StatusCode +DetDescrAddress::toString(std::string& refString) const +{ + refString += m_payload; + return StatusCode::SUCCESS; +} + +//------------------------------------------------------------------------- + +StatusCode +DetDescrAddress::fromString(const std::string& stringifiedIOA) +{ + m_payload = stringifiedIOA; + return StatusCode::SUCCESS; +} + diff --git a/DetectorDescription/DetDescrCnvSvc/src/DetDescrCnvSvc.cxx b/DetectorDescription/DetDescrCnvSvc/src/DetDescrCnvSvc.cxx new file mode 100755 index 0000000000000000000000000000000000000000..f864d725befc74f967d392f5c8ff6951ab183c6d --- /dev/null +++ b/DetectorDescription/DetDescrCnvSvc/src/DetDescrCnvSvc.cxx @@ -0,0 +1,315 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// Include files +#include "DetDescrCnvSvc/DetDescrCnvSvc.h" +#include "DetDescrCnvSvc/IDetDescrCnvSvc.h" +//#include "AthenaServices/AthenaConversionSvc.h" +#include "DetDescrCnvSvc/DetDescrAddress.h" + + +#include "GaudiKernel/SvcFactory.h" +#include "GaudiKernel/CnvFactory.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/IConversionSvc.h" +#include "GaudiKernel/IConverter.h" +#include "GaudiKernel/IDataSelector.h" +#include "GaudiKernel/IOpaqueAddress.h" + +#include "StoreGate/StoreGate.h" +// #include "SGTools/TransientAddress.h" + +//External definitions +long DetDescr_StorageType=0x44; + +//------------------------------------------------------------------------- + +/// Standard constructor +DetDescrCnvSvc::DetDescrCnvSvc(const std::string& name, ISvcLocator* svc) + : + ConversionSvc( name, svc, DetDescr_StorageType), + m_detStore(0), + m_decodeIdDict(true), + m_idDictFromRDB(false), + m_fromRoot(false), + m_fromNova(false), + m_detElemsfromDetNodes(false), + m_compact_ids_only(false), + m_do_checks(false), + m_do_neighbours(true) +{ + declareProperty("DetectorManagers", m_detMgrs); + declareProperty("DetectorNodes", m_detNodes ); + declareProperty("DecodeIdDict", m_decodeIdDict ); + declareProperty("IdDictName", m_idDictName ); + declareProperty("IdDictFromRDB", m_idDictFromRDB ); + declareProperty("IdDictGlobalTag", m_idDictGlobalTag ); + declareProperty("ReadFromROOT", m_fromRoot ); + declareProperty("ReadFromNova", m_fromNova ); + declareProperty("InitDetElemsFromGeoModel", m_detElemsfromDetNodes); + declareProperty("CompactIDsOnly", m_compact_ids_only); + declareProperty("DoIdChecks", m_do_checks); + declareProperty("DoInitNeighbours", m_do_neighbours); + + declareProperty("AtlasIDFileName", m_idDictATLASName); + declareProperty("InDetIDFileName", m_idDictInDetName); + declareProperty("LArIDFileName", m_idDictLArName); + declareProperty("TileIDFileName", m_idDictTileName); + declareProperty("CaloIDFileName", m_idDictLVL1Name); + declareProperty("MuonIDFileName", m_idDictMuonName); + declareProperty("HighVoltageIDFileName", m_idDictLArHighVoltageName); + declareProperty("LArElectrodeIDFileName", m_idDictLArElectrodeName); + declareProperty("ForwardIDFileName", m_idDictForwardName); + declareProperty("FullAtlasNeighborsFileName", m_fullAtlasNeighborsName); + declareProperty("FCAL2DNeighborsFileName", m_fcal2dNeighborsName); + declareProperty("FCAL3DNeighborsNextFileName", m_fcal3dNeighborsNextName); + declareProperty("FCAL3DNeighborsPrevFileName", m_fcal3dNeighborsPrevName); + declareProperty("TileNeighborsFileName", m_tileNeighborsName); + +} + +//------------------------------------------------------------------------- + +/// Standard Destructor +DetDescrCnvSvc::~DetDescrCnvSvc() { +} + +//------------------------------------------------------------------------- + +/// Identify interfaces to which this service is responsive +StatusCode +DetDescrCnvSvc::queryInterface(const InterfaceID& riid, void** ppvInterface) { + if ( riid == IConversionSvc::interfaceID() ) { + *ppvInterface = (IConversionSvc*)this; + } + else if ( riid == IDetDescrCnvSvc::interfaceID() ) { + *ppvInterface = (IDetDescrCnvSvc*)this; + } + else { + return ConversionSvc::queryInterface( riid, ppvInterface ); + } + addRef(); + return StatusCode::SUCCESS; +} + +//------------------------------------------------------------------------- + +/// Initialize the service. +StatusCode +DetDescrCnvSvc::initialize() { + + MsgStream log(msgSvc(),name()); + StatusCode status = ConversionSvc::initialize(); + if (status.isFailure()) { + log << MSG::FATAL << "Unable to initialize ConversionSvc !" << endreq; + return StatusCode::FAILURE; + } + + log << MSG::INFO << " initializing " <<endreq ; + + // get DetectorStore service + status = service("DetectorStore", m_detStore); + if (status.isFailure()) { + log << MSG::FATAL << "DetectorStore service not found !" << endreq; + return StatusCode::FAILURE; + } else { + log << MSG::INFO << "Found DetectorStore service" << endreq; + } + + // fill in the Addresses for Transient Detector Store objects + + log << MSG::INFO << " filling proxies for detector managers " <<endreq ; + + // Obsolete --- this CLID no longer exists + //status = addToDetStore(2512, "InDetMgr"); + //if (status != StatusCode::SUCCESS) return status; + // now LArGeoModel does it itself + // status = addToDetStore(2741, "LArMgr"); + // if (status != StatusCode::SUCCESS) return status; + // now TileGeoModel is does it itself + // status = addToDetStore(2941, "TileMgr"); + // if (status != StatusCode::SUCCESS) return status; + // Obsolete --- this CLID no longer exists + //status = addToDetStore(4060, "MuonMgr"); + //if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(117659265, "CaloTTMgr"); + if (status != StatusCode::SUCCESS) return status; + + + status = addToDetStore(4548337, "CaloMgr"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(241807251, "CaloSuperCellMgr"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(125856940, "CaloIdManager"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(79554919, "LArIdManager"); + if (status != StatusCode::SUCCESS) return status; + + + // IdDict: + status = addToDetStore(2411, "IdDict"); + if (status != StatusCode::SUCCESS) return status; + + // IdHelpers + status = addToDetStore(164875623, "AtlasID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(2516, "PixelID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(2517, "SCT_ID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(2518, "TRT_ID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(129452393, "SiliconID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(163583365, "LArEM_ID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(99488227, "LArEM_SuperCell_ID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(3870484, "LArHEC_ID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(254277678, "LArHEC_SuperCell_ID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(45738051, "LArFCAL_ID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(12829437, "LArFCAL_SuperCell_ID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(79264204, "LArMiniFCAL_ID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(158698068, "LArOnlineID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(38321944, "TTOnlineID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(115600394, "LArOnline_SuperCellID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(27863673, "LArHVLineID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(80757351, "LArElectrodeID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(2901, "TileID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(49557789, "Tile_SuperCell_ID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(2902, "TileHWID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(2903, "TileTBID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(4170, "MDTIDHELPER"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(4171, "CSCIDHELPER"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(4172, "RPCIDHELPER"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(4173, "TGCIDHELPER"); + if (status != StatusCode::SUCCESS) return status; + // for nSW + status = addToDetStore(4174, "STGCIDHELPER"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(4175, "MMIDHELPER"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(108133391, "CaloLVL1_ID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(123500438, "CaloCell_ID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(128365736, "CaloCell_SuperCell_ID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(167756483, "CaloDM_ID"); + if (status != StatusCode::SUCCESS) return status; + status = addToDetStore(190591643, "ZdcID"); + if (status != StatusCode::SUCCESS) return status; + + return status; +} + +//------------------------------------------------------------------------- + +StoreGateSvc * +DetDescrCnvSvc::detStore() const +{ + return (m_detStore); +} + +//------------------------------------------------------------------------- + +/// Create a Generic address using explicit arguments to identify a single object. +StatusCode DetDescrCnvSvc::createAddress(long /* svc_type */, + const CLID& /* clid */, + const std::string* /* par */, + const unsigned long* /* ip */, + IOpaqueAddress*& refpAddress) { + refpAddress = 0; + return StatusCode::FAILURE; +} + +//------------------------------------------------------------------------- + +StatusCode DetDescrCnvSvc::createAddress( long /* svc_type */, + const CLID& clid, + const std::string& refAddress, + IOpaqueAddress*& refpAddress) +{ + try { + refpAddress = new DetDescrAddress(clid); + DetDescrAddress* ddAddr; + ddAddr = dynamic_cast<DetDescrAddress*> (refpAddress); + if(!ddAddr) { + MsgStream log(msgSvc(),name()); + log << MSG::FATAL << "Could not cast to DetDescrAddress." << endreq; + return StatusCode::FAILURE; + } + ddAddr->fromString(refAddress); + } + catch(...) { + refpAddress = 0; + } + return (refpAddress != 0) ? StatusCode::SUCCESS : StatusCode::FAILURE; +} + +//------------------------------------------------------------------------- + +StatusCode DetDescrCnvSvc::convertAddress( const IOpaqueAddress* pAddress, + std::string& refAddress) +{ + const DetDescrAddress* addr = dynamic_cast<const DetDescrAddress*>(pAddress); + if (!addr) return StatusCode::FAILURE; + return addr->toString(refAddress); +} + + +//------------------------------------------------------------------------- + +StatusCode +DetDescrCnvSvc::addToDetStore(const CLID& clid, const std::string& name) const +{ + + MsgStream log(messageService(), "DetDescrCnvSvc"); + + // Based on input parameters, create StoreGate proxies with + // DetDescrAddresses in the detector store for the different + // detectors. + + // fill in the Addresses for Transient Detector Store objects + + DetDescrAddress * addr; + addr = new DetDescrAddress(clid, name, name); + StatusCode status = m_detStore->recordAddress(addr); + if (status != StatusCode::SUCCESS) { + log << MSG::INFO + << " unable to fill address for " << (*addr->par()) + << " with CLID " << addr->clID() + << " and storage type " << addr->svcType() + << " to detector store " <<endreq ; + return StatusCode::FAILURE; + } + else { + unsigned int st = addr->svcType(); + log << MSG::INFO + << " filling address for " << (*addr->par()) + << " with CLID " << addr->clID() + << " and storage type " << st + << " to detector store " <<endreq ; + } + return status; +} + diff --git a/DetectorDescription/DetDescrCnvSvc/src/DetDescrConverter.cxx b/DetectorDescription/DetDescrCnvSvc/src/DetDescrConverter.cxx new file mode 100755 index 0000000000000000000000000000000000000000..c634fc43a84a187fbced284b1361e3ac5acaec16 --- /dev/null +++ b/DetectorDescription/DetDescrCnvSvc/src/DetDescrConverter.cxx @@ -0,0 +1,149 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/*************************************************************************** + Detector description conversion service package + ----------------------------------------------- + Copyright (C) 2002 by ATLAS Collaboration + ***************************************************************************/ + +//<doc><file> $Id: DetDescrConverter.cxx,v 1.6 2008-12-14 02:24:44 ssnyder Exp $ +//<version> $Name: not supported by cvs2svn $ + +//<<<<<< INCLUDES >>>>>> + +#include "DetDescrCnvSvc/DetDescrConverter.h" +#include "DetDescrCnvSvc/DetDescrAddress.h" +#include "DetDescrCnvSvc/DetDescrCnvSvc.h" +#include "GaudiKernel/MsgStream.h" +// #include "GaudiKernel/CnvFactory.h" +// #include "GaudiKernel/ContainedObject.h" +// #include "GaudiKernel/DataObject.h" + +//<<<<<< PRIVATE DEFINES >>>>>> +//<<<<<< PRIVATE CONSTANTS >>>>>> +//<<<<<< PRIVATE TYPES >>>>>> +//<<<<<< PRIVATE VARIABLE DEFINITIONS >>>>>> +//<<<<<< PUBLIC VARIABLE DEFINITIONS >>>>>> +//<<<<<< CLASS STRUCTURE INITIALIZATION >>>>>> +//<<<<<< PRIVATE FUNCTION DEFINITIONS >>>>>> +//<<<<<< PUBLIC FUNCTION DEFINITIONS >>>>>> +//<<<<<< MEMBER FUNCTION DEFINITIONS >>>>>> + +StatusCode +DetDescrConverter::initialize() +{ + // Just call parent initialize + return Converter::initialize(); +} + +StatusCode +DetDescrConverter::finalize() +{ + // Just call parent finalize + return Converter::finalize(); +} + + +StatusCode +DetDescrConverter::fillObjRefs(IOpaqueAddress* /*pAddr*/, DataObject* /*pObj*/) +{ + return StatusCode::SUCCESS; +} + +StatusCode +DetDescrConverter::createRep(DataObject* /*pObj*/, IOpaqueAddress*& /*pAddr*/) +{ + return StatusCode::SUCCESS; +} + +StatusCode +DetDescrConverter::fillRepRefs(IOpaqueAddress* /*pAddr*/, DataObject* /*pObj*/) +{ + return StatusCode::SUCCESS; +} + +long +DetDescrConverter::storageType() +{ + return DetDescr_StorageType; +} + +// StatusCode +// DetDescrConverter::addToDetStore(const CLID& clid, const std::string& name) const +// { + +// StatusCode status = StatusCode::SUCCESS; +// MsgStream log(messageService(), "DetDescrConverter"); +// log << MSG::DEBUG << "in addToDetStore" << endreq; + +// if(!m_cnvSvc) { +// log << MSG::INFO << " Unable to add address for " << name +// << " with CLID " << clid +// << " to detector store " <<endreq; +// return StatusCode::FAILURE; +// } +// else { +// m_cnvSvc->addToDetStore(clid, name); +// } +// return status; +// } + + +// d_Ref_Any +// DetDescrConverter::getRef(IOpaqueAddress* pAddr) const { +// d_Ref_Any retVal; +// DetDescrAddress *nAddr = dynamic_cast<DetDescrAddress*>(pAddr); +// if (0 != nAddr) { +// nAddr->getRef(retVal); +// // check for Gaudi NULL (different than ODMG NULL) here... +// if (65535==*((unsigned short*)(&retVal))) { +// retVal.clear(); +// } +// } +// return retVal; +// } + +// DetDescrAddress* +// DetDescrConverter::newDetDescrAddress(const d_Ref_Any& outRef) const { +// return new DetDescrAddress(m_CLID, "", "", outRef); +// } + +// d_Ref_Any +// DetDescrConverter::where() const { +// return m_cnvSvc->getClustering(m_CLID); +// } + +DetDescrConverter::DetDescrConverter(const CLID& myCLID, ISvcLocator* svcloc) : + Converter(DetDescr_StorageType, myCLID, svcloc) + //m_CLID(myCLID) +{ + + IInterface* toCnvSvc = 0; + m_cnvSvc = 0; + StatusCode status = serviceLocator() + ->getService("DetDescrCnvSvc", + IConversionSvc::interfaceID(), + toCnvSvc); + if (status.isSuccess()) { + m_cnvSvc = dynamic_cast<DetDescrCnvSvc*>(toCnvSvc); + } + if (0 == m_cnvSvc) { + // cout<<"DMM: ERROR--converter could not find DetDescrCnvSvc"<<endl; + } +} + + + +/// Provide access to Detector Store +StoreGateSvc * DetDescrConverter::detStore() const +{ + if(m_cnvSvc) { + return (m_cnvSvc->detStore()); + } + else { + return (0); + } +} + diff --git a/DetectorDescription/DetDescrCnvSvc/src/components/DetDescrCnvSvc_entries.cxx b/DetectorDescription/DetDescrCnvSvc/src/components/DetDescrCnvSvc_entries.cxx new file mode 100755 index 0000000000000000000000000000000000000000..e234f514134eecfecb310503f0d18d309f02531e --- /dev/null +++ b/DetectorDescription/DetDescrCnvSvc/src/components/DetDescrCnvSvc_entries.cxx @@ -0,0 +1,12 @@ +//==================================================================== + +#include "GaudiKernel/DeclareFactoryEntries.h" +#include "DetDescrCnvSvc/DetDescrCnvSvc.h" + +DECLARE_SERVICE_FACTORY( DetDescrCnvSvc ) + +DECLARE_FACTORY_ENTRIES ( DetDescrCnvSvc ) { + DECLARE_SERVICE ( DetDescrCnvSvc ) +} + + diff --git a/DetectorDescription/DetDescrCnvSvc/src/components/DetDescrCnvSvc_load.cxx b/DetectorDescription/DetDescrCnvSvc/src/components/DetDescrCnvSvc_load.cxx new file mode 100755 index 0000000000000000000000000000000000000000..c919d44cb438224abd0b7d6efa504f53d7137ba9 --- /dev/null +++ b/DetectorDescription/DetDescrCnvSvc/src/components/DetDescrCnvSvc_load.cxx @@ -0,0 +1,5 @@ +//==================================================================== + +#include "GaudiKernel/LoadFactoryEntries.h" + +LOAD_FACTORY_ENTRIES( DetDescrCnvSvc )