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