ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileRawUtils
src
TileRoI_Map.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TileRawUtils/TileRoI_Map.h
"
6
7
#include "
CaloIdentifier/TileID.h
"
8
#include "
TileIdentifier/TileHWID.h
"
9
#include "CaloDetDescr/CaloDetDescrElement.h"
10
#include "
TileDetDescr/TileDetDescrManager.h
"
11
#include "
TileConditions/TileCablingService.h
"
12
13
#include "
StoreGate/StoreGateSvc.h
"
14
15
// This class converts a Tile offline ID and Online Identifier into a RoI id,
16
//
17
18
static
const
InterfaceID
IID_ITileRoI_Map
(
"TileRoI_Map"
, 1, 0);
19
20
const
InterfaceID&
TileRoI_Map::interfaceID
( )
21
{
return
IID_ITileRoI_Map
; }
22
23
// default contructor
24
TileRoI_Map::TileRoI_Map
(
const
std::string&
type
,
const
std::string& name,
25
const
IInterface* parent )
26
:
AthAlgTool
(
type
,name,parent)
27
{
28
declareInterface<TileRoI_Map>(
this
);
29
}
30
31
StatusCode
TileRoI_Map::initialize
()
32
{
33
ATH_CHECK
(
detStore
()->retrieve(
m_tileMgr
) );
34
ATH_CHECK
(
detStore
()->retrieve(
m_tileID
,
"TileID"
) );
35
ATH_CHECK
(
detStore
()->retrieve(
m_tileHWID
,
"TileHWID"
) );
36
37
// get the pointer to CablingSvc
38
m_cablingSvc
=
TileCablingService::getInstance
();
39
40
m_idhash
.initialize(
m_tileHWID
);
41
42
// intialize the internal map
43
45
std::vector<HWIdentifier>::const_iterator first =
m_tileHWID
->adc_begin();
46
std::vector<HWIdentifier>::const_iterator last =
m_tileHWID
->adc_end();
47
48
int
nADC = 0;
49
for
( ; first!=last; ++first) {
50
if
(
addEntry
(*first) ) ++nADC;
51
}
52
53
if
(
m_print
) {
54
std::cout <<
" number of ADCs made in TileRoI_Map "
<< nADC<< std::endl;
55
}
56
57
if
(
m_print
)
printEtaPhiRegions
();
58
59
return
StatusCode::SUCCESS;
60
}
61
62
TileRoI_Map::~TileRoI_Map
( )
63
{
64
}
65
66
67
bool
TileRoI_Map::addEntry
(
const
HWIdentifier
& adc_hwid)
68
{
69
70
Identifier
adc_id =
m_cablingSvc
->h2s_adc_id(adc_hwid);
71
72
if
(adc_id.
is_valid
()) {
73
74
Identifier
pmt_id =
m_tileID
->pmt_id(adc_id);
75
Identifier
cell_id =
m_tileID
->cell_id(adc_id);
76
77
Identifier
rId =
m_cablingSvc
->pmt2tt_id(pmt_id);
78
79
m_offmap
[ cell_id ] = rId;
// mapping for Cell id
80
m_offmap
[ pmt_id ] = rId;
// mapping for PMT id
81
m_offmap
[ adc_id ] = rId;
// mapping for ADC id
82
83
HWIdentifier
chan_id =
m_tileHWID
->channel_id(adc_hwid);
84
m_onlmap
[ chan_id ] = rId;
// mapping for online channel id
85
m_onlmap
[ adc_hwid ] = rId;
// mapping for online ADC id
86
87
std::cout
88
<<
" HW id "
<<
m_tileHWID
->to_string(adc_hwid)
89
<<
" id "
<<
m_tileID
->to_string(adc_id)
90
<<
" tt id "
<< rId
// don't know how to print TT ID
91
<< std::endl;
92
93
// add entry for RoI to COLL_ID map.
94
// make an Tile frag ID
95
int
frag =
m_tileHWID
->frag(chan_id);
96
COLL_ID_VEC
& v =
m_roimap
[rId];
97
COLL_ID_VEC::const_iterator it = v.begin();
98
COLL_ID_VEC::const_iterator it_end = v.end();
99
bool
found =
false
;
100
101
const
CaloDetDescrElement
* caloDDE =
m_tileMgr
->get_cell_element(cell_id);
102
m_epmap
[frag].set(caloDDE->
eta
(),caloDDE->
phi
());
103
104
for
(; it != it_end; ++it)
105
if
(frag == (*it) ) found =
true
;
106
if
(!found) {
107
// std::cout <<" Mapped RoI "<<rId.sample()<<" "<<rId.eta()<<" "
108
// <<rId.phi()<<" to frag "<<std::hex<<frag<<std::dec<<std::endl;
109
v.push_back(frag);
110
}
111
}
else
112
{
113
std::cout <<
" Failed to get Identifier in TileRoI_Map::add "
<< std::endl;
114
return
false
;
115
}
116
117
return
true
;
118
119
}
120
121
122
// Given offline channel ID, find TT ID.
123
TileRoI_Map::TT_ID
TileRoI_Map::TrigTowerID
(
const
Identifier
&
id
)
124
const
125
{
126
OFFMAP::const_iterator it =
m_offmap
.find(
id
);
127
if
( it==
m_offmap
.end() )
128
{
129
std::string err(
" TileRoI_Map: not entry for ID "
);
130
err +=
m_tileID
->to_string(
id
,-1) ;
131
TileID_Exception
except(err,1);
132
throw
except;
133
}
134
135
return
(*it).second;
136
137
}
138
139
140
// Given online Channel ID, find TT ID.
141
TileRoI_Map::TT_ID
TileRoI_Map::TrigTowerID
(
const
HWIdentifier
&
id
)
142
const
143
{
144
ONLMAP::const_iterator it =
m_onlmap
.find(
id
);
145
if
(it==
m_onlmap
.end() )
146
{
147
std::string err(
" TileRoI_Map::TrigTowerID(const HWIdentifier&): no entry for HWID "
);
148
err +=
m_tileHWID
->to_string(
id
,-1) ;
149
TileID_Exception
except(err,2);
150
throw
except;
151
}
152
153
return
(*it).second;
154
155
}
156
157
const
TileRoI_Map::COLL_ID_VEC
&
TileRoI_Map::CollectionID
158
(
const
TileRoI_Map::TT_ID
& RoIid )
const
159
{
160
ROIMAP::const_iterator it =
m_roimap
.find(RoIid);
161
if
(it !=
m_roimap
.end()) {
162
return
(*it).second;
163
}
164
std::cout <<
" TileRoI_Map::CollectionID: can not find RoI"
<< std::endl;
165
static
const
COLL_ID_VEC
v ;
166
return
v;
167
}
168
169
bool
TileRoI_Map::validId
170
(
const
TileRoI_Map::TT_ID
& RoIid )
const
171
{
172
ROIMAP::const_iterator it =
m_roimap
.find(RoIid);
173
return
it !=
m_roimap
.end() ;
174
}
175
176
void
TileRoI_Map::printEtaPhiRegions
()
177
{
178
// print all Collection ID and eta phi region
179
180
E_P_MAP::const_iterator it =
m_epmap
.begin();
181
E_P_MAP::const_iterator it_end =
m_epmap
.end();
182
183
std::cout <<
" COLLECTION ID , HASHID, ETAMIN, ETAMAX, PHIMIN, PHIMAX "
<<std::endl ;
184
185
TileHWID
tileHW;
186
187
for
(; it!=it_end;++it){
188
int
frag = (*it).first;
189
int
hashid =
m_idhash
(frag);
190
191
float
e1,e2,p1,p2 ;
192
193
// check getEtaPhiRegion method.
194
getEtaPhiRegion
(hashid,e1,e2,p1,p2);
195
196
// print them out.
197
std::cout <<std::hex<< frag
198
<<
" "
<<hashid <<
" "
199
<<e1 <<
" "
200
<<e2 <<
" "
201
<<p1 <<
" "
202
<<p2 << std::endl;
203
}
204
std::cout << std::dec << std::endl;
205
206
}
207
208
bool
TileRoI_Map:: getEtaPhiRegion
(
unsigned
int
hashid,
209
float
& etamin,
float
& etamax,
210
float
& phimin,
float
& phimax )
const
211
212
{
213
if
( (
int
)hashid >=
m_idhash
.max() )
return
false
;
214
215
int
frag =
m_idhash
.identifier(hashid);
216
E_P_MAP::const_iterator it =
m_epmap
.find(frag);
217
if
(it ==
m_epmap
.end())
return
false
;
218
219
etamin = (*it).second.etamin;
220
etamax = (*it).second.etamax;
221
phimin = (*it).second.phimin;
222
phimax = (*it).second.phimax;
223
224
return
true
;
225
226
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
StoreGateSvc.h
TileCablingService.h
TileDetDescrManager.h
TileHWID.h
TileID.h
IID_ITileRoI_Map
static const InterfaceID IID_ITileRoI_Map("TileRoI_Map", 1, 0)
TileRoI_Map.h
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell.
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloDetDescrElement::eta
float eta() const
cell eta
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:344
CaloDetDescrElement::phi
float phi() const
cell phi
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:346
HWIdentifier
Definition
HWIdentifier.h:13
Identifier::is_valid
bool is_valid() const
Check if id is in a valid state.
TileCablingService::getInstance
static const TileCablingService * getInstance()
get pointer to service instance
Definition
TileCablingService.cxx:24
TileHWID
Helper class for TileCal online (hardware) identifiers.
Definition
TileHWID.h:49
TileID_Exception
Exception class for Tile Identifiers.
Definition
TileID_Exception.h:16
TileRoI_Map::TrigTowerID
TT_ID TrigTowerID(const Identifier &id) const
return TrigTowerID for various queries.
Definition
TileRoI_Map.cxx:123
TileRoI_Map::m_tileMgr
const TileDetDescrManager * m_tileMgr
Definition
TileRoI_Map.h:126
TileRoI_Map::TT_ID
Identifier TT_ID
Definition
TileRoI_Map.h:46
TileRoI_Map::m_cablingSvc
const TileCablingService * m_cablingSvc
Definition
TileRoI_Map.h:127
TileRoI_Map::m_offmap
OFFMAP m_offmap
Definition
TileRoI_Map.h:118
TileRoI_Map::m_tileID
const TileID * m_tileID
Definition
TileRoI_Map.h:124
TileRoI_Map::CollectionID
const std::vector< COLL_ID > & CollectionID(const TT_ID &id) const
reserve lookup.
Definition
TileRoI_Map.cxx:158
TileRoI_Map::initialize
StatusCode initialize()
define a RoI identifier type, two ints.
Definition
TileRoI_Map.cxx:31
TileRoI_Map::~TileRoI_Map
virtual ~TileRoI_Map()
Definition
TileRoI_Map.cxx:62
TileRoI_Map::m_roimap
ROIMAP m_roimap
Definition
TileRoI_Map.h:120
TileRoI_Map::m_print
Gaudi::Property< bool > m_print
Definition
TileRoI_Map.h:130
TileRoI_Map::m_onlmap
ONLMAP m_onlmap
Definition
TileRoI_Map.h:119
TileRoI_Map::interfaceID
static const InterfaceID & interfaceID()
AlgTool InterfaceID.
Definition
TileRoI_Map.cxx:20
TileRoI_Map::m_idhash
TileFragHash m_idhash
Definition
TileRoI_Map.h:129
TileRoI_Map::validId
bool validId(const TT_ID &tt_id) const
check validity
Definition
TileRoI_Map.cxx:170
TileRoI_Map::addEntry
bool addEntry(const HWIdentifier &adc_hwid)
Definition
TileRoI_Map.cxx:67
TileRoI_Map::getEtaPhiRegion
bool getEtaPhiRegion(unsigned int hashid, float &etamin, float &etamax, float &phimin, float &phimax) const
returns Eta-Phi Region for a hashed ID of the Collection.
Definition
TileRoI_Map.cxx:208
TileRoI_Map::COLL_ID_VEC
std::vector< COLL_ID > COLL_ID_VEC
Definition
TileRoI_Map.h:113
TileRoI_Map::TileRoI_Map
TileRoI_Map(const std::string &type, const std::string &name, const IInterface *parent)
constructor
Definition
TileRoI_Map.cxx:24
TileRoI_Map::printEtaPhiRegions
void printEtaPhiRegions()
Definition
TileRoI_Map.cxx:176
TileRoI_Map::m_epmap
E_P_MAP m_epmap
Definition
TileRoI_Map.h:122
TileRoI_Map::m_tileHWID
const TileHWID * m_tileHWID
Definition
TileRoI_Map.h:125
Identifier
Definition
IdentifierFieldParser.cxx:14
type
Generated on
for ATLAS Offline Software by
1.17.0