ATLAS Offline Software
Loading...
Searching...
No Matches
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
14using eformat::helper::SourceIdentifier;
15
16// This class converts a LArReadoutModuleID into an integer,
17//
18
19
20void LArRodIdHash::initialize( int offset, const std::vector<HWIdentifier>& roms ) {
21
22//
23
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
71int 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
82int LArRodIdHash::max() const {
83
84return m_size;
85
86}
87
89
90return m_offset;
91
92}
93
Service for creating and interpreting LAr readout modules identifiers.
static int subDet(const HWIdentifier &id)
return sub-detector identifier
static int rodFragId(const HWIdentifier &id)
return ROD fragment identifier ( == ROL == ROB identifier )
std::vector< ID > m_int2id
reverse look up
unsigned int ID
definition of ID type
ID identifier(int i) const
reverse conversion
std::map< unsigned int, int > m_lookup
test beam flag
int m_size
total number of IDs
int max() const
return maximum number of IDs
void initialize(int offset, const std::vector< HWIdentifier > &roms)
Initialize.
int operator()(const ID &id) const
Convert ID to int.
int offset() const
return offset
Definition index.py:1