ATLAS Offline Software
Loading...
Searching...
No Matches
LArBadFebBitPacking.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
7
9 m_index( 8*sizeof(BitWord),-1)
10{
11 // Here, specify each problem and its name
12 addBit( deadAllBit, "deadAll");
13 addBit( deadReadoutBit, "deadReadout");
14 addBit( inErrorBit, "inError");
15 addBit( deactivatedInOKSBit, "deactivatedInOKS");
16 addBit( maskParity, "maskParity");
17 addBit( maskBCID, "maskBCID");
18 addBit( maskSampleHeader, "maskSampleHeader");
19 addBit( maskEVTID, "maskEVTID");
20 addBit( maskScacStatus, "maskScacStatus");
21 addBit( maskScaOutOfRange, "maskScaOutOfRange");
22 addBit( maskGainMismatch, "maskGainMismatch");
23 addBit( maskTypeMismatch, "maskTypeMismatch");
24 addBit( maskNumOfSamples, "maskNumOfSamples");
25 addBit( maskEmptyDataBlock, "maskEmptyDataBlock");
26 addBit( maskDspBlockSize, "maskDspBlockSize");
27 addBit( maskCheckSum, "maskCheckSum");
28 addBit( maskMissingHeader, "maskMissingHeader");
29 addBit( maskBadGain, "maskBadGain");
30
31 for (unsigned int i=0; i<m_enumVec.size(); i++) {
32 m_index[m_enumVec[i]] = i;
33 }
34}
35
36void LArBadFebBitPacking::addBit( ProblemType pb, const std::string& name)
37{
38 m_enumVec.push_back(pb);
39 m_nameVec.push_back(name);
40 m_nameMap[name] = pb;
41}
42
43
44 const std::string& LArBadFebBitPacking::stringName( ProblemType pb) const
45 {
46 return m_nameVec.at(index(pb));
47 }
48
49 std::pair<bool, LArBadFebEnum::ProblemType>
50 LArBadFebBitPacking::enumName( const std::string& str) const
51 {
52 std::map<std::string, ProblemType>::const_iterator i = m_nameMap.find( str);
53 if (i != m_nameMap.end()) { return std::make_pair(true,i->second);}
54 else return std::make_pair(false, (ProblemType) 0);
55 }
56
57
58 void LArBadFebBitPacking::setBit( ProblemType pb, BitWord& word, bool value) const {
59 BitWord mask = 1;
60 mask = mask << bitPosition(pb); // all at 0 except pb bit
61 if (value) word |= mask;
62 else word &= ~mask;
63 }
64
65 bool LArBadFebBitPacking::setBit( const std::string& name,
66 BitWord& word, bool value) const
67 {
68 std::pair<bool, ProblemType> res = enumName( name);
69 if (res.first) { // name corresponds to enum
70 setBit( res.second, word, value);
71 return true;
72 }
73 else return false; // name not recognized
74 }
75
76 void LArBadFebBitPacking::setBit( ProblemType pb, LArBadFeb& word, bool value) const
77 {
78 setBit( pb, word.packedDataRef(), value);
79 }
80
81 bool LArBadFebBitPacking::setBit( const std::string& name, LArBadFeb& word, bool value) const
82 {
83 return setBit( name, word.packedDataRef(), value);
84 }
85
86 std::string LArBadFebBitPacking::stringStatus( const LArBadFeb& bc) const
87 {
88 std::string res;
89 for (unsigned int i=0; i<m_enumVec.size(); ++i) {
90 if ( ! bc.statusOK( m_enumVec.at(i))) {
91 if (!res.empty()) res += " ";
92 res += m_nameVec.at(i);
93 }
94 }
95 return res;
96 }
std::pair< std::vector< unsigned int >, bool > res
std::map< std::string, ProblemType > m_nameMap
std::vector< int > m_index
std::vector< std::string > m_nameVec
std::vector< ProblemType > m_enumVec
const std::string & stringName(ProblemType pb) const
PosType bitPosition(ProblemType pb) const
std::pair< bool, ProblemType > enumName(const std::string &str) const
void setBit(ProblemType pb, BitWord &word, bool value=true) const
std::string stringStatus(const LArBadFeb &bc) const
void addBit(ProblemType pb, const std::string &name)
unsigned int BitWord
BitWord & packedDataRef()
Definition LArBadFeb.h:58
bool statusOK(ProblemType pb) const
Returns true if there is no problem in corresponding status bit.
Definition LArBadFeb.h:24
Definition index.py:1