ATLAS Offline Software
Loading...
Searching...
No Matches
LArLATOMEMappingAlg.cxx
Go to the documentation of this file.
1//dear emacs, this is -*-c++-*-
2
3/*
4 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5*/
6
9#include "CoralBase/Blob.h"
10#include "CoralBase/AttributeList.h"
11
14
16
17 ATH_MSG_DEBUG("initializing");
18
19 // Read Handles
20 ATH_CHECK( m_readKey.initialize() );
21 ATH_CHECK( m_writeKey.initialize() );
22
23 return StatusCode::SUCCESS;
24}
25
26
27StatusCode LArLATOMEMappingAlg::execute(const EventContext& ctx) const {
28 ATH_MSG_DEBUG("executing");
29
31
32 if (writeHandle.isValid()) {
33 ATH_MSG_DEBUG("Found valid write handle");
34 return StatusCode::SUCCESS;
35 }
36
38 const CondAttrListCollection * catr{*readHandle};
39
40 if (catr==nullptr) {
41 ATH_MSG_ERROR("Failed to retrieve CondAttrListCollection with key " << m_readKey.key());
42 return StatusCode::FAILURE;
43 }
44
45
46 writeHandle.addDependency(readHandle);
47
48 //Loop over COOL channels:
51 // needs a length of blobs first
52 const coral::Blob& bls = chanIt->second["SourceIDs"].data<coral::Blob>();
53 unsigned nLat=bls.size()/sizeof(uint32_t);
54 std::unique_ptr<LArLATOMEMapping> latomeMap=std::make_unique<LArLATOMEMapping>(nLat);
55
56 for (;chanIt!=chanIt_e;++chanIt) {
57
58 const coral::AttributeList& attr = chanIt->second;
59 const coral::Blob& blobsourceId=attr["SourceIDs"].data<coral::Blob>();
60 unsigned nLatome=blobsourceId.size()/sizeof(uint32_t);
61 const coral::Blob& blobonlineId=attr["OnlineIDs"].data<coral::Blob>();
62 unsigned nChan=blobonlineId.size()/blobsourceId.size();
63 const uint32_t* pblobsourceId=static_cast<const uint32_t*>(blobsourceId.startingAddress());
64 const uint32_t* pblobonlineId=static_cast<const uint32_t*>(blobonlineId.startingAddress());
65
66 if (nChan!=N_LATOME_CHANNELS) {
67 ATH_MSG_ERROR("Number of channels read from DB (" << nChan << ") does not match expected "
68 <<N_LATOME_CHANNELS << ")");
69 return StatusCode::FAILURE;
70 }
71
72 for (unsigned i=0;i<nLatome;++i) {
73 const unsigned sid=pblobsourceId[i];
74 ATH_MSG_DEBUG("Latome SID: "<<sid);
75 std::pair<unsigned, std::vector<HWIdentifier> > entry{sid,{}};
76 entry.second.reserve(N_LATOME_CHANNELS);
77 for (unsigned j=0;j<N_LATOME_CHANNELS ;++j) {
78 const HWIdentifier hwid=HWIdentifier(Identifier32(pblobonlineId[i*N_LATOME_CHANNELS + j]));
79 if (hwid.is_valid() && hwid != 0) {
80 entry.second.push_back(hwid);
81 } else {
82 entry.second.push_back(latomeMap->m_hwidEmpty);
83 }
84 }
85 latomeMap->m_map.insert(std::move(entry));
86 }//end loop over LATOME sourceIDs
87 ATH_MSG_INFO("Done reading latome mapping");
88 ATH_MSG_INFO("Found " << nLatome << " LATOMEs ");
89 } // end over cool channels
90
91 if(writeHandle.record(std::move(latomeMap)).isFailure()) {
92 ATH_MSG_ERROR("Could not record LArLATOMEMapping object with "
93 << writeHandle.key()
94 << " with EventRange " << writeHandle.getRange()
95 << " into Conditions Store");
96 return StatusCode::FAILURE;
97 }
98 ATH_MSG_INFO("recorded new " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
99
100 return StatusCode::SUCCESS;
101}
102
#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)
Helper class for offline supercell identifiers.
#define N_LATOME_CHANNELS
fixed number of channels on one LATOME board
This class is a collection of AttributeLists where each one is associated with a channel number.
const_iterator end() const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
ChanAttrListMap::const_iterator const_iterator
bool is_valid() const
Check if id is in a valid state.
virtual StatusCode execute(const EventContext &ctx) const override
SG::WriteCondHandleKey< LArLATOMEMapping > m_writeKey
virtual StatusCode initialize() override
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
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