ATLAS Offline Software
TagFunctions.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 //@file TagFunctions.cxx
5 //@brief Implementation of helper functions for tag resolution
6 //@author Shaun Roe
7 
8 #include "TagFunctions.h"
10 #include "IOVDbStringFunctions.h"
11 #include "GaudiKernel/StatusCode.h"
12 #include "GaudiKernel/ISvcLocator.h"
15 
16 #include <stdexcept>
17 
18 
19 namespace IOVDbNamespace{
20  std::string
21  getTagInfo(const std::string &tag, const ITagInfoMgr *tagInfoMgr){
22  std::string result{};
23  enum ResultIndices{WHOLETAG, MAJMIN, PATH1, PATH2, SIZEWITHPREFIX};
25  if (results.empty()) return result;
27  std::string tagval = tagInfoMgr->findTag(target);
28  if (not tagval.empty()) result=prefix+tagval;
29  return result;
30  }
31 
32  std::string
34  std::string version{};
35  IGeoModelSvc* geomodel=nullptr;
36  ISvcLocator* svcLocator=Gaudi::svcLocator();
37  if (not svcLocator or StatusCode::SUCCESS!=svcLocator->service("GeoModelSvc",geomodel)) {
38  throw std::runtime_error("The GeoModelSvc could not be retrieved in TagFunctions.cxx getGeoAtlasVersion()");
39  } else {
40  version=geomodel->atlasVersion();
41  }
42  return version;
43  }
44 
45  std::optional<bool>
46  checkTagLock(const cool::IFolderPtr& fptr, const std::string & tag){
47  try {
48  return (fptr->tagLockStatus(tag)==cool::HvsTagLock::LOCKED);
49  } catch (cool::Exception& e) {
50  //dont do anything, but...
51  }
52  //...return a null object
53  return std::nullopt;
54  }
55 
56  std::string
57  resolveUsingTagInfo(const std::string & tag, const ITagInfoMgr *tagInfoMgr){
58  // tag an input tag of form TagInfo{Major|Minor}/<tag> or
59  // TagInfo(Major|Minor}/<prefix>/<tag>
60  // and resolve to value of TagInfo object tag <tag>
61  // with optional prefix
62  // <prefix>DEFAULT tags are no longer returned
63  // return true for successful resolution
64  std::string result="";
65  enum ResultIndices{WHOLETAG, MAJMIN, PATH1, PATH2, SIZEWITHPREFIX};
67  if (results.empty()) {
68  return result;
69  }
71  // try to get the Tag value
72  if( tagInfoMgr ) {
74  }
75  // if nothing found, try to get GeoAtlas directly from GeoModelSvc
76  if (result.empty() and target=="GeoAtlas") {
78  }
79  if (not result.empty()) {
80  std::string::size_type rstrip{};
81  //number of characters to strip from tag end
82  if (results[MAJMIN] == "Major") rstrip=6;
83  if (results[MAJMIN] == "Minor") rstrip=3;
84  // check if characters need to be stripped from end of tag
85  if (rstrip>0 && tag.size()>rstrip) result.erase(result.size()-rstrip);
86  } else {
87  throw std::runtime_error("Could not resolve TagInfo tag " + target );
88  }
89  return result;
90  }
91 
92 
93 
94 
95 
96 }
IOVDbNamespace::parseMagicTag
std::vector< std::string > parseMagicTag(const std::string &v)
Takes a tag of form TagInfo{Major|Minor}/<tag> or TagInfo{Major|Minor}/<prefix>/<tag> and resolve it ...
Definition: IOVDbStringFunctions.cxx:164
IOVDbNamespace::tag2PrefixTarget
std::pair< std::string, std::string > tag2PrefixTarget(const std::vector< std::string > &tagParseResults)
Takes a vector<string> containing {"<fulltag>", "Major|Minor", "<prefix>", "<tag>"} and returns a pai...
Definition: IOVDbStringFunctions.cxx:198
ITagInfoMgr::findTag
virtual std::string findTag(const std::string &name) const =0
Find tag by its name, return by value - empty string if not found.
get_generator_info.result
result
Definition: get_generator_info.py:21
IGeoModelSvc
Definition: IGeoModelSvc.h:17
ITagInfoMgr.h
IOVDbNamespace::getGeoAtlasVersion
std::string getGeoAtlasVersion()
Get the GeoAtlas version directly from GeoModelSvc.
Definition: TagFunctions.cxx:33
IOVDbNamespace::getTagInfo
std::string getTagInfo(const std::string &tag, const ITagInfoMgr *tagInfoMgr)
Retrieve the TagInfo.
Definition: TagFunctions.cxx:21
IOVDbStringFunctions.h
IOVDbNamespace::checkTagLock
std::optional< bool > checkTagLock(const cool::IFolderPtr &fptr, const std::string &tag)
Check whether a tag is locked on a folder, if possible.
Definition: TagFunctions.cxx:46
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
fptr
std::vector< TFile * > fptr
Definition: hcg.cxx:48
python.ami.results
def results
Definition: ami.py:386
IOVDbNamespace::resolveUsingTagInfo
std::string resolveUsingTagInfo(const std::string &tag, const ITagInfoMgr *tagInfoMgr)
Definition: TagFunctions.cxx:57
get_generator_info.version
version
Definition: get_generator_info.py:33
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
ITagInfoMgr
This is a Athena service which manages detector description tag information. It maintains a TagInfo o...
Definition: ITagInfoMgr.h:58
COOLRates.target
target
Definition: COOLRates.py:1106
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
IGeoModelSvc::atlasVersion
virtual const std::string & atlasVersion() const =0
IGeoModelSvc.h
StoreGateSvc.h
TagFunctions.h
IOVDbNamespace
Definition: Base64Codec.cxx:16