ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArRecUtils
src
LArLATOMEMappingAlg.cxx
Go to the documentation of this file.
1
//dear emacs, this is -*-c++-*-
2
3
/*
4
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
#include "
LArLATOMEMappingAlg.h
"
8
#include "
AthenaPoolUtilities/AthenaAttributeList.h
"
9
#include "CoralBase/Blob.h"
10
#include "CoralBase/AttributeList.h"
11
12
#include "
CaloIdentifier/CaloCell_SuperCell_ID.h
"
13
#include "
LArIdentifier/LArOnline_SuperCellID.h
"
14
15
StatusCode
LArLATOMEMappingAlg::initialize
() {
16
17
ATH_MSG_DEBUG
(
"initializing"
);
18
19
// Read Handles
20
ATH_CHECK
(
m_readKey
.initialize() );
21
ATH_CHECK
(
m_writeKey
.initialize() );
22
23
return
StatusCode::SUCCESS;
24
}
25
26
27
StatusCode
LArLATOMEMappingAlg::execute
(
const
EventContext& ctx)
const
{
28
ATH_MSG_DEBUG
(
"executing"
);
29
30
SG::WriteCondHandle<LArLATOMEMapping>
writeHandle{
m_writeKey
, ctx};
31
32
if
(writeHandle.
isValid
()) {
33
ATH_MSG_DEBUG
(
"Found valid write handle"
);
34
return
StatusCode::SUCCESS;
35
}
36
37
SG::ReadCondHandle<CondAttrListCollection>
readHandle{
m_readKey
, ctx};
38
const
CondAttrListCollection
* catr{*readHandle};
39
40
if
(catr==
nullptr
) {
41
ATH_MSG_ERROR
(
"Failed to retrieve CondAttrListCollection with key "
<<
m_readKey
.key());
42
return
StatusCode::FAILURE;
43
}
44
45
46
writeHandle.
addDependency
(readHandle);
47
48
//Loop over COOL channels:
49
CondAttrListCollection::const_iterator
chanIt=catr->
begin
();
50
CondAttrListCollection::const_iterator
chanIt_e=catr->
end
();
51
// needs a length of blobs first
52
const
coral::Blob& bls = chanIt->second[
"SourceIDs"
].data<coral::Blob>();
53
unsigned
nLat=bls.size()/
sizeof
(uint32_t);
54
std::unique_ptr<LArLATOMEMapping> latomeMap=std::make_unique<LArLATOMEMapping>(nLat);
55
56
for
(;chanIt!=chanIt_e;++chanIt) {
57
58
const
coral::AttributeList& attr = chanIt->second;
59
const
coral::Blob& blobsourceId=attr[
"SourceIDs"
].data<coral::Blob>();
60
unsigned
nLatome=blobsourceId.size()/
sizeof
(uint32_t);
61
const
coral::Blob& blobonlineId=attr[
"OnlineIDs"
].data<coral::Blob>();
62
unsigned
nChan=blobonlineId.size()/blobsourceId.size();
63
const
uint32_t* pblobsourceId=
static_cast<
const
uint32_t*
>
(blobsourceId.startingAddress());
64
const
uint32_t* pblobonlineId=
static_cast<
const
uint32_t*
>
(blobonlineId.startingAddress());
65
66
if
(nChan!=
N_LATOME_CHANNELS
) {
67
ATH_MSG_ERROR
(
"Number of channels read from DB ("
<< nChan <<
") does not match expected "
68
<<
N_LATOME_CHANNELS
<<
")"
);
69
return
StatusCode::FAILURE;
70
}
71
72
for
(
unsigned
i=0;i<nLatome;++i) {
73
const
unsigned
sid=pblobsourceId[i];
74
ATH_MSG_DEBUG
(
"Latome SID: "
<<sid);
75
std::pair<unsigned, std::vector<HWIdentifier> > entry{sid,{}};
76
entry.second.reserve(
N_LATOME_CHANNELS
);
77
for
(
unsigned
j=0;j<
N_LATOME_CHANNELS
;++j) {
78
const
HWIdentifier
hwid=
HWIdentifier
(
Identifier32
(pblobonlineId[i*
N_LATOME_CHANNELS
+ j]));
79
if
(hwid.
is_valid
() && hwid != 0) {
80
entry.second.push_back(hwid);
81
}
else
{
82
entry.second.push_back(latomeMap->m_hwidEmpty);
83
}
84
}
85
latomeMap->m_map.insert(std::move(entry));
86
}
//end loop over LATOME sourceIDs
87
ATH_MSG_INFO
(
"Done reading latome mapping"
);
88
ATH_MSG_INFO
(
"Found "
<< nLatome <<
" LATOMEs "
);
89
}
// end over cool channels
90
91
if
(writeHandle.
record
(std::move(latomeMap)).isFailure()) {
92
ATH_MSG_ERROR
(
"Could not record LArLATOMEMapping object with "
93
<< writeHandle.
key
()
94
<<
" with EventRange "
<< writeHandle.
getRange
()
95
<<
" into Conditions Store"
);
96
return
StatusCode::FAILURE;
97
}
98
ATH_MSG_INFO
(
"recorded new "
<< writeHandle.
key
() <<
" with range "
<< writeHandle.
getRange
() <<
" into Conditions Store"
);
99
100
return
StatusCode::SUCCESS;
101
}
102
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
AthenaAttributeList.h
CaloCell_SuperCell_ID.h
Helper class for offline supercell identifiers.
LArLATOMEMappingAlg.h
N_LATOME_CHANNELS
#define N_LATOME_CHANNELS
fixed number of channels on one LATOME board
Definition
LArLATOMEMapping.h:22
LArOnline_SuperCellID.h
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number.
Definition
CondAttrListCollection.h:51
CondAttrListCollection::end
const_iterator end() const
Definition
CondAttrListCollection.h:314
CondAttrListCollection::begin
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
Definition
CondAttrListCollection.h:308
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition
CondAttrListCollection.h:62
HWIdentifier
Definition
HWIdentifier.h:13
Identifier32
Definition
Identifier32.h:28
Identifier::is_valid
bool is_valid() const
Check if id is in a valid state.
LArLATOMEMappingAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
LArLATOMEMappingAlg.cxx:27
LArLATOMEMappingAlg::m_writeKey
SG::WriteCondHandleKey< LArLATOMEMapping > m_writeKey
Definition
LArLATOMEMappingAlg.h:35
LArLATOMEMappingAlg::initialize
virtual StatusCode initialize() override
Definition
LArLATOMEMappingAlg.cxx:15
LArLATOMEMappingAlg::m_readKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
Definition
LArLATOMEMappingAlg.h:34
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::WriteCondHandle
Definition
WriteCondHandle.h:26
SG::WriteCondHandle::key
const std::string & key() const
Definition
WriteCondHandle.h:44
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition
WriteCondHandle.h:279
SG::WriteCondHandle::getRange
const EventIDRange & getRange() const
Definition
WriteCondHandle.h:93
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition
WriteCondHandle.h:161
SG::WriteCondHandle::isValid
bool isValid() const
Definition
WriteCondHandle.h:252
Generated on
for ATLAS Offline Software by
1.17.0