ATLAS Offline Software
Loading...
Searching...
No Matches
TileDetectorTool.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/*
6 * Updates:
7 * - 2021, Riccardo Maria BIANCHI <riccardo.maria.bianchi@cern.ch>
8 * * Added TileDetectorFactoryLite to load the Tile geomnetry from SQLite
9 */
10
12#include "TileDetectorFactory.h"
13#include "TileAtlasFactory.h"
14#include "TileTBFactory.h"
16
20
24
27#include "GaudiKernel/IService.h"
28#include "GaudiKernel/MsgStream.h"
31
32#include "GeoModelRead/ReadGeoModel.h"
33
36#include "SGTools/DataProxy.h"
37
38
40 const std::string& name,
41 const IInterface* parent)
42 : GeoModelTool(type, name, parent)
43 , m_switches(false,true)
44 , m_not_locked(true)
45 , m_useNewFactory(true)
46 , m_geometryConfig("FULL")
47 , m_manager(0)
48{
49 declareProperty("UseNewFactory", m_useNewFactory);
50 declareProperty("GeometryConfig",m_geometryConfig);
51 declareProperty("TestBeam", m_switches.testBeam);
52 // declareProperty("AddPlatesToCellVolume", m_switches.addPlatesToCell); to make user aware that the value is taken from DB rather from JO
53 declareProperty("Ushape",m_switches.uShape);
54 declareProperty("Glue",m_switches.glue);
55 declareProperty("PVT",m_switches.pvt);
56 declareProperty("Steel",m_switches.steel);
57 declareProperty("CsTube",m_switches.csTube);
58 declareProperty("CrackOption",m_switches.crackOption);
59}
60
61
65
66
67void TileDetectorTool::setSwitch(int & param, int value, const char * name)
68{
69 if (param < 0) {
70 param = value;
71 ATH_MSG_INFO(name << " parameter from database is: " << param);
72 } else {
73 if (param != value) {
74 ATH_MSG_WARNING("Overriding " << name << " value from DB by value from jobOptions, using "
75 << param << " instead of " << value);
76 } else {
77 ATH_MSG_INFO(name << " parameter from jobOptions is: " << param);
78 }
79 }
80}
81
82
84{
85 MsgStream log(msgSvc(), name());
86 ATH_MSG_INFO(" Entering TileDetectorTool::create()");
87
88 // Get the detector configuration
89 SmartIF<IGeoModelSvc> geoModel{service("GeoModelSvc")};
90 ATH_CHECK(geoModel.isValid());
91
92 std::string atlasVersion = geoModel->atlasVersion();
93 std::string tileVersion = geoModel->tileVersionOverride();
94
95 std::string versionTag = tileVersion.empty()? atlasVersion : tileVersion;
96 std::string versionNode = tileVersion.empty()? "ATLAS" : "TileCal";
97
98 if (versionTag == "AUTO") {
99 versionTag = "TileCal-00";
100 versionNode = "TileCal";
101 }
102 if (atlasVersion.compare(0,9,"ATLAS-CTB") == 0 || tileVersion.compare(0,6,"TileTB") == 0) {
103 ATH_MSG_INFO("CTB geometry detected: " << atlasVersion << " " << tileVersion);
104 m_switches.testBeam = true;
105 }
106
107 //Locate the top level experiment node
108 GeoModelExperiment* theExpt = nullptr;
109 CHECK( detStore()->retrieve(theExpt, "ATLAS") );
110
111 if ( 0 == m_detector ) {
112 // Get the detector configuration.
113 ServiceHandle<IGeoDbTagSvc> geoDbTag("GeoDbTagSvc",name());
114 ATH_CHECK(geoDbTag.retrieve());
115
116 // Get the 'new' accessSvc to get parameters / DB data from the DD SQLite input file.
117 ServiceHandle<IRDBAccessSvc> accessSvc(geoDbTag->getParamSvcName(),name());
118 ATH_CHECK(accessSvc.retrieve());
119
120 // Get the SQLite reader, if specified in the jobOption
121 GeoModelIO::ReadGeoModel* sqliteReader = geoDbTag->getSqliteReader();
122
123 // Get the Tile 'DDDB' and 'DetDescr' managers
124 // Note: we need to pass the raw IRDBAccess* to the TildDddbManager constructor.
125 bool sqliteInput = false;
126 if (sqliteReader) sqliteInput = true;
127 TileDddbManager_ptr dbManager(new TileDddbManager(&*accessSvc,versionTag,versionNode, sqliteInput));
128 m_manager = new TileDetDescrManager(dbManager);
129
130 // check what factory can be used
131 if (0==dbManager->GetNumberOfEnv() && m_useNewFactory) {
132 ATH_MSG_WARNING("New TileAtlasFactory can not be used because TileGlobals do not exist in Database");
133 ATH_MSG_WARNING("Use old TileDetectorFactory instead");
134 m_useNewFactory = false;
135 }
136
137 CHECK( initIds() );
138
139 m_switches.addPlatesToCell = dbManager->addPlatesToCell();
140 setSwitch(m_switches.uShape, dbManager->uShape(), "Ushape");
141 setSwitch(m_switches.glue, dbManager->glue(), "Glue");
142 setSwitch(m_switches.pvt, dbManager->PVT(), "PVT");
143 setSwitch(m_switches.steel, dbManager->steel(), "Steel");
144 setSwitch(m_switches.csTube, dbManager->csTube(), "CsTube");
145
146 m_not_locked = false;
147
148 GeoPhysVol *world=&*theExpt->getPhysVol();
149
150 // build the geometry from the standalone SQLite file
151 if (sqliteReader) {
152 TileDetectorFactoryLite theTileFactoryLite(detStore().operator->(),
153 m_manager,
154 sqliteReader,
155 accessSvc.operator->(),
157 &log,
158 true);
159 theTileFactoryLite.create(world);
160 } else {
161 // build the geometry from the Oracle-based GeometryDB
162 if (m_switches.testBeam) {
163 // TileTBFactory is not thread-safe. But since this code should only be
164 // ever called once (and this is "only" for test beam geometry), we use
165 // this rather ugly hack to silence the thread-checker warnings:
166 [[maybe_unused]] static const bool do_once ATLAS_THREAD_SAFE = [&]() ATLAS_NOT_THREAD_SAFE {
167 TileCablingService::getInstance_nc()->setTestBeam(true);
168 TileTBFactory theTileTBFactory = TileTBFactory(detStore().operator->(),m_manager,m_switches,&log);
169 theTileTBFactory.create(world);
170 return true;
171 }();
172
173 } else if (m_useNewFactory) {
174 std::vector<GeoPhysVol *> volumePtrs;
175 std::vector<double> volumePositions;
176 TileAtlasFactory theTileFactory(detStore().operator->(),m_manager,m_switches,m_volumes,volumePtrs,volumePositions,&log,m_geometryConfig=="FULL");
177 theTileFactory.create(world);
178
179 } else {
180 TileDetectorFactory theTileFactory(detStore().operator->(),m_manager,m_switches,&log);
181 theTileFactory.create(world);
182 }
183 } // end of building the geometry from the GeometryDB
184 ATH_MSG_DEBUG( "The Tile raw geometry has been built.");
185
187
188 // Register the TileDetDescrManager instance with the Transient Detector Store
189 CHECK( detStore()->record(m_manager, m_manager->getName()) );
190 theExpt->addManager(m_manager);
191
192 // For reco jobs: release DB manager. Cannot do it here for simulation jobs, they
193 // release DB manager as part of global GeoModel release
194 if (m_geometryConfig=="RECO")
195 m_manager->releaseDbManager();
196
197 return StatusCode::SUCCESS;
198
199 }
200
201 return StatusCode::FAILURE;
202}
203
204
206{
207 SG::DataProxy* proxy = detStore()->proxy(ClassID_traits<TileDetDescrManager>::ID(),m_manager->getName());
208 if (proxy) {
209 proxy->reset();
210 m_manager = 0;
211 }
212 return StatusCode::SUCCESS;
213}
214
215
217{
218 const TileID* tileID;
219 const CaloCell_ID* cellID;
220 const TileHWID* tileHWID;
221
222 // Retrieve all helpers from the detector store
223 CHECK( detStore()->retrieve(tileID, "TileID") );
224 CHECK( detStore()->retrieve(tileHWID, "TileHWID") );
225 CHECK( detStore()->retrieve(cellID, "CaloCell_ID") );
226
227 m_manager->set_helper(tileID);
228 m_manager->set_helper(cellID);
229 m_manager->set_helper(tileHWID);
230
231 // instantiate Cabling Svc to initialize pointers to helpers there
233 if (cabling==0) {
234 ATH_MSG_ERROR("Could not get instance of TileCablingService");
235 return StatusCode::FAILURE;
236 }
237
238 return StatusCode::SUCCESS;
239}
240
241
243{
244 m_manager->create_elements(true);
245 return StatusCode::SUCCESS;
246}
#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...
#define CHECK(...)
Evaluate an expression and check for errors.
Definition of the abstract IRDBAccessSvc interface.
Definition of TileAtlasFactory class.
std::shared_ptr< TileDddbManager > TileDddbManager_ptr
Definition of TileDetectorFactory class.
Definition of TileTBFactory class.
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
Helper class for offline cell identifiers.
Definition CaloCell_ID.h:34
GeoPhysVol * getPhysVol()
Destructor.
void addManager(const GeoVDetectorManager *)
GeoVDetectorManager * m_detector
virtual StatusCode registerCallback ATLAS_NOT_THREAD_SAFE() override
virtual void create(GeoPhysVol *world)
Creation of Tile geometry.
static const TileCablingService * getInstance()
get pointer to service instance
This class provides access to constants in the Geometry DB.
int GetNumberOfEnv() const
int addPlatesToCell() const
Definition of the TileDetectorFactoryLite class.
virtual void create(GeoPhysVol *world)
Creation of Tile geometry.
virtual void create(GeoPhysVol *world)
Creation of Tile geometry.
virtual StatusCode create() override final
void setSwitch(int &param, int value, const char *name)
Gaudi::Property< std::vector< std::string > > m_volumes
virtual ~TileDetectorTool() override final
TileDetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
TileDetDescrManager * m_manager
StatusCode createElements()
TileSwitches m_switches
std::string m_geometryConfig
virtual StatusCode clear() override final
Helper class for TileCal online (hardware) identifiers.
Definition TileHWID.h:49
Helper class for TileCal offline identifiers.
Definition TileID.h:67
virtual void create(GeoPhysVol *world) override
Creation of Test Beam Tile geometry.