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),
7  mHFsorted(false) {
8 }
9 
11 }
12 
14  HcalDcsDetId tempId( newVal.DcsId() );
15  switch (tempId.subdet()) {
16  case HcalDcsBarrel :
17  mHBValues.push_back(newVal);
18  mHBsorted=false;
19  return true;
20  case HcalDcsEndcap :
21  mHEValues.push_back(newVal);
22  mHEsorted=false;
23  return true;
24  case HcalDcsOuter :
25  if (tempId.ring() == 0) {
26  mHO0Values.push_back(newVal);
27  mHO0sorted=false;
28  } else {
29  mHO12Values.push_back(newVal);
30  mHO12sorted=false;
31  }
32  return true;
33  case HcalDcsForward :
34  mHFValues.push_back(newVal);
35  mHFsorted=false;
36  return true;
37  default :
38  return false;
39  }
40 }
41 
48 }
49 
51  switch (fid.subdet()) {
52  case HcalDcsBarrel :
54  return foundDcsId(mHBValues, fid);
55  case HcalDcsEndcap :
57  return foundDcsId(mHEValues, fid);
58  case HcalDcsOuter :
59  if (fid.ring() == 0) {
61  return foundDcsId(mHO0Values, fid);
62  } else {
64  return foundDcsId(mHO12Values, fid);
65  }
66  case HcalDcsForward :
68  return foundDcsId(mHBValues, fid);
69  default : return false;
70  }
71 }
72 
74  DcsSet * valList = nullptr;
75  switch(fid.subdet()) {
76  case HcalDcsBarrel :
77  valList = &mHBValues;
79  break;
80  case HcalDcsEndcap :
81  valList = &mHEValues;
83  break;
84  case HcalDcsOuter :
85  if (fid.ring() == 0) {
86  valList = &mHO0Values;
88  } else {
89  valList = &mHO12Values;
91  }
92  break;
93  case HcalDcsForward :
94  valList = &mHFValues;
96  break;
97  default : valList = nullptr;
98  }
99 
100  if (valList) {
101  HcalDcsValue dummy(fid.rawId(), -1, 0., 0., 0.);
102  DcsSet::const_iterator lb = lower_bound(valList->begin(), valList->end(), dummy);
103  if ((lb != valList->end()) && (lb->DcsId() == fid.rawId())) {
104  DcsSet::const_iterator ub = upper_bound(valList->begin(), valList->end(), dummy);
105  return DcsSet(lb, ub) ;
106  }
107  }
108  return DcsSet() ;
109 }
110 
111 // std::set<uint32_t> HcalDcsValues::getAllIds() const {
112 // std::set<uint32_t> chans;
113 // std::pair< set<uint32_t>::iterator, bool > retVal;
114 // std::set<uint32_t>::iterator currId = 0;
115 // DcsSet::const_iterator currRec;
116 // for (currRec = mHBValues.begin(); currRec != mHBValues.end(); ++currRec) {
117 // if (!currId) {
118 // retVal = chans.insert(currRec->DcsId());
119 // currId = retVal.first;
120 // } else
121 // currId = chans.insert(currId, currRec->Dcs());
122 // }
123 // for (currRec = mHEValues.begin(); currRec != mHEValues.end(); ++currRec) {
124 // if (!currId) {
125 // retVal = chans.insert(currRec->DcsId());
126 // currId = retVal.first;
127 // } else
128 // currId = chans.insert(currId, currRec->Dcs());
129 // }
130 // for (currRec = mHO0Values.begin(); currRec != mHO0Values.end(); ++currRec) {
131 // if (!currId) {
132 // retVal = chans.insert(currRec->DcsId());
133 // currId = retVal.first;
134 // } else
135 // currId = chans.insert(currId, currRec->Dcs());
136 // }
137 // for (currRec = mHO12Values.begin(); currRec != mHO12Values.end(); ++currRec) {
138 // if (!currId) {
139 // retVal = chans.insert(currRec->DcsId());
140 // currId = retVal.first;
141 // } else
142 // currId = chans.insert(currId, currRec->Dcs());
143 // }
144 // for (currRec = mHFValues.begin(); currRec != mHFValues.end(); ++currRec) {
145 // if (!currId) {
146 // retVal = chans.insert(currRec->DcsId());
147 // currId = retVal.first;
148 // } else
149 // currId = chans.insert(currId, currRec->Dcs());
150 // }
151 // return chans;
152 // }
153 
154 
156  switch (subd) {
157  case HcalHB : return mHBValues;
158  case HcalHE : return mHEValues;
159  case HcalHO0 : return mHO0Values;
160  case HcalHO12 : return mHO12Values;
161  case HcalHF : return mHFValues;
162  }
163  return mHBValues;
164 }
165 
167  switch (subd) {
168  case HcalHB :
170  return subDetOk(mHBValues, LS);
171  case HcalHE :
173  return subDetOk(mHEValues, LS);
174  case HcalHO0 :
176  return subDetOk(mHO0Values, LS);
177  case HcalHO12 :
179  return subDetOk(mHO12Values, LS);
180  case HcalHF :
182  return subDetOk(mHFValues, LS);
183  default : return false;
184  }
185  return false;
186 }
187 
188 bool HcalDcsValues::foundDcsId(DcsSet const& valList,
189  HcalDcsDetId const& fid) const {
190  HcalDcsValue dummy(fid.rawId(), -1, 0., 0., 0.);
191  DcsSet::const_iterator lb = lower_bound(valList.begin(), valList.end(), dummy);
192  if ((lb != valList.end()) && (lb->DcsId() == fid.rawId()))
193  return true;
194  return false;
195 }
196 
197 bool HcalDcsValues::subDetOk(DcsSet const& valList, int LS) const {
198  std::set<uint32_t> badIds;
199  DcsSet::const_iterator val = valList.begin();
200  while ( (val != valList.end()) &&
201  ( (LS>-1) ? (val->LS()<=LS) : true) ) {
202  if (!val->isValueGood()) {
203  badIds.insert(val->DcsId());
204  } else {
205  std::set<uint32_t>::iterator fnd = badIds.find(val->DcsId());
206  if (*fnd == val->DcsId()) badIds.erase(fnd);
207  }
208  ++val;
209  }
210  return (badIds.empty());
211 }
212 
213 bool HcalDcsValues::sortList(DcsSet& valList) const {
214  sort(valList.begin(), valList.end());
215  return true;
216 }
uint32_t DcsId() const
Definition: HcalDcsValue.h:20
DcsSet getValues(HcalDcsDetId const &fid)
bool exists(HcalDcsDetId const &fid)
DcsSet const & getAllSubdetValues(DcsSubDet subd) const
DcsSet mHO0Values
Definition: HcalDcsValues.h:64
bool foundDcsId(DcsSet const &valList, HcalDcsDetId const &fid) const
uint32_t rawId() const
get the raw id
Definition: DetId.h:44
std::vector< HcalDcsValue > DcsSet
Definition: HcalDcsValues.h:27
DcsSet mHFValues
Definition: HcalDcsValues.h:68
bool DcsValuesOK(DcsSubDet subd, int LS=-1)
HcalOtherSubdetector subdet() const
get the category
virtual ~HcalDcsValues()
bool addValue(HcalDcsValue const &newVal)
DcsSet mHBValues
Definition: HcalDcsValues.h:60
bool sortList(DcsSet &valList) const
bool subDetOk(DcsSet const &valList, int LS) const
int ring() const
Definition: HcalDcsDetId.h:46
DcsSet mHO12Values
Definition: HcalDcsValues.h:66
DcsSet mHEValues
Definition: HcalDcsValues.h:62