ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloCellCorrection
src
CaloCellPedCorrCondAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
CaloCellPedCorrCondAlg.h
"
6
#include "
CaloCondBlobObjs/CaloCondBlobFlt.h
"
7
#include "
CaloCondBlobObjs/CaloCondUtils.h
"
8
#include "
CaloIdentifier/CaloCell_ID.h
"
9
10
StatusCode
CaloCellPedCorrCondAlg::initialize
() {
11
12
ATH_CHECK
(
detStore
()->retrieve(
m_cellId
,
"CaloCell_ID"
));
13
14
ATH_CHECK
(
m_pedShiftFolder
.initialize());
15
ATH_CHECK
(
m_lumiFolderName
.initialize(
m_lumi0
<0));
16
ATH_CHECK
(
m_pedShiftKey
.initialize());
17
18
return
StatusCode::SUCCESS;
19
}
20
21
22
23
StatusCode
CaloCellPedCorrCondAlg::execute
(
const
EventContext& ctx)
const
{
24
25
SG::WriteCondHandle<CaloCellPedShift>
writeHandle{
m_pedShiftKey
,ctx};
26
27
if
(writeHandle.
isValid
()) {
28
ATH_MSG_DEBUG
(
"Found valid write handle"
);
29
return
StatusCode::SUCCESS;
30
}
31
32
33
//Output object
34
std::unique_ptr<CaloCellPedShift> pedShift=std::make_unique<CaloCellPedShift>(
m_cellId
);
35
36
float
lumi=
m_lumi0
;
37
// Get Luminosity estimate
38
if
(lumi<0) {
39
SG::ReadCondHandle<CondAttrListCollection>
lumiHdl(
m_lumiFolderName
,ctx);
40
writeHandle.
addDependency
(lumiHdl);
41
const
CondAttrListCollection
* attrListColl=(*lumiHdl);
42
if
(attrListColl->
size
() == 0) {
43
lumi = 0;
44
}
45
else
{
46
const
coral::AttributeList& attrList=attrListColl->
attributeList
(0);
//Get channel number 0
47
if
(attrList[
"LBAvInstLumi"
].isNull()) {
48
ATH_MSG_WARNING
(
"No valid luminosity information in folder "
<<
m_lumiFolderName
.key() <<
", attribute LBAvInstLumi"
);
49
lumi=0;
50
}
51
else
{
52
lumi=attrList[
"LBAvInstLumi"
].data<
float
>() *1e-3;
// luminosity (from 10**30 units in db to 10*33 units)
53
}
54
}
55
}
//end if lumi<0
56
57
58
SG::ReadCondHandle<CondAttrListCollection>
pedShiftHdl(
m_pedShiftFolder
,ctx);
59
writeHandle.
addDependency
(pedShiftHdl);
60
const
CondAttrListCollection
* pedShiftColl{*pedShiftHdl};
61
62
const
size_t
maxCells=
m_cellId
->calo_cell_hash_max();
63
64
std::pair<unsigned,std::unique_ptr<const CaloCondBlobFlt> >blobCache{999999,
nullptr
};
65
//Loop over the CaloCellHash range
66
for
(
size_t
iCell=0;iCell<maxCells;++iCell) {
67
unsigned
int
subHash;
68
const
unsigned
int
iCool =
m_caloCoolIdTool
->getCoolChannelId(iCell,subHash);
69
if
(iCool!=blobCache.first) {
70
const
coral::AttributeList& attrList=pedShiftColl->
attributeList
(iCool);
71
const
coral::Blob& blob = attrList[
"CaloCondBlob16M"
].data<coral::Blob>();
72
blobCache.first=iCool;
73
blobCache.second.reset(
CaloCondBlobFlt::getInstance
(blob));
74
}
75
const
size_t
maxGain=
m_cellId
->is_tile(iCell) ? 4 : 3;
76
for
(
size_t
iGain=0;iGain<maxGain;++iGain) {
77
const
float
value = blobCache.second->getCalib(subHash, iGain, lumi);
78
pedShift->setPedShift(iCell,iGain,value);
79
}
//end loop over gains
80
}
//end loop over cells
81
82
if
(writeHandle.
record
(std::move(pedShift)).isFailure()) {
83
ATH_MSG_ERROR
(
"Could not record CaloCellPedShift object with "
84
<< writeHandle.
key
()
85
<<
" with EventRange "
<< writeHandle.
getRange
()
86
<<
" into Conditions Store"
);
87
return
StatusCode::FAILURE;
88
}
89
ATH_MSG_INFO
(
"recorded new "
<< writeHandle.
key
() <<
" with range "
<< writeHandle.
getRange
() <<
" into Conditions Store"
);
90
91
return
StatusCode::SUCCESS;
92
}
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_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CaloCellPedCorrCondAlg.h
CaloCell_ID.h
CaloCondBlobFlt.h
CaloCondUtils.h
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
CaloCellPedCorrCondAlg::initialize
StatusCode initialize() override final
Definition
CaloCellPedCorrCondAlg.cxx:10
CaloCellPedCorrCondAlg::m_pedShiftFolder
SG::ReadCondHandleKey< CondAttrListCollection > m_pedShiftFolder
Definition
CaloCellPedCorrCondAlg.h:29
CaloCellPedCorrCondAlg::m_caloCoolIdTool
ToolHandle< ICaloCoolIdTool > m_caloCoolIdTool
Definition
CaloCellPedCorrCondAlg.h:33
CaloCellPedCorrCondAlg::m_pedShiftKey
SG::WriteCondHandleKey< CaloCellPedShift > m_pedShiftKey
Definition
CaloCellPedCorrCondAlg.h:31
CaloCellPedCorrCondAlg::m_cellId
const CaloCell_ID * m_cellId
Definition
CaloCellPedCorrCondAlg.h:37
CaloCellPedCorrCondAlg::m_lumiFolderName
SG::ReadCondHandleKey< CondAttrListCollection > m_lumiFolderName
Definition
CaloCellPedCorrCondAlg.h:30
CaloCellPedCorrCondAlg::m_lumi0
Gaudi::Property< float > m_lumi0
Definition
CaloCellPedCorrCondAlg.h:35
CaloCellPedCorrCondAlg::execute
StatusCode execute(const EventContext &ctx) const override final
Definition
CaloCellPedCorrCondAlg.cxx:23
CaloCondBlobFlt::getInstance
static CaloCondBlobFlt * getInstance(coral::Blob &blob)
Returns a pointer to a non-const CaloCondBlobFlt.
Definition
CaloCondBlobFlt.cxx:12
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number.
Definition
CondAttrListCollection.h:51
CondAttrListCollection::attributeList
const AttributeList & attributeList(ChanNum chanNum) const
attribute list for a given channel number
Definition
CondAttrListCollection.h:400
CondAttrListCollection::size
size_type size() const
number of Chan/AttributeList pairs
Definition
CondAttrListCollection.h:321
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