ATLAS Offline Software
Loading...
Searching...
No Matches
LArIdMapConvert.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "LArIdMapConvert.h"
6
9#include "CoralBase/Blob.h"
10
11#include <fstream>
12
13LArIdMapConvert::LArIdMapConvert( const std::string& name,
14 ISvcLocator* pSvcLocator ) :
15 ::AthAlgorithm( name, pSvcLocator ),
16 m_onlineID(nullptr),
17 m_caloCellID(nullptr)
18{
19
20}
21
25
27
28 ATH_CHECK(detStore()->retrieve(m_onlineID, "LArOnlineID"));
29
30 ATH_CHECK(detStore()->retrieve(m_caloCellID, "CaloCell_ID"));
31
32 ATH_CHECK( m_cablingKey.initialize() );
33
34 return StatusCode::SUCCESS;
35}
36
38{
39
40 return StatusCode::SUCCESS;
41}
42
43
45
46 const uint32_t onlHashMax=m_onlineID->channelHashMax();
47
49 const LArOnOffIdMapping* cabling{*cablingHdl};
50 if(!cabling) {
51 ATH_MSG_ERROR( "Do not have cabling mapping from key " << m_cablingKey.key() );
52 return StatusCode::FAILURE;
53 }
55 const LArCalibLineMapping *clCont {*clHdl};
56 if(!clCont) {
57 ATH_MSG_ERROR( "Do not have calib line mapping !!!" );
58 return StatusCode::FAILURE;
59 }
60
61 coral::AttributeListSpecification* spec_onOff = new coral::AttributeListSpecification();
62 spec_onOff->extend("OnlineHashToOfflineId", "blob");
63 spec_onOff->extend<unsigned>("version");
64 AthenaAttributeList* al_onOff = new AthenaAttributeList(*spec_onOff);
65 coral::Blob& blobOnOff=(*al_onOff)["OnlineHashToOfflineId"].data<coral::Blob>();
66 (*al_onOff)["version"].setValue(0U);
67 blobOnOff.resize(onlHashMax*sizeof(uint32_t));
68
69 spec_onOff->release();
70 // cppcheck-suppress memleak
71 spec_onOff = nullptr;
72
73 coral::AttributeListSpecification* spec_calib = new coral::AttributeListSpecification();
74 spec_calib->extend("OnlineHashToCalibIds", "blob");
75 spec_calib->extend<unsigned>("version");
76 AthenaAttributeList* al_calib = new AthenaAttributeList(*spec_calib);
77 coral::Blob& blobCalib=(*al_calib)["OnlineHashToCalibIds"].data<coral::Blob>();
78 (*al_calib)["version"].setValue(0U);
79 blobCalib.resize(onlHashMax*sizeof(uint32_t)*3); //Bigger than necessary
80
81 spec_calib->release();
82 // cppcheck-suppress memleak
83 spec_calib = nullptr;
84
85 uint32_t* pBlobOnOff=static_cast<uint32_t*>(blobOnOff.startingAddress());
86 uint32_t* pBlobCalib=static_cast<uint32_t*>(blobCalib.startingAddress());
87
88 size_t index=0;
89 size_t calibIndex=0;
90
91 std::vector<unsigned> calibHist(5,0);
92
93 std::ofstream outfile("identifiers.txt");
94
95 outfile << "hash id bec pn FT SL chan id calo pn sampl reg eta phi calib" << std::endl;
96
97 for (uint32_t onlHash=0;onlHash<onlHashMax;++onlHash) {
98 const HWIdentifier hwid=m_onlineID->channel_Id(onlHash);
99 print(hwid,outfile);
100 const Identifier id=cabling->cnvToIdentifierFromHash(onlHash);
101 pBlobOnOff[index++]=id.get_identifier32().get_compact();
102
103 const std::vector<HWIdentifier>& calibIDs=clCont->calibSlotLine(hwid);
104 const size_t nCalibLines=calibIDs.size();
105 (calibHist[nCalibLines])++;
106 pBlobCalib[calibIndex++]=nCalibLines;
107 for(uint32_t iCalib=0;iCalib<nCalibLines;++iCalib)
108 pBlobCalib[calibIndex++]=calibIDs[iCalib].get_identifier32().get_compact();
109 }
110
111 blobCalib.resize(calibIndex*sizeof(uint32_t)); //Size down to actual size
112
113
114 outfile.close();
115
116 ATH_MSG_INFO("BlobSize OnOffId:" << index);
117 ATH_MSG_INFO("BlobSize CalibId:" << calibIndex);
118 msg(MSG::INFO) << "nCalib[i] ";
119 for (unsigned j=0;j<5;++j)
120 msg() << calibHist[j] << "/";
121 msg() << endmsg;
122
123 ATH_CHECK(detStore()->record(al_onOff,"/LAR/Identifier/OnOffIdMap"));
124
125 ATH_CHECK(detStore()->record(al_calib,"/LAR/Identifier/CalibIdMap"));
126
127 return StatusCode::SUCCESS;
128}
129
130
131void LArIdMapConvert::print (const HWIdentifier& hwid, std::ostream& out) {
132 const IdentifierHash hwid_hash=m_onlineID->channel_Hash(hwid);
134 const LArOnOffIdMapping* cabling{*cablingHdl};
135 if(!cabling) {
136 ATH_MSG_ERROR( "Do not have cabling mapping from key " << m_cablingKey.key() );
137 return;
138 }
140 const LArCalibLineMapping *clCont {*clHdl};
141 if(!clCont) {
142 ATH_MSG_ERROR( "Do not have calib line mapping !!!" );
143 return;
144 }
145 out << hwid_hash << " " << std::hex << "0x" << hwid.get_identifier32().get_compact() << std::dec << " "
146 << m_onlineID->barrel_ec(hwid) << " "
147 << m_onlineID->pos_neg(hwid) << " "
148 << m_onlineID->feedthrough(hwid) << " "
149 << m_onlineID->slot(hwid) << " "
150 << m_onlineID->channel(hwid) << " : ";
151 if (cabling->isOnlineConnected(hwid)) {
152 const Identifier id=cabling->cnvToIdentifier(hwid);
153 out << std::hex << "0x" << id.get_identifier32().get_compact() << std::dec << " "
154 << m_caloCellID->sub_calo(id) << " "
155 << m_caloCellID->pos_neg(id) << " "
156 << m_caloCellID->sampling(id) << " "
157 << m_caloCellID->region(id) << " "
158 << m_caloCellID->eta(id) << " "
159 << m_caloCellID->phi(id) << " ";
160 }
161 else
162 out << " disconnected ";
163
164 const std::vector<HWIdentifier>& calibIDs=clCont->calibSlotLine(hwid);
165 for (size_t i=0;i<calibIDs.size();++i) {
166 out << std::hex << "0x" << calibIDs[i].get_identifier32().get_compact() << " ";
167 }
168 out << std::dec << std::endl;
169}
170
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
MsgStream & msg() const
An AttributeList represents a logical row of attributes in a metadata table.
value_type get_compact() const
Get the compact id.
This is a "hash" representation of an Identifier.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
const std::vector< HWIdentifier > & calibSlotLine(const HWIdentifier id) const
virtual StatusCode execute() override
virtual StatusCode finalize() override
virtual StatusCode initialize() override
SG::ReadCondHandleKey< LArCalibLineMapping > m_CLKey
LArIdMapConvert()
Default constructor:
const CaloCell_ID * m_caloCellID
const LArOnlineID * m_onlineID
void print(const HWIdentifier &hwid, std::ostream &out=std::cout)
virtual ~LArIdMapConvert()
Destructor:
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition index.py:1