2 const int mxEta=12, mxPhi=60, mxVer=5;
3 float g[mxVer][mxEta][mxPhi];
4 float eg[mxVer][mxEta][mxPhi];
10 float slFac[mxEta]={-2.26,-2.64,-2.88,-2.92,-3.00,-3.36,
11 -3.60,-3.64,-3.98,-4.30,-4.44,-4.41};
13 enum { gIdeal=0, gAu200=1, gAu62=2, gFinal=3, gSlpp=4};
16 memset(g,0,
sizeof(g));
17 memset(eg,0,
sizeof(eg));
18 gStyle->SetOptStat(0);
20 TLine *ln1=
new TLine(0,0,60,60); ln1->SetLineColor(kGreen);ln1->SetLineWidth(1);
21 TLine *lnV=
new TLine(1,0,1,20); lnV->SetLineColor(kMagenta);lnV->SetLineWidth(1);
27 readG(gFinal,
"/star/u/wissink/WWW/cal2006/tablesTowers/",
'T');
36 c=
new TCanvas(
"aa",
"aa",600,800); c->Divide(3,4);
37 c2=
new TCanvas(
"bb",
"bb",600,800); c2->Divide(3,4);
39 c=
new TCanvas(
"aa",
"aa",400,400); c->Divide(1,1);
40 c2=
new TCanvas(
"bb",
"bb",300,300); c2->Divide(1,1);
44 for(ieta=0;ieta<12;ieta++) {
45 if(!keta) c->cd(ieta+1);
47 if(keta!=ieta+1)
continue;
55 if(!keta) c2->cd(ieta+1);
57 hX[ieta]->Fit(
"gaus",
"WQ"); lnV->Draw();
59 prGainChange(gSlpp,ieta);
67 int readG(
int iv,
char *path,
char cT=
'T') {
71 sprintf(fname,
"%sgains%c-allSect.dat",path,cT);
72 printf(
"reading gains from %s\n",fname);
73 FILE *fd=fopen(fname,
"r"); assert(fd);
75 bool isSlope= strstr(path,
"iter4xx")!=0;
78 for(sec=sec1;sec<=sec2;sec++) {
83 sprintf(fname,
"%sgains%02dtower.dat",path,sec);
84 if(isSlope)sprintf(fname,
"%ssect%d.txt",path,sec);
85 printf(
"reading gains from %s\n",fname);
86 FILE *fd=fopen(fname,
"r"); assert(fd);
90 char buf[mx], name[100];
94 char * ret=fgets(buf,mx,fd);
96 if(buf[0]==
'#')
continue;
97 if(strlen(buf)<=1)
continue;
99 int n=sscanf(buf,
"%s %f %f",name,&gx, &egx);
102 int isec=atoi(name)-1;
103 int isub=name[3]-
'A';
104 int ieta=atoi(name+4)-1;
106 int iphi=5*isec+isub;
107 printf(
"%s %d %d %d %d\n",name, isec,isub,ieta,iphi);
110 float r=fabs(egx/gx);
115 g[iv][ieta][iphi]=gx;
116 eg[iv][ieta][iphi]=egx;
125 int plAllGains(
int v1) {
126 TGraphErrors *gr=
new TGraphErrors;
127 gr->SetMarkerStyle(21);
128 gr->SetMarkerColor(kRed);
129 gr->SetMarkerSize(0.5);
133 sprintf(tit,
"2006 EEMC tower gains from MIPs w/ UxV, day89; eta bin; gain (ch/GeV)");
138 TString tt=
"T"; tt+=
"-shower";
139 h=
new TH2F(tt,tit,10,0.91,13.1,10,0,60);
142 c=
new TCanvas(tt,tt,900,600);
145 for(ieta=0; ieta<mxEta;ieta++)
146 for(iphi=iphi1;iphi<iphi2;iphi++) {
150 float g1=g[v1][ieta][iphi];
151 float eg1=eg[v1][ieta][iphi];
152 float x=ieta+1.+iphi/60.;
154 gr->SetPoint(n,x,g1);
155 gr->SetPointError(n,0,eg1);
159 h->Draw(); gr->Draw(
"P");
162 for(ieta=0; ieta<mxEta;ieta++) drawIdeal(ieta,1.1, 1);
173 int plGainsRaw(
int v1,
char cT=
'X') {
174 TGraphErrors *gr=
new TGraphErrors;
175 gr->SetMarkerStyle(8);
176 gr->SetMarkerColor(kRed);
177 gr->SetMarkerSize(0.5);
181 sprintf(tit,
"Reconstructed %c-shower gains for M-C , INPUT=23000; eta bin; gain (ch/GeV)",cT);
184 TString tt=cT; tt+=
"-shower";
185 h=
new TH2F(tt,tit,10,0.91,13.1,10,0,40000);
187 c=
new TCanvas(tt,tt,500,400);
190 for(ieta=0; ieta<mxEta;ieta++)
191 for(iphi=iphi1;iphi<iphi2;iphi++) {
195 float g1=g[v1][ieta][iphi];
196 float eg1=eg[v1][ieta][iphi];
198 float x=ieta+1.+iphi/60.;
200 gr->SetPoint(n,x,g1);
201 gr->SetPointError(n,0,eg1);
205 h->Draw(); gr->Draw(
"P");
210 ln=
new TLine(0,23000,13,23000);
211 ln->SetLineColor(kRed);
222 int writeG(
char *path,
int iv) {
226 for(sec=sec1;sec<=sec2;sec++) {
227 if(drop58 && sec>=5 && sec<=8)
continue;
229 sprintf(fname,
"%sgains%02dtower.dat",path,sec);
230 printf(
"write gains from %s\n",fname);
231 FILE *fd=fopen(fname,
"w"); assert(fd);
232 fprintf(fd,
"# gains from slopes pp200 from iter4, scaled to average from sector5-8, sector %d\n# name, gain, error\n",sec);
234 for(isub=0;isub<5;isub++)
235 for(ieta=0;ieta<12;ieta++) {
236 int iphi=5*(sec-1)+isub;
237 fprintf(fd,
"%02dT%c%02d %.2f %.2f\n",sec,
'A'+isub,ieta+1,g[iv][ieta][iphi],eg[iv][ieta][iphi]);
247 int doCorr1(
int v1,
int v2 ,
int ieta=11) {
248 TGraphErrors *gr=
new TGraphErrors;
249 gr->SetMarkerStyle(8);
250 gr->SetMarkerColor(kRed);
251 gr->SetMarkerSize(0.5);
253 sprintf(tit,
"etaBin = %d",ieta+1);
255 h=
new TH2F(tit,tit,10,0,50,10,0,50);
258 for(iphi=iphi1;iphi<iphi2;iphi++) {
261 if(drop58 && sec>=5 && sec<=8)
continue;
263 float g1=g[v1][ieta][iphi];
264 float g2=g[v2][ieta][iphi];
265 float eg1=eg[v1][ieta][iphi];
266 float eg2=eg[v2][ieta][iphi];
267 if(g1==0 || g2==0)
continue;
269 gr->SetPoint(n,g1,g2);
270 gr->SetPointError(n,eg1,eg2);
280 printf(
"%02dT%c%02d %f %f %f\n",sec,sub,ieta+1,g1,g2,x);
284 h->Draw(); gr->Draw(
"P");
291 int prGainChange(
int v1,
int ieta=11) {
293 int nH=0, nL=0, nOK=0,nD=0, nTot=0;
296 printf(
"\n HV tower gain erGain ratio (big) , eta bin=%d, ideal gain(ch/GeV)=%.2f\n",ieta+1, iGain[ieta]);
299 for(iphi=iphi1;iphi<iphi2;iphi++) {
303 if(drop58 && sec>=5 && sec<=8)
continue;
306 float g1=g[v1][ieta][iphi];
307 float eg1=eg[v1][ieta][iphi];
308 float r=g1/ iGain[ieta];
311 if(g1<=0) { printf(
"# xx "); nD++; }
312 elseif(r>1+eps) { printf(
"# + "); nH++; }
313 elseif(r<1-eps) { printf(
"# - "); nL++; }
314 else { printf(
"# OK "); nOK++; }
316 printf(
"%02dT%c%02d %4.1f %.1f %.3f",sec,sub,ieta+1,g1,eg1,r);
324 printf(
"nH=%d nL=%d nOK=%d nD=%d nTot=%d\n",nH,nL,nOK,nD,nTot);
325 printf(
"<tr><th> x <td>%d <td>%d <td>%d <td>%d \n",nH,nL,nOK,nD);
332 const float maxADC=4095;
333 const float maxEt=60;
334 const float eta[mxEta]={1.95,1.855,1.765,1.675,1.59,1.51,1.435,1.365,1.3,1.235,1.17,1.115};
336 char tit[200], tit2[200];
338 for(ieta=0;ieta<12;ieta++) {
339 sprintf(tit,
"x%d",ieta+1);
340 sprintf(tit2,
"MIPgain*slope , etaBin=%d",ieta+1);
341 hX[ieta]=
new TH1F(tit,tit2,20,.5,1.5);
342 iGain[ieta]=maxADC/maxEt/cosh(eta[ieta]);
343 printf(
"%.3f ", iGain[ieta]);
345 printf(
" <- ideal gains\n");
350 void drawIdeal(
int ieta,
float fac=1.1,
int flag=0) {
352 if(flag) { x1=ieta+1; x2=x1+1; }
353 TLine *ln0 =
new TLine(x1,iGain[ieta],x2,iGain[ieta]); ln0->SetLineColor(kBlue);ln0->SetLineWidth(1); ln0->Draw();
354 if(flag) ln0->SetLineWidth(2);
356 ln0 =
new TLine(x1,iGain[ieta]*fac,x2,iGain[ieta]*fac); ln0->SetLineColor(kBlue);ln0->SetLineWidth(1); ln0->Draw();ln0->SetLineStyle(2);
358 ln0 =
new TLine(x1,iGain[ieta]/fac,x2,iGain[ieta]/fac); ln0->SetLineColor(kBlue);ln0->SetLineWidth(1); ln0->Draw();ln0->SetLineStyle(2);