ATLAS Offline Software
SiliconID.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3  */
4 
14 #include "GaudiKernel/MsgStream.h"
15 #include <iostream>
16 
20 
22  :
23  AtlasDetectorID("SiliconID", ""),
24  m_wafer_hash_max(0),
25  m_pixel_wafer_hash_max(0),
26  m_pixel_helper(nullptr),
27  m_sct_helper(nullptr)
28 {}
29 
30 SiliconID::SiliconID(const PixelID* pixel_helper, const SCT_ID* sct_helper)
31  :
32  AtlasDetectorID("SiliconID", ""),
33  m_wafer_hash_max(0),
34  m_pixel_wafer_hash_max(0),
35  m_pixel_helper(pixel_helper),
36  m_sct_helper(sct_helper)
37 {}
38 
39 
40 SiliconID::~SiliconID() = default;
41 
42 
43 
44 int
46  MsgStream log(m_msgSvc, "SiliconID");
47  log << MSG::INFO << "Initialize from dictionary" << endmsg;
48  // Check whether this helper should be reinitialized
49  if (!reinitialize(dict_mgr)) {
50  log << MSG::INFO << "Request to reinitialize not satisfied - tags have not changed" << endmsg;
51 
52  return(0);
53  } else {
54  log << MSG::DEBUG << "(Re)initialize" << endmsg;
55  }
56  // init base object
57  if (AtlasDetectorID::initialize_from_dictionary(dict_mgr)) return(1);
58  // Register version of InnerDetector dictionary
59  if (register_dict_tag(dict_mgr, "InnerDetector")) return(1);
60  // Make sure that pix/sct helpers are initialized
61  // CANNOT MODIFY CONST HELPERS
64  return 0;
65 }
66 
67 // From hash get Identifier
68 int
69 SiliconID::get_id(const IdentifierHash& /*hash_id*/,
70  Identifier& id,
71  const IdContext* /*context*/) const {
72  int result = 1;
73  Identifier newid;
74 
75  id = newid;
76  return(result);
77 }
78 
79 int
81  IdentifierHash& hash_id,
82  const IdContext* /*context*/) const {
83  // Get the hash code from either a vec (for wafers) or calculate
84  // it (pixels). For the former, we convert to compact and call
85  // get_hash again. For the latter, we calculate the hash from the
86  // Identifier.
87 
88  int result = 1;
89 
90  hash_id = 0;
91  return(result);
92 }
93 
94 int
96  MsgStream log(m_msgSvc, "IdDictTest_SiliconID");
97 
98  log << MSG::INFO << "test_wafer_packing: wafer hash max, pix, sct "
99  << wafer_hash_max() << " "
100  << m_pixel_helper->wafer_hash_max() << " "
101  << m_sct_helper->wafer_hash_max() << " "
102  << endmsg;
103 
104 
105  bool error = false;
106 
107  int nids = 0;
108  int nblay = 0;
109  int nbar = 0;
110  int nbars = 0;
111  int nbarp = 0;
112  int nHashPix = 0;
113 
114  for (unsigned int i = 0; i < wafer_hash_max(); ++i, ++nids) {
115  Identifier id = wafer_id(i);
116  if (i < 10) {
117  log << MSG::INFO << "test_wafer_packing: id "
118  << show_to_string(id)
119  << endmsg;
120 
121  }
122 
123  // Check hash
125  if (hash != i) {
126  log << MSG::ERROR << "test_wafer_packing: wafer_hash not equal to i "
127  << "hash: " << hash << " i: " << i << " "
128  << show_to_string(id)
129  << endmsg;
130 
131  error = true;
132  }
133 
134  // Check is_barrel
135  if (is_barrel(id)) {
136  nbar++;
137  if (is_sct(id)) {
138  nbars++;
139  if (!m_sct_helper->is_barrel(id)) {
140  log << MSG::ERROR << "test_wafer_packing: is_barrel fails for sct. "
141  << "hash: " << hash << " i: " << i << " "
142  << show_to_string(id)
143  << endmsg;
144 
145  error = true;
146  }
147  } else {
148  nbarp++;
149  if (!m_pixel_helper->is_barrel(id)) {
150  log << MSG::ERROR << "test_wafer_packing: is_barrel fails for pixel. "
151  << "hash: " << hash << " i: " << i << " "
152  << show_to_string(id)
153  << endmsg;
154 
155  error = true;
156  }
157  }
158  }
159 
160  // Check is_blayer
161  if (is_blayer(id)) {
162  nblay++;
163  if (is_sct(id)) {
164  log << MSG::ERROR << "test_wafer_packing: is_blayer is sct. "
165  << "hash: " << hash << " i: " << i << " "
166  << show_to_string(id)
167  << endmsg;
168 
169  error = true;
170  } else {
171  if (!m_pixel_helper->is_blayer(id)) {
172  log << MSG::ERROR << "test_wafer_packing: is_blayer fails for pixel. "
173  << "hash: " << hash << " i: " << i << " "
174  << show_to_string(id)
175  << endmsg;
176 
177  error = true;
178  }
179  }
180  }
181 
182  // Check is_pixel
183  if (is_hash_pixel(i) != is_pixel(id)) {
184  log << MSG::ERROR << "test_wafer_packing: is_hash_pixel "
185  << "hash: " << hash << " i: " << i << " "
186  << show_to_string(id)
187  << endmsg;
188 
189  error = true;
190  } else {
191  nHashPix++;
192  }
193  }
194 
195 
196  log << MSG::INFO << "Looped over " << nids << " hashes "
197  << endmsg;
198  log << MSG::INFO << "Number of is_barrel (pix/sct): " << nbar
199  << " " << nbarp << " " << nbars
200  << endmsg;
201  log << MSG::INFO << "Number of is_blayer: " << nblay
202  << endmsg;
203  log << MSG::INFO << "Number of matching is_hash_pixel/is_pixel: " << nHashPix
204  << endmsg;
205 
206 
207 
208  if (error) return(1);
209 
210  return(0);
211 }
AtlasDetectorID::is_pixel
bool is_pixel(Identifier id) const
Definition: AtlasDetectorID.h:755
SiliconID::get_id
virtual int get_id(const IdentifierHash &hash_id, Identifier &id, const IdContext *context=0) const override final
Create compact id from hash id (return == 0 for OK)
Definition: SiliconID.cxx:69
SiliconID::wafer_id
Identifier wafer_id(IdentifierHash wafer_hash) const
Identifier from hash.
Definition: SiliconID.h:114
AtlasDetectorID::initialize_from_dictionary
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
Definition: AtlasDetectorID.cxx:255
get_generator_info.result
result
Definition: get_generator_info.py:21
SiliconID::wafer_hash_max
size_type wafer_hash_max() const
Hash table maximum sizes.
Definition: SiliconID.h:143
SiliconID::m_sct_helper
const SCT_ID * m_sct_helper
Definition: SiliconID.h:103
AtlasDetectorID::is_sct
bool is_sct(Identifier id) const
Definition: AtlasDetectorID.h:765
SiliconID::wafer_hash
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
Definition: SiliconID.h:130
SiliconID::test_wafer_hashes
int test_wafer_hashes() const
Tests of packing.
Definition: SiliconID.cxx:95
SiliconID::is_barrel
bool is_barrel(const Identifier &id) const
Test for barrel - generic, i.e. works for EITHER pixel or sct id.
Definition: SiliconID.h:150
AtlasDetectorID::m_msgSvc
IMessageSvc * m_msgSvc
pointer to the message service
Definition: AtlasDetectorID.h:369
PixelID::is_blayer
bool is_blayer(const Identifier &id) const
Test for b-layer - WARNING: id MUST be pixel id, otherwise answer is not accurate....
Definition: PixelID.h:614
SiliconID::initialize_from_dictionary
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override final
Initialization from the identifier dictionary.
Definition: SiliconID.cxx:45
SiliconID::m_wafer_hash_max
size_type m_wafer_hash_max
Definition: SiliconID.h:100
SiliconID::is_blayer
bool is_blayer(const Identifier &id) const
Test for pixle b-layer - generic, i.e. works for EITHER pixel or sct id.
Definition: SiliconID.h:163
SiliconID::SiliconID
SiliconID()
Definition: SiliconID.cxx:21
IdDictMgr
Definition: IdDictMgr.h:15
PixelID::is_barrel
bool is_barrel(const Identifier &id) const
Test for barrel - WARNING: id MUST be pixel id, otherwise answer is not accurate. Use SiliconID for g...
Definition: PixelID.h:586
SCT_ID::wafer_hash_max
size_type wafer_hash_max() const
Definition: SCT_ID.cxx:650
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
SiliconID::is_hash_pixel
bool is_hash_pixel(IdentifierHash wafer_hash) const
Test whether hash is pixel or sct.
Definition: SiliconID.h:176
SiliconID.h
This is an Identifier helper class for both the Pixel and SCT subdetectors. This class defines identi...
SiliconID::get_hash
virtual int get_hash(const Identifier &id, IdentifierHash &hash_id, const IdContext *context=0) const override final
Create hash id from compact id (return == 0 for OK)
Definition: SiliconID.cxx:80
SiliconID::~SiliconID
~SiliconID()
AtlasDetectorID::register_dict_tag
int register_dict_tag(const IdDictMgr &dict_mgr, const std::string &dict_name)
Register the file and tag names for a particular IdDict dictionary.
Definition: AtlasDetectorID.cxx:201
PixelID::wafer_hash_max
size_type wafer_hash_max() const
Definition: PixelID.cxx:837
IdentifierHash.h
SiliconID::m_pixel_wafer_hash_max
size_type m_pixel_wafer_hash_max
Definition: SiliconID.h:101
AtlasDetectorID::reinitialize
bool reinitialize(const IdDictMgr &dict_mgr)
Test whether an idhelper should be reinitialized based on the change of tags.
Definition: AtlasDetectorID.cxx:221
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:365
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:108
SCT_ID
Definition: SCT_ID.h:68
python.Constants.INFO
int INFO
Definition: Control/AthenaCommon/python/Constants.py:15
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
PixelID
Definition: PixelID.h:67
error
Definition: IImpactPoint3dEstimator.h:70
IdContext
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition: IdContext.h:26
AtlasDetectorID
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Definition: AtlasDetectorID.h:52
SiliconID::m_pixel_helper
const PixelID * m_pixel_helper
Definition: SiliconID.h:102
SCT_ID::is_barrel
bool is_barrel(const Identifier &id) const
Test for barrel - WARNING: id MUST be sct id, otherwise answer is not accurate. Use SiliconID for gen...
Definition: SCT_ID.h:679
Identifier
Definition: IdentifierFieldParser.cxx:14