ATLAS Offline Software
LArRodIdHash.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "GaudiKernel/ISvcLocator.h"
7 #include "GaudiKernel/IToolSvc.h"
8 #include <iostream>
9 
10 #include "eformat/SourceIdentifier.h"
11 
13 
14 using eformat::helper::SourceIdentifier;
15 
16 // This class converts a LArReadoutModuleID into an integer,
17 //
18 
19 
20 void LArRodIdHash::initialize( int offset, const std::vector<HWIdentifier>& roms ) {
21 
22 //
23 
24  m_offset = offset;
25 
26  LArReadoutModuleService larROMService;
27  eformat::SubDetector detid ;
28  std::vector<ID> rmod;
29  std::vector<HWIdentifier>::const_iterator tit = roms.begin();
30  std::vector<HWIdentifier>::const_iterator tit_end = roms.end();
31 
32  for(; tit!=tit_end; ++tit)
33  {
34 
35  HWIdentifier mId = (*tit);
36  detid = (eformat::SubDetector) larROMService.subDet(mId);
37  uint8_t m = larROMService.rodFragId(mId);
38 
39  SourceIdentifier sid = SourceIdentifier(detid,m);
40  uint32_t rod_id = sid.code();
41  rmod.push_back(rod_id);
42 
43  }
44 
45  std::vector<ID>::const_iterator
46  it = rmod.begin();
47  std::vector<ID>::const_iterator
48  it_end = rmod.end() ;
49 
50  int n = 0;
51  for (; it!=it_end;++it) {
52  ID id = *it;
53  // std::cout << " LArReadoutModuleID = "<<id.id()<<std::endl;
54  unsigned int i = id;
55  m_lookup[i] = n ;
56  m_int2id.push_back(id);
57  ++n;
58  }
59 
60  // cout << " Number of LArReadoutModuleID valid ID "<< n <<endl;
61  m_size = n;
62 
63 }
64 
66 
67  return m_int2id[index] ;
68 
69 }
70 
71 int LArRodIdHash::operator() (const ID& id) const {
72 
73  unsigned int i = id ;
74  std::map<unsigned int, int> ::const_iterator it= m_lookup.find(i);
75  if(it!=m_lookup.end()) return (*it).second;
76  std::cout <<" ERROR in LArRodIdHash : invalid Rod number"
77  <<std::endl;
78  return -1;
79 
80 }
81 
82 int LArRodIdHash::max() const {
83 
84 return m_size;
85 
86 }
87 
88 int LArRodIdHash::offset() const {
89 
90 return m_offset;
91 
92 }
93 
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
LArRodIdHash::initialize
void initialize(int offset, const std::vector< HWIdentifier > &roms)
Initialize.
Definition: LArRodIdHash.cxx:20
LArReadoutModuleService::subDet
static int subDet(const HWIdentifier &id)
return sub-detector identifier
Definition: LArReadoutModuleService.cxx:162
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
LArRodIdHash::identifier
ID identifier(int i) const
reverse conversion
Definition: LArRodIdHash.cxx:65
index
Definition: index.py:1
LArRodIdHash::offset
int offset() const
return offset
Definition: LArRodIdHash.cxx:88
LArReadoutModuleService::rodFragId
static int rodFragId(const HWIdentifier &id)
return ROD fragment identifier ( == ROL == ROB identifier )
Definition: LArReadoutModuleService.cxx:211
skel.it
it
Definition: skel.GENtoEVGEN.py:423
LArRodIdHash.h
HWIdentifier
Definition: HWIdentifier.h:13
LArReadoutModuleService.h
LArRodIdHash::ID
unsigned int ID
definition of ID type
Definition: LArRodIdHash.h:31
LArRodIdHash::m_size
int m_size
total number of IDs
Definition: LArRodIdHash.h:50
LArReadoutModuleService
Service for creating and interpreting LAr readout modules identifiers.
Definition: LArReadoutModuleService.h:20
TileDCSDataPlotter.tit
tit
Definition: TileDCSDataPlotter.py:890
LArRodIdHash::m_lookup
std::map< unsigned int, int > m_lookup
test beam flag
Definition: LArRodIdHash.h:53
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
LArRodIdHash::operator()
int operator()(const ID &id) const
Convert ID to int.
Definition: LArRodIdHash.cxx:71
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:194
LArRodIdHash::max
int max() const
return maximum number of IDs
Definition: LArRodIdHash.cxx:82
DeMoScan.index
string index
Definition: DeMoScan.py:362
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
LArRodIdHash::m_int2id
std::vector< ID > m_int2id
reverse look up
Definition: LArRodIdHash.h:56
LArRodIdHash::m_offset
int m_offset
Definition: LArRodIdHash.h:58