00001 #include <cstdlib>
00002
00003 #include <StMessMgr.h>
00004
00005 #include "EemcTwMask.h"
00006
00007
00008 EemcTwMask::EemcTwMask()
00009 : txtH(0)
00010 , nMask(0)
00011 {
00012 }
00013
00014
00015 EemcTwMask::~EemcTwMask() {
00016 if (txtH) delete txtH; txtH = 0;
00017 }
00018
00019
00020 void EemcTwMask::clear() {
00021 for (int i = 0;i < nCr;i++) {
00022 crG[i].Clear();
00023 crG2[i].Clear();
00024 }
00025 phiG.Clear();
00026 if (txtH) txtH->Clear();
00027 nMask = 0;
00028 memset(crCh, 0, sizeof(crCh));
00029 }
00030
00031
00032 bool useTwMask(const Char_t *fname, EemcTwMask *m) {
00033 if (!(fname && fname[0] && m)) return false;
00034 const int mx=1000;
00035 Char_t buf[mx];
00036
00037 LOG_INFO << "EEqaPresenter::useTwMask(\"" << fname << "\") ..." << endm;
00038
00039 m->clear();
00040 FILE *fd = fopen(fname, "r");
00041 int nok = 0;
00042 int nM = 1;
00043 m->txtH = new TPaveText(0, 0., 1, 1);
00044 TString myTxt = "ETOW masked (cr-ch-name): ";
00045 if (!fd) goto abandon;
00046 while (1) {
00047 Char_t *ret = fgets(buf, mx, fd);
00048 if (ret == 0) break ;
00049 if (buf[0] == '#') continue;
00050 if (buf[0] == '\n') continue;
00051 Char_t name[100];
00052 int cr, ch;
00053 int sec, isub, jeta, jphi;
00054 int n = sscanf(buf, "%d %d %s", &cr, &ch, name);
00055 if (n != 3) goto abandon;
00056 if ((cr < 1) || (cr > m->nCr) || (ch < 0) || (ch >= m->nCh)) goto abandon;
00057 if (name[2] != 'T') goto abandon;
00058 sec = atoi(name);
00059 isub = name[3] - 'A';
00060 jeta = atoi(name + 4);
00061 jphi = (sec - 1) * 5 + isub;
00062
00063
00064 m->crCh[cr-1][ch] = 1;
00065 int jj = m->crG[cr - 1].GetN();
00066 m->crG[cr - 1].SetPoint(jj, ch, 10);
00067 m->crG2[cr - 1].SetPoint(jj, 250, ch);
00068 m->crG2[cr - 1].SetPointError(jj, 250, 0.);
00069
00070 jj = m->phiG.GetN();
00071 m->phiG.SetPoint(jj, jphi, jeta);
00072 TString tt = Form("%d-%d-%s, ", cr, ch, name);
00073 myTxt += tt;
00074 nok++;
00075 nM++;
00076 LOG_DEBUG << Form("mask ETOW cr=%d ch=%d =%s=",cr,ch,name) << endm;
00077 if((nM % 4) == 0) {
00078 m->txtH->AddText(myTxt);
00079 myTxt=" ";
00080 }
00081 }
00082 m->nMask = nok;
00083 m->txtH->AddText(myTxt);
00084 m->txtH->AddText("--");
00085 LOG_INFO << " got " << nok << " masked towers" << endm;
00086
00087 for (int i = 0;i < 6;i++){
00088 m->crG[i].SetMarkerStyle(23);
00089 m->crG[i].SetMarkerColor(kRed);
00090 m->crG2[i].SetMarkerStyle(1);
00091 m->crG2[i].SetLineColor(kRed);
00092 }
00093
00094 m->phiG.SetMarkerStyle(24);
00095
00096 return true;
00097 abandon:
00098 m->clear();
00099 m->txtH->AddText("List of ETOW hot towers not found");
00100 m->txtH->AddText("--");
00101 LOG_ERROR << " EEqaPresenter::useTwMask() FAILED" << endm;
00102 return false;
00103 }