StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
plWjacob_APS.C
1 float thresET=25; // cut of for computations of yields & backg
2 TH1F *hRaw[5];
3 TH1F *hFinW[5];
4 int stage=3;
5 
6 void plWjacob_APS() {
7 
8  gStyle->SetOptDate(0);
9 
10  TString iPath="";
11  TString fullInpName=iPath+"bkgd_histos_pos_output4.root";
12  fdP=new TFile(fullInpName); assert(fdP->IsOpen());
13  TString fullInpName=iPath+"bkgd_histos_neg_4GeV_output4.root";
14  fdN=new TFile(fullInpName); assert(fdN->IsOpen());
15  //fdP->ls();
16  //fdN->ls();
17 
18  c=new TCanvas("aa","aa",900,450);
19  c->Divide(2,1);
20  c->SetFillColor(kWhite);
21 
22  c->cd(2); doJob1(fdP,"W^{#scale[1.5]{+}}",0); // W+
23  c->cd(1); doJob1(fdN,"W^{#scale[1.5]{-}}",1); // W-
24 
25 }
26 
27 //===================
28 void doJob1(TFile *fd, TString charge, int q) {
29  gStyle->SetPalette(1,0);
30  gStyle->SetEndErrorSize(0);
31 
32  gPad->SetGridy(false);
33  gPad->SetGridx(false);
34 
35  TString fileEnd;
36  if(q==1) fileEnd="_r";
37 
38  //error histograms
39  TH1F *hRaw2= (TH1F*) fd->Get(Form("raw_stat_err2%s",fileEnd.Data())); assert(hRaw2);
40  TH1F *hEemcBack2= (TH1F*) fd->Get(Form("eemc_stat_err2%s",fileEnd.Data())); assert(hEemcBack2);
41  TH1F *hTauBack2= (TH1F*) fd->Get(Form("tau_stat_err2%s",fileEnd.Data())); assert(hTauBack2);
42  TH1F *hQcdBack2= (TH1F*) fd->Get(Form("QCD_stat_err2%s",fileEnd.Data())); assert(hQcdBack2);
43 
44  hRaw[q]= (TH1F*) fd->Get(Form("signal2%s",fileEnd.Data())); assert(hRaw[q]);
45  hFinW[q]= (TH1F*) fd->Get(Form("signal_final3%s",fileEnd.Data())); assert(hFinW[q]);
46  hRaw[q]->SetAxisRange(0,70);
47  if(q==0){
48  hRaw[q]->SetMaximum(99.9);
49  hRaw[q]->SetMinimum(-10);
50  }
51  else {
52  hRaw[q]->SetMaximum(99.9);
53  hRaw[q]->SetMinimum(-10);
54  }
55  hRaw[q]->SetStats(false);
56  hRaw[q]->Draw("h");
57  if(stage < 3) hRaw[q]->SetLineWidth(2);
58 
59  TH1F * hBack=(TH1F*) hRaw[q]->Clone(); hBack->SetNameTitle("totBackg", "totBackg");
60  hBack->Add(hFinW[q],-1.);
61  hBack->SetLineColor(kBlue);
62  hBack->SetLineWidth(2);
63  hBack->SetMarkerStyle(8);
64  hBack->SetMarkerColor(kBlue);
65  hBack->SetMarkerSize(0.8);
66 
67  //draw histograms
68  hFinW[q]->SetMarkerStyle(8); hFinW[q]->SetMarkerSize(0.8); hFinW[q]->SetLineColor(kBlack);
69  hFinW[q]->SetFillColor(kYellow);
70  hFinW[q]->SetLineWidth(2);
71  if(stage > 2) hFinW[q]->Draw("same h");
72  float startLine=1;
73  if(q==1) startLine=3;
74  ln=new TLine(startLine,0,71,0); ln->Draw();
75  if(stage > 1) {
76  hBack->Draw("h e same");
77  ln2=new TLine(startLine,0,15,0); ln2->SetLineWidth(2); ln2->Draw();
78  }
79 
80  //set stat errors
81  int startbin=8;
82  if(q==1) startbin=4;
83  float xpos[50],ypos[50],err[50];
84  for(int ibin=startbin;ibin<hRaw[q]->GetNbinsX();ibin++){
85  float eemcBack2=hEemcBack2->GetBinContent(ibin);
86  float tauBack2=hTauBack2->GetBinContent(ibin);
87  float qcdBack2=hQcdBack2->GetBinContent(ibin);
88  float rawErr2=hRaw[q]->GetBinContent(ibin);
89  float backToterr=sqrt(eemcBack2+tauBack2+qcdBack2);
90  float finToterr=sqrt(eemcBack2+tauBack2+qcdBack2+rawErr2);
91  hBack->SetBinError(ibin,backToterr);
92  xpos[ibin-startbin]=hBack->GetBinCenter(ibin);
93  ypos[ibin-startbin]=hFinW[q]->GetBinContent(ibin);
94  err[ibin-startbin]=finToterr;
95  }
96  TGraphErrors *errors = new TGraphErrors(50,xpos,ypos,0,err);
97  errors->SetMarkerStyle(8);
98  errors->SetMarkerSize(0.8); errors->SetLineColor(kBlack);
99  if(stage > 2) errors->Draw("p");
100 
101  lg=new TLegend(0.6,0.62,0.88,0.78); // top
102  //TDatime dt;lg->SetHeader(dt.AsString());
103  if(q==0) lg->SetHeader(" positron |#eta|_{ }<_{ }1");
104  else lg->SetHeader(" electron |#eta|_{ }<_{ }1");
105  lg->AddEntry(hRaw[q],Form("#font[52]{%s} candidates",charge.Data()),"l");
106  lg->AddEntry(hBack,"Backg. est.","lfep");
107  lg->AddEntry(hFinW[q],Form("Backg. subtr. #font[52]{%s} ",charge.Data()),"lfep");
108  lg->SetFillColor(kWhite);
109  lg->SetLineColor(kWhite);
110  lg->Draw();
111 
112  TLatex *lat1 = new TLatex(0.15,0.84,"Run 9 STAR Preliminary #sqrt{#font[72]{s}}_{ }=_{ }500 GeV");
113  lat1->SetNDC(); lat1->SetTextSize(0.045); lat1->Draw("same");
114  if(q==0){
115  TLatex *lat2 = new TLatex(0.48,0.79,"#font[52]{p+p #rightarrow W^{#scale[1.2]{+}} #rightarrow e^{#scale[1.2]{+}} + #nu_{e}}");
116  lat2->SetNDC(); lat2->Draw("same");
117  }
118  else{
119  TLatex *lat2 = new TLatex(0.48,0.79,"#font[52]{p+p #rightarrow W^{#scale[1.2]{-}} #rightarrow e^{#scale[1.2]{-}} + #bar{#nu}_{e}}");
120  lat2->SetNDC(); lat2->Draw("same");
121  }
122 
123  if(max==100) tx=new TText(14,20,"software threshold");
124  else tx=new TText(14,10,"software threshold");
125  tx->SetTextAngle(90);
126  tx->SetTextSize(0.03);//tx->SetTextColor(kMagenta);
127  tx->Draw();
128 
129  char tt[100]; sprintf(tt,"; EMC cluster #font[72]{E_{T}} (GeV) ;Counts",charge.Data());
130  hRaw[q]->GetYaxis()->SetTitleOffset(1.25);
131  hRaw[q]->SetTitle(tt);
132  //hRaw[q]->SetLineWidth(2);
133 
134  // .... compute integrals
135  //float rawSum=getSum(hRaw[q]);
136  //float signSum=getSum(hFinW[q]);
137  //float backSum=getSum(hBack);
138  //printf(" sum ET>25 : raw=%.0f signal=%.0f back=%.0f S+B/S=%.2f\n", rawSum,signSum, backSum,rawSum/signSum);
139 
140 }
141 
142 //------------------
143 float getSum(TH1F* h) {
144  h->SetAxisRange(thresET,100);
145  float sum=h->Integral();
146  h->SetAxisRange(0,100);
147  return sum;
148 }