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