ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCellPedCorrCondAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
8
10
11 ATH_CHECK(detStore()->retrieve(m_cellId, "CaloCell_ID"));
12
13 ATH_CHECK(m_pedShiftFolder.initialize());
14 ATH_CHECK(m_lumiFolderName.initialize(m_lumi0<0));
15 ATH_CHECK(m_pedShiftKey.initialize());
16
17 return StatusCode::SUCCESS;
18}
19
20
21
22StatusCode CaloCellPedCorrCondAlg::execute(const EventContext& ctx) const {
23
25
26 if (writeHandle.isValid()) {
27 ATH_MSG_DEBUG("Found valid write handle");
28 return StatusCode::SUCCESS;
29 }
30
31
32 //Output object
33 std::unique_ptr<CaloCellPedShift> pedShift=std::make_unique<CaloCellPedShift>(m_cellId);
34
35 float lumi=m_lumi0;
36 // Get Luminosity estimate
37 if (lumi<0) {
39 writeHandle.addDependency(lumiHdl);
40 const CondAttrListCollection* attrListColl=(*lumiHdl);
41 if (attrListColl->size() == 0) {
42 lumi = 0;
43 }
44 else {
45 const coral::AttributeList& attrList=attrListColl->attributeList(0); //Get channel number 0
46 if (attrList["LBAvInstLumi"].isNull()) {
47 ATH_MSG_WARNING("No valid luminosity information in folder " << m_lumiFolderName.key() << ", attribute LBAvInstLumi");
48 lumi=0;
49 }
50 else {
51 lumi=attrList["LBAvInstLumi"].data<float>() *1e-3; // luminosity (from 10**30 units in db to 10*33 units)
52 }
53 }
54 }//end if lumi<0
55
56
58 writeHandle.addDependency(pedShiftHdl);
59 const CondAttrListCollection* pedShiftColl{*pedShiftHdl};
60
61 const size_t maxCells=m_cellId->calo_cell_hash_max();
62
63 std::pair<unsigned,std::unique_ptr<const CaloCondBlobFlt> >blobCache{999999,nullptr};
64 //Loop over the CaloCellHash range
65 for (size_t iCell=0;iCell<maxCells;++iCell) {
66 unsigned int subHash;
67 const unsigned int iCool = m_caloCoolIdTool->getCoolChannelId(iCell,subHash);
68 if (iCool!=blobCache.first) {
69 const coral::AttributeList& attrList=pedShiftColl->attributeList(iCool);
70 const coral::Blob& blob = attrList["CaloCondBlob16M"].data<coral::Blob>();
71 blobCache.first=iCool;
72 blobCache.second.reset(CaloCondBlobFlt::getInstance(blob));
73 }
74 const size_t maxGain= m_cellId->is_tile(iCell) ? 4 : 3;
75 for (size_t iGain=0;iGain<maxGain;++iGain) {
76 const float value = blobCache.second->getCalib(subHash, iGain, lumi);
77 pedShift->setPedShift(iCell,iGain,value);
78 }//end loop over gains
79 } //end loop over cells
80
81 if(writeHandle.record(std::move(pedShift)).isFailure()) {
82 ATH_MSG_ERROR("Could not record CaloCellPedShift object with "
83 << writeHandle.key()
84 << " with EventRange " << writeHandle.getRange()
85 << " into Conditions Store");
86 return StatusCode::FAILURE;
87 }
88 ATH_MSG_INFO("recorded new " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
89
90 return StatusCode::SUCCESS;
91}
#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