1 //Dear emacs, this is -*-c++-*-
3 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
7 //Constructor with payload
8 template<class LArBC_t>
9 LArBadXCont<LArBC_t>::LArBadXCont( const BadChanVec& vec):
14 //Add a bad channel to the list of bad channels (no sorting!)
15 template<class LArBC_t>
16 void LArBadXCont<LArBC_t>::add(const HWIdentifier hwid, const LArBC_t stat) {
17 m_cont.push_back(std::make_pair(hwid.get_identifier32().get_compact(),stat));
21 template<class LArBC_t>
22 void LArBadXCont<LArBC_t>::setOflVec(BadChanVec& input) {
23 m_oflCont.swap(input);
24 std::sort(m_oflCont.begin(), m_oflCont.end(), ChannelLess());
28 //Sorting method (call before recording!)
29 template<class LArBC_t>
30 void LArBadXCont<LArBC_t>::sort() {
31 std::sort(m_cont.begin(), m_cont.end(), ChannelLess());
33 //Merge duplicate entries is needed ...
34 if (m_cont.size()>1) { //got at least 2 entries
35 auto it=m_cont.begin();
36 while (it+1!=m_cont.end()) {
38 if (it->first==it2->first) {//Same channel number
39 it2->second|=it->second; //Merge (logical-or) bad channel status ...
40 it=m_cont.erase(it); //... and delete first instance
45 }//end if got at least 2 entries
48 //Main client acess method: Check the bad-channel status
49 template<class LArBC_t>
50 LArBC_t LArBadXCont<LArBC_t>::status(const HWIdentifier hwid) const {
52 const ChanId_t channel=hwid.get_identifier32().get_compact();
55 std::lower_bound( m_cont.begin(), m_cont.end(), BadChanEntry( channel,(LArBC_t) 0),
57 if (i != m_cont.end() && i->first == channel) {
65 //Client acess method: Check the bad-channel status by offline id
66 template<class LArBC_t>
67 LArBC_t LArBadXCont<LArBC_t>::offlineStatus(const Identifier id) const {
69 const ChanId_t channel=id.get_identifier32().get_compact();
72 std::lower_bound( m_oflCont.begin(), m_oflCont.end(), BadChanEntry( channel,(LArBC_t) 0),
74 if (i != m_oflCont.end() && i->first == channel) {