CMS 3D CMS Logo

HcalDcsValues.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <set>
4 
6  : mHBsorted(false), mHEsorted(false), mHO0sorted(false), mHO12sorted(false), mHFsorted(false) {}
7 
9 
11  HcalDcsDetId tempId(newVal.DcsId());
12  switch (tempId.subdet()) {
13  case HcalDcsBarrel:
14  mHBValues.push_back(newVal);
15  mHBsorted = false;
16  return true;
17  case HcalDcsEndcap:
18  mHEValues.push_back(newVal);
19  mHEsorted = false;
20  return true;
21  case HcalDcsOuter:
22  if (tempId.ring() == 0) {
23  mHO0Values.push_back(newVal);
24  mHO0sorted = false;
25  } else {
26  mHO12Values.push_back(newVal);
27  mHO12sorted = false;
28  }
29  return true;
30  case HcalDcsForward:
31  mHFValues.push_back(newVal);
32  mHFsorted = false;
33  return true;
34  default:
35  return false;
36  }
37 }
38 
45 }
46 
48  switch (fid.subdet()) {
49  case HcalDcsBarrel:
50  if (!mHBsorted)
52  return foundDcsId(mHBValues, fid);
53  case HcalDcsEndcap:
54  if (!mHEsorted)
56  return foundDcsId(mHEValues, fid);
57  case HcalDcsOuter:
58  if (fid.ring() == 0) {
59  if (!mHO0sorted)
61  return foundDcsId(mHO0Values, fid);
62  } else {
63  if (!mHO12sorted)
65  return foundDcsId(mHO12Values, fid);
66  }
67  case HcalDcsForward:
68  if (!mHFsorted)
70  return foundDcsId(mHBValues, fid);
71  default:
72  return false;
73  }
74 }
75 
77  DcsSet* valList = nullptr;
78  switch (fid.subdet()) {
79  case HcalDcsBarrel:
80  valList = &mHBValues;
81  if (!mHBsorted)
83  break;
84  case HcalDcsEndcap:
85  valList = &mHEValues;
86  if (!mHEsorted)
88  break;
89  case HcalDcsOuter:
90  if (fid.ring() == 0) {
91  valList = &mHO0Values;
92  if (!mHO0sorted)
94  } else {
95  valList = &mHO12Values;
96  if (!mHO12sorted)
98  }
99  break;
100  case HcalDcsForward:
101  valList = &mHFValues;
102  if (!mHFsorted)
104  break;
105  default:
106  valList = nullptr;
107  }
108 
109  if (valList) {
110  HcalDcsValue dummy(fid.rawId(), -1, 0., 0., 0.);
111  DcsSet::const_iterator lb = lower_bound(valList->begin(), valList->end(), dummy);
112  if ((lb != valList->end()) && (lb->DcsId() == fid.rawId())) {
113  DcsSet::const_iterator ub = upper_bound(valList->begin(), valList->end(), dummy);
114  return DcsSet(lb, ub);
115  }
116  }
117  return DcsSet();
118 }
119 
120 // std::set<uint32_t> HcalDcsValues::getAllIds() const {
121 // std::set<uint32_t> chans;
122 // std::pair< set<uint32_t>::iterator, bool > retVal;
123 // std::set<uint32_t>::iterator currId = 0;
124 // DcsSet::const_iterator currRec;
125 // for (currRec = mHBValues.begin(); currRec != mHBValues.end(); ++currRec) {
126 // if (!currId) {
127 // retVal = chans.insert(currRec->DcsId());
128 // currId = retVal.first;
129 // } else
130 // currId = chans.insert(currId, currRec->Dcs());
131 // }
132 // for (currRec = mHEValues.begin(); currRec != mHEValues.end(); ++currRec) {
133 // if (!currId) {
134 // retVal = chans.insert(currRec->DcsId());
135 // currId = retVal.first;
136 // } else
137 // currId = chans.insert(currId, currRec->Dcs());
138 // }
139 // for (currRec = mHO0Values.begin(); currRec != mHO0Values.end(); ++currRec) {
140 // if (!currId) {
141 // retVal = chans.insert(currRec->DcsId());
142 // currId = retVal.first;
143 // } else
144 // currId = chans.insert(currId, currRec->Dcs());
145 // }
146 // for (currRec = mHO12Values.begin(); currRec != mHO12Values.end(); ++currRec) {
147 // if (!currId) {
148 // retVal = chans.insert(currRec->DcsId());
149 // currId = retVal.first;
150 // } else
151 // currId = chans.insert(currId, currRec->Dcs());
152 // }
153 // for (currRec = mHFValues.begin(); currRec != mHFValues.end(); ++currRec) {
154 // if (!currId) {
155 // retVal = chans.insert(currRec->DcsId());
156 // currId = retVal.first;
157 // } else
158 // currId = chans.insert(currId, currRec->Dcs());
159 // }
160 // return chans;
161 // }
162 
164  switch (subd) {
165  case HcalHB:
166  return mHBValues;
167  case HcalHE:
168  return mHEValues;
169  case HcalHO0:
170  return mHO0Values;
171  case HcalHO12:
172  return mHO12Values;
173  case HcalHF:
174  return mHFValues;
175  }
176  return mHBValues;
177 }
178 
180  switch (subd) {
181  case HcalHB:
182  if (!mHBsorted)
184  return subDetOk(mHBValues, LS);
185  case HcalHE:
186  if (!mHEsorted)
188  return subDetOk(mHEValues, LS);
189  case HcalHO0:
190  if (!mHO0sorted)
192  return subDetOk(mHO0Values, LS);
193  case HcalHO12:
194  if (!mHO12sorted)
196  return subDetOk(mHO12Values, LS);
197  case HcalHF:
198  if (!mHFsorted)
200  return subDetOk(mHFValues, LS);
201  default:
202  return false;
203  }
204  return false;
205 }
206 
207 bool HcalDcsValues::foundDcsId(DcsSet const& valList, HcalDcsDetId const& fid) const {
208  HcalDcsValue dummy(fid.rawId(), -1, 0., 0., 0.);
209  DcsSet::const_iterator lb = lower_bound(valList.begin(), valList.end(), dummy);
210  if ((lb != valList.end()) && (lb->DcsId() == fid.rawId()))
211  return true;
212  return false;
213 }
214 
215 bool HcalDcsValues::subDetOk(DcsSet const& valList, int LS) const {
216  std::set<uint32_t> badIds;
217  DcsSet::const_iterator val = valList.begin();
218  while ((val != valList.end()) && ((LS > -1) ? (val->LS() <= LS) : true)) {
219  if (!val->isValueGood()) {
220  badIds.insert(val->DcsId());
221  } else {
222  std::set<uint32_t>::iterator fnd = badIds.find(val->DcsId());
223  if (*fnd == val->DcsId())
224  badIds.erase(fnd);
225  }
226  ++val;
227  }
228  return (badIds.empty());
229 }
230 
231 bool HcalDcsValues::sortList(DcsSet& valList) const {
232  sort(valList.begin(), valList.end());
233  return true;
234 }
uint32_t DcsId() const
Definition: HcalDcsValue.h:18
bool foundDcsId(DcsSet const &valList, HcalDcsDetId const &fid) const
DcsSet getValues(HcalDcsDetId const &fid)
bool subDetOk(DcsSet const &valList, int LS) const
bool exists(HcalDcsDetId const &fid)
DcsSet mHO0Values
Definition: HcalDcsValues.h:63
int ring() const
Definition: HcalDcsDetId.h:55
std::vector< HcalDcsValue > DcsSet
Definition: HcalDcsValues.h:27
DcsSet mHFValues
Definition: HcalDcsValues.h:67
bool sortList(DcsSet &valList) const
bool DcsValuesOK(DcsSubDet subd, int LS=-1)
virtual ~HcalDcsValues()
Definition: HcalDcsValues.cc:8
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
bool addValue(HcalDcsValue const &newVal)
DcsSet mHBValues
Definition: HcalDcsValues.h:59
DcsSet const & getAllSubdetValues(DcsSubDet subd) const
DcsSet mHO12Values
Definition: HcalDcsValues.h:65
HcalOtherSubdetector subdet() const
get the category
DcsSet mHEValues
Definition: HcalDcsValues.h:61