9 #include "GeoModelKernel/GeoBox.h"
10 #include "GeoModelKernel/GeoLogVol.h"
11 #include "GeoModelKernel/GeoPhysVol.h"
12 #include "GeoModelKernel/GeoMaterial.h"
13 #include "GeoModelKernel/GeoVolumeCursor.h"
14 #include "GeoModelKernel/GeoPerfUtils.h"
17 #include "GaudiKernel/ISvcLocator.h"
18 #include "GaudiKernel/IConversionSvc.h"
19 #include "GaudiKernel/SystemOfUnits.h"
40 if(!m_sqliteDbFullPath.empty()) m_sqliteDb=
true;
42 if(!m_sqliteDb && m_supportedGeometry==0) {
43 ATH_MSG_FATAL(
"The Supported Geometry flag was not set in Job Options! Exiting ...");
44 return StatusCode::FAILURE;
60 if (convSvc->FSMState() < Gaudi::StateMachine::INITIALIZED) {
68 itPrivEnd = m_detectorTools.end();
83 std::list<std::string> par2;
84 for(; itPriv!=itPrivEnd; ++itPriv) {
85 if((*itPriv)->align(par1,par2) != StatusCode::SUCCESS) {
86 ATH_MSG_DEBUG(
"align() failed for the tool " << (*itPriv)->name());
97 for (; itPriv!=itPrivEnd; ++itPriv) {
100 if(StatusCode::SUCCESS != theTool->registerCallback()) {
101 ATH_MSG_DEBUG(
"IGeoModelTool::align() was not registerred on CondDB object for the tool " << theTool->name());
108 m_tagInfoMgr->addListener(
this );
114 return StatusCode::SUCCESS;
120 return StatusCode::SUCCESS;
133 return StatusCode::SUCCESS;
137 return AthService::queryInterface(riid, ppvInterface);
143 GeoPhysVol* worldPhys{
nullptr};
150 if(dbTagSvc==
nullptr) {
151 ATH_MSG_FATAL(
"Unable to dyn-cast the IGeoDbTagSvc pointer to GeoDbTagSvc");
152 return StatusCode::FAILURE;
162 ATH_MSG_FATAL(
"Failed to find SQLite database file " << sqliteDbName <<
" for reading in persistent GeoModel tree");
163 return StatusCode::FAILURE;
166 ATH_MSG_INFO(
"Successfully located SQLite database file " << sqliteDbPath <<
" for reading in persistent GeoModel tree");
171 ATH_MSG_INFO(
"Successfully opened SQLite DB file " << sqliteDbPath <<
" for reading in persistent GeoModel tree");
173 ATH_MSG_FATAL(
"Failed to open SQLite database " << sqliteDbPath <<
" for reading in persistent GeoModel tree");
174 return StatusCode::FAILURE;
178 worldPhys =
dynamic_cast<GeoPhysVol*
>(vWorldPhys);
180 ATH_MSG_FATAL(
"Having Full Physical Volumes as World Volumes not supported!");
181 return StatusCode::FAILURE;
183 ATH_MSG_INFO(
"Successfully read persistent GeoModel description from the file");
188 if(!sqliteReadSvc->connect(sqliteDbPath)) {
189 ATH_MSG_FATAL(
"Failed to open SQLite database file " << sqliteDbPath <<
" for reading geometry parameters");
190 return StatusCode::FAILURE;
192 ATH_MSG_INFO(
"Successfully opened SQLite DB file: " << sqliteDbPath <<
" for reading Det Descr parameters");
216 if(!rdbAccess->connect()) {
218 return StatusCode::FAILURE;
224 ATH_MSG_FATAL(
" Either ATLAS geometry tag has been misspelled, or the DB Release does not contain the geometry specified.");
225 ATH_MSG_FATAL(
" In latter case please update DB Release version");
226 return StatusCode::FAILURE;
234 const coral::AttributeSpecification& supportedSpec = atlasTagDetails[
"SUPPORTED"].specification();
235 if(supportedSpec.type()==
typeid(
bool)) {
236 if(!atlasTagDetails[
"SUPPORTED"].data<bool>()) {
238 return StatusCode::FAILURE;
241 else if(supportedSpec.type()==
typeid(
int)) {
245 <<
" and can NOT be supported any more! *** ***");
246 return StatusCode::FAILURE;
266 return StatusCode::FAILURE;
274 catch(std::runtime_error&
e) {
276 return StatusCode::FAILURE;
281 const GeoMaterial* air = theMaterialManager->getMaterial(
"std::Air");
283 const GeoLogVol* worldLog =
new GeoLogVol(
"WorldLog", worldBox, air);
284 worldPhys=
new GeoPhysVol(worldLog);
292 std::unique_ptr<std::ofstream> geoModelStats;
294 geoModelStats = std::make_unique<std::ofstream>(
"GeoModelStatistics");
295 *geoModelStats <<
"Detector Configuration flag = " <<
m_atlasVersion << std::endl;
302 for(; itPriv!=itPrivEnd; ++itPriv) {
305 mem = GeoPerfUtils::getMem();
311 *geoModelStats << theTool->name() <<
"\t SZ= "
312 << GeoPerfUtils::getMem() - mem <<
"Kb \t Time = " << (
GeoPerfUtils::getCpu() - cpu) * 0.01 <<
"S" << std::endl;
316 << GeoPerfUtils::getMem() - mem <<
"Kb \t Time = " << (
GeoPerfUtils::getCpu() - cpu) * 0.01 <<
"S");
321 geoModelStats->close();
326 rdbAccess->shutdown();
329 return StatusCode::SUCCESS;
341 bool tagsMatch =
true;
347 for(
const auto& pair :
pairs ) {
348 std::string tagPairName = pair.first;
349 if(tagPairName==
"GeoAtlas") {
359 std::vector<std::string> tokensTagInfo, tokensJobOpt;
362 std::string::size_type startpos = 0;
363 std::string currStr = pair.second;
364 for(std::string::size_type endpos=currStr.find(
'-'); endpos!=std::string::npos; endpos=currStr.find(
'-',startpos)) {
365 tokensTagInfo.push_back(currStr.substr(startpos,endpos-startpos));
368 tokensTagInfo.push_back(currStr.substr(startpos));
370 size_t tokensTagInfoSize = tokensTagInfo.size();
371 bool tagInfoFollowsTheScheme = (tokensTagInfoSize>=5
372 && tokensTagInfo[tokensTagInfoSize-1].size()==2
373 && tokensTagInfo[tokensTagInfoSize-2].size()==2
374 && tokensTagInfo[tokensTagInfoSize-3].size()==2);
376 if(tagInfoFollowsTheScheme) {
380 for(std::string::size_type endpos=currStr.find(
'-'); endpos!=std::string::npos; endpos=currStr.find(
'-',startpos)) {
381 tokensJobOpt.push_back(currStr.substr(startpos,endpos-startpos));
384 tokensJobOpt.push_back(currStr.substr(startpos));
386 size_t tokensJobOptSize = tokensJobOpt.size();
387 bool jobOptFollowsTheScheme = (tokensJobOptSize>=5
388 && tokensJobOpt[tokensJobOptSize-1].size()==2
389 && tokensJobOpt[tokensJobOptSize-2].size()==2
390 && tokensJobOpt[tokensJobOptSize-3].size()==2);
391 if(jobOptFollowsTheScheme) {
403 else if(tagPairName==
"GeoInDet")
405 else if(tagPairName==
"GeoPixel")
407 else if(tagPairName==
"GeoSCT")
409 else if(tagPairName==
"GeoTRT")
411 else if(tagPairName==
"GeoLAr")
413 else if(tagPairName==
"GeoTile")
415 else if(tagPairName==
"GeoMuon")
418 if(!tagsMatch)
break;
423 <<
"*** *** Geometry configured through jobOptions does not match TagInfo tags! *** ***" <<
endmsg;
438 for (
const auto& pair :
pairs) {
439 std::string tagPairName = pair.first;
440 if(tagPairName==
"GeoAtlas")
442 else if(tagPairName==
"GeoInDet")
444 else if(tagPairName==
"GeoPixel")
446 else if(tagPairName==
"GeoSCT")
448 else if(tagPairName==
"GeoTRT")
450 else if(tagPairName==
"GeoLAr")
452 else if(tagPairName==
"GeoTile")
454 else if(tagPairName==
"GeoMuon")
456 else if(tagPairName==
"GeoCalo")
458 else if(tagPairName==
"GeoMagField")
460 else if(tagPairName==
"GeoCavernInfra")
462 else if(tagPairName==
"GeoForwardDetectors")
467 ATH_MSG_INFO(
"*** *** Please fix geometry tag settings *** ***");
468 return StatusCode::FAILURE;
472 ATH_MSG_DEBUG(
"Geometry configurations in jobOptions and TagInfo are consistent");
474 return StatusCode::SUCCESS;
484 return StatusCode::FAILURE;
489 return StatusCode::FAILURE;
495 return StatusCode::FAILURE;
502 return StatusCode::FAILURE;
509 return StatusCode::FAILURE;
516 return StatusCode::FAILURE;
523 return StatusCode::FAILURE;
530 return StatusCode::FAILURE;
537 return StatusCode::FAILURE;
544 return StatusCode::FAILURE;
551 return StatusCode::FAILURE;
558 return StatusCode::FAILURE;
565 return StatusCode::FAILURE;
569 return StatusCode::SUCCESS;
575 if(
tool->name().find(toolName)!=std::string::npos)
588 if(
tool->clear().isFailure()) {
590 return StatusCode::FAILURE;
597 std::vector<std::string> sgkeysExp;
599 for (
const std::string&
key : sgkeysExp) {
608 std::vector<std::string> sgkeysMat;
610 for (
const std::string&
key : sgkeysMat) {
618 return StatusCode::SUCCESS;