ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCondTools
src
LArIdMapConvert.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
#include "
LArIdMapConvert.h
"
6
7
#include "
LArIdentifier/LArOnlineID.h
"
8
#include "
AthenaPoolUtilities/AthenaAttributeList.h
"
9
#include "CoralBase/Blob.h"
10
11
#include <fstream>
12
13
LArIdMapConvert::LArIdMapConvert
(
const
std::string& name,
14
ISvcLocator* pSvcLocator ) :
15
::
AthAlgorithm
( name, pSvcLocator ),
16
m_onlineID
(nullptr),
17
m_caloCellID
(nullptr)
18
{
19
20
}
21
22
LArIdMapConvert::~LArIdMapConvert
()
23
24
{}
25
26
StatusCode
LArIdMapConvert::initialize
() {
27
28
ATH_CHECK
(
detStore
()->retrieve(
m_onlineID
,
"LArOnlineID"
));
29
30
ATH_CHECK
(
detStore
()->retrieve(
m_caloCellID
,
"CaloCell_ID"
));
31
32
ATH_CHECK
(
m_cablingKey
.initialize() );
33
34
return
StatusCode::SUCCESS;
35
}
36
37
StatusCode
LArIdMapConvert::finalize
()
38
{
39
40
return
StatusCode::SUCCESS;
41
}
42
43
44
StatusCode
LArIdMapConvert::execute
(
const
EventContext& ctx) {
45
46
const
uint32_t onlHashMax=
m_onlineID
->channelHashMax();
47
48
SG::ReadCondHandle<LArOnOffIdMapping>
cablingHdl{
m_cablingKey
, ctx};
49
const
LArOnOffIdMapping
* cabling{*cablingHdl};
50
if
(!cabling) {
51
ATH_MSG_ERROR
(
"Do not have cabling mapping from key "
<<
m_cablingKey
.key() );
52
return
StatusCode::FAILURE;
53
}
54
SG::ReadCondHandle<LArCalibLineMapping>
clHdl{
m_CLKey
, ctx};
55
const
LArCalibLineMapping
*clCont {*clHdl};
56
if
(!clCont) {
57
ATH_MSG_ERROR
(
"Do not have calib line mapping !!!"
);
58
return
StatusCode::FAILURE;
59
}
60
61
coral::AttributeListSpecification* spec_onOff =
new
coral::AttributeListSpecification();
62
spec_onOff->extend(
"OnlineHashToOfflineId"
,
"blob"
);
63
spec_onOff->extend<
unsigned
>(
"version"
);
64
AthenaAttributeList
* al_onOff =
new
AthenaAttributeList
(*spec_onOff);
65
coral::Blob& blobOnOff=(*al_onOff)[
"OnlineHashToOfflineId"
].data<coral::Blob>();
66
(*al_onOff)[
"version"
].setValue(0U);
67
blobOnOff.resize(onlHashMax*
sizeof
(uint32_t));
68
69
spec_onOff->release();
70
// cppcheck-suppress memleak
71
spec_onOff =
nullptr
;
72
73
coral::AttributeListSpecification* spec_calib =
new
coral::AttributeListSpecification();
74
spec_calib->extend(
"OnlineHashToCalibIds"
,
"blob"
);
75
spec_calib->extend<
unsigned
>(
"version"
);
76
AthenaAttributeList
* al_calib =
new
AthenaAttributeList
(*spec_calib);
77
coral::Blob& blobCalib=(*al_calib)[
"OnlineHashToCalibIds"
].data<coral::Blob>();
78
(*al_calib)[
"version"
].setValue(0U);
79
blobCalib.resize(onlHashMax*
sizeof
(uint32_t)*3);
//Bigger than necessary
80
81
spec_calib->release();
82
// cppcheck-suppress memleak
83
spec_calib =
nullptr
;
84
85
uint32_t* pBlobOnOff=
static_cast<
uint32_t*
>
(blobOnOff.startingAddress());
86
uint32_t* pBlobCalib=
static_cast<
uint32_t*
>
(blobCalib.startingAddress());
87
88
size_t
index
=0;
89
size_t
calibIndex=0;
90
91
std::vector<unsigned> calibHist(5,0);
92
93
std::ofstream outfile(
"identifiers.txt"
);
94
95
outfile <<
"hash id bec pn FT SL chan id calo pn sampl reg eta phi calib"
<< std::endl;
96
97
for
(uint32_t onlHash=0;onlHash<onlHashMax;++onlHash) {
98
const
HWIdentifier
hwid=
m_onlineID
->channel_Id(onlHash);
99
print
(hwid,outfile);
100
const
Identifier
id
=cabling->cnvToIdentifierFromHash(onlHash);
101
pBlobOnOff[
index
++]=
id
.get_identifier32().get_compact();
102
103
const
std::vector<HWIdentifier>& calibIDs=clCont->
calibSlotLine
(hwid);
104
const
size_t
nCalibLines=calibIDs.size();
105
(calibHist[nCalibLines])++;
106
pBlobCalib[calibIndex++]=nCalibLines;
107
for
(uint32_t iCalib=0;iCalib<nCalibLines;++iCalib)
108
pBlobCalib[calibIndex++]=calibIDs[iCalib].get_identifier32().get_compact();
109
}
110
111
blobCalib.resize(calibIndex*
sizeof
(uint32_t));
//Size down to actual size
112
113
114
outfile.close();
115
116
ATH_MSG_INFO
(
"BlobSize OnOffId:"
<<
index
);
117
ATH_MSG_INFO
(
"BlobSize CalibId:"
<< calibIndex);
118
msg
(MSG::INFO) <<
"nCalib[i] "
;
119
for
(
unsigned
j=0;j<5;++j)
120
msg
() << calibHist[j] <<
"/"
;
121
msg
() <<
endmsg
;
122
123
ATH_CHECK
(
detStore
()->record(al_onOff,
"/LAR/Identifier/OnOffIdMap"
));
124
125
ATH_CHECK
(
detStore
()->record(al_calib,
"/LAR/Identifier/CalibIdMap"
));
126
127
return
StatusCode::SUCCESS;
128
}
129
130
131
void
LArIdMapConvert::print
(
const
HWIdentifier
& hwid, std::ostream& out) {
132
const
IdentifierHash
hwid_hash=
m_onlineID
->channel_Hash(hwid);
133
SG::ReadCondHandle<LArOnOffIdMapping>
cablingHdl{
m_cablingKey
};
134
const
LArOnOffIdMapping
* cabling{*cablingHdl};
135
if
(!cabling) {
136
ATH_MSG_ERROR
(
"Do not have cabling mapping from key "
<<
m_cablingKey
.key() );
137
return
;
138
}
139
SG::ReadCondHandle<LArCalibLineMapping>
clHdl{
m_CLKey
};
140
const
LArCalibLineMapping
*clCont {*clHdl};
141
if
(!clCont) {
142
ATH_MSG_ERROR
(
"Do not have calib line mapping !!!"
);
143
return
;
144
}
145
out << hwid_hash <<
" "
<< std::hex <<
"0x"
<< hwid.
get_identifier32
().
get_compact
() << std::dec <<
" "
146
<<
m_onlineID
->barrel_ec(hwid) <<
" "
147
<<
m_onlineID
->pos_neg(hwid) <<
" "
148
<<
m_onlineID
->feedthrough(hwid) <<
" "
149
<<
m_onlineID
->slot(hwid) <<
" "
150
<<
m_onlineID
->channel(hwid) <<
" : "
;
151
if
(cabling->isOnlineConnected(hwid)) {
152
const
Identifier
id
=cabling->cnvToIdentifier(hwid);
153
out << std::hex <<
"0x"
<<
id
.get_identifier32().get_compact() << std::dec <<
" "
154
<<
m_caloCellID
->sub_calo(
id
) <<
" "
155
<<
m_caloCellID
->pos_neg(
id
) <<
" "
156
<<
m_caloCellID
->sampling(
id
) <<
" "
157
<<
m_caloCellID
->region(
id
) <<
" "
158
<<
m_caloCellID
->eta(
id
) <<
" "
159
<<
m_caloCellID
->phi(
id
) <<
" "
;
160
}
161
else
162
out <<
" disconnected "
;
163
164
const
std::vector<HWIdentifier>& calibIDs=clCont->
calibSlotLine
(hwid);
165
for
(
size_t
i=0;i<calibIDs.size();++i) {
166
out << std::hex <<
"0x"
<< calibIDs[i].get_identifier32().get_compact() <<
" "
;
167
}
168
out << std::dec << std::endl;
169
}
170
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:61
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
AthenaAttributeList.h
LArIdMapConvert.h
LArOnlineID.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table.
Definition
PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:46
HWIdentifier
Definition
HWIdentifier.h:13
Identifier32::get_compact
value_type get_compact() const
Get the compact id.
Definition
Identifier32.h:47
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
Identifier::get_identifier32
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
LArCalibLineMapping
Definition
LArCalibLineMapping.h:17
LArCalibLineMapping::calibSlotLine
const std::vector< HWIdentifier > & calibSlotLine(const HWIdentifier id) const
Definition
LArCalibLineMapping.cxx:15
LArIdMapConvert::finalize
virtual StatusCode finalize() override
Definition
LArIdMapConvert.cxx:37
LArIdMapConvert::execute
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
LArIdMapConvert.cxx:44
LArIdMapConvert::initialize
virtual StatusCode initialize() override
Definition
LArIdMapConvert.cxx:26
LArIdMapConvert::m_CLKey
SG::ReadCondHandleKey< LArCalibLineMapping > m_CLKey
Definition
LArIdMapConvert.h:43
LArIdMapConvert::LArIdMapConvert
LArIdMapConvert()
Default constructor:
LArIdMapConvert::m_caloCellID
const CaloCell_ID * m_caloCellID
Definition
LArIdMapConvert.h:50
LArIdMapConvert::m_onlineID
const LArOnlineID * m_onlineID
Definition
LArIdMapConvert.h:49
LArIdMapConvert::print
void print(const HWIdentifier &hwid, std::ostream &out=std::cout)
Definition
LArIdMapConvert.cxx:131
LArIdMapConvert::~LArIdMapConvert
virtual ~LArIdMapConvert()
Destructor:
Definition
LArIdMapConvert.cxx:22
LArIdMapConvert::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition
LArIdMapConvert.h:42
LArOnOffIdMapping
Definition
LArOnOffIdMapping.h:20
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
Identifier
Definition
IdentifierFieldParser.cxx:14
index
Definition
index.py:1
Generated on
for ATLAS Offline Software by
1.17.0