ATLAS Offline Software
Loading...
Searching...
No Matches
LArBadChannelCont.icc
Go to the documentation of this file.
1//Dear emacs, this is -*-c++-*-
2/*
3 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
4*/
5
6
7//Constructor with payload
8template<class LArBC_t>
9LArBadXCont<LArBC_t>::LArBadXCont( const BadChanVec& vec):
10 m_cont(vec) {
11 sort();
12}
13
14//Add a bad channel to the list of bad channels (no sorting!)
15template<class LArBC_t>
16void 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));
18 return;
19}
20
21template<class LArBC_t>
22void LArBadXCont<LArBC_t>::setOflVec(BadChanVec& input) {
23 m_oflCont.swap(input);
24 std::sort(m_oflCont.begin(), m_oflCont.end(), ChannelLess());
25 return;
26}
27
28//Sorting method (call before recording!)
29template<class LArBC_t>
30void LArBadXCont<LArBC_t>::sort() {
31 std::sort(m_cont.begin(), m_cont.end(), ChannelLess());
32
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()) {
37 auto it2=it+1;
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
41 }
42 else
43 ++it;
44 }
45 }//end if got at least 2 entries
46}
47
48//Main client acess method: Check the bad-channel status
49template<class LArBC_t>
50LArBC_t LArBadXCont<LArBC_t>::status(const HWIdentifier hwid) const {
51
52 const ChanId_t channel=hwid.get_identifier32().get_compact();
53
54 const_iterator i =
55 std::lower_bound( m_cont.begin(), m_cont.end(), BadChanEntry( channel,(LArBC_t) 0),
56 ChannelLess());
57 if (i != m_cont.end() && i->first == channel) {
58 return i->second;
59 }
60 else {
61 return LArBC_t(0);
62 }
63}
64
65//Client acess method: Check the bad-channel status by offline id
66template<class LArBC_t>
67LArBC_t LArBadXCont<LArBC_t>::offlineStatus(const Identifier id) const {
68
69 const ChanId_t channel=id.get_identifier32().get_compact();
70
71 const_iterator i =
72 std::lower_bound( m_oflCont.begin(), m_oflCont.end(), BadChanEntry( channel,(LArBC_t) 0),
73 ChannelLess());
74 if (i != m_oflCont.end() && i->first == channel) {
75 return i->second;
76 }
77 else {
78 return LArBC_t(0);
79 }
80}