2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
7 * @file CaloIdentifier/LArEM_Base_ID.icc
8 * @author scott snyder <snyder@bnl.gov>
10 * @brief Inline implementations for LArEM_Base_ID.
14 //--------------------
16 //--------------------
18 //----------------------------------------------------------------------------
20 LArEM_Base_ID::region_id ( const ExpandedIdentifier& exp_id) const
22 return this->region_id ( exp_id[m_BEC_INDEX],
23 exp_id[m_SAMPLING_INDEX],
24 exp_id[m_REGION_INDEX] );
27 //----------------------------------------------------------------------------
29 LArEM_Base_ID::channel_id ( const ExpandedIdentifier& exp_id) const
31 return this->channel_id (exp_id[m_BEC_INDEX],
32 exp_id[m_SAMPLING_INDEX],
33 exp_id[m_REGION_INDEX],
38 //----------------------------------------------------------------------------
40 LArEM_Base_ID::region_id (int barrel_ec, int sampling, int region, bool checks) const
45 region_id_checks ( barrel_ec, sampling, region );
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);
62 LArEM_Base_ID::region_id (int barrel_ec, int sampling, int region) const
64 return region_id (barrel_ec, sampling, region, do_checks());
68 //----------------------------------------------------------------------------
70 LArEM_Base_ID::channel_id ( int barrel_ec, int sampling, int region,
71 int eta, int phi, bool checks ) const
75 channel_id_checks( barrel_ec, sampling, region, eta, phi );
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);
93 LArEM_Base_ID::channel_id ( int barrel_ec, int sampling, int region,
94 int eta, int phi ) const
96 return channel_id (barrel_ec, sampling, region, eta, phi, do_checks());
100 //----------------------------------------------------------------------------
102 LArEM_Base_ID::region_id ( const Identifier channelId ) const
104 Identifier result(channelId);
106 m_eta_impl.reset(result);
107 m_phi_impl.reset(result);
108 m_slar_impl.pack(m_slar,result);
112 //----------------------------------------------------------------------------
114 LArEM_Base_ID::channel_id ( const Identifier regionId,
115 int eta, int phi, bool checks ) const
119 channel_id_checks( regionId, eta, phi );
122 Identifier result(regionId);
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);
135 LArEM_Base_ID::channel_id ( const Identifier regionId,
136 int eta, int phi ) const
138 return channel_id (regionId, eta, phi, do_checks());
141 //----------------------------------------------------------------------------
142 inline IdentifierHash LArEM_Base_ID::channel_hash (Identifier channelId) const
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) );
149 //----------------------------------------------------------------------------
150 inline IdentifierHash LArEM_Base_ID::channel_hash_binary_search (Identifier channelId) const
152 return CaloIDHelper::channel_hash (channelId);
155 //----------------------------------------------------------------------------
156 inline LArEM_Base_ID::id_iterator LArEM_Base_ID::reg_begin (void) const
158 return regions().begin();
161 //----------------------------------------------------------------------------
162 inline LArEM_Base_ID::id_iterator LArEM_Base_ID::reg_end (void) const
164 return regions().end();
167 //----------------------------------------------------------------------------
168 inline LArEM_Base_ID::id_range LArEM_Base_ID::reg_range (void) const
170 return regions().range();
173 //----------------------------------------------------------------------------
174 inline LArEM_Base_ID::id_iterator LArEM_Base_ID::em_begin (void) const
176 return channels().begin();
179 //----------------------------------------------------------------------------
180 inline LArEM_Base_ID::id_iterator LArEM_Base_ID::em_end (void) const
182 return channels().end();
185 //----------------------------------------------------------------------------
186 inline LArEM_Base_ID::id_range LArEM_Base_ID::em_range (void) const
188 return channels().range();
191 //----------------------------------------------------------------------------
192 inline const std::vector<Identifier>& LArEM_Base_ID::channel_ids() const
194 return channels().ids();
197 //----------------------------------------------------------------------------
198 inline bool LArEM_Base_ID::is_em_barrel(const Identifier id) const
200 return (is_lar_em(id) && (abs(barrel_ec(id)))==1);
203 //----------------------------------------------------------------------------
204 inline bool LArEM_Base_ID::is_em_endcap(const Identifier id) const
206 return (is_lar_em(id) && (abs(barrel_ec(id)))>1);
209 //----------------------------------------------------------------------------
210 inline bool LArEM_Base_ID::is_em_endcap_outer(const Identifier id) const
212 return (is_lar_em(id) && (abs(barrel_ec(id)))==2);
215 //----------------------------------------------------------------------------
216 inline bool LArEM_Base_ID::is_em_endcap_inner(const Identifier id) const
218 return (is_lar_em(id) && (abs(barrel_ec(id)))==3);
221 //----------------------------------------------------------------------------
222 inline int LArEM_Base_ID::barrel_ec(const Identifier id)const
224 return (m_bec_impl.unpack(id));
227 //----------------------------------------------------------------------------
228 inline int LArEM_Base_ID::sampling(const Identifier id)const
230 return (m_sampling_impl.unpack(id));
233 //----------------------------------------------------------------------------
234 inline int LArEM_Base_ID::region(const Identifier id)const
236 return (m_region_impl.unpack(id));
239 //----------------------------------------------------------------------------
240 inline int LArEM_Base_ID::eta(const Identifier id)const
242 int result = m_eta_impl.unpack(id);
246 //----------------------------------------------------------------------------
247 inline int LArEM_Base_ID::phi(const Identifier id)const
249 int result = m_phi_impl.unpack(id);
253 //----------------------------------------------------------------------------
254 inline int LArEM_Base_ID::phi_min(const Identifier regId) const
256 IdentifierHash regHash = region_hash(regId);
257 unsigned int index = regHash;
258 return (m_vecOfPhiMin[index]);
262 //----------------------------------------------------------------------------
263 inline bool LArEM_Base_ID::twoSymSides() const
265 return m_two_sym_sides;