ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloTriggerTool
src
CaloTTOnOffIdMap.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 "
CaloTriggerTool/CaloTTOnOffIdMap.h
"
6
#include "
CaloIdentifier/TTOnlineID.h
"
7
#include "
CaloIdentifier/CaloLVL1_ID.h
"
8
#include "
CaloIdentifier/CaloID_Exception.h
"
9
10
#include "GaudiKernel/ISvcLocator.h"
11
#include "GaudiKernel/Bootstrap.h"
12
#include "GaudiKernel/MsgStream.h"
13
#include "GaudiKernel/IMessageSvc.h"
14
15
#include "
AthenaKernel/errorcheck.h
"
16
#include "
StoreGate/StoreGateSvc.h
"
17
18
#include <iostream>
19
20
CaloTTOnOffIdMap::CaloTTOnOffIdMap
() {
21
}
22
23
24
CaloTTOnOffIdMap::~CaloTTOnOffIdMap
() {
25
}
26
27
//------------------------------------------//
28
void
CaloTTOnOffIdMap::set
(
const
CaloTTOnOffId
& m ) {
29
30
convert_to_P
(m);
31
32
SmartIF<IMessageSvc> msgSvc{Gaudi::svcLocator()->service(
"MessageSvc"
)};
33
if
(!msgSvc){
34
throw
std::runtime_error(
"Cannot locate MessageSvc"
);
35
}
36
MsgStream log( msgSvc,
"CaloTTOnOffIdMap"
);
37
38
log<<MSG::DEBUG<<
" CaloTTOnOffId size = "
<<m.size() <<
endmsg
;
39
40
SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore"
)};
41
if
(!detStore){
42
log << MSG::ERROR <<
"Cannot locate DetectorStore"
<<
endmsg
;
43
}
44
45
const
TTOnlineID
* online_id =
nullptr
;
46
const
CaloLVL1_ID
* offline_id =
nullptr
;
47
48
StatusCode status=detStore->retrieve(online_id);
49
if
(status.isFailure()){
50
log << MSG::ERROR <<
"Cannot retrieve online_id"
<<
endmsg
;
51
}
52
status=detStore->retrieve(offline_id);
53
if
(status.isFailure()){
54
log << MSG::ERROR <<
"Cannot retrieve offline_id"
<<
endmsg
;
55
}
56
57
CaloTTOnOffId::const_iterator it = m.begin();
58
CaloTTOnOffId::const_iterator it_e = m.end();
59
60
try
{
61
for
(; it!=it_e; ++it) {
62
const
CaloTTOnOffId_t
& t = *it;
63
64
Identifier
id
= offline_id->
tower_id
(t.pn, t.sampling, t.region, t.eta, t.phi);
65
HWIdentifier
sid = online_id->
channelId
(t.crate, t.module, t.submodule, t.channel);
66
67
if
(log.level()<=MSG::VERBOSE) {
68
log<<MSG::VERBOSE
69
<<
" db struct= "
70
<<
" pn="
<<t.pn<<
" sampling="
<<t.sampling
71
<<
" region="
<<t.region
72
<<
" eta="
<<t.eta<<
" phi="
<<t.phi<<
" layer="
<<t.layer<<
" | "
73
<<
" crate="
<<t.crate<<
" module="
<<t.module
74
<<
" submodule="
<<t.submodule
75
<<
" channel="
<<t.channel
76
<<
endmsg
;
77
78
log<<MSG::VERBOSE<<
" onl id = "
<< sid<<
" offline id ="
<<
id
<<
endmsg
;
79
}
80
81
m_off2onIdMap
[id] = sid;
82
m_on2offIdMap
[sid] = id;
83
}
84
if
(log.level()<=MSG::DEBUG) {
85
log<<MSG::DEBUG<<
" CaloTTOnOffIdMap::set : number of Ids="
<<
m_on2offIdMap
.size()<<std::endl;
86
}
87
}
catch
(
CaloID_Exception
& except) {
88
log<<MSG::ERROR<<
" Failed in CaloTTOnOffIdMap::set "
<<
endmsg
;
89
log<<MSG::ERROR<< (std::string) except <<
endmsg
;
90
}
91
return
;
92
}
93
94
//--------------------------------------------------------------------------//
95
HWIdentifier
CaloTTOnOffIdMap::createSignalChannelID
(
const
Identifier
&
id
,
bool
bQuiet)
const
{
96
97
std::map<Identifier,HWIdentifier>::const_iterator it =
m_off2onIdMap
.find(
id
);
98
99
if
(it!=
m_off2onIdMap
.end()){
100
return
(*it).second;
101
}
102
103
if
(bQuiet) {
104
return
HWIdentifier
(0);
105
106
}
else
{
107
108
REPORT_MESSAGE_WITH_CONTEXT
(MSG::ERROR,
"CaloTTOnOffIdMap"
) <<
109
"Offline ID not found "
<<
id
<<
endmsg
;
110
111
return
HWIdentifier
(0);
112
}
113
}
114
115
116
//---------------------------------------------------------------------//
117
Identifier
CaloTTOnOffIdMap::cnvToIdentifier
(
const
HWIdentifier
& sid,
bool
bQuiet)
const
{
118
119
std::map<HWIdentifier,Identifier>::const_iterator it=
m_on2offIdMap
.find(sid);
120
121
if
(it!=
m_on2offIdMap
.end()){
122
return
(*it).second;
123
}
124
125
if
(bQuiet) {
126
return
Identifier
(0);
127
128
}
else
{
129
130
// ERROR, can not find the channelId.
131
REPORT_MESSAGE_WITH_CONTEXT
(MSG::ERROR,
"CaloTTOnOffIdMap"
) <<
132
"Online ID not found, id = "
<<sid.
get_compact
()<<
endmsg
;
133
134
return
Identifier
(0) ;
135
}
136
}
137
138
CaloTTOnOffId_P
*
CaloTTOnOffIdMap::getP
() {
139
return
&
m_persData
;
140
}
141
142
void
CaloTTOnOffIdMap::convert_to_P
(
const
CaloTTOnOffId
& d ) {
143
144
CaloTTOnOffId::const_iterator it = d.begin();
145
CaloTTOnOffId::const_iterator it_e = d.end();
146
147
for
( ;it!=it_e;++it){
148
const
CaloTTOnOffId_t
& t = *it;
149
CaloTTOnOffId_P::__t
t2 ;
150
151
t2.pn = t.pn;
152
t2.sampling = t.sampling;
153
t2.region = t.region;
154
t2.eta = t.eta;
155
t2.phi = t.phi;
156
t2.layer = t.layer;
157
158
t2.crate = t.crate ;
159
t2.module = t.module;
160
t2.submodule= t.submodule;
161
t2.channel = t.channel;
162
163
m_persData
.m_v.push_back(t2);
164
}
165
}
166
167
168
void
CaloTTOnOffIdMap::convert_to_D
(
const
CaloTTOnOffId_P
& p,
CaloTTOnOffId
& d ) {
169
170
std::vector<CaloTTOnOffId_P::__t>::const_iterator it = p.m_v.begin();
171
std::vector<CaloTTOnOffId_P::__t>::const_iterator it_e = p.m_v.end();
172
173
d.clear();
174
for
( ;it!=it_e;++it){
175
const
CaloTTOnOffId_P::__t
& t = *it;
176
CaloTTOnOffId_t
t2 ;
177
178
t2.pn = t.pn;
179
t2.sampling = t.sampling;
180
t2.region = t.region;
181
t2.eta = t.eta;
182
t2.phi = t.phi;
183
t2.layer = t.layer;
184
185
t2.crate = t.crate ;
186
t2.module = t.module;
187
t2.submodule= t.submodule;
188
t2.channel = t.channel;
189
190
d.push_back(t2);
191
}
192
}
193
194
void
CaloTTOnOffIdMap::set
(
const
CaloTTOnOffId_P
& p) {
195
196
CaloTTOnOffId
d;
197
convert_to_D
(p,d);
198
set
(d);
199
m_persData
.m_version = p.m_version;
200
return
;
201
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
CaloID_Exception.h
CaloLVL1_ID.h
CaloTTOnOffIdMap.h
CaloTTOnOffId
std::vector< CaloTTOnOffId_t > CaloTTOnOffId
Definition
CaloTTOnOffId.h:30
errorcheck.h
Helpers for checking error return status codes and reporting errors.
REPORT_MESSAGE_WITH_CONTEXT
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:345
StoreGateSvc.h
TTOnlineID.h
CaloID_Exception
Exception class for Calo Identifiers.
Definition
CaloID_Exception.h:20
CaloLVL1_ID
Helper class for offline TT identifiers.
Definition
CaloLVL1_ID.h:66
CaloLVL1_ID::tower_id
Identifier tower_id(int pos_neg_z, int sampling, int region, int eta, int phi) const
build a tower identifier
Definition
CaloLVL1_ID.h:429
CaloTTOnOffIdMap::CaloTTOnOffIdMap
CaloTTOnOffIdMap()
Definition
CaloTTOnOffIdMap.cxx:20
CaloTTOnOffIdMap::getP
CaloTTOnOffId_P * getP()
return the persistified map
Definition
CaloTTOnOffIdMap.cxx:138
CaloTTOnOffIdMap::m_off2onIdMap
std::map< Identifier, HWIdentifier > m_off2onIdMap
Definition
CaloTTOnOffIdMap.h:60
CaloTTOnOffIdMap::m_persData
CaloTTOnOffId_P m_persData
Definition
CaloTTOnOffIdMap.h:63
CaloTTOnOffIdMap::convert_to_D
void convert_to_D(const CaloTTOnOffId_P &t, CaloTTOnOffId &d)
Definition
CaloTTOnOffIdMap.cxx:168
CaloTTOnOffIdMap::set
void set(const PDATA &t)
initialize from Nova
Definition
CaloTTOnOffIdMap.cxx:28
CaloTTOnOffIdMap::m_on2offIdMap
std::map< HWIdentifier, Identifier > m_on2offIdMap
Definition
CaloTTOnOffIdMap.h:61
CaloTTOnOffIdMap::~CaloTTOnOffIdMap
~CaloTTOnOffIdMap()
Definition
CaloTTOnOffIdMap.cxx:24
CaloTTOnOffIdMap::cnvToIdentifier
Identifier cnvToIdentifier(const HWIdentifier &sid, bool bQuiet=false) const
return the corresponfing offline Id of an online one
Definition
CaloTTOnOffIdMap.cxx:117
CaloTTOnOffIdMap::createSignalChannelID
HWIdentifier createSignalChannelID(const Identifier &id, bool bQuiet=false) const
return the corresponfing online Id of an offline one
Definition
CaloTTOnOffIdMap.cxx:95
CaloTTOnOffIdMap::convert_to_P
void convert_to_P(const CaloTTOnOffId &t)
Definition
CaloTTOnOffIdMap.cxx:142
CaloTTOnOffId_P
This is a database object holding the TT online-offline map.
Definition
CaloTTOnOffId_P.h:22
CaloTTOnOffId_P::__t
CaloTTOnOffId_P_t __t
Definition
CaloTTOnOffId_P.h:41
HWIdentifier
Definition
HWIdentifier.h:13
Identifier::get_compact
value_type get_compact() const
Get the compact id.
TTOnlineID
Helper class for Calo TT online identifiers.
Definition
TTOnlineID.h:29
TTOnlineID::channelId
HWIdentifier channelId(int crate, int module, int submodule, int channel) const
(1) create towerId from fields
Definition
TTOnlineID.h:390
Identifier
Definition
IdentifierFieldParser.cxx:14
CaloTTOnOffId_t
Structure definition of the LArTTOnOffIdMap.
Definition
CaloTTOnOffId.h:15
Generated on
for ATLAS Offline Software by
1.17.0