StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
prd2009WdataMCjacob.C
1 
2 bool colorPlot;
3 TString iPathMC,iPathBkgd;
4 
5 void prd2009WdataMCjacob(bool x=false,TString y="/star/u/stevens4/wAnalysis/efficXsec/outEmb/gainUp2/",TString z="/star/u/stevens4/wAnalysis/xSecPaper/background/",float canvasScale=1.0) {
6 
7  colorPlot=x;
8  iPathMC=y;
9  iPathBkgd=z;
10 
11  TCanvas *c=new TCanvas("aa","bb",500*canvasScale,500*canvasScale);
12  if(!colorPlot) c->SetGrayscale();
13 
14  TPad *cT = new TPad("padT","padT",0,0.5,1.,1.); cT->Draw();
15  TPad *cB = new TPad("padB","padB",0,0,1.,0.5); cB->Draw();
16 
17  //both charges
18  cT->cd();
19  prd2009WdataMCjacobX("Wplus","pos",128.6,147.0,1,canvasScale);
20  cB->cd();
21  prd2009WdataMCjacobX("Wminus","neg",385.0,74.0,2,canvasScale);
22 
23  if(colorPlot) {
24  c->Print("/star/u/stevens4/wAnalysis/xSecPaper/plots//color/wJacobColor.eps");
25  c->Print("/star/u/stevens4/wAnalysis/xSecPaper/plots/color/wJacobColor.png");
26  }
27  else {
28  c->Print("/star/u/stevens4/wAnalysis/xSecPaper/plots/bw/wJacobBW.eps");
29  c->Print("/star/u/stevens4/wAnalysis/xSecPaper/plots/bw/wJacobBW.png");
30  }
31  return;
32 
33 }
34 
35 void prd2009WdataMCjacobX(string charge, string charge2,float wlumi,float max,int pad,float canvasScale) {
36 
37  gStyle->SetOptStat(00000);
38  gStyle->SetOptDate(0);
39 
40  //init files
41  TFile *f;
42  f=new TFile(Form("%sbkgd_histos_%s_final.root",iPathBkgd.Data(),charge2)); assert(f->IsOpen());
43 
44  TFile *fmc = new TFile(Form("%s%s.wana.hist.root",iPathMC.Data(),charge)); assert(fmc->IsOpen());
45 
46  TH1F* hTau;
47  TH1F* hZ;
48  TH1F* hEemc;
49  TH1F* hQcd;
50  TH1F* hData;
51 
52 #if 0
53  if(charge=="Wplus"){
54  hTau = (TH1F*)f->Get("mcclustPtBal_2");
55  hZ = (TH1F*)f->Get("zsig_bkgd2");
56  hEemc= (TH1F*)f->Get("eemc_bkgd2");
57  hQcd = (TH1F*)f->Get("new_bkgd");
58  hData= (TH1F*)f->Get("signal2");
59  } else if(charge=="Wminus"){
60 #endif
61 
62  hTau = (TH1F*)f->Get("tauhist_r");
63  hZ = (TH1F*)f->Get("zsig_bkgd2_r");
64  hEemc= (TH1F*)f->Get("eemc_bkgd2_r");
65  hQcd = (TH1F*)f->Get("new_bkgd_r");
66  hData= (TH1F*)f->Get("signal2_r");
67  //}
68 
69  if(colorPlot) { int color[4]={kGreen,kBlue,kRed,kOrange}; }
70  else { int color[4]={kYellow+2,kYellow+4,kYellow,kYellow+3}; }
71 
72  hTau->SetFillColor(color[0]); hTau->SetLineColor(color[0]);
73  hZ->SetFillColor(color[1]); hZ->SetLineColor(color[1]);
74  hEemc->SetFillColor(color[2]); hEemc->SetLineColor(color[2]);
75  hQcd->SetFillColor(color[3]); hQcd->SetLineColor(color[3]);
76  if(!colorPlot) {
77  hEemc->SetLineColor(color[3]);
78  hQcd->SetFillStyle(3344); hQcd->SetLineColor(1);
79  }
80  hData->SetLineWidth(2);
81 
82  TH1F* hW = fmc->Get("muclustPtBal"); hW->Scale(13.18/wlumi);
83  TH1F *hW2 = new TH1F("muclustPtBal_2","; E_{T}^{e} (GeV); Counts",49,1,99);
84  TH1F *hW4 = new TH1F("muclustPtBal_4","; E_{T}^{e} (GeV); Counts",24,3,99);
85  //set axis range and offsets
86  hW2->GetYaxis()->SetTitleOffset(1.25);
87  hW2->GetXaxis()->SetRangeUser(10,60);
88  hW4->GetYaxis()->SetTitleOffset(1.25);
89  hW4->GetXaxis()->SetRangeUser(10,60);
90 
91  for (int i=1; i<=49; i++) { //repack in 2 GeV bins
92  hW2->SetBinContent(i,hW->GetBinContent(2*i)+hW->GetBinContent(2*i+1));
93  }
94  for (int i=1; i<=24; i++) { //repack in 4 GeV bins
95  hW4->SetBinContent(i,hW2->GetBinContent(2*i)+hW2->GetBinContent(2*i+1));
96  }
97  hW2->SetLineColor(6); hW2->SetLineStyle(2); hW2->SetLineWidth(2);
98  hW4->SetLineColor(6); hW4->SetLineStyle(2); hW4->SetLineWidth(2);
99 
100  //plot everything
101  if(pad==1){
102  gPad->SetTopMargin(0.05); gPad->SetBottomMargin(0.0);
103  gPad->SetLeftMargin(0.1); gPad->SetRightMargin(0.03);
104  }
105  if(pad==2){
106  gPad->SetTopMargin(0.0); gPad->SetBottomMargin(0.15);
107  gPad->SetLeftMargin(0.1); gPad->SetRightMargin(0.03);
108  }
109  gPad->SetGridy(false); gPad->SetGridx(false);
110  THStack *hs = new THStack("hs",";E_{T}^{e} (GeV);Counts");
111  hs->Add(hZ); hs->Add(hTau); //electroweak background
112  hs->Add(hEemc); hs->Add(hQcd); //sum together as "QCD"
113  //if(charge=="Wplus") hs->Add(hW2); //W signal histo
114  //else if(charge=="Wminus")
115  hs->Add(hW4); //W signal histo
116 
117  if(pad==1) hs->SetMinimum(0.001);
118  hs->SetMaximum(max);
119  hs->Draw();
120  hs->GetXaxis()->SetTitleOffset(0.9);
121  hs->GetXaxis()->SetRangeUser(10,60);
122  hs->GetXaxis()->SetTitleSize(0.07);
123  hs->GetXaxis()->SetLabelSize(0.06);
124  hs->GetXaxis()->CenterTitle();
125  hs->GetYaxis()->SetTitleOffset(0.65);
126  hs->GetYaxis()->SetTitleSize(0.07);
127  hs->GetYaxis()->SetLabelSize(0.06);
128  hs->GetYaxis()->CenterTitle();
129 
130  hData->GetXaxis()->SetLabelSize(0.06);
131  hData->GetYaxis()->SetLabelSize(0.06);
132  hData->Draw("h e same");
133 
134  //hData->Draw();
135  //hs->Draw("h e same");
136 
137 #if 0
138  gPad->SetGridy(false); gPad->SetGridx(false);
139  TH1F* hDataBkgdSub;
140  //if(charge=="Wplus") {
141  // hW2->Draw();
142  // hDataBkgdSub= (TH1F*)f->Get("signal_final3");
143  //}
144  //else if(charge=="Wminus") {
145  hW4->Draw();
146  hDataBkgdSub= (TH1F*)f->Get("signal_final3_r");
147  hDataBkgdSub->SetLineWidth(2);
148  //}
149  hDataBkgdSub->Draw("h e same");
150 #endif
151 
152  //make legend
153  float textSize=0.055; if(canvasScale>1.0) textSize=0.05;
154  if(charge=="Wplus"){
155  TLegend *leg = new TLegend(0.7,0.63,0.95,0.9);
156  leg->SetEntrySeparation(0.01);
157  leg->SetMargin(0.2);
158  leg->SetFillColor(0);
159  leg->SetTextSize(textSize);
160  leg->SetLineColor(kWhite);
161  leg->SetHeader("#scale[1.3]{Positron |#eta_{e}| < 1}");
162  leg->AddEntry(hData," STAR 2009 Data","l");
163  leg->AddEntry(hW2," W #rightarrow e #nu MC","l");
164  leg->AddEntry(hQcd," Data-driven QCD","f");
165  leg->Draw();
166  }
167  else {
168  TLegend *leg = new TLegend(0.7,0.66,0.95,0.93);
169  leg->SetEntrySeparation(0.01);
170  leg->SetMargin(0.2);
171  leg->SetFillColor(0);
172  leg->SetTextSize(textSize);
173  leg->SetLineColor(kWhite);
174  leg->SetHeader("#scale[1.25]{Electron |#eta_{e}| < 1}");
175  leg->AddEntry(hEemc," Second EEMC","f");
176  leg->AddEntry(hTau," W #rightarrow #tau #nu MC","f");
177  leg->AddEntry(hZ," Z #rightarrow ee MC","f");
178  leg->Draw();
179  }
180 
181  return;
182 
183  //insert text
184  TLatex *lat0 = new TLatex(0.13,0.945,"Run 9 STAR #font[52]{p+p} #sqrt{#font[72]{s}}_{ }=_{ }500 GeV");
185  lat0->SetNDC(); lat0->SetTextSize(0.04); lat0->Draw("same");
186  TLatex *lat2 = new TLatex(0.6,0.86,"#sigma(#font[52]{W^{#scale[1.2]{#pm}} #rightarrow e^{#scale[1.2]{#pm}} + #nu_{e}})");
187  //lat2->SetNDC(); lat2->SetTextSize(0.042); lat2->Draw("same");
188 
189 }
190