CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDQMChannelQuality.cc
Go to the documentation of this file.
1 #include <iostream>
2 
5 
7  : mSorted (false) {}
8 
10 
11 HcalDQMChannelQuality::Quality HcalDQMChannelQuality::quality (unsigned long fId, bool fWarning) const {
12  Item target;
13  target.mId = fId;
14  std::vector<Item>::const_iterator cell;
15  if (sorted ()) {
16  cell = std::lower_bound (mItems.begin(), mItems.end(), target);
17  }
18  else {
19  if (fWarning) std::cerr << "HcalDQMChannelQuality::quality-> container is not sorted. Sort it to search effectively" << std::endl;
20  cell = std::find (mItems.begin(), mItems.end(), target);
21  }
22  if (cell == mItems.end() || cell->mId != fId)
23  throw cms::Exception ("Conditions not found") << "Unavailable Quality for cell " << fId;
24  return (HcalDQMChannelQuality::Quality) cell->mQuality;
25 }
26 
27 bool HcalDQMChannelQuality::isMasked (unsigned long fId, bool fWarning) const{
28 
29  Item target;
30  target.mId = fId;
31  std::vector<Item>::const_iterator cell;
32  if (sorted ()) {
33  cell = std::lower_bound (mItems.begin(), mItems.end(), target);
34  }
35  else {
36  if (fWarning) std::cerr << "HcalDQMChannelQuality::quality-> container is not sorted. Sort it to search effectively" << std::endl;
37  cell = std::find (mItems.begin(), mItems.end(), target);
38  }
39  if (cell == mItems.end() || cell->mId != fId)
40  throw cms::Exception ("Conditions not found") << "Unavailable Quality for cell " << fId;
41  return cell->mMasked;
42 
43 }
44 
45 unsigned short HcalDQMChannelQuality::flagAlgo (unsigned long fId, bool fWarning) const{
46 
47  Item target;
48  target.mId = fId;
49  std::vector<Item>::const_iterator cell;
50  if (sorted ()) {
51  cell = std::lower_bound (mItems.begin(), mItems.end(), target);
52  }
53  else {
54  if (fWarning) std::cerr << "HcalDQMChannelQuality::quality-> container is not sorted. Sort it to search effectively" << std::endl;
55  cell = std::find (mItems.begin(), mItems.end(), target);
56  }
57  if (cell == mItems.end() || cell->mId != fId)
58  throw cms::Exception ("Conditions not found") << "Unavailable Quality for cell " << fId;
59  return cell->mAlgo;
60 
61 }
62 
63 std::vector<unsigned long> HcalDQMChannelQuality::getAllChannels () const {
64  std::vector<unsigned long> result;
65  for (std::vector<Item>::const_iterator item = mItems.begin (); item != mItems.end (); item++) {
66  result.push_back (item->mId);
67  }
68  return result;
69 }
70 
71 bool HcalDQMChannelQuality::setChannel (unsigned long fId, unsigned short fAlgo, Quality fQuality) {
72  Item item;
73  item.mId = fId;
74  item.mAlgo = fAlgo;
75  item.mMasked = maskCell(fQuality);
76  item.mQuality = unsigned (fQuality);
77  mSorted = false;
78  return true;
79 }
80 
82  switch (fQuality) {
83  case BAD: return true;
84  case HOT: return true;
85  case GOOD: return false;
86  case COOL: return false;
87  case DEAD: return false;
88  case END: return false;
89  default: return false;
90  }
91 }
92 
94  if (!mSorted) {
95  std::sort (mItems.begin(), mItems.end());
96  mSorted = true;
97  }
98 }
99 
100 const char* HcalDQMChannelQuality::str (Quality fQuality) {
101  switch (fQuality) {
102  case BAD: return "BAD";
103  case GOOD: return "GOOD";
104  case COOL: return "COOL";
105  case HOT: return "HOT";
106  case DEAD: return "DEAD";
107  case END: return "END";
108  default: return "UNKNOWN";
109  }
110 }
unsigned short flagAlgo(unsigned long fId, bool fWarning=true) const
std::vector< Item > mItems
Quality quality(unsigned long fId, bool fWarning=true) const
static const char * str(Quality fQuality)
bool maskCell(Quality fQual) const
bool setChannel(unsigned long fId, unsigned short algo, Quality fQuality=UNKNOWN)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
tuple result
Definition: mps_fire.py:83
std::vector< unsigned long > getAllChannels() const
bool isMasked(unsigned long fId, bool fWarning=true) const
volatile std::atomic< bool > shutdown_flag false