ATLAS Offline Software
Loading...
Searching...
No Matches
LUCID_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
8
11#include "GaudiKernel/IService.h"
12#include "GaudiKernel/ISvcLocator.h"
13#include "GaudiKernel/MsgStream.h"
15
17
20#include "SGTools/DataProxy.h"
21
23 const std::string& name,
24 const IInterface* parent):
25 GeoModelTool(type, name, parent),
26 m_manager(nullptr)
27{
28}
29
31
33
34 MsgStream log(msgSvc(), name());
35
36 ATH_MSG_INFO("Building LUCID geometry");
37
38 ServiceHandle<IGeoDbTagSvc> geoDbTag("GeoDbTagSvc", name());
39 ATH_CHECK( geoDbTag.retrieve() );
40
41 ServiceHandle<IRDBAccessSvc> raccess("RDBAccessSvc", name());
42 ATH_CHECK( raccess.retrieve() );
43
44 const std::string AtlasVersion = geoDbTag->atlasVersion();
45 const std::string LucidVersion = raccess->getChildTag("LUCID",AtlasVersion,"ATLAS");
46
47 if(LucidVersion.empty()) {
48 ATH_MSG_DEBUG("LUCID is not part of the selected ATLAS geometry. Skipping");
49 return StatusCode::SUCCESS;
50 }
51
52 GeoModelExperiment* theExpt = nullptr;
53 ATH_CHECK( detStore()->retrieve(theExpt, "ATLAS") );
54
55 if(nullptr == m_detector) {
56
57 GeoPhysVol* world = &*theExpt->getPhysVol();
58
59 LUCID_DetectorFactory theLUCID_Factory(detStore().get(),raccess.get());
60
61 theLUCID_Factory.create(world);
62 m_manager = theLUCID_Factory.getDetectorManager();
63 theExpt->addManager(m_manager);
64
65 ATH_CHECK( detStore()->record(m_manager, m_manager->getName()) );
66 return StatusCode::SUCCESS;
67 }
68
69 return StatusCode::FAILURE;
70}
71
73
74 SG::DataProxy* proxy = detStore()->proxy(ClassID_traits<LUCID_DetectorManager>::ID(),m_manager->getName());
75
76 if(proxy) {
77 proxy->reset();
78 m_manager = nullptr;
79 }
80
81 proxy = detStore()->proxy(ClassID_traits<GeoBorderSurfaceContainer>::ID(), "LUCID", false);
82
83 if(proxy) {
84 proxy->reset();
85 }
86
87 return StatusCode::SUCCESS;
88}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(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...
Definition of the abstract IRDBAccessSvc interface.
GeoPhysVol * getPhysVol()
Destructor.
void addManager(const GeoVDetectorManager *)
GeoVDetectorManager * m_detector
virtual const LUCID_DetectorManager * getDetectorManager() const
virtual void create(GeoPhysVol *)
virtual ~LUCID_DetectorTool() override final
const LUCID_DetectorManager * m_manager
virtual StatusCode create() override final
virtual StatusCode clear() override final
LUCID_DetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130