ATLAS Offline Software
Loading...
Searching...
No Matches
DecodeVersionKey.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
8#include "GaudiKernel/ISvcLocator.h"
9#include "GaudiKernel/Bootstrap.h"
10#include <string>
11#include <iostream>
12
13DecodeVersionKey::DecodeVersionKey(const IGeoModelSvc * geoModel, const std::string & node)
14{
16}
17
18DecodeVersionKey::DecodeVersionKey(const IGeoDbTagSvc * geoDbTag, const std::string & node)
19{
21}
22
24{
25 SmartIF<IGeoDbTagSvc> geoDbTag{Gaudi::svcLocator()->service("GeoDbTagSvc")};
26 if(!geoDbTag.isValid()) throw std::runtime_error("DecodeVersionKey constructor: cannot access GeoDbTagSvc");
28}
29
30template <class T>
31void DecodeVersionKey::defineTag(const T* svc, const std::string & node)
32{
33 std::string nodeOverrideTag;
34 std::string indetOverrideTag; // Indet has two levels.
35 if (node == "ATLAS") {
36 nodeOverrideTag = "";
37 } else if (node == "InnerDetector") {
38 nodeOverrideTag = svc->inDetVersionOverride();
39 } else if (node == "Pixel") {
40 indetOverrideTag = svc->inDetVersionOverride();
41 nodeOverrideTag = svc->pixelVersionOverride();
42 } else if (node == "SCT") {
43 indetOverrideTag = svc->inDetVersionOverride();
44 nodeOverrideTag = svc->SCT_VersionOverride();
45 } else if (node == "TRT") {
46 indetOverrideTag = svc->inDetVersionOverride();
47 nodeOverrideTag = svc->TRT_VersionOverride();
48 } else if (node == "LAr") {
49 nodeOverrideTag = svc->LAr_VersionOverride();
50 } else if (node == "TileCal") {
51 nodeOverrideTag = svc->tileVersionOverride();
52 } else if (node == "MuonSpectrometer") {
53 nodeOverrideTag = svc->muonVersionOverride();
54 } else if (node == "Calorimeter") {
55 nodeOverrideTag = svc->caloVersionOverride();
56 } else if (node == "ForwardDetectors") {
57 nodeOverrideTag = svc->forwardDetectorsVersionOverride();
58 } else {
59 std::cout << "DecodeVersionKey passed an unknown node:" << node << std::endl;
60 nodeOverrideTag = "";
61 }
62
63 // Default to atlas version
64 m_tag = svc->atlasVersion();
65 m_node = "ATLAS";
66
67 // If indetOverrideTag is specified (and is not just "CUSTOM") then override with the indet tag.
68 std::string indetTag;
69 if (!indetOverrideTag.empty()) {
70 // We dont care about the return value (custom = true/false). We only take notice of the custom
71 // flag if the override is at the node we have selected. Ie we only look at nodeOverrideTag
72 // in order to set m_custom. At any rate, we have to remove the CUSTOM string if it is present.
73 getCustomTag(indetOverrideTag, indetTag);
74 }
75 if (!indetTag.empty()) {
76 m_tag = std::move(indetTag);
77 m_node = "InnerDetector";
78 }
79
80 // Finally if subsystem tag is overriden then use that.
81 std::string outputTag;
82 m_custom = getCustomTag(nodeOverrideTag, outputTag);
83
84 if (!outputTag.empty()) {
85 m_tag = std::move(outputTag);
86 m_node = node;
87 }
88}
89
90const std::string &
92{
93 return m_tag;
94}
95
96const std::string &
98{
99 return m_node;
100}
101
102bool
104{
105 return m_custom;
106}
107
108
109
110bool
111DecodeVersionKey::getCustomTag(const std::string & inputTag, std::string & outputTag)
112{
113 //
114 // Check if CUSTOM is specified. If it is not specified then outputTag = inputTag.
115 // If the tag is just "CUSTOM" then set output tag to "" so that we use the higher level tag.
116 // If the tag is of the form CUSTOM-XXXXX use the XXXXX as the tag
117 // The separating character (in this example a '-') can be any character.
118 //
119 bool custom = false;
120 outputTag = inputTag;
121 if (!inputTag.empty()) {
122 if (inputTag.compare(0,6,"CUSTOM") == 0) {
123 custom = true;
124 // If its CUSTOM-something skip the next character and get the something
125 outputTag = inputTag.substr(6);
126 if (!outputTag.empty()) outputTag = outputTag.substr(1);
127 }
128 }
129 return custom;
130}
131
bool getCustomTag(const std::string &inputTag, std::string &outputTag)
DecodeVersionKey(const IGeoModelSvc *, const std::string &node)
Constructor is passed a pointer to GeoModelSvc plus the node for which you want the tag.
void defineTag(const T *svc, const std::string &node)
bool custom() const
Return true if CUSTOM is selected.
const std::string & tag() const
Return version tag.
const std::string & node() const
Return the version node.