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  Reset();
28  }
29 
34 
38  void Summary::Reset() {
39  Address adr;
40 
42  adr.mask.side = adr.mask.station = adr.mask.layer = false;
43  adr.mask.ring = adr.mask.chamber = adr.mask.cfeb = adr.mask.hv = true;
44  for (adr.ring = 1; adr.ring <= N_RINGS; adr.ring++) {
45  for (adr.chamber = 1; adr.chamber <= N_CHAMBERS; adr.chamber++) {
46  for (adr.cfeb = 1; adr.cfeb <= N_CFEBS; adr.cfeb++) {
47  for (adr.hv = 1; adr.hv <= N_HVS; adr.hv++) {
48  for (unsigned int bit = 0; bit < HWSTATUSBITSETSIZE; bit++) {
49  ReSetValue(adr, (HWStatusBit) bit);
50  }
51  }
52  }
53  }
54  }
55  }
56 
62  void Summary::ReadReportingChambers(const TH2*& h2, const double threshold) {
63 
64  if(h2->GetXaxis()->GetXmin() <= 1 && h2->GetXaxis()->GetXmax() >= 36 &&
65  h2->GetYaxis()->GetXmin() <= 1 && h2->GetYaxis()->GetXmax() >= 18) {
66 
67  Address adr;
68  double z = 0.0;
69 
70  for(unsigned int x = 1; x <= 36; x++) {
71  for(unsigned int y = 1; y <= 18; y++) {
72  z = h2->GetBinContent(x, y);
73  if(ChamberCoordsToAddress(x, y, adr)) {
74  if(z >= threshold) {
75  SetValue(adr, DATA);
76  } else {
77  ReSetValue(adr, DATA);
78  }
79  }
80  }
81  }
82  } else {
83  LOG_WARN << "cscdqm::Summary.ReadReportingChambers routine. Wrong histogram dimensions!";
84  }
85  }
86 
97  void Summary::ReadReportingChambersRef(const TH2*& h2, const TH2*& refh2, const double cold_coef, const double cold_Sfail, const double hot_coef, const double hot_Sfail) {
98 
99  if(h2->GetXaxis()->GetXmin() <= 1 && h2->GetXaxis()->GetXmax() >= 36 &&
100  h2->GetYaxis()->GetXmin() <= 1 && h2->GetYaxis()->GetXmax() >= 18 &&
101  refh2->GetXaxis()->GetXmin() <= 1 && refh2->GetXaxis()->GetXmax() >= 36 &&
102  refh2->GetYaxis()->GetXmin() <= 1 && refh2->GetYaxis()->GetXmax() >= 18) {
103 
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  unsigned int N = 0, n = 0;
120 
121  for(unsigned int x = 1; x <= 36; x++) {
122  for(unsigned int y = 1; y <= 18; y++) {
123 
124  N = int(refh2->GetBinContent(x, y) * factor);
125  n = int(h2->GetBinContent(x, y));
126 
127  if(ChamberCoordsToAddress(x, y, adr)) {
128 
130  ReSetValue(adr, HOT);
131  ReSetValue(adr, COLD);
132 
133  if (n == 0) {
134  ReSetValue(adr, DATA);
135  } else {
136  SetValue(adr, DATA);
137  }
138 
139  switch (Utility::checkOccupancy(N, n, cold_coef, hot_coef, cold_Sfail, hot_Sfail)) {
140  case -1:
141  SetValue(adr, COLD);
142 
143  /*
144  std::cout << "adr = " << detector.AddressName(adr);
145  std::cout << ", x = " << x << ", y = " << y;
146  std::cout << ", value = " << GetValue(adr);
147  std::cout << ", refh2 = " << refh2->GetBinContent(x, y);
148  std::cout << ", factor = " << factor;
149  std::cout << ", N = " << N;
150  std::cout << ", n = " << n;
151  std::cout << ", num = " << num;
152  std::cout << ", denum = " << denum;
153  std::cout << ", rate = " << (N > 0 ? n / N : 0);
154  std::cout << ", cold_coef = " << cold_coef;
155  std::cout << ", = COLD";
156  std::cout << "\n";
157  */
158 
159  break;
160  case 1:
161  SetValue(adr, HOT);
162 
163  /*
164  std::cout << "adr = " << detector.AddressName(adr);
165  std::cout << ", x = " << x << ", y = " << y;
166  std::cout << ", value = " << GetValue(adr);
167  std::cout << ", refh2 = " << refh2->GetBinContent(x, y);
168  std::cout << ", factor = " << factor;
169  std::cout << ", N = " << N;
170  std::cout << ", n = " << n;
171  std::cout << ", num = " << num;
172  std::cout << ", denum = " << denum;
173  std::cout << ", rate = " << (N > 0 ? n / N : 0);
174  std::cout << ", hot_coef = " << hot_coef;
175  std::cout << ", = HOT";
176  std::cout << "\n";
177  */
178 
179  break;
180  };
181 
182 
183  }
184 
185  }
186  }
187 
188  } else {
189  LOG_WARN << "cscdqm::Summary.ReadReportingChambersRef routine. Wrong histogram dimensions!";
190  }
191  }
192 
201  void Summary::ReadErrorChambers(const TH2*& evs, const TH2*& err, const HWStatusBit bit, const double eps_max, const double Sfail) {
202 
203  if(evs->GetXaxis()->GetXmin() <= 1 && evs->GetXaxis()->GetXmax() >= 36 &&
204  evs->GetYaxis()->GetXmin() <= 1 && evs->GetYaxis()->GetXmax() >= 18 &&
205  err->GetXaxis()->GetXmin() <= 1 && err->GetXaxis()->GetXmax() >= 36 &&
206  err->GetYaxis()->GetXmin() <= 1 && err->GetYaxis()->GetXmax() >= 18) {
207 
208  Address adr;
209  unsigned int N = 0, n = 0;
210 
211  for(unsigned int x = 1; x <= 36; x++) {
212  for(unsigned int y = 1; y <= 18; y++) {
213  N = int(evs->GetBinContent(x, y));
214  n = int(err->GetBinContent(x, y));
215  if (ChamberCoordsToAddress(x, y, adr)) {
216  if(Utility::checkError(N, n, eps_max, Sfail)) {
217  SetValue(adr, bit);
218  } else {
219  ReSetValue(adr, bit);
220  }
221  }
222  }
223  }
224  } else {
225  LOG_WARN << "cscdqm::Summary.ReadErrorChambers routine. Wrong histogram dimensions!";
226  }
227  }
228 
234  void Summary::Write(TH2*& h2, const unsigned int station) const {
235  const AddressBox* box;
236  Address adr, tadr;
237  float area_all = 0.0, area_rep = 0.0;
238 
239  if(station < 1 || station > N_STATIONS) return;
240 
241  adr.mask.side = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
242  adr.mask.station = true;
243  adr.station = station;
244 
245  unsigned int i = 0;
246 
247  while (detector.NextAddressBox(i, box, adr)) {
248 
249  unsigned int x = 1 + (box->adr.side - 1) * 9 + (box->adr.ring - 1) * 3 + (box->adr.hv - 1);
250  unsigned int y = 1 + (box->adr.chamber - 1) * 5 + (box->adr.cfeb - 1);
251 
252  tadr = box->adr;
254 
255  float area_box = fabs((box->xmax - box->xmin) * (box->ymax - box->ymin));
256 
257  if (status.test(MASKED)) {
258  h2->SetBinContent(x, y, 2.0);
259  } else {
260  area_all += area_box;
261  if (HWSTATUSANYERROR(status)) {
262  h2->SetBinContent(x, y, -1.0);
263  } else {
264  area_rep += area_box;
265  if (status.test(DATA)) {
266  h2->SetBinContent(x, y, 1.0);
267  } else {
268  h2->SetBinContent(x, y, 0.0);
269  }
270  }
271  }
272 
273  }
274 
275  TString title = Form("ME%d Status: Physics Efficiency %.2f%%", station, (area_rep / area_all) * 100.0);
276  h2->SetTitle(title);
277 
278  }
279 
284  void Summary::WriteMap(TH2*& h2) {
285 
286  unsigned int rep_el = 0, csc_el = 0;
287 
288  if(h2->GetXaxis()->GetXmin() <= 1 && h2->GetXaxis()->GetXmax() >= NTICS &&
289  h2->GetYaxis()->GetXmin() <= 1 && h2->GetYaxis()->GetXmax() >= NTICS) {
290 
291  float xd = 5.0 / NTICS;
292 
293  float xmin, xmax;
294 
295  for(unsigned int x = 0; x < NTICS; x++) {
296 
297  xmin = -2.5 + xd * x;
298  xmax = xmin + xd;
299 
300  for(unsigned int y = 0; y < NTICS; y++) {
301 
302  double value = 0.0;
303 
304  if (xmin == -2.5 || xmax == 2.5) continue;
305  if (xmin >= -1 && xmax <= 1) continue;
306 
307  switch(IsPhysicsReady(x, y)) {
308  case -1:
309  value = -1.0;
310  break;
311  case 0:
312  value = 0.0;
313  rep_el++;
314  break;
315  case 1:
316  value = 1.0;
317  rep_el++;
318  break;
319  case 2:
320  value = 2.0;
321  rep_el++;
322  }
323 
324  h2->SetBinContent(x + 1, y + 1, value);
325  csc_el++;
326 
327  }
328  }
329 
330  } else {
331  LOG_WARN << "cscdqm::Summary.WriteMap routine. Wrong histogram dimensions!";
332  }
333 
334  TString title = Form("EMU Status: Physics Efficiency %.2f%%", (csc_el == 0 ? 0.0 : (1.0 * rep_el) / csc_el) * 100.0);
335  h2->SetTitle(title);
336 
337  }
338 
339 
348  void Summary::WriteChamberState(TH2*& h2, const int mask, const int value, const bool reset, const bool op_any) const {
349 
350  if(h2->GetXaxis()->GetXmin() <= 1 && h2->GetXaxis()->GetXmax() >= 36 &&
351  h2->GetYaxis()->GetXmin() <= 1 && h2->GetYaxis()->GetXmax() >= 18) {
352 
353  unsigned int x, y;
354  Address adr;
355 
356  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = true;
357  adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
358 
359  for (adr.side = 1; adr.side <= N_SIDES; adr.side++) {
360  for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) {
361  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) {
362  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) {
363  if (ChamberAddressToCoords(adr, x, y)) {
364  HWStatusBitSet hwValue = GetValue(adr);
365  bool hit = (op_any ? HWSTATUSANY(hwValue, mask) : HWSTATUSEQUALS(hwValue, mask));
366 
367  // std::cout << "x = " << x << ", y = " << y << ", value = " << GetValue(adr) << std::endl;
368  // std::cout << "adr = " << detector.AddressName(adr) << ", x = " << x << ", y = " << y << ", value = " << GetValue(adr) << std::endl;
369  if (hit) {
370  h2->SetBinContent(x, y, 1.0 * value);
371  } else if (reset) {
372  h2->SetBinContent(x, y, 0.0);
373  }
374  }
375  }
376  }
377  }
378  }
379 
380  } else {
381  LOG_WARN << "cscdqm::Summary.WriteChamberState routine. Wrong histogram dimensions!";
382  }
383 
384  }
385 
391  SetValue(bit, 0);
392  }
393 
399  void Summary::ReSetValue(const Address& adr, const HWStatusBit bit) {
400  SetValue(adr, bit, 0);
401  }
402 
408  void Summary::SetValue(const HWStatusBit bit, const int value) {
409  Address adr;
410  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
411  SetValue(adr, bit, value);
412  }
413 
420  void Summary::SetValue(Address adr, const HWStatusBit bit, const int value) {
421  if (!adr.mask.side) {
422  adr.mask.side = true;
423  for (adr.side = 1; adr.side <= N_SIDES; adr.side++) SetValue(adr, bit, value);
424  return;
425  }
426 
427  if (!adr.mask.station) {
428  adr.mask.station = true;
429  for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) SetValue(adr, bit, value);
430  return;
431  }
432 
433  if (!adr.mask.ring) {
434  adr.mask.ring = true;
435  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) SetValue(adr, bit, value);
436  return;
437  }
438 
439  if (!adr.mask.chamber) {
440  adr.mask.chamber = true;
441  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) SetValue(adr, bit, value);
442  return;
443  }
444 
445  if (!adr.mask.layer) {
446  adr.mask.layer = true;
447  for (adr.layer = 1; adr.layer <= N_LAYERS; adr.layer++) SetValue(adr, bit, value);
448  return;
449  }
450 
451  if (!adr.mask.cfeb) {
452  adr.mask.cfeb = true;
453  for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++) SetValue(adr, bit, value);
454  return;
455  }
456 
457  if (!adr.mask.hv) {
458  adr.mask.hv = true;
459  for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++) SetValue(adr, bit, value);
460  return;
461  }
462 
463  if( adr.side > 0 && adr.side <= N_SIDES && adr.station > 0 && adr.station <= N_STATIONS &&
464  adr.ring > 0 && adr.ring <= N_RINGS && adr.chamber > 0 && adr.chamber <= N_CHAMBERS &&
465  adr.layer > 0 && adr.layer <= N_LAYERS && adr.cfeb > 0 && adr.cfeb <= N_CFEBS && adr.hv > 0 && adr.hv <= N_HVS) {
466 
467  map[adr.side - 1][adr.station - 1][adr.ring - 1][adr.chamber - 1][adr.layer - 1][adr.cfeb - 1][adr.hv - 1].set(bit, value);
468 
469  }
470 
471  }
472 
481  const int Summary::IsPhysicsReady(const unsigned int px, const unsigned int py) {
482 
483  AddressBox *box;
484 
486 
487  unsigned int i = 0;
488  while(detector.NextAddressBoxByPartition(i, px, py, box)) {
489  status[box->adr.station - 1] |= GetValue(box->adr);
490  }
491 
492  unsigned int cdata = 0, cerror = 0, cmask = 0;
493  for (unsigned int i = 0; i < N_STATIONS; i++) {
494  if (HWSTATUSANYERROR(status[i])) {
495  cerror++;
496  } else {
497  if (status[i].test(MASKED)) cmask++;
498  if (status[i].test(DATA)) cdata++;
499  }
500  }
501 
503  if (cdata > 1) return 1;
505  if (cerror > 0) return -1;
507  if (cmask > 0) return 2;
509  return 0;
510 
511  }
512 
517  const double Summary::GetEfficiencyHW() const {
518 
519  Address adr;
520  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
521  return GetEfficiencyHW(adr);
522 
523  }
524 
530  const double Summary::GetEfficiencyHW(const unsigned int station) const {
531 
532  Address adr;
533  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
534 
535  if (station > 0 && station <= N_STATIONS) {
536  adr.mask.station = true;
537  adr.station = station;
538  } else {
539  return 0.0;
540  }
541 
542  return GetEfficiencyHW(adr);
543 
544  }
545 
551  const double Summary::GetEfficiencyHW(Address adr) const {
552  double sum = 0.0;
553  if (!adr.mask.side) {
554  adr.mask.side = true;
555  for (adr.side = 1; adr.side <= N_SIDES; adr.side++) sum += GetEfficiencyHW(adr);
556  return sum / N_SIDES;
557  }
558 
559  if (!adr.mask.station) {
560  adr.mask.station = true;
561  for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) sum += GetEfficiencyHW(adr);
562  return sum / N_STATIONS;
563  }
564 
565  if (!adr.mask.ring) {
566  adr.mask.ring = true;
567  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) sum += GetEfficiencyHW(adr);
568  return sum / detector.NumberOfRings(adr.station);
569  }
570 
571  if (!adr.mask.chamber) {
572  adr.mask.chamber = true;
573  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) sum += GetEfficiencyHW(adr);
574  return sum / detector.NumberOfChambers(adr.station, adr.ring);
575  }
576 
577  if (!adr.mask.layer) {
578  adr.mask.layer = true;
579  for (adr.layer = 1; adr.layer <= N_LAYERS; adr.layer++) 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++) sum += GetEfficiencyHW(adr);
586  return sum / detector.NumberOfChamberCFEBs(adr.station, adr.ring);
587  }
588 
589  if (!adr.mask.hv) {
590  adr.mask.hv = true;
591  for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++) sum += GetEfficiencyHW(adr);
592  return sum / detector.NumberOfChamberHVs(adr.station, adr.ring);
593  }
594 
597  if (HWSTATUSANYERROR(status)) return 0.0;
598  return 1.0;
599 
600  }
601 
607  const double Summary::GetEfficiencyArea(const unsigned int station) const {
608  if (station <= 0 || station > N_STATIONS) return 0.0;
609 
610  Address adr;
611  adr.mask.side = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
612  adr.station = true;
613  adr.station = station;
614 
615  return GetEfficiencyArea(adr);
616  }
617 
623  const double Summary::GetEfficiencyArea(const Address& adr) const {
624  double all_area = 1;
625 
626  if (adr.mask.side == false &&
627  adr.mask.ring == false &&
628  adr.mask.chamber == false &&
629  adr.mask.layer == false &&
630  adr.mask.cfeb == false &&
631  adr.mask.hv == false &&
632  adr.mask.station == true)
633  all_area = detector.Area(adr.station);
634  else
635  all_area = detector.Area(adr);
636 
637  double rep_area = GetReportingArea(adr);
638  return rep_area / all_area;
639  }
640 
646  const double Summary::GetReportingArea(Address adr) const {
647  double sum = 0.0;
648  if (!adr.mask.side) {
649  adr.mask.side = true;
650  for (adr.side = 1; adr.side <= N_SIDES; adr.side++) 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++) sum += GetReportingArea(adr);
657  return sum;
658  }
659 
660  if (!adr.mask.ring) {
661  adr.mask.ring = true;
662  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) sum += GetReportingArea(adr);
663  return sum;
664  }
665 
666  if (!adr.mask.chamber) {
667  adr.mask.chamber = true;
668  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) sum += GetReportingArea(adr);
669  return sum;
670  }
671 
672  if (!adr.mask.cfeb) {
673  adr.mask.cfeb = true;
674  for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++) sum += GetReportingArea(adr);
675  return sum;
676  }
677 
678  if (!adr.mask.hv) {
679  adr.mask.hv = true;
680  for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++) sum += GetReportingArea(adr);
681  return sum;
682  }
683 
684  adr.mask.layer = false;
685 
688  if (!HWSTATUSANYERROR(status)) {
689  return detector.Area(adr);
690  }
691  return 0.0;
692 
693  }
694 
703  bool Summary::isChamberStandby(unsigned int side, unsigned int station, unsigned int ring, unsigned int chamber) const {
704 
705  Address adr;
706  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = true;
707  adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
708  adr.side = side;
709  adr.station = station;
710  adr.ring = ring;
711  adr.chamber = chamber;
712 
713  //std::cout << adr << " = " << HWSTATUSANY(GetValue(adr), 0x1000) << "\n";
714 
715  return HWSTATUSANY(GetValue(adr), 0x1000);
716  }
717 
724  return isChamberStandby(cid.endcap(), cid.station(), cid.ring(), cid.chamber());
725  }
726 
733  HWStatusBitSet state;
734  state.reset();
735 
736  if (!adr.mask.side) {
737  adr.mask.side = true;
738  for (adr.side = 1; adr.side <= N_SIDES; adr.side++) state |= GetValue(adr);
739  return state;
740  }
741 
742  if (!adr.mask.station) {
743  adr.mask.station = true;
744  for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) state |= GetValue(adr);
745  return state;
746  }
747 
748  if (!adr.mask.ring) {
749  adr.mask.ring = true;
750  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) state |= GetValue(adr);
751  return state;
752  }
753 
754  if (!adr.mask.chamber) {
755  adr.mask.chamber = true;
756  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) state |= GetValue(adr);
757  return state;
758  }
759 
760  if (!adr.mask.layer) {
761  adr.mask.layer = true;
762  for (adr.layer = 1; adr.layer <= N_LAYERS; adr.layer++) 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++) state |= GetValue(adr);
769  return state;
770  }
771 
772  if (!adr.mask.hv) {
773  adr.mask.hv = true;
774  for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++) state |= GetValue(adr);
775  return state;
776  }
777 
778  return map[adr.side - 1][adr.station - 1][adr.ring - 1][adr.chamber - 1][adr.layer - 1][adr.cfeb - 1][adr.hv - 1];
779 
780  }
781 
787  const unsigned int Summary::setMaskedHWElements(std::vector<std::string>& tokens) {
788  unsigned int applied = 0;
789 
790  for (unsigned int r = 0; r < tokens.size(); r++) {
791  std::string token = (std::string) tokens.at(r);
792  Address adr;
793  if (detector.AddressFromString(token, adr)) {
794  SetValue(adr, MASKED);
795  applied++;
796  }
797  }
798  return applied;
799  }
800 
808  const bool Summary::ChamberCoordsToAddress(const unsigned int x, const unsigned int y, Address& adr) const {
809 
810  if( x < 1 || x > 36 || y < 1 || y > 18) return false;
811 
812  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = true;
813  adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
814 
815  if ( y < 10 ) adr.side = 2;
816  else adr.side = 1;
817 
818  adr.chamber = x;
819 
820  if (y == 1 || y == 18) {
821  adr.station = 4;
822  adr.ring = 2;
823  } else
824  if (y == 2 || y == 17) {
825  adr.station = 4;
826  adr.ring = 1;
827  } else
828  if (y == 3 || y == 16) {
829  adr.station = 3;
830  adr.ring = 2;
831  } else
832  if (y == 4 || y == 15) {
833  adr.station = 3;
834  adr.ring = 1;
835  } else
836  if (y == 5 || y == 14) {
837  adr.station = 2;
838  adr.ring = 2;
839  } else
840  if (y == 6 || y == 13) {
841  adr.station = 2;
842  adr.ring = 1;
843  } else
844  if (y == 7 || y == 12) {
845  adr.station = 1;
846  adr.ring = 3;
847  } else
848  if (y == 8 || y == 11) {
849  adr.station = 1;
850  adr.ring = 2;
851  } else
852  if (y == 9 || y == 10) {
853  adr.station = 1;
854  adr.ring = 1;
855  }
856 
857  return true;
858 
859  }
860 
868  const bool Summary::ChamberAddressToCoords(const Address& adr, unsigned int& x, unsigned int& y) const {
869 
870  if (!adr.mask.side || !adr.mask.station || !adr.mask.ring || !adr.mask.chamber) return false;
871 
872  x = adr.chamber;
873  y = 0;
874 
875  if (adr.side == 1) {
876  switch (adr.station) {
877  case 1:
878  y = 10;
879  if (adr.ring == 2) y = 11;
880  if (adr.ring == 3) y = 12;
881  break;
882  case 2:
883  y = 13;
884  if (adr.ring == 2) y = 14;
885  break;
886  case 3:
887  y = 15;
888  if (adr.ring == 2) y = 16;
889  break;
890  case 4:
891  y = 17;
892  if (adr.ring == 2) y = 18;
893  break;
894  }
895  } else
896  if (adr.side == 2) {
897  switch (adr.station) {
898  case 1:
899  y = 7;
900  if (adr.ring == 2) y = 8;
901  if (adr.ring == 1) y = 9;
902  break;
903  case 2:
904  y = 5;
905  if (adr.ring == 1) y = 6;
906  break;
907  case 3:
908  y = 3;
909  if (adr.ring == 1) y = 4;
910  break;
911  case 4:
912  y = 1;
913  if (adr.ring == 1) y = 2;
914  break;
915  }
916  }
917 
918  return true;
919 
920  }
921 
922 }
int chamber() const
Definition: CSCDetId.h:68
#define N_CHAMBERS
const unsigned int setMaskedHWElements(std::vector< std::string > &tokens)
Read HW element masks (strings), create Address and apply to detector map.
const bool AddressFromString(const std::string &str_address, Address &adr) const
Construct address from string.
void ReadReportingChambers(const TH2 *&h2, const double threshold=1.0)
Read Reporting Chamber histogram and fill in detector map.
unsigned int layer
HW element was masked out (not in readout)
const float Area(const unsigned int station) const
Calculate station area in eta/phi space.
const bool NextAddressBox(unsigned int &i, const AddressBox *&box, const Address &mask) const
Address box iterator by mask.
void Write(TH2 *&h2, const unsigned int station) const
Write detector map to H1 histogram (linear data) for the selected adr.station.
bool isChamberStandby(unsigned int side, unsigned int station, unsigned int ring, unsigned int chamber) const
Check if chamber is in standby?
const HWStatusBitSet GetValue(Address adr) const
Get value of some address.
#define N_LAYERS
Area covered by Address in eta/phy space.
const unsigned int NumberOfRings(const unsigned int station) const
Returns the number of rings for the given station.
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.
const unsigned int NumberOfChamberCFEBs(const unsigned int station, const unsigned int ring) const
Returns the number of CFEBs per Chamber on given Station/Ring.
int endcap() const
Definition: CSCDetId.h:93
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()
Constructor.
Data available (reporting)
const bool ChamberAddressToCoords(const Address &adr, unsigned int &x, unsigned int &y) const
Calculate CSCChamberMap histogram coordinates from Address.
unsigned int cfeb
HWStatusBit
Hardware Status Bit values used in Summary efficiency calculation.
const double GetEfficiencyHW() const
Get efficiency of the whole detector.
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.
const double GetEfficiencyArea(const unsigned int station) const
Get Efficiency area for the station.
#define HWSTATUSANYERROR(s)
#define N_CFEBS
void ReSetValue(const HWStatusBit bit)
ReSetValue for the whole of detector.
#define HWSTATUSANY(s, m)
unsigned int chamber
unsigned int hv
Definition: value.py:1
void WriteMap(TH2 *&h2)
Write PhysicsReady Map to H2 histogram.
unsigned int station
HW element is hot by comparing with reference histogram.
#define N_STATIONS
int ring() const
Definition: CSCDetId.h:75
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.
#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
#define N_SIDES
#define LOG_WARN
Definition: CSCDQM_Logger.h:42
const double GetReportingArea(Address adr) const
Calculate the reporting area for the address.
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...
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.
AddressMask mask
const bool ChamberCoordsToAddress(const unsigned int x, const unsigned int y, Address &adr) const
Calculate Address from CSCChamberMap histogram coordinates.
void Reset()
Resets all detector map.
std::bitset< 14 > HWStatusBitSet
Hardware Status Bits structure used in Summary efficiency calculation and storage.
int station() const
Definition: CSCDetId.h:86
unsigned int side
const unsigned int NumberOfChambers(const unsigned int station, const unsigned int ring) const
Returns the number of chambers for the given station and ring.
#define HWSTATUSBITSETSIZE
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:40
unsigned int ring
~Summary()
Destructor.