1 const int mxBx=120, mxPol=4;
3 char *cpolBY[mxPol]={
"B+Y+",
"B+Y-",
"B-Y+",
"B-Y-"};
4 char bXselection[mxBx];
6 double Lum[mxPol],Lum2[mxPol];
13 void updatePattern(
char *run) {
16 printf(
"Update pattern for run=%d\n",irun);
18 char * polPattY,* polPattB,*dum;
21 selPatt=
"a.........k....BBBBBa.........k....pppppa.........k....YYYYY";
23 dum =
"1 11 21 31 41 51 60";
26 polPattY=
"--++--++--++--++--++--++--++--++--++--++--++--++--++--+aaaaa";
27 polPattB=
"-+-+-+-+-+-+-+-aaaaa-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+";
28 dum =
"| | | | | | |";
29 dum =
"1 11 21 31 41 51 60";
31 polPattY=
"0-+-+-+-+-+-+-+-+-+-0+-+-+-+-+-+-+-+-+-+0-+-+-+-+-+-+-+aaaaa";
32 polPattB=
"0++--++--++--++aaaaa0--++--++--++--++--+0+--++--++--++--++--";
33 dum =
"| | | | | | |";
34 dum =
"1 11 21 31 41 51 60";
39 bXselection[2*i]=selPatt[i];
40 bXselection[2*i+1]=
'i';
46 if (polPattB[i]==
'+' && polPattY[i]==
'+' ) polPattBY[k]=0;
47 else if(polPattB[i]==
'+' && polPattY[i]==
'-' ) polPattBY[k]=1;
48 else if(polPattB[i]==
'-' && polPattY[i]==
'+' ) polPattBY[k]=2;
49 else if(polPattB[i]==
'-' && polPattY[i]==
'-' ) polPattBY[k]=3;
59 addRuns(TString fill=0, TString runL=0, TString wrkDir=0) {
60 gStyle->SetPalette(1,0);
61 gStyle->SetOptStat(1111111);
67 TString outF=wrkDir+fill+
".hist.root";
69 outH=
new TFile(outF,
"RECREATE");
70 assert(outH->IsOpen());
71 printf(
"save outH -->%s\n", outF.Data());
75 TString inpScal=
"JoannaScal/scalVsRun.hist.root";
76 scal=
new TFile(inpScal);
77 assert(scal->IsOpen());
79 char *run=strtok(runL.Data(),
" ");
84 printf(
"\n\n process run %02d '%s' \n",nRun,run);
88 TString lcpHist=wrkDir+run+
".hist.root";
89 TFile * lcp=
new TFile(lcpHist);
90 assert(lcp->IsOpen());
92 printf(
"#fail %s does not open, skip\n",lcpHist.Data());
99 TH1F *hSc=(TH1F*)scal->Get(run);
101 printf(
" use absolute normalization\n");
106 printf(
" NO Scaler data, --> no renormalization\n");
107 for(
int i=0;i<mxPol;i++) {Lum[i]=Lum2[i]=1.;}
112 TList *top = lcp->GetListOfKeys();
117 char *name=ob->GetName();
118 if(strstr(name,
"PhiBx")==0)
continue;
121 TH2F *hIn=(TH2F*)lcp->Get(name);
122 printf(
" %10s integral=%.1f\n",name, hIn->Integral());
123 if(strstr(name,
"PhiBxAll"))sumIn+=hIn->Integral();
125 if(nRun==1) createHisto1D(hIn);
129 accumulateLcp(hIn,h);
136 }
while(run=strtok(0,
" "));
138 printf(
"acumulation done nRun=%d nLum=%d\n", nRun, nLum);
139 assert(nLum==0 || nRun==nLum);
141 if(nLum==0) autoLum(
"All");
142 printf(
"left2=%s=\n",cutL.Data());
143 printf(
"#fill %s , inp= %d , ",fill.Data(),sumIn);
144 float sumAll=summaryLcp();
145 printf(
" AllEff= %.2f\n",sumAll/sumIn );
154 (outH->Get(
"PhiB+Y-All"))->Draw();
155 TH1F*h1=(TH1F*) outH->Get(
"PhiB+Y+All");
156 h1->Draw(
"same"); h1->SetLineColor(kRed);
167 int bx2pol(
int bx1) {
168 if(bXselection[bx1-1]!=
'.')
return -3;
169 int pol= polPattBY[bx1-1];
176 void createHisto1D(TH2F *hIn){
177 TString name=hIn->GetName();
178 TString cut=name.Data()+5;
180 printf(
"create outHist for %s\n",name.Data());
181 TAxis *phiAx=hIn->GetYaxis();
185 for(k=0;k<mxPol;k++) {
189 char tit2[100]={
"aaa bbb"};
190 sprintf(tit2,
"LCP vs. Phi/rad, pol=%s, cut=%s",cpolBY[k],cut.Data());
191 printf(
"k=%d %s '%s'\n",k,name1.Data(), tit2);
192 TH1F *h=
new TH1F(name1,tit2,phiAx->GetNbins(),phiAx->GetXmin(), phiAx->GetXmax());
200 void accumulateLcp(TH2F *hIn, TH1F**h){
201 TString name=hIn->GetName();
206 for(k=0;k<mxPol;k++) {
207 TString name1=hIn->GetName();
208 name1.ReplaceAll(
"Bx",cpolBY[k]);
209 h[k]=(TH1F *)outH->Get(name1);
214 TAxis *X=hIn->GetXaxis();
215 int nx=X->GetNbins();
216 TAxis *Yax=hIn->GetYaxis();
218 int ny=Yax->GetNbins();
222 for(iy=1; iy<=ny; iy++) {
223 float phi=Yax->GetBinCenter(iy);
225 for(ix=1;ix<=nx;ix++) {
228 double val=hIn->GetBinContent(ix,iy);
229 if (val==0)
continue;
232 h1->AddBinContent(iy,val/Lum[pol]);
234 double err=h1->GetBinError(iy);
235 h1->SetBinError(iy,sqrt(err*err+val/Lum2[pol]));
243 printf(
"%s --> %.1f nSel=%.1f\n",hIn->GetName(), hIn->Integral(),nSel);
244 for(k=0;k<mxPol;k++) {
246 printf(
"%s --> %.0f\n",h1->GetName(), h1->Integral());
254 void printLcp(
char *cut){
255 printf(
"print histo %s, format: kPhi polBY ++ +- -+ --\n#tot: ",cut);
262 for(k=0;k<mxPol;k++) {
264 name1.ReplaceAll(
"Bx",cpolBY[k]);
265 h[k]=(TH1F *)outH->Get(name1);
267 sum+=h[k]->Integral();
268 printf(
" %.1f ", h[k]->Integral());
271 printf(
"\n#rel: ",cut);
272 for(k=0;k<mxPol;k++) {
273 printf(
" %.3f ", h[k]->Integral()*4/sum);
276 TAxis *X=h[0]->GetXaxis();
277 int nx=X->GetNbins();
280 for(ix=1; ix<=nx; ix++) {
282 for(k=0;k<mxPol;k++) {
283 float val=h[k]->GetBinContent(ix);
284 float err=h[k]->GetBinError(ix);
285 printf(
"%8.1f +/- %5.1f, ",val,err);
293 void fetch1D(TString cut,TH1F **h) {
295 for(k=0;k<mxPol;k++) {
299 h[k]=(TH1F *)outH->Get(name1);
306 void sumScal(TH1F *h) {
307 memset(Lum,0,
sizeof(Lum));
308 memset(Lum2,0,
sizeof(Lum2));
311 TAxis *X=h->GetXaxis();
312 int nx=X->GetNbins();
315 for(ix=1;ix<=nx;ix++) {
319 Lum[pol]+=h->GetBinContent(ix);
327 printf(
"%d ",Lum[i]);
329 printf(
" usedBx=%d\n",nBx);
335 void calcNorm(
char *name){
339 for(i=0;i<mxPol;i++){
341 printf(
"%d ",Lum[i]);
347 printf(
"\n#norm %s %d ",name ,
id);
350 for(i=0;i<mxPol;i++){
352 Lum2[i]=Lum[i]*Lum[i];
353 printf(
"%.4f ",Lum[i]);
362 void autoLum(
char *cut0) {
363 printf(
"autoLuminosiy using cut=%s\n",cut0);
368 for(k=0;k<mxPol;k++) {
369 Lum[k]=h[k]->Integral();
372 calcNorm(
"AutoLum7777");
375 TString cut1=
" "+cutL;
376 char *cut=strtok(cut1.Data(),
" ");
381 for(k=0;k<mxPol;k++) {
382 h[k]->Scale(1./Lum[k]);
384 }
while(cut=strtok(0,
" "));
393 char *cut=strtok(cut1.Data(),
" ");
402 for(k=0;k<mxPol;k++) {
404 sum[k]=h[k]->Integral();
408 printf(
"%s= %.1f , ",cut,sum0);
409 if(strstr(cut,
"All"))sumAll=sum0;
411 }
while(cut=strtok(0,
" "));