ATLAS Offline Software
TRT_CablingData.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //
6 // Implementation file for TRT_CablingData class
7 //
8 //
9 
10 #include "TRT_CablingData.h"
11 #include <algorithm>
12 #include <cassert>
13 #include <fstream>
14 #include <iostream>
15 #include <sstream>
16 
17  //Constructor
19  : m_bofai_sorted (true)
20 {
21 }
22 
23  //Destructor
25 {
26  for (std::map< uint32_t, std::vector<IdentifierHash> *>::iterator i =
27  m_collID.begin();
28  i != m_collID.end();
29  ++i)
30  delete i->second;
31 }
32 
33  // Fill m_identifierForAllStraws with zeros (TB case)
35 (int, const std::vector<Identifier>& )
36 {
37  return;
38 }
39 
40  // Fill m_identifierHashForAllStraws with zeros (TB case)
42 (int, const std::vector<IdentifierHash>& )
43 {
44  return;
45 }
46 
47 
49 TRT_CablingData::find_idandhash (int rod, int bufferPosition)
50 {
51  assert (rod >= 0);
52  assert (bufferPosition >= 0);
53  unsigned int rodhi = ((unsigned)rod & 0xffff0000) >> 16;
54  unsigned int rodlo = (rod & 0x0000ffff);
55  rodvec_t& rodvec = m_rodoffset_to_id[rodhi];
56  if (rodvec.size() <= rodlo)
57  rodvec.resize (rodlo + 1);
58  offsetvec_t& offsetvec = rodvec[rodlo];
59  if (offsetvec.size() <= (unsigned)bufferPosition)
60  offsetvec.resize (bufferPosition+1);
61  return offsetvec[bufferPosition];
62 }
63 
65 TRT_CablingData::find_idandhash (int rod, int bufferPosition) const
66 {
67  assert (rod >= 0);
68  assert (bufferPosition >= 0);
69  unsigned int rodhi = ((unsigned)rod & 0xffff0000) >> 16;
70  unsigned int rodlo = (rod & 0x0000ffff);
71  auto it = m_rodoffset_to_id.find (rodhi);
72  if (it != m_rodoffset_to_id.end()) {
73  const rodvec_t& rodvec = it->second;
74  if (rodlo < rodvec.size()) {
75  const offsetvec_t& offsetvec = rodvec[rodlo];
76  if ((unsigned)bufferPosition < offsetvec.size())
77  return offsetvec[bufferPosition];
78  }
79  }
80 
81  static const idandhash_t dum;
82  return dum;
83 }
84 
85  // Set value of Identifier for each straw (TB case)
87  int bufferPosition, Identifier strawID)
88 {
89  find_idandhash (rod, bufferPosition).first = strawID;
90  m_BufferOffsetForAllIdentifiers.emplace_back(strawID, bufferPosition);
91  m_bofai_sorted = false;
92 
93  // cout << "set m_BufferOffsetForAllIdentifiers["
94  // << std::hex << strawID << std::dec
95  // << "] = " << bufferPosition << endl;
96 }
97 
98 
99  // Set value of Identifier for each straw (DC1, DC2)
101 {
102  m_identifierForAllStraws.push_back(strawID);
103 }
104 
105 
106  // Set value of IdentifierHash for each straw (TB case)
108  int bufferPosition, IdentifierHash hashId)
109 {
110  find_idandhash (rod, bufferPosition).second = hashId;
111 }
112 
113  // Set value of IdentifierHash for each straw (DC1, DC2)
115 {
116  m_identifierHashForAllStraws.push_back(hashId);
117 }
118 
119 
121  int bufferPosition) const
122 {
123  return find_idandhash (rod, bufferPosition).first;
124 }
125 
127  (int rod, int bufferPosition) const
128 {
129  return find_idandhash (rod, bufferPosition).second;
130 }
131 
132 
133  // Get value of Identifier for each straw (DC1, DC2)
135 {
136  return m_identifierForAllStraws[shift];
137 }
138 
139  // Get value of IdentifierHash for each straw (DC1, DC2)
141 {
142  return m_identifierHashForAllStraws[shift];
143 }
144 
145 // Get buffer offset from Identifier
147 {
148  // cout << "get m_BufferOffsetForAllIdentifiers["
149  // << std::hex << StrawId << std::dec
150  // << "] = " << m_BufferOffsetForAllIdentifiers[StrawId] << endl;
151 
152  if (!m_bofai_sorted) {
153  std::sort (m_BufferOffsetForAllIdentifiers.begin(),
155  m_bofai_sorted = true;
156  }
157 
159  std::lower_bound (m_BufferOffsetForAllIdentifiers.begin(),
161  StrawId);
162  assert (i != m_BufferOffsetForAllIdentifiers.end() && i->first == StrawId);
163  return i->second;
164 }
165 
166 
167  // Add collection IDs for ROB
168 void TRT_CablingData::add_collID(uint32_t rob_id, std::vector<IdentifierHash> * vectID)
169 {
170  m_collID[rob_id] = vectID;
171 }
172 
173 
174  // Get Identifiers of Collections for the given ROBID
175 const std::vector<IdentifierHash>& TRT_CablingData::get_collID(int shift)
176 {
177  return *m_collID[shift];
178 }
179 
180  // Add SourceID
182 {
183  m_allRobs.push_back(sidROB);
184 }
185 
186  // Get all RODIDs for TRT
187 const std::vector<uint32_t>& TRT_CablingData::get_allRods() const
188 {
189  return m_allRobs;
190 }
191 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
TRT_CablingData::m_rodoffset_to_id
rodmap_t m_rodoffset_to_id
Definition: TRT_CablingData.h:106
TRT_CablingData::idandhash_t
std::pair< Identifier, IdentifierHash > idandhash_t
Definition: TRT_CablingData.h:102
TRT_CablingData::m_bofai_sorted
bool m_bofai_sorted
Definition: TRT_CablingData.h:96
TRT_CablingData::set_identifierHashForAllStraws
void set_identifierHashForAllStraws(int rod, int bufferPosition, IdentifierHash hashId)
Definition: TRT_CablingData.cxx:107
TRT_CablingData::TRT_CablingData
TRT_CablingData()
Definition: TRT_CablingData.cxx:18
TRT_CablingData.h
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
skel.it
it
Definition: skel.GENtoEVGEN.py:396
TRT_CablingData::get_allRods
const std::vector< uint32_t > & get_allRods() const
Definition: TRT_CablingData.cxx:187
TRT_CablingData::~TRT_CablingData
virtual ~TRT_CablingData()
Definition: TRT_CablingData.cxx:24
TRT_CablingData::get_collID
const std::vector< IdentifierHash > & get_collID(int shift)
Definition: TRT_CablingData.cxx:175
TRT_CablingData::set_identifierForAllStraws
void set_identifierForAllStraws(int rod, int bufferPosition, Identifier strawID)
Definition: TRT_CablingData.cxx:86
xAOD::unsigned
unsigned
Definition: RingSetConf_v1.cxx:662
TRT_CablingData::zero_identifierForAllStraws
void zero_identifierForAllStraws(int rod, const std::vector< Identifier > &tempbuff)
Definition: TRT_CablingData.cxx:35
TRT_CablingData::get_identifierHashForAllStraws
IdentifierHash get_identifierHashForAllStraws(int rod, int bufferPosition) const
Definition: TRT_CablingData.cxx:127
TRT_CablingData::add_allRobs
void add_allRobs(uint32_t sidROB)
Definition: TRT_CablingData.cxx:181
TRT_CablingData::get_BufferOffset
uint32_t get_BufferOffset(Identifier StrawId)
Definition: TRT_CablingData.cxx:146
TRT_CablingData::m_BufferOffsetForAllIdentifiers
std::vector< idpair > m_BufferOffsetForAllIdentifiers
Definition: TRT_CablingData.h:95
lumiFormat.i
int i
Definition: lumiFormat.py:85
TRT_CablingData::add_collID
void add_collID(uint32_t rob_id, std::vector< IdentifierHash > *vectID)
Definition: TRT_CablingData.cxx:168
TRT_CablingData::m_collID
std::map< uint32_t, std::vector< IdentifierHash > * > m_collID
Definition: TRT_CablingData.h:100
RunTileMonitoring.rod
rod
Definition: RunTileMonitoring.py:134
TRT_CablingData::offsetvec_t
std::vector< idandhash_t > offsetvec_t
Definition: TRT_CablingData.h:103
TRT_CablingData::get_identifierForAllStraws
Identifier get_identifierForAllStraws(int rod, int bufferPosition) const
Definition: TRT_CablingData.cxx:120
TRT_CablingData::m_identifierForAllStraws
std::vector< Identifier > m_identifierForAllStraws
Definition: TRT_CablingData.h:80
TRT_CablingData::m_identifierHashForAllStraws
std::vector< IdentifierHash > m_identifierHashForAllStraws
Definition: TRT_CablingData.h:83
TRT_CablingData::find_idandhash
idandhash_t & find_idandhash(int rod, int bufferPosition)
Definition: TRT_CablingData.cxx:49
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
TRT_CablingData::rodvec_t
std::vector< offsetvec_t > rodvec_t
Definition: TRT_CablingData.h:104
TRT_CablingData::zero_identifierHashForAllStraws
void zero_identifierHashForAllStraws(int rod, const std::vector< IdentifierHash > &tempbuff)
Definition: TRT_CablingData.cxx:42
TRT_CablingData::m_allRobs
std::vector< uint32_t > m_allRobs
Definition: TRT_CablingData.h:77
Identifier
Definition: IdentifierFieldParser.cxx:14