ATLAS Offline Software
TileFragHash.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
8 #include <cassert>
9 #include <cstring>
10 
11 // This class converts a Frag_ID into a integer, according to its
12 // value of (ROS and drawer number).
13 
14 // default contructor
16  : m_size(0)
17  , m_offset(0)
18  , m_type(Default)
19 {
20  memset(m_lookup,0,sizeof(m_lookup));
21 }
22 
23 void TileFragHash::initialize( const TileHWID * tileHWID, TYPE type )
24 {
25  // std::cout << " TileFragHash Constructor "<< std::endl;
26 
27  m_type = type;
28  m_size = 0;
29  if (!tileHWID) return;
30  m_int2id.clear();
31  m_int2id.reserve(tileHWID->drawer_hash_max());
32 
33  for(int i = 0; i< m_table_size; ++i) { m_lookup[i]=-1; }
34 
36  std::vector<HWIdentifier>::const_iterator first = tileHWID->drawer_begin();
37  std::vector<HWIdentifier>::const_iterator last = tileHWID->drawer_end();
38 
39  switch (type) {
40  case Beam:
41  m_offset = 0;
42  for ( ; first!=last; ++first) {
43  ID id = tileHWID->frag(*first);
44  if (id >= 0x100) continue; // skip all real drawers
45  assert(id>=0 && id < m_table_size);
46 
47  m_int2id.push_back(id);
48  m_lookup[id] = (m_size++);
49  }
50  // std::cout << " Number of valid Beam frag IDs "<< m_size << std::endl;
51  break;
52  default:
53  m_offset = (int)type * 0x1000;
54  for ( ; first!=last; ++first) {
55  ID id = tileHWID->frag(*first);
56  if (id < 0x100) continue; // skip Beam ROD frags
57  assert(id>=0 && id < m_table_size);
58 
59  m_int2id.push_back(id);
60  m_lookup[id] = (m_size++);
61  }
62  // std::cout << " Number of valid drawer IDs "<< m_size << std::endl;
63  break;
64  }
65 }
66 
68 {
69  assert(index>=0 && index < m_size);
70 
71  return m_int2id[index];
72 }
73 
74 int TileFragHash::hash (const ID& id) const
75 {
76  assert(id>=0 && id < m_table_size);
77 
78  return m_lookup[id];
79 }
80 
81 
86 {
87  switch (type) {
88 #define CASE(X) case TileFragHash::X: return #X
89  CASE(Digitizer);
93  CASE(ManyAmps);
94  CASE(MF);
95  CASE(FitFilter);
98  CASE(Beam);
99 #undef CASE
100  default: break;
101  };
102  return "UNKNOWN";
103 }
TileFragHash::m_lookup
int m_lookup[m_table_size]
Definition: TileFragHash.h:71
TileFragHash::m_offset
int m_offset
Definition: TileFragHash.h:66
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
index
Definition: index.py:1
TileFragHash::m_table_size
static const int m_table_size
lookup table
Definition: TileFragHash.h:70
TileFragHash::FitFilter
@ FitFilter
Definition: TileFragHash.h:35
TileFragHash::TYPE
TYPE
initialize
Definition: TileFragHash.h:33
TileFragHash.h
TileHWID::frag
int frag(const HWIdentifier &id) const
extract frag field from HW identifier
Definition: TileHWID.h:181
TileHWID::drawer_hash_max
size_type drawer_hash_max(void) const
drawer hash table max size
Definition: TileHWID.h:268
TileFragHash::Digitizer
@ Digitizer
Definition: TileFragHash.h:33
TileFragHash::m_int2id
std::vector< ID > m_int2id
Definition: TileFragHash.h:73
TileFragHash::OptFilterDsp
@ OptFilterDsp
Definition: TileFragHash.h:34
TileFragHash::OptFilterDspCompressed
@ OptFilterDspCompressed
Definition: TileFragHash.h:34
TileFragHash::hash
int hash(const ID &id) const
Convert ID to int (same as the converter, but easier to call from python)
Definition: TileFragHash.cxx:74
TileFragHash::TileFragHash
TileFragHash()
Definition: TileFragHash.cxx:15
TileFragHash::OptFilterOffline
@ OptFilterOffline
Definition: TileFragHash.h:34
m_type
TokenType m_type
the type
Definition: TProperty.cxx:44
TileHWID
Helper class for TileCal online (hardware) identifiers.
Definition: TileHWID.h:49
TileFragHash::typeToString
static std::string typeToString(TYPE type)
Printable representation of a type.
Definition: TileFragHash.cxx:85
TileHWID.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
TileHWID::drawer_begin
std::vector< HWIdentifier >::const_iterator drawer_begin(void) const
begin iterator for drawer Identifiers
Definition: TileHWID.h:290
TileFragHash::m_size
int m_size
total number of IDs
Definition: TileFragHash.h:65
TileFragHash::ID
int ID
Definition: TileFragHash.h:28
TileFragHash::initialize
void initialize(const TileHWID *tileHWID, TYPE type=Default)
Definition: TileFragHash.cxx:23
TileFragHash::Beam
@ Beam
Definition: TileFragHash.h:33
TileFragHash::m_type
TYPE m_type
Definition: TileFragHash.h:67
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
TileFragHash::MF
@ MF
Definition: TileFragHash.h:35
CASE
#define CASE(X)
TileFragHash::type
TYPE type() const
return hash type
Definition: TileFragHash.h:56
DeMoScan.index
string index
Definition: DeMoScan.py:364
TileFragHash::FlatFilter
@ FlatFilter
Definition: TileFragHash.h:35
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DeMoScan.first
bool first
Definition: DeMoScan.py:536
TileFragHash::ManyAmps
@ ManyAmps
Definition: TileFragHash.h:35
TileFragHash::FitFilterCool
@ FitFilterCool
Definition: TileFragHash.h:35
TileHWID::drawer_end
std::vector< HWIdentifier >::const_iterator drawer_end(void) const
end iterator for drawer Identifiers
Definition: TileHWID.h:294
TileFragHash::identifier
ID identifier(int i) const
reverse conversion
Definition: TileFragHash.cxx:67
Default