ATLAS Offline Software
LArHEC_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/LArHEC_Base_ID.icc
8  * @author scott snyder <snyder@bnl.gov>
9  * @date May, 2013
10  * @brief Inline implementations for LArHEC_Base_ID.
11  */
12 
13 //--------------------
14 // Inline definitions
15 //--------------------
16 
17 //----------------------------------------------------------------------------
18 inline Identifier
19 LArHEC_Base_ID::region_id (const ExpandedIdentifier& exp_id) const
20 {
21  return this->region_id ( exp_id[m_POSNEG_INDEX],
22  exp_id[m_SAMPLING_INDEX],
23  exp_id[m_REGION_INDEX] );
24 }
25 
26 //----------------------------------------------------------------------------
27 inline Identifier
28 LArHEC_Base_ID::channel_id (const ExpandedIdentifier& exp_id) const
29 {
30  return this->channel_id (exp_id[m_POSNEG_INDEX],
31  exp_id[m_SAMPLING_INDEX],
32  exp_id[m_REGION_INDEX],
33  exp_id[m_ETA_INDEX],
34  exp_id[m_PHI_INDEX]);
35 }
36 
37 //----------------------------------------------------------------------------
38 inline Identifier
39 LArHEC_Base_ID::region_id (int pos_neg, int sampling, int region, bool checks) const
40 {
41  // Do checks
42  if(checks) {
43  region_id_checks ( pos_neg, sampling, region );
44  }
45 
46  Identifier result(0);
47 
48  // Pack fields independently
49  m_lar_impl.pack (lar_field_value(), result);
50  m_hec_impl.pack (lar_hec_field_value(),result);
51  m_pn_impl.pack (pos_neg, 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 LArHEC_Base_ID::region_id (int pos_neg, int sampling, int region) const
61 {
62  return region_id (pos_neg, sampling, region, do_checks());
63 }
64 
65 //----------------------------------------------------------------------------
66 inline Identifier
67 LArHEC_Base_ID::channel_id ( int pos_neg, int sampling, int region,
68  int eta, int phi,
69  bool checks) const
70 {
71  // Do checks
72  if(checks) {
73  channel_id_checks( pos_neg, 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_hec_impl.pack (lar_hec_field_value(),result);
80  m_pn_impl.pack (pos_neg, 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 inline Identifier
90 LArHEC_Base_ID::channel_id ( int pos_neg, int sampling, int region,
91  int eta, int phi ) const
92 {
93  return channel_id (pos_neg, sampling, region, eta, phi, do_checks());
94 }
95 
96 //----------------------------------------------------------------------------
97 inline Identifier
98 LArHEC_Base_ID::region_id ( const Identifier channelId ) const
99 {
100 
101  Identifier result(channelId);
102  // reset eta/phi
103  m_eta_impl.reset(result);
104  m_phi_impl.reset(result);
105  m_slar_impl.pack(m_slar,result);
106  return (result);
107 }
108 
109 //----------------------------------------------------------------------------
110 inline Identifier
111 LArHEC_Base_ID::channel_id ( const Identifier regionId,
112  int eta, int phi,
113  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 LArHEC_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 LArHEC_Base_ID::channel_hash (Identifier channelId) const
141 {
142  const HashCalc& hc = m_hash_calcs[m_pn_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 LArHEC_Base_ID::channel_hash_binary_search (Identifier channelId) const
149 {
150  return CaloIDHelper::channel_hash (channelId);
151 }
152 
153 //----------------------------------------------------------------------------
154 inline LArHEC_Base_ID::id_iterator LArHEC_Base_ID::reg_begin () const
155 {
156  return regions().begin();
157 }
158 
159 //----------------------------------------------------------------------------
160 inline LArHEC_Base_ID::id_iterator LArHEC_Base_ID::reg_end (void) const
161 {
162  return regions().end();
163 }
164 
165 //----------------------------------------------------------------------------
166 inline LArHEC_Base_ID::id_range LArHEC_Base_ID::reg_range (void) const
167 {
168  return regions().range();
169 }
170 
171 //----------------------------------------------------------------------------
172 inline LArHEC_Base_ID::id_iterator LArHEC_Base_ID::hec_begin (void) const
173 {
174  return channels().begin();
175 }
176 
177 //----------------------------------------------------------------------------
178 inline LArHEC_Base_ID::id_iterator LArHEC_Base_ID::hec_end (void) const
179 {
180  return channels().end();
181 }
182 
183 //----------------------------------------------------------------------------
184 inline LArHEC_Base_ID::id_range LArHEC_Base_ID::hec_range (void) const
185 {
186  return channels().range();
187 }
188 
189 //----------------------------------------------------------------------------
190 inline const std::vector<Identifier>& LArHEC_Base_ID::channel_ids() const
191 {
192  return channels().ids();
193 }
194 
195 //----------------------------------------------------------------------------
196 inline const std::vector<Identifier>& LArHEC_Base_ID::region_ids() const
197 {
198  return regions().ids();
199 }
200 
201 //----------------------------------------------------------------------------
202 inline int LArHEC_Base_ID::pos_neg(const Identifier id)const
203 {
204  return (m_pn_impl.unpack(id));
205 }
206 
207 //----------------------------------------------------------------------------
208 inline int LArHEC_Base_ID::sampling(const Identifier id)const
209 {
210  return (m_sampling_impl.unpack(id));
211 }
212 
213 //----------------------------------------------------------------------------
214 inline int LArHEC_Base_ID::region(const Identifier id)const
215 {
216  return (m_region_impl.unpack(id));
217 }
218 
219 //----------------------------------------------------------------------------
220 inline int LArHEC_Base_ID::eta(const Identifier id)const
221 {
222  int result = m_eta_impl.unpack(id);
223  return(result);
224 }
225 
226 //----------------------------------------------------------------------------
227 inline int LArHEC_Base_ID::phi(const Identifier id)const
228 {
229  int result = m_phi_impl.unpack(id);
230  return(result);
231 }
232 
233 //----------------------------------------------------------------------------
234 inline int LArHEC_Base_ID::phi_min(const Identifier regId) const
235 {
236  IdentifierHash regHash = region_hash(regId);
237  unsigned int index = regHash;
238  return (m_vecOfPhiMin[index]);
239 }
240 
241 
242 //----------------------------------------------------------------------------
243 inline bool LArHEC_Base_ID::is_supercell (Identifier id) const
244 {
245  return(m_slar_impl.unpack(id)) != 0;
246 }
247 
248 //----------------------------------------------------------------------------
249 inline bool LArHEC_Base_ID::twoSymSides() const
250 {
251  return m_two_sym_sides;
252 }