00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "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;
00292
00293 float xmin, xmax;
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 switch(IsPhysicsReady(x, y)) {
00308 case -1:
00309 value = -1.0;
00310 break;
00311 case 0:
00312 value = 0.0;
00313 rep_el++;
00314 break;
00315 case 1:
00316 value = 1.0;
00317 rep_el++;
00318 break;
00319 case 2:
00320 value = 2.0;
00321 rep_el++;
00322 }
00323
00324 h2->SetBinContent(x + 1, y + 1, value);
00325 csc_el++;
00326
00327 }
00328 }
00329
00330 } else {
00331 LOG_WARN << "cscdqm::Summary.WriteMap routine. Wrong histogram dimensions!";
00332 }
00333
00334 TString title = Form("EMU Status: Physics Efficiency %.2f%%", (csc_el == 0 ? 0.0 : (1.0 * rep_el) / csc_el) * 100.0);
00335 h2->SetTitle(title);
00336
00337 }
00338
00339
00348 void Summary::WriteChamberState(TH2*& h2, const int mask, const int value, const bool reset, const bool op_any) const {
00349
00350 if(h2->GetXaxis()->GetXmin() <= 1 && h2->GetXaxis()->GetXmax() >= 36 &&
00351 h2->GetYaxis()->GetXmin() <= 1 && h2->GetYaxis()->GetXmax() >= 18) {
00352
00353 unsigned int x, y;
00354 Address adr;
00355
00356 adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = true;
00357 adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
00358
00359 for (adr.side = 1; adr.side <= N_SIDES; adr.side++) {
00360 for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) {
00361 for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) {
00362 for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) {
00363 if (ChamberAddressToCoords(adr, x, y)) {
00364 HWStatusBitSet hwValue = GetValue(adr);
00365 bool hit = (op_any ? HWSTATUSANY(hwValue, mask) : HWSTATUSEQUALS(hwValue, mask));
00366
00367
00368
00369 if (hit) {
00370 h2->SetBinContent(x, y, 1.0 * value);
00371 } else if (reset) {
00372 h2->SetBinContent(x, y, 0.0);
00373 }
00374 }
00375 }
00376 }
00377 }
00378 }
00379
00380 } else {
00381 LOG_WARN << "cscdqm::Summary.WriteChamberState routine. Wrong histogram dimensions!";
00382 }
00383
00384 }
00385
00390 void Summary::ReSetValue(const HWStatusBit bit) {
00391 SetValue(bit, 0);
00392 }
00393
00399 void Summary::ReSetValue(Address adr, const HWStatusBit bit) {
00400 SetValue(adr, bit, 0);
00401 }
00402
00408 void Summary::SetValue(const HWStatusBit bit, const int value) {
00409 Address adr;
00410 adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
00411 SetValue(adr, bit, value);
00412 }
00413
00420 void Summary::SetValue(Address adr, const HWStatusBit bit, const int value) {
00421
00422 if (!adr.mask.side) {
00423 adr.mask.side = true;
00424 for (adr.side = 1; adr.side <= N_SIDES; adr.side++) SetValue(adr, bit, value);
00425 return;
00426 }
00427
00428 if (!adr.mask.station) {
00429 adr.mask.station = true;
00430 for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) SetValue(adr, bit, value);
00431 return;
00432 }
00433
00434 if (!adr.mask.ring) {
00435 adr.mask.ring = true;
00436 for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) SetValue(adr, bit, value);
00437 return;
00438 }
00439
00440 if (!adr.mask.chamber) {
00441 adr.mask.chamber = true;
00442 for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) SetValue(adr, bit, value);
00443 return;
00444 }
00445
00446 if (!adr.mask.layer) {
00447 adr.mask.layer = true;
00448 for (adr.layer = 1; adr.layer <= N_LAYERS; adr.layer++) SetValue(adr, bit, value);
00449 return;
00450 }
00451
00452 if (!adr.mask.cfeb) {
00453 adr.mask.cfeb = true;
00454 for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++) SetValue(adr, bit, value);
00455 return;
00456 }
00457
00458 if (!adr.mask.hv) {
00459 adr.mask.hv = true;
00460 for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++) SetValue(adr, bit, value);
00461 return;
00462 }
00463
00464 if( adr.side > 0 && adr.side <= N_SIDES && adr.station > 0 && adr.station <= N_STATIONS &&
00465 adr.ring > 0 && adr.ring <= N_RINGS && adr.chamber > 0 && adr.chamber <= N_CHAMBERS &&
00466 adr.layer > 0 && adr.layer <= N_LAYERS && adr.cfeb > 0 && adr.cfeb <= N_CFEBS && adr.hv > 0 && adr.hv <= N_HVS) {
00467
00468 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);
00469
00470 }
00471
00472 }
00473
00482 const int Summary::IsPhysicsReady(const unsigned int px, const unsigned int py) {
00483
00484 AddressBox *box;
00485
00486 HWStatusBitSet status[N_STATIONS];
00487
00488 unsigned int i = 0;
00489 while(detector.NextAddressBoxByPartition(i, px, py, box)) {
00490 status[box->adr.station - 1] |= GetValue(box->adr);
00491 }
00492
00493 unsigned int cdata = 0, cerror = 0, cmask = 0;
00494 for (unsigned int i = 0; i < N_STATIONS; i++) {
00495 if (HWSTATUSANYERROR(status[i])) {
00496 cerror++;
00497 } else {
00498 if (status[i].test(MASKED)) cmask++;
00499 if (status[i].test(DATA)) cdata++;
00500 }
00501 }
00502
00504 if (cdata > 1) return 1;
00506 if (cerror > 0) return -1;
00508 if (cmask > 0) return 2;
00510 return 0;
00511
00512 }
00513
00518 const double Summary::GetEfficiencyHW() const {
00519
00520 Address adr;
00521 adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
00522 return GetEfficiencyHW(adr);
00523
00524 }
00525
00531 const double Summary::GetEfficiencyHW(const unsigned int station) const {
00532
00533 Address adr;
00534 adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
00535
00536 if (station > 0 && station <= N_STATIONS) {
00537 adr.mask.station = true;
00538 adr.station = station;
00539 } else {
00540 return 0.0;
00541 }
00542
00543 return GetEfficiencyHW(adr);
00544
00545 }
00546
00552 const double Summary::GetEfficiencyHW(Address adr) const {
00553 double sum = 0.0;
00554
00555 if (!adr.mask.side) {
00556 adr.mask.side = true;
00557 for (adr.side = 1; adr.side <= N_SIDES; adr.side++) sum += GetEfficiencyHW(adr);
00558 return sum / N_SIDES;
00559 }
00560
00561 if (!adr.mask.station) {
00562 adr.mask.station = true;
00563 for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) sum += GetEfficiencyHW(adr);
00564 return sum / N_STATIONS;
00565 }
00566
00567 if (!adr.mask.ring) {
00568 adr.mask.ring = true;
00569 for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) sum += GetEfficiencyHW(adr);
00570 return sum / detector.NumberOfRings(adr.station);
00571 }
00572
00573 if (!adr.mask.chamber) {
00574 adr.mask.chamber = true;
00575 for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) sum += GetEfficiencyHW(adr);
00576 return sum / detector.NumberOfChambers(adr.station, adr.ring);
00577 }
00578
00579 if (!adr.mask.layer) {
00580 adr.mask.layer = true;
00581 for (adr.layer = 1; adr.layer <= N_LAYERS; adr.layer++) sum += GetEfficiencyHW(adr);
00582 return sum / N_LAYERS;
00583 }
00584
00585 if (!adr.mask.cfeb) {
00586 adr.mask.cfeb = true;
00587 for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++) sum += GetEfficiencyHW(adr);
00588 return sum / detector.NumberOfChamberCFEBs(adr.station, adr.ring);
00589 }
00590
00591 if (!adr.mask.hv) {
00592 adr.mask.hv = true;
00593 for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++) sum += GetEfficiencyHW(adr);
00594 return sum / detector.NumberOfChamberHVs(adr.station, adr.ring);
00595 }
00596
00598 HWStatusBitSet status = GetValue(adr);
00599 if (HWSTATUSANYERROR(status)) return 0.0;
00600 return 1.0;
00601
00602 }
00603
00609 const double Summary::GetEfficiencyArea(const unsigned int station) const {
00610 if (station <= 0 || station > N_STATIONS) return 0.0;
00611
00612 Address adr;
00613 adr.mask.side = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
00614 adr.station = true;
00615 adr.station = station;
00616
00617 return GetEfficiencyArea(adr);
00618 }
00619
00625 const double Summary::GetEfficiencyArea(Address adr) const {
00626 double all_area = 1;
00627
00628 if (adr.mask.side == false &&
00629 adr.mask.ring == false &&
00630 adr.mask.chamber == false &&
00631 adr.mask.layer == false &&
00632 adr.mask.cfeb == false &&
00633 adr.mask.hv == false &&
00634 adr.mask.station == true)
00635 all_area = detector.Area(adr.station);
00636 else
00637 all_area = detector.Area(adr);
00638
00639 double rep_area = GetReportingArea(adr);
00640 return rep_area / all_area;
00641 }
00642
00648 const double Summary::GetReportingArea(Address adr) const {
00649 double sum = 0.0;
00650
00651 if (!adr.mask.side) {
00652 adr.mask.side = true;
00653 for (adr.side = 1; adr.side <= N_SIDES; adr.side++) sum += GetReportingArea(adr);
00654 return sum;
00655 }
00656
00657 if (!adr.mask.station) {
00658 adr.mask.station = true;
00659 for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) sum += GetReportingArea(adr);
00660 return sum;
00661 }
00662
00663 if (!adr.mask.ring) {
00664 adr.mask.ring = true;
00665 for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) sum += GetReportingArea(adr);
00666 return sum;
00667 }
00668
00669 if (!adr.mask.chamber) {
00670 adr.mask.chamber = true;
00671 for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) sum += GetReportingArea(adr);
00672 return sum;
00673 }
00674
00675 if (!adr.mask.cfeb) {
00676 adr.mask.cfeb = true;
00677 for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++) sum += GetReportingArea(adr);
00678 return sum;
00679 }
00680
00681 if (!adr.mask.hv) {
00682 adr.mask.hv = true;
00683 for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++) sum += GetReportingArea(adr);
00684 return sum;
00685 }
00686
00687 adr.mask.layer = false;
00688
00690 HWStatusBitSet status = GetValue(adr);
00691 if (!HWSTATUSANYERROR(status)) {
00692 return detector.Area(adr);
00693 }
00694 return 0.0;
00695
00696 }
00697
00706 bool Summary::isChamberStandby(unsigned int side, unsigned int station, unsigned int ring, unsigned int chamber) const {
00707
00708 Address adr;
00709 adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = true;
00710 adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
00711 adr.side = side;
00712 adr.station = station;
00713 adr.ring = ring;
00714 adr.chamber = chamber;
00715
00716
00717
00718 return HWSTATUSANY(GetValue(adr), 0x1000);
00719 }
00720
00726 bool Summary::isChamberStandby(CSCDetId cid) const {
00727 return isChamberStandby(cid.endcap(), cid.station(), cid.ring(), cid.chamber());
00728 }
00729
00735 const HWStatusBitSet Summary::GetValue(Address adr) const {
00736
00737 HWStatusBitSet state;
00738 state.reset();
00739
00740 if (!adr.mask.side) {
00741 adr.mask.side = true;
00742 for (adr.side = 1; adr.side <= N_SIDES; adr.side++) state |= GetValue(adr);
00743 return state;
00744 }
00745
00746 if (!adr.mask.station) {
00747 adr.mask.station = true;
00748 for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) state |= GetValue(adr);
00749 return state;
00750 }
00751
00752 if (!adr.mask.ring) {
00753 adr.mask.ring = true;
00754 for (adr.ring = 1; adr.ring <= detector.NumberOfRings(adr.station); adr.ring++) state |= GetValue(adr);
00755 return state;
00756 }
00757
00758 if (!adr.mask.chamber) {
00759 adr.mask.chamber = true;
00760 for (adr.chamber = 1; adr.chamber <= detector.NumberOfChambers(adr.station, adr.ring); adr.chamber++) state |= GetValue(adr);
00761 return state;
00762 }
00763
00764 if (!adr.mask.layer) {
00765 adr.mask.layer = true;
00766 for (adr.layer = 1; adr.layer <= N_LAYERS; adr.layer++) state |= GetValue(adr);
00767 return state;
00768 }
00769
00770 if (!adr.mask.cfeb) {
00771 adr.mask.cfeb = true;
00772 for (adr.cfeb = 1; adr.cfeb <= detector.NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++) state |= GetValue(adr);
00773 return state;
00774 }
00775
00776 if (!adr.mask.hv) {
00777 adr.mask.hv = true;
00778 for (adr.hv = 1; adr.hv <= detector.NumberOfChamberHVs(adr.station, adr.ring); adr.hv++) state |= GetValue(adr);
00779 return state;
00780 }
00781
00782 return map[adr.side - 1][adr.station - 1][adr.ring - 1][adr.chamber - 1][adr.layer - 1][adr.cfeb - 1][adr.hv - 1];
00783
00784 }
00785
00791 const unsigned int Summary::setMaskedHWElements(std::vector<std::string>& tokens) {
00792 unsigned int applied = 0;
00793
00794 for (unsigned int r = 0; r < tokens.size(); r++) {
00795 std::string token = (std::string) tokens.at(r);
00796 Address adr;
00797 if (detector.AddressFromString(token, adr)) {
00798 SetValue(adr, MASKED);
00799 applied++;
00800 }
00801 }
00802 return applied;
00803 }
00804
00812 const bool Summary::ChamberCoordsToAddress(const unsigned int x, const unsigned int y, Address& adr) const {
00813
00814 if( x < 1 || x > 36 || y < 1 || y > 18) return false;
00815
00816 adr.mask.side = adr.mask.station = adr.mask.ring = adr.mask.chamber = true;
00817 adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
00818
00819 if ( y < 10 ) adr.side = 2;
00820 else adr.side = 1;
00821
00822 adr.chamber = x;
00823
00824 if (y == 1 || y == 18) {
00825 adr.station = 4;
00826 adr.ring = 2;
00827 } else
00828 if (y == 2 || y == 17) {
00829 adr.station = 4;
00830 adr.ring = 1;
00831 } else
00832 if (y == 3 || y == 16) {
00833 adr.station = 3;
00834 adr.ring = 2;
00835 } else
00836 if (y == 4 || y == 15) {
00837 adr.station = 3;
00838 adr.ring = 1;
00839 } else
00840 if (y == 5 || y == 14) {
00841 adr.station = 2;
00842 adr.ring = 2;
00843 } else
00844 if (y == 6 || y == 13) {
00845 adr.station = 2;
00846 adr.ring = 1;
00847 } else
00848 if (y == 7 || y == 12) {
00849 adr.station = 1;
00850 adr.ring = 3;
00851 } else
00852 if (y == 8 || y == 11) {
00853 adr.station = 1;
00854 adr.ring = 2;
00855 } else
00856 if (y == 9 || y == 10) {
00857 adr.station = 1;
00858 adr.ring = 1;
00859 }
00860
00861 return true;
00862
00863 }
00864
00872 const bool Summary::ChamberAddressToCoords(const Address& adr, unsigned int& x, unsigned int& y) const {
00873
00874 if (!adr.mask.side || !adr.mask.station || !adr.mask.ring || !adr.mask.chamber) return false;
00875
00876 x = adr.chamber;
00877 y = 0;
00878
00879 if (adr.side == 1) {
00880 switch (adr.station) {
00881 case 1:
00882 y = 10;
00883 if (adr.ring == 2) y = 11;
00884 if (adr.ring == 3) y = 12;
00885 break;
00886 case 2:
00887 y = 13;
00888 if (adr.ring == 2) y = 14;
00889 break;
00890 case 3:
00891 y = 15;
00892 if (adr.ring == 2) y = 16;
00893 break;
00894 case 4:
00895 y = 17;
00896 if (adr.ring == 2) y = 18;
00897 break;
00898 }
00899 } else
00900 if (adr.side == 2) {
00901 switch (adr.station) {
00902 case 1:
00903 y = 7;
00904 if (adr.ring == 2) y = 8;
00905 if (adr.ring == 1) y = 9;
00906 break;
00907 case 2:
00908 y = 5;
00909 if (adr.ring == 1) y = 6;
00910 break;
00911 case 3:
00912 y = 3;
00913 if (adr.ring == 1) y = 4;
00914 break;
00915 case 4:
00916 y = 1;
00917 if (adr.ring == 1) y = 2;
00918 break;
00919 }
00920 }
00921
00922 return true;
00923
00924 }
00925
00926 }