ATLAS Offline Software
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 
16 
17  return StatusCode::SUCCESS;
18 }
19 
20 
21 
22 StatusCode 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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CaloCellPedCorrCondAlg::m_pedShiftFolder
SG::ReadCondHandleKey< CondAttrListCollection > m_pedShiftFolder
Definition: CaloCellPedCorrCondAlg.h:30
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloCellPedShift::setPedShift
void setPedShift(const IdentifierHash hash, const int gain, const float value)
Definition: CaloCellPedShift.cxx:21
CaloCellPedCorrCondAlg::m_caloCoolIdTool
ToolHandle< ICaloCoolIdTool > m_caloCoolIdTool
Definition: CaloCellPedCorrCondAlg.h:34
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
athena.value
value
Definition: athena.py:124
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
CaloCell_Base_ID::is_tile
bool is_tile(const Identifier id) const
test if the id belongs to the Tiles
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
CaloCondUtils.h
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
CaloCellPedCorrCondAlg::m_lumiFolderName
SG::ReadCondHandleKey< CondAttrListCollection > m_lumiFolderName
Definition: CaloCellPedCorrCondAlg.h:31
CaloCellPedCorrCondAlg::m_pedShiftKey
SG::WriteCondHandleKey< CaloCellPedShift > m_pedShiftKey
Definition: CaloCellPedCorrCondAlg.h:32
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CaloCellPedCorrCondAlg::m_lumi0
Gaudi::Property< float > m_lumi0
Definition: CaloCellPedCorrCondAlg.h:36
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CondAttrListCollection::attributeList
const AttributeList & attributeList(ChanNum chanNum) const
attribute list for a given channel number
Definition: CondAttrListCollection.h:401
CaloCellPedCorrCondAlg::execute
StatusCode execute(const EventContext &ctx) const override final
Definition: CaloCellPedCorrCondAlg.cxx:22
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloCellPedCorrCondAlg.h
CondAttrListCollection::size
size_type size() const
number of Chan/AttributeList pairs
Definition: CondAttrListCollection.h:322
CaloCondBlobFlt.h
lumiFormat.lumi
lumi
Definition: lumiFormat.py:106
CaloCellPedCorrCondAlg::m_cellId
const CaloCell_ID * m_cellId
Definition: CaloCellPedCorrCondAlg.h:38
CaloCondBlobFlt::getInstance
static CaloCondBlobFlt * getInstance(coral::Blob &blob)
Returns a pointer to a non-const CaloCondBlobFlt.
Definition: CaloCondBlobFlt.cxx:12
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CaloCellPedCorrCondAlg::initialize
StatusCode initialize() override final
Definition: CaloCellPedCorrCondAlg.cxx:9
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96
CaloCell_Base_ID::calo_cell_hash_max
size_type calo_cell_hash_max(void) const
cell 'global' hash table max size