ATLAS Offline Software
Loading...
Searching...
No Matches
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
9
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
23StatusCode CaloCellPedCorrCondAlg::execute(const EventContext& ctx) const {
24
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) {
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
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
const ServiceHandle< StoreGateSvc > & detStore() const
StatusCode initialize() override final
SG::ReadCondHandleKey< CondAttrListCollection > m_pedShiftFolder
ToolHandle< ICaloCoolIdTool > m_caloCoolIdTool
SG::WriteCondHandleKey< CaloCellPedShift > m_pedShiftKey
SG::ReadCondHandleKey< CondAttrListCollection > m_lumiFolderName
Gaudi::Property< float > m_lumi0
StatusCode execute(const EventContext &ctx) const override final
static CaloCondBlobFlt * getInstance(coral::Blob &blob)
Returns a pointer to a non-const CaloCondBlobFlt.
This class is a collection of AttributeLists where each one is associated with a channel number.
const AttributeList & attributeList(ChanNum chanNum) const
attribute list for a given channel number
size_type size() const
number of Chan/AttributeList pairs
const std::string & key() const
void addDependency(const EventIDRange &range)
const EventIDRange & getRange() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED