ATLAS Offline Software
Loading...
Searching...
No Matches
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
19 ATH_CHECK( m_readKey.initialize() );
20 ATH_CHECK( m_writeKey.initialize() );
21
22 return StatusCode::SUCCESS;
23}
24
25
26StatusCode LArCalibLineMappingAlg::execute(const EventContext& ctx) const {
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
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
const ServiceHandle< StoreGateSvc > & detStore() const
An AttributeList represents a logical row of attributes in a metadata table.
Gaudi::Property< unsigned > m_maxCalibLines
virtual StatusCode initialize() override
SG::WriteCondHandleKey< LArCalibLineMapping > m_writeKey
Gaudi::Property< bool > m_isSuperCell
virtual StatusCode execute(const EventContext &ctx) const override
SG::ReadCondHandleKey< AthenaAttributeList > m_readKey
Helper for the Liquid Argon Calorimeter cell identifiers.
size_type channelHashMax() const
Define channel hash tables max size.
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