00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "DQM/CSCMonitorModule/interface/CSCDQM_Summary.h"
00020
00021 namespace cscdqm {
00022
00026 Summary::Summary() : detector(NTICS, NTICS) {
00027 Reset();
00028 }
00029
00033 Summary::~Summary() { }
00034
00038 void Summary::Reset() {
00039 Address adr;
00040
00042 adr.mask.side = adr.mask.station = adr.mask.layer = false;
00043 adr.mask.ring = adr.mask.chamber = adr.mask.cfeb = adr.mask.hv = true;
00044 for (adr.ring = 1; adr.ring <= N_RINGS; adr.ring++) {
00045 for (adr.chamber = 1; adr.chamber <= N_CHAMBERS; adr.chamber++) {
00046 for (adr.cfeb = 1; adr.cfeb <= N_CFEBS; adr.cfeb++) {
00047 for (adr.hv = 1; adr.hv <= N_HVS; adr.hv++) {
00048 for (unsigned int bit = 0; bit < HWSTATUSBITSETSIZE; bit++) {
00049 ReSetValue(adr, (HWStatusBit) bit);
00050 }
00051 }
00052 }
00053 }
00054 }
00055 }
00056
00062 void Summary::ReadReportingChambers(const TH2*& h2, const double threshold) {
00063
00064 if(h2->GetXaxis()->GetXmin() <= 1 && h2->GetXaxis()->GetXmax() >= 36 &&
00065 h2->GetYaxis()->GetXmin() <= 1 && h2->GetYaxis()->GetXmax() >= 18) {
00066
00067 Address adr;
00068 double z = 0.0;
00069
00070 for(unsigned int x = 1; x <= 36; x++) {
00071 for(unsigned int y = 1; y <= 18; y++) {
00072 z = h2->GetBinContent(x, y);
00073 if(ChamberCoordsToAddress(x, y, adr)) {
00074 if(z >= threshold) {
00075 SetValue(adr, DATA);
00076 } else {
00077 ReSetValue(adr, DATA);
00078 }
00079 }
00080 }
00081 }
00082 } else {
00083 LOG_WARN << "cscdqm::Summary.ReadReportingChambers routine. Wrong histogram dimensions!";
00084 }
00085 }
00086
00097 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) {
00098
00099 if(h2->GetXaxis()->GetXmin() <= 1 && h2->GetXaxis()->GetXmax() >= 36 &&
00100 h2->GetYaxis()->GetXmin() <= 1 && h2->GetYaxis()->GetXmax() >= 18 &&
00101 refh2->GetXaxis()->GetXmin() <= 1 && refh2->GetXaxis()->GetXmax() >= 36 &&
00102 refh2->GetYaxis()->GetXmin() <= 1 && refh2->GetYaxis()->GetXmax() >= 18) {
00103
00105 double num = 1.0, denum = 1.0;
00106 for(unsigned int x = 1; x <= 36; x++) {
00107 for(unsigned int y = 1; y <= 18; y++) {
00108 double Nij = h2->GetBinContent(x, y);
00109 double Nrefij = refh2->GetBinContent(x, y);
00110 if (Nij > 0) {
00111 num += Nrefij;
00112 denum += pow(Nrefij, 2.0) / Nij;
00113 }
00114 }
00115 }
00116 double factor = num / denum;
00117
00118 Address adr;
00119 unsigned int N = 0, n = 0;
00120
00121 for(unsigned int x = 1; x <= 36; x++) {
00122 for(unsigned int y = 1; y <= 18; y++) {
00123
00124 N = int(refh2->GetBinContent(x, y) * factor);
00125 n = int(h2->GetBinContent(x, y));
00126
00127 if(ChamberCoordsToAddress(x, y, adr)) {
00128
00130 ReSetValue(adr, HOT);
00131 ReSetValue(adr, COLD);
00132
00133 if (n == 0) {
00134 ReSetValue(adr, DATA);
00135 } else {
00136 SetValue(adr, DATA);
00137 }
00138
00139 switch (Utility::checkOccupancy(N, n, cold_coef, hot_coef, cold_Sfail, hot_Sfail)) {
00140 case -1:
00141 SetValue(adr, COLD);
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159 break;
00160 case 1:
00161 SetValue(adr, HOT);
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179 break;
00180 };
00181
00182
00183 }
00184
00185 }
00186 }
00187
00188 } else {
00189 LOG_WARN << "cscdqm::Summary.ReadReportingChambersRef routine. Wrong histogram dimensions!";
00190 }
00191 }
00192
00201 void Summary::ReadErrorChambers(const TH2*& evs, const TH2*& err, const HWStatusBit bit, const double eps_max, const double Sfail) {
00202
00203 if(evs->GetXaxis()->GetXmin() <= 1 && evs->GetXaxis()->GetXmax() >= 36 &&
00204 evs->GetYaxis()->GetXmin() <= 1 && evs->GetYaxis()->GetXmax() >= 18 &&
00205 err->GetXaxis()->GetXmin() <= 1 && err->GetXaxis()->GetXmax() >= 36 &&
00206 err->GetYaxis()->GetXmin() <= 1 && err->GetYaxis()->GetXmax() >= 18) {
00207
00208 Address adr;
00209 unsigned int N = 0, n = 0;
00210
00211 for(unsigned int x = 1; x <= 36; x++) {
00212 for(unsigned int y = 1; y <= 18; y++) {
00213 N = int(evs->GetBinContent(x, y));
00214 n = int(err->GetBinContent(x, y));
00215 if (ChamberCoordsToAddress(x, y, adr)) {
00216 if(Utility::checkError(N, n, eps_max, Sfail)) {
00217 SetValue(adr, bit);
00218 } else {
00219 ReSetValue(adr, bit);
00220 }
00221 }
00222 }
00223 }
00224 } else {
00225 LOG_WARN << "cscdqm::Summary.ReadErrorChambers routine. Wrong histogram dimensions!";
00226 }
00227 }
00228
00234 void Summary::Write(TH2*& h2, const unsigned int station) const {
00235 const AddressBox* box;
00236 Address adr, tadr;
00237 float area_all = 0.0, area_rep = 0.0;
00238
00239 if(station < 1 || station > N_STATIONS) return;
00240
00241 adr.mask.side = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
00242 adr.mask.station = true;
00243 adr.station = station;
00244
00245 unsigned int i = 0;
00246
00247 while (detector.NextAddressBox(i, box, adr)) {
00248
00249 unsigned int x = 1 + (box->adr.side - 1) * 9 + (box->adr.ring - 1) * 3 + (box->adr.hv - 1);
00250 unsigned int y = 1 + (box->adr.chamber - 1) * 5 + (box->adr.cfeb - 1);
00251
00252 tadr = box->adr;
00253 HWStatusBitSet status = GetValue(tadr);
00254
00255 float area_box = fabs((box->xmax - box->xmin) * (box->ymax - box->ymin));
00256
00257 if (status.test(MASKED)) {
00258 h2->SetBinContent(x, y, 2.0);
00259 } else {
00260 area_all += area_box;
00261 if (HWSTATUSANYERROR(status)) {
00262 h2->SetBinContent(x, y, -1.0);
00263 } else {
00264 area_rep += area_box;
00265 if (status.test(DATA)) {
00266 h2->SetBinContent(x, y, 1.0);
00267 } else {
00268 h2->SetBinContent(x, y, 0.0);
00269 }
00270 }
00271 }
00272
00273 }
00274
00275 TString title = Form("ME%d Status: Physics Efficiency %.2f%%", station, (area_rep / area_all) * 100.0);
00276 h2->SetTitle(title);
00277
00278 }
00279
00284 void Summary::WriteMap(TH2*& h2) {
00285
00286 unsigned int rep_el = 0, csc_el = 0;
00287
00288 if(h2->GetXaxis()->GetXmin() <= 1 && h2->GetXaxis()->GetXmax() >= NTICS &&
00289 h2->GetYaxis()->GetXmin() <= 1 && h2->GetYaxis()->GetXmax() >= NTICS) {
00290
00291 float xd = 5.0 / NTICS, yd = 1.0 * (2.0 * 3.14159) / NTICS;
00292
00293 float xmin, xmax, ymin, ymax;
00294
00295 for(unsigned int x = 0; x < NTICS; x++) {
00296
00297 xmin = -2.5 + xd * x;
00298 xmax = xmin + xd;
00299
00300 for(unsigned int y = 0; y < NTICS; y++) {
00301
00302 double value = 0.0;
00303
00304 if (xmin == -2.5 || xmax == 2.5) continue;
00305 if (xmin >= -1 && xmax <= 1) continue;
00306
00307 ymin = yd * y;
00308 ymax = ymin + yd;
00309
00310 switch(IsPhysicsReady(x, y)) {
00311 case -1:
00312 value = -1.0;
00313 break;
00314 case 0:
00315 value = 0.0;
00316 rep_el++;
00317 break;
00318 case 1:
00319 value = 1.0;
00320 rep_el++;
00321 break;
00322 case 2:
00323 value = 2.0;
00324 rep_el++;
00325 }
00326
00327 h2->SetBinContent(x + 1, y + 1, value);
00328 csc_el++;
00329
00330 }
00331 }
00332
00333 } else {
00334 LOG_WARN << "cscdqm::Summary.WriteMap routine. Wrong histogram dimensions!";
00335 }
00336
00337 TString title = Form("EMU Status: Physics Efficiency %.2f%%", (csc_el == 0 ? 0.0 : (1.0 * rep_el) / csc_el) * 100.0);
00338 h2->SetTitle(title);
00339
00340 }
00341
00342
00351 void Summary::WriteChamberState(TH2*& h2, const int mask, const int value, const bool reset, const bool op_any) const {
00352
00353 if(h2->GetXaxis()->GetXmin() <= 1 && h2->GetXaxis()->GetXmax() >= 36 &&
00354 h2->GetYaxis()->GetXmin() <= 1 && h2->GetYaxis()->GetXmax() >= 18) {
00355
00356 unsigned int x, y;
00357 Address adr;
00358
00359 adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = true;
00360 adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
00361
00362 for (adr.side = 1; adr.side <= N_SIDES; adr.side++) {
00363 for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) {
00364 for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) {
00365 for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) {
00366 if (ChamberAddressToCoords(adr, x, y)) {
00367 HWStatusBitSet hwValue = GetValue(adr);
00368 bool hit = (op_any ? HWSTATUSANY(hwValue, mask) : HWSTATUSEQUALS(hwValue, mask));
00369
00370
00371
00372 if (hit) {
00373 h2->SetBinContent(x, y, 1.0 * value);
00374 } else if (reset) {
00375 h2->SetBinContent(x, y, 0.0);
00376 }
00377 }
00378 }
00379 }
00380 }
00381 }
00382
00383 } else {
00384 LOG_WARN << "cscdqm::Summary.WriteChamberState routine. Wrong histogram dimensions!";
00385 }
00386
00387 }
00388
00393 void Summary::ReSetValue(const HWStatusBit bit) {
00394 SetValue(bit, 0);
00395 }
00396
00402 void Summary::ReSetValue(Address adr, const HWStatusBit bit) {
00403 SetValue(adr, bit, 0);
00404 }
00405
00411 void Summary::SetValue(const HWStatusBit bit, const int value) {
00412 Address adr;
00413 adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
00414 SetValue(adr, bit, value);
00415 }
00416
00423 void Summary::SetValue(Address adr, const HWStatusBit bit, const int value) {
00424
00425 if (!adr.mask.side) {
00426 adr.mask.side = true;
00427 for (adr.side = 1; adr.side <= N_SIDES; adr.side++) SetValue(adr, bit, value);
00428 return;
00429 }
00430
00431 if (!adr.mask.station) {
00432 adr.mask.station = true;
00433 for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) SetValue(adr, bit, value);
00434 return;
00435 }
00436
00437 if (!adr.mask.ring) {
00438 adr.mask.ring = true;
00439 for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) SetValue(adr, bit, value);
00440 return;
00441 }
00442
00443 if (!adr.mask.chamber) {
00444 adr.mask.chamber = true;
00445 for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) SetValue(adr, bit, value);
00446 return;
00447 }
00448
00449 if (!adr.mask.layer) {
00450 adr.mask.layer = true;
00451 for (adr.layer = 1; adr.layer <= N_LAYERS; adr.layer++) SetValue(adr, bit, value);
00452 return;
00453 }
00454
00455 if (!adr.mask.cfeb) {
00456 adr.mask.cfeb = true;
00457 for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++) SetValue(adr, bit, value);
00458 return;
00459 }
00460
00461 if (!adr.mask.hv) {
00462 adr.mask.hv = true;
00463 for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++) SetValue(adr, bit, value);
00464 return;
00465 }
00466
00467 if( adr.side > 0 && adr.side <= N_SIDES && adr.station > 0 && adr.station <= N_STATIONS &&
00468 adr.ring > 0 && adr.ring <= N_RINGS && adr.chamber > 0 && adr.chamber <= N_CHAMBERS &&
00469 adr.layer > 0 && adr.layer <= N_LAYERS && adr.cfeb > 0 && adr.cfeb <= N_CFEBS && adr.hv > 0 && adr.hv <= N_HVS) {
00470
00471 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);
00472
00473 }
00474
00475 }
00476
00485 const int Summary::IsPhysicsReady(const unsigned int px, const unsigned int py) {
00486
00487 AddressBox *box;
00488
00489 HWStatusBitSet status[N_STATIONS];
00490
00491 unsigned int i = 0;
00492 while(detector.NextAddressBoxByPartition(i, px, py, box)) {
00493 status[box->adr.station - 1] |= GetValue(box->adr);
00494 }
00495
00496 unsigned int cdata = 0, cerror = 0, cmask = 0;
00497 for (unsigned int i = 0; i < N_STATIONS; i++) {
00498 if (HWSTATUSANYERROR(status[i])) {
00499 cerror++;
00500 } else {
00501 if (status[i].test(MASKED)) cmask++;
00502 if (status[i].test(DATA)) cdata++;
00503 }
00504 }
00505
00507 if (cdata > 1) return 1;
00509 if (cerror > 0) return -1;
00511 if (cmask > 0) return 2;
00513 return 0;
00514
00515 }
00516
00521 const double Summary::GetEfficiencyHW() const {
00522
00523 Address adr;
00524 adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
00525 return GetEfficiencyHW(adr);
00526
00527 }
00528
00534 const double Summary::GetEfficiencyHW(const unsigned int station) const {
00535
00536 Address adr;
00537 adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
00538
00539 if (station > 0 && station <= N_STATIONS) {
00540 adr.mask.station = true;
00541 adr.station = station;
00542 } else {
00543 return 0.0;
00544 }
00545
00546 return GetEfficiencyHW(adr);
00547
00548 }
00549
00555 const double Summary::GetEfficiencyHW(Address adr) const {
00556 double sum = 0.0;
00557
00558 if (!adr.mask.side) {
00559 adr.mask.side = true;
00560 for (adr.side = 1; adr.side <= N_SIDES; adr.side++) sum += GetEfficiencyHW(adr);
00561 return sum / N_SIDES;
00562 }
00563
00564 if (!adr.mask.station) {
00565 adr.mask.station = true;
00566 for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) sum += GetEfficiencyHW(adr);
00567 return sum / N_STATIONS;
00568 }
00569
00570 if (!adr.mask.ring) {
00571 adr.mask.ring = true;
00572 for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) sum += GetEfficiencyHW(adr);
00573 return sum / detector.NumberOfRings(adr.station);
00574 }
00575
00576 if (!adr.mask.chamber) {
00577 adr.mask.chamber = true;
00578 for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) sum += GetEfficiencyHW(adr);
00579 return sum / detector.NumberOfChambers(adr.station, adr.ring);
00580 }
00581
00582 if (!adr.mask.layer) {
00583 adr.mask.layer = true;
00584 for (adr.layer = 1; adr.layer <= N_LAYERS; adr.layer++) sum += GetEfficiencyHW(adr);
00585 return sum / N_LAYERS;
00586 }
00587
00588 if (!adr.mask.cfeb) {
00589 adr.mask.cfeb = true;
00590 for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++) sum += GetEfficiencyHW(adr);
00591 return sum / detector.NumberOfChamberCFEBs(adr.station, adr.ring);
00592 }
00593
00594 if (!adr.mask.hv) {
00595 adr.mask.hv = true;
00596 for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++) sum += GetEfficiencyHW(adr);
00597 return sum / detector.NumberOfChamberHVs(adr.station, adr.ring);
00598 }
00599
00601 HWStatusBitSet status = GetValue(adr);
00602 if (HWSTATUSANYERROR(status)) return 0.0;
00603 return 1.0;
00604
00605 }
00606
00612 const double Summary::GetEfficiencyArea(const unsigned int station) const {
00613 if (station <= 0 || station > N_STATIONS) return 0.0;
00614
00615 Address adr;
00616 adr.mask.side = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
00617 adr.station = true;
00618 adr.station = station;
00619
00620 return GetEfficiencyArea(adr);
00621 }
00622
00628 const double Summary::GetEfficiencyArea(Address adr) const {
00629 double all_area = 1;
00630
00631 if (adr.mask.side == false &&
00632 adr.mask.ring == false &&
00633 adr.mask.chamber == false &&
00634 adr.mask.layer == false &&
00635 adr.mask.cfeb == false &&
00636 adr.mask.hv == false &&
00637 adr.mask.station == true)
00638 all_area = detector.Area(adr.station);
00639 else
00640 all_area = detector.Area(adr);
00641
00642 double rep_area = GetReportingArea(adr);
00643 return rep_area / all_area;
00644 }
00645
00651 const double Summary::GetReportingArea(Address adr) const {
00652 double sum = 0.0;
00653
00654 if (!adr.mask.side) {
00655 adr.mask.side = true;
00656 for (adr.side = 1; adr.side <= N_SIDES; adr.side++) sum += GetReportingArea(adr);
00657 return sum;
00658 }
00659
00660 if (!adr.mask.station) {
00661 adr.mask.station = true;
00662 for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) sum += GetReportingArea(adr);
00663 return sum;
00664 }
00665
00666 if (!adr.mask.ring) {
00667 adr.mask.ring = true;
00668 for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) sum += GetReportingArea(adr);
00669 return sum;
00670 }
00671
00672 if (!adr.mask.chamber) {
00673 adr.mask.chamber = true;
00674 for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) sum += GetReportingArea(adr);
00675 return sum;
00676 }
00677
00678 if (!adr.mask.cfeb) {
00679 adr.mask.cfeb = true;
00680 for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++) sum += GetReportingArea(adr);
00681 return sum;
00682 }
00683
00684 if (!adr.mask.hv) {
00685 adr.mask.hv = true;
00686 for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++) sum += GetReportingArea(adr);
00687 return sum;
00688 }
00689
00690 adr.mask.layer = false;
00691
00693 HWStatusBitSet status = GetValue(adr);
00694 if (!HWSTATUSANYERROR(status)) {
00695 return detector.Area(adr);
00696 }
00697 return 0.0;
00698
00699 }
00700
00709 bool Summary::isChamberStandby(unsigned int side, unsigned int station, unsigned int ring, unsigned int chamber) const {
00710
00711 Address adr;
00712 adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = true;
00713 adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
00714 adr.side = side;
00715 adr.station = station;
00716 adr.ring = ring;
00717 adr.chamber = chamber;
00718
00719
00720
00721 return HWSTATUSANY(GetValue(adr), 0x1000);
00722 }
00723
00729 bool Summary::isChamberStandby(CSCDetId cid) const {
00730 return isChamberStandby(cid.endcap(), cid.station(), cid.ring(), cid.chamber());
00731 }
00732
00738 const HWStatusBitSet Summary::GetValue(Address adr) const {
00739
00740 HWStatusBitSet state;
00741 state.reset();
00742
00743 if (!adr.mask.side) {
00744 adr.mask.side = true;
00745 for (adr.side = 1; adr.side <= N_SIDES; adr.side++) state |= GetValue(adr);
00746 return state;
00747 }
00748
00749 if (!adr.mask.station) {
00750 adr.mask.station = true;
00751 for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) state |= GetValue(adr);
00752 return state;
00753 }
00754
00755 if (!adr.mask.ring) {
00756 adr.mask.ring = true;
00757 for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) state |= GetValue(adr);
00758 return state;
00759 }
00760
00761 if (!adr.mask.chamber) {
00762 adr.mask.chamber = true;
00763 for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) state |= GetValue(adr);
00764 return state;
00765 }
00766
00767 if (!adr.mask.layer) {
00768 adr.mask.layer = true;
00769 for (adr.layer = 1; adr.layer <= N_LAYERS; adr.layer++) state |= GetValue(adr);
00770 return state;
00771 }
00772
00773 if (!adr.mask.cfeb) {
00774 adr.mask.cfeb = true;
00775 for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++) state |= GetValue(adr);
00776 return state;
00777 }
00778
00779 if (!adr.mask.hv) {
00780 adr.mask.hv = true;
00781 for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++) state |= GetValue(adr);
00782 return state;
00783 }
00784
00785 return map[adr.side - 1][adr.station - 1][adr.ring - 1][adr.chamber - 1][adr.layer - 1][adr.cfeb - 1][adr.hv - 1];
00786
00787 }
00788
00794 const unsigned int Summary::setMaskedHWElements(std::vector<std::string>& tokens) {
00795 unsigned int applied = 0;
00796
00797 for (unsigned int r = 0; r < tokens.size(); r++) {
00798 std::string token = (std::string) tokens.at(r);
00799 Address adr;
00800 if (detector.AddressFromString(token, adr)) {
00801 SetValue(adr, MASKED);
00802 applied++;
00803 }
00804 }
00805 return applied;
00806 }
00807
00815 const bool Summary::ChamberCoordsToAddress(const unsigned int x, const unsigned int y, Address& adr) const {
00816
00817 if( x < 1 || x > 36 || y < 1 || y > 18) return false;
00818
00819 adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = true;
00820 adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
00821
00822 if ( y < 10 ) adr.side = 2;
00823 else adr.side = 1;
00824
00825 adr.chamber = x;
00826
00827 if (y == 1 || y == 18) {
00828 adr.station = 4;
00829 adr.ring = 2;
00830 } else
00831 if (y == 2 || y == 17) {
00832 adr.station = 4;
00833 adr.ring = 1;
00834 } else
00835 if (y == 3 || y == 16) {
00836 adr.station = 3;
00837 adr.ring = 2;
00838 } else
00839 if (y == 4 || y == 15) {
00840 adr.station = 3;
00841 adr.ring = 1;
00842 } else
00843 if (y == 5 || y == 14) {
00844 adr.station = 2;
00845 adr.ring = 2;
00846 } else
00847 if (y == 6 || y == 13) {
00848 adr.station = 2;
00849 adr.ring = 1;
00850 } else
00851 if (y == 7 || y == 12) {
00852 adr.station = 1;
00853 adr.ring = 3;
00854 } else
00855 if (y == 8 || y == 11) {
00856 adr.station = 1;
00857 adr.ring = 2;
00858 } else
00859 if (y == 9 || y == 10) {
00860 adr.station = 1;
00861 adr.ring = 1;
00862 }
00863
00864 return true;
00865
00866 }
00867
00875 const bool Summary::ChamberAddressToCoords(const Address& adr, unsigned int& x, unsigned int& y) const {
00876
00877 if (!adr.mask.side || !adr.mask.station || !adr.mask.ring || !adr.mask.chamber) return false;
00878
00879 x = adr.chamber;
00880 y = 0;
00881
00882 if (adr.side == 1) {
00883 switch (adr.station) {
00884 case 1:
00885 y = 10;
00886 if (adr.ring == 2) y = 11;
00887 if (adr.ring == 3) y = 12;
00888 break;
00889 case 2:
00890 y = 13;
00891 if (adr.ring == 2) y = 14;
00892 break;
00893 case 3:
00894 y = 15;
00895 if (adr.ring == 2) y = 16;
00896 break;
00897 case 4:
00898 y = 17;
00899 if (adr.ring == 2) y = 18;
00900 break;
00901 }
00902 } else
00903 if (adr.side == 2) {
00904 switch (adr.station) {
00905 case 1:
00906 y = 7;
00907 if (adr.ring == 2) y = 8;
00908 if (adr.ring == 1) y = 9;
00909 break;
00910 case 2:
00911 y = 5;
00912 if (adr.ring == 1) y = 6;
00913 break;
00914 case 3:
00915 y = 3;
00916 if (adr.ring == 1) y = 4;
00917 break;
00918 case 4:
00919 y = 1;
00920 if (adr.ring == 1) y = 2;
00921 break;
00922 }
00923 }
00924
00925 return true;
00926
00927 }
00928
00929 }