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  bzero(&adr, sizeof(Address));
39 
41  adr.mask.side = adr.mask.station = adr.mask.layer = false;
42  adr.mask.ring = adr.mask.chamber = adr.mask.cfeb = adr.mask.hv = true;
43  for (adr.ring = 1; adr.ring <= N_RINGS; adr.ring++) {
44  for (adr.chamber = 1; adr.chamber <= N_CHAMBERS; adr.chamber++) {
45  for (adr.cfeb = 1; adr.cfeb <= N_CFEBS; adr.cfeb++) {
46  for (adr.hv = 1; adr.hv <= N_HVS; adr.hv++) {
47  for (unsigned int bit = 0; bit < HWSTATUSBITSETSIZE; bit++) {
48  ReSetValue(adr, (HWStatusBit)bit);
49  }
50  }
51  }
52  }
53  }
54  }
55 
61  void Summary::ReadReportingChambers(const TH2*& h2, const double threshold) {
62  if (h2->GetXaxis()->GetXmin() <= 1 && h2->GetXaxis()->GetXmax() >= 36 && h2->GetYaxis()->GetXmin() <= 1 &&
63  h2->GetYaxis()->GetXmax() >= 18) {
64  Address adr;
65  bzero(&adr, sizeof(Address));
66  double z = 0.0;
67 
68  for (unsigned int x = 1; x <= 36; x++) {
69  for (unsigned int y = 1; y <= 18; y++) {
70  z = h2->GetBinContent(x, y);
71  if (ChamberCoordsToAddress(x, y, adr)) {
72  if (z >= threshold) {
73  SetValue(adr, DATA);
74  } else {
75  ReSetValue(adr, DATA);
76  }
77  }
78  }
79  }
80  } else {
81  LOG_WARN << "cscdqm::Summary.ReadReportingChambers routine. Wrong histogram dimensions!";
82  }
83  }
84 
95  void Summary::ReadReportingChambersRef(const TH2*& h2,
96  const TH2*& refh2,
97  const double cold_coef,
98  const double cold_Sfail,
99  const double hot_coef,
100  const double hot_Sfail) {
101  if (h2->GetXaxis()->GetXmin() <= 1 && h2->GetXaxis()->GetXmax() >= 36 && h2->GetYaxis()->GetXmin() <= 1 &&
102  h2->GetYaxis()->GetXmax() >= 18 && refh2->GetXaxis()->GetXmin() <= 1 && refh2->GetXaxis()->GetXmax() >= 36 &&
103  refh2->GetYaxis()->GetXmin() <= 1 && refh2->GetYaxis()->GetXmax() >= 18) {
105  double num = 1.0, denum = 1.0;
106  for (unsigned int x = 1; x <= 36; x++) {
107  for (unsigned int y = 1; y <= 18; y++) {
108  double Nij = h2->GetBinContent(x, y);
109  double Nrefij = refh2->GetBinContent(x, y);
110  if (Nij > 0) {
111  num += Nrefij;
112  denum += pow(Nrefij, 2.0) / Nij;
113  }
114  }
115  }
116  double factor = num / denum;
117 
118  Address adr;
119  bzero(&adr, sizeof(Address));
120  unsigned int N = 0, n = 0;
121 
122  for (unsigned int x = 1; x <= 36; x++) {
123  for (unsigned int y = 1; y <= 18; y++) {
124  N = int(refh2->GetBinContent(x, y) * factor);
125  n = int(h2->GetBinContent(x, y));
126 
127  if (ChamberCoordsToAddress(x, y, adr)) {
129  ReSetValue(adr, HOT);
130  ReSetValue(adr, COLD);
131 
132  if (n == 0) {
133  ReSetValue(adr, DATA);
134  } else {
135  SetValue(adr, DATA);
136  }
137 
138  switch (Utility::checkOccupancy(N, n, cold_coef, hot_coef, cold_Sfail, hot_Sfail)) {
139  case -1:
140  SetValue(adr, COLD);
141 
142  /*
143  std::cout << "adr = " << detector.AddressName(adr);
144  std::cout << ", x = " << x << ", y = " << y;
145  std::cout << ", value = " << GetValue(adr);
146  std::cout << ", refh2 = " << refh2->GetBinContent(x, y);
147  std::cout << ", factor = " << factor;
148  std::cout << ", N = " << N;
149  std::cout << ", n = " << n;
150  std::cout << ", num = " << num;
151  std::cout << ", denum = " << denum;
152  std::cout << ", rate = " << (N > 0 ? n / N : 0);
153  std::cout << ", cold_coef = " << cold_coef;
154  std::cout << ", = COLD";
155  std::cout << "\n";
156  */
157 
158  break;
159  case 1:
160  SetValue(adr, HOT);
161 
162  /*
163  std::cout << "adr = " << detector.AddressName(adr);
164  std::cout << ", x = " << x << ", y = " << y;
165  std::cout << ", value = " << GetValue(adr);
166  std::cout << ", refh2 = " << refh2->GetBinContent(x, y);
167  std::cout << ", factor = " << factor;
168  std::cout << ", N = " << N;
169  std::cout << ", n = " << n;
170  std::cout << ", num = " << num;
171  std::cout << ", denum = " << denum;
172  std::cout << ", rate = " << (N > 0 ? n / N : 0);
173  std::cout << ", hot_coef = " << hot_coef;
174  std::cout << ", = HOT";
175  std::cout << "\n";
176  */
177 
178  break;
179  };
180  }
181  }
182  }
183 
184  } else {
185  LOG_WARN << "cscdqm::Summary.ReadReportingChambersRef routine. Wrong histogram dimensions!";
186  }
187  }
188 
198  const TH2*& evs, const TH2*& err, const HWStatusBit bit, const double eps_max, const double Sfail) {
199  if (evs->GetXaxis()->GetXmin() <= 1 && evs->GetXaxis()->GetXmax() >= 36 && evs->GetYaxis()->GetXmin() <= 1 &&
200  evs->GetYaxis()->GetXmax() >= 18 && err->GetXaxis()->GetXmin() <= 1 && err->GetXaxis()->GetXmax() >= 36 &&
201  err->GetYaxis()->GetXmin() <= 1 && err->GetYaxis()->GetXmax() >= 18) {
202  Address adr;
203  bzero(&adr, sizeof(Address));
204  unsigned int N = 0, n = 0;
205 
206  for (unsigned int x = 1; x <= 36; x++) {
207  for (unsigned int y = 1; y <= 18; y++) {
208  N = int(evs->GetBinContent(x, y));
209  n = int(err->GetBinContent(x, y));
210  if (ChamberCoordsToAddress(x, y, adr)) {
211  if (Utility::checkError(N, n, eps_max, Sfail)) {
212  SetValue(adr, bit);
213  } else {
214  ReSetValue(adr, bit);
215  }
216  }
217  }
218  }
219  } else {
220  LOG_WARN << "cscdqm::Summary.ReadErrorChambers routine. Wrong histogram dimensions!";
221  }
222  }
223 
229  void Summary::Write(TH2*& h2, const unsigned int station) const {
230  const AddressBox* box;
231  Address adr, tadr;
232  bzero(&adr, sizeof(Address));
233  bzero(&tadr, sizeof(Address));
234  float area_all = 0.0, area_rep = 0.0;
235 
236  if (station < 1 || station > N_STATIONS)
237  return;
238 
239  adr.mask.side = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
240  adr.mask.station = true;
241  adr.station = station;
242 
243  unsigned int i = 0;
244 
245  while (detector.NextAddressBox(i, box, adr)) {
246  unsigned int x = 1 + (box->adr.side - 1) * 9 + (box->adr.ring - 1) * 3 + (box->adr.hv - 1);
247  unsigned int y = 1 + (box->adr.chamber - 1) * 5 + (box->adr.cfeb - 1);
248 
249  tadr = box->adr;
251 
252  float area_box = fabs((box->xmax - box->xmin) * (box->ymax - box->ymin));
253 
254  if (status.test(MASKED)) {
255  h2->SetBinContent(x, y, 2.0);
256  } else {
257  area_all += area_box;
258  if (HWSTATUSANYERROR(status)) {
259  h2->SetBinContent(x, y, -1.0);
260  } else {
261  area_rep += area_box;
262  if (status.test(DATA)) {
263  h2->SetBinContent(x, y, 1.0);
264  } else {
265  h2->SetBinContent(x, y, 0.0);
266  }
267  }
268  }
269  }
270 
271  TString title = Form("ME%d Status: Physics Efficiency %.2f%%", station, (area_rep / area_all) * 100.0);
272  h2->SetTitle(title);
273  }
274 
279  void Summary::WriteMap(TH2*& h2) {
280  unsigned int rep_el = 0, csc_el = 0;
281 
282  if (h2->GetXaxis()->GetXmin() <= 1 && h2->GetXaxis()->GetXmax() >= NTICS && h2->GetYaxis()->GetXmin() <= 1 &&
283  h2->GetYaxis()->GetXmax() >= NTICS) {
284  float xd = 5.0 / NTICS;
285 
286  float xmin, xmax;
287 
288  for (unsigned int x = 0; x < NTICS; x++) {
289  xmin = -2.5 + xd * x;
290  xmax = xmin + xd;
291 
292  for (unsigned int y = 0; y < NTICS; y++) {
293  double value = 0.0;
294 
295  if (xmin == -2.5 || xmax == 2.5)
296  continue;
297  if (xmin >= -1 && xmax <= 1)
298  continue;
299 
300  switch (IsPhysicsReady(x, y)) {
301  case -1:
302  value = -1.0;
303  break;
304  case 0:
305  value = 0.0;
306  rep_el++;
307  break;
308  case 1:
309  value = 1.0;
310  rep_el++;
311  break;
312  case 2:
313  value = 2.0;
314  rep_el++;
315  }
316 
317  h2->SetBinContent(x + 1, y + 1, value);
318  csc_el++;
319  }
320  }
321 
322  } else {
323  LOG_WARN << "cscdqm::Summary.WriteMap routine. Wrong histogram dimensions!";
324  }
325 
326  TString title =
327  Form("EMU Status: Physics Efficiency %.2f%%", (csc_el == 0 ? 0.0 : (1.0 * rep_el) / csc_el) * 100.0);
328  h2->SetTitle(title);
329  }
330 
339  void Summary::WriteChamberState(TH2*& h2, const int mask, const int value, const bool reset, const bool op_any) const {
340  if (h2->GetXaxis()->GetXmin() <= 1 && h2->GetXaxis()->GetXmax() >= 36 && h2->GetYaxis()->GetXmin() <= 1 &&
341  h2->GetYaxis()->GetXmax() >= 18) {
342  unsigned int x, y;
343  Address adr;
344  bzero(&adr, sizeof(Address));
345 
346  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = true;
347  adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
348 
349  for (adr.side = 1; adr.side <= N_SIDES; adr.side++) {
350  for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) {
351  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) {
352  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) {
353  if (ChamberAddressToCoords(adr, x, y)) {
354  HWStatusBitSet hwValue = GetValue(adr);
355  bool hit = (op_any ? HWSTATUSANY(hwValue, mask) : HWSTATUSEQUALS(hwValue, mask));
356 
357  // std::cout << "x = " << x << ", y = " << y << ", value = " << GetValue(adr) << std::endl;
358  // std::cout << "adr = " << detector.AddressName(adr) << ", x = " << x << ", y = " << y << ", value = " << GetValue(adr) << std::endl;
359  if (hit) {
360  h2->SetBinContent(x, y, 1.0 * value);
361  } else if (reset) {
362  h2->SetBinContent(x, y, 0.0);
363  }
364  }
365  }
366  }
367  }
368  }
369 
370  } else {
371  LOG_WARN << "cscdqm::Summary.WriteChamberState routine. Wrong histogram dimensions!";
372  }
373  }
374 
379  void Summary::ReSetValue(const HWStatusBit bit) { SetValue(bit, 0); }
380 
386  void Summary::ReSetValue(const Address& adr, const HWStatusBit bit) { SetValue(adr, bit, 0); }
387 
393  void Summary::SetValue(const HWStatusBit bit, const int value) {
394  Address adr;
395  bzero(&adr, sizeof(Address));
396  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv =
397  false;
398  SetValue(adr, bit, value);
399  }
400 
407  void Summary::SetValue(Address adr, const HWStatusBit bit, const int value) {
408  if (!adr.mask.side) {
409  adr.mask.side = true;
410  for (adr.side = 1; adr.side <= N_SIDES; adr.side++)
411  SetValue(adr, bit, value);
412  return;
413  }
414 
415  if (!adr.mask.station) {
416  adr.mask.station = true;
417  for (adr.station = 1; adr.station <= N_STATIONS; adr.station++)
418  SetValue(adr, bit, value);
419  return;
420  }
421 
422  if (!adr.mask.ring) {
423  adr.mask.ring = true;
424  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++)
425  SetValue(adr, bit, value);
426  return;
427  }
428 
429  if (!adr.mask.chamber) {
430  adr.mask.chamber = true;
431  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++)
432  SetValue(adr, bit, value);
433  return;
434  }
435 
436  if (!adr.mask.layer) {
437  adr.mask.layer = true;
438  for (adr.layer = 1; adr.layer <= N_LAYERS; adr.layer++)
439  SetValue(adr, bit, value);
440  return;
441  }
442 
443  if (!adr.mask.cfeb) {
444  adr.mask.cfeb = true;
445  for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++)
446  SetValue(adr, bit, value);
447  return;
448  }
449 
450  if (!adr.mask.hv) {
451  adr.mask.hv = true;
452  for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++)
453  SetValue(adr, bit, value);
454  return;
455  }
456 
457  if (adr.side > 0 && adr.side <= N_SIDES && adr.station > 0 && adr.station <= N_STATIONS && adr.ring > 0 &&
458  adr.ring <= N_RINGS && adr.chamber > 0 && adr.chamber <= N_CHAMBERS && adr.layer > 0 && adr.layer <= N_LAYERS &&
459  adr.cfeb > 0 && adr.cfeb <= N_CFEBS && adr.hv > 0 && adr.hv <= N_HVS) {
460  map[adr.side - 1][adr.station - 1][adr.ring - 1][adr.chamber - 1][adr.layer - 1][adr.cfeb - 1][adr.hv - 1].set(
461  bit, value);
462  }
463  }
464 
473  const int Summary::IsPhysicsReady(const unsigned int px, const unsigned int py) {
474  AddressBox* box;
475 
477 
478  unsigned int i = 0;
479  while (detector.NextAddressBoxByPartition(i, px, py, box)) {
480  status[box->adr.station - 1] |= GetValue(box->adr);
481  }
482 
483  unsigned int cdata = 0, cerror = 0, cmask = 0;
484  for (unsigned int i = 0; i < N_STATIONS; i++) {
485  if (HWSTATUSANYERROR(status[i])) {
486  cerror++;
487  } else {
488  if (status[i].test(MASKED))
489  cmask++;
490  if (status[i].test(DATA))
491  cdata++;
492  }
493  }
494 
496  if (cdata > 1)
497  return 1;
499  if (cerror > 0)
500  return -1;
502  if (cmask > 0)
503  return 2;
505  return 0;
506  }
507 
512  const double Summary::GetEfficiencyHW() const {
513  Address adr;
514  bzero(&adr, sizeof(Address));
515  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv =
516  false;
517  return GetEfficiencyHW(adr);
518  }
519 
525  const double Summary::GetEfficiencyHW(const unsigned int station) const {
526  Address adr;
527  bzero(&adr, sizeof(Address));
528  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv =
529  false;
530 
531  if (station > 0 && station <= N_STATIONS) {
532  adr.mask.station = true;
533  adr.station = station;
534  } else {
535  return 0.0;
536  }
537 
538  return GetEfficiencyHW(adr);
539  }
540 
546  const double Summary::GetEfficiencyHW(Address adr) const {
547  double sum = 0.0;
548  if (!adr.mask.side) {
549  adr.mask.side = true;
550  for (adr.side = 1; adr.side <= N_SIDES; adr.side++)
551  sum += GetEfficiencyHW(adr);
552  return sum / N_SIDES;
553  }
554 
555  if (!adr.mask.station) {
556  adr.mask.station = true;
557  for (adr.station = 1; adr.station <= N_STATIONS; adr.station++)
558  sum += GetEfficiencyHW(adr);
559  return sum / N_STATIONS;
560  }
561 
562  if (!adr.mask.ring) {
563  adr.mask.ring = true;
564  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++)
565  sum += GetEfficiencyHW(adr);
566  return sum / detector.NumberOfRings(adr.station);
567  }
568 
569  if (!adr.mask.chamber) {
570  adr.mask.chamber = true;
571  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++)
572  sum += GetEfficiencyHW(adr);
573  return sum / detector.NumberOfChambers(adr.station, adr.ring);
574  }
575 
576  if (!adr.mask.layer) {
577  adr.mask.layer = true;
578  for (adr.layer = 1; adr.layer <= N_LAYERS; adr.layer++)
579  sum += GetEfficiencyHW(adr);
580  return sum / N_LAYERS;
581  }
582 
583  if (!adr.mask.cfeb) {
584  adr.mask.cfeb = true;
585  for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++)
586  sum += GetEfficiencyHW(adr);
587  return sum / detector.NumberOfChamberCFEBs(adr.station, adr.ring);
588  }
589 
590  if (!adr.mask.hv) {
591  adr.mask.hv = true;
592  for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++)
593  sum += GetEfficiencyHW(adr);
594  return sum / detector.NumberOfChamberHVs(adr.station, adr.ring);
595  }
596 
600  return 0.0;
601  return 1.0;
602  }
603 
609  const double Summary::GetEfficiencyArea(const unsigned int station) const {
610  if (station <= 0 || station > N_STATIONS)
611  return 0.0;
612 
613  Address adr;
614  bzero(&adr, sizeof(Address));
615  adr.mask.side = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
616  adr.mask.station = true;
617  adr.station = station;
618 
619  return GetEfficiencyArea(adr);
620  }
621 
627  const double Summary::GetEfficiencyArea(const Address& adr) const {
628  double all_area = 1;
629 
630  if ((adr.mask.side == false) && (adr.mask.ring == false) && (adr.mask.chamber == false) &&
631  (adr.mask.layer == false) && (adr.mask.cfeb == false) && (adr.mask.hv == false) && (adr.mask.station == true))
632  all_area = detector.Area(adr.station);
633  else
634  all_area = detector.Area(adr);
635 
636  double rep_area = GetReportingArea(adr);
637  return rep_area / all_area;
638  }
639 
645  const double Summary::GetReportingArea(Address adr) const {
646  double sum = 0.0;
647  if (!adr.mask.side) {
648  adr.mask.side = true;
649  for (adr.side = 1; adr.side <= N_SIDES; adr.side++)
650  sum += GetReportingArea(adr);
651  return sum;
652  }
653 
654  if (!adr.mask.station) {
655  adr.mask.station = true;
656  for (adr.station = 1; adr.station <= N_STATIONS; adr.station++)
657  sum += GetReportingArea(adr);
658  return sum;
659  }
660 
661  if (!adr.mask.ring) {
662  adr.mask.ring = true;
663  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++)
664  sum += GetReportingArea(adr);
665  return sum;
666  }
667 
668  if (!adr.mask.chamber) {
669  adr.mask.chamber = true;
670  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++)
671  sum += GetReportingArea(adr);
672  return sum;
673  }
674 
675  if (!adr.mask.cfeb) {
676  adr.mask.cfeb = true;
677  for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++)
678  sum += GetReportingArea(adr);
679  return sum;
680  }
681 
682  if (!adr.mask.hv) {
683  adr.mask.hv = true;
684  for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++)
685  sum += GetReportingArea(adr);
686  return sum;
687  }
688 
689  adr.mask.layer = false;
690 
693  if (!HWSTATUSANYERROR(status)) {
694  return detector.Area(adr);
695  }
696  return 0.0;
697  }
698 
707  bool Summary::isChamberStandby(unsigned int side,
708  unsigned int station,
709  unsigned int ring,
710  unsigned int chamber) const {
711  Address adr;
712  bzero(&adr, sizeof(Address));
713  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = true;
714  adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
715  adr.side = side;
716  adr.station = station;
717  adr.ring = ring;
718  adr.chamber = chamber;
719 
720  //std::cout << adr << " = " << HWSTATUSANY(GetValue(adr), 0x1000) << "\n";
721 
722  return HWSTATUSANY(GetValue(adr), 0x1000);
723  }
724 
731  return isChamberStandby(cid.endcap(), cid.station(), cid.ring(), cid.chamber());
732  }
733 
741  state.reset();
742 
743  if (!adr.mask.side) {
744  adr.mask.side = true;
745  for (adr.side = 1; adr.side <= N_SIDES; adr.side++)
746  state |= GetValue(adr);
747  return state;
748  }
749 
750  if (!adr.mask.station) {
751  adr.mask.station = true;
752  for (adr.station = 1; adr.station <= N_STATIONS; adr.station++)
753  state |= GetValue(adr);
754  return state;
755  }
756 
757  if (!adr.mask.ring) {
758  adr.mask.ring = true;
759  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++)
760  state |= GetValue(adr);
761  return state;
762  }
763 
764  if (!adr.mask.chamber) {
765  adr.mask.chamber = true;
766  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++)
767  state |= GetValue(adr);
768  return state;
769  }
770 
771  if (!adr.mask.layer) {
772  adr.mask.layer = true;
773  for (adr.layer = 1; adr.layer <= N_LAYERS; adr.layer++)
774  state |= GetValue(adr);
775  return state;
776  }
777 
778  if (!adr.mask.cfeb) {
779  adr.mask.cfeb = true;
780  for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++)
781  state |= GetValue(adr);
782  return state;
783  }
784 
785  if (!adr.mask.hv) {
786  adr.mask.hv = true;
787  for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++)
788  state |= GetValue(adr);
789  return state;
790  }
791 
792  return map[adr.side - 1][adr.station - 1][adr.ring - 1][adr.chamber - 1][adr.layer - 1][adr.cfeb - 1][adr.hv - 1];
793  }
794 
800  const unsigned int Summary::setMaskedHWElements(std::vector<std::string>& tokens) {
801  unsigned int applied = 0;
802 
803  for (unsigned int r = 0; r < tokens.size(); r++) {
804  std::string token = (std::string)tokens.at(r);
805  Address adr;
806  if (detector.AddressFromString(token, adr)) {
807  SetValue(adr, MASKED);
808  applied++;
809  }
810  }
811  return applied;
812  }
813 
821  const bool Summary::ChamberCoordsToAddress(const unsigned int x, const unsigned int y, Address& adr) const {
822  if (x < 1 || x > 36 || y < 1 || y > 18)
823  return false;
824 
825  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = true;
826  adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
827 
828  if (y < 10)
829  adr.side = 2;
830  else
831  adr.side = 1;
832 
833  adr.chamber = x;
834 
835  if (y == 1 || y == 18) {
836  adr.station = 4;
837  adr.ring = 2;
838  } else if (y == 2 || y == 17) {
839  adr.station = 4;
840  adr.ring = 1;
841  } else if (y == 3 || y == 16) {
842  adr.station = 3;
843  adr.ring = 2;
844  } else if (y == 4 || y == 15) {
845  adr.station = 3;
846  adr.ring = 1;
847  } else if (y == 5 || y == 14) {
848  adr.station = 2;
849  adr.ring = 2;
850  } else if (y == 6 || y == 13) {
851  adr.station = 2;
852  adr.ring = 1;
853  } else if (y == 7 || y == 12) {
854  adr.station = 1;
855  adr.ring = 3;
856  } else if (y == 8 || y == 11) {
857  adr.station = 1;
858  adr.ring = 2;
859  } else if (y == 9 || y == 10) {
860  adr.station = 1;
861  adr.ring = 1;
862  }
863 
864  return true;
865  }
866 
874  const bool Summary::ChamberAddressToCoords(const Address& adr, unsigned int& x, unsigned int& y) const {
875  if (!adr.mask.side || !adr.mask.station || !adr.mask.ring || !adr.mask.chamber)
876  return false;
877 
878  x = adr.chamber;
879  y = 0;
880 
881  if (adr.side == 1) {
882  switch (adr.station) {
883  case 1:
884  y = 10;
885  if (adr.ring == 2)
886  y = 11;
887  if (adr.ring == 3)
888  y = 12;
889  break;
890  case 2:
891  y = 13;
892  if (adr.ring == 2)
893  y = 14;
894  break;
895  case 3:
896  y = 15;
897  if (adr.ring == 2)
898  y = 16;
899  break;
900  case 4:
901  y = 17;
902  if (adr.ring == 2)
903  y = 18;
904  break;
905  }
906  } else if (adr.side == 2) {
907  switch (adr.station) {
908  case 1:
909  y = 7;
910  if (adr.ring == 2)
911  y = 8;
912  if (adr.ring == 1)
913  y = 9;
914  break;
915  case 2:
916  y = 5;
917  if (adr.ring == 1)
918  y = 6;
919  break;
920  case 3:
921  y = 3;
922  if (adr.ring == 1)
923  y = 4;
924  break;
925  case 4:
926  y = 1;
927  if (adr.ring == 1)
928  y = 2;
929  break;
930  }
931  }
932 
933  return true;
934  }
935 
936 } // namespace cscdqm
const bool NextAddressBox(unsigned int &i, const AddressBox *&box, const Address &mask) const
Address box iterator by mask.
#define N_CHAMBERS
const unsigned int setMaskedHWElements(std::vector< std::string > &tokens)
Read HW element masks (strings), create Address and apply to detector map.
void ReadReportingChambers(const TH2 *&h2, const double threshold=1.0)
Read Reporting Chamber histogram and fill in detector map.
const HWStatusBitSet GetValue(Address adr) const
Get value of some address.
unsigned int layer
#define HWSTATUSANYERROR(s)
HW element was masked out (not in readout)
const bool ChamberCoordsToAddress(const unsigned int x, const unsigned int y, Address &adr) const
Calculate Address from CSCChamberMap histogram coordinates.
const double GetEfficiencyHW() const
Get efficiency of the whole detector.
#define N_LAYERS
void Write(TH2 *&h2, const unsigned int station) const
Write detector map to H1 histogram (linear data) for the selected adr.station.
Area covered by Address in eta/phy space.
#define HWSTATUSANY(s, m)
HWStatusBitSet map[2][4][3][36][6][5][5]
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...
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...
#define HWSTATUSEQUALS(s, m)
const bool NextAddressBoxByPartition(unsigned int &i, const unsigned int px, const unsigned int py, AddressBox *&box)
Address box iterator by partition.
Summary()
Constructor.
const float Area(const unsigned int station) const
Calculate station area in eta/phi space.
Data available (reporting)
unsigned int cfeb
HWStatusBit
Hardware Status Bit values used in Summary efficiency calculation.
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.
#define N_CFEBS
void ReSetValue(const HWStatusBit bit)
ReSetValue for the whole of detector.
const unsigned int NumberOfChamberCFEBs(const unsigned int station, const unsigned int ring) const
Returns the number of CFEBs per Chamber on given Station/Ring.
unsigned int chamber
int chamber() const
Definition: CSCDetId.h:62
unsigned int hv
Definition: value.py:1
void WriteMap(TH2 *&h2)
Write PhysicsReady Map to H2 histogram.
const unsigned int NumberOfRings(const unsigned int station) const
Returns the number of rings for the given station.
unsigned int station
const double GetReportingArea(Address adr) const
Calculate the reporting area for the address.
HW element is hot by comparing with reference histogram.
#define N_STATIONS
bool isChamberStandby(unsigned int side, unsigned int station, unsigned int ring, unsigned int chamber) const
Check if chamber is in standby?
const bool AddressFromString(const std::string &str_address, Address &adr) const
Construct address from string.
const unsigned int NumberOfChambers(const unsigned int station, const unsigned int ring) const
Returns the number of chambers for the given station and ring.
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.
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.
#define N_HVS
#define NTICS
void SetValue(const HWStatusBit bit, const int value=1)
SetValue for the whole of detector.
#define N
Definition: blowfish.cc:9
int station() const
Definition: CSCDetId.h:79
const double GetEfficiencyArea(const unsigned int station) const
Get Efficiency area for the station.
#define N_SIDES
int endcap() const
Definition: CSCDetId.h:85
#define LOG_WARN
Definition: CSCDQM_Logger.h:41
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...
AddressMask mask
void Reset()
Resets all detector map.
float x
std::bitset< 14 > HWStatusBitSet
Hardware Status Bits structure used in Summary efficiency calculation and storage.
unsigned int side
int ring() const
Definition: CSCDetId.h:68
#define HWSTATUSBITSETSIZE
const bool ChamberAddressToCoords(const Address &adr, unsigned int &x, unsigned int &y) const
Calculate CSCChamberMap histogram coordinates from Address.
Structure to store detector addresses of any granularity: from whole detector to the single HV elemen...
void reset(double vett[256])
Definition: TPedValues.cc:11
#define N_RINGS
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
unsigned int ring
const unsigned int NumberOfChamberHVs(const unsigned int station, const unsigned int ring) const
Returns the number of HVs per Chamber on given Station/Ring.
~Summary()
Destructor.