2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
7 * @file CaloIdentifier/LArHEC_Base_ID.icc
8 * @author scott snyder <snyder@bnl.gov>
10 * @brief Inline implementations for LArHEC_Base_ID.
13 //--------------------
15 //--------------------
17 //----------------------------------------------------------------------------
19 LArHEC_Base_ID::region_id (const ExpandedIdentifier& exp_id) const
21 return this->region_id ( exp_id[m_POSNEG_INDEX],
22 exp_id[m_SAMPLING_INDEX],
23 exp_id[m_REGION_INDEX] );
26 //----------------------------------------------------------------------------
28 LArHEC_Base_ID::channel_id (const ExpandedIdentifier& exp_id) const
30 return this->channel_id (exp_id[m_POSNEG_INDEX],
31 exp_id[m_SAMPLING_INDEX],
32 exp_id[m_REGION_INDEX],
37 //----------------------------------------------------------------------------
39 LArHEC_Base_ID::region_id (int pos_neg, int sampling, int region, bool checks) const
43 region_id_checks ( pos_neg, sampling, region );
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);
60 LArHEC_Base_ID::region_id (int pos_neg, int sampling, int region) const
62 return region_id (pos_neg, sampling, region, do_checks());
65 //----------------------------------------------------------------------------
67 LArHEC_Base_ID::channel_id ( int pos_neg, int sampling, int region,
73 channel_id_checks( pos_neg, sampling, region, eta, phi );
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);
90 LArHEC_Base_ID::channel_id ( int pos_neg, int sampling, int region,
91 int eta, int phi ) const
93 return channel_id (pos_neg, sampling, region, eta, phi, do_checks());
96 //----------------------------------------------------------------------------
98 LArHEC_Base_ID::region_id ( const Identifier channelId ) const
101 Identifier result(channelId);
103 m_eta_impl.reset(result);
104 m_phi_impl.reset(result);
105 m_slar_impl.pack(m_slar,result);
109 //----------------------------------------------------------------------------
111 LArHEC_Base_ID::channel_id ( const Identifier regionId,
117 channel_id_checks( regionId, eta, phi );
120 Identifier result(regionId);
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);
133 LArHEC_Base_ID::channel_id ( const Identifier regionId,
134 int eta, int phi ) const
136 return channel_id (regionId, eta, phi, do_checks());
139 //----------------------------------------------------------------------------
140 inline IdentifierHash LArHEC_Base_ID::channel_hash (Identifier channelId) const
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) );
147 //----------------------------------------------------------------------------
148 inline IdentifierHash LArHEC_Base_ID::channel_hash_binary_search (Identifier channelId) const
150 return CaloIDHelper::channel_hash (channelId);
153 //----------------------------------------------------------------------------
154 inline LArHEC_Base_ID::id_iterator LArHEC_Base_ID::reg_begin () const
156 return regions().begin();
159 //----------------------------------------------------------------------------
160 inline LArHEC_Base_ID::id_iterator LArHEC_Base_ID::reg_end (void) const
162 return regions().end();
165 //----------------------------------------------------------------------------
166 inline LArHEC_Base_ID::id_range LArHEC_Base_ID::reg_range (void) const
168 return regions().range();
171 //----------------------------------------------------------------------------
172 inline LArHEC_Base_ID::id_iterator LArHEC_Base_ID::hec_begin (void) const
174 return channels().begin();
177 //----------------------------------------------------------------------------
178 inline LArHEC_Base_ID::id_iterator LArHEC_Base_ID::hec_end (void) const
180 return channels().end();
183 //----------------------------------------------------------------------------
184 inline LArHEC_Base_ID::id_range LArHEC_Base_ID::hec_range (void) const
186 return channels().range();
189 //----------------------------------------------------------------------------
190 inline const std::vector<Identifier>& LArHEC_Base_ID::channel_ids() const
192 return channels().ids();
195 //----------------------------------------------------------------------------
196 inline const std::vector<Identifier>& LArHEC_Base_ID::region_ids() const
198 return regions().ids();
201 //----------------------------------------------------------------------------
202 inline int LArHEC_Base_ID::pos_neg(const Identifier id)const
204 return (m_pn_impl.unpack(id));
207 //----------------------------------------------------------------------------
208 inline int LArHEC_Base_ID::sampling(const Identifier id)const
210 return (m_sampling_impl.unpack(id));
213 //----------------------------------------------------------------------------
214 inline int LArHEC_Base_ID::region(const Identifier id)const
216 return (m_region_impl.unpack(id));
219 //----------------------------------------------------------------------------
220 inline int LArHEC_Base_ID::eta(const Identifier id)const
222 int result = m_eta_impl.unpack(id);
226 //----------------------------------------------------------------------------
227 inline int LArHEC_Base_ID::phi(const Identifier id)const
229 int result = m_phi_impl.unpack(id);
233 //----------------------------------------------------------------------------
234 inline int LArHEC_Base_ID::phi_min(const Identifier regId) const
236 IdentifierHash regHash = region_hash(regId);
237 unsigned int index = regHash;
238 return (m_vecOfPhiMin[index]);
242 //----------------------------------------------------------------------------
243 inline bool LArHEC_Base_ID::is_supercell (Identifier id) const
245 return(m_slar_impl.unpack(id)) != 0;
248 //----------------------------------------------------------------------------
249 inline bool LArHEC_Base_ID::twoSymSides() const
251 return m_two_sym_sides;