ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloTriggerTool
src
CaloTTOnAttrIdMap.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/CaloTTOnAttrIdMap.h
"
6
#include "
CaloIdentifier/TTOnlineID.h
"
7
#include "
CaloIdentifier/CaloID_Exception.h
"
8
9
#include "GaudiKernel/ISvcLocator.h"
10
#include "GaudiKernel/Bootstrap.h"
11
#include "GaudiKernel/MsgStream.h"
12
#include "GaudiKernel/IMessageSvc.h"
13
14
#include "
AthenaKernel/errorcheck.h
"
15
#include "
StoreGate/StoreGateSvc.h
"
16
17
#include <iostream>
18
19
CaloTTOnAttrIdMap::CaloTTOnAttrIdMap
() {
20
}
21
22
23
CaloTTOnAttrIdMap::~CaloTTOnAttrIdMap
() {
24
}
25
26
//------------------------------------------//
27
void
CaloTTOnAttrIdMap::set
(
const
CaloTTOnAttrId
& m ) {
28
29
convert_to_P
(m);
30
31
SmartIF<IMessageSvc> msgSvc{Gaudi::svcLocator()->service(
"MessageSvc"
)};
32
if
(!msgSvc){
33
throw
std::runtime_error(
"Cannot locate MessageSvc"
);
34
}
35
MsgStream log( msgSvc,
"CaloTTOnAttrIdMap"
);
36
37
log<<MSG::DEBUG<<
" CaloTTOnAttrId size = "
<<m.size() <<
endmsg
;
38
39
SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore"
)};
40
if
(!detStore){
41
log << MSG::ERROR <<
"Cannot locate DetectorStore"
<<
endmsg
;
42
}
43
44
const
TTOnlineID
* online_id =
nullptr
;
45
if
(detStore->retrieve(online_id).isFailure()){
46
log << MSG::ERROR <<
"Cannot retrieve online_id"
<<
endmsg
;
47
}
48
49
CaloTTOnAttrId::const_iterator it = m.begin();
50
CaloTTOnAttrId::const_iterator it_e = m.end();
51
52
try
{
53
for
(; it!=it_e; ++it) {
54
const
CaloTTOnAttrId_t
& t = *it;
55
56
HWIdentifier
sid = online_id->
channelId
(t.crate, t.module, t.submodule, t.channel);
57
58
if
(log.level()<=MSG::VERBOSE) {
59
log<<MSG::VERBOSE
60
<<
" db struct= "
61
<<
" crate="
<<t.crate<<
" module="
<<t.module
62
<<
" submodule="
<<t.submodule
63
<<
" channel="
<<t.channel
64
<<
" em_had="
<<t.em_had
65
<<
" pos_neg="
<<t.pos_neg
66
<<
" barrel_endcap_fcal"
<<t.barrel_endcap_fcal
67
<<
endmsg
;
68
69
log<<MSG::VERBOSE<<
" onl id = "
<< sid <<
endmsg
;
70
}
71
72
AttrStruct
attrStruct;
73
attrStruct.
em_had
= t.em_had;
74
attrStruct.
pos_neg
= t.pos_neg;
75
attrStruct.
barrel_endcap_fcal
= t.barrel_endcap_fcal;
76
attrStruct.
module_type
= t.module_type;
77
78
m_on2attrIdMap
[sid] = attrStruct;
79
}
80
if
(log.level()<=MSG::DEBUG) {
81
log<<MSG::DEBUG<<
" CaloTTOnAttrIdMap::set : number of Ids="
<<
m_on2attrIdMap
.size()<<std::endl;
82
}
83
}
catch
(
CaloID_Exception
& except) {
84
log<<MSG::ERROR<<
" Failed in CaloTTOnAttrIdMap::set "
<<
endmsg
;
85
log<<MSG::ERROR<< (std::string) except <<
endmsg
;
86
}
87
return
;
88
}
89
90
unsigned
int
CaloTTOnAttrIdMap::em_had
(
HWIdentifier
channelId )
const
{
91
std::map<HWIdentifier,AttrStruct>::const_iterator it=
m_on2attrIdMap
.find(channelId);
92
93
if
(it!=
m_on2attrIdMap
.end()){
94
return
((*it).second).em_had;
95
}
96
97
// ERROR, can not find the channelId.
98
REPORT_MESSAGE_WITH_CONTEXT
(MSG::ERROR,
"CaloTTOnAttrIdMap"
) <<
99
"Online ID not found, channelId = "
<< channelId.get_compact() <<
endmsg
;
100
return
0;
101
}
102
103
unsigned
int
CaloTTOnAttrIdMap::pos_neg
(
HWIdentifier
channelId )
const
{
104
std::map<HWIdentifier,AttrStruct>::const_iterator it=
m_on2attrIdMap
.find(channelId);
105
106
if
(it!=
m_on2attrIdMap
.end()){
107
return
((*it).second).pos_neg;
108
}
109
110
// ERROR, can not find the channelId.
111
REPORT_MESSAGE_WITH_CONTEXT
(MSG::ERROR,
"CaloTTOnAttrIdMap"
) <<
112
"Online ID not found, channelId = "
<< channelId.get_compact() <<
endmsg
;
113
return
0;
114
}
115
116
unsigned
int
CaloTTOnAttrIdMap::barrel_endcap_fcal
(
HWIdentifier
channelId )
const
{
117
std::map<HWIdentifier,AttrStruct>::const_iterator it=
m_on2attrIdMap
.find(channelId);
118
119
if
(it!=
m_on2attrIdMap
.end()){
120
return
((*it).second).barrel_endcap_fcal;
121
}
122
123
// ERROR, can not find the channelId.
124
REPORT_MESSAGE_WITH_CONTEXT
(MSG::ERROR,
"CaloTTOnAttrIdMap"
) <<
125
"Online ID not found, channelId = "
<< channelId.get_compact() <<
endmsg
;
126
return
0;
127
}
128
129
unsigned
int
CaloTTOnAttrIdMap::module_type
(
HWIdentifier
channelId )
const
{
130
std::map<HWIdentifier,AttrStruct>::const_iterator it=
m_on2attrIdMap
.find(channelId);
131
132
if
(it!=
m_on2attrIdMap
.end()){
133
return
((*it).second).module_type;
134
}
135
136
// ERROR, can not find the channelId.
137
REPORT_MESSAGE_WITH_CONTEXT
(MSG::ERROR,
"CaloTTOnAttrIdMap"
) <<
138
"Online ID not found, channelId = "
<< channelId.get_compact() <<
endmsg
;
139
return
0;
140
}
141
142
CaloTTOnAttrId_P
*
CaloTTOnAttrIdMap::getP
() {
143
return
&
m_persData
;
144
}
145
146
void
CaloTTOnAttrIdMap::convert_to_P
(
const
CaloTTOnAttrId
& d ) {
147
148
CaloTTOnAttrId::const_iterator it = d.begin();
149
CaloTTOnAttrId::const_iterator it_e = d.end();
150
151
for
( ;it!=it_e;++it){
152
const
CaloTTOnAttrId_t
& t = *it;
153
CaloTTOnAttrId_P::__t
t2 ;
154
155
t2.crate = t.crate ;
156
t2.module = t.module;
157
t2.submodule= t.submodule;
158
t2.channel = t.channel;
159
160
t2.em_had = t.em_had;
161
t2.pos_neg = t.pos_neg;
162
t2.barrel_endcap_fcal = t.barrel_endcap_fcal;
163
t2.module_type = t.module_type;
164
165
m_persData
.m_v.push_back(t2);
166
}
167
}
168
169
170
void
CaloTTOnAttrIdMap::convert_to_D
(
const
CaloTTOnAttrId_P
& p,
CaloTTOnAttrId
& d ) {
171
172
std::vector<CaloTTOnAttrId_P::__t>::const_iterator it = p.m_v.begin();
173
std::vector<CaloTTOnAttrId_P::__t>::const_iterator it_e = p.m_v.end();
174
175
d.clear();
176
for
( ;it!=it_e;++it){
177
const
CaloTTOnAttrId_P::__t
& t = *it;
178
CaloTTOnAttrId_t
t2 ;
179
180
t2.crate = t.crate ;
181
t2.module = t.module;
182
t2.submodule= t.submodule;
183
t2.channel = t.channel;
184
185
t2.em_had = t.em_had;
186
t2.pos_neg = t.pos_neg;
187
t2.barrel_endcap_fcal = t.barrel_endcap_fcal;
188
t2.module_type = t.module_type;
189
190
d.push_back(t2);
191
}
192
}
193
194
void
CaloTTOnAttrIdMap::set
(
const
CaloTTOnAttrId_P
& p) {
195
196
CaloTTOnAttrId
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
CaloTTOnAttrIdMap.h
CaloTTOnAttrId
std::vector< CaloTTOnAttrId_t > CaloTTOnAttrId
Definition
CaloTTOnAttrId.h:27
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
CaloTTOnAttrIdMap::pos_neg
unsigned int pos_neg(HWIdentifier channelId) const
return 0 for z<0 channels and 1 for z>0 channels
Definition
CaloTTOnAttrIdMap.cxx:103
CaloTTOnAttrIdMap::convert_to_P
void convert_to_P(const CaloTTOnAttrId &t)
Definition
CaloTTOnAttrIdMap.cxx:146
CaloTTOnAttrIdMap::getP
CaloTTOnAttrId_P * getP()
return the persistified map
Definition
CaloTTOnAttrIdMap.cxx:142
CaloTTOnAttrIdMap::m_on2attrIdMap
std::map< HWIdentifier, AttrStruct > m_on2attrIdMap
Definition
CaloTTOnAttrIdMap.h:87
CaloTTOnAttrIdMap::set
void set(const PDATA &t)
initialize from Nova
Definition
CaloTTOnAttrIdMap.cxx:27
CaloTTOnAttrIdMap::barrel_endcap_fcal
unsigned int barrel_endcap_fcal(HWIdentifier channelId) const
To know if a channel belongs to the barrel, end cap or fcal parts.
Definition
CaloTTOnAttrIdMap.cxx:116
CaloTTOnAttrIdMap::module_type
unsigned int module_type(HWIdentifier channelId) const
To get the type of the module connected to the channel:
Definition
CaloTTOnAttrIdMap.cxx:129
CaloTTOnAttrIdMap::CaloTTOnAttrIdMap
CaloTTOnAttrIdMap()
Definition
CaloTTOnAttrIdMap.cxx:19
CaloTTOnAttrIdMap::~CaloTTOnAttrIdMap
~CaloTTOnAttrIdMap()
Definition
CaloTTOnAttrIdMap.cxx:23
CaloTTOnAttrIdMap::convert_to_D
void convert_to_D(const CaloTTOnAttrId_P &t, CaloTTOnAttrId &d)
Definition
CaloTTOnAttrIdMap.cxx:170
CaloTTOnAttrIdMap::m_persData
CaloTTOnAttrId_P m_persData
Definition
CaloTTOnAttrIdMap.h:89
CaloTTOnAttrIdMap::em_had
unsigned int em_had(HWIdentifier channelId) const
return the corresponding sampling of channelId:
Definition
CaloTTOnAttrIdMap.cxx:90
CaloTTOnAttrId_P
This is a database object holding the TT online-attribute map.
Definition
CaloTTOnAttrId_P.h:22
CaloTTOnAttrId_P::__t
CaloTTOnAttrId_P_t __t
Definition
CaloTTOnAttrId_P.h:38
HWIdentifier
Definition
HWIdentifier.h:13
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
AttrStruct
This is a StoreGate object holding the TT online-attribute map.
Definition
CaloTTOnAttrIdMap.h:25
AttrStruct::pos_neg
unsigned int pos_neg
Definition
CaloTTOnAttrIdMap.h:27
AttrStruct::barrel_endcap_fcal
unsigned int barrel_endcap_fcal
Definition
CaloTTOnAttrIdMap.h:28
AttrStruct::module_type
unsigned int module_type
Definition
CaloTTOnAttrIdMap.h:29
AttrStruct::em_had
unsigned int em_had
Definition
CaloTTOnAttrIdMap.h:26
CaloTTOnAttrId_t
Structure definition of the LArTTOnAttrIdMap.
Definition
CaloTTOnAttrId.h:15
Generated on
for ATLAS Offline Software by
1.17.0