ATLAS Offline Software
TileTTL1Hash.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //*****************************************************************************
6 // Filename : TileTTL1Hash.cxx
7 // Author : jose.maneira@cern.ch
8 // Created : Nov 2005
9 //
10 // DESCRIPTION:
11 // Provides a hash (integer) conversion for the TileTTL1 identifiers.
12 //
13 // HISTORY:
14 //
15 // BUGS:
16 //
17 //*****************************************************************************
18 
19 // Calo include
21 
22 //TileCal include
24 
25 #include "assert.h"
26 
27 // This class converts a TTL1_ID into a integer, according to its
28 // value of (ROS and drawer number).
29 
30 // default contructor
32  : m_size(0),
33  m_lookup()
34 {
35 }
36 
37 void TileTTL1Hash::initialize( const CaloLVL1_ID * caloLVL1_ID)
38 {
39  std::cout << "Initialization started" << std::endl;
40 
41  m_size = 0;
42  for(int i = 0; i< m_table_size; ++i) { m_lookup[i]=-1; }
43 
45  std::vector<Identifier>::const_iterator first = caloLVL1_ID->tower_begin();
46  std::vector<Identifier>::const_iterator last = caloLVL1_ID->tower_end();
47 
48  int maxid = 0;
49  for ( ; first!=last; ++first) {
50  if(caloLVL1_ID->is_tile(*first)){
51  ID id = caloLVL1_ID->tower_hash(*first);
52  if (id > maxid) maxid = id;
53  assert(id>=0 && id < m_table_size);
54  m_int2id.push_back(id);
55  m_lookup[id] = (m_size++);
56  }
57  }
58  std::cout << " Number of valid tower IDs "<< m_size << std::endl;
59  std::cout << " Highest tower ID "<< maxid << std::endl;
60 
61 
62 }
63 
65 {
66  assert(index>=0 && index < m_size);
67 
68  return m_int2id[index];
69 }
70 
71 int TileTTL1Hash::operator() (const ID& id) const
72 {
73  assert(id>=0 && id < m_table_size);
74 
75  return m_lookup[id];
76 }
77 
TileTTL1Hash::ID
int ID
Definition: TileTTL1Hash.h:42
TileTTL1Hash::m_lookup
int m_lookup[m_table_size]
Definition: TileTTL1Hash.h:64
index
Definition: index.py:1
TileTTL1Hash::m_size
int m_size
total number of IDs
Definition: TileTTL1Hash.h:60
TileTTL1Hash::identifier
ID identifier(int i) const
reverse conversion
Definition: TileTTL1Hash.cxx:64
CaloLVL1_ID::tower_end
id_iterator tower_end() const
end iterator over towers
Definition: CaloLVL1_ID.h:603
TileTTL1Hash::initialize
void initialize(const CaloLVL1_ID *caloLVL1_ID)
Definition: TileTTL1Hash.cxx:37
TileTTL1Hash::TileTTL1Hash
TileTTL1Hash()
Definition: TileTTL1Hash.cxx:31
lumiFormat.i
int i
Definition: lumiFormat.py:85
TileTTL1Hash.h
CaloLVL1_ID
Helper class for offline TT identifiers.
Definition: CaloLVL1_ID.h:66
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
DeMoScan.index
string index
Definition: DeMoScan.py:364
CaloLVL1_ID.h
TileTTL1Hash::m_int2id
std::vector< ID > m_int2id
Definition: TileTTL1Hash.h:66
DeMoScan.first
bool first
Definition: DeMoScan.py:536
CaloLVL1_ID::tower_begin
id_iterator tower_begin() const
begin iterator over towers
Definition: CaloLVL1_ID.h:597
CaloLVL1_ID::tower_hash
IdentifierHash tower_hash(Identifier towerId) const
create hash id from tower id
Definition: CaloLVL1_ID.h:728
TileTTL1Hash::m_table_size
static const int m_table_size
lookup table
Definition: TileTTL1Hash.h:63
CaloLVL1_ID::is_tile
bool is_tile(const Identifier id) const
Test wether given tower or layer is part of the Tile Calorimeter.
Definition: CaloLVL1_ID.h:672
TileTTL1Hash::operator()
int operator()(const ID &id) const
Convert ID to int.
Definition: TileTTL1Hash.cxx:71