ATLAS Offline Software
IdDictCnvTest.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  IdDict converter package
7  -----------------------------------------
8  ***************************************************************************/
9 
10 //<doc><file> $Id: IdDictCnvTest.cxx,v 1.6 2004-10-12 16:45:36 schaffer Exp $
11 //<version> $Name: not supported by cvs2svn $
12 
13 #include "IdDictCnvTest.h"
14 
15 // Id-related includes
16 #include "Identifier/Range.h"
20 
21 // Athena-related includes
22 #include "StoreGate/DataHandle.h"
23 #include "GaudiKernel/MsgStream.h"
24 #include "Gaudi/Property.h"
25 #include "GaudiKernel/IChronoStatSvc.h"
26 
27 
29 
30 void
31 IdDictCnvTest::tab (size_t level) const
32 {
33  for (size_t i = 0; i < level; ++i) msg() << " ";
34 }
35 
37 // CONSTRUCTOR:
39 
40 IdDictCnvTest::IdDictCnvTest(const std::string& name, ISvcLocator* pSvcLocator)
41  :
42  AthAlgorithm(name, pSvcLocator)
43 {}
44 
46 // DESTRUCTOR:
48 
50 { }
51 
53 // INITIALIZE:
54 // The initialize method will create all the required algorithm objects
55 // Note that it is NOT NECESSARY to run the initialize of individual
56 // sub-algorithms. The framework takes care of it.
58 
61 {
62  ATH_MSG_INFO ( "Start initialization" );
63 
64  const IdDictManager* idDictMgr = nullptr;
65  ATH_CHECK( detStore()->retrieve(idDictMgr, "IdDict") );
66  ATH_MSG_DEBUG ( " Found the IdDictManager. " );
67  ATH_MSG_DEBUG ( " Tag is " << idDictMgr->manager()->tag() );
68 
69  const IdDictMgr::dictionary_map& dm = idDictMgr->manager()->get_dictionary_map ();
70  IdDictMgr::dictionary_map::const_iterator it;
71 
72  int n = 0;
73 
74  if (dm.begin () == dm.end ()) {
75  // No dicts found
76  ATH_MSG_ERROR ( "No dictionaries found!" );
77  return StatusCode::FAILURE;
78  }
79 
80 
81  for (it = dm.begin (); it != dm.end (); ++it, ++n) {
82  const IdDictDictionary& dictionary = *((*it).second);
83 
84 
85  ATH_MSG_INFO( "---- " << n << " ----------------------------" );
86  std::string version = ("" != dictionary.m_version) ? dictionary.m_version : "default";
87  ATH_MSG_INFO ( "Dictionary " << dictionary.m_name
88  << " version " << version );
89 
90  if(dictionary.verify()) {
91  ATH_MSG_INFO( "Dictionary verification is OK" );
92  }
93  else {
94  ATH_MSG_FATAL( "Dictionary verification has failed: "
95  << dictionary.m_name << " multirange: "
96  << (std::string)dictionary.build_multirange() );
97  return StatusCode::FAILURE;
98  }
99 
100 
101 // std::vector<IdDictRegion*>::const_iterator rit;
102 // for (rit = dictionary.m_regions.begin (); rit != dictionary.m_regions.end (); ++rit) {
103 // const IdDictRegion& region = *(*rit);
104 
105 // log << MSG::DEBUG
106 // << "region #" << region.m_index
107 // << endmsg;
108 
109 // std::vector <IdDictFieldImplementation>::const_iterator fit;
110 
111 // size_t width = 0;
112 
113 // for (fit = region.m_implementation.begin ();
114 // fit != region.m_implementation.end ();
115 // ++fit) {
116 // const IdDictFieldImplementation& impl = *fit;
117 
118 // size_t w = impl.range()->m_field->m_name.size ();
119 
120 // if (w > width) width = w;
121 // }
122 
123 // int bits = 0;
124 
125 // for (fit = region.m_implementation.begin ();
126 // fit != region.m_implementation.end ();
127 // ++fit) {
128 // const IdDictFieldImplementation& impl = *fit;
129 
130 // size_t w = impl.range()->m_field->m_name.size ();
131 
132 // log << MSG::DEBUG
133 // << " implement field #" << impl.range()->m_field->m_index <<
134 // " " << impl.range()->m_field->m_name;
135 
136 // tab (width - w);
137 
138 // // int index = impl.field();
139 // // std::string label = impl.range()->m_field->labels[index]->m_name;
140 // // std::cout << " name " << label << " ";
141 
142 // log << " -> " << (std::string) impl.field()
143 // << "/" << (std::string) impl.ored_field()
144 // << " (" << impl.bits() << " bits)"
145 // << endmsg;
146 
147 // bits += impl.bits();
148 // }
149 
150 // Range range = region.build_range ();
151 
152 // log << MSG::DEBUG
153 // << " -> " << (std::string) range <<
154 // " (cardinality=" << range.cardinality () << ")" <<
155 // " (" << bits << " bits)"
156 // << endmsg;
157 // }
158 // }
159  }
160 
161 
162  ATH_MSG_DEBUG ( " Get AtlasDetectorID. " );
163  const AtlasDetectorID* atlasID = nullptr;
164  // Access AtlasID from detector store
165  ATH_CHECK( detStore()->retrieve(atlasID, "AtlasID") );
166  ATH_MSG_DEBUG ( " Found the AtlasDetectorID. " );
167 
168  ATH_MSG_DEBUG ( " Begin tests for AtlasDetectorID. " );
169  Identifier id = atlasID->indet();
170  ATH_MSG_DEBUG ( " is indet " << atlasID->show_to_string(id)
171  << " " << atlasID->is_indet(id) );
172  ATH_MSG_DEBUG ( " is sct " << atlasID->show_to_string(id)
173  << " " << atlasID->is_sct(id) );
174  ATH_MSG_DEBUG ( " is lar " << atlasID->show_to_string(id)
175  << " " << atlasID->is_lar(id) );
176  ATH_MSG_DEBUG ( " is muon " << atlasID->show_to_string(id)
177  << " " << atlasID->is_muon(id) );
178  id = atlasID->trt();
179  ATH_MSG_DEBUG ( " is indet " << atlasID->show_to_string(id)
180  << " " << atlasID->is_indet(id) );
181  ATH_MSG_DEBUG ( " is sct " << atlasID->show_to_string(id)
182  << " " << atlasID->is_sct(id) );
183  ATH_MSG_DEBUG ( " is trt " << atlasID->show_to_string(id)
184  << " " << atlasID->is_trt(id) );
185  ATH_MSG_DEBUG ( " is lar " << atlasID->show_to_string(id)
186  << " " << atlasID->is_lar(id) );
187  ATH_MSG_DEBUG ( " is muon " << atlasID->show_to_string(id)
188  << " " << atlasID->is_muon(id) );
189 
190  ATH_MSG_INFO( "Initialization completed successfully" );
191 
192  return StatusCode::SUCCESS;
193 
194 }
195 
196 
198 StatusCode
200 {
201  return StatusCode::SUCCESS;
202 }
203 
204 
206 // FINALIZE:
208 
209 StatusCode
211 {
212  ATH_MSG_DEBUG ( "finalize completed successfully" );
213  return StatusCode::SUCCESS;
214 }
215 
216 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
IdDictMgr::dictionary_map
std::map< std::string, IdDictDictionary * > dictionary_map
Definition: IdDictMgr.h:16
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
IdDictCnvTest::execute
StatusCode execute()
Definition: IdDictCnvTest.cxx:199
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AtlasDetectorID::is_lar
bool is_lar(Identifier id) const
Definition: AtlasDetectorID.h:689
AtlasDetectorID::is_sct
bool is_sct(Identifier id) const
Definition: AtlasDetectorID.h:770
Range.h
skel.it
it
Definition: skel.GENtoEVGEN.py:396
IdDictMgr::get_dictionary_map
const dictionary_map & get_dictionary_map() const
Access to all dictionaries.
Definition: IdDictMgr.cxx:111
AtlasDetectorID::is_trt
bool is_trt(Identifier id) const
Definition: AtlasDetectorID.h:782
IdDictManager.h
AtlasDetectorID::indet
Identifier indet(void) const
Detector systems:
Definition: AtlasDetectorID.cxx:26
DataHandle.h
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
IdDictCnvTest.h
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IdDictCnvTest::tab
void tab(size_t level) const
Definition: IdDictCnvTest.cxx:31
AthAlgorithm
Definition: AthAlgorithm.h:47
ReadCellNoiseFromCool.dm
dm
Definition: ReadCellNoiseFromCool.py:235
master.dictionary
dictionary
Definition: master.py:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
IdDictManager
IdDictManager is the interface to identifier dictionaries.
Definition: IdDictManager.h:36
IdentifierHash.h
AtlasDetectorID::is_indet
bool is_indet(Identifier id) const
Definition: AtlasDetectorID.h:683
IdDictDictionary
Definition: IdDictDictionary.h:30
IdDictCnvTest::finalize
StatusCode finalize()
Definition: IdDictCnvTest.cxx:210
get_generator_info.version
version
Definition: get_generator_info.py:33
AtlasDetectorID::trt
Identifier trt(void) const
Definition: AtlasDetectorID.cxx:93
AtlasDetectorID::is_muon
bool is_muon(Identifier id) const
Definition: AtlasDetectorID.h:701
AtlasDetectorID::show_to_string
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:574
IdDictCnvTest::~IdDictCnvTest
~IdDictCnvTest()
Definition: IdDictCnvTest.cxx:49
IdDictManager::manager
const IdDictMgr * manager(void) const
Definition: IdDictManager.cxx:37
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
IdDictCnvTest::IdDictCnvTest
IdDictCnvTest(const std::string &name, ISvcLocator *pSvcLocator)
Definition: IdDictCnvTest.cxx:40
IdDictMgr::tag
const std::string & tag() const
Version tag.
Definition: IdDictMgr.cxx:57
AtlasDetectorID
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Definition: AtlasDetectorID.h:57
IdDictCnvTest::initialize
StatusCode initialize()
Definition: IdDictCnvTest.cxx:60
Identifier
Definition: IdentifierFieldParser.cxx:14