ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
TrigT1CaloMappingTools
src
PpmCoolMappingTool.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 <cmath>
6
7
#include "GaudiKernel/IIncidentSvc.h"
8
#include "GaudiKernel/IInterface.h"
9
#include "GaudiKernel/MsgStream.h"
10
#include "GaudiKernel/StatusCode.h"
11
12
#include "
CaloIdentifier/CaloIdManager.h
"
13
#include "
CaloIdentifier/CaloID_Exception.h
"
14
#include "
CaloIdentifier/CaloLVL1_ID.h
"
15
#include "
CaloIdentifier/TTOnlineID.h
"
16
#include "Identifier/Identifier.h"
17
#include "
Identifier/HWIdentifier.h
"
18
19
#include "
PpmCoolMappingTool.h
"
20
21
namespace
LVL1
{
22
23
const
int
PpmCoolMappingTool::s_maxTableEntries
;
24
25
26
// Initialise the mappings
27
28
StatusCode
PpmCoolMappingTool::initialize
()
29
{
30
// Retrieve the CaloTriggerTowerService tool
31
ATH_CHECK
(
m_ttSvc
.retrieve() );
32
33
// Retrieve the CaloIdManager from the detector store
34
const
CaloIdManager
* caloMgr = 0;
35
ATH_CHECK
( detStore()->retrieve(caloMgr) );
36
37
// Use the CaloIdManager to get a pointer to an instance
38
// of the CaloLVL1_ID helper
39
ATH_CHECK
( (
m_lvl1Helper
= caloMgr->
getLVL1_ID
()) !=
nullptr
);
40
41
// Use the CaloIdManager to get a pointer to an instance
42
// of the TTOnlineID helper
43
ATH_CHECK
( (
m_l1ttonlineHelper
= caloMgr->
getTTOnlineID
()) !=
nullptr
);
44
45
// Incident Service:
46
ServiceHandle<IIncidentSvc>
incSvc(
"IncidentSvc"
,
name
());
47
ATH_CHECK
( incSvc.retrieve() );
48
49
//start listening to "BeginRun"
50
incSvc->addListener(
this
,
"BeginRun"
);
51
52
return
StatusCode::SUCCESS;
53
}
54
55
56
// Reset mapping table at start of run
57
58
void
PpmCoolMappingTool::handle
(
const
Incident& inc)
59
{
60
// FIXME: not thread safe --- won't work if there's more than one run
61
// in the input.
62
if
(inc.type()==
"BeginRun"
) {
63
ATH_MSG_DEBUG
(
"Resetting mapping table at start of run"
);
64
65
m_idTable
.resize (
s_maxTableEntries
);
66
for
(
int
index
= 0;
index
<
s_maxTableEntries
; ++
index
) {
67
const
int
channel =
index
& 0x3f;
68
const
int
module = (
index
>> 6) & 0x0f;
69
const
int
crate =
index
>> 10;
70
const
int
slot =
module
+ 5;
71
const
int
pin = channel % 16;
72
const
int
asic = channel / 16;
73
74
Identifier
ttId(0);
75
Identifier
invalidId
(0);
76
try
{
77
ATH_MSG_VERBOSE
(
"crate/module/channel "
<< crate <<
"/"
78
<< module <<
"/"
<< channel
79
<<
" maps to crate/slot/pin/asic "
<< crate <<
"/"
80
<< slot <<
"/"
<< pin <<
"/"
<< asic);
81
const
HWIdentifier
id
=
m_l1ttonlineHelper
->channelId(crate, slot, pin,
82
asic);
83
ATH_MSG_VERBOSE
(
"hardware_id: "
<<
id
);
84
85
ttId =
m_ttSvc
->cnvToIdentifier(
id
,
true
);
86
ATH_MSG_VERBOSE
(
"tower_id: "
<< ttId);
87
}
88
catch
(
const
CaloID_Exception
&) { ttId =
invalidId
; }
89
if
(ttId ==
invalidId
) {
90
m_idTable
[
index
] = 0;
91
}
92
else
{
93
const
int
side = (
m_lvl1Helper
->pos_neg_z(ttId) == 1) ? 1 : 2;
94
const
int
sample =
m_lvl1Helper
->sampling(ttId);
95
const
int
region =
m_lvl1Helper
->region(ttId);
96
const
int
ieta =
m_lvl1Helper
->eta(ttId);
97
const
int
iphi =
m_lvl1Helper
->phi(ttId);
98
m_idTable
[
index
] = (side<<14)+(sample<<13)+(region<<11)+(ieta<<6)+iphi;
99
}
100
}
101
}
102
return
;
103
}
104
105
// Return eta, phi and layer mapping for given crate/module/channel
106
107
bool
PpmCoolMappingTool::mapping
(
const
int
crate,
const
int
module,
108
const
int
channel,
double
&
eta
,
double
&
phi
,
int
& layer)
const
109
{
110
if
(crate < 0 || crate >= 8 || module < 0 || module >= 16 ||
111
channel < 0 || channel >= 64)
return
false
;
112
113
int
index
= (crate<<10) + (module<<6) + channel;
114
if
(
index
>=
s_maxTableEntries
)
return
false
;
115
116
if
(
index
>=
static_cast<
int
>
(
m_idTable
.size()) ||
m_idTable
[
index
] == 0) {
117
return
false
;
118
}
119
const
unsigned
int
entry =
m_idTable
[
index
];
120
const
int
side = ((entry>>14) == 1) ? 1 : -1;
121
const
int
region = (entry>>11)&0x3;
122
const
int
ieta = (entry>>6)&0x1f;
123
const
int
iphi = entry&0x3f;
124
const
double
etaOffsets[4] = { 0., 2.5, 3.1, 3.2 };
125
const
double
etaGrans[4] = { 0.1, 0.2, 0.1, 0.425 };
126
const
double
phiGrans[4] = {
M_PI
/32.,
M_PI
/16.,
M_PI
/16.,
M_PI
/8. };
127
128
eta
= side * (etaOffsets[region] + etaGrans[region] * (ieta + 0.5));
129
phi
= phiGrans[region] * (iphi + 0.5);
130
layer = (entry>>13)&0x1;
131
132
ATH_MSG_VERBOSE
(
"crate/module/channel "
<< crate <<
"/"
<< module
133
<<
"/"
<< channel <<
" maps to eta/phi/layer "
134
<<
eta
<<
"/"
<<
phi
<<
"/"
<< layer);
135
136
return
true
;
137
}
138
139
// Return crate, module and channel mapping for given eta/phi/layer
140
141
bool
PpmCoolMappingTool::mapping
(
const
double
eta
,
const
double
phi
,
142
const
int
layer,
int
& crate,
int
& module,
int
& channel)
const
143
{
144
if
(
eta <= -4.9 || eta >
= 4.9 ||
phi <= 0. || phi >
= 2.*
M_PI
)
return
false
;
145
146
const
double
etaOffsets[5] = { 0., 2.5, 3.1, 3.2, 4.9 };
147
const
double
etaGrans[4] = { 0.1, 0.2, 0.1, 0.425 };
148
const
double
phiGrans[4] = {
M_PI
/32.,
M_PI
/16.,
M_PI
/16.,
M_PI
/8. };
149
const
int
side = (
eta
< 0.) ? -1 : 1;
150
int
region = 0;
151
int
ieta = 0;
152
int
iphi = 0;
153
const
double
absEta = fabs(
eta
);
154
for
(
int
i = 0; i < 4; ++i) {
155
if
(absEta < etaOffsets[i+1]) {
156
region = i;
157
ieta = int((absEta - etaOffsets[i]) / etaGrans[i]);
158
iphi = int(
phi
/ phiGrans[i]);
159
break
;
160
}
161
}
162
163
HWIdentifier
id(0);
164
HWIdentifier
invalidId
(0);
165
try
{
166
ATH_MSG_VERBOSE
(
"eta/phi/layer "
<<
eta
<<
"/"
<<
phi
<<
"/"
167
<< layer <<
" maps to side/layer/region/ieta/iphi "
168
<< side <<
"/"
<< layer <<
"/"
<< region <<
"/"
169
<< ieta <<
"/"
<< iphi);
170
const
Identifier
ttId =
m_lvl1Helper
->tower_id(side, layer, region,
171
ieta, iphi);
172
ATH_MSG_VERBOSE
(
"tower_id: "
<< ttId);
173
174
id
=
m_ttSvc
->createTTChannelID(ttId,
true
);
175
176
ATH_MSG_VERBOSE
(
"hardware_id: "
<<
id
);
177
178
}
179
catch
(
const
CaloID_Exception
&) {
id
=
invalidId
; }
180
if
(
id
==
invalidId
)
return
false
;
181
182
const
int
slot =
m_l1ttonlineHelper
->module(
id
);
183
const
int
pin =
m_l1ttonlineHelper
->submodule(
id
);
184
const
int
asic =
m_l1ttonlineHelper
->channel(
id
);
185
186
crate =
m_l1ttonlineHelper
->crate(
id
);
187
module
= slot - 5;
188
channel = asic * 16 + pin;
189
190
ATH_MSG_VERBOSE
(
"eta/phi/layer "
<<
eta
<<
"/"
<<
phi
<<
"/"
<< layer
191
<<
" maps to crate/module/channel "
192
<< crate <<
"/"
<< module <<
"/"
<< channel);
193
194
return
true
;
195
}
196
197
}
// end namespace
M_PI
#define M_PI
Definition
ActiveFraction.h:14
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x,...)
Definition
AthMsgStreamMacros.h:42
CaloID_Exception.h
CaloIdManager.h
CaloLVL1_ID.h
HWIdentifier.h
invalidId
static const ITkStripOnlineId invalidId
Definition
ITkStripCablingTool.cxx:31
PpmCoolMappingTool.h
TTOnlineID.h
CaloID_Exception
Exception class for Calo Identifiers.
Definition
CaloID_Exception.h:20
CaloIdManager
This class initializes the Calo (LAr and Tile) offline identifiers.
Definition
CaloIdManager.h:45
CaloIdManager::getTTOnlineID
const TTOnlineID * getTTOnlineID(void) const
Definition
CaloIdManager.cxx:105
CaloIdManager::getLVL1_ID
const CaloLVL1_ID * getLVL1_ID(void) const
Definition
CaloIdManager.cxx:75
HWIdentifier
Definition
HWIdentifier.h:13
LVL1::PpmCoolMappingTool::m_l1ttonlineHelper
const TTOnlineID * m_l1ttonlineHelper
Definition
PpmCoolMappingTool.h:55
LVL1::PpmCoolMappingTool::mapping
virtual bool mapping(int crate, int module, int channel, double &eta, double &phi, int &layer) const override
Return eta, phi and layer mapping for given crate/module/channel.
Definition
PpmCoolMappingTool.cxx:107
LVL1::PpmCoolMappingTool::m_idTable
std::vector< unsigned int > m_idTable
Mapping lookup table.
Definition
PpmCoolMappingTool.h:58
LVL1::PpmCoolMappingTool::m_lvl1Helper
const CaloLVL1_ID * m_lvl1Helper
Definition
PpmCoolMappingTool.h:54
LVL1::PpmCoolMappingTool::s_maxTableEntries
static const int s_maxTableEntries
Definition
PpmCoolMappingTool.h:59
LVL1::PpmCoolMappingTool::initialize
virtual StatusCode initialize() override
Definition
PpmCoolMappingTool.cxx:28
LVL1::PpmCoolMappingTool::handle
virtual void handle(const Incident &) override
Definition
PpmCoolMappingTool.cxx:58
LVL1::PpmCoolMappingTool::m_ttSvc
ToolHandle< CaloTriggerTowerService > m_ttSvc
Definition
PpmCoolMappingTool.h:53
ServiceHandle
Definition
ClusterMakerTool.h:36
Identifier
Definition
IdentifierFieldParser.cxx:14
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition
IZdcDataAccess.h:13
index
Definition
index.py:1
TrigConf::name
Definition
HLTChainList.h:35
Generated on
for ATLAS Offline Software by
1.17.0