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;
59 Service* convSvc=
dynamic_cast<Service*
>(conversionSvc.get());
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;
125 GeoPhysVol* worldPhys{
nullptr};
132 if(dbTagSvc==
nullptr) {
133 ATH_MSG_FATAL(
"Unable to dyn-cast the IGeoDbTagSvc pointer to GeoDbTagSvc");
134 return StatusCode::FAILURE;
144 ATH_MSG_FATAL(
"Failed to find SQLite database file " << sqliteDbName <<
" for reading in persistent GeoModel tree");
145 return StatusCode::FAILURE;
148 ATH_MSG_INFO(
"Successfully located SQLite database file " << sqliteDbPath <<
" for reading in persistent GeoModel tree");
153 ATH_MSG_INFO(
"Successfully opened SQLite DB file " << sqliteDbPath <<
" for reading in persistent GeoModel tree");
155 ATH_MSG_FATAL(
"Failed to open SQLite database " << sqliteDbPath <<
" for reading in persistent GeoModel tree");
156 return StatusCode::FAILURE;
160 worldPhys =
dynamic_cast<GeoPhysVol*
>(vWorldPhys);
162 ATH_MSG_FATAL(
"Having Full Physical Volumes as World Volumes not supported!");
163 return StatusCode::FAILURE;
165 ATH_MSG_INFO(
"Successfully read persistent GeoModel description from the file");
170 if(!sqliteReadSvc->connect(sqliteDbPath)) {
171 ATH_MSG_FATAL(
"Failed to open SQLite database file " << sqliteDbPath <<
" for reading geometry parameters");
172 return StatusCode::FAILURE;
174 ATH_MSG_INFO(
"Successfully opened SQLite DB file: " << sqliteDbPath <<
" for reading Det Descr parameters");
180 return StatusCode::FAILURE;
202 if(!rdbAccess->connect()) {
204 return StatusCode::FAILURE;
210 ATH_MSG_FATAL(
" Either ATLAS geometry tag has been misspelled, or the DB Release does not contain the geometry specified.");
211 ATH_MSG_FATAL(
" In latter case please update DB Release version");
212 return StatusCode::FAILURE;
220 const coral::AttributeSpecification& supportedSpec = atlasTagDetails[
"SUPPORTED"].specification();
221 if(supportedSpec.type()==
typeid(
bool)) {
222 if(!atlasTagDetails[
"SUPPORTED"].data<bool>()) {
224 return StatusCode::FAILURE;
227 else if(supportedSpec.type()==
typeid(
int)) {
231 <<
" and can NOT be supported any more! *** ***");
232 return StatusCode::FAILURE;
252 return StatusCode::FAILURE;
256 return StatusCode::FAILURE;
264 catch(std::runtime_error&
e) {
266 return StatusCode::FAILURE;
271 const GeoMaterial* air = theMaterialManager->getMaterial(
"std::Air");
273 const GeoLogVol* worldLog =
new GeoLogVol(
"WorldLog", worldBox, air);
274 worldPhys=
new GeoPhysVol(worldLog);
282 std::unique_ptr<std::ofstream> geoModelStats;
284 geoModelStats = std::make_unique<std::ofstream>(
"GeoModelStatistics");
285 *geoModelStats <<
"Detector Configuration flag = " <<
m_atlasVersion << std::endl;
292 for(; itPriv!=itPrivEnd; ++itPriv) {
295 mem = GeoPerfUtils::getMem();
301 *geoModelStats << theTool->name() <<
"\t SZ= "
302 << GeoPerfUtils::getMem() - mem <<
"Kb \t Time = " << (
GeoPerfUtils::getCpu() - cpu) * 0.01 <<
"S" << std::endl;
306 << GeoPerfUtils::getMem() - mem <<
"Kb \t Time = " << (
GeoPerfUtils::getCpu() - cpu) * 0.01 <<
"S");
311 geoModelStats->close();
316 rdbAccess->shutdown();
319 return StatusCode::SUCCESS;
331 bool tagsMatch =
true;
337 for(
const auto& pair :
pairs ) {
338 std::string tagPairName = pair.first;
339 if(tagPairName==
"GeoAtlas") {
349 std::vector<std::string> tokensTagInfo, tokensJobOpt;
352 std::string::size_type startpos = 0;
353 std::string currStr = pair.second;
354 for(std::string::size_type endpos=currStr.find(
'-'); endpos!=std::string::npos; endpos=currStr.find(
'-',startpos)) {
355 tokensTagInfo.push_back(currStr.substr(startpos,endpos-startpos));
358 tokensTagInfo.push_back(currStr.substr(startpos));
360 size_t tokensTagInfoSize = tokensTagInfo.size();
361 bool tagInfoFollowsTheScheme = (tokensTagInfoSize>=5
362 && tokensTagInfo[tokensTagInfoSize-1].size()==2
363 && tokensTagInfo[tokensTagInfoSize-2].size()==2
364 && tokensTagInfo[tokensTagInfoSize-3].size()==2);
366 if(tagInfoFollowsTheScheme) {
370 for(std::string::size_type endpos=currStr.find(
'-'); endpos!=std::string::npos; endpos=currStr.find(
'-',startpos)) {
371 tokensJobOpt.push_back(currStr.substr(startpos,endpos-startpos));
374 tokensJobOpt.push_back(currStr.substr(startpos));
376 size_t tokensJobOptSize = tokensJobOpt.size();
377 bool jobOptFollowsTheScheme = (tokensJobOptSize>=5
378 && tokensJobOpt[tokensJobOptSize-1].size()==2
379 && tokensJobOpt[tokensJobOptSize-2].size()==2
380 && tokensJobOpt[tokensJobOptSize-3].size()==2);
381 if(jobOptFollowsTheScheme) {
393 else if(tagPairName==
"GeoInDet")
395 else if(tagPairName==
"GeoPixel")
397 else if(tagPairName==
"GeoSCT")
399 else if(tagPairName==
"GeoTRT")
401 else if(tagPairName==
"GeoLAr")
403 else if(tagPairName==
"GeoTile")
405 else if(tagPairName==
"GeoMuon")
408 if(!tagsMatch)
break;
413 <<
"*** *** Geometry configured through jobOptions does not match TagInfo tags! *** ***" <<
endmsg;
428 for (
const auto& pair :
pairs) {
429 std::string tagPairName = pair.first;
430 if(tagPairName==
"GeoAtlas")
432 else if(tagPairName==
"GeoInDet")
434 else if(tagPairName==
"GeoPixel")
436 else if(tagPairName==
"GeoSCT")
438 else if(tagPairName==
"GeoTRT")
440 else if(tagPairName==
"GeoLAr")
442 else if(tagPairName==
"GeoTile")
444 else if(tagPairName==
"GeoMuon")
446 else if(tagPairName==
"GeoCalo")
448 else if(tagPairName==
"GeoMagField")
450 else if(tagPairName==
"GeoCavernInfra")
452 else if(tagPairName==
"GeoForwardDetectors")
457 ATH_MSG_INFO(
"*** *** Please fix geometry tag settings *** ***");
458 return StatusCode::FAILURE;
462 ATH_MSG_DEBUG(
"Geometry configurations in jobOptions and TagInfo are consistent");
464 return StatusCode::SUCCESS;
474 return StatusCode::FAILURE;
479 return StatusCode::FAILURE;
485 return StatusCode::FAILURE;
492 return StatusCode::FAILURE;
499 return StatusCode::FAILURE;
506 return StatusCode::FAILURE;
513 return StatusCode::FAILURE;
520 return StatusCode::FAILURE;
527 return StatusCode::FAILURE;
534 return StatusCode::FAILURE;
541 return StatusCode::FAILURE;
548 return StatusCode::FAILURE;
555 return StatusCode::FAILURE;
559 return StatusCode::SUCCESS;
565 if(
tool->name().find(toolName)!=std::string::npos)
578 if(
tool->clear().isFailure()) {
580 return StatusCode::FAILURE;
587 std::vector<std::string> sgkeysExp;
589 for (
const std::string&
key : sgkeysExp) {
598 std::vector<std::string> sgkeysMat;
600 for (
const std::string&
key : sgkeysMat) {
608 return StatusCode::SUCCESS;