CMS 3D CMS Logo

CSCDQM_Summary.cc
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: Summary.cc
5  *
6  * Description: Class Summary implementation
7  *
8  * Version: 1.0
9  * Created: 05/19/2008 10:59:34 AM
10  * Revision: none
11  * Compiler: gcc
12  *
13  * Author: Valdas Rapsevicius (VR), Valdas.Rapsevicius@cern.ch
14  * Company: CERN, CH
15  *
16  * =====================================================================================
17  */
18 
19 #include "CSCDQM_Summary.h"
20 
21 namespace cscdqm {
22 
27 
32 
36  void Summary::Reset() {
37  Address adr;
38 
40  adr.mask.side = adr.mask.station = adr.mask.layer = false;
41  adr.mask.ring = adr.mask.chamber = adr.mask.cfeb = adr.mask.hv = true;
42  for (adr.ring = 1; adr.ring <= N_RINGS; adr.ring++) {
43  for (adr.chamber = 1; adr.chamber <= N_CHAMBERS; adr.chamber++) {
44  for (adr.cfeb = 1; adr.cfeb <= N_CFEBS; adr.cfeb++) {
45  for (adr.hv = 1; adr.hv <= N_HVS; adr.hv++) {
46  for (unsigned int bit = 0; bit < HWSTATUSBITSETSIZE; bit++) {
47  ReSetValue(adr, (HWStatusBit)bit);
48  }
49  }
50  }
51  }
52  }
53  }
54 
60  void Summary::ReadReportingChambers(const TH2*& h2, const double threshold) {
61  if (h2->GetXaxis()->GetXmin() <= 1 && h2->GetXaxis()->GetXmax() >= 36 && h2->GetYaxis()->GetXmin() <= 1 &&
62  h2->GetYaxis()->GetXmax() >= 18) {
63  Address adr;
64  double z = 0.0;
65 
66  for (unsigned int x = 1; x <= 36; x++) {
67  for (unsigned int y = 1; y <= 18; y++) {
68  z = h2->GetBinContent(x, y);
69  if (ChamberCoordsToAddress(x, y, adr)) {
70  if (z >= threshold) {
71  SetValue(adr, DATA);
72  } else {
73  ReSetValue(adr, DATA);
74  }
75  }
76  }
77  }
78  } else {
79  LOG_WARN << "cscdqm::Summary.ReadReportingChambers routine. Wrong histogram dimensions!";
80  }
81  }
82 
93  void Summary::ReadReportingChambersRef(const TH2*& h2,
94  const TH2*& refh2,
95  const double cold_coef,
96  const double cold_Sfail,
97  const double hot_coef,
98  const double hot_Sfail) {
99  if (h2->GetXaxis()->GetXmin() <= 1 && h2->GetXaxis()->GetXmax() >= 36 && h2->GetYaxis()->GetXmin() <= 1 &&
100  h2->GetYaxis()->GetXmax() >= 18 && refh2->GetXaxis()->GetXmin() <= 1 && refh2->GetXaxis()->GetXmax() >= 36 &&
101  refh2->GetYaxis()->GetXmin() <= 1 && refh2->GetYaxis()->GetXmax() >= 18) {
103  double num = 1.0, denum = 1.0;
104  for (unsigned int x = 1; x <= 36; x++) {
105  for (unsigned int y = 1; y <= 18; y++) {
106  double Nij = h2->GetBinContent(x, y);
107  double Nrefij = refh2->GetBinContent(x, y);
108  if (Nij > 0) {
109  num += Nrefij;
110  denum += pow(Nrefij, 2.0) / Nij;
111  }
112  }
113  }
114  double factor = num / denum;
115 
116  Address adr;
117  unsigned int N = 0, n = 0;
118 
119  for (unsigned int x = 1; x <= 36; x++) {
120  for (unsigned int y = 1; y <= 18; y++) {
121  N = int(refh2->GetBinContent(x, y) * factor);
122  n = int(h2->GetBinContent(x, y));
123 
124  if (ChamberCoordsToAddress(x, y, adr)) {
126  ReSetValue(adr, HOT);
127  ReSetValue(adr, COLD);
128 
129  if (n == 0) {
130  ReSetValue(adr, DATA);
131  } else {
132  SetValue(adr, DATA);
133  }
134 
135  switch (Utility::checkOccupancy(N, n, cold_coef, hot_coef, cold_Sfail, hot_Sfail)) {
136  case -1:
137  SetValue(adr, COLD);
138 
139  /*
140  std::cout << "adr = " << detector.AddressName(adr);
141  std::cout << ", x = " << x << ", y = " << y;
142  std::cout << ", value = " << GetValue(adr);
143  std::cout << ", refh2 = " << refh2->GetBinContent(x, y);
144  std::cout << ", factor = " << factor;
145  std::cout << ", N = " << N;
146  std::cout << ", n = " << n;
147  std::cout << ", num = " << num;
148  std::cout << ", denum = " << denum;
149  std::cout << ", rate = " << (N > 0 ? n / N : 0);
150  std::cout << ", cold_coef = " << cold_coef;
151  std::cout << ", = COLD";
152  std::cout << "\n";
153  */
154 
155  break;
156  case 1:
157  SetValue(adr, HOT);
158 
159  /*
160  std::cout << "adr = " << detector.AddressName(adr);
161  std::cout << ", x = " << x << ", y = " << y;
162  std::cout << ", value = " << GetValue(adr);
163  std::cout << ", refh2 = " << refh2->GetBinContent(x, y);
164  std::cout << ", factor = " << factor;
165  std::cout << ", N = " << N;
166  std::cout << ", n = " << n;
167  std::cout << ", num = " << num;
168  std::cout << ", denum = " << denum;
169  std::cout << ", rate = " << (N > 0 ? n / N : 0);
170  std::cout << ", hot_coef = " << hot_coef;
171  std::cout << ", = HOT";
172  std::cout << "\n";
173  */
174 
175  break;
176  };
177  }
178  }
179  }
180 
181  } else {
182  LOG_WARN << "cscdqm::Summary.ReadReportingChambersRef routine. Wrong histogram dimensions!";
183  }
184  }
185 
195  const TH2*& evs, const TH2*& err, const HWStatusBit bit, const double eps_max, const double Sfail) {
196  if (evs->GetXaxis()->GetXmin() <= 1 && evs->GetXaxis()->GetXmax() >= 36 && evs->GetYaxis()->GetXmin() <= 1 &&
197  evs->GetYaxis()->GetXmax() >= 18 && err->GetXaxis()->GetXmin() <= 1 && err->GetXaxis()->GetXmax() >= 36 &&
198  err->GetYaxis()->GetXmin() <= 1 && err->GetYaxis()->GetXmax() >= 18) {
199  Address adr;
200  unsigned int N = 0, n = 0;
201 
202  for (unsigned int x = 1; x <= 36; x++) {
203  for (unsigned int y = 1; y <= 18; y++) {
204  N = int(evs->GetBinContent(x, y));
205  n = int(err->GetBinContent(x, y));
206  if (ChamberCoordsToAddress(x, y, adr)) {
207  if (Utility::checkError(N, n, eps_max, Sfail)) {
208  SetValue(adr, bit);
209  } else {
210  ReSetValue(adr, bit);
211  }
212  }
213  }
214  }
215  } else {
216  LOG_WARN << "cscdqm::Summary.ReadErrorChambers routine. Wrong histogram dimensions!";
217  }
218  }
219 
225  void Summary::Write(TH2*& h2, const unsigned int station) const {
226  const AddressBox* box;
227  Address adr, tadr;
228  float area_all = 0.0, area_rep = 0.0;
229 
230  if (station < 1 || station > N_STATIONS)
231  return;
232 
233  adr.mask.side = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
234  adr.mask.station = true;
235  adr.station = station;
236 
237  unsigned int i = 0;
238 
239  while (detector.NextAddressBox(i, box, adr)) {
240  unsigned int x = 1 + (box->adr.side - 1) * 9 + (box->adr.ring - 1) * 3 + (box->adr.hv - 1);
241  unsigned int y = 1 + (box->adr.chamber - 1) * 5 + (box->adr.cfeb - 1);
242 
243  tadr = box->adr;
245 
246  float area_box = fabs((box->xmax - box->xmin) * (box->ymax - box->ymin));
247 
248  if (status.test(MASKED)) {
249  h2->SetBinContent(x, y, 2.0);
250  } else {
251  area_all += area_box;
252  if (HWSTATUSANYERROR(status)) {
253  h2->SetBinContent(x, y, -1.0);
254  } else {
255  area_rep += area_box;
256  if (status.test(DATA)) {
257  h2->SetBinContent(x, y, 1.0);
258  } else {
259  h2->SetBinContent(x, y, 0.0);
260  }
261  }
262  }
263  }
264 
265  TString title = Form("ME%d Status: Physics Efficiency %.2f%%", station, (area_rep / area_all) * 100.0);
266  h2->SetTitle(title);
267  }
268 
273  void Summary::WriteMap(TH2*& h2) {
274  unsigned int rep_el = 0, csc_el = 0;
275 
276  if (h2->GetXaxis()->GetXmin() <= 1 && h2->GetXaxis()->GetXmax() >= NTICS && h2->GetYaxis()->GetXmin() <= 1 &&
277  h2->GetYaxis()->GetXmax() >= NTICS) {
278  float xd = 5.0 / NTICS;
279 
280  float xmin, xmax;
281 
282  for (unsigned int x = 0; x < NTICS; x++) {
283  xmin = -2.5 + xd * x;
284  xmax = xmin + xd;
285 
286  for (unsigned int y = 0; y < NTICS; y++) {
287  double value = 0.0;
288 
289  if (xmin == -2.5 || xmax == 2.5)
290  continue;
291  if (xmin >= -1 && xmax <= 1)
292  continue;
293 
294  switch (IsPhysicsReady(x, y)) {
295  case -1:
296  value = -1.0;
297  break;
298  case 0:
299  value = 0.0;
300  rep_el++;
301  break;
302  case 1:
303  value = 1.0;
304  rep_el++;
305  break;
306  case 2:
307  value = 2.0;
308  rep_el++;
309  }
310 
311  h2->SetBinContent(x + 1, y + 1, value);
312  csc_el++;
313  }
314  }
315 
316  } else {
317  LOG_WARN << "cscdqm::Summary.WriteMap routine. Wrong histogram dimensions!";
318  }
319 
320  TString title =
321  Form("EMU Status: Physics Efficiency %.2f%%", (csc_el == 0 ? 0.0 : (1.0 * rep_el) / csc_el) * 100.0);
322  h2->SetTitle(title);
323  }
324 
333  void Summary::WriteChamberState(TH2*& h2, const int mask, const int value, const bool reset, const bool op_any) const {
334  if (h2->GetXaxis()->GetXmin() <= 1 && h2->GetXaxis()->GetXmax() >= 36 && h2->GetYaxis()->GetXmin() <= 1 &&
335  h2->GetYaxis()->GetXmax() >= 18) {
336  unsigned int x, y;
337  Address adr;
338 
339  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = true;
340  adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
341 
342  for (adr.side = 1; adr.side <= N_SIDES; adr.side++) {
343  for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) {
344  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) {
345  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) {
346  if (ChamberAddressToCoords(adr, x, y)) {
347  HWStatusBitSet hwValue = GetValue(adr);
348  bool hit = (op_any ? HWSTATUSANY(hwValue, mask) : HWSTATUSEQUALS(hwValue, mask));
349 
350  // std::cout << "x = " << x << ", y = " << y << ", value = " << GetValue(adr) << std::endl;
351  // std::cout << "adr = " << detector.AddressName(adr) << ", x = " << x << ", y = " << y << ", value = " << GetValue(adr) << std::endl;
352  if (hit) {
353  h2->SetBinContent(x, y, 1.0 * value);
354  } else if (reset) {
355  h2->SetBinContent(x, y, 0.0);
356  }
357  }
358  }
359  }
360  }
361  }
362 
363  } else {
364  LOG_WARN << "cscdqm::Summary.WriteChamberState routine. Wrong histogram dimensions!";
365  }
366  }
367 
372  void Summary::ReSetValue(const HWStatusBit bit) { SetValue(bit, 0); }
373 
379  void Summary::ReSetValue(const Address& adr, const HWStatusBit bit) { SetValue(adr, bit, 0); }
380 
386  void Summary::SetValue(const HWStatusBit bit, const int value) {
387  Address adr;
388  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv =
389  false;
390  SetValue(adr, bit, value);
391  }
392 
399  void Summary::SetValue(Address adr, const HWStatusBit bit, const int value) {
400  if (!adr.mask.side) {
401  adr.mask.side = true;
402  for (adr.side = 1; adr.side <= N_SIDES; adr.side++)
403  SetValue(adr, bit, value);
404  return;
405  }
406 
407  if (!adr.mask.station) {
408  adr.mask.station = true;
409  for (adr.station = 1; adr.station <= N_STATIONS; adr.station++)
410  SetValue(adr, bit, value);
411  return;
412  }
413 
414  if (!adr.mask.ring) {
415  adr.mask.ring = true;
416  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++)
417  SetValue(adr, bit, value);
418  return;
419  }
420 
421  if (!adr.mask.chamber) {
422  adr.mask.chamber = true;
423  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++)
424  SetValue(adr, bit, value);
425  return;
426  }
427 
428  if (!adr.mask.layer) {
429  adr.mask.layer = true;
430  for (adr.layer = 1; adr.layer <= N_LAYERS; adr.layer++)
431  SetValue(adr, bit, value);
432  return;
433  }
434 
435  if (!adr.mask.cfeb) {
436  adr.mask.cfeb = true;
437  for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++)
438  SetValue(adr, bit, value);
439  return;
440  }
441 
442  if (!adr.mask.hv) {
443  adr.mask.hv = true;
444  for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++)
445  SetValue(adr, bit, value);
446  return;
447  }
448 
449  if (adr.side > 0 && adr.side <= N_SIDES && adr.station > 0 && adr.station <= N_STATIONS && adr.ring > 0 &&
450  adr.ring <= N_RINGS && adr.chamber > 0 && adr.chamber <= N_CHAMBERS && adr.layer > 0 && adr.layer <= N_LAYERS &&
451  adr.cfeb > 0 && adr.cfeb <= N_CFEBS && adr.hv > 0 && adr.hv <= N_HVS) {
452  map[adr.side - 1][adr.station - 1][adr.ring - 1][adr.chamber - 1][adr.layer - 1][adr.cfeb - 1][adr.hv - 1].set(
453  bit, value);
454  }
455  }
456 
465  const int Summary::IsPhysicsReady(const unsigned int px, const unsigned int py) {
466  AddressBox* box;
467 
469 
470  unsigned int i = 0;
471  while (detector.NextAddressBoxByPartition(i, px, py, box)) {
472  status[box->adr.station - 1] |= GetValue(box->adr);
473  }
474 
475  unsigned int cdata = 0, cerror = 0, cmask = 0;
476  for (unsigned int i = 0; i < N_STATIONS; i++) {
477  if (HWSTATUSANYERROR(status[i])) {
478  cerror++;
479  } else {
480  if (status[i].test(MASKED))
481  cmask++;
482  if (status[i].test(DATA))
483  cdata++;
484  }
485  }
486 
488  if (cdata > 1)
489  return 1;
491  if (cerror > 0)
492  return -1;
494  if (cmask > 0)
495  return 2;
497  return 0;
498  }
499 
504  const double Summary::GetEfficiencyHW() const {
505  Address adr;
506  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv =
507  false;
508  return GetEfficiencyHW(adr);
509  }
510 
516  const double Summary::GetEfficiencyHW(const unsigned int station) const {
517  Address adr;
518  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv =
519  false;
520 
521  if (station > 0 && station <= N_STATIONS) {
522  adr.mask.station = true;
523  adr.station = station;
524  } else {
525  return 0.0;
526  }
527 
528  return GetEfficiencyHW(adr);
529  }
530 
536  const double Summary::GetEfficiencyHW(Address adr) const {
537  double sum = 0.0;
538  if (!adr.mask.side) {
539  adr.mask.side = true;
540  for (adr.side = 1; adr.side <= N_SIDES; adr.side++)
541  sum += GetEfficiencyHW(adr);
542  return sum / N_SIDES;
543  }
544 
545  if (!adr.mask.station) {
546  adr.mask.station = true;
547  for (adr.station = 1; adr.station <= N_STATIONS; adr.station++)
548  sum += GetEfficiencyHW(adr);
549  return sum / N_STATIONS;
550  }
551 
552  if (!adr.mask.ring) {
553  adr.mask.ring = true;
554  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++)
555  sum += GetEfficiencyHW(adr);
556  return sum / detector.NumberOfRings(adr.station);
557  }
558 
559  if (!adr.mask.chamber) {
560  adr.mask.chamber = true;
561  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++)
562  sum += GetEfficiencyHW(adr);
563  return sum / detector.NumberOfChambers(adr.station, adr.ring);
564  }
565 
566  if (!adr.mask.layer) {
567  adr.mask.layer = true;
568  for (adr.layer = 1; adr.layer <= N_LAYERS; adr.layer++)
569  sum += GetEfficiencyHW(adr);
570  return sum / N_LAYERS;
571  }
572 
573  if (!adr.mask.cfeb) {
574  adr.mask.cfeb = true;
575  for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++)
576  sum += GetEfficiencyHW(adr);
577  return sum / detector.NumberOfChamberCFEBs(adr.station, adr.ring);
578  }
579 
580  if (!adr.mask.hv) {
581  adr.mask.hv = true;
582  for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++)
583  sum += GetEfficiencyHW(adr);
584  return sum / detector.NumberOfChamberHVs(adr.station, adr.ring);
585  }
586 
590  return 0.0;
591  return 1.0;
592  }
593 
599  const double Summary::GetEfficiencyArea(const unsigned int station) const {
600  if (station <= 0 || station > N_STATIONS)
601  return 0.0;
602 
603  Address adr;
604  adr.mask.side = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
605  adr.station = true;
606  adr.station = station;
607 
608  return GetEfficiencyArea(adr);
609  }
610 
616  const double Summary::GetEfficiencyArea(const Address& adr) const {
617  double all_area = 1;
618 
619  if (adr.mask.side == false && adr.mask.ring == false && adr.mask.chamber == false && adr.mask.layer == false &&
620  adr.mask.cfeb == false && adr.mask.hv == false && adr.mask.station == true)
621  all_area = detector.Area(adr.station);
622  else
623  all_area = detector.Area(adr);
624 
625  double rep_area = GetReportingArea(adr);
626  return rep_area / all_area;
627  }
628 
634  const double Summary::GetReportingArea(Address adr) const {
635  double sum = 0.0;
636  if (!adr.mask.side) {
637  adr.mask.side = true;
638  for (adr.side = 1; adr.side <= N_SIDES; adr.side++)
639  sum += GetReportingArea(adr);
640  return sum;
641  }
642 
643  if (!adr.mask.station) {
644  adr.mask.station = true;
645  for (adr.station = 1; adr.station <= N_STATIONS; adr.station++)
646  sum += GetReportingArea(adr);
647  return sum;
648  }
649 
650  if (!adr.mask.ring) {
651  adr.mask.ring = true;
652  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++)
653  sum += GetReportingArea(adr);
654  return sum;
655  }
656 
657  if (!adr.mask.chamber) {
658  adr.mask.chamber = true;
659  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++)
660  sum += GetReportingArea(adr);
661  return sum;
662  }
663 
664  if (!adr.mask.cfeb) {
665  adr.mask.cfeb = true;
666  for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++)
667  sum += GetReportingArea(adr);
668  return sum;
669  }
670 
671  if (!adr.mask.hv) {
672  adr.mask.hv = true;
673  for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++)
674  sum += GetReportingArea(adr);
675  return sum;
676  }
677 
678  adr.mask.layer = false;
679 
682  if (!HWSTATUSANYERROR(status)) {
683  return detector.Area(adr);
684  }
685  return 0.0;
686  }
687 
696  bool Summary::isChamberStandby(unsigned int side,
697  unsigned int station,
698  unsigned int ring,
699  unsigned int chamber) const {
700  Address adr;
701  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = true;
702  adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
703  adr.side = side;
704  adr.station = station;
705  adr.ring = ring;
706  adr.chamber = chamber;
707 
708  //std::cout << adr << " = " << HWSTATUSANY(GetValue(adr), 0x1000) << "\n";
709 
710  return HWSTATUSANY(GetValue(adr), 0x1000);
711  }
712 
719  return isChamberStandby(cid.endcap(), cid.station(), cid.ring(), cid.chamber());
720  }
721 
729  state.reset();
730 
731  if (!adr.mask.side) {
732  adr.mask.side = true;
733  for (adr.side = 1; adr.side <= N_SIDES; adr.side++)
734  state |= GetValue(adr);
735  return state;
736  }
737 
738  if (!adr.mask.station) {
739  adr.mask.station = true;
740  for (adr.station = 1; adr.station <= N_STATIONS; adr.station++)
741  state |= GetValue(adr);
742  return state;
743  }
744 
745  if (!adr.mask.ring) {
746  adr.mask.ring = true;
747  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++)
748  state |= GetValue(adr);
749  return state;
750  }
751 
752  if (!adr.mask.chamber) {
753  adr.mask.chamber = true;
754  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++)
755  state |= GetValue(adr);
756  return state;
757  }
758 
759  if (!adr.mask.layer) {
760  adr.mask.layer = true;
761  for (adr.layer = 1; adr.layer <= N_LAYERS; adr.layer++)
762  state |= GetValue(adr);
763  return state;
764  }
765 
766  if (!adr.mask.cfeb) {
767  adr.mask.cfeb = true;
768  for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++)
769  state |= GetValue(adr);
770  return state;
771  }
772 
773  if (!adr.mask.hv) {
774  adr.mask.hv = true;
775  for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++)
776  state |= GetValue(adr);
777  return state;
778  }
779 
780  return map[adr.side - 1][adr.station - 1][adr.ring - 1][adr.chamber - 1][adr.layer - 1][adr.cfeb - 1][adr.hv - 1];
781  }
782 
788  const unsigned int Summary::setMaskedHWElements(std::vector<std::string>& tokens) {
789  unsigned int applied = 0;
790 
791  for (unsigned int r = 0; r < tokens.size(); r++) {
792  std::string token = (std::string)tokens.at(r);
793  Address adr;
794  if (detector.AddressFromString(token, adr)) {
795  SetValue(adr, MASKED);
796  applied++;
797  }
798  }
799  return applied;
800  }
801 
809  const bool Summary::ChamberCoordsToAddress(const unsigned int x, const unsigned int y, Address& adr) const {
810  if (x < 1 || x > 36 || y < 1 || y > 18)
811  return false;
812 
813  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = true;
814  adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
815 
816  if (y < 10)
817  adr.side = 2;
818  else
819  adr.side = 1;
820 
821  adr.chamber = x;
822 
823  if (y == 1 || y == 18) {
824  adr.station = 4;
825  adr.ring = 2;
826  } else if (y == 2 || y == 17) {
827  adr.station = 4;
828  adr.ring = 1;
829  } else if (y == 3 || y == 16) {
830  adr.station = 3;
831  adr.ring = 2;
832  } else if (y == 4 || y == 15) {
833  adr.station = 3;
834  adr.ring = 1;
835  } else if (y == 5 || y == 14) {
836  adr.station = 2;
837  adr.ring = 2;
838  } else if (y == 6 || y == 13) {
839  adr.station = 2;
840  adr.ring = 1;
841  } else if (y == 7 || y == 12) {
842  adr.station = 1;
843  adr.ring = 3;
844  } else if (y == 8 || y == 11) {
845  adr.station = 1;
846  adr.ring = 2;
847  } else if (y == 9 || y == 10) {
848  adr.station = 1;
849  adr.ring = 1;
850  }
851 
852  return true;
853  }
854 
862  const bool Summary::ChamberAddressToCoords(const Address& adr, unsigned int& x, unsigned int& y) const {
863  if (!adr.mask.side || !adr.mask.station || !adr.mask.ring || !adr.mask.chamber)
864  return false;
865 
866  x = adr.chamber;
867  y = 0;
868 
869  if (adr.side == 1) {
870  switch (adr.station) {
871  case 1:
872  y = 10;
873  if (adr.ring == 2)
874  y = 11;
875  if (adr.ring == 3)
876  y = 12;
877  break;
878  case 2:
879  y = 13;
880  if (adr.ring == 2)
881  y = 14;
882  break;
883  case 3:
884  y = 15;
885  if (adr.ring == 2)
886  y = 16;
887  break;
888  case 4:
889  y = 17;
890  if (adr.ring == 2)
891  y = 18;
892  break;
893  }
894  } else if (adr.side == 2) {
895  switch (adr.station) {
896  case 1:
897  y = 7;
898  if (adr.ring == 2)
899  y = 8;
900  if (adr.ring == 1)
901  y = 9;
902  break;
903  case 2:
904  y = 5;
905  if (adr.ring == 1)
906  y = 6;
907  break;
908  case 3:
909  y = 3;
910  if (adr.ring == 1)
911  y = 4;
912  break;
913  case 4:
914  y = 1;
915  if (adr.ring == 1)
916  y = 2;
917  break;
918  }
919  }
920 
921  return true;
922  }
923 
924 } // namespace cscdqm
cscdqm::Summary::ReadReportingChambers
void ReadReportingChambers(const TH2 *&h2, const double threshold=1.0)
Read Reporting Chamber histogram and fill in detector map.
Definition: CSCDQM_Summary.cc:60
cscdqm::AddressMask::chamber
bool chamber
Definition: CSCDQM_Detector.h:72
cscdqm::Summary::WriteChamberState
void WriteChamberState(TH2 *&h2, const int mask, const int value=1, const bool reset=true, const bool op_any=false) const
Write State information to chamber histogram.
Definition: CSCDQM_Summary.cc:333
cscdqm::Summary::~Summary
~Summary()
Destructor.
Definition: CSCDQM_Summary.cc:31
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
mps_fire.i
i
Definition: mps_fire.py:428
cscdqm::Summary::ChamberCoordsToAddress
const bool ChamberCoordsToAddress(const unsigned int x, const unsigned int y, Address &adr) const
Calculate Address from CSCChamberMap histogram coordinates.
Definition: CSCDQM_Summary.cc:809
cscdqm::HWStatusBit
HWStatusBit
Hardware Status Bit values used in Summary efficiency calculation.
Definition: CSCDQM_Summary.h:45
cscdqm::Detector::NumberOfChambers
const unsigned int NumberOfChambers(const unsigned int station, const unsigned int ring) const
Returns the number of chambers for the given station and ring.
Definition: CSCDQM_Detector.cc:215
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
cscdqm::Address::side
unsigned int side
Definition: CSCDQM_Detector.h:83
cscdqm::Address::layer
unsigned int layer
Definition: CSCDQM_Detector.h:87
cscdqm::HWStatusBitSet
std::bitset< 14 > HWStatusBitSet
Hardware Status Bits structure used in Summary efficiency calculation and storage.
Definition: CSCDQM_Summary.h:72
mps_update.status
status
Definition: mps_update.py:69
cscdqm::Detector::NumberOfChamberHVs
const unsigned int NumberOfChamberHVs(const unsigned int station, const unsigned int ring) const
Returns the number of HVs per Chamber on given Station/Ring.
Definition: CSCDQM_Detector.cc:271
relativeConstraints.station
station
Definition: relativeConstraints.py:67
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
HWSTATUSANYERROR
#define HWSTATUSANYERROR(s)
Definition: CSCDQM_Summary.h:36
cscdqm::MASKED
Data available (reporting)
Definition: CSCDQM_Summary.h:48
N_CFEBS
#define N_CFEBS
Definition: CSCDQM_Detector.h:47
N_HVS
#define N_HVS
Definition: CSCDQM_Detector.h:48
CSCDQM_Summary.h
cscdqm::Utility::checkError
static bool checkError(const unsigned int N, const unsigned int n, const double threshold, const double sigfail)
Check the hypothesis that error events (n) value above threshold comparing with the expected 0 and st...
Definition: CSCDQM_Utility.cc:331
cscdqm::AddressBox
Area covered by Address in eta/phy space.
Definition: CSCDQM_Detector.h:151
HWSTATUSEQUALS
#define HWSTATUSEQUALS(s, m)
Definition: CSCDQM_Summary.h:34
cscdqm::Summary::Write
void Write(TH2 *&h2, const unsigned int station) const
Write detector map to H1 histogram (linear data) for the selected adr.station.
Definition: CSCDQM_Summary.cc:225
cscdqm::Summary::ChamberAddressToCoords
const bool ChamberAddressToCoords(const Address &adr, unsigned int &x, unsigned int &y) const
Calculate CSCChamberMap histogram coordinates from Address.
Definition: CSCDQM_Summary.cc:862
cscdqm::AddressBox::adr
Address adr
Definition: CSCDQM_Detector.h:152
cscdqm::AddressBox::ymax
float ymax
Definition: CSCDQM_Detector.h:156
N_LAYERS
#define N_LAYERS
Definition: CSCDQM_Detector.h:46
N_CHAMBERS
#define N_CHAMBERS
Definition: CSCDQM_Detector.h:45
cscdqm::Summary::ReSetValue
void ReSetValue(const HWStatusBit bit)
ReSetValue for the whole of detector.
Definition: CSCDQM_Summary.cc:372
N_SIDES
#define N_SIDES
Definition: CSCDQM_Detector.h:42
ctpps_dqm_sourceclient-live_cfg.test
test
Definition: ctpps_dqm_sourceclient-live_cfg.py:7
cscdqm::Detector::NextAddressBoxByPartition
const bool NextAddressBoxByPartition(unsigned int &i, const unsigned int px, const unsigned int py, AddressBox *&box)
Address box iterator by partition.
Definition: CSCDQM_Detector.cc:374
cscdqm::Summary::IsPhysicsReady
const int IsPhysicsReady(const unsigned int px, const unsigned int py)
Check if the current partition element (aka eta/phi polygon) has at least 2 active HW elements in the...
Definition: CSCDQM_Summary.cc:465
cscdqm::Detector::NumberOfRings
const unsigned int NumberOfRings(const unsigned int station) const
Returns the number of rings for the given station.
Definition: CSCDQM_Detector.cc:197
HWSTATUSANY
#define HWSTATUSANY(s, m)
Definition: CSCDQM_Summary.h:35
cscdqm::Summary::GetReportingArea
const double GetReportingArea(Address adr) const
Calculate the reporting area for the address.
Definition: CSCDQM_Summary.cc:634
N
#define N
Definition: blowfish.cc:9
cscdqm::Detector::NextAddressBox
const bool NextAddressBox(unsigned int &i, const AddressBox *&box, const Address &mask) const
Address box iterator by mask.
Definition: CSCDQM_Detector.cc:355
DQMScaleToClient_cfi.factor
factor
Definition: DQMScaleToClient_cfi.py:8
cscdqm::HOT
HW element was masked out (not in readout)
Definition: CSCDQM_Summary.h:50
cscdqm::Address::station
unsigned int station
Definition: CSCDQM_Detector.h:84
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cscdqm::Summary::SetValue
void SetValue(const HWStatusBit bit, const int value=1)
SetValue for the whole of detector.
Definition: CSCDQM_Summary.cc:386
cscdqm::DATA
Definition: CSCDQM_Summary.h:47
cscdqm::AddressBox::xmax
float xmax
Definition: CSCDQM_Detector.h:154
HWSTATUSBITSETSIZE
#define HWSTATUSBITSETSIZE
Definition: CSCDQM_Summary.h:32
cscdqm
Definition: CSCDQM_DCSBase.h:29
CSCDetId
Definition: CSCDetId.h:26
cscdqm::Address::mask
AddressMask mask
Definition: CSCDQM_Detector.h:91
createfilelist.int
int
Definition: createfilelist.py:10
cscdqm::Address::cfeb
unsigned int cfeb
Definition: CSCDQM_Detector.h:88
value
Definition: value.py:1
cscdqm::Summary::Summary
Summary()
Constructor.
Definition: CSCDQM_Summary.cc:26
cscdqm::AddressBox::ymin
float ymin
Definition: CSCDQM_Detector.h:155
cscdqm::Detector::NumberOfChamberCFEBs
const unsigned int NumberOfChamberCFEBs(const unsigned int station, const unsigned int ring) const
Returns the number of CFEBs per Chamber on given Station/Ring.
Definition: CSCDQM_Detector.cc:243
CSCDetId::chamber
int chamber() const
Definition: CSCDetId.h:62
cscdqm::Summary::setMaskedHWElements
const unsigned int setMaskedHWElements(std::vector< std::string > &tokens)
Read HW element masks (strings), create Address and apply to detector map.
Definition: CSCDQM_Summary.cc:788
cscdqm::AddressMask::cfeb
bool cfeb
Definition: CSCDQM_Detector.h:74
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
cscdqm::AddressMask::side
bool side
Definition: CSCDQM_Detector.h:69
N_RINGS
#define N_RINGS
Definition: CSCDQM_Detector.h:44
cscdqm::Summary::ReadErrorChambers
void ReadErrorChambers(const TH2 *&evs, const TH2 *&err, const HWStatusBit bit, const double eps_max=0.1, const double Sfail=5.0)
Read Error data for Chambers.
Definition: CSCDQM_Summary.cc:194
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
cscdqm::Summary::GetValue
const HWStatusBitSet GetValue(Address adr) const
Get value of some address.
Definition: CSCDQM_Summary.cc:727
alignCSCRings.r
r
Definition: alignCSCRings.py:93
cscdqm::Summary::WriteMap
void WriteMap(TH2 *&h2)
Write PhysicsReady Map to H2 histogram.
Definition: CSCDQM_Summary.cc:273
cscdqm::AddressMask::station
bool station
Definition: CSCDQM_Detector.h:70
cscdqm::Address
Structure to store detector addresses of any granularity: from whole detector to the single HV elemen...
Definition: CSCDQM_Detector.h:82
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
cscdqm::AddressMask::ring
bool ring
Definition: CSCDQM_Detector.h:71
cscdqm::AddressMask::layer
bool layer
Definition: CSCDQM_Detector.h:73
cscdqm::Address::hv
unsigned int hv
Definition: CSCDQM_Detector.h:89
cscdqm::Address::chamber
unsigned int chamber
Definition: CSCDQM_Detector.h:86
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
cscdqm::Summary::isChamberStandby
bool isChamberStandby(unsigned int side, unsigned int station, unsigned int ring, unsigned int chamber) const
Check if chamber is in standby?
Definition: CSCDQM_Summary.cc:696
cscdqm::Summary::GetEfficiencyHW
const double GetEfficiencyHW() const
Get efficiency of the whole detector.
Definition: CSCDQM_Summary.cc:504
CSCDetId::endcap
int endcap() const
Definition: CSCDetId.h:85
NTICS
#define NTICS
Definition: CSCDQM_Summary.h:38
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
cscdqm::Summary::ReadReportingChambersRef
void ReadReportingChambersRef(const TH2 *&h2, const TH2 *&refh2, const double cold_coef=0.1, const double cold_Sfail=5.0, const double hot_coef=2.0, const double hot_Sfail=5.0)
Read Reporting Chamber histogram and fill in detector map based on reference histogram.
Definition: CSCDQM_Summary.cc:93
cscdqm::COLD
HW element is hot by comparing with reference histogram.
Definition: CSCDQM_Summary.h:51
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
cscdqm::Utility::checkOccupancy
static short checkOccupancy(const unsigned int N, const unsigned int n, const double low_threshold, const double high_threshold, const double low_sigfail, const double high_sigfail)
Check the hypothesis that observed events (n) value is too low or too high comparing with the expecte...
Definition: CSCDQM_Utility.cc:302
N_STATIONS
#define N_STATIONS
Definition: CSCDQM_Detector.h:43
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
cscdqm::Summary::GetEfficiencyArea
const double GetEfficiencyArea(const unsigned int station) const
Get Efficiency area for the station.
Definition: CSCDQM_Summary.cc:599
hgcalTestNeighbor_cfi.detector
detector
Definition: hgcalTestNeighbor_cfi.py:6
reset
void reset(double vett[256])
Definition: TPedValues.cc:11
cscdqm::Detector::AddressFromString
const bool AddressFromString(const std::string &str_address, Address &adr) const
Construct address from string.
Definition: CSCDQM_Detector.cc:658
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
cscdqm::AddressMask::hv
bool hv
Definition: CSCDQM_Detector.h:75
cscdqm::Summary::detector
Detector detector
Definition: CSCDQM_Summary.h:131
cscdqm::Address::ring
unsigned int ring
Definition: CSCDQM_Detector.h:85
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
cscdqm::Detector::Area
const float Area(const unsigned int station) const
Calculate station area in eta/phi space.
Definition: CSCDQM_Detector.cc:132
LOG_WARN
#define LOG_WARN
Definition: CSCDQM_Logger.h:41
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:430
cscdqm::Summary::map
HWStatusBitSet map[2][4][3][36][6][5][5]
Definition: CSCDQM_Summary.h:128
hit
Definition: SiStripHitEffFromCalibTree.cc:88
cscdqm::AddressBox::xmin
float xmin
Definition: CSCDQM_Detector.h:153
cscdqm::Summary::Reset
void Reset()
Resets all detector map.
Definition: CSCDQM_Summary.cc:36
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316