ATLAS Offline Software
Loading...
Searching...
No Matches
LArHEC_Base_ID.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4/**
5 * @file CaloIdentifier/LArHEC_Base_ID.icc
6 * @author scott snyder <snyder@bnl.gov>
7 * @date May, 2013
8 * @brief Inline implementations for LArHEC_Base_ID.
9 */
10
11//--------------------
12// Inline definitions
13//--------------------
14
15//----------------------------------------------------------------------------
16inline Identifier
17LArHEC_Base_ID::region_id (const ExpandedIdentifier& exp_id) const
18{
19 return this->region_id ( exp_id[m_POSNEG_INDEX],
20 exp_id[m_SAMPLING_INDEX],
21 exp_id[m_REGION_INDEX] );
22}
23
24//----------------------------------------------------------------------------
25inline Identifier
26LArHEC_Base_ID::channel_id (const ExpandedIdentifier& exp_id) const
27{
28 return this->channel_id (exp_id[m_POSNEG_INDEX],
29 exp_id[m_SAMPLING_INDEX],
30 exp_id[m_REGION_INDEX],
31 exp_id[m_ETA_INDEX],
32 exp_id[m_PHI_INDEX]);
33}
34
35//----------------------------------------------------------------------------
36inline Identifier
37LArHEC_Base_ID::region_id (int pos_neg, int sampling, int region, bool checks) const
38{
39 // Do checks
40 if(checks) {
41 region_id_checks ( pos_neg, sampling, region );
42 }
43
44 Identifier result(0);
45
46 // Pack fields independently
47 m_lar_impl.pack (lar_field_value(), result);
48 m_hec_impl.pack (lar_hec_field_value(),result);
49 m_pn_impl.pack (pos_neg, result);
50 m_sampling_impl.pack (sampling, result);
51 m_region_impl.pack (region, result);
52 m_slar_impl.pack (m_slar, result);
53
54 return result;
55}
56
57inline Identifier
58LArHEC_Base_ID::region_id (int pos_neg, int sampling, int region) const
59{
60 return region_id (pos_neg, sampling, region, do_checks());
61}
62
63//----------------------------------------------------------------------------
64inline Identifier
65LArHEC_Base_ID::channel_id ( int pos_neg, int sampling, int region,
66 int eta, int phi,
67 bool checks) const
68{
69 // Do checks
70 if(checks) {
71 channel_id_checks( pos_neg, sampling, region, eta, phi );
72 }
73
74 Identifier result(0);
75 // Pack fields independently
76 m_lar_impl.pack (lar_field_value(), result);
77 m_hec_impl.pack (lar_hec_field_value(),result);
78 m_pn_impl.pack (pos_neg, result);
79 m_sampling_impl.pack (sampling, result);
80 m_region_impl.pack (region, result);
81 m_eta_impl.pack (eta, result);
82 m_phi_impl.pack (phi, result);
83 m_slar_impl.pack (m_slar, result);
84
85 return result;
86}
87inline Identifier
88LArHEC_Base_ID::channel_id ( int pos_neg, int sampling, int region,
89 int eta, int phi ) const
90{
91 return channel_id (pos_neg, sampling, region, eta, phi, do_checks());
92}
93
94//----------------------------------------------------------------------------
95inline Identifier
96LArHEC_Base_ID::region_id ( const Identifier channelId ) const
97{
98
99 Identifier result(channelId);
100 // reset eta/phi
101 m_eta_impl.reset(result);
102 m_phi_impl.reset(result);
103 m_slar_impl.pack(m_slar,result);
104 return (result);
105}
106
107//----------------------------------------------------------------------------
108inline Identifier
109LArHEC_Base_ID::channel_id ( const Identifier regionId,
110 int eta, int phi,
111 bool checks) const
112{
113 // Do checks
114 if(checks) {
115 channel_id_checks( regionId, eta, phi );
116 }
117
118 Identifier result(regionId);
119
120 // Reset the fields and then set the values
121 m_eta_impl.reset (result);
122 m_phi_impl.reset (result);
123 m_eta_impl.pack (eta, result);
124 m_phi_impl.pack (phi, result);
125 m_slar_impl.pack (m_slar, result);
126
127 return result;
128}
129
130inline Identifier
131LArHEC_Base_ID::channel_id ( const Identifier regionId,
132 int eta, int phi ) const
133{
134 return channel_id (regionId, eta, phi, do_checks());
135}
136
137//----------------------------------------------------------------------------
138inline IdentifierHash LArHEC_Base_ID::channel_hash (Identifier channelId) const
139{
140 const HashCalc& hc = m_hash_calcs[m_pn_reg_impl.unpack(channelId)];
141 //return (hc.m_hash + (eta(channelId)-hc.m_etamin)*hc.m_nphi + phi(channelId)-hc.m_phimin );
142 return (hc.m_hash + (m_eta_impl.unpack(channelId)-hc.m_etamin)*hc.m_nphi + (m_phi_impl.unpack(channelId)-hc.m_phimin) );
143}
144
145//----------------------------------------------------------------------------
146inline IdentifierHash LArHEC_Base_ID::channel_hash_binary_search (Identifier channelId) const
147{
148 return CaloIDHelper::channel_hash (channelId);
149}
150
151//----------------------------------------------------------------------------
152inline LArHEC_Base_ID::id_iterator LArHEC_Base_ID::reg_begin () const
153{
154 return regions().begin();
155}
156
157//----------------------------------------------------------------------------
158inline LArHEC_Base_ID::id_iterator LArHEC_Base_ID::reg_end () const
159{
160 return regions().end();
161}
162
163//----------------------------------------------------------------------------
164inline LArHEC_Base_ID::id_range LArHEC_Base_ID::reg_range () const
165{
166 return regions().range();
167}
168
169//----------------------------------------------------------------------------
170inline LArHEC_Base_ID::id_iterator LArHEC_Base_ID::hec_begin () const
171{
172 return channels().begin();
173}
174
175//----------------------------------------------------------------------------
176inline LArHEC_Base_ID::id_iterator LArHEC_Base_ID::hec_end () const
177{
178 return channels().end();
179}
180
181//----------------------------------------------------------------------------
182inline LArHEC_Base_ID::id_range LArHEC_Base_ID::hec_range () const
183{
184 return channels().range();
185}
186
187//----------------------------------------------------------------------------
188inline const std::vector<Identifier>& LArHEC_Base_ID::channel_ids() const
189{
190 return channels().ids();
191}
192
193//----------------------------------------------------------------------------
194inline const std::vector<Identifier>& LArHEC_Base_ID::region_ids() const
195{
196 return regions().ids();
197}
198
199//----------------------------------------------------------------------------
200inline int LArHEC_Base_ID::pos_neg(const Identifier id)const
201{
202 return (m_pn_impl.unpack(id));
203}
204
205//----------------------------------------------------------------------------
206inline int LArHEC_Base_ID::sampling(const Identifier id)const
207{
208 return (m_sampling_impl.unpack(id));
209}
210
211//----------------------------------------------------------------------------
212inline int LArHEC_Base_ID::region(const Identifier id)const
213{
214 return (m_region_impl.unpack(id));
215}
216
217//----------------------------------------------------------------------------
218inline int LArHEC_Base_ID::eta(const Identifier id)const
219{
220 int result = m_eta_impl.unpack(id);
221 return(result);
222}
223
224//----------------------------------------------------------------------------
225inline int LArHEC_Base_ID::phi(const Identifier id)const
226{
227 int result = m_phi_impl.unpack(id);
228 return(result);
229}
230
231//----------------------------------------------------------------------------
232inline int LArHEC_Base_ID::phi_min(const Identifier regId) const
233{
234 IdentifierHash regHash = region_hash(regId);
235 unsigned int index = regHash;
236 return (m_vecOfPhiMin[index]);
237}
238
239
240//----------------------------------------------------------------------------
241inline bool LArHEC_Base_ID::is_supercell (Identifier id) const
242{
243 return(m_slar_impl.unpack(id)) != 0;
244}
245
246//----------------------------------------------------------------------------
247inline bool LArHEC_Base_ID::twoSymSides() const
248{
249 return m_two_sym_sides;
250}