ATLAS Offline Software
Loading...
Searching...
No Matches
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
11
14#include <iostream>
15
19
21 :
22 AtlasDetectorID("SiliconID", ""),
25 m_pixel_helper(nullptr),
26 m_sct_helper(nullptr)
27{}
28
29SiliconID::SiliconID(const PixelID* pixel_helper, const SCT_ID* sct_helper)
30 :
31 AtlasDetectorID("SiliconID", ""),
34 m_pixel_helper(pixel_helper),
35 m_sct_helper(sct_helper)
36{}
37
38
39SiliconID::~SiliconID() = default;
40
41
42
43int
45 ATH_MSG_INFO("Initialize from dictionary");
46 // Check whether this helper should be reinitialized
47 if (!reinitialize(dict_mgr)) {
48 ATH_MSG_INFO("Request to reinitialize not satisfied - tags have not changed");
49
50 return(0);
51 } else {
52 ATH_MSG_DEBUG("(Re)initialize");
53 }
54 // init base object
55 if (AtlasDetectorID::initialize_from_dictionary(dict_mgr)) return(1);
56 // Register version of InnerDetector dictionary
57 if (register_dict_tag(dict_mgr, "InnerDetector")) return(1);
58 // Make sure that pix/sct helpers are initialized
59 // CANNOT MODIFY CONST HELPERS
60 m_pixel_wafer_hash_max = m_pixel_helper->wafer_hash_max();
62 return 0;
63}
64
65// From hash get Identifier
66int
68 Identifier& id,
69 const IdContext* /*context*/) const {
70 int result = 1;
71 Identifier newid;
72
73 id = newid;
74 return(result);
75}
76
77int
79 IdentifierHash& hash_id,
80 const IdContext* /*context*/) const {
81 // Get the hash code from either a vec (for wafers) or calculate
82 // it (pixels). For the former, we convert to compact and call
83 // get_hash again. For the latter, we calculate the hash from the
84 // Identifier.
85
86 int result = 1;
87
88 hash_id = 0;
89 return(result);
90}
91
92int
94
95 ATH_MSG_INFO("test_wafer_packing: wafer hash max, pix, sct "
96 << wafer_hash_max() << " " << m_pixel_helper->wafer_hash_max() << " " << m_sct_helper->wafer_hash_max());
97
98
99 bool error = false;
100
101 int nids = 0;
102 int nblay = 0;
103 int nbar = 0;
104 int nbars = 0;
105 int nbarp = 0;
106 int nHashPix = 0;
107
108 for (unsigned int i = 0; i < wafer_hash_max(); ++i, ++nids) {
109 Identifier id = wafer_id(i);
110 if (i < 10) {
111 ATH_MSG_INFO("test_wafer_packing: id " << show_to_string(id));
112
113 }
114
115 // Check hash
116 IdentifierHash hash = wafer_hash(id);
117 if (hash != i) {
118 ATH_MSG_ERROR("test_wafer_packing: wafer_hash not equal to i hash: " << hash << " i: " << i << " " << show_to_string(id));
119
120 error = true;
121 }
122
123 // Check is_barrel
124 if (is_barrel(id)) {
125 nbar++;
126 if (is_sct(id)) {
127 nbars++;
128 if (!m_sct_helper->is_barrel(id)) {
129 ATH_MSG_ERROR("test_wafer_packing: is_barrel fails for sct. hash: " << hash << " i: " << i << " " << show_to_string(id));
130
131 error = true;
132 }
133 } else {
134 nbarp++;
135 if (!m_pixel_helper->is_barrel(id)) {
136 ATH_MSG_ERROR("test_wafer_packing: is_barrel fails for pixel. hash: " << hash << " i: " << i << " " << show_to_string(id));
137
138 error = true;
139 }
140 }
141 }
142
143 // Check is_blayer
144 if (is_blayer(id)) {
145 nblay++;
146 if (is_sct(id)) {
147 ATH_MSG_ERROR("test_wafer_packing: is_blayer is sct. hash: " << hash << " i: " << i << " " << show_to_string(id));
148
149 error = true;
150 } else {
151 if (!m_pixel_helper->is_blayer(id)) {
152 ATH_MSG_ERROR("test_wafer_packing: is_blayer fails for pixel. hash: " << hash << " i: " << i << " " << show_to_string(id));
153
154 error = true;
155 }
156 }
157 }
158
159 // Check is_pixel
160 if (is_hash_pixel(i) != is_pixel(id)) {
161 ATH_MSG_ERROR("test_wafer_packing: is_hash_pixel hash: " << hash << " i: " << i << " " << show_to_string(id));
162
163 error = true;
164 } else {
165 nHashPix++;
166 }
167 }
168
169
170 ATH_MSG_INFO("Looped over " << nids << " hashes");
171 ATH_MSG_INFO("Number of is_barrel (pix/sct): " << nbar << " " << nbarp << " " << nbars);
172 ATH_MSG_INFO("Number of is_blayer: " << nblay);
173 ATH_MSG_INFO("Number of matching is_hash_pixel/is_pixel: " << nHashPix);
174
175
176
177 if (error) return(1);
178
179 return(0);
180}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
This is an Identifier helper class for both the Pixel and SCT subdetectors.
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override
Initialization from the identifier dictionary.
bool reinitialize(const IdDictMgr &dict_mgr)
Test whether an idhelper should be reinitialized based on the change of tags.
int register_dict_tag(const IdDictMgr &dict_mgr, const std::string &dict_name)
Register the file and tag names for a particular IdDict dictionary.
bool is_sct(Identifier id) const
bool is_pixel(Identifier id) const
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
AtlasDetectorID(const std::string &name, const std::string &group)
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
This is a "hash" representation of an Identifier.
This is an Identifier helper class for the Pixel subdetector.
Definition PixelID.h:67
This is an Identifier helper class for the SCT subdetector.
Definition SCT_ID.h:68
int test_wafer_hashes() const
Tests of packing.
Definition SiliconID.cxx:93
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
bool is_barrel(const Identifier &id) const
Test for barrel - generic, i.e. works for EITHER pixel or sct id.
Definition SiliconID.h:150
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:78
virtual int initialize_from_dictionary(const IdDictMgr &dict_mgr) override final
Initialization from the identifier dictionary.
Definition SiliconID.cxx:44
const PixelID * m_pixel_helper
Definition SiliconID.h:102
const SCT_ID * m_sct_helper
Definition SiliconID.h:103
size_type wafer_hash_max() const
Hash table maximum sizes.
Definition SiliconID.h:143
bool is_hash_pixel(IdentifierHash wafer_hash) const
Test whether hash is pixel or sct.
Definition SiliconID.h:176
size_type m_wafer_hash_max
Definition SiliconID.h:100
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
Definition SiliconID.h:130
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:67
size_type m_pixel_wafer_hash_max
Definition SiliconID.h:101
Identifier wafer_id(IdentifierHash wafer_hash) const
Identifier from hash.
Definition SiliconID.h:114