ATLAS Offline Software
Loading...
Searching...
No Matches
LArBadChannelDecoder Class Reference

#include <LArBadChannelDecoder.h>

Collaboration diagram for LArBadChannelDecoder:

Public Types

typedef LArBadChannelState State
typedef LArBadChannelState::BadChanEntry BadChanEntry
typedef std::pair< HWIdentifier, LArBadFebBadFebEntry

Public Member Functions

 LArBadChannelDecoder (const LArOnlineID_Base *onlineID, bool isSC=false)
std::vector< BadChanEntryreadASCII (const std::string &name, State::CoolChannelEnum coolChan, MsgStream &log) const
std::vector< BadFebEntryreadFebASCII (const std::string &fname, MsgStream &log) const

Private Types

enum  {
  barrel_ec , pos_neg , feedthrough , slot ,
  channel
}

Private Member Functions

HWIdentifier constructChannelId (const std::vector< int > &intVec, State::CoolChannelEnum coolChan, MsgStream &log) const
std::pair< bool, LArBadChannelconstructStatus (const std::vector< std::string > &vec, MsgStream &log) const
std::pair< bool, LArBadFebconstructFebStatus (const std::vector< std::string > &vec, MsgStream &log) const
bool checkId (const HWIdentifier &, int be, int pn, State::CoolChannelEnum) const
std::vector< HWIdentifierconstructFebId (const std::vector< int > &intVec, MsgStream &log) const
HWIdentifier constructSingleFebId (const std::vector< int > &v, MsgStream &log) const

Static Private Member Functions

static MsgStream & insertExpandedID (const std::vector< int > &intVec, MsgStream &log)

Private Attributes

const LArOnlineID_Basem_onlineID
LArBadChanBitPacking m_packing
LArBadChanSCBitPacking m_SCpacking
LArBadFebBitPacking m_febPacking
bool m_isSC

Detailed Description

Definition at line 21 of file LArBadChannelDecoder.h.

Member Typedef Documentation

◆ BadChanEntry

◆ BadFebEntry

Definition at line 29 of file LArBadChannelDecoder.h.

◆ State

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
barrel_ec 
pos_neg 
feedthrough 
slot 
channel 

Definition at line 40 of file LArBadChannelDecoder.h.

Constructor & Destructor Documentation

◆ LArBadChannelDecoder()

LArBadChannelDecoder::LArBadChannelDecoder ( const LArOnlineID_Base * onlineID,
bool isSC = false )
inline

Definition at line 24 of file LArBadChannelDecoder.h.

24 :
25 m_onlineID( onlineID), m_isSC(isSC) {}
const LArOnlineID_Base * m_onlineID

Member Function Documentation

◆ checkId()

bool LArBadChannelDecoder::checkId ( const HWIdentifier & id,
int be,
int pn,
State::CoolChannelEnum coolCh ) const
private

Definition at line 202 of file LArBadChannelDecoder.cxx.

204{
205 if (barrel_ec != State::barrelEndcap(coolCh)) return false; // first check barrel/ec (faster)
206 if (pos_neg != State::posNeg(coolCh)) return false; // then check side (faster)
207 if (m_onlineID->isEMBchannel(id) && State::caloPart(coolCh)==State::EMB) return true;
208 if (m_onlineID->isEMECchannel(id) && State::caloPart(coolCh)==State::EMEC) return true;
209 if (m_onlineID->isHECchannel(id) && State::caloPart(coolCh)==State::HEC) return true;
210 if (m_onlineID->isFCALchannel(id) && State::caloPart(coolCh)==State::FCAL) return true;
211 return false;
212}
static CaloPartEnum caloPart(CoolChannelEnum chan)
static int barrelEndcap(CoolChannelEnum chan)
static int posNeg(CoolChannelEnum chan)

◆ constructChannelId()

HWIdentifier LArBadChannelDecoder::constructChannelId ( const std::vector< int > & intVec,
State::CoolChannelEnum coolChan,
MsgStream & log ) const
private

Definition at line 77 of file LArBadChannelDecoder.cxx.

80{
81 HWIdentifier invalid;
82 if (intVec.size() < 5) { // redundant error check
83 log << MSG::WARNING << "Failed to produce a channel HWIdentifier for ";
84 for (unsigned int i=0; i<intVec.size(); i++) log << intVec[i] << " ";
85 log << "not enough identifiers" << endmsg;
86 return invalid;
87 }
88 try {
89 HWIdentifier hwid( m_onlineID->channel_Id( intVec[barrel_ec], intVec[pos_neg], intVec[feedthrough],
90 intVec[slot], intVec[channel], true));
91 if (coolChan<LArBadChannelState::MAXCOOLCHAN && !checkId( hwid, intVec[barrel_ec], intVec[pos_neg], coolChan)) {
92 log << MSG::WARNING << "Channel "; insertExpandedID( intVec, log);
93 log << " does not belong to COOL channel " << State::coolChannelName( coolChan)
94 << ". Skipped" << endmsg;
95 return invalid;
96 }
97 log << MSG::DEBUG << "Translating id "; insertExpandedID( intVec, log);
98 log << " to 0x" << MSG::hex << hwid << MSG::dec << endmsg;
99 return hwid;
100 }
101 catch( LArOnlID_Exception& idException) {
102 log << MSG::ERROR << "Failed to produce a HWIdentifier for "; insertExpandedID( intVec, log) << endmsg;
103 }
104 return invalid;
105}
#define endmsg
static MsgStream & insertExpandedID(const std::vector< int > &intVec, MsgStream &log)
bool checkId(const HWIdentifier &, int be, int pn, State::CoolChannelEnum) const
static std::string coolChannelName(CoolChannelEnum chan)

◆ constructFebId()

std::vector< HWIdentifier > LArBadChannelDecoder::constructFebId ( const std::vector< int > & intVec,
MsgStream & log ) const
private

Definition at line 107 of file LArBadChannelDecoder.cxx.

109{
110 const int maxFebPerFT = 15; // hard-wired number of slots per feed-through
111
112 std::vector<HWIdentifier> result;
113 if (intVec.size() != 4) { // redundant error check
114 log << MSG::WARNING << "Failed to produce a FEB HWIdentifier for ";
115 for (unsigned int i=0; i<intVec.size(); i++) log << intVec[i] << " ";
116 log << "not enough identifiers" << endmsg;
117 return result;
118 }
119
120 // expand wildcard
121 if (intVec[slot] == -1) {
122 std::vector<int> vec( intVec); // modifiable copy
123
124 // FEB slot counting starts at 1
125 for (vec[slot]=1; vec[slot] <= maxFebPerFT; vec[slot]++) {
126
127 HWIdentifier hwid = constructSingleFebId( vec, log);
128 if (hwid.is_valid()) result.push_back( hwid);
129 }
130 }
131 else{
132 HWIdentifier hwid = constructSingleFebId( intVec, log);
133 if (hwid.is_valid()) result.push_back( hwid);
134 }
135 return result;
136}
std::vector< size_t > vec
bool is_valid() const
Check if id is in a valid state.
HWIdentifier constructSingleFebId(const std::vector< int > &v, MsgStream &log) const

◆ constructFebStatus()

std::pair< bool, LArBadFeb > LArBadChannelDecoder::constructFebStatus ( const std::vector< std::string > & vec,
MsgStream & log ) const
private

Definition at line 176 of file LArBadChannelDecoder.cxx.

178{
179 LArBadFeb result;
180 for(std::vector<std::string>::const_iterator it = vec.begin(); it != vec.end(); ++it) {
181 bool ok = m_febPacking.setBit( *it, result);
182 if (!ok) {
183 log << MSG::WARNING << "LArBadChannelDecoder REJECTED line with "
184 << ":\t unrecognized problem status: " << *it << endmsg;
185 return std::pair<bool,LArBadFeb>(false,result); // exit on error
186 }
187 }
188 return std::pair<bool,LArBadFeb>(true,result);
189}
LArBadFebBitPacking m_febPacking

◆ constructSingleFebId()

HWIdentifier LArBadChannelDecoder::constructSingleFebId ( const std::vector< int > & v,
MsgStream & log ) const
private

Definition at line 138 of file LArBadChannelDecoder.cxx.

140{
141 HWIdentifier invalid;
142 if (v.size() != 4) return invalid;
143 try {
144 HWIdentifier hwid( m_onlineID->feb_Id( v[barrel_ec], v[pos_neg], v[feedthrough], v[slot], true));
145 log << MSG::DEBUG << "Translating FEB id "; insertExpandedID( v, log);
146 log << " to 0x" << MSG::hex << hwid << MSG::dec << endmsg;
147 return hwid;
148 }
149 catch( LArOnlID_Exception& idException) {
150 log << MSG::ERROR << "Failed to produce a FEB HWIdentifier for "; insertExpandedID( v, log);
151 log << endmsg;
152 }
153 return invalid;
154}

◆ constructStatus()

std::pair< bool, LArBadChannel > LArBadChannelDecoder::constructStatus ( const std::vector< std::string > & vec,
MsgStream & log ) const
private

Definition at line 157 of file LArBadChannelDecoder.cxx.

158{
159 LArBadChannel result;
160 for(std::vector<std::string>::const_iterator it = vec.begin(); it != vec.end(); ++it) {
161 bool ok = false;
162 if(m_isSC)
163 ok = m_SCpacking.setBit( *it, result);
164 else
165 ok = m_packing.setBit( *it, result);
166 if (!ok) {
167 log << MSG::WARNING << "LArBadChannelDecoder REJECTED line with "
168 << ":\t unrecognized problem status: " << *it << endmsg;
169 return std::pair<bool,LArBadChannel>(false,result); // exit on error
170 }
171 }
172 return std::pair<bool,LArBadChannel>(true,result);
173}
LArBadChanBitPacking m_packing
LArBadChanSCBitPacking m_SCpacking

◆ insertExpandedID()

MsgStream & LArBadChannelDecoder::insertExpandedID ( const std::vector< int > & intVec,
MsgStream & log )
staticprivate

Definition at line 192 of file LArBadChannelDecoder.cxx.

193{
194 log << " b/e " << intVec[barrel_ec]
195 << " p/n " << intVec[pos_neg]
196 << " ft " << intVec[feedthrough]
197 << " slot " << intVec[slot];
198 if (intVec.size() >= 5) log << " ch " << intVec[channel]; // no endmsg,
199 return log;
200}

◆ readASCII()

std::vector< LArBadChannelDecoder::BadChanEntry > LArBadChannelDecoder::readASCII ( const std::string & name,
State::CoolChannelEnum coolChan,
MsgStream & log ) const

Definition at line 13 of file LArBadChannelDecoder.cxx.

16{
17 std::vector<BadChanEntry> result;
18
19 // set up parsing with exactly 6 ints and >= 1 string, for reading channels
20 LArBadChannelParser parser(fname, &log, 6, -1);
21 if (!parser.fileStatusGood()) {
22 log << MSG::ERROR << "Failed to open file " << fname
23 << " for COOL channel " << State::coolChannelName( coolChan) << endmsg;
24 return result;
25 }
26
27 typedef std::string ParseType;
28 typedef std::pair<std::vector<int>, std::vector<ParseType> > ParsedLine;
29 std::vector<ParsedLine> parsed = parser.parseFile<ParseType>();
30 log << MSG::INFO << "Parsed " << parsed.size() << " lines from file " << fname << endmsg;
31
32 for (std::vector<ParsedLine>::const_iterator i=parsed.begin();
33 i != parsed.end(); ++i) {
34 HWIdentifier hwid = constructChannelId( i->first, coolChan, log);
35 if (hwid.is_valid()) {
36 std::pair<bool,LArBadChannel> badCh = constructStatus( i->second, log);
37 if (badCh.first) {
38 result.emplace_back( hwid, badCh.second);
39 }
40 }
41 }
42 return result;
43}
HWIdentifier constructChannelId(const std::vector< int > &intVec, State::CoolChannelEnum coolChan, MsgStream &log) const
std::pair< bool, LArBadChannel > constructStatus(const std::vector< std::string > &vec, MsgStream &log) const

◆ readFebASCII()

std::vector< LArBadChannelDecoder::BadFebEntry > LArBadChannelDecoder::readFebASCII ( const std::string & fname,
MsgStream & log ) const

Definition at line 46 of file LArBadChannelDecoder.cxx.

48{
49 std::vector<BadFebEntry> result;
50
51 // set up a parser to read 4 ints (the 4th of which can be a wildcard) and >=1 strings
52 LArBadChannelParser parser(fname, &log, 4, -1, 4);
53 if (!parser.fileStatusGood()) {
54 log << MSG::ERROR << "Failed to open missing FEBs file " << fname << endmsg;
55 return result;
56 }
57
58 typedef std::string ParseType;
59 typedef std::pair<std::vector<int>, std::vector<ParseType> > ParsedLine;
60 std::vector<ParsedLine> parsed = parser.parseFile<ParseType>();
61 for (std::vector<ParsedLine>::const_iterator i=parsed.begin();
62 i != parsed.end(); ++i) {
63 std::vector<HWIdentifier> hwid = constructFebId( i->first, log);
64 if (!hwid.empty()) {
65 // BEFORE: result.insert( result.end(), hwid.begin(), hwid.end());
66 std::pair<bool,LArBadFeb> badFeb = constructFebStatus( i->second, log);
67 if (badFeb.first) {
68 for (std::vector<HWIdentifier>::const_iterator i=hwid.begin(); i!=hwid.end(); ++i) {
69 result.emplace_back( *i, badFeb.second);
70 }
71 }
72 }
73 }
74 return result;
75}
std::pair< bool, LArBadFeb > constructFebStatus(const std::vector< std::string > &vec, MsgStream &log) const
std::vector< HWIdentifier > constructFebId(const std::vector< int > &intVec, MsgStream &log) const

Member Data Documentation

◆ m_febPacking

LArBadFebBitPacking LArBadChannelDecoder::m_febPacking
private

Definition at line 45 of file LArBadChannelDecoder.h.

◆ m_isSC

bool LArBadChannelDecoder::m_isSC
private

Definition at line 47 of file LArBadChannelDecoder.h.

◆ m_onlineID

const LArOnlineID_Base* LArBadChannelDecoder::m_onlineID
private

Definition at line 42 of file LArBadChannelDecoder.h.

◆ m_packing

LArBadChanBitPacking LArBadChannelDecoder::m_packing
private

Definition at line 43 of file LArBadChannelDecoder.h.

◆ m_SCpacking

LArBadChanSCBitPacking LArBadChannelDecoder::m_SCpacking
private

Definition at line 44 of file LArBadChannelDecoder.h.


The documentation for this class was generated from the following files: