ATLAS Offline Software
Loading...
Searching...
No Matches
IdDictCnvTest.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5/***************************************************************************
6 IdDict converter package
7 -----------------------------------------
8 ***************************************************************************/
9
10#include "IdDictCnvTest.h"
11
12// Id-related includes
14#include "IdDict/IdDictMgr.h"
16#include "Identifier/Range.h"
20
21// Athena-related includes
22#include "GaudiKernel/MsgStream.h"
23#include "Gaudi/Property.h"
24#include "GaudiKernel/IChronoStatSvc.h"
25
26
28
29void
30IdDictCnvTest::tab (size_t level) const
31{
32 for (size_t i = 0; i < level; ++i) msg() << " ";
33}
34
36// CONSTRUCTOR:
38
39IdDictCnvTest::IdDictCnvTest(const std::string& name, ISvcLocator* pSvcLocator)
40 :
41 AthAlgorithm(name, pSvcLocator)
42{}
43
45// DESTRUCTOR:
47
50
52// INITIALIZE:
53// The initialize method will create all the required algorithm objects
54// Note that it is NOT NECESSARY to run the initialize of individual
55// sub-algorithms. The framework takes care of it.
57
58StatusCode
60{
61 ATH_MSG_INFO ( "Start initialization" );
62
63 const IdDictManager* idDictMgr = nullptr;
64 ATH_CHECK( detStore()->retrieve(idDictMgr, "IdDict") );
65 ATH_MSG_DEBUG ( " Found the IdDictManager. " );
66 ATH_MSG_DEBUG ( " Tag is " << idDictMgr->manager()->tag() );
67
69
70 int n = 0;
71
72 if (dv.empty()) {
73 // No dicts found
74 ATH_MSG_ERROR ( "No dictionaries found!" );
75 return StatusCode::FAILURE;
76 }
77
78
79 for (const IdDictDictionary* dictionary : dv) {
80 ATH_MSG_INFO( "---- " << n << " ----------------------------" );
81 std::string version = ("" != dictionary->version()) ? dictionary->version() : "default";
82 ATH_MSG_INFO ( "Dictionary " << dictionary->name()
83 << " version " << version );
84
85 if(dictionary->verify()) {
86 ATH_MSG_INFO( "Dictionary verification is OK" );
87 }
88 else {
89 ATH_MSG_FATAL( "Dictionary verification has failed: "
90 << dictionary->name() << " multirange: "
91 << (std::string)dictionary->build_multirange() );
92 return StatusCode::FAILURE;
93 }
94
95
96// std::vector<IdDictRegion*>::const_iterator rit;
97// for (rit = dictionary->m_regions.begin (); rit != dictionary->m_regions.end (); ++rit) {
98// const IdDictRegion& region = *(*rit);
99
100// log << MSG::DEBUG
101// << "region #" << region.m_index
102// << endmsg;
103
104// std::vector <IdDictFieldImplementation>::const_iterator fit;
105
106// size_t width = 0;
107
108// for (fit = region.m_implementation.begin ();
109// fit != region.m_implementation.end ();
110// ++fit) {
111// const IdDictFieldImplementation& impl = *fit;
112
113// size_t w = impl.range()->m_field->m_name.size ();
114
115// if (w > width) width = w;
116// }
117
118// int bits = 0;
119
120// for (fit = region.m_implementation.begin ();
121// fit != region.m_implementation.end ();
122// ++fit) {
123// const IdDictFieldImplementation& impl = *fit;
124
125// size_t w = impl.range()->m_field->m_name.size ();
126
127// log << MSG::DEBUG
128// << " implement field #" << impl.range()->m_field->m_index <<
129// " " << impl.range()->m_field->m_name;
130
131// tab (width - w);
132
133// // int index = impl.field();
134// // std::string label = impl.range()->m_field->labels[index]->m_name;
135// // std::cout << " name " << label << " ";
136
137// log << " -> " << (std::string) impl.field()
138// << "/" << (std::string) impl.ored_field()
139// << " (" << impl.bits() << " bits)"
140// << endmsg;
141
142// bits += impl.bits();
143// }
144
145// Range range = region.build_range ();
146
147// log << MSG::DEBUG
148// << " -> " << (std::string) range <<
149// " (cardinality=" << range.cardinality () << ")" <<
150// " (" << bits << " bits)"
151// << endmsg;
152// }
153// }
154 }
155
156
157 ATH_MSG_DEBUG ( " Get AtlasDetectorID. " );
158 const AtlasDetectorID* atlasID = nullptr;
159 // Access AtlasID from detector store
160 ATH_CHECK( detStore()->retrieve(atlasID, "AtlasID") );
161 ATH_MSG_DEBUG ( " Found the AtlasDetectorID. " );
162
163 ATH_MSG_DEBUG ( " Begin tests for AtlasDetectorID. " );
164 Identifier id = atlasID->indet();
165 ATH_MSG_DEBUG ( " is indet " << atlasID->show_to_string(id)
166 << " " << atlasID->is_indet(id) );
167 ATH_MSG_DEBUG ( " is sct " << atlasID->show_to_string(id)
168 << " " << atlasID->is_sct(id) );
169 ATH_MSG_DEBUG ( " is lar " << atlasID->show_to_string(id)
170 << " " << atlasID->is_lar(id) );
171 ATH_MSG_DEBUG ( " is muon " << atlasID->show_to_string(id)
172 << " " << atlasID->is_muon(id) );
173 id = atlasID->trt();
174 ATH_MSG_DEBUG ( " is indet " << atlasID->show_to_string(id)
175 << " " << atlasID->is_indet(id) );
176 ATH_MSG_DEBUG ( " is sct " << atlasID->show_to_string(id)
177 << " " << atlasID->is_sct(id) );
178 ATH_MSG_DEBUG ( " is trt " << atlasID->show_to_string(id)
179 << " " << atlasID->is_trt(id) );
180 ATH_MSG_DEBUG ( " is lar " << atlasID->show_to_string(id)
181 << " " << atlasID->is_lar(id) );
182 ATH_MSG_DEBUG ( " is muon " << atlasID->show_to_string(id)
183 << " " << atlasID->is_muon(id) );
184
185 ATH_MSG_INFO( "Initialization completed successfully" );
186
187 return StatusCode::SUCCESS;
188
189}
190
191
193StatusCode
195{
196 return StatusCode::SUCCESS;
197}
198
199
201// FINALIZE:
203
204StatusCode
206{
207 ATH_MSG_DEBUG ( "finalize completed successfully" );
208 return StatusCode::SUCCESS;
209}
210
211
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
MsgStream & msg() const
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Identifier trt(void) const
bool is_indet(Identifier id) const
bool is_lar(Identifier id) const
bool is_sct(Identifier id) const
bool is_muon(Identifier id) const
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
bool is_trt(Identifier id) const
Identifier indet(void) const
Detector systems:
StatusCode execute()
StatusCode finalize()
void tab(size_t level) const
IdDictCnvTest(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize()
IdDictManager is the interface to identifier dictionaries.
const IdDictMgr * manager(void) const
const std::string & tag() const
Version tag.
Definition IdDictMgr.cxx:54
dictionary_vec get_dictionaries() const
Access to all dictionaries.
std::vector< const IdDictDictionary * > dictionary_vec
Definition IdDictMgr.h:19