ATLAS Offline Software
BadChanContainerHashed.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef BadChanContainerHashed_H
6 #define BadChanContainerHashed_H
7 
8 template <class Chan, class State, class Hasher>
10 public:
11 
12  typedef std::pair<Chan,State> BadChanEntry;
13  typedef std::vector<BadChanEntry> BadChanVec;
14  typedef typename BadChanVec::const_iterator const_iterator;
15  typedef typename BadChanVec::size_type size_type;
16 
17 public:
18 
20 
21  explicit BadChanContainerHashed( const Hasher& h) : m_hasher(h) {}
22 
24 
25  State status( const Chan& channel) const;
26 
27  State status( const Chan& feb, int ch) const {return m_vec.at( m_hasher.hash( feb, ch));}
28 
29  const_iterator begin() const {return m_bcv.begin();}
30  const_iterator end() const {return m_bcv.end();}
31  size_type size() const {return m_bcv.size();}
32 
34  void clear() {m_vec.clear(); m_bcv.clear();}
35 
36  void set( const BadChanVec& cont);
37 
38  void setHasher( const Hasher& hasher) { m_hasher = hasher;}
39 
40 private:
41 
42  typedef unsigned int HashType;
43 
44  std::vector<State> m_vec;
45  Hasher m_hasher;
47 
48  // these methods should move to a Hasher class
49  HashType hash( Chan ch) const {return m_hasher.hash(ch);}
50  // Chan unhash( HashType h) const;
51  HashType maxHash() const {return m_hasher.maxHash();}
52 
53 };
54 
55 template <class Chan, class State, class Hasher>
57 {
58  return m_vec[ hash( channel)];
59 }
60 
61 template <class Chan, class State, class Hasher>
63 {
64  State good; // default constructed state is good
65  if (m_vec.size() == maxHash()) {
66  for (typename std::vector<State>::iterator i=m_vec.begin(); i!=m_vec.end(); ++i) {
67  *i = good; // reset all channels to good
68  }
69  }
70  else {
71  std::vector<State> tmp( maxHash(), good); // all channels good
72  m_vec.swap(tmp);
73  }
74  for (typename BadChanVec::const_iterator i=cont.begin(); i!=cont.end(); ++i) {
75  // m_vec.at( hash( i->first)) = i->second; // skip invalid hash values
76  HashType h = hash( i->first);
77  if (h < maxHash()) m_vec[h] = i->second;
78  }
79 
80  m_bcv = cont;
81 }
82 
83 
84 #endif
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
BadChanContainerHashed::BadChanContainerHashed
BadChanContainerHashed(const Hasher &h)
Definition: BadChanContainerHashed.h:21
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
BadChanContainerHashed::begin
const_iterator begin() const
Definition: BadChanContainerHashed.h:29
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
BadChanContainerHashed::setHasher
void setHasher(const Hasher &hasher)
Definition: BadChanContainerHashed.h:38
BadChanContainerHashed::clear
void clear()
Deletes the contents and sets size to 0 (same as stl::vector<T>::clear())
Definition: BadChanContainerHashed.h:34
BadChanContainerHashed::BadChanVec
std::vector< BadChanEntry > BadChanVec
Definition: BadChanContainerHashed.h:13
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
BadChanContainerHashed::BadChanContainerHashed
BadChanContainerHashed(const BadChanVec &vec)
Definition: BadChanContainerHashed.h:23
BadChanContainerHashed::set
void set(const BadChanVec &cont)
Definition: BadChanContainerHashed.h:62
BadChanContainerHashed::hash
HashType hash(Chan ch) const
Definition: BadChanContainerHashed.h:49
BadChanContainerHashed::HashType
unsigned int HashType
Definition: BadChanContainerHashed.h:42
BadChanContainerHashed::status
State status(const Chan &feb, int ch) const
Definition: BadChanContainerHashed.h:27
BadChanContainerHashed::BadChanEntry
std::pair< Chan, State > BadChanEntry
Definition: BadChanContainerHashed.h:12
BadChanContainerHashed::BadChanContainerHashed
BadChanContainerHashed()
Definition: BadChanContainerHashed.h:19
lumiFormat.i
int i
Definition: lumiFormat.py:92
BadChanContainerHashed::end
const_iterator end() const
Definition: BadChanContainerHashed.h:30
extractSporadic.h
list h
Definition: extractSporadic.py:97
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
BadChanContainerHashed::status
State status(const Chan &channel) const
Definition: BadChanContainerHashed.h:56
BadChanContainerHashed::m_bcv
BadChanVec m_bcv
Definition: BadChanContainerHashed.h:46
BadChanContainerHashed::m_vec
std::vector< State > m_vec
Definition: BadChanContainerHashed.h:44
BadChanContainerHashed::const_iterator
BadChanVec::const_iterator const_iterator
Definition: BadChanContainerHashed.h:14
ReadBchFromCool.good
good
Definition: ReadBchFromCool.py:433
h
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
BadChanContainerHashed::size_type
BadChanVec::size_type size_type
Definition: BadChanContainerHashed.h:15
BadChanContainerHashed::maxHash
HashType maxHash() const
Definition: BadChanContainerHashed.h:51
BadChanContainerHashed::size
size_type size() const
Definition: BadChanContainerHashed.h:31
BadChanContainerHashed
Definition: BadChanContainerHashed.h:9
BadChanContainerHashed::m_hasher
Hasher m_hasher
Definition: BadChanContainerHashed.h:45