ATLAS Offline Software
LArFCAL_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/LArFCAL_Base_ID.icc
6  * @author naoko kanaya <nkanaya@cern.ch>
7  * @date May, 2013
8  * @brief Inline implementations for LArFCAL_Base_ID.
9  */
10 
11 
12 //--------------------
13 // Inline definitions
14 //--------------------
15 
16 //----------------------------------------------------------------------------
17 inline Identifier
18 LArFCAL_Base_ID::module_id (const ExpandedIdentifier& exp_id) const
19 {
20  return this->module_id ( exp_id[m_POSNEG_INDEX],
21  exp_id[m_MODULE_INDEX] );
22 }
23 
24 //----------------------------------------------------------------------------
25 inline Identifier
26 LArFCAL_Base_ID::channel_id (const ExpandedIdentifier& exp_id) const
27 {
28  return this->channel_id (exp_id[m_POSNEG_INDEX],
29  exp_id[m_MODULE_INDEX],
30  exp_id[m_ETA_INDEX],
31  exp_id[m_PHI_INDEX]);
32 }
33 
34 //----------------------------------------------------------------------------
35 inline Identifier
36 LArFCAL_Base_ID::module_id (int pos_neg, int module, bool checks) const
37 {
38  // Do checks
39  if(checks) {
40  module_id_checks ( pos_neg, module );
41  }
42 
43  Identifier result(0);
44 
45  // Pack fields independently
46  m_lar_impl.pack (lar_field_value(), result);
47  m_fcal_impl.pack (lar_fcal_field_value(), result);
48  m_pn_impl.pack (pos_neg, result);
49  m_module_impl.pack (module, result);
50  m_slar_impl.pack (m_slar, result);
51 
52  return result;
53 }
54 
55 inline Identifier
56 LArFCAL_Base_ID::module_id (int pos_neg, int module) const
57 {
58  return module_id (pos_neg, module, do_checks());
59 }
60 
61 //----------------------------------------------------------------------------
62 inline Identifier
63 LArFCAL_Base_ID::channel_id ( int pos_neg, int module,
64  int eta, int phi, bool checks ) const
65 {
66  // Do checks
67  if(checks) {
68  channel_id_checks( pos_neg, module, eta, phi );
69  }
70 
71  Identifier result(0);
72  // Pack fields independently
73  m_lar_impl.pack (lar_field_value(), result);
74  m_fcal_impl.pack (lar_fcal_field_value(), result);
75  m_pn_impl.pack (pos_neg, result);
76  m_module_impl.pack (module, result);
77  m_eta_impl.pack (eta, result);
78  m_phi_impl.pack (phi, result);
79  m_slar_impl.pack (m_slar, result);
80 
81  return result;
82 }
83 
84 inline Identifier
85 LArFCAL_Base_ID::channel_id ( int pos_neg, int module,
86  int eta, int phi ) const
87 {
88  return channel_id (pos_neg, module, eta, phi, do_checks());
89 }
90 
91 
92 //----------------------------------------------------------------------------
93 inline Identifier
94 LArFCAL_Base_ID::module_id ( const Identifier channelId ) const
95 {
96 
97  Identifier result(channelId);
98  // reset eta/phi
99  m_eta_impl.reset(result);
100  m_phi_impl.reset(result);
101  m_slar_impl.pack(m_slar,result);
102  return (result);
103 }
104 
105 //----------------------------------------------------------------------------
106 inline Identifier
107 LArFCAL_Base_ID::channel_id ( const Identifier module_id,
108  int eta, int phi, bool checks ) const
109 {
110  // Do checks
111  if(checks) {
112  channel_id_checks( module_id, eta, phi );
113  }
114 
115  Identifier result(module_id);
116 
117  // Reset the fields and then set the values
118  m_eta_impl.reset (result);
119  m_phi_impl.reset (result);
120  m_eta_impl.pack (eta, result);
121  m_phi_impl.pack (phi, result);
122  m_slar_impl.pack (m_slar, result);
123 
124  return result;
125 }
126 
127 inline Identifier
128 LArFCAL_Base_ID::channel_id ( const Identifier module_id,
129  int eta, int phi ) const
130 {
131  return channel_id (module_id, eta, phi, do_checks());
132 }
133 
134 //----------------------------------------------------------------------------
135 inline Identifier LArFCAL_Base_ID::module_id (IdentifierHash module_hash_id) const
136 {
137  return region_id (module_hash_id);
138 }
139 
140 //----------------------------------------------------------------------------
141 inline IdentifierHash LArFCAL_Base_ID::module_hash (Identifier module_id) const
142 {
143  return region_hash (module_id);
144 }
145 
146 //----------------------------------------------------------------------------
147 inline IdentifierHash LArFCAL_Base_ID::channel_hash_binary_search (Identifier channelId) const
148 {
149  return channel_hash (channelId);
150 }
151 
152 //----------------------------------------------------------------------------
153 inline LArFCAL_Base_ID::size_type LArFCAL_Base_ID::module_hash_max () const
154 {
155  return region_hash_max();
156 }
157 
158 //----------------------------------------------------------------------------
159 inline LArFCAL_Base_ID::id_iterator LArFCAL_Base_ID::mod_begin () const
160 {
161  return regions().begin();
162 }
163 
164 //----------------------------------------------------------------------------
165 inline LArFCAL_Base_ID::id_iterator LArFCAL_Base_ID::mod_end () const
166 {
167  return regions().end();
168 }
169 
170 //----------------------------------------------------------------------------
171 inline LArFCAL_Base_ID::id_range LArFCAL_Base_ID::mod_range () const
172 {
173  return regions().range();
174 }
175 
176 //----------------------------------------------------------------------------
177 inline LArFCAL_Base_ID::id_iterator LArFCAL_Base_ID::fcal_begin () const
178 {
179  return channels().begin();
180 }
181 
182 //----------------------------------------------------------------------------
183 inline LArFCAL_Base_ID::id_iterator LArFCAL_Base_ID::fcal_end () const
184 {
185  return channels().end();
186 }
187 
188 //----------------------------------------------------------------------------
189 inline LArFCAL_Base_ID::id_range LArFCAL_Base_ID::fcal_range () const
190 {
191  return channels().range();
192 }
193 
194 //----------------------------------------------------------------------------
195 inline const std::vector<Identifier>& LArFCAL_Base_ID::channel_ids() const
196 {
197  return channels().ids();
198 }
199 
200 //----------------------------------------------------------------------------
201 inline int LArFCAL_Base_ID::pos_neg (const Identifier id)const
202 {
203  return (m_pn_impl.unpack(id));
204 }
205 
206 //----------------------------------------------------------------------------
207 inline int LArFCAL_Base_ID::module (const Identifier id)const
208 {
209  return (m_module_impl.unpack(id));
210 }
211 
212 //----------------------------------------------------------------------------
213 inline int LArFCAL_Base_ID::eta (const Identifier id)const
214 {
215  int result = m_eta_impl.unpack(id);
216  return(result);
217 }
218 
219 //----------------------------------------------------------------------------
220 inline int LArFCAL_Base_ID::phi(const Identifier id)const
221 {
222  int result = m_phi_impl.unpack(id);
223  return(result);
224 }
225 
226 //----------------------------------------------------------------------------
227 inline int LArFCAL_Base_ID::phi_min(const Identifier modId) const
228 {
229  IdentifierHash modHash = module_hash(modId);
230  unsigned int index = modHash;
231  return (m_vecOfPhiMin[index]);
232 }