ATLAS Offline Software
Loading...
Searching...
No Matches
LArBadChannelDBTools.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8#include "CoolKernel/types.h"
9#include "CoolKernel/Record.h"
10#include "CoralBase/AttributeListSpecification.h"
13
17
18#include "GaudiKernel/MsgStream.h"
20
21#include <vector>
22#include <typeinfo>
23
24namespace LArBadChannelDBTools {
25
26 using namespace LArBadChanBlobUtils;
27
29 {
30 MsgStream log(Athena::getMessageSvc());
31 return log;
32 }
33
35 coral::AttributeListSpecification* createCoolSpec()
36 {
37 coral::AttributeListSpecification* spec = new coral::AttributeListSpecification();
38 if (spec == nullptr) {
39 return spec;
40 }
41 spec->extend("ChannelSize", "unsigned int");
42 spec->extend("StatusWordSize", "unsigned int");
43 spec->extend("Endianness", "unsigned int");
44 spec->extend("Version", "unsigned int");
45 spec->extend("Blob", "blob");
46
47 return spec;
48 }
49
50 void fillControlInfo( AthenaAttributeList* attrList, unsigned int wordSize, unsigned int vers)
51 {
52 (*attrList)["ChannelSize"].setValue( (unsigned int) sizeof(Channel));
53 (*attrList)["StatusWordSize"].setValue( wordSize);
54 (*attrList)["Endianness"].setValue( (unsigned int) machineEndianness());
55 (*attrList)["Version"].setValue( vers);
56 }
57
58
60 const coral::AttributeListSpecification& spec)
61 {
62 return createPayload( data, spec, badChanVersion());
63 }
64
66 {
67 coral::AttributeListSpecification* spec = createCoolSpec();
68 return createPayload( data, *spec, badFebVersion());
69 }
70
71 AthenaAttributeList* createFebPayloadV1( const std::vector<HWIdentifier>& data)
72 {
73 coral::AttributeListSpecification* spec = createCoolSpec();
74
75 AthenaAttributeList* attrList = new AthenaAttributeList(*spec);
76 fillControlInfo(attrList, 0, 1);
77 coral::Blob& blob=(*attrList)["Blob"].data<coral::Blob>();
78 fillFebBlobV1( data, blob);
79 return attrList;
80 }
81
83 {
84 CondAttrListCollection* attrListColl = new CondAttrListCollection(true);
85
86 coral::AttributeListSpecification* spec = createCoolSpec();
87
88 for (int i=0; i<LArBadChannelState::NCoolChannels; i++) {
91 if (!bcState.coolChannel( cc).empty()) {
92 AthenaAttributeList* ilist =
93 createChanPayload( bcState.coolChannel( cc).stateVector(), *spec);
95 attrListColl->add(chanNum, *ilist);
96 }
97 }
98
99 return attrListColl;
100 }
101
103 {
104 CondAttrListCollection* attrListColl = new CondAttrListCollection(true);
105
106 coral::AttributeListSpecification* spec = createCoolSpec();
107 for (int i=0; i<2; i++) {
111 AthenaAttributeList* ilist = createChanPayload( emptyChan.stateVector(), *spec);
113 attrListColl->add(chanNum, *ilist);
114 }
115 return attrListColl;
116 }
117
118 std::vector<BadChanEntry>
119 readBadChan( const coral::AttributeList& attrList, MsgStream& log)
120 {
121 const coral::Blob& blob = attrList["Blob"].data<coral::Blob>();
122 unsigned int chanSize = attrList["ChannelSize"].data<unsigned int>();
123 unsigned int stateSize = attrList["StatusWordSize"].data<unsigned int>();
124 unsigned int endian = attrList["Endianness"].data<unsigned int>();
125 unsigned int version = attrList["Version"].data<unsigned int>();
126
127 return
128 LArBadChanBlobUtils::decodeBlob<LArBadChannel>( &blob, chanSize, stateSize, endian,
129 version, log);
130 }
131
132 std::vector<BadFebEntry>
133 readBadFeb( const coral::AttributeList& attrList, MsgStream& log)
134 {
135 const coral::Blob& blob = attrList["Blob"].data<coral::Blob>();
136 unsigned int chanSize = attrList["ChannelSize"].data<unsigned int>();
137 unsigned int stateSize = attrList["StatusWordSize"].data<unsigned int>();
138 unsigned int endian = attrList["Endianness"].data<unsigned int>();
139 unsigned int version = attrList["Version"].data<unsigned int>();
140
141 if (version == 1) {
142 // Version 1 nas only HWIdentifier and no LArBadFeb, so we have to add a
143 // LArBadFeb with status "deadAll" by hand
144 std::vector<HWIdentifier> idvec =
145 LArBadChanBlobUtils::decodeFebBlobV1( &blob, chanSize, endian, version, log);
146 std::vector<BadFebEntry> result;
147 result.resize(idvec.size());
148 LArBadFeb missingState;
149 LArBadFebBitPacking febPacking;
150 febPacking.setBit( LArBadFeb::deadAllBit, missingState);
151 for (unsigned int i=0; i<idvec.size(); ++i) {
152 result[i] = BadFebEntry( idvec[i], missingState);
153 }
154 return result;
155 }
156 else {
157 return LArBadChanBlobUtils::decodeBlob<LArBadFeb>( &blob, chanSize, stateSize,
158 endian, version, log);
159 }
160 }
161
162}
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
An AttributeList represents a logical row of attributes in a metadata table.
This class is a collection of AttributeLists where each one is associated with a channel number.
bool add(ChanNum chanNum, const AttributeList &attributeList)
Adding in chan/attrList pairs.
const BadChanVec & stateVector() const
const CoolChannelData & coolChannel(CoolChannelEnum chan) const
void setBit(ProblemType pb, BitWord &word, bool value=true) const
singleton-like access to IMessageSvc via open function and helper
IMessageSvc * getMessageSvc(bool quiet=false)
std::pair< HWIdentifier, LArBadFeb > BadFebEntry
std::vector< std::pair< HWIdentifier, T > > decodeBlob(const coral::Blob *blobp, std::size_t chanSize, std::size_t stateSize, int endian, int version, MsgStream &log)
Checks BLOB for differences in endian-ness and size of data types with respect to the architecture on...
std::vector< BadChanEntry > BadChanVec
Identifier32::value_type Channel
std::vector< HWIdentifier > decodeFebBlobV1(const coral::Blob *blobp, std::size_t chanSize, int endian, int version, MsgStream &log)
std::vector< BadFebEntry > BadFebVec
void fillFebBlobV1(const std::vector< HWIdentifier > &vec, coral::Blob &blob)
coral::AttributeListSpecification * createCoolSpec()
creates the AttributeListSpecification for the LArBadChannel DB
CondAttrListCollection * createCoolCollection(const LArBadChannelState &bcState)
unsigned int badChanVersion()
Version of the BLOB encoding, to be incremented each time the BLOB format changes.
CondAttrListCollection * createEmptyCoolCollection()
Create an empty collection with no bad channels, e.g. for MC.
std::vector< BadChanEntry > readBadChan(const coral::AttributeList &attrList, MsgStream &log)
AthenaAttributeList * createPayload(const std::vector< Entry > &data, const coral::AttributeListSpecification &spec)
AthenaAttributeList * createFebPayloadV1(const std::vector< HWIdentifier32 > &data)
void fillControlInfo(AthenaAttributeList *attrList, unsigned int wordSize, unsigned int vers)
std::vector< BadFebEntry > readBadFeb(const coral::AttributeList &attrList, MsgStream &log)
AthenaAttributeList * createFebPayload(const BadFebVec &data)
MsgStream getDefaultMsgStream()
used to get default msg stream
AthenaAttributeList * createChanPayload(const BadChanVec &data, const coral::AttributeListSpecification &spec)