7 #include "TGraphErrors.h"
12 #include "TLegendEntry.h"
15 #include "TPaveText.h"
26 typedef struct {
int detId, ch, bs;
float x, y; }
st_info;
30 void bsQaShowMap(
const char* inList =
"FmsBsGainSample.txt",
const char* inMap =
"fmsCellMap.txt",
bool PRINT =
true)
32 std::vector<st_info> Info;
38 if (!in1.is_open()) { cout <<
"Cannot open file: " <<inList <<endl;
return; }
39 if (!in2.is_open()) { cout <<
"Cannot open file: " <<inMap <<endl;
return; }
42 int detId1, detId2, ch1, ch2, bs, valid;
44 in1 >> detId1 >> ch1 >> bs;
45 in2 >> detId2 >> ch2 >> valid >> x >> y;
47 if (!in1.good() || !in2.good())
break;
48 if ((detId1!=detId2) || (ch1!=ch2)) { cout <<
"WARNING! File format does NOT match!" <<endl;
return; }
49 if (valid !=
true)
continue;
53 tempInfo.detId = detId1;
58 Info.push_back(tempInfo);
66 string inListName = inList;
67 std::size_t strPos = inListName.find(
".txt");
68 string outName = inListName.substr(0, strPos);
70 gStyle->SetOptDate(0);
71 gStyle->SetOptStat(0);
73 TCanvas* c1 =
new TCanvas(Form(
"bsQaMap_%s", outName.c_str()), outName.c_str(), 1200, 900);
74 c1->cd()->SetRightMargin(0.3);
75 TH2F* H2Frame =
new TH2F(
"Frame",
"", 210,-105,105, 210,-105,105);
76 H2Frame->SetTitle(Form(
"%s;X;Y", c1->GetTitle()));
81 int nCell_nstb[4] = {0};
82 int nNZBS_nstb[4] = {0};
84 int Colors[] = {51, 56, 61, 66, 71, 17, 80, 85, 90, 95, 100};
85 for (
unsigned int a=0; a<Info.size(); a++)
88 const int detId = tempInfo.detId;
89 const int bs = tempInfo.bs;
90 const float x = tempInfo.x;
91 const float y = tempInfo.y;
92 const float cellHW = detId<10?(5.8/2):(3.8/2);
95 if (bs != 0) nNZBS[detId-8]++;
98 if (x>0 && y>0) nstb = 0;
99 else if (x>0 && y<0) nstb = 1;
100 else if (x<0 && y>0) nstb = 2;
101 else if (x<0 && y<0) nstb = 3;
103 if (bs != 0) nNZBS_nstb[nstb]++;
105 TPaveText* pt =
new TPaveText(x-cellHW, y-cellHW, x+cellHW, y+cellHW);
106 pt->SetFillStyle(3001);
107 pt->AddText(Form(
"%i", bs));
110 TBox* box =
new TBox(x-cellHW, y-cellHW, x+cellHW, y+cellHW);
111 box->SetFillColor(Colors[bs+5]);
112 box->SetFillStyle(3001);
113 box->SetLineColor(1);
114 box->SetLineWidth(1);
118 TLegend* L1 =
new TLegend(0.72, 0.1, 0.95, 0.9);
120 L1->AddEntry((TObject*)0,
"Non-zero BS ratio",
"");
121 L1->AddEntry((TObject*)0,
"",
"");
122 L1->AddEntry((TObject*)0,
"All:",
"");
123 const int nCell_all = nCell[0] + nCell[1] + nCell[2] + nCell[2];
124 const int nNZBS_all = nNZBS[0] + nNZBS[1] + nNZBS[2] + nNZBS[3];
125 L1->AddEntry((TObject*)0, Form(
"%i/%i (%4.3f)", nNZBS_all, nCell_all, (
float)nNZBS_all/(
float)nCell_all),
"");
126 L1->AddEntry((TObject*)0,
"",
"");
127 L1->AddEntry((TObject*)0,
"by detId",
"");
128 for (
int a=0; a<4; a++)
130 const char* ENT = Form(
"detId %i: %i/%i (%4.3f)", a+8,nNZBS[a],nCell[a],(
float)nNZBS[a]/(
float)nCell[a]);
131 L1->AddEntry((TObject*)0, ENT,
"");
133 L1->AddEntry((TObject*)0,
"",
"");
134 L1->AddEntry((TObject*)0,
"by NSTB",
"");
135 for (
int i=0; i<4; i++)
137 const char* ENT = Form(
"%s%s: %i/%i (%4.3f)", i<2?
"S":
"N", i%2==0?
"T":
"B",
138 nNZBS_nstb[i], nCell_nstb[i], (
float)nNZBS_nstb[i]/(
float)nCell_nstb[i]);
139 L1->AddEntry((TObject*)0, ENT,
"");
141 L1->AddEntry((TObject*)0,
"",
"");
144 if (PRINT) c1->Print(Form(
"%s.png", c1->GetName()));