Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
LArEM_Base_ID.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
11 #include <cmath>
12 
14 #include "LArEM_region.h"
15 #include "IdDict/IdDictDefs.h"
16 #include "CxxUtils/StrFormat.h"
17 #include "CxxUtils/trapping_fp.h"
18 
20 
21 
22 LArEM_Base_ID::LArEM_Base_ID (const std::string& name, bool supercell)
23  : CaloIDHelper (name),
24  m_slar (supercell ? 1 : 0)
25 {
26 }
27 
28 
30 {
33  for (; first != last; ++first) delete (*first);
34 }
35 
37 {
38  return(m_slar_impl.unpack(id)) != 0;
39 }
40 
41 
42 int LArEM_Base_ID::eta_min(const Identifier regId) const
43 {
44  ExpandedIdentifier expId;
45  IdContext context = region_context();
46  if(!get_expanded_id(regId, expId, &context)) {
47  int result = -999;
48  for (unsigned int i = 0; i < m_full_em_range.size(); ++i) {
49  const Range& range = m_full_em_range[i];
50  if (range.match(expId)) {
51  const Range::field& eta_field = range[m_ETA_INDEX];
52  if (not eta_field.empty()) {
53  int etamin = eta_field.get_minimum();
54  if (-999 == result) {
55  result = etamin;
56  }
57  else {
58  if (etamin < result) result = etamin;
59  }
60  }
61  }
62  }
63  return (result);
64  }
65  return (-999);
66 }
67 
68 int LArEM_Base_ID::eta_max(const Identifier regId) const
69 {
70  ExpandedIdentifier expId;
71  IdContext context = region_context();
72  if(!get_expanded_id(regId, expId, &context)) {
73  int result = -999;
74  for (unsigned int i = 0; i < m_full_em_range.size(); ++i) {
75  const Range& range = m_full_em_range[i];
76  if (range.match(expId)) {
77  const Range::field& eta_field = range[m_ETA_INDEX];
78  if (not eta_field.empty()) {
79  int etamax = eta_field.get_maximum();
80  if (result < etamax) result = etamax;
81  }
82  }
83  }
84  return (result);
85  }
86  return (-999); // default
87 }
88 
90 {
91  ExpandedIdentifier expId;
92  IdContext region_cntxt = region_context();
93  if(!get_expanded_id(regId, expId, &region_cntxt)) {
94  int result = -999;
95  for (unsigned int i = 0; i < m_full_em_range.size(); ++i) {
96  const Range& range = m_full_em_range[i];
97  if (range.match(expId)) {
98  const Range::field& phi_field = range[m_PHI_INDEX];
99  if (not phi_field.empty()) {
100  int phimin = phi_field.get_minimum();
101  if (-999 == result) {
102  result = phimin;
103  }
104  else {
105  if (phimin < result) result = phimin;
106  }
107  }
108  }
109  }
110  return (result);
111  }
112  return (-999); // default
113 }
114 
115 int LArEM_Base_ID::phi_max(const Identifier regId) const
116 {
117  ExpandedIdentifier expId;
118  IdContext context = region_context();
119  if(!get_expanded_id(regId, expId, &context)) {
120  int result = -999;
121  for (unsigned int i = 0; i < m_full_em_range.size(); ++i) {
122  const Range& range = m_full_em_range[i];
123  if (range.match(expId)) {
124  const Range::field& phi_field = range[m_PHI_INDEX];
125  if (not phi_field.empty()) {
126  int phimax = phi_field.get_maximum();
127  if (result < phimax) result = phimax;
128  }
129  }
130  }
131  return (result);
132  }
133  return (-999); // default
134 }
135 
136 void LArEM_Base_ID::region_id_checks ( int barrel_ec, int sampling, int region ) const
137 {
138  // Check that id is within allowed range
139 
140  // Fill expanded id
142  expId << barrel_ec << sampling << region ;
143 
144  if (!m_full_region_range.match(expId)) {
145  std::string errorMessage = "LArEM_Base_ID::region_id_checks() result is not OK: ID, range = "
146  + std::string(expId) + " , " + (std::string)m_full_region_range;
147  throw LArID_Exception(errorMessage , 5);
148  }
149 }
150 
151 
152 void LArEM_Base_ID::channel_id_checks ( int barrel_ec, int sampling, int region,
153  int eta, int phi ) const
154 {
155  // Check that id is within allowed range
156 
157  // Fill expanded id
159  expId << barrel_ec << sampling << region << eta << phi << m_slar ;
160 
161  if (!m_full_em_range.match(expId)) {
162  std::string errorMessage = "LArEM_Base_ID::channel_id_checks() result is not OK: ID, range = "
163  + std::string(expId) + " , " + (std::string)m_full_em_range;
164  throw LArID_Exception(errorMessage , 6);
165  }
166 }
167 
169  int eta, int phi ) const
170 {
171  // Check that id is within allowed range
172 
173  // Fill expanded id
174  ExpandedIdentifier expId;
175 
176  IdContext context = region_context();
177  if (get_expanded_id(regionId, expId, &context)) {
178  std::string errorMessage = "LArEM_Base_ID::channel_id_checks(regId) result is not OK: ID = "
179  + show_to_string(regionId) ;
180  throw LArID_Exception(errorMessage , 6);
181  }
182 
183  expId << eta << phi << m_slar;
184 
185  if (!m_full_em_range.match(expId)) {
186  std::string errorMessage = "LArEM_Base_ID::channel_id_checks(regId) result is not OK: ID, range = "
187  + std::string(expId) + " , " + (std::string)m_full_em_range;
188  throw LArID_Exception(errorMessage , 6);
189  }
190 }
191 
192 
193 
194 
195 int LArEM_Base_ID::get_expanded_id (const Identifier& id, ExpandedIdentifier& exp_id, const IdContext* context) const
196 {
197  // We assume that the context is >= region
198  exp_id.clear();
199  exp_id << lar_field_value()
200  << lar_em_field_value()
201  << barrel_ec(id)
202  << sampling(id)
203  << region(id);
204  if(context && context->end_index() >= m_ETA_INDEX) {
205  exp_id << eta(id);
206  if(context->end_index() >= m_PHI_INDEX) {
207  exp_id << phi(id);
208  if ( context->end_index() >= m_SLAR_INDEX) {
209  exp_id << (unsigned)is_supercell(id);
210  }
211  }
212  }
213  return (0);
214 }
215 
217 {
218  MsgStream log(m_msgSvc, "LArEM_Base_ID" );
219  if(!dict()) {
220  if(m_msgSvc) {
221  log << MSG::ERROR << "initLevelsFromDict - dictionary NOT initialized "
222  << endmsg;
223  }
224  else {
225  std::cout << "LArEM_Base_ID::initLevelsFromDict - dictionary NOT initialized "
226  << std::endl ;
227  }
228  return (1);
229  }
230 
231  // Find out which identifier field corresponds to each level.
232 
233  m_LAR_INDEX = 999 ;
234  m_EM_INDEX = 999 ;
235  m_BEC_INDEX = 999 ;
236  m_SAMPLING_INDEX = 999 ;
237  m_REGION_INDEX = 999 ;
238  m_ETA_INDEX = 999 ;
239  m_PHI_INDEX = 999 ;
240  m_SLAR_INDEX = 999 ;
241 
242  // Find a EM region
243  IdDictField* field = dict()->find_field("subdet") ;
244  if (field) {
245  m_LAR_INDEX = field->m_index ;
246  }
247  else {
248  if(m_msgSvc) {
249  log << MSG::ERROR << "initLevelsFromDict - unable to find 'subdet' field "
250  << endmsg;
251  }
252  else {
253  std::cout << "LArEM_Base_ID::initLevelsFromDict - unable to find 'subdet' field "
254  << std::endl ;
255  }
256  return (1);
257  }
258 
259  field = dict()->find_field("part") ;
260  if (field) {
261  m_EM_INDEX = field->m_index ;
262  }
263  else {
264  if(m_msgSvc) {
265  log << MSG::ERROR << "initLevelsFromDict - unable to find 'part' field "
266  << endmsg;
267  }
268  else {
269  std::cout << "LArEM_Base_ID::initLevelsFromDict - unable to find 'part' field "
270  << std::endl ;
271  }
272  return (1);
273  }
274 
275  field = dict()->find_field("barrel-endcap") ;
276  if (field) {
277  m_BEC_INDEX = field->m_index ;
278  }
279  else {
280  if(m_msgSvc) {
281  log << MSG::ERROR << "initLevelsFromDict - unable to find 'barrel-endcap' field "
282  << endmsg;
283  }
284  else {
285  std::cout << "LArEM_Base_ID::initLevelsFromDict - unable to find 'barrel-endcap' field "
286  << std::endl ;
287  }
288  return (1);
289  }
290 
291  field = dict()->find_field("sampling") ;
292  if (field) {
293  m_SAMPLING_INDEX = field->m_index ;
294  }
295  else {
296  if(m_msgSvc) {
297  log << MSG::ERROR << "initLevelsFromDict - unable to find 'sampling' field "
298  << endmsg;
299  }
300  else {
301  std::cout << "LArEM_Base_ID::initLevelsFromDict - unable to find 'sampling' field "
302  << std::endl ;
303  }
304  return (1);
305  }
306 
307  field = dict()->find_field("region") ;
308  if (field) {
309  m_REGION_INDEX = field->m_index ;
310  }
311  else {
312  if(m_msgSvc) {
313  log << MSG::ERROR << "initLevelsFromDict - unable to find 'region' field "
314  << endmsg;
315  }
316  else {
317  std::cout << "LArEM_Base_ID::initLevelsFromDict - unable to find 'region' field "
318  << std::endl ;
319  }
320  return (1);
321  }
322 
323  field = dict()->find_field("eta") ;
324  if (field) {
325  m_ETA_INDEX = field->m_index ;
326  }
327  else {
328  if(m_msgSvc) {
329  log << MSG::ERROR << "initLevelsFromDict - unable to find 'eta' field "
330  << endmsg;
331  }
332  else {
333  std::cout << "LArEM_Base_ID::initLevelsFromDict - unable to find 'eta' field "
334  << std::endl ;
335  }
336  return (1);
337  }
338 
339  field = dict()->find_field("phi") ;
340  if (field) {
341  m_PHI_INDEX = field->m_index ;
342  }
343  else {
344  if(m_msgSvc) {
345  log << MSG::ERROR << "initLevelsFromDict - unable to find 'phi' field "
346  << endmsg;
347  }
348  else {
349  std::cout << "LArEM_Base_ID::initLevelsFromDict - unable to find 'phi' field "
350  << std::endl ;
351  }
352  return (1);
353  }
354 
355  field = dict()->find_field("is-slar") ;
356  if (field) {
357  m_SLAR_INDEX = field->m_index ;
358  }
359  else {
360  if(m_msgSvc) {
361  log << MSG::ERROR << "initLevelsFromDict - unable to find 'is-slar' field "
362  << endmsg;
363  }
364  else {
365  std::cout << "LArEM_Base_ID::initLevelsFromDict - unable to find 'is-slar' field "
366  << std::endl ;
367  }
368  return (1);
369  }
370 
371  // Set the field implementations
372 
374  if ( !group ){
375  log << MSG::ERROR << "initLevelsFromDict - cannot find " << group_name
376  << " group' field " << endmsg;
377  }
378  else {
379  m_em_region_index = group->regions()[0]->m_index;
380  }
382 
383  m_lar_impl = region.m_implementation[m_LAR_INDEX];
384  m_em_impl = region.m_implementation[m_EM_INDEX];
385  m_bec_impl = region.m_implementation[m_BEC_INDEX];
386  m_sampling_impl = region.m_implementation[m_SAMPLING_INDEX];
387  m_region_impl = region.m_implementation[m_REGION_INDEX];
388  m_eta_impl = region.m_implementation[m_ETA_INDEX];
389  m_phi_impl = region.m_implementation[m_PHI_INDEX];
390  m_slar_impl = region.m_implementation[m_SLAR_INDEX];
391 
392  if (!m_quiet) {
393  if(m_msgSvc) {
394  log << MSG::DEBUG << "decode index and bit fields for each level: " << endmsg;
395  log << MSG::DEBUG << "lar " << m_lar_impl.show_to_string() << endmsg;
396  log << MSG::DEBUG << "em " << m_em_impl.show_to_string() << endmsg;
397  log << MSG::DEBUG << "bec " << m_bec_impl.show_to_string() << endmsg;
398  log << MSG::DEBUG << "samp " << m_sampling_impl.show_to_string() << endmsg;
399  log << MSG::DEBUG << "reg " << m_region_impl.show_to_string() << endmsg;
400  log << MSG::DEBUG << "eta " << m_eta_impl.show_to_string() << endmsg;
401  log << MSG::DEBUG << "phi " << m_phi_impl.show_to_string() << endmsg;
402  log << MSG::DEBUG << "is-slar " << m_slar_impl.show_to_string() << endmsg;
403  }
404  else {
405  std::cout << "decode index and bit fields for each level: " << std::endl;
406  std::cout << "lar " << m_lar_impl.show_to_string() << std::endl;
407  std::cout << "em " << m_em_impl.show_to_string() << std::endl;
408  std::cout << "bec " << m_bec_impl.show_to_string() << std::endl;
409  std::cout << "samp " << m_sampling_impl.show_to_string() << std::endl;
410  std::cout << "reg " << m_region_impl.show_to_string() << std::endl;
411  std::cout << "eta " << m_eta_impl.show_to_string() << std::endl;
412  std::cout << "phi " << m_phi_impl.show_to_string() << std::endl;
413  std::cout << "is-slar " << m_slar_impl.show_to_string() << std::endl;
414  }
415  }
416 
417 
418  return(0) ;
419 }
420 
421 
423 {
424  if (channels().init (*this, "channels",
426  m_SLAR_INDEX))
427  return 1;
428  if (regions().init (*this, "regions",
431  return 1;
432 
433  return (0);
434 }
435 
436 
437 int
439  const std::string& group_name)
440 /*=================================================================*/
441 {
442  MsgStream log(m_msgSvc, "LArEM_Base_ID" );
443 
444  log << MSG::DEBUG << "initialize_base_from_dictionary" << endmsg;
445 
446  // Check whether this helper should be reinitialized
447  if (!reinitialize(dict_mgr)) {
448  log << MSG::DEBUG << "Request to reinitialize not satisfied - tags have not changed" << endmsg;
449  return (0);
450  }
451  else {
452  if(m_msgSvc)log << MSG::DEBUG << "(Re)initialize" << endmsg;
453  }
454 
455  // init base object
457  "LArCalorimeter"))
458  return (1);
459 
460  // initialize dictionary version
461  AtlasDetectorID::setDictVersion(dict_mgr, "LArCalorimeter");
462 
463  // Initialize the field indices
464  if (initLevelsFromDict(group_name)) return (1);
465 
466  // Find value for the field LAr Calorimeter
467  const IdDictDictionary* atlasDict = dict_mgr.find_dictionary ("ATLAS");
468  int larField = -1;
469  if (atlasDict->get_label_value("subdet", "LArCalorimeter", larField)) {
470  if(m_msgSvc) {
471  log << MSG::ERROR << "Could not get value for label 'LArCalorimeter' of field 'subdet' in dictionary "
472  << atlasDict->m_name
473  << endmsg;
474  }
475  else {
476  std::cout << "Could not get value for label 'LArCalorimeter' of field 'subdet' in dictionary "
477  << atlasDict->m_name
478  << std::endl;
479  }
480  return (1);
481  }
482 
483  // Find value for the field LArEM
484  int larEmField = -1;
485  if (dict()->get_label_value("part", "LArEM", larEmField)) {
486  if(m_msgSvc) {
487  log << MSG::ERROR << "Could not get value for label 'LArEM' of field 'part' in dictionary "
488  << dict()->m_name
489  << endmsg;
490  }
491  else {
492  std::cout << "Could not get value for label 'LArEM' of field 'part' in dictionary "
493  << dict()->m_name
494  << std::endl;
495  }
496  return (1);
497  }
498 
499  // Set up id for region and range prefix
500  ExpandedIdentifier reg_id;
501  reg_id.add(larField);
502  reg_id.add(larEmField);
503  Range prefix;
504 
506  m_full_region_range = dict()->build_multirange(reg_id, group_name, prefix, "region");
507 
508  if (!m_quiet) {
509  if(m_msgSvc) {
510  log << MSG::DEBUG << " initialize_from_dict : "
511  << endmsg;
512  log << MSG::DEBUG << " region range -> " << (std::string)m_full_region_range
513  << endmsg;
514  log << MSG::DEBUG << " channel range -> " << (std::string)m_full_em_range
515  << endmsg;
516  }
517  else {
518  std::cout << " LArEM_Base_ID::initialize_from_dict : "
519  << std::endl;
520  std::cout << " region range -> " << (std::string)m_full_region_range
521  << std::endl;
522  std::cout << " channel range -> " << (std::string)m_full_em_range
523  << std::endl;
524  }
525  }
526 
527  // initialize m_two_sym_sides
528  m_two_sym_sides = ( dictionaryVersion() == "fullAtlas" );
529 
530 
531  // Setup the hash tables
532  if(init_hashes()) return (1);
533 
534  // initialize dictionary regions
535  if (fill_vec_of_dict_regions (group_name)) return 1;
536 
537  m_vecOfPhiMin.resize(regions().hash_max());
538  for (unsigned int i = 0; i < regions().hash_max(); ++i) {
539  Identifier regId = region_id(i);
540  m_vecOfPhiMin[i] = phi_min_init(regId);
541  }
542 
543 
544  // Setup for hash calculation
545 
546  // We use the structure of the region definitions in the
547  // dictionary to optimize. Specifically, each dict region
548  // corresponds to two regions of uniform eta/phi granularity (+/-
549  // in barrel/endcap). The lookup table only needs to contain the
550  // hash offset for each region and the number of phi cells.
551 
552  // The implementation requires:
553 
554  // 1) a lookup table for each region containing hash offset and
555  // nphi
556  // 2) a decoder to access the "index" corresponding to the
557  // bec/samp/reg fields. These fields use 8 bits, so the
558  // vector has a length of 256 for only 36 regions.
559 
560 
561  // Create decoder for fields bec to region
563  m_bec_impl.bits() +
567  m_bec_reg_impl.set_bits(bits, bits_offset);
568 
569  // std::cout << "bec_reg " << m_bec_reg_impl.decode_index() << " "
570  // << (std::string)m_bec_reg_impl.ored_field() << " "
571  // << std::hex << m_bec_reg_impl.mask() << " "
572  // << m_bec_reg_impl.zeroing_mask() << " "
573  // << std::dec << m_bec_reg_impl.shift()
574  // << " " << m_bec_reg_impl.bits() << " " <<m_bec_reg_impl.bits_offset()
575  // << std::endl;
576 
577 
578  // Set up vector as lookup table for hash calculation.
579  m_hash_calcs.resize(256);
580  for (unsigned int i = 0; i < m_full_em_range.size(); ++i) {
581  const Range* range = &m_full_em_range[i];
582  ExpandedIdentifier exp_id = range->minimum ();
583  HashCalc hc;
584 
586  exp_id[m_SAMPLING_INDEX],
587  exp_id[m_REGION_INDEX],
588  exp_id[m_ETA_INDEX],
589  exp_id[m_PHI_INDEX]);
591  hc.m_hash = min_neg;
592  Identifier minReg = region_id(min) ;
593  hc.m_etamin = eta_min(minReg);
594  hc.m_phimin = phi_min(minReg);
595  hc.m_nphi = (*range)[m_PHI_INDEX].get_indices();
597 
598  // Flip sign for bec if 2 symmetric sides (ATLAS case, not TB)
599  if(m_two_sym_sides) {
600  Identifier min1 = channel_id (-exp_id[m_BEC_INDEX],
601  exp_id[m_SAMPLING_INDEX],
602  exp_id[m_REGION_INDEX],
603  exp_id[m_ETA_INDEX],
604  exp_id[m_PHI_INDEX]);
606  hc.m_hash = min_pos;
607  m_hash_calcs[m_bec_reg_impl.unpack(min1)] = hc;
608  }
609 
610 
611  if (m_bec_reg_impl.unpack(min) > 255) {
612  if(m_msgSvc) {
613  log << MSG::WARNING << "min > 255 "
614  << i << " "
615  << show_to_string(min) << " "
616  << m_bec_reg_impl.unpack(min) << " "
617  << endmsg;
618  }
619  else {
620  std::cout << "min > 255 "
621  << i << " "
622  << show_to_string(min) << " "
623  << m_bec_reg_impl.unpack(min) << " "
624  << std::endl;
625  }
626  }
627  }
628 
629 // Some detailed printout
630 // ExpandedIdentifier exp_id = range->maximum ();
631 // Identifier max = channel_id (exp_id[m_BEC_INDEX],
632 // exp_id[m_SAMPLING_INDEX],
633 // exp_id[m_REGION_INDEX],
634 // exp_id[m_ETA_INDEX],
635 // exp_id[m_PHI_INDEX]);
636 // Identifier max0 = channel_id (-exp_id[m_BEC_INDEX],
637 // exp_id[m_SAMPLING_INDEX],
638 // exp_id[m_REGION_INDEX],
639 // exp_id[m_ETA_INDEX],
640 // exp_id[m_PHI_INDEX]);
641 // std::cout << "channel ranges, id, hash "
642 // << i << " "
643 // << show_to_string(min) << " "
644 // << show_to_string(max0) << " "
645 // << show_to_string(min1) << " "
646 // << show_to_string(max) << " "
647 // << channel_hash_binary_search(min) << " "
648 // << channel_hash_binary_search(min1) << " "
649 // << min_pos << " "
650 // << range->cardinality() << " "
651 // << std::endl;
652 // }
653 
654  // Check hash calculation
655  for (unsigned int i = 0; i < channels().hash_max(); ++i) {
656  Identifier id = channel_id(i);
657  if (channel_hash(id) != i) {
658  if(m_msgSvc) {
659  log << MSG::ERROR << "channel ranges, id, hash "
660  << show_to_string(id) << " "
661  << channel_hash(id) << " "
662  << i
663  << endmsg;
664  }
665  else {
666  std::cout << " ***** Error ";
667  std::cout << "channel ranges, id, hash "
668  << show_to_string(id) << " "
669  << channel_hash(id) << " "
670  << i
671  << std::endl;
672  }
673  }
674  }
675 
676  // Setup hash tables for finding neighbors (at the end of initialisation,
677  // to benefit from optimization
678  if(m_do_neighbours) {
679  if(init_neighbors()) return (1);
680  }
681 
682  return 0;
683 }
684 
685 
687  std::vector<IdentifierHash>& neighbourList) const
688 {
689  int result = 1;
690 
691  neighbourList.clear();
692 
693  if(!m_do_neighbours) {
694  if(m_msgSvc) {
695  MsgStream log(m_msgSvc, "LArEM_Base_ID" );
696  log << MSG::WARNING << "neighbours not initialized !!! returning empty list" << endmsg;
697  }
698  else {
699  std::cout << " WARNING: neighbours not initialized !!! returning empty list " << std::endl;
700  }
701  return result;
702  }
703 
704  if(id >= channel_hash_max()) {
705  if(m_msgSvc) {
706  MsgStream log(m_msgSvc, "LArEM_Base_ID" );
707  log << MSG::WARNING << "neighbours requested for non-existing channel -- id/max " << id << "/"
708  << channel_hash_max() << endmsg;
709  }
710  else {
711  std::cout << " neighbours requested for non-existing channel -- id/max " << id << "/"
712  << channel_hash_max() << std::endl;
713  }
714  return result;
715  }
716 
717  const short int maxNeighb=22;
718  IdentifierHash neighbList[maxNeighb];
719  int neighbourIndex = 0;
720 
721  // cell index
722  unsigned int index=id;
723 
724  //
725  // .... find in which region is the cell
726  //
727  auto itr = std::upper_bound(m_cells.begin(), m_cells.end(), index);
728  unsigned short int regionN = (itr - m_cells.begin()) - 1;
729  assert (regionN < m_vecOfRegions.size());
730  // get pointer to this region
731  LArEM_region* emRegion = m_vecOfRegions[regionN];
732  // retrieve characteristic numbers for this region
733  short int nPhi = emRegion->phiN();
734  float gPhi = emRegion->phiGranularity();
735  unsigned int minHash = emRegion->hashMin();
736  unsigned int maxHash = emRegion->hashMax();
737 
738  bool corners2DOnly = ( (option & LArNeighbours::all2D)
740  //
741  // .... previous neighbour in phi
742  //
743  IdentifierHash prevNeighbInPhi=NOT_VALID_HASH;
744  if( (option & LArNeighbours::prevInPhi)
745  || corners2DOnly ){
746  if(!get_prevInPhi(emRegion, index, nPhi, minHash, neighbourIndex, neighbList)){
747  // always 1 and only 1 neighbour in phi in ATLAS, but 0 or 1 neighbour in phi in TB
748  prevNeighbInPhi=neighbList[neighbourIndex-1];
749  if( corners2DOnly ){
750  neighbourIndex--;
751  }
752  }
753  }
754 
755  //
756  // ....next neighbour in phi
757  //
758  IdentifierHash nextNeighbInPhi=NOT_VALID_HASH;
759  if( (option & LArNeighbours::nextInPhi)
760  || corners2DOnly ){
761  if(!get_nextInPhi(emRegion, index, nPhi, minHash, neighbourIndex, neighbList)){
762  // always 1 and only 1 neighbour in phi in ATLAS, but 0 or 1 neighbour in phi in TB
763  nextNeighbInPhi=neighbList[neighbourIndex-1];
764  if( corners2DOnly ){
765  neighbourIndex--;
766  }
767  }
768  }
769 
770  //
771  // ....previous neighbours in eta
772  //
773  unsigned int nPrevBiggerCell=NOT_VALID_HASH;
774  if( (option & LArNeighbours::prevInEta) ){
775  get_prevInEta(emRegion, index, nPhi, gPhi, minHash, neighbourIndex, neighbList, nPrevBiggerCell);
776  }
777 
778  //
779  // ....next neighbours in eta
780  //
781  unsigned int nNextBiggerCell=NOT_VALID_HASH;
782  if( (option & LArNeighbours::nextInEta) ){
783  get_nextInEta(emRegion, index, nPhi, gPhi, maxHash, neighbourIndex, neighbList, nNextBiggerCell);
784  }
785 
786  //
787  // ....corners in the same sampling
788  //
789  if( (option & LArNeighbours::corners2D) ){
790  if(prevNeighbInPhi != NOT_VALID_HASH){
791  unsigned int index1=prevNeighbInPhi;
792  int oldNeighbourIndex = neighbourIndex;
793  // allow only 1 corner cell in order to avoid the problem of
794  // non-mutual neighbourness
795  // since the cells come ordered in phi it should be the last cell for
796  // prevNeighbInPhi as starting points
797  get_prevInEta(emRegion, index1, nPhi, gPhi, minHash, neighbourIndex, neighbList, nPrevBiggerCell);
798  if ( neighbourIndex > oldNeighbourIndex+1 ) {
799  neighbList[oldNeighbourIndex] = neighbList[neighbourIndex-1];
800  neighbourIndex = oldNeighbourIndex+1;
801  }
802  oldNeighbourIndex = neighbourIndex;
803  get_nextInEta(emRegion, index1, nPhi, gPhi, maxHash, neighbourIndex, neighbList, nNextBiggerCell);
804  if ( neighbourIndex > oldNeighbourIndex+1 ) {
805  neighbList[oldNeighbourIndex] = neighbList[neighbourIndex-1];
806  neighbourIndex = oldNeighbourIndex+1;
807  }
808  }
809 
810  if(nextNeighbInPhi != NOT_VALID_HASH){
811  unsigned int index2=nextNeighbInPhi;
812  int oldNeighbourIndex = neighbourIndex;
813  // allow only 1 corner cell in order to avoid the problem of
814  // non-mutual neighbourness
815  // since the cells come ordered in phi it should be the 1st cell for
816  // nextNeighbInPhi
817  get_prevInEta(emRegion, index2, nPhi, gPhi, minHash, neighbourIndex, neighbList, nPrevBiggerCell);
818  if ( neighbourIndex > oldNeighbourIndex+1 ) {
819  neighbourIndex = oldNeighbourIndex+1;
820  }
821  oldNeighbourIndex = neighbourIndex;
822  get_nextInEta(emRegion, index2, nPhi, gPhi, maxHash, neighbourIndex, neighbList, nNextBiggerCell);
823  if ( neighbourIndex > oldNeighbourIndex+1 ) {
824  neighbourIndex = oldNeighbourIndex+1;
825  }
826  }
827  }
828 
829  //
830  // .... neighbours in sampling (common code)
831  // EM caracteristics = granularity changes in both eta and phi + partial overlap of samplings
832  //
833  if( (option & LArNeighbours::upAndDown) ) {
834  // granularity of the initial region
835  double gEta = (double)(emRegion->etaGranularity());
836  // initial eta
837  int nEta = int( (index-minHash) / nPhi);
838  double absEta = (double)(emRegion->etaMin()) + (double)(nEta * gEta);
839 
840  // previous neighbours in sampling
841  if( (option & LArNeighbours::prevInSamp) ){
842  get_prevInSamp(emRegion, index, nPhi, minHash, gEta, gPhi, absEta, neighbourIndex, neighbList);
843  }
844 
845  // next neighbours in sampling
846  if( (option & LArNeighbours::nextInSamp) ){
847  get_nextInSamp(emRegion, index, nPhi, minHash, gEta, gPhi, absEta, neighbourIndex, neighbList);
848  }
849  }
850 
851  //
852  // .... neighbours across subdet
853  //
855  // granularity of the initial region
856  double gEta = (double)(emRegion->etaGranularity());
857  // initial eta
858  int nEta = int( (index-minHash) / nPhi);
859  double absEta = (double)(emRegion->etaMin()) + (double)(nEta * gEta);
860 
861  // prev neighbours in subdet
862  if( (option & LArNeighbours::prevSubDet) ){
863  get_prevInSubdet(emRegion, index, nPhi, minHash, gEta, gPhi, absEta, neighbourIndex, neighbList);
864  }
865  // next neighbours in subdet
866  if( (option & LArNeighbours::nextSubDet) ){
867  get_nextInSubdet(emRegion, index, nPhi, minHash, gEta, gPhi, absEta, neighbourIndex, neighbList);
868  }
869  }
870 
871 
872  neighbourList.resize(neighbourIndex);
873  if (neighbourIndex > 0) {
874  if (neighbourIndex <= maxNeighb) {
875  std::copy (&neighbList[0], &neighbList[neighbourIndex], neighbourList.begin());
876  result = 0 ;
877  } else {
878  if(m_msgSvc) {
879  MsgStream log(m_msgSvc, "LArEM_Base_ID" );
880  log << MSG::WARNING << " more than 22 neighbours for this cell, NONE will be retained" << endmsg;
881  }
882  else {
883  std::cout << "WARNING: more than 22 neighbours for this cell, NONE will be retained " << neighbourIndex << std::endl;
884  }
885  }
886  }
887 
888  return result;
889 }
890 
891 
892 int LArEM_Base_ID::get_prevInPhi(const LArEM_region* emRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
893  int& neighbourIndex, IdentifierHash* neighbList)
894 {
895  int result = 1;
896  unsigned int nIndex = index-1;
897  if(!emRegion->isPhiMin(index)) {
898  if( ((index-minHash)%(nPhi)) == 0 ) nIndex=index+nPhi-1;
899  IdentifierHash nHash = nIndex;
900  neighbList[neighbourIndex] = nHash;
901  neighbourIndex++;
902  result = 0;
903  }
904  return result;
905 }
906 
907 int LArEM_Base_ID::get_nextInPhi(const LArEM_region* emRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
908  int& neighbourIndex, IdentifierHash* neighbList)
909 {
910  int result = 1;
911  if(!emRegion->isPhiMax(index)) {
912  unsigned int nIndex = index+1;
913  if( ((index-minHash+1)%(nPhi)) == 0 ) nIndex=index-nPhi+1;
914  IdentifierHash nHash = nIndex;
915  neighbList[neighbourIndex] = nHash;
916  neighbourIndex++;
917  result = 0;
918  }
919  return result;
920 }
921 
922 int LArEM_Base_ID::get_prevInEta(const LArEM_region* emRegion, const unsigned int& index, const short int& nPhi, const float& gPhi,
923  const unsigned int& minHash,
924  int& neighbourIndex, IdentifierHash* neighbList, unsigned int& nBiggerCell) const
925 {
926  int result = 1;
927 
928  unsigned int nIndex = 0;
929  IdentifierHash nHash = 0;
930 
931  if( emRegion->isEtaMin(index)){
932  // eta == etaMin -> go to previous region in eta
933  short int nPrevEtaRegion = emRegion->prevEtaRegion();
934  // no neighbour if no previous region in eta
935  if( nPrevEtaRegion != NOT_VALID_REGION ) {
936  LArEM_region* prevEmRegion = m_vecOfRegions[nPrevEtaRegion];
937  if(emRegion->isFirstBarrelRegion()) {
938  // special case: barrel middle
939  unsigned int minHashMinus = prevEmRegion->hashMin();
940  nIndex = minHashMinus + index-minHash ;
941  nHash = nIndex;
942  neighbList[neighbourIndex] = nHash;
943  neighbourIndex++;
944  result = 0;
945  }
946  else {
947  // Tell clang to optimize assuming that FP exceptions can trap.
948  // Otherwise, it can vectorize the division, which can lead to
949  // spurious division-by-zero traps from unused vector lanes.
951  short int nPhiMinus = prevEmRegion->phiN();
952  float gPhiMinus= prevEmRegion->phiGranularity();
953  unsigned int maxHashMinus = prevEmRegion->hashMax();
954  float phiMargin = 0.25*std::min(gPhi,gPhiMinus);
955  float rPhi = (index-minHash)*gPhi+emRegion->phiMin();
956  int nPhiMinusFirst = int(std::floor((rPhi -prevEmRegion->phiMin())
957  /gPhiMinus+phiMargin))
958  +maxHashMinus-nPhiMinus;
959  int nPhiMinusNext = int(std::floor((rPhi+gPhi-prevEmRegion->phiMin())
960  /gPhiMinus+phiMargin))
961  +maxHashMinus-nPhiMinus;
962  if ( nPhiMinusNext == nPhiMinusFirst ) nPhiMinusNext++;
963 
964  for(int i=nPhiMinusFirst; i<nPhiMinusNext; i++){
965  nIndex = i ;
966  if(nIndex != nBiggerCell) {
967  nHash = nIndex;
968  neighbList[neighbourIndex] = nHash;
969  neighbourIndex++;
970  result = 0;
971  }
972  // to avoid duplicated cells in corners
973  if(gPhi < gPhiMinus && nBiggerCell == NOT_VALID_HASH) nBiggerCell=nIndex;
974  }
975  }
976  }
977  }
978  else {
979  // stay in same region (1 neighbour)
980  nIndex = index - nPhi;
981  nHash = nIndex;
982  neighbList[neighbourIndex] = nHash;
983  neighbourIndex++;
984  result = 0;
985  }
986  return result;
987 }
988 
989 int LArEM_Base_ID::get_nextInEta(const LArEM_region* emRegion, const unsigned int& index, const short int& nPhi, const float& gPhi,
990  const unsigned int& maxHash,
991  int& neighbourIndex, IdentifierHash* neighbList, unsigned int& nBiggerCell) const
992 {
993  int result = 1;
994 
995  unsigned int nIndex = 0;
996  IdentifierHash nHash = 0;
997 
998  if( emRegion->isEtaMax(index)){
999  // eta == etaMax -> go to next region in eta
1000  short int nNextEtaRegion = emRegion->nextEtaRegion();
1001  // no neighbour if no next region in eta
1002  if( nNextEtaRegion != NOT_VALID_REGION ) {
1003  // Tell clang to optimize assuming that FP exceptions can trap.
1004  // Otherwise, it can vectorize the division, which can lead to
1005  // spurious division-by-zero traps from unused vector lanes.
1007  LArEM_region* nextEmRegion = m_vecOfRegions[nNextEtaRegion];
1008  float gPhiPlus= nextEmRegion->phiGranularity();
1009  unsigned int minHashPlus = nextEmRegion->hashMin();
1010  float phiMargin = 0.25*std::min(gPhi,gPhiPlus);
1011  float rPhi = (index+nPhi-maxHash)*gPhi+emRegion->phiMin();
1012  int nPhiPlusFirst = int(std::floor((rPhi -nextEmRegion->phiMin())
1013  /gPhiPlus+phiMargin))+minHashPlus;
1014  int nPhiPlusNext = int(std::floor((rPhi+gPhi-nextEmRegion->phiMin())
1015  /gPhiPlus+phiMargin))+minHashPlus;
1016  if ( nPhiPlusNext == nPhiPlusFirst ) nPhiPlusNext++;
1017 
1018  for(int i=nPhiPlusFirst; i<nPhiPlusNext; i++){
1019  nIndex = i ;
1020  if(nIndex != nBiggerCell) {
1021  nHash = nIndex;
1022  neighbList[neighbourIndex] = nHash;
1023  neighbourIndex++;
1024  result = 0;
1025  }
1026  // to avoid duplicated cells in corners
1027  if(gPhi < gPhiPlus && nBiggerCell == NOT_VALID_HASH) nBiggerCell=nIndex;
1028  }
1029  }
1030  }
1031  else {
1032  // stay in same region (1 neighbour)
1033  nIndex = index + nPhi;
1034  nHash = nIndex;
1035  neighbList[neighbourIndex] = nHash;
1036  neighbourIndex++;
1037  result = 0;
1038  }
1039  return result;
1040 }
1041 
1042 int LArEM_Base_ID::get_prevInSamp(const LArEM_region* emRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
1043  const double& gEta, const float& gPhi, const double& absEta,
1044  int& neighbourIndex, IdentifierHash* neighbList) const
1045 {
1046  int result = 1;
1047 
1048  // neighbours' indices
1049  unsigned int nIndex=0;
1050  // neighbours' hash
1051  IdentifierHash nHash=0;
1052 
1053  // previous region in sampling
1054  const std::vector<short int>& prevSampRegion= emRegion->prevSamplingRegion();
1055  int nPrevSampReg = prevSampRegion.size();
1056  if(nPrevSampReg > 0) {
1057  for(int ireg=0; ireg<nPrevSampReg; ireg++) {
1058  LArEM_region* prevEmRegion = m_vecOfRegions[prevSampRegion[ireg]];
1059  // eta granularity of previous region in sampling
1060  double gEtaMinus= (double)(prevEmRegion->etaGranularity());
1061  // starting eta of prev region
1062  double minEtaMinus = (double)(prevEmRegion->etaMin());
1063  double maxEtaMinus = (double)(prevEmRegion->etaMax());
1064  double margin = 0.25*std::min(gEta,gEtaMinus);
1065  if((minEtaMinus < absEta+gEta-margin) && (absEta+margin < maxEtaMinus)) {
1066  // Tell clang to optimize assuming that FP exceptions can trap.
1067  // Otherwise, it can vectorize the division, which can lead to
1068  // spurious division-by-zero traps from unused vector lanes.
1070 
1071  // phi granularity of previous region in sampling
1072  float gPhiMinus= prevEmRegion->phiGranularity();
1073  // max phi of previous region in sampling
1074  short int nPhiMinus = prevEmRegion->phiN();
1075  // first hash of previous region in sampling
1076  unsigned int minHashMinus = prevEmRegion->hashMin();
1077  float phiMargin = 0.25*std::min(gPhi,gPhiMinus);
1078  // phi 'coordinate' in initial region
1079  float rPhi = ((index-minHash)%nPhi)*gPhi+emRegion->phiMin();
1080  int nPhiMinusFirst = int(std::floor((rPhi -prevEmRegion->phiMin())
1081  /gPhiMinus+phiMargin));
1082  int nPhiMinusNext = int(std::floor((rPhi+gPhi-prevEmRegion->phiMin())
1083  /gPhiMinus+phiMargin));
1084  if ( nPhiMinusNext == nPhiMinusFirst ) nPhiMinusNext++;
1085 
1086  // eta 'coordinate' in initial region
1087  double fEtaMinus = (absEta-minEtaMinus) / gEtaMinus + margin ;
1088  // eta 'coordinate' in initial region + 1
1089  double fEtaMaxMinus = (absEta+gEta-minEtaMinus) / gEtaMinus + margin ;
1090  int nEtaMinus = int(fEtaMinus);
1091  int nEtaMaxMinus = int(fEtaMaxMinus);
1092  if ( nEtaMaxMinus == nEtaMinus ) nEtaMaxMinus++;
1093  for(int i=nEtaMinus; i<nEtaMaxMinus; i++) {
1094  for (int j=nPhiMinusFirst; j<nPhiMinusNext;j++) {
1095  nIndex = minHashMinus + i * nPhiMinus + j;
1096  if( (nIndex >= prevEmRegion->hashMin()) && (nIndex < prevEmRegion->hashMax()) ) {
1097  nHash = nIndex;
1098  neighbList[neighbourIndex] = nHash;
1099  neighbourIndex++;
1100  result = 0;
1101  }
1102  }
1103  }
1104  } // end eta condition
1105  } // loop on ireg
1106  }
1107  return result;
1108 }
1109 
1110 int LArEM_Base_ID::get_nextInSamp(const LArEM_region* emRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
1111  const double& gEta, const float& gPhi, const double& absEta,
1112  int& neighbourIndex, IdentifierHash* neighbList) const
1113 {
1114  int result = 1;
1115 
1116  // neighbours' indices
1117  unsigned int nIndex=0;
1118  // neighbours' hash
1119  IdentifierHash nHash=0;
1120 
1121  const std::vector<short int>& nextSampRegion= emRegion->nextSamplingRegion();
1122  int nNextSampReg = nextSampRegion.size();
1123  if(nNextSampReg > 0) {
1124  for(int ireg=0; ireg<nNextSampReg; ireg++) {
1125  LArEM_region* nextEmRegion = m_vecOfRegions[nextSampRegion[ireg]];
1126  double gEtaPlus = (double)(nextEmRegion->etaGranularity());
1127  float gPhiPlus= nextEmRegion->phiGranularity();
1128  double minEtaPlus = (double)(nextEmRegion->etaMin());
1129  double maxEtaPlus = (double)(nextEmRegion->etaMax());
1130  double margin = 0.25*std::min(gEta,gEtaPlus);
1131  if((minEtaPlus < absEta+gEta-margin) && (absEta+margin < maxEtaPlus)) {
1132  // Tell clang to optimize assuming that FP exceptions can trap.
1133  // Otherwise, it can vectorize the division, which can lead to
1134  // spurious division-by-zero traps from unused vector lanes.
1136 
1137  short int nPhiPlus = nextEmRegion->phiN();
1138  unsigned int minHashPlus = nextEmRegion->hashMin();
1139  float phiMargin = 0.25*std::min(gPhi,gPhiPlus);
1140  // phi 'coordinate' in initial region
1141  float rPhi = ((index-minHash)%nPhi)*gPhi+emRegion->phiMin();
1142  int nPhiPlusFirst = int(std::floor((rPhi -nextEmRegion->phiMin())
1143  /gPhiPlus+phiMargin));
1144  int nPhiPlusNext = int(std::floor((rPhi+gPhi-nextEmRegion->phiMin())
1145  /gPhiPlus+phiMargin));
1146  if ( nPhiPlusNext == nPhiPlusFirst ) nPhiPlusNext++;
1147 
1148  double fEtaPlus = (absEta-minEtaPlus) / gEtaPlus + margin ;
1149  // eta 'coordinate' in initial region + 1
1150  double fEtaMaxPlus = (absEta+gEta-minEtaPlus) / gEtaPlus + margin ;
1151  int nEtaPlus = int(fEtaPlus) ;
1152  int nEtaMaxPlus = int(fEtaMaxPlus) ;
1153  if (nEtaMaxPlus == nEtaPlus) nEtaMaxPlus++;
1154 
1155  for(int i=nEtaPlus; i<nEtaMaxPlus; i++){
1156  for(int j=nPhiPlusFirst; j<nPhiPlusNext; j++){
1157  nIndex = minHashPlus + i * nPhiPlus + j;
1158  if( (nIndex >= nextEmRegion->hashMin()) && (nIndex < nextEmRegion->hashMax()) ) {
1159  nHash = nIndex;
1160  neighbList[neighbourIndex] = nHash;
1161  neighbourIndex++;
1162  result = 0;
1163  }
1164  }
1165  }
1166  } // end eta condition
1167  } // end loop on regions
1168  }
1169  return result;
1170 }
1171 
1172 
1173 int LArEM_Base_ID::get_prevInSubdet(const LArEM_region* emRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
1174  const double& gEta, const float& gPhi, const double& absEta,
1175  int& neighbourIndex, IdentifierHash* neighbList) const
1176 {
1177  int result = 1;
1178 
1179  // neighbours' indices
1180  unsigned int nIndex=0;
1181  // neighbours' hash
1182  IdentifierHash nHash=0;
1183 
1184  // previous region in sampling
1185  const std::vector<short int>& prevSubdetRegion= emRegion->prevSubdetRegion();
1186  int nPrevSubdetReg = prevSubdetRegion.size();
1187  if(nPrevSubdetReg > 0) {
1188  for(int ireg=0; ireg<nPrevSubdetReg; ireg++) {
1189  LArEM_region* prevEmRegion = m_vecOfRegions[prevSubdetRegion[ireg]];
1190  // eta granularity of previous region in sampling
1191  double gEtaMinus= (double)(prevEmRegion->etaGranularity());
1192  // starting eta of prev region
1193  double minEtaMinus = (double)(prevEmRegion->etaMin());
1194  double maxEtaMinus = (double)(prevEmRegion->etaMax());
1195  double margin = 0.25*std::min(gEta,gEtaMinus);
1196  if((minEtaMinus < absEta+gEta-margin) && (absEta+margin < maxEtaMinus)) {
1197  // Tell clang to optimize assuming that FP exceptions can trap.
1198  // Otherwise, it can vectorize the division, which can lead to
1199  // spurious division-by-zero traps from unused vector lanes.
1201 
1202  // phi granularity of previous region in sampling
1203  float gPhiMinus= prevEmRegion->phiGranularity();
1204  // max phi of previous region in sampling
1205  short int nPhiMinus = prevEmRegion->phiN();
1206  // first hash of previous region in sampling
1207  unsigned int minHashMinus = prevEmRegion->hashMin();
1208  float phiMargin = 0.25*std::min(gPhi,gPhiMinus);
1209  // phi 'coordinate' in initial region
1210  float rPhi = ((index-minHash)%nPhi)*gPhi+emRegion->phiMin();
1211  int nPhiMinusFirst = int(std::floor((rPhi -prevEmRegion->phiMin())
1212  /gPhiMinus+phiMargin));
1213  int nPhiMinusNext = int(std::floor((rPhi+gPhi-prevEmRegion->phiMin())
1214  /gPhiMinus+phiMargin));
1215  if ( nPhiMinusNext == nPhiMinusFirst ) nPhiMinusNext++;
1216  // eta 'coordinate' in initial region
1217  double fEtaMinus = (absEta-minEtaMinus) / gEtaMinus + margin ;
1218  // eta 'coordinate' in initial region + 1
1219  double fEtaMaxMinus = (absEta+gEta-minEtaMinus) / gEtaMinus + margin ;
1220  int nEtaMinus = int(fEtaMinus);
1221  int nEtaMaxMinus = int(fEtaMaxMinus);
1222  if ( nEtaMaxMinus == nEtaMinus ) nEtaMaxMinus++;
1223 
1224  for(int i=nEtaMinus; i<nEtaMaxMinus; i++) {
1225  for (int j=nPhiMinusFirst; j<nPhiMinusNext;j++) {
1226  nIndex = minHashMinus + i * nPhiMinus + j;
1227  if( (nIndex >= prevEmRegion->hashMin()) && (nIndex < prevEmRegion->hashMax()) ) {
1228  nHash = nIndex;
1229  neighbList[neighbourIndex] = nHash;
1230  neighbourIndex++;
1231  result = 0;
1232  }
1233  }
1234  }
1235  } // end eta condition
1236  } // loop on ireg
1237  }
1238  return result;
1239 }
1240 
1241 int LArEM_Base_ID::get_nextInSubdet(const LArEM_region* emRegion, const unsigned int& index, const short int& nPhi, const unsigned int& minHash,
1242  const double& gEta, const float& gPhi, const double& absEta,
1243  int& neighbourIndex, IdentifierHash* neighbList) const
1244 {
1245  int result = 1;
1246 
1247  // neighbours' indices
1248  unsigned int nIndex=0;
1249  // neighbours' hash
1250  IdentifierHash nHash=0;
1251 
1252  const std::vector<short int>& nextSubdetRegion= emRegion->nextSubdetRegion();
1253  int nNextSubdetReg = nextSubdetRegion.size();
1254  if(nNextSubdetReg > 0) {
1255  for(int ireg=0; ireg<nNextSubdetReg; ireg++) {
1256  LArEM_region* nextEmRegion = m_vecOfRegions[nextSubdetRegion[ireg]];
1257  double gEtaPlus = (double)(nextEmRegion->etaGranularity());
1258  float gPhiPlus= nextEmRegion->phiGranularity();
1259  double minEtaPlus = (double)(nextEmRegion->etaMin());
1260  double maxEtaPlus = (double)(nextEmRegion->etaMax());
1261  double margin = 0.25*std::min(gEta,gEtaPlus);
1262  if((minEtaPlus < absEta+gEta-margin) && (absEta+margin < maxEtaPlus)) {
1263  // Tell clang to optimize assuming that FP exceptions can trap.
1264  // Otherwise, it can vectorize the division, which can lead to
1265  // spurious division-by-zero traps from unused vector lanes.
1267 
1268  short int nPhiPlus = nextEmRegion->phiN();
1269  unsigned int minHashPlus = nextEmRegion->hashMin();
1270  float phiMargin = 0.25*std::min(gPhi,gPhiPlus);
1271  // phi 'coordinate' in initial region
1272  float rPhi = ((index-minHash)%nPhi)*gPhi+emRegion->phiMin();
1273  int nPhiPlusFirst = int(std::floor((rPhi -nextEmRegion->phiMin())
1274  /gPhiPlus+phiMargin));
1275  int nPhiPlusNext = int(std::floor((rPhi+gPhi-nextEmRegion->phiMin())
1276  /gPhiPlus+phiMargin));
1277  if ( nPhiPlusNext == nPhiPlusFirst ) nPhiPlusNext++;
1278 
1279  double fEtaPlus = (absEta-minEtaPlus) / gEtaPlus + margin ;
1280  // eta 'coordinate' in initial region + 1
1281  double fEtaMaxPlus = (absEta+gEta-minEtaPlus) / gEtaPlus + margin ;
1282  int nEtaPlus = int(fEtaPlus) ;
1283  int nEtaMaxPlus = int(fEtaMaxPlus) ;
1284  if (nEtaMaxPlus == nEtaPlus) nEtaMaxPlus++;
1285 
1286  for(int i=nEtaPlus; i<nEtaMaxPlus; i++) {
1287  for(int j=nPhiPlusFirst; j<nPhiPlusNext; j++) {
1288  nIndex = minHashPlus + i * nPhiPlus + j;
1289  if( (nIndex >= nextEmRegion->hashMin()) && (nIndex < nextEmRegion->hashMax()) ) {
1290  nHash = nIndex;
1291  neighbList[neighbourIndex] = nHash;
1292  neighbourIndex++;
1293  result = 0;
1294  }
1295  }
1296  }
1297  } // end eta condition
1298  } // end loop on regions
1299  }
1300  return result;
1301 }
1302 
1303 
1305 {
1306  MsgStream log(m_msgSvc, "LArEM_Base_ID" );
1307  if(m_msgSvc) {
1308  log << MSG::DEBUG << "init_neighbors" << endmsg;
1309  }
1310  else {
1311  std::cout << " LArEM_Base_ID::init_neighbors " << std::endl;
1312  }
1313 
1314  const std::vector<const IdDictRegion*>& vecOfDictRegions = dictRegions();
1315 
1316  //
1317  // ..... loop on regions -> store vector of LArEM_region*
1318  //
1319  m_vecOfRegions.resize(region_hash_max());
1320  short int reg=0;
1321  std::vector<Identifier>::const_iterator debut=reg_begin() ;
1322  std::vector<Identifier>::const_iterator fin =reg_end() ;
1323  for (; debut != fin; ++debut) {
1324  const Identifier& regId = (*debut);
1325 
1326  bool phiWrapAround = (dictionaryVersion() == "fullAtlas" );
1327  bool isBarrelMiddle = false;
1328 
1329  //
1330  // ..... translate regId to chanId and get hash
1331  //
1332 
1333  Identifier id ;
1334  unsigned int index0 = NOT_VALID_HASH;
1335  int etaMin = eta_min(regId);
1336  int phiMin = phi_min(regId);
1337  if(etaMin >= 0 && phiMin >= 0) {
1338  try{
1339  id = channel_id (regId, eta_min(regId), phi_min(regId) );
1340  }
1341  catch(LArID_Exception & except){
1342  if(m_msgSvc) {
1343  log << MSG::ERROR << " LArId exception "
1344  << (std::string)except
1345  << endmsg;
1346  }
1347  else {
1348  std::cout
1349  << " LArId exception "
1350  << (std::string)except
1351  << std::endl;
1352  }
1353  }
1354  IdentifierHash hashId = channel_hash (id) ;
1355  index0=hashId;
1356  }
1357  else {
1358  if(m_msgSvc) {
1359  log << MSG::WARNING << " could not find non negative etaMin and phiMin for region "
1360  << show_to_string(regId)
1361  << endmsg;
1362  }
1363  else {
1364  std::cout << "WARNING !! could not find non negative etaMin and phiMin for region "
1365  << show_to_string(regId)
1366  << std::endl;
1367  }
1368  index0 = 0;
1369  }
1370 
1371  short int deltaEta = eta_max(regId) - eta_min(regId) + 1 ;
1372  short int nPhi = phi_max(regId) - phi_min(regId) + 1 ;
1373  // starting eta
1374  float eta0 = this->eta0(reg);
1375  // eta granularity
1376  float deta = etaGranularity(reg);
1377  // starting phi
1378  float phi0 = this->phi0(reg);
1379  // phi granularity
1380  float dphi = phiGranularity(reg);
1381 
1382  // full range of regions
1383  unsigned int ireg0=0;
1384  unsigned int ireg1=region_hash_max();
1385  // if 2 symetric sides, in which side is the current reg.
1386  if(twoSymSides()) {
1387  if(reg < (short int)region_hash_max()/2) {
1388  ireg0=0;
1389  ireg1=region_hash_max()/2;
1390  } else {
1391  ireg0=region_hash_max()/2;
1392  ireg1=region_hash_max();
1393  }
1394  }
1395 
1396  //
1397  // .... compute prev/next regions in eta
1398  //
1399  short int regForPrevEta=NOT_VALID_REGION;
1400  IdDictRegion* prevEtaDicReg = vecOfDictRegions[reg]->m_prev_abs_eta;
1401  short int regForNextEta=NOT_VALID_REGION;
1402  IdDictRegion* nextEtaDicReg = vecOfDictRegions[reg]->m_next_abs_eta;
1403  for(unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1404  if(vecOfDictRegions[ireg] == prevEtaDicReg) regForPrevEta = ireg;
1405  if(vecOfDictRegions[ireg] == nextEtaDicReg) regForNextEta = ireg;
1406  }
1407  // .... special case of barrel middle
1408  if(twoSymSides()) {
1409  if(eta0 < 0.1 ) {
1410  isBarrelMiddle = true;
1411  if(barrel_ec(regId) < 0) {
1412  regForPrevEta = reg+6;
1413  } else {
1414  regForPrevEta = reg-6;
1415  }
1416  }
1417  }
1418 
1419  //
1420  // .... compute prev/next regions in sampling
1421  //
1422  std::vector<short int> regForPrevSamp;
1423  std::vector<IdDictRegion*> prevSampDicReg = vecOfDictRegions[reg]->m_prev_samp;
1424  for(unsigned int isam=0;isam<prevSampDicReg.size();isam++){
1425  for(unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1426  if(vecOfDictRegions[ireg] == prevSampDicReg[isam]) regForPrevSamp.push_back(ireg);
1427  }
1428  }
1429 
1430  std::vector<short int> regForNextSamp;
1431  std::vector<IdDictRegion*> nextSampDicReg = vecOfDictRegions[reg]->m_next_samp;
1432  for(unsigned int isam=0;isam<nextSampDicReg.size();isam++){
1433  for(unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1434  if(vecOfDictRegions[ireg] == nextSampDicReg[isam]) regForNextSamp.push_back(ireg);
1435  }
1436  }
1437 
1438  //
1439  // .... compute prev/next regions in subdet
1440  //
1441  std::vector<short int> regForPrevSubdet;
1442  std::vector<IdDictRegion*> prevSubdetDicReg = vecOfDictRegions[reg]->m_prev_subdet;
1443  for(unsigned int isubdet=0;isubdet<prevSubdetDicReg.size();isubdet++){
1444  for(unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1445  if(vecOfDictRegions[ireg] == prevSubdetDicReg[isubdet]) regForPrevSubdet.push_back(ireg);
1446  }
1447  }
1448 
1449  std::vector<short int> regForNextSubdet;
1450  std::vector<IdDictRegion*> nextSubdetDicReg = vecOfDictRegions[reg]->m_next_subdet;
1451  for(unsigned int isubdet=0;isubdet<nextSubdetDicReg.size();isubdet++){
1452  for(unsigned int ireg=ireg0;ireg<ireg1;ireg++){
1453  if(vecOfDictRegions[ireg] == nextSubdetDicReg[isubdet]) regForNextSubdet.push_back(ireg);
1454  }
1455  }
1456 
1457  //
1458  // ....now ready to build region object
1459  //
1460 
1461  LArEM_region * emRegion = new LArEM_region(index0,deltaEta,nPhi,eta0,deta,phi0,dphi,phiWrapAround,isBarrelMiddle,
1462  regForPrevEta,regForNextEta,
1463  regForPrevSamp,regForNextSamp,
1464  regForPrevSubdet,regForNextSubdet);
1465  // save in a vector for further use in get_neighbours method
1466  // optimized nov 2005
1467  // m_vecOfRegions.push_back(emRegion);
1468  m_vecOfRegions[reg]=emRegion;
1469  reg++;
1470  } // end of loop on regions
1471 
1472  //
1473  // ..... loop on channels
1474  //
1475  // optimized nov 2005
1476  m_cells.reserve(64);
1477  unsigned int i=0;
1478  reg=0;
1479  Identifier lastRegId;
1480  for (Identifier chanId : em_range()) {
1481  const Identifier& regId = region_id(chanId);
1482  if(regId != lastRegId) {
1483  m_cells.push_back(i);
1484  reg++;
1485  }
1486  ++i;
1487 
1488  if(m_do_checks) {
1489  // for cross check only
1490  IdentifierHash hashReg = region_hash (regId) ;
1491  if ((short int)hashReg != reg) {
1492  if(m_msgSvc) {
1493  log << MSG::ERROR << " init_neighbors: problem reg, hashReg = " << reg << " " << hashReg
1494  << endmsg;
1495  }
1496  else {
1497  std::cout << " init_neighbors: problem reg, hashReg = " << reg << " " << hashReg
1498  << std::endl;
1499  }
1500  }
1501  }
1502 
1503  lastRegId=regId;
1504  }
1505 
1506  return (0);
1507 }
1508 
1509 
1510 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
AtlasDetectorID::lar_em_field_value
int lar_em_field_value() const
Definition: AtlasDetectorID.h:644
LArNeighbours::neighbourOption
neighbourOption
Definition: LArNeighbours.h:12
LArEM_Base_ID.h
Factor out code common between LArEM_ID and LArEM_SuperCell_ID.
CXXUTILS_TRAPPING_FP
#define CXXUTILS_TRAPPING_FP
Definition: trapping_fp.h:24
LArEM_Base_ID::phi
int phi(const Identifier id) const
return phi according to :
LArEM_region::prevSubdetRegion
const std::vector< short int > & prevSubdetRegion() const
region number of the prev region in subdet
Definition: LArEM_region.h:102
IdDictDictionary::build_multirange
MultiRange build_multirange() const
Get MultiRange for full dictionary.
Definition: IdDictDictionary.cxx:299
LArNeighbours::upAndDown
@ upAndDown
Definition: LArNeighbours.h:21
LArEM_Base_ID::m_eta_impl
IdDictFieldImplementation m_eta_impl
Definition: LArEM_Base_ID.h:423
LArEM_Base_ID::phi_max
int phi_max(const Identifier regId) const
max value of phi index (-999 == failure)
Definition: LArEM_Base_ID.cxx:115
LArEM_Base_ID::reg_end
id_iterator reg_end(void) const
end iterator over set of Region Identifiers
LArEM_Base_ID::m_ETA_INDEX
size_type m_ETA_INDEX
Definition: LArEM_Base_ID.h:414
get_generator_info.result
result
Definition: get_generator_info.py:21
IdDictGroup
Definition: IdDictGroup.h:19
LArEM_region::isEtaMin
bool isEtaMin(unsigned int index) const
is the considered cell in the first eta bin of the region ?
Definition: LArEM_region.h:76
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
LArEM_Base_ID::phi_min_init
int phi_min_init(const Identifier regId) const
Definition: LArEM_Base_ID.cxx:89
LArEM_region::phiMin
float phiMin() const
starting phi
Definition: LArEM_region.h:58
LArEM_region::nextSubdetRegion
const std::vector< short int > & nextSubdetRegion() const
region number of the next region in subdet
Definition: LArEM_region.h:105
IdDictFieldImplementation::show_to_string
std::string show_to_string(void) const
Definition: IdDictFieldImplementation.cxx:38
CaloIDHelper::channel_hash_max
size_type channel_hash_max() const
One more than the largest channel (cell) hash code.
LArEM_Base_ID::m_slar_impl
IdDictFieldImplementation m_slar_impl
Definition: LArEM_Base_ID.h:426
LArEM_Base_ID::HashCalc::m_nphi
size_type m_nphi
Definition: LArEM_Base_ID.h:446
LArNeighbours::corners2D
@ corners2D
Definition: LArNeighbours.h:17
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
index
Definition: index.py:1
CaloIDHelper::fill_vec_of_dict_regions
int fill_vec_of_dict_regions(const std::string &group_name="")
Initialize the list of detector regions.
Definition: CaloIDHelper.cxx:259
IdentifierField::get_minimum
element_type get_minimum() const
Query the values.
Definition: IdentifierField.h:59
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
LArEM_region::isPhiMin
bool isPhiMin(unsigned int index) const
is the considered cell in the first phi bin of the region ?
Definition: LArEM_region.h:86
LArEM_Base_ID::region_id
Identifier region_id(const ExpandedIdentifier &exp_id) const
Build a cell identifier from an expanded identifier.
LArEM_Base_ID::init_neighbors
int init_neighbors(void)
Definition: LArEM_Base_ID.cxx:1304
IdContext::end_index
size_type end_index() const
Definition: IdContext.h:46
CaloIDHelper::region_context
IdContext region_context() const
Return the context for regions.
LArNeighbours::nextSubDet
@ nextSubDet
Definition: LArNeighbours.h:23
ExpandedIdentifier::add
void add(element_type value)
Append a value into a new field.
LArEM_Base_ID::m_vecOfRegions
std::vector< LArEM_region * > m_vecOfRegions
Definition: LArEM_Base_ID.h:452
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
LArEM_Base_ID::region
int region(const Identifier id) const
return region according to :
LArEM_Base_ID::sampling
int sampling(const Identifier id) const
return sampling according to :
LArEM_Base_ID::get_nextInSubdet
int get_nextInSubdet(const LArEM_region *emRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, const double &gEta, const float &gPhi, const double &absEta, int &neighbourIndex, IdentifierHash *neighbList) const
Definition: LArEM_Base_ID.cxx:1241
AtlasDetectorID::m_msgSvc
IMessageSvc * m_msgSvc
pointer to the message service
Definition: AtlasDetectorID.h:368
IdentifierField::get_maximum
element_type get_maximum() const
Definition: IdentifierField.h:68
AtlasDetectorID::m_do_checks
bool m_do_checks
Flag for subclasses to know whether or not to perform checks.
Definition: AtlasDetectorID.h:362
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
LArEM_region::etaMax
float etaMax() const
end eta
Definition: LArEM_region.h:55
AtlasDetectorID::lar_field_value
int lar_field_value() const
Definition: AtlasDetectorID.h:614
LArEM_Base_ID::~LArEM_Base_ID
~LArEM_Base_ID(void)
Definition: LArEM_Base_ID.cxx:29
LArEM_Base_ID::init_hashes
int init_hashes(void)
Definition: LArEM_Base_ID.cxx:422
IdDictFieldImplementation::unpack
int unpack(Identifier id) const
Identifier manipulation methods.
Definition: IdDictFieldImplementation.h:147
LArNeighbours::prevInPhi
@ prevInPhi
Definition: LArNeighbours.h:12
LArEM_Base_ID::channel_id
Identifier channel_id(const ExpandedIdentifier &exp_id) const
Build a cell identifier from an expanded identifier.
LArEM_Base_ID::m_em_impl
IdDictFieldImplementation m_em_impl
Definition: LArEM_Base_ID.h:419
LArEM_Base_ID::get_expanded_id
virtual int get_expanded_id(const Identifier &id, ExpandedIdentifier &exp_id, const IdContext *context) const
create expanded Identifier from Identifier (return == 0 for OK)
Definition: LArEM_Base_ID.cxx:195
xAOD::unsigned
unsigned
Definition: RingSetConf_v1.cxx:662
TrigVSI::AlgConsts::nPhi
constexpr int nPhi
Default bin number of phi for vertex map.
Definition: Trigger/TrigTools/TrigVrtSecInclusive/TrigVrtSecInclusive/Constants.h:27
IdDictDictionary::find_field
IdDictField * find_field(const std::string &name) const
Definition: IdDictDictionary.cxx:45
IdDictRegion
Definition: IdDictRegion.h:20
CaloIDHelper::regions
const HashGroup & regions() const
Return the HashGroup for regions.
AtlasDetectorID::dictionaryVersion
virtual std::string dictionaryVersion(void) const override
Definition: AtlasDetectorID.cxx:266
LArEM_Base_ID::eta
int eta(const Identifier id) const
return eta according to :
LArEM_Base_ID::get_nextInSamp
int get_nextInSamp(const LArEM_region *emRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, const double &gEta, const float &gPhi, const double &absEta, int &neighbourIndex, IdentifierHash *neighbList) const
Definition: LArEM_Base_ID.cxx:1110
AtlasDetectorID::m_do_neighbours
bool m_do_neighbours
Flag for subclasses to know whether or not to perform neighbour initialization.
Definition: AtlasDetectorID.h:365
LArEM_Base_ID::initLevelsFromDict
int initLevelsFromDict(const std::string &group_name)
Definition: LArEM_Base_ID.cxx:216
LArEM_Base_ID::get_prevInSamp
int get_prevInSamp(const LArEM_region *emRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, const double &gEta, const float &gPhi, const double &absEta, int &neighbourIndex, IdentifierHash *neighbList) const
Definition: LArEM_Base_ID.cxx:1042
LArEM_Base_ID::m_sampling_impl
IdDictFieldImplementation m_sampling_impl
Definition: LArEM_Base_ID.h:421
IdDictDefs.h
LArEM_Base_ID::m_full_em_range
MultiRange m_full_em_range
Definition: LArEM_Base_ID.h:406
LArEM_Base_ID::m_phi_impl
IdDictFieldImplementation m_phi_impl
Definition: LArEM_Base_ID.h:424
LArNeighbours::nextInSamp
@ nextInSamp
Definition: LArNeighbours.h:20
LArEM_region
This class provides an interface to deal with regions in the neighbours finding
Definition: LArEM_region.h:20
LArEM_Base_ID::eta_max
int eta_max(const Identifier regId) const
max value of eta index (-999 == failure)
Definition: LArEM_Base_ID.cxx:68
LArNeighbours::nextInPhi
@ nextInPhi
Definition: LArNeighbours.h:13
IdDictMgr
Definition: IdDictMgr.h:14
LArEM_Base_ID::m_region_impl
IdDictFieldImplementation m_region_impl
Definition: LArEM_Base_ID.h:422
LArEM_Base_ID::channel_hash
IdentifierHash channel_hash(Identifier channelId) const
create hash id from channel id
IdDictDictionary::find_group
IdDictGroup * find_group(const std::string &group_name) const
Definition: IdDictDictionary.cxx:115
StrFormat.h
Provide helper functions to create formatted strings.
IdDictMgr::find_dictionary
IdDictDictionary * find_dictionary(const std::string &name) const
Access dictionary by name.
Definition: IdDictMgr.cxx:115
CaloIDHelper::region_hash_max
size_type region_hash_max() const
One more than the largest region hash code.
LArEM_Base_ID::HashCalc
small class holding the starting hash value, the min eta and the number of phi bins of each region
Definition: LArEM_Base_ID.h:436
Trk::index1
@ index1
Definition: BoundarySurfaceFace.h:48
P4Helpers::deltaEta
double deltaEta(const I4Momentum &p1, const I4Momentum &p2)
Computes efficiently .
Definition: P4Helpers.h:66
IdentifierField::empty
bool empty() const
Definition: IdentifierField.h:114
LArEM_region::phiGranularity
float phiGranularity() const
phi granularity
Definition: LArEM_region.h:43
CaloIDHelper::etaGranularity
float etaGranularity(const IdentifierHash regHash) const
Return the eta granularity of a region, or NOT_VALID.
Definition: CaloIDHelper.cxx:185
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArEM_Base_ID::phi_min
int phi_min(const Identifier regId) const
min value of phi index (-999 == failure)
IdDictFieldImplementation::set_bits
void set_bits(size_type bits, size_type bits_offset)
Definition: IdDictFieldImplementation.h:278
CaloIDHelper::dict
const IdDictDictionary * dict() const
Return the dictionary for this subdetector.
CaloIDHelper
Base class to factor out code common among Calo ID helpers.
Definition: CaloIDHelper.h:34
LArEM_Base_ID::m_bec_reg_impl
IdDictFieldImplementation m_bec_reg_impl
Definition: LArEM_Base_ID.h:450
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
LArEM_Base_ID::m_full_region_range
MultiRange m_full_region_range
Definition: LArEM_Base_ID.h:405
python.LArMinBiasAlgConfig.int
int
Definition: LArMinBiasAlgConfig.py:59
LArEM_region::isEtaMax
bool isEtaMax(unsigned int index) const
is the considered cell in the last eta bin of the region ?
Definition: LArEM_region.h:81
LArEM_Base_ID::m_SAMPLING_INDEX
size_type m_SAMPLING_INDEX
Definition: LArEM_Base_ID.h:412
LArEM_Base_ID::twoSymSides
bool twoSymSides() const
True if the + and - sides of the calorimeter are identical (true layout).
IdDictFieldImplementation::bits_offset
size_type bits_offset() const
Definition: IdDictFieldImplementation.h:208
IdDictDictionary::m_regions
std::vector< IdDictRegion * > m_regions
Definition: IdDictDictionary.h:235
LArEM_region::etaMin
float etaMin() const
starting eta
Definition: LArEM_region.h:52
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
mc.group_name
group_name
Definition: mc.PhPy8EG_A14NNPDF23_NNLOPS_example.py:33
LArEM_Base_ID::m_lar_impl
IdDictFieldImplementation m_lar_impl
Definition: LArEM_Base_ID.h:418
NOT_VALID_REGION
@ NOT_VALID_REGION
Definition: LArEM_region.h:11
LArNeighbours::prevSubDet
@ prevSubDet
Definition: LArNeighbours.h:22
LArEM_region::hashMax
unsigned int hashMax() const
hash Id of the last cell of the region +1
Definition: LArEM_region.h:67
LArEM_Base_ID::m_slar
unsigned m_slar
Definition: LArEM_Base_ID.h:401
LArEM_region::phiN
short int phiN() const
number of phi bins
Definition: LArEM_region.h:37
LArEM_Base_ID::m_bec_impl
IdDictFieldImplementation m_bec_impl
Definition: LArEM_Base_ID.h:420
LArEM_region.h
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
LArEM_region::prevSamplingRegion
const std::vector< short int > & prevSamplingRegion() const
region number of the prev region in sampling
Definition: LArEM_region.h:96
LArNeighbours::prevInSamp
@ prevInSamp
Definition: LArNeighbours.h:19
AtlasDetectorID::m_quiet
bool m_quiet
If true, suppress DEBUG/INFO messages.
Definition: AtlasDetectorID.h:371
LArEM_Base_ID::get_prevInPhi
static int get_prevInPhi(const LArEM_region *emRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, int &neighbourIndex, IdentifierHash *neighbList)
Definition: LArEM_Base_ID.cxx:892
Trk::index0
@ index0
Definition: BoundarySurfaceFace.h:47
LArEM_Base_ID::eta_min
int eta_min(const Identifier regId) const
min value of eta index (-999 == failure)
Definition: LArEM_Base_ID.cxx:42
LArEM_Base_ID::get_nextInPhi
static int get_nextInPhi(const LArEM_region *emRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, int &neighbourIndex, IdentifierHash *neighbList)
Definition: LArEM_Base_ID.cxx:907
CaloIDHelper::initialize_base_from_dictionary
int initialize_base_from_dictionary(const IdDictMgr &dict_mgr, const std::string &dict_name)
Do basic initialization of the helper.
Definition: CaloIDHelper.cxx:232
LArEM_Base_ID::region_id_checks
void region_id_checks(int barrel_ec, int sampling, int region) const
Definition: LArEM_Base_ID.cxx:136
trapping_fp.h
Tell the compiler to optimize assuming that FP may trap.
IdDictDictionary::get_label_value
int get_label_value(const std::string &field, const std::string &label, int &value) const
Definition: IdDictDictionary.cxx:73
LArEM_Base_ID::m_EM_INDEX
size_type m_EM_INDEX
Definition: LArEM_Base_ID.h:410
Trk::index2
@ index2
Definition: BoundarySurfaceFace.h:49
CxxUtils::strformat
std::string strformat(const char *fmt,...)
return a std::string according to a format fmt and varargs
Definition: StrFormat.cxx:49
CaloIDHelper::eta0
float eta0(const IdentifierHash regHash) const
Return the minimum eta of region, or NOT_VALID.
Definition: CaloIDHelper.cxx:207
LArEM_Base_ID::m_cells
std::vector< unsigned > m_cells
Definition: LArEM_Base_ID.h:453
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
LArEM_Base_ID::get_neighbours
int get_neighbours(const IdentifierHash id, const LArNeighbours::neighbourOption &option, std::vector< IdentifierHash > &neighbourList) const
access to hashes for neighbours return == 0 for neighbours found option = prevInPhi,...
Definition: LArEM_Base_ID.cxx:686
LArEM_Base_ID::barrel_ec
int barrel_ec(const Identifier id) const
return barrel_ec according to :
AtlasDetectorID::setDictVersion
virtual void setDictVersion(const IdDictMgr &dict_mgr, const std::string &name) override
Definition: AtlasDetectorID.cxx:480
Range
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
Definition: DetectorDescription/Identifier/Identifier/Range.h:29
LArEM_Base_ID::get_prevInEta
int get_prevInEta(const LArEM_region *emRegion, const unsigned int &index, const short int &nPhi, const float &gPhi, const unsigned int &minHash, int &neighbourIndex, IdentifierHash *neighbList, unsigned int &nBiggerCell) const
Definition: LArEM_Base_ID.cxx:922
LArEM_Base_ID::m_SLAR_INDEX
size_type m_SLAR_INDEX
Definition: LArEM_Base_ID.h:416
LArEM_region::isFirstBarrelRegion
bool isFirstBarrelRegion() const
true if region close to barrel middle
Definition: LArEM_region.h:49
python.PyKernel.init
def init(v_theApp, v_rootStream=None)
Definition: PyKernel.py:45
LArEM_region::nextEtaRegion
short int nextEtaRegion() const
region number of the next region in eta
Definition: LArEM_region.h:73
LArEM_Base_ID::m_PHI_INDEX
size_type m_PHI_INDEX
Definition: LArEM_Base_ID.h:415
IdDictDictionary
Definition: IdDictDictionary.h:30
LArEM_Base_ID::HashCalc::m_phimin
size_type m_phimin
Definition: LArEM_Base_ID.h:445
CaloIDHelper::channels
const HashGroup & channels() const
Return the HashGroup for channels (cells).
MultiRange::match
int match(const ExpandedIdentifier &id) const
Match an identifier.
Definition: MultiRange.cxx:57
AtlasDetectorID::reinitialize
bool reinitialize(const IdDictMgr &dict_mgr)
Test whether an idhelper should be reinitialized based on the change of tags.
Definition: AtlasDetectorID.cxx:206
LArEM_region::etaGranularity
float etaGranularity() const
eta granularity
Definition: LArEM_region.h:40
LArCellBinning.etaMin
etaMin
Definition: LArCellBinning.py:84
LArEM_Base_ID::m_BEC_INDEX
size_type m_BEC_INDEX
Definition: LArEM_Base_ID.h:411
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
IdDictDictionary::m_name
std::string m_name
Definition: IdDictDictionary.h:216
CaloIDHelper::phi0
float phi0(const IdentifierHash regHash) const
Return the minimum phi of region, or NOT_VALID.
Definition: CaloIDHelper.cxx:218
LArEM_Base_ID::m_two_sym_sides
bool m_two_sym_sides
Definition: LArEM_Base_ID.h:403
AtlasDetectorID::show_to_string
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:350
CaloIDHelper::dictRegions
const std::vector< const IdDictRegion * > & dictRegions() const
Return the vector of IdDictRegion, accessed via region hash.
LArEM_Base_ID::HashCalc::m_etamin
size_type m_etamin
Definition: LArEM_Base_ID.h:444
LArNeighbours::nextInEta
@ nextInEta
Definition: LArNeighbours.h:15
MultiRange::size
size_type size() const
Definition: MultiRange.cxx:70
DeMoScan.first
bool first
Definition: DeMoScan.py:536
DEBUG
#define DEBUG
Definition: page_access.h:11
LArEM_Base_ID::get_prevInSubdet
int get_prevInSubdet(const LArEM_region *emRegion, const unsigned int &index, const short int &nPhi, const unsigned int &minHash, const double &gEta, const float &gPhi, const double &absEta, int &neighbourIndex, IdentifierHash *neighbList) const
Definition: LArEM_Base_ID.cxx:1173
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
IdentifierField
This is the individual specification for the range of one ExpandedIdentifier IdentifierField.
Definition: IdentifierField.h:21
TauGNNUtils::Variables::absEta
bool absEta(const xAOD::TauJet &tau, double &out)
Definition: TauGNNUtils.cxx:234
ExpandedIdentifier::clear
void clear()
Erase all fields.
LArEM_Base_ID::m_em_region_index
size_type m_em_region_index
Definition: LArEM_Base_ID.h:408
compute_lumi.fin
fin
Definition: compute_lumi.py:19
LArEM_Base_ID::get_nextInEta
int get_nextInEta(const LArEM_region *emRegion, const unsigned int &index, const short int &nPhi, const float &gPhi, const unsigned int &maxHash, int &neighbourIndex, IdentifierHash *neighbList, unsigned int &nBiggerCell) const
Definition: LArEM_Base_ID.cxx:989
LArEM_Base_ID::initialize_base_from_dictionary
int initialize_base_from_dictionary(const IdDictMgr &dict_mgr, const std::string &group_name)
initialization from the identifier dictionary
Definition: LArEM_Base_ID.cxx:438
LArNeighbours::prevInEta
@ prevInEta
Definition: LArNeighbours.h:14
LArEM_region::prevEtaRegion
short int prevEtaRegion() const
region number of the previous region in eta
Definition: LArEM_region.h:70
calibdata.copy
bool copy
Definition: calibdata.py:27
CaloIDHelper::phiGranularity
float phiGranularity(const IdentifierHash regHash) const
Return the phi granularity of a region, or NOT_VALID.
Definition: CaloIDHelper.cxx:196
IdDictField
Definition: IdDictField.h:15
LArEM_Base_ID::channel_id_checks
void channel_id_checks(int barrel_ec, int sampling, int region, int eta, int phi) const
Definition: LArEM_Base_ID.cxx:152
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
LArEM_Base_ID::em_range
id_range em_range() const
Range over full set of EM Identifiers.
LArEM_Base_ID::reg_begin
id_iterator reg_begin(void) const
begin iterator over set of Region Identifiers
TrigVSI::AlgConsts::nEta
constexpr int nEta
Default bin number of eta for vertex map.
Definition: Trigger/TrigTools/TrigVrtSecInclusive/TrigVrtSecInclusive/Constants.h:26
LArEM_Base_ID::m_vecOfPhiMin
std::vector< int > m_vecOfPhiMin
Definition: LArEM_Base_ID.h:428
LArEM_region::isPhiMax
bool isPhiMax(unsigned int index) const
is the considered cell in the last phi bin of the region ?
Definition: LArEM_region.h:91
LArCellBinning.etamin
etamin
Definition: LArCellBinning.py:137
IdContext
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition: IdContext.h:26
LArEM_Base_ID::NOT_VALID_HASH
@ NOT_VALID_HASH
Definition: LArEM_Base_ID.h:350
CaloIDHelper::region_hash
IdentifierHash region_hash(Identifier regionId) const
Convert a connected region Identifier to a hash code.
LArEM_Base_ID::m_LAR_INDEX
size_type m_LAR_INDEX
Definition: LArEM_Base_ID.h:409
LArEM_region::nextSamplingRegion
const std::vector< short int > & nextSamplingRegion() const
region number of the next region in sampling
Definition: LArEM_region.h:99
AtlasDetectorID::lar_em_exp
ExpandedIdentifier lar_em_exp(void) const
LAr.
Definition: AtlasDetectorID.h:562
LArID_Exception
Exception class for LAr Identifiers.
Definition: LArID_Exception.h:20
LArEM_region::hashMin
unsigned int hashMin() const
hash Id of the first cell of the region
Definition: LArEM_region.h:64
LArEM_Base_ID::channel_hash_binary_search
IdentifierHash channel_hash_binary_search(Identifier channelId) const
create hash id from channel id – method NOT optimised, please use channel_hash() above
LArNeighbours::all2D
@ all2D
Definition: LArNeighbours.h:18
LArEM_Base_ID::m_REGION_INDEX
size_type m_REGION_INDEX
Definition: LArEM_Base_ID.h:413
LArEM_Base_ID::is_supercell
bool is_supercell(const Identifier id) const
Test if the identifier represents a supercell.
Definition: LArEM_Base_ID.cxx:36
LArEM_Base_ID::HashCalc::m_hash
IdentifierHash m_hash
Definition: LArEM_Base_ID.h:443
IdDictFieldImplementation::size_type
Identifier::size_type size_type
Definition: IdDictFieldImplementation.h:62
LArEM_Base_ID::LArEM_Base_ID
LArEM_Base_ID(const std::string &name, bool supercell)
Constructor.
Definition: LArEM_Base_ID.cxx:22
CaloIDHelper::HashGroup::hash_max
size_type hash_max() const
Return one more than the largest hash code.
LArEM_Base_ID::m_hash_calcs
std::vector< HashCalc > m_hash_calcs
Definition: LArEM_Base_ID.h:448
IdDictFieldImplementation::bits
size_type bits() const
Definition: IdDictFieldImplementation.h:202
Identifier
Definition: IdentifierFieldParser.cxx:14