CMS 3D CMS Logo

StatusManager.cc
Go to the documentation of this file.
2 
4 
6 
8 
13 
14 #include "TPRegexp.h"
15 #include "TObjArray.h"
16 #include "TString.h"
17 
18 namespace ecaldqm
19 {
20 
22  dictionary_(),
23  status_()
24  {
25  dictionary_["CH_ID_ERROR"] = 0x1 << EcalDQMStatusHelper::CH_ID_ERROR;
26  dictionary_["CH_GAIN_ZERO_ERROR"] = 0x1 << EcalDQMStatusHelper::CH_GAIN_ZERO_ERROR;
27  dictionary_["CH_GAIN_SWITCH_ERROR"] = 0x1 << EcalDQMStatusHelper::CH_GAIN_SWITCH_ERROR;
28  dictionary_["TT_ID_ERROR"] = 0x1 << EcalDQMStatusHelper::TT_ID_ERROR;
29  dictionary_["TT_SIZE_ERROR"] = 0x1 << EcalDQMStatusHelper::TT_SIZE_ERROR;
30 
31  dictionary_["PEDESTAL_LOW_GAIN_MEAN_ERROR"] = 0x1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_MEAN_ERROR;
32  dictionary_["PEDESTAL_MIDDLE_GAIN_MEAN_ERROR"] = 0x1 << EcalDQMStatusHelper::PEDESTAL_MIDDLE_GAIN_MEAN_ERROR;
33  dictionary_["PEDESTAL_HIGH_GAIN_MEAN_ERROR"] = 0x1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_MEAN_ERROR;
34  dictionary_["PEDESTAL_LOW_GAIN_RMS_ERROR"] = 0x1 << EcalDQMStatusHelper::PEDESTAL_LOW_GAIN_RMS_ERROR;
35  dictionary_["PEDESTAL_MIDDLE_GAIN_RMS_ERROR"] = 0x1 << EcalDQMStatusHelper::PEDESTAL_MIDDLE_GAIN_RMS_ERROR;
36  dictionary_["PEDESTAL_HIGH_GAIN_RMS_ERROR"] = 0x1 << EcalDQMStatusHelper::PEDESTAL_HIGH_GAIN_RMS_ERROR;
37 
38  dictionary_["PEDESTAL_ONLINE_HIGH_GAIN_MEAN_ERROR"] = 0x1 << EcalDQMStatusHelper::PEDESTAL_ONLINE_HIGH_GAIN_MEAN_ERROR;
39  dictionary_["PEDESTAL_ONLINE_HIGH_GAIN_RMS_ERROR"] = 0x1 << EcalDQMStatusHelper::PEDESTAL_ONLINE_HIGH_GAIN_RMS_ERROR;
40 
41  dictionary_["TESTPULSE_LOW_GAIN_MEAN_ERROR"] = 0x1 << EcalDQMStatusHelper::TESTPULSE_LOW_GAIN_MEAN_ERROR;
42  dictionary_["TESTPULSE_MIDDLE_GAIN_MEAN_ERROR"] = 0x1 << EcalDQMStatusHelper::TESTPULSE_MIDDLE_GAIN_MEAN_ERROR;
43  dictionary_["TESTPULSE_HIGH_GAIN_MEAN_ERROR"] = 0x1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_MEAN_ERROR;
44  dictionary_["TESTPULSE_LOW_GAIN_RMS_ERROR"] = 0x1 << EcalDQMStatusHelper::TESTPULSE_LOW_GAIN_RMS_ERROR;
45  dictionary_["TESTPULSE_MIDDLE_GAIN_RMS_ERROR"] = 0x1 << EcalDQMStatusHelper::TESTPULSE_MIDDLE_GAIN_RMS_ERROR;
46  dictionary_["TESTPULSE_HIGH_GAIN_RMS_ERROR"] = 0x1 << EcalDQMStatusHelper::TESTPULSE_HIGH_GAIN_RMS_ERROR;
47 
48  dictionary_["LASER_MEAN_ERROR"] = 0x1 << EcalDQMStatusHelper::LASER_MEAN_ERROR;
49  dictionary_["LASER_RMS_ERROR"] = 0x1 << EcalDQMStatusHelper::LASER_RMS_ERROR;
50  dictionary_["LASER_TIMING_MEAN_ERROR"] = 0x1 << EcalDQMStatusHelper::LASER_TIMING_MEAN_ERROR;
51  dictionary_["LASER_TIMING_RMS_ERROR"] = 0x1 << EcalDQMStatusHelper::LASER_TIMING_RMS_ERROR;
52 
53  dictionary_["LED_MEAN_ERROR"] = 0x1 << EcalDQMStatusHelper::LED_MEAN_ERROR;
54  dictionary_["LED_RMS_ERROR"] = 0x1 << EcalDQMStatusHelper::LED_RMS_ERROR;
55  dictionary_["LED_TIMING_MEAN_ERROR"] = 0x1 << EcalDQMStatusHelper::LED_TIMING_MEAN_ERROR;
56  dictionary_["LED_TIMING_RMS_ERROR"] = 0x1 << EcalDQMStatusHelper::LED_TIMING_RMS_ERROR;
57 
58  dictionary_["STATUS_FLAG_ERROR"] = 0x1 << EcalDQMStatusHelper::STATUS_FLAG_ERROR;
59 
60  dictionary_["PHYSICS_BAD_CHANNEL_WARNING"] = 0x1 << EcalDQMStatusHelper::PHYSICS_BAD_CHANNEL_WARNING;
61  dictionary_["PHYSICS_BAD_CHANNEL_ERROR"] = 0x1 << EcalDQMStatusHelper::PHYSICS_BAD_CHANNEL_ERROR;
62 
63  dictionary_["disabled_channel"] =
76 
77  dictionary_["dead_channel"] =
102 
103  dictionary_["pedestal_problem"] =
112 
113  dictionary_["testpulse_problem"] =
120 
121  dictionary_["laser_problem"] =
126 
127  dictionary_["led_problem"] =
132 
133  dictionary_["noise_problem"] =
139  }
140 
141  void
142  StatusManager::readFromStream(std::istream& _input)
143  {
144  TPRegexp linePat("^[ ]*(Crystal|TT|PN)[ ]+(EB[0-9+-]*|EE[0-9+-]*|[0-9]+)[ ]+([0-9]+)[ ]([a-zA-Z_]+)");
145 
147  while(true){
148  std::getline(_input, line);
149  if(!_input.good()) break;
150 
151  if(!linePat.MatchB(line)) continue;
152 
153  TObjArray* matches(linePat.MatchS(line));
154  TString channelType(matches->At(1)->GetName());
155  TString module(matches->At(2)->GetName());
156  unsigned channel(TString(matches->At(3)->GetName()).Atoi());
157  TString statusName(matches->At(4)->GetName());
158  delete matches;
159 
160  std::map<std::string, uint32_t>::const_iterator dItr(dictionary_.find(statusName.Data()));
161  if(dItr == dictionary_.end()) continue;
162  uint32_t statusVal(dItr->second);
163 
164  if(channelType == "Crystal"){
165  // module: Subdetector name, channel: dense ID
166  // Store using EBDetId and EEDetId as keys (following EcalDQMChannelStatus)
167 
168  if(module == "EB"){
169  if(!EBDetId::validDenseIndex(channel)) continue;
170  status_.insert(std::pair<uint32_t, uint32_t>(EBDetId::unhashIndex(channel).rawId(), statusVal));
171  }
172  else if(module == "EE"){
173  if(!EEDetId::validDenseIndex(channel)) continue;
174  status_.insert(std::pair<uint32_t, uint32_t>(EEDetId::unhashIndex(channel).rawId(), statusVal));
175  }
176  }
177  else if(channelType == "TT"){
178  // module: Supermodule name, channel: RU ID (electronics ID tower)
179  // Store using EcalTrigTowerDetId and EcalScDetId as keys (following EcalDQMTowerStatus)
180 
181  if(module.Contains("EB")){
182  /* TODO CHECK THIS */
183 
184  int iEta((channel - 1) / 4 + 1);
185  int zside(0);
186  int iPhi(0);
187  if(module(3) == '-'){
188  zside = -1;
189  iPhi = (channel - 1) % 4 + 1;
190  }
191  else{
192  zside = 1;
193  iPhi = (68 - channel) % 4 + 1;
194  }
195 
196  status_.insert(std::pair<uint32_t, uint32_t>(EcalTrigTowerDetId(zside, EcalBarrel, iEta, iPhi).rawId(), statusVal));
197  }
198  else if(module.Contains("EE")){
199  std::vector<EcalScDetId> scIds(getElectronicsMap()->getEcalScDetId(dccId(module.Data()), channel, false));
200  for(unsigned iS(0); iS != scIds.size(); ++iS)
201  status_.insert(std::pair<uint32_t, uint32_t>(scIds[iS].rawId(), statusVal));
202  }
203  }
204  else if(channelType == "PN"){
205  // module: DCC ID, channel: iPN
206  // Store using EcalPnDiodeDetId as keys
207  unsigned iDCC(module.Atoi() - 1);
208  int subdet(iDCC <= kEEmHigh || iDCC >= kEEpLow ? EcalEndcap : EcalBarrel);
209  status_.insert(std::pair<uint32_t, uint32_t>(EcalPnDiodeDetId(subdet, iDCC + 1, channel).rawId(), statusVal));
210  }
211  }
212  }
213 
214  void
215  StatusManager::readFromObj(EcalDQMChannelStatus const& _channelStatus, EcalDQMTowerStatus const& _towerStatus)
216  {
217  EcalDQMChannelStatus::Items const& barrelChStatus(_channelStatus.barrelItems());
218  for(unsigned iC(0); iC != EBDetId::kSizeForDenseIndexing; ++iC)
219  status_.insert(std::pair<uint32_t, uint32_t>(EBDetId::unhashIndex(iC).rawId(), barrelChStatus[iC].getStatusCode()));
220 
221  EcalDQMChannelStatus::Items const& endcapChStatus(_channelStatus.endcapItems());
222  for(unsigned iC(0); iC != EEDetId::kSizeForDenseIndexing; ++iC)
223  status_.insert(std::pair<uint32_t, uint32_t>(EEDetId::unhashIndex(iC).rawId(), endcapChStatus[iC].getStatusCode()));
224 
225  EcalDQMTowerStatus::Items const& barrelTowStatus(_towerStatus.barrelItems());
226  for(unsigned iC(0); iC != EcalTrigTowerDetId::kEBTotalTowers; ++iC)
227  status_.insert(std::pair<uint32_t, uint32_t>(EcalTrigTowerDetId::detIdFromDenseIndex(iC).rawId(), barrelTowStatus[iC].getStatusCode()));
228 
229  EcalDQMTowerStatus::Items const& endcapTowStatus(_towerStatus.endcapItems());
230  for(unsigned iC(0); iC != EcalScDetId::kSizeForDenseIndexing; ++iC)
231  status_.insert(std::pair<uint32_t, uint32_t>(EcalScDetId::unhashIndex(iC).rawId(), endcapTowStatus[iC].getStatusCode()));
232  }
233 
234  void
235  StatusManager::writeToStream(std::ostream& _output) const
236  {
237 
238  }
239 
240  void
242  {
243  for(unsigned iC(0); iC != EBDetId::kSizeForDenseIndexing; ++iC){
244  uint32_t key(EBDetId::unhashIndex(iC).rawId());
245  _channelStatus.setValue(key, EcalDQMStatusCode(getStatus(key)));
246  }
247 
248  for(unsigned iC(0); iC != EEDetId::kSizeForDenseIndexing; ++iC){
249  uint32_t key(EEDetId::unhashIndex(iC).rawId());
250  _channelStatus.setValue(key, EcalDQMStatusCode(getStatus(key)));
251  }
252 
253  for(unsigned iC(0); iC != EcalTrigTowerDetId::kEBTotalTowers; ++iC){
255  _towerStatus.setValue(key, EcalDQMStatusCode(getStatus(key)));
256  }
257 
258  for(unsigned iC(0); iC != EcalScDetId::kSizeForDenseIndexing; ++iC){
259  uint32_t key(EcalScDetId::unhashIndex(iC));
260  _towerStatus.setValue(key, EcalDQMStatusCode(getStatus(key)));
261  }
262  }
263 
264  uint32_t
265  StatusManager::getStatus(uint32_t _key) const
266  {
267  std::map<uint32_t, uint32_t>::const_iterator itr(status_.find(_key));
268  if(itr == status_.end()) return 0;
269  return itr->second;
270  }
271 
272 }
static const int LED_MEAN_ERROR
static const int PEDESTAL_MIDDLE_GAIN_RMS_ERROR
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
static const int LASER_MEAN_ERROR
static const int TESTPULSE_LOW_GAIN_RMS_ERROR
static const int PHYSICS_BAD_CHANNEL_WARNING
void readFromStream(std::istream &)
uint32_t getStatus(uint32_t) const
static const int LASER_TIMING_RMS_ERROR
static const int PEDESTAL_HIGH_GAIN_MEAN_ERROR
const Items & barrelItems() const
EcalElectronicsMapping const * getElectronicsMap()
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
static const int PEDESTAL_ONLINE_HIGH_GAIN_RMS_ERROR
static EcalScDetId unhashIndex(int hi)
Definition: EcalScDetId.h:118
static const int PHYSICS_BAD_CHANNEL_ERROR
static const int TT_SIZE_ERROR
int zside(DetId const &)
static const int CH_GAIN_SWITCH_ERROR
static const int TESTPULSE_MIDDLE_GAIN_MEAN_ERROR
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:99
static const int PEDESTAL_LOW_GAIN_RMS_ERROR
std::map< std::string, uint32_t > dictionary_
Definition: StatusManager.h:28
void setValue(const uint32_t id, const Item &item)
static const int PEDESTAL_HIGH_GAIN_RMS_ERROR
static const int STATUS_FLAG_ERROR
void writeToStream(std::ostream &) const
void setValue(const uint32_t id, const Item &item)
static const int TESTPULSE_MIDDLE_GAIN_RMS_ERROR
static const int TESTPULSE_HIGH_GAIN_RMS_ERROR
static const int LED_TIMING_MEAN_ERROR
static const int PEDESTAL_LOW_GAIN_MEAN_ERROR
static const int TESTPULSE_LOW_GAIN_MEAN_ERROR
static const int LED_TIMING_RMS_ERROR
static const int CH_GAIN_ZERO_ERROR
static const int PEDESTAL_ONLINE_HIGH_GAIN_MEAN_ERROR
static const int LASER_TIMING_MEAN_ERROR
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:114
std::map< uint32_t, uint32_t > status_
Definition: StatusManager.h:29
static bool validDenseIndex(uint32_t din)
Definition: EEDetId.h:213
void writeToObj(EcalDQMChannelStatus &, EcalDQMTowerStatus &) const
static const int TT_ID_ERROR
static const int LED_RMS_ERROR
static const int PEDESTAL_MIDDLE_GAIN_MEAN_ERROR
static const int TESTPULSE_HIGH_GAIN_MEAN_ERROR
static const int LASER_RMS_ERROR
const Items & endcapItems() const
static const int CH_ID_ERROR
unsigned dccId(DetId const &)
Definition: vlib.h:208
void readFromObj(EcalDQMChannelStatus const &, EcalDQMTowerStatus const &)
static bool validDenseIndex(uint32_t din)
Definition: EBDetId.h:109