ATLAS Offline Software
LArCalibLineMappingAlg.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 
9 #include "CoralBase/Blob.h"
10 
13 
14 
16  ATH_MSG_DEBUG("initializing");
17 
18  // Read Handles
21 
22  return StatusCode::SUCCESS;
23 }
24 
25 
27  ATH_MSG_DEBUG("executing");
28 
30 
31  if (writeHandle.isValid()) {
32  ATH_MSG_DEBUG("Found valid write handle");
33  return StatusCode::SUCCESS;
34  }
35 
37  const AthenaAttributeList* attr{*readHandle};
38 
39  if (attr==nullptr) {
40  ATH_MSG_ERROR("Failed to retrieve CondAttributeListCollection with key " << m_readKey.key());
41  return StatusCode::FAILURE;
42  }
43  writeHandle.addDependency(readHandle);
44 
45  const LArOnlineID_Base* onlineID;
46  if(m_isSuperCell) {
47  const LArOnline_SuperCellID* scidhelper;
48  ATH_CHECK(detStore()->retrieve(scidhelper,"LArOnline_SuperCellID"));
49  onlineID=scidhelper; //cast to base-class
50  } else {
51  const LArOnlineID* idhelper;
52  ATH_CHECK(detStore()->retrieve(idhelper,"LArOnlineID"));
53  onlineID=idhelper; //cast to base-class
54  }
55 
56  std::unique_ptr<LArCalibLineMapping> calibLineMap=std::make_unique<LArCalibLineMapping>(onlineID);
57 
58  std::vector<std::vector<HWIdentifier> >&onlHashToCalibLines=calibLineMap->m_onlHashToCalibLines; //basically a shorthand
59 
60  //The following lines are copied from the callback method of the old-style LArCablingService.cxx
61  const coral::Blob& blobCalib=(*attr)["OnlineHashToCalibIds"].data<coral::Blob>();
62  const unsigned nEntries=blobCalib.size()/sizeof(uint32_t);
63  const uint32_t* pBlobCalib=static_cast<const uint32_t*>(blobCalib.startingAddress());
64 
65  const unsigned chanMax=onlineID->channelHashMax();
66 
67  onlHashToCalibLines.resize(chanMax);
68 
69  unsigned blobIdx=0;
70  unsigned chanIdx=0;
71  unsigned totCalibLines=0;
72  for (;blobIdx<nEntries && chanIdx<chanMax;++chanIdx) {
73  const unsigned nCalibLines=pBlobCalib[blobIdx++];
74  totCalibLines+=nCalibLines;
75  if (nCalibLines>m_maxCalibLines) {
76  msg(MSG::ERROR) << "Found unresonable large number of calib lines (" << nCalibLines << ") for channel hash " << chanIdx << endmsg;
77  return StatusCode::FAILURE;
78  }
79  onlHashToCalibLines[chanIdx].clear();
80  for (unsigned i=0;i<nCalibLines && blobIdx<nEntries;++i) {
81  onlHashToCalibLines[chanIdx].emplace_back(pBlobCalib[blobIdx++]);
82  }//End loop over calib-lines
83  }//end loop over channels
84  msg() << MSG::INFO << "Done reading readout/calibration line mapping." << endmsg;
85  ATH_MSG_DEBUG("BlobIdx=" << blobIdx<<", chanIdx=" << chanIdx << ", totCalibLines=" << totCalibLines);
86 
87 
88  if(writeHandle.record(std::move(calibLineMap)).isFailure()) {
89  ATH_MSG_ERROR("Could not record LArCalibLineMapping object with "
90  << writeHandle.key()
91  << " with EventRange " << writeHandle.getRange()
92  << " into Conditions Store");
93  return StatusCode::FAILURE;
94  }
95  ATH_MSG_INFO("recorded new " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
96 
97  return StatusCode::SUCCESS;
98 }
99 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArCalibLineMapping::m_onlHashToCalibLines
std::vector< std::vector< HWIdentifier > > m_onlHashToCalibLines
Definition: LArCalibLineMapping.h:29
LArCalibLineMappingAlg::initialize
virtual StatusCode initialize() override
Definition: LArCalibLineMappingAlg.cxx:15
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArCalibLineMappingAlg::m_readKey
SG::ReadCondHandleKey< AthenaAttributeList > m_readKey
Definition: LArCalibLineMappingAlg.h:29
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
AthenaAttributeList.h
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
LArCalibLineMappingAlg::m_writeKey
SG::WriteCondHandleKey< LArCalibLineMapping > m_writeKey
Definition: LArCalibLineMappingAlg.h:30
LArCalibLineMappingAlg::m_maxCalibLines
Gaudi::Property< unsigned > m_maxCalibLines
Definition: LArCalibLineMappingAlg.h:32
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
Definition: PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:45
LArOnlineID_Base
Helper for the Liquid Argon Calorimeter cell identifiers.
Definition: LArOnlineID_Base.h:105
LArOnlineID_Base::channelHashMax
size_type channelHashMax(void) const
Define channel hash tables max size.
Definition: LArOnlineID_Base.cxx:1897
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArOnlineID
Definition: LArOnlineID.h:20
LArOnline_SuperCellID
Definition: LArOnline_SuperCellID.h:20
LArCalibLineMappingAlg::execute
virtual StatusCode execute() override
Definition: LArCalibLineMappingAlg.cxx:26
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
LArOnline_SuperCellID.h
LArCalibLineMappingAlg::m_isSuperCell
Gaudi::Property< bool > m_isSuperCell
Definition: LArCalibLineMappingAlg.h:31
LArCalibLineMappingAlg.h
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
LArOnlineID.h