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