ATLAS Offline Software
Loading...
Searching...
No Matches
LArBadChannelState.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <set>
8
10{
11 for ( unsigned int i=0; i<NCoolChannels; i++) {
12 m_DataVec.emplace_back( static_cast<CoolChannelEnum>(i));
13 }
14}
15
17{
18 m_DataVec[chan].add(entry);
19}
20
21void LArBadChannelState::setFromDB( const std::vector<BadChanEntry>& stateVec,
22 CoolChannelEnum chan)
23{
24 m_DataVec[chan].setFromDB( stateVec);
25}
26
27void LArBadChannelState::addFromDB( const std::vector<BadChanEntry>& stateVec,
28 CoolChannelEnum chan)
29{
30 m_DataVec[chan].addFromDB( stateVec);
31}
32
34{
35 for ( unsigned int i=0; i<NCoolChannels; i++) {
36 m_DataVec[i].reset();
37 }
38}
39
41{
42 switch( chan) {
43 case EMBA:
44 return "EMBA";
45 break;
46 case EMBC:
47 return "EMBC";
48 break;
49 case EMECA:
50 return "EMECA";
51 break;
52 case EMECC:
53 return "EMECC";
54 break;
55 case HECA:
56 return "HECA";
57 break;
58 case HECC:
59 return "HECC";
60 break;
61 case FCALA:
62 return "FCALA";
63 break;
64 case FCALC:
65 return "FCALC";
66 break;
67 case MAXCOOLCHAN:
68 break;
69 }
70 return "Unknown";
71}
72
73void LArBadChannelState::CoolChannelData::addFromDB( const std::vector<BadChanEntry>& stateVec)
74{
75 m_entries.insert( m_entries.end(), stateVec.begin(), stateVec.end());
77 //sort( m_entries.begin(), m_entries.end())
78 m_changed = false;
79}
80
82{
83 // using namespace std;
84 typedef std::vector<BadChanEntry>::iterator Iter;
85
86 std::multiset<Iter> toDelete;
87 for (Iter i = m_entries.begin(); i != m_entries.end(); ++i) {
88 for (Iter j = i+1; j != m_entries.end(); ++j) {
89 if (i->first == j->first) {
90 mergeFlags( *i, *j); // j's flags are added to i's flags
91 toDelete.insert(j);
92 }
93 }
94 }
95
96 // We make a copy of the vector to avoid erasing elements
97 std::vector<BadChanEntry> tmp;
98 tmp.reserve( m_entries.size() - toDelete.size());
99 for (Iter i = m_entries.begin(); i != m_entries.end(); ++i) {
100 if (toDelete.find(i) == toDelete.end()) {
101 tmp.push_back(*i); // not one of the duplicates
102 }
103 }
104
105 m_entries.swap( tmp);
106}
void addFromDB(const BadChanVec &stateVec)
void setFromDB(const BadChanVec &stateVec, CoolChannelEnum chan)
Set cool channel from vector<BadChanEntry>, for example when reading from DB.
void add(const BadChanEntry &entry, CoolChannelEnum chan)
Add a bad channel entry to a specified cool channel data.
std::pair< HWIdentifier, LArBadChannel > BadChanEntry
static std::string coolChannelName(CoolChannelEnum chan)
static void mergeFlags(BadChanEntry &a, const BadChanEntry &b)
void addFromDB(const BadChanVec &stateVec, CoolChannelEnum chan)
Add a complete cool channel from DB, with duplicate removal.
void reset()
Reset to an empty state, erasing all data in all cool channels.
std::vector< CoolChannelData > m_DataVec