StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
BackgroundLL.C
1 // This macro calculates the background ALL based on the side-band analysis.
2 // Author: Weihong He
3 
4 const int mx=4;
5 const int mt=1;
6 TFile *fd[mx];
7 TCanvas *c1=0;
8 int bg1[7][4],bg2[7][4];
9 float cut1[7]={6,5,4,5,5,6,7};
10 
11 BackgroundLL(){
12  gStyle->SetPadGridX(0);
13  gStyle->SetPadGridY(0);
14  gStyle->SetCanvasColor(0);
15  gStyle->SetOptStat(0);
16  c=new TCanvas("tmp","tmp",700,500);
17  float fptmin[7]={4.0,5.0,6.0,7.0,8.0,9.0,10.0};
18  float fptmax[7]={5.0,6.0,7.0,8.0,9.0,10.0,25.0};
19  TH1F* h5=new TH1F("A_LL_back","#vec{p}+#vec{p}->#pi^{0}X, #sqrt{s}=200Gev, 1.0#leq#eta#leq2.0;pT[Gev/c];A_{LL}_back",22,1.0,12.0);
20  TH1F* h6=new TH1F("A_LL","#vec{p}+#vec{p}->#pi^{0}X, #sqrt{s}=200Gev, 1.089#leq#eta#leq2.0,P=60%;[Gev/c];A_{LL}",22,1.0,12.0);
21  TH1F* h7=new TH1F("A_LL","#vec{p}+#vec{p}->#pi^{0}X, #sqrt{s}=200Gev, 1.089#leq#eta#leq2.0,P=60%;[Gev/c];A_{LL}",22,1.0,12.0);
22  TH1F* h8=new TH1F("A_LL","#vec{p}+#vec{p}->#pi^{0}X, #sqrt{s}=200Gev, 1.089#leq#eta#leq2.0,P=60%;[Gev/c];A_{LL}",22,1.0,12.0);
23  const int nBins = 7;
24  float bins[nBins+1] = {4,5,6,7,8,9,10,12};
25  TH1F* h4 = new TH1F("A_LL_back","#vec{p}+#vec{p}->#pi^{0}X, #sqrt{s}=200Gev, 1.0#leq#eta#leq2.0;pT[Gev/c];A_{LL};",nBins,bins);
26  h4->SetMarkerStyle(8);
27 #endif
28  TH1F* hSys = new TH1F("A_LL_back","#vec{p}+#vec{p}->#pi^{0}X, #sqrt{s}=200Gev, 1.0#leq#eta#leq2.0;pT[Gev/c];A_{LL};",nBins,bins);
29  TH1F* hB = new TH1F("A_LL_back","#vec{p}+#vec{p}->#pi^{0}X, #sqrt{s}=200Gev, 1.0#leq#eta#leq2.0;pT[Gev/c];A_{LL};",nBins,bins);
30  float baseLine=-0.14;
31  float sysErr[7] = {0.00239,0.00521,0.00485,0.00405,0.012,0.0108,0.0104};
32 
33 
34  psquare=0.3;
35 
36  for(int i=0;i<7;i++){
37  float bgll=0.0,bgll_error=0.0,bgll1=0.0,bgll1_error=0.0,bgll2=0.0,bgll2_error=0.0;
38  Background(i, fptmin[i], fptmax[i]);
39  int Nsame1=bg1[i][0]+bg1[i][3];
40  int Nanti1=bg1[i][1]+bg1[i][2];
41  int Nsame2=bg2[i][0]+bg2[i][3];
42  int Nanti2=bg2[i][1]+bg2[i][2];
43  //int Nsame=Nsame1+Nsame2;
44  //int Nanti=Nanti1+Nanti2;
45  bgll1=1.0/psquare*(Nsame1-Nanti1)/(Nsame1+Nanti1);
46  bgll1_error=1.0/psquare*1.0/sqrt(Nsame1+Nanti1);
47  bgll2=1.0/psquare*(Nsame2-Nanti2)/(Nsame2+Nanti2);
48  bgll2_error=1.0/psquare*1.0/sqrt(Nsame2+Nanti2);
49  bgll=0.5*(bgll1+bgll2);
50  bgll_error=0.5*(bgll1_error+bgll2_error);
51  //bgll_error=sqrt(1.0/(1.0/pow(bgll1_error,2.0)+1.0/pow(bgll2_error,2.0)));
52  cout<<"bgll="<<bgll<<" error1="<<bgll1_error<<" error2="<<bgll2_error<<" error="<<bgll_error<<endl;
53  h4->Fill(fptmin[i]+0.5,bgll);
54  int nbin0=h4->FindBin(fptmin[i]+0.5);
55  h4->SetBinError(nbin0,bgll_error);
56  //cout<<"point1 error="<<e3[0]<<" all="<<a3[0]<<endl;
57  hSys->SetBinContent(nbin0,baseLine + sysErr[i]);
58  hB->SetBinContent(nbin0,baseLine);
59 
60  }
61 
62  //open theory curve
63  ifstream unp("theorycurve/pion-unp-cteq6-rap1to2.dat");
64  ifstream g0("theorycurve/pion-pol-g0-rap1to2.dat");
65  ifstream plusg("theorycurve/pion-pol-max-rap1to2.dat");
66  ifstream minusg("theorycurve/pion-pol-maxminus-rap1to2.dat");
67  ifstream stdg("theorycurve/pion-pol-std-rap1to2.dat");
68  double x1=0.0,x2=0.0,x3=0.0,x4=0.0,x5=0.0;
69  double d1=0.0,d2=0.0,d3=0.0,d4=0.0,d5=0.0;
70  double b1=0.0,b2=0.0,b3=0.0,b4=0.0,b5=0.0;
71  double c1=0.0,c2=0.0,c3=0.0,c4=0.0,c5=0.0;
72  double y1=0.0,y2=0.0,y3=0.0,y4=0.0,y5=0.0;
73  int ccount=0;
74  double theoryd[18],theoryb[18],theoryc[18],theoryg[18];;
75  while(1){
76  unp>>y1>>y2>>y3>>y4>>y5;
77  g0>>x1>>x2>>x3>>x4>>x5;
78  plusg>>d1>>d2>>d3>>d4>>d5;
79  minusg>>b1>>b2>>b3>>b4>>b5;
80  stdg>>c1>>c2>>c3>>c4>>c5;
81  theoryd[ccount]=d5/y5;
82  theoryb[ccount]=b5/y5;
83  theoryc[ccount]=c5/y5;
84  theoryg[ccount]=x5/y5;
85  //cout<<"x3="<<d3<<" theoryd="<<theoryg[ccount]<<endl;
86  h5->Fill(d3,theoryd[ccount]);
87  h6->Fill(b3,theoryb[ccount]);
88  h7->Fill(c3,theoryc[ccount]);
89  h8->Fill(x3,theoryg[ccount]);
90  ccount++;
91  if(ccount>17) break;
92  }
93  h5->Fill(8.0,0.03);
94  h5->SetAxisRange(0,25,"X");
95  h5->Fill(9.0,0.0305);
96  h5->Fill(10.0,0.031);
97  h5->Fill(10.5,0.0312);
98  h5->Fill(11.5,0.031);
99  h6->Fill(8.0,-0.001);
100  h6->Fill(9.0,-0.0035);
101  h6->Fill(10.0,-0.0065);
102  h6->Fill(10.5,-0.0075);
103  h6->Fill(11.5,-0.01);
104  h7->Fill(8.0,0.0072);
105  h7->Fill(9.0,0.0079);
106  h7->Fill(10.0,0.0087);
107  h7->Fill(10.5,0.0091);
108  h7->Fill(11.5,0.0099);
109  h8->Fill(8.0,0.00152);
110  h8->Fill(9.0,0.00183);
111  h8->Fill(10.0,0.00204);
112  h8->Fill(10.5,0.0022);
113  h8->Fill(11.5,0.0026);
114 #if 1
115  //A_LL plotting
116  c->cd(1);
117  h5->SetLineColor(kRed);
118  h5->Draw("C");
119  h5->SetMinimum(-0.15);
120  h5->SetMaximum(0.15);
121  hB->SetFillColor(11);
122  hB->Draw("same");
123  hSys->SetFillColor(10);
124  hSys->Draw("same");
125  h6->SetLineColor(kGreen);
126  h6->Draw("Csame");
127  h7->Draw("Csame");
128  h8->SetLineColor(kBlue);
129  h8->Draw("Csame");
130 
131  h4->Draw("E1same,p");
132 
133  TLegend* leg = new TLegend(0.15,0.6,0.4,0.8);
134  leg->AddEntry(h5,"#Delta{G}=G","L");
135  leg->AddEntry(h6,"#Delta{G}=-G","L");
136  leg->AddEntry(h7,"#Delta{G}=std","L");
137  leg->AddEntry(h8,"#Delta{G}=0","L");
138  leg->SetHeader("Vogelsang Prediction(GRSV)");
139  leg->SetBorderSize(0.0);
140  leg->SetFillColor(0.0);
141  leg->Draw();
142  TLegend* leg2 = new TLegend(0.6,0.75,0.9,0.85);
143  leg2->SetHeader("STAR 2006 Preliminary #pi^{0}");
144  leg2->SetBorderSize(0.0);
145  leg2->SetFillColor(0.0);
146  leg2->Draw();
147 
148 #endif
149  c->Print("tmp.gif");
150 }
151 
152 void Background(int key, float ptmin, float ptmax) {
153 
154  int Realpi=0,backpi=0,totpi=0;
155 
156  char *PlotName[mx]={"hMassPtUU","hMassPtUD","hMassPtDU","hMassPtDD"};
157  char *fName[mt]={"allfill.hist"};
158  TString inPath="";
159 
160  gStyle->SetPalette(1,0);
161  int i;
162  for(i=0;i<mt;i++) {
163  TString hFile=inPath+fName[i];
164  hFile+=".root";
165  fd0=new TFile(hFile); assert(fd0->IsOpen());
166  fd[i]=fd0;
167  }
168  //int ploti;
169 
170  for(int ploti=0;ploti<mx;ploti++)
171  {
172  int ent=0;
173  int minbin,maxbin;
174  TH1F* h1= new TH1F("hMassAny","diphoton invariant mass",120,0.,1.2 );
175  TString hname=PlotName[ploti];
176  printf("i= %d =%s=\n",ploti,hname.Data());
177  h0=(TH2F*)fd[0]->Get(hname); assert(h0);
178  minbin=h0->GetYaxis()->FindBin(ptmin);
179  maxbin=h0->GetYaxis()->FindBin(ptmax)-1;
180  h1->Add(h0->ProjectionX("htemp",minbin,maxbin,""));
181  ent=h1->Integral();
182  bg1[key][ploti]=h1->Integral(5,9);
183  bg2[key][ploti]=h1->Integral(20,41);
184  cout<<"entry="<<ent<<" bg1="<<bg1[key][ploti]<<" bg2="<<bg2[key][ploti]<<endl;
185  h1->SetEntries(ent);
186 
187  }//end of mx
188  return;
189 
190 }
191