10#include "GaudiKernel/ConcurrencyFlags.h"
11#include "GaudiKernel/IConversionSvc.h"
12#include "GaudiKernel/ISvcLocator.h"
13#include "GaudiKernel/SystemOfUnits.h"
15#include "GeoModelHelpers/ThreadPool.h"
16#include "GeoModelHelpers/defineWorld.h"
17#include "GeoModelKernel/GeoBox.h"
18#include "GeoModelKernel/GeoLogVol.h"
19#include "GeoModelKernel/GeoMaterial.h"
20#include "GeoModelKernel/GeoPerfUtils.h"
21#include "GeoModelKernel/GeoPhysVol.h"
22#include "GeoModelKernel/GeoVolumeCursor.h"
37 if (!m_sqliteDb && m_supportedGeometry == 0) {
39 "The Supported Geometry flag was not set in Job Options! Exiting ...");
40 return StatusCode::FAILURE;
55 Service *convSvc =
dynamic_cast<Service *
>(conversionSvc.get());
58 return StatusCode::FAILURE;
60 if (convSvc->FSMState() < Gaudi::StateMachine::INITIALIZED) {
67 ToolHandleArray<IGeoModelTool>::iterator itPriv = m_detectorTools.begin(),
68 itPrivEnd = m_detectorTools.end();
84 std::list<std::string> par2;
85 for (; itPriv != itPrivEnd; ++itPriv) {
86 if ((*itPriv)->align(par1, par2) != StatusCode::SUCCESS) {
87 ATH_MSG_DEBUG(
"align() failed for the tool " << (*itPriv)->name());
97 for (; itPriv != itPrivEnd; ++itPriv) {
100 if (StatusCode::SUCCESS != theTool->registerCallback()) {
102 "IGeoModelTool::align() was not registerred on CondDB object for "
111 m_tagInfoMgr->addListener(
this);
117 return StatusCode::SUCCESS;
122 return StatusCode::SUCCESS;
126 PVLink worldPhys{
nullptr};
133 if (dbTagSvc ==
nullptr) {
134 ATH_MSG_FATAL(
"Unable to dyn-cast the IGeoDbTagSvc pointer to GeoDbTagSvc");
135 return StatusCode::FAILURE;
141 std::string sqliteDbPath =
148 <<
" for reading in persistent GeoModel tree");
149 return StatusCode::FAILURE;
151 ATH_MSG_INFO(
"Successfully located SQLite database file "
152 << sqliteDbPath <<
" for reading in persistent GeoModel tree");
158 <<
" for reading in persistent GeoModel tree");
159 return StatusCode::FAILURE;
161 GeoThreading::ThreadPool::getPool(
m_nTheads);
163 "Successfully opened SQLite DB file "
164 << sqliteDbPath <<
" for reading in persistent GeoModel tree using "
165 << GeoThreading::ThreadPool::getPool().nThreads() <<
" threads.");
169 worldPhys = const_pointer_cast(vWorldPhys);
172 "Having Full Physical Volumes as World Volumes not supported!");
173 return StatusCode::FAILURE;
176 "Successfully read persistent GeoModel description from the file");
182 if (!sqliteReadSvc->connect(sqliteDbPath)) {
184 << sqliteDbPath <<
" for reading geometry parameters");
185 return StatusCode::FAILURE;
188 << sqliteDbPath <<
" for reading Det Descr parameters");
194 return StatusCode::FAILURE;
215 if (!rdbAccess->connect()) {
217 return StatusCode::FAILURE;
221 if (rdbAccess->getChildTag(
"ATLAS",
m_atlasVersion,
"ATLAS") ==
"") {
225 " Either ATLAS geometry tag has been misspelled, or the DB Release "
226 "does not contain the geometry specified.");
227 ATH_MSG_FATAL(
" In latter case please update DB Release version");
228 return StatusCode::FAILURE;
236 const coral::AttributeSpecification &supportedSpec =
237 atlasTagDetails[
"SUPPORTED"].specification();
238 if (supportedSpec.type() ==
typeid(
bool)) {
239 if (!atlasTagDetails[
"SUPPORTED"].
data<bool>()) {
241 " *** *** ATLAS layout "
243 <<
" is OBSOLETE and can NOT be supported any more! *** ***");
244 return StatusCode::FAILURE;
246 }
else if (supportedSpec.type() ==
typeid(
int)) {
251 <<
" and can NOT be supported any more! *** ***");
252 return StatusCode::FAILURE;
272 return StatusCode::FAILURE;
276 return StatusCode::FAILURE;
280 std::unique_ptr<StoredMaterialManager> theMaterialManager{};
282 theMaterialManager = std::make_unique<RDBMaterialManager>(
m_pSvcLocator);
283 }
catch (std::runtime_error &e) {
285 return StatusCode::FAILURE;
289 worldPhys = createGeoWorld();
294 std::make_unique<GeoModelExperiment>(std::move(worldPhys));
300 geoModelStats <<
"Detector Configuration flag = " <<
m_atlasVersion
305 ToolHandleArray<IGeoModelTool>::iterator itPriv =
m_detectorTools.begin(),
308 for (; itPriv != itPrivEnd; ++itPriv) {
311 mem = GeoPerfUtils::getMem();
312 cpu = GeoPerfUtils::getCpu();
317 geoModelStats << theTool->name()
318 <<
"\t SZ= " << GeoPerfUtils::getMem() - mem
319 <<
"Kb \t Time = " << (GeoPerfUtils::getCpu() - cpu) * 0.01
323 <<
"\t SZ= " << GeoPerfUtils::getMem() - mem
324 <<
"Kb \t Time = " << (GeoPerfUtils::getCpu() - cpu) * 0.01
331 rdbAccess->shutdown();
334 return StatusCode::SUCCESS;
342 bool tagsMatch =
true;
348 for (
const auto &
pair : pairs) {
349 std::string tagPairName =
pair.first;
350 if (tagPairName ==
"GeoAtlas") {
364 std::vector<std::string> tokensTagInfo, tokensJobOpt;
367 std::string::size_type startpos = 0;
368 std::string currStr =
pair.second;
369 for (std::string::size_type endpos = currStr.find(
'-');
370 endpos != std::string::npos; endpos = currStr.find(
'-', startpos)) {
371 tokensTagInfo.push_back(currStr.substr(startpos, endpos - startpos));
372 startpos = endpos + 1;
374 tokensTagInfo.push_back(currStr.substr(startpos));
376 size_t tokensTagInfoSize = tokensTagInfo.size();
377 bool tagInfoFollowsTheScheme =
378 (tokensTagInfoSize >= 5 &&
379 tokensTagInfo[tokensTagInfoSize - 1].size() == 2 &&
380 tokensTagInfo[tokensTagInfoSize - 2].size() == 2 &&
381 tokensTagInfo[tokensTagInfoSize - 3].size() == 2);
383 if (tagInfoFollowsTheScheme) {
387 for (std::string::size_type endpos = currStr.find(
'-');
388 endpos != std::string::npos;
389 endpos = currStr.find(
'-', startpos)) {
390 tokensJobOpt.push_back(currStr.substr(startpos, endpos - startpos));
391 startpos = endpos + 1;
393 tokensJobOpt.push_back(currStr.substr(startpos));
395 size_t tokensJobOptSize = tokensJobOpt.size();
396 bool jobOptFollowsTheScheme =
397 (tokensJobOptSize >= 5 &&
398 tokensJobOpt[tokensJobOptSize - 1].size() == 2 &&
399 tokensJobOpt[tokensJobOptSize - 2].size() == 2 &&
400 tokensJobOpt[tokensJobOptSize - 3].size() == 2);
401 if (jobOptFollowsTheScheme) {
403 tagsMatch = (
pair.second.substr(0, currStr.size() - 6) ==
411 }
else if (tagPairName ==
"GeoInDet")
413 else if (tagPairName ==
"GeoPixel")
415 else if (tagPairName ==
"GeoSCT")
417 else if (tagPairName ==
"GeoTRT")
419 else if (tagPairName ==
"GeoLAr")
421 else if (tagPairName ==
"GeoTile")
423 else if (tagPairName ==
"GeoMuon")
432 <<
"*** *** Geometry configured through jobOptions does not match "
433 "TagInfo tags! *** ***"
449 for (
const auto &
pair : pairs) {
450 const std::string &tagPairName =
pair.first;
451 if (tagPairName ==
"GeoAtlas") {
453 }
else if (tagPairName ==
"GeoInDet") {
455 }
else if (tagPairName ==
"GeoPixel") {
457 }
else if (tagPairName ==
"GeoSCT") {
459 }
else if (tagPairName ==
"GeoTRT") {
461 }
else if (tagPairName ==
"GeoLAr") {
463 }
else if (tagPairName ==
"GeoTile") {
465 }
else if (tagPairName ==
"GeoMuon") {
467 }
else if (tagPairName ==
"GeoCalo") {
469 }
else if (tagPairName ==
"GeoMagField") {
471 }
else if (tagPairName ==
"GeoCavernInfra") {
473 }
else if (tagPairName ==
"GeoForwardDetectors") {
479 ATH_MSG_INFO(
"*** *** Please fix geometry tag settings *** ***");
480 return StatusCode::FAILURE;
484 "Geometry configurations in jobOptions and TagInfo are consistent");
486 return StatusCode::SUCCESS;
495 return StatusCode::FAILURE;
500 <<
" not added to TagInfo ");
501 return StatusCode::FAILURE;
507 <<
" not added to TagInfo ");
508 return StatusCode::FAILURE;
515 <<
" not added to TagInfo ");
516 return StatusCode::FAILURE;
523 <<
" not added to TagInfo ");
524 return StatusCode::FAILURE;
531 <<
" not added to TagInfo ");
532 return StatusCode::FAILURE;
539 <<
" not added to TagInfo ");
540 return StatusCode::FAILURE;
547 <<
" not added to TagInfo ");
548 return StatusCode::FAILURE;
555 <<
" not added to TagInfo ");
556 return StatusCode::FAILURE;
563 <<
" not added to TagInfo ");
564 return StatusCode::FAILURE;
572 <<
" not added to TagInfo ");
573 return StatusCode::FAILURE;
582 return StatusCode::FAILURE;
591 return StatusCode::FAILURE;
595 return StatusCode::SUCCESS;
600 if (tool->name().find(toolName) != std::string::npos)
612 if (tool->clear().isFailure()) {
613 ATH_MSG_ERROR(
"clear() failed for the tool: " << tool->name());
614 return StatusCode::FAILURE;
621 std::vector<std::string> sgkeysExp;
623 for (
const std::string &key : sgkeysExp) {
633 std::vector<std::string> sgkeysMat;
635 for (
const std::string &key : sgkeysMat) {
646 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
StatusCode GeoModelSvc::initialize ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
char data[hepevt_bytes_allocation_ATLAS]
Definition of the abstract IRDBAccessSvc interface.
coral::AttributeList RDBTagDetails
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
ServiceHandle< ITagInfoMgr > m_tagInfoMgr
Gaudi::Property< bool > m_ignoreTagSupport
virtual void tagInfoUpdated() override final
Callback from TagInfoMgr on TagInfo change.
Gaudi::Property< std::string > m_muonVersionOverride
Gaudi::Property< std::string > m_atlasVersion
virtual const IGeoModelTool * getTool(std::string toolName) const override
Gaudi::Property< unsigned > m_nTheads
Gaudi::Property< int > m_supportedGeometry
std::unique_ptr< GeoModelIO::ReadGeoModel > m_sqliteReader
Gaudi::Property< std::string > m_larVersionOverride
Gaudi::Property< std::string > m_bFieldVersionOverride
ServiceHandle< StoreGateSvc > m_detStore
Gaudi::Property< std::string > m_sqliteDbFullPath
Gaudi::Property< std::string > m_tileVersionOverride
Gaudi::Property< std::string > m_trtVersionOverride
StatusCode fillTagInfo() const
virtual const std::string & atlasVersion() const override
Gaudi::Property< bool > m_ignoreTagDifference
Gaudi::Property< bool > m_sqliteDb
virtual StatusCode finalize() override
Gaudi::Property< std::string > m_forDetVersionOverride
ISvcLocator * m_pSvcLocator
Gaudi::Property< std::string > m_inDetVersionOverride
GeoModelSvc(const std::string &name, ISvcLocator *svc)
Gaudi::Property< std::string > m_caloVersionOverride
Gaudi::Property< std::string > m_pixelVersionOverride
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
std::shared_ptr< GMDBManager > m_sqliteDbManager
ToolHandleArray< IGeoModelTool > m_detectorTools
Gaudi::Property< std::string > m_sctVersionOverride
Gaudi::Property< std::string > m_cavInfraVersionOverride
Gaudi::Property< bool > m_statisticsToFile
virtual StatusCode clear() override
std::vector< NameTagPair > NameTagPairVec
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
This class holds one or more material managers and makes them storeable, under StoreGate.