ATLAS Offline Software
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 
24 namespace LArBadChannelDBTools {
25 
26  using namespace LArBadChanBlobUtils;
27 
28  MsgStream getDefaultMsgStream()
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  {
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 
76  fillControlInfo(attrList, 0, 1);
77  coral::Blob& blob=(*attrList)["Blob"].data<coral::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 =
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 }
LArBadChannelState.h
LArBadChannelState
Definition: LArBadChannelState.h:15
LArBadChanBlobUtils
Definition: LArBadChanBlobUtils.h:18
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
get_generator_info.result
result
Definition: get_generator_info.py:21
LArBadChannelDBTools::createCoolSpec
coral::AttributeListSpecification * createCoolSpec()
creates the AttributeListSpecification for the LArBadChannel DB
Definition: LArBadChannelDBTools.cxx:35
LArBadChannelDBTools
Definition: LArBadChannelDBTools.h:26
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
LArBadChanBlobUtils::Channel
Identifier32::value_type Channel
Definition: LArBadChanBlobUtils.h:24
CaloCondBlobAlgs_fillNoiseFromASCII.spec
spec
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:47
LArBadChannel.h
LArBadChannelDBTools::createFebPayload
AthenaAttributeList * createFebPayload(const BadFebVec &data)
Definition: LArBadChannelDBTools.cxx:65
LArBadChanBlobUtils::BadChanVec
std::vector< BadChanEntry > BadChanVec
Definition: LArBadChanBlobUtils.h:22
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
LArBadChannelDBTools::createFebPayloadV1
AthenaAttributeList * createFebPayloadV1(const std::vector< HWIdentifier32 > &data)
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
LArBadChanBlobUtils::decodeFebBlobV1
std::vector< HWIdentifier > decodeFebBlobV1(const coral::Blob *blobp, std::size_t chanSize, int endian, int version, MsgStream &log)
Definition: LArBadChanBlobUtils.cxx:72
LArBadChannelState::CoolChannelData::empty
bool empty() const
Definition: LArBadChannelState.h:86
LArBadChannelDBTools::readBadFeb
std::vector< BadFebEntry > readBadFeb(const coral::AttributeList &attrList, MsgStream &log)
Definition: LArBadChannelDBTools.cxx:133
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
AthenaAttributeList.h
LArBadChanBlobUtils::BadFebVec
std::vector< BadFebEntry > BadFebVec
Definition: LArBadChanBlobUtils.h:23
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
LArBadFebEnum::deadAllBit
@ deadAllBit
Definition: LArBadFebEnum.h:16
LArBadChannelDBTools::createCoolCollection
CondAttrListCollection * createCoolCollection(const LArBadChannelState &bcState)
Definition: LArBadChannelDBTools.cxx:82
LArBadChannelDBTools::createPayload
AthenaAttributeList * createPayload(const std::vector< Entry > &data, const coral::AttributeListSpecification &spec)
LArBadChannelDBTools::readBadChan
std::vector< BadChanEntry > readBadChan(const coral::AttributeList &attrList, MsgStream &log)
Definition: LArBadChannelDBTools.cxx:119
LArBadChannelState::CoolChannelData
Definition: LArBadChannelState.h:25
LArBadChannelDBTools::fillControlInfo
void fillControlInfo(AthenaAttributeList *attrList, unsigned int wordSize, unsigned int vers)
Definition: LArBadChannelDBTools.cxx:50
LArBadChanBlobUtils::machineEndianness
int machineEndianness()
Definition: LArBadChanBlobUtils.cxx:9
checkCoolLatestUpdate.chanNum
chanNum
Definition: checkCoolLatestUpdate.py:27
LArBadChannelDBTools.h
LArBadChanBlobUtils.h
LArBadChanBlobUtils::fillFebBlobV1
void fillFebBlobV1(const std::vector< HWIdentifier > &vec, coral::Blob &blob)
Definition: LArBadChanBlobUtils.cxx:17
lumiFormat.i
int i
Definition: lumiFormat.py:92
LArBadChannelDBTools::createChanPayload
AthenaAttributeList * createChanPayload(const BadChanVec &data, const coral::AttributeListSpecification &spec)
Definition: LArBadChannelDBTools.cxx:59
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
LArBadFebBitPacking::setBit
void setBit(ProblemType pb, BitWord &word, bool value=true) const
Definition: LArBadFebBitPacking.cxx:58
CondAttrListCollection::ChanNum
unsigned int ChanNum
Definition: CondAttrListCollection.h:55
LArBadChannelState::coolChannel
const CoolChannelData & coolChannel(CoolChannelEnum chan) const
Definition: LArBadChannelState.h:134
HWIdentifier.h
LArBadChannelDBTools::BadFebEntry
std::pair< HWIdentifier, LArBadFeb > BadFebEntry
Definition: LArBadChannelDBTools.h:29
LArBadFeb
Definition: LArBadFeb.h:10
LArBadChannelDBTools::badChanVersion
unsigned int badChanVersion()
Version of the BLOB encoding, to be incremented each time the BLOB format changes.
Definition: LArBadChannelDBTools.h:57
DetDescrDictionaryDict::idvec
DataVector< Identifier > idvec
Definition: DetDescrDictionaryDict.h:14
get_generator_info.version
version
Definition: get_generator_info.py:33
LArBadChannelState::CoolChannelEnum
CoolChannelEnum
Definition: LArBadChannelState.h:23
LArBadFebBitPacking
Definition: LArBadFebBitPacking.h:16
LArBadChannelDBTools::createEmptyCoolCollection
CondAttrListCollection * createEmptyCoolCollection()
Create an empty collection with no bad channels, e.g. for MC.
Definition: LArBadChannelDBTools.cxx:102
LArBadChannelDBTools::badFebVersion
unsigned int badFebVersion()
Definition: LArBadChannelDBTools.h:58
LArBadChannelState::CoolChannelData::stateVector
const BadChanVec & stateVector() const
Definition: LArBadChannelState.h:90
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
CondAttrListCollection::add
bool add(ChanNum chanNum, const AttributeList &attributeList)
Adding in chan/attrList pairs.
Definition: CondAttrListCollection.h:452
LArBadChannelState::NCoolChannels
@ NCoolChannels
Definition: LArBadChannelState.h:20
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
LArBadChannelDBTools::getDefaultMsgStream
MsgStream getDefaultMsgStream()
used to get default msg stream
Definition: LArBadChannelDBTools.cxx:28
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96
python.handimod.cc
int cc
Definition: handimod.py:523