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