CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
20 
21 namespace cscdqm {
22 
26  Summary::Summary() : detector(NTICS, NTICS) {
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(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 
422  if (!adr.mask.side) {
423  adr.mask.side = true;
424  for (adr.side = 1; adr.side <= N_SIDES; adr.side++) SetValue(adr, bit, value);
425  return;
426  }
427 
428  if (!adr.mask.station) {
429  adr.mask.station = true;
430  for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) SetValue(adr, bit, value);
431  return;
432  }
433 
434  if (!adr.mask.ring) {
435  adr.mask.ring = true;
436  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) SetValue(adr, bit, value);
437  return;
438  }
439 
440  if (!adr.mask.chamber) {
441  adr.mask.chamber = true;
442  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) SetValue(adr, bit, value);
443  return;
444  }
445 
446  if (!adr.mask.layer) {
447  adr.mask.layer = true;
448  for (adr.layer = 1; adr.layer <= N_LAYERS; adr.layer++) SetValue(adr, bit, value);
449  return;
450  }
451 
452  if (!adr.mask.cfeb) {
453  adr.mask.cfeb = true;
454  for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++) SetValue(adr, bit, value);
455  return;
456  }
457 
458  if (!adr.mask.hv) {
459  adr.mask.hv = true;
460  for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++) SetValue(adr, bit, value);
461  return;
462  }
463 
464  if( adr.side > 0 && adr.side <= N_SIDES && adr.station > 0 && adr.station <= N_STATIONS &&
465  adr.ring > 0 && adr.ring <= N_RINGS && adr.chamber > 0 && adr.chamber <= N_CHAMBERS &&
466  adr.layer > 0 && adr.layer <= N_LAYERS && adr.cfeb > 0 && adr.cfeb <= N_CFEBS && adr.hv > 0 && adr.hv <= N_HVS) {
467 
468  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);
469 
470  }
471 
472  }
473 
482  const int Summary::IsPhysicsReady(const unsigned int px, const unsigned int py) {
483 
484  AddressBox *box;
485 
487 
488  unsigned int i = 0;
489  while(detector.NextAddressBoxByPartition(i, px, py, box)) {
490  status[box->adr.station - 1] |= GetValue(box->adr);
491  }
492 
493  unsigned int cdata = 0, cerror = 0, cmask = 0;
494  for (unsigned int i = 0; i < N_STATIONS; i++) {
495  if (HWSTATUSANYERROR(status[i])) {
496  cerror++;
497  } else {
498  if (status[i].test(MASKED)) cmask++;
499  if (status[i].test(DATA)) cdata++;
500  }
501  }
502 
504  if (cdata > 1) return 1;
506  if (cerror > 0) return -1;
508  if (cmask > 0) return 2;
510  return 0;
511 
512  }
513 
518  const double Summary::GetEfficiencyHW() const {
519 
520  Address adr;
521  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
522  return GetEfficiencyHW(adr);
523 
524  }
525 
531  const double Summary::GetEfficiencyHW(const unsigned int station) const {
532 
533  Address adr;
534  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
535 
536  if (station > 0 && station <= N_STATIONS) {
537  adr.mask.station = true;
538  adr.station = station;
539  } else {
540  return 0.0;
541  }
542 
543  return GetEfficiencyHW(adr);
544 
545  }
546 
552  const double Summary::GetEfficiencyHW(Address adr) const {
553  double sum = 0.0;
554 
555  if (!adr.mask.side) {
556  adr.mask.side = true;
557  for (adr.side = 1; adr.side <= N_SIDES; adr.side++) sum += GetEfficiencyHW(adr);
558  return sum / N_SIDES;
559  }
560 
561  if (!adr.mask.station) {
562  adr.mask.station = true;
563  for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) sum += GetEfficiencyHW(adr);
564  return sum / N_STATIONS;
565  }
566 
567  if (!adr.mask.ring) {
568  adr.mask.ring = true;
569  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) sum += GetEfficiencyHW(adr);
570  return sum / detector.NumberOfRings(adr.station);
571  }
572 
573  if (!adr.mask.chamber) {
574  adr.mask.chamber = true;
575  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) sum += GetEfficiencyHW(adr);
576  return sum / detector.NumberOfChambers(adr.station, adr.ring);
577  }
578 
579  if (!adr.mask.layer) {
580  adr.mask.layer = true;
581  for (adr.layer = 1; adr.layer <= N_LAYERS; adr.layer++) sum += GetEfficiencyHW(adr);
582  return sum / N_LAYERS;
583  }
584 
585  if (!adr.mask.cfeb) {
586  adr.mask.cfeb = true;
587  for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++) sum += GetEfficiencyHW(adr);
588  return sum / detector.NumberOfChamberCFEBs(adr.station, adr.ring);
589  }
590 
591  if (!adr.mask.hv) {
592  adr.mask.hv = true;
593  for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++) sum += GetEfficiencyHW(adr);
594  return sum / detector.NumberOfChamberHVs(adr.station, adr.ring);
595  }
596 
599  if (HWSTATUSANYERROR(status)) return 0.0;
600  return 1.0;
601 
602  }
603 
609  const double Summary::GetEfficiencyArea(const unsigned int station) const {
610  if (station <= 0 || station > N_STATIONS) return 0.0;
611 
612  Address adr;
613  adr.mask.side = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
614  adr.station = true;
615  adr.station = station;
616 
617  return GetEfficiencyArea(adr);
618  }
619 
625  const double Summary::GetEfficiencyArea(Address adr) const {
626  double all_area = 1;
627 
628  if (adr.mask.side == false &&
629  adr.mask.ring == false &&
630  adr.mask.chamber == false &&
631  adr.mask.layer == false &&
632  adr.mask.cfeb == false &&
633  adr.mask.hv == false &&
634  adr.mask.station == true)
635  all_area = detector.Area(adr.station);
636  else
637  all_area = detector.Area(adr);
638 
639  double rep_area = GetReportingArea(adr);
640  return rep_area / all_area;
641  }
642 
648  const double Summary::GetReportingArea(Address adr) const {
649  double sum = 0.0;
650 
651  if (!adr.mask.side) {
652  adr.mask.side = true;
653  for (adr.side = 1; adr.side <= N_SIDES; adr.side++) sum += GetReportingArea(adr);
654  return sum;
655  }
656 
657  if (!adr.mask.station) {
658  adr.mask.station = true;
659  for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) sum += GetReportingArea(adr);
660  return sum;
661  }
662 
663  if (!adr.mask.ring) {
664  adr.mask.ring = true;
665  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) sum += GetReportingArea(adr);
666  return sum;
667  }
668 
669  if (!adr.mask.chamber) {
670  adr.mask.chamber = true;
671  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) 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++) sum += GetReportingArea(adr);
678  return sum;
679  }
680 
681  if (!adr.mask.hv) {
682  adr.mask.hv = true;
683  for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++) sum += GetReportingArea(adr);
684  return sum;
685  }
686 
687  adr.mask.layer = false;
688 
691  if (!HWSTATUSANYERROR(status)) {
692  return detector.Area(adr);
693  }
694  return 0.0;
695 
696  }
697 
706  bool Summary::isChamberStandby(unsigned int side, unsigned int station, unsigned int ring, unsigned int chamber) const {
707 
708  Address adr;
709  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = true;
710  adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
711  adr.side = side;
712  adr.station = station;
713  adr.ring = ring;
714  adr.chamber = chamber;
715 
716  //std::cout << adr << " = " << HWSTATUSANY(GetValue(adr), 0x1000) << "\n";
717 
718  return HWSTATUSANY(GetValue(adr), 0x1000);
719  }
720 
727  return isChamberStandby(cid.endcap(), cid.station(), cid.ring(), cid.chamber());
728  }
729 
736 
738  state.reset();
739 
740  if (!adr.mask.side) {
741  adr.mask.side = true;
742  for (adr.side = 1; adr.side <= N_SIDES; adr.side++) state |= GetValue(adr);
743  return state;
744  }
745 
746  if (!adr.mask.station) {
747  adr.mask.station = true;
748  for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) state |= GetValue(adr);
749  return state;
750  }
751 
752  if (!adr.mask.ring) {
753  adr.mask.ring = true;
754  for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) state |= GetValue(adr);
755  return state;
756  }
757 
758  if (!adr.mask.chamber) {
759  adr.mask.chamber = true;
760  for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) state |= GetValue(adr);
761  return state;
762  }
763 
764  if (!adr.mask.layer) {
765  adr.mask.layer = true;
766  for (adr.layer = 1; adr.layer <= N_LAYERS; adr.layer++) state |= GetValue(adr);
767  return state;
768  }
769 
770  if (!adr.mask.cfeb) {
771  adr.mask.cfeb = true;
772  for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++) state |= GetValue(adr);
773  return state;
774  }
775 
776  if (!adr.mask.hv) {
777  adr.mask.hv = true;
778  for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++) state |= GetValue(adr);
779  return state;
780  }
781 
782  return map[adr.side - 1][adr.station - 1][adr.ring - 1][adr.chamber - 1][adr.layer - 1][adr.cfeb - 1][adr.hv - 1];
783 
784  }
785 
791  const unsigned int Summary::setMaskedHWElements(std::vector<std::string>& tokens) {
792  unsigned int applied = 0;
793 
794  for (unsigned int r = 0; r < tokens.size(); r++) {
795  std::string token = (std::string) tokens.at(r);
796  Address adr;
797  if (detector.AddressFromString(token, adr)) {
798  SetValue(adr, MASKED);
799  applied++;
800  }
801  }
802  return applied;
803  }
804 
812  const bool Summary::ChamberCoordsToAddress(const unsigned int x, const unsigned int y, Address& adr) const {
813 
814  if( x < 1 || x > 36 || y < 1 || y > 18) return false;
815 
816  adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = true;
817  adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
818 
819  if ( y < 10 ) adr.side = 2;
820  else adr.side = 1;
821 
822  adr.chamber = x;
823 
824  if (y == 1 || y == 18) {
825  adr.station = 4;
826  adr.ring = 2;
827  } else
828  if (y == 2 || y == 17) {
829  adr.station = 4;
830  adr.ring = 1;
831  } else
832  if (y == 3 || y == 16) {
833  adr.station = 3;
834  adr.ring = 2;
835  } else
836  if (y == 4 || y == 15) {
837  adr.station = 3;
838  adr.ring = 1;
839  } else
840  if (y == 5 || y == 14) {
841  adr.station = 2;
842  adr.ring = 2;
843  } else
844  if (y == 6 || y == 13) {
845  adr.station = 2;
846  adr.ring = 1;
847  } else
848  if (y == 7 || y == 12) {
849  adr.station = 1;
850  adr.ring = 3;
851  } else
852  if (y == 8 || y == 11) {
853  adr.station = 1;
854  adr.ring = 2;
855  } else
856  if (y == 9 || y == 10) {
857  adr.station = 1;
858  adr.ring = 1;
859  }
860 
861  return true;
862 
863  }
864 
872  const bool Summary::ChamberAddressToCoords(const Address& adr, unsigned int& x, unsigned int& y) const {
873 
874  if (!adr.mask.side || !adr.mask.station || !adr.mask.ring || !adr.mask.chamber) return false;
875 
876  x = adr.chamber;
877  y = 0;
878 
879  if (adr.side == 1) {
880  switch (adr.station) {
881  case 1:
882  y = 10;
883  if (adr.ring == 2) y = 11;
884  if (adr.ring == 3) y = 12;
885  break;
886  case 2:
887  y = 13;
888  if (adr.ring == 2) y = 14;
889  break;
890  case 3:
891  y = 15;
892  if (adr.ring == 2) y = 16;
893  break;
894  case 4:
895  y = 17;
896  if (adr.ring == 2) y = 18;
897  break;
898  }
899  } else
900  if (adr.side == 2) {
901  switch (adr.station) {
902  case 1:
903  y = 7;
904  if (adr.ring == 2) y = 8;
905  if (adr.ring == 1) y = 9;
906  break;
907  case 2:
908  y = 5;
909  if (adr.ring == 1) y = 6;
910  break;
911  case 3:
912  y = 3;
913  if (adr.ring == 1) y = 4;
914  break;
915  case 4:
916  y = 1;
917  if (adr.ring == 1) y = 2;
918  break;
919  }
920  }
921 
922  return true;
923 
924  }
925 
926 }
int chamber() const
Definition: CSCDetId.h:70
#define N_CHAMBERS
const unsigned int setMaskedHWElements(std::vector< std::string > &tokens)
Read HW element masks (strings), create Address and apply to detector map.
int i
Definition: DBlmapReader.cc:9
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
#define HWSTATUSANYERROR(s)
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.
#define HWSTATUSANY(s, m)
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.
double double double z
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:95
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 N_CFEBS
void ReSetValue(const HWStatusBit bit)
ReSetValue for the whole of detector.
unsigned int chamber
unsigned int hv
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:77
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
long long int num
Definition: procUtils.cc:71
#define LOG_WARN
Definition: CSCDQM_Logger.h:42
char state
Definition: procUtils.cc:75
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:88
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.
tuple status
Definition: ntuplemaker.py:245
#define HWSTATUSBITSETSIZE
x
Definition: VDTMath.h:216
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.