ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArRecUtils
src
LArOnOffMappingAlg.cxx
Go to the documentation of this file.
1
//dear emacs, this is -*-c++-*-
2
3
/*
4
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
#include "
LArOnOffMappingAlg.h
"
8
#include "
AthenaPoolUtilities/AthenaAttributeList.h
"
9
#include "CoralBase/Blob.h"
10
11
#include "
CaloIdentifier/CaloCell_ID.h
"
12
#include "
CaloIdentifier/CaloCell_SuperCell_ID.h
"
13
#include "
LArIdentifier/LArOnlineID.h
"
14
#include "
LArIdentifier/LArOnline_SuperCellID.h
"
15
16
17
StatusCode
LArOnOffMappingAlg::initialize
() {
18
19
ATH_MSG_DEBUG
(
"initializing"
);
20
21
// Read Handles
22
ATH_CHECK
(
m_readKey
.initialize() );
23
ATH_CHECK
(
m_writeKey
.initialize() );
24
25
return
StatusCode::SUCCESS;
26
}
27
28
29
StatusCode
LArOnOffMappingAlg::execute
(
const
EventContext& ctx)
const
{
30
ATH_MSG_DEBUG
(
"executing"
);
31
32
SG::WriteCondHandle<LArOnOffIdMapping>
writeHandle{
m_writeKey
, ctx};
33
34
if
(writeHandle.
isValid
()) {
35
ATH_MSG_DEBUG
(
"Found valid write handle"
);
36
return
StatusCode::SUCCESS;
37
}
38
39
SG::ReadCondHandle<AthenaAttributeList>
readHandle{
m_readKey
, ctx};
40
const
AthenaAttributeList
* attr{*readHandle};
41
42
if
(attr==
nullptr
) {
43
ATH_MSG_ERROR
(
"Failed to retrieve CondAttributeListCollection with key "
<<
m_readKey
.key());
44
return
StatusCode::FAILURE;
45
}
46
47
writeHandle.
addDependency
(readHandle);
48
49
const
LArOnlineID_Base
* larOnlineID=
nullptr
;
50
const
CaloCell_Base_ID
* calocellID=
nullptr
;
51
52
//Identifier helper:
53
if
(
m_isSuperCell
) {
54
const
LArOnline_SuperCellID
* scidhelper =
nullptr
;
55
ATH_CHECK
(
detStore
()->retrieve(scidhelper,
"LArOnline_SuperCellID"
));
56
larOnlineID=scidhelper;
//cast to base-class
57
58
const
CaloCell_SuperCell_ID
* sccaloid =
nullptr
;
59
ATH_CHECK
(
detStore
()->retrieve(sccaloid,
"CaloCell_SuperCell_ID"
));
60
calocellID=sccaloid;
//cast to base-class
61
62
}
63
else
{
//regular cells
64
const
LArOnlineID
* idhelper =
nullptr
;
65
ATH_CHECK
(
detStore
()->retrieve(idhelper,
"LArOnlineID"
));
66
larOnlineID=idhelper;
//cast to base-class
67
68
const
CaloCell_ID
* sccaloid =
nullptr
;
69
ATH_CHECK
(
detStore
()->retrieve(sccaloid,
"CaloCell_ID"
));
70
calocellID=sccaloid;
//cast to base-class
71
72
}
73
74
75
std::unique_ptr<LArOnOffIdMapping> onOffMap=std::make_unique<LArOnOffIdMapping>(larOnlineID,calocellID);
76
77
const
coral::Blob& blobOnOff=(*attr)[
"OnlineHashToOfflineId"
].data<coral::Blob>();
78
unsigned
nChan=blobOnOff.size()/
sizeof
(uint32_t);
79
const
uint32_t* pBlobOnOff=
static_cast<
const
uint32_t*
>
(blobOnOff.startingAddress());
80
81
if
(nChan!=larOnlineID->
channelHashMax
()) {
82
ATH_MSG_ERROR
(
"Number of channels read from DB ("
<< nChan <<
") does not match online hash max ("
83
<<larOnlineID->
channelHashMax
() <<
")"
);
84
return
StatusCode::FAILURE;
85
}
86
87
88
unsigned
nConnected=0;
89
90
for
(
unsigned
i=0;i<nChan;++i) {
91
const
Identifier
id
=
Identifier
(
Identifier32
(pBlobOnOff[i]));
92
if
(
id
.is_valid()) {
93
const
IdentifierHash
oflHash=calocellID->
calo_cell_hash
(
id
);
94
const
HWIdentifier
hwid=larOnlineID->
channel_Id
(
IdentifierHash
(i));
95
++nConnected;
96
onOffMap->m_onlHashToOffline[i]=id;
97
onOffMap->m_oflHashToOnline[oflHash]=hwid;
98
onOffMap->m_onlHashToOflHash[i]=oflHash;
99
}
100
}
//end loop over channels
101
102
ATH_MSG_INFO
(
"Done reading online/offline identifier mapping"
);
103
ATH_MSG_INFO
(
"Found "
<< nChan <<
" online identifier and "
<< nConnected <<
" offline identifier. "
104
<< nChan-nConnected <<
" disconnected channels."
);
105
106
if
(writeHandle.
record
(std::move(onOffMap)).isFailure()) {
107
ATH_MSG_ERROR
(
"Could not record LArOnOffMapping object with "
108
<< writeHandle.
key
()
109
<<
" with EventRange "
<< writeHandle.
getRange
()
110
<<
" into Conditions Store"
);
111
return
StatusCode::FAILURE;
112
}
113
ATH_MSG_INFO
(
"recorded new "
<< writeHandle.
key
() <<
" with range "
<< writeHandle.
getRange
() <<
" into Conditions Store"
);
114
115
return
StatusCode::SUCCESS;
116
}
117
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_ID.h
CaloCell_SuperCell_ID.h
Helper class for offline supercell identifiers.
LArOnOffMappingAlg.h
LArOnlineID.h
LArOnline_SuperCellID.h
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table.
Definition
PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:46
CaloCell_Base_ID
Helper base class for offline cell identifiers.
Definition
CaloCell_Base_ID.h:40
CaloCell_Base_ID::calo_cell_hash
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
CaloCell_ID
Helper class for offline cell identifiers.
Definition
CaloCell_ID.h:34
CaloCell_SuperCell_ID
Helper class for offline supercell identifiers.
Definition
CaloCell_SuperCell_ID.h:45
HWIdentifier
Definition
HWIdentifier.h:13
Identifier32
Definition
Identifier32.h:28
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
LArOnOffMappingAlg::initialize
virtual StatusCode initialize() override
Definition
LArOnOffMappingAlg.cxx:17
LArOnOffMappingAlg::m_isSuperCell
Gaudi::Property< bool > m_isSuperCell
Definition
LArOnOffMappingAlg.h:33
LArOnOffMappingAlg::m_readKey
SG::ReadCondHandleKey< AthenaAttributeList > m_readKey
Definition
LArOnOffMappingAlg.h:31
LArOnOffMappingAlg::m_writeKey
SG::WriteCondHandleKey< LArOnOffIdMapping > m_writeKey
Definition
LArOnOffMappingAlg.h:32
LArOnOffMappingAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
LArOnOffMappingAlg.cxx:29
LArOnlineID_Base
Helper for the Liquid Argon Calorimeter cell identifiers.
Definition
LArOnlineID_Base.h:97
LArOnlineID_Base::channel_Id
HWIdentifier channel_Id(int barrel_ec, int pos_neg, int feedthrough, int slot, int channel) const
create channel identifier from fields
Definition
LArOnlineID_Base.cxx:1275
LArOnlineID_Base::channelHashMax
size_type channelHashMax() const
Define channel hash tables max size.
Definition
LArOnlineID_Base.cxx:1607
LArOnlineID
Definition
LArOnlineID.h:21
LArOnline_SuperCellID
Definition
LArOnline_SuperCellID.h:21
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
Identifier
Definition
IdentifierFieldParser.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0