FairRoot/PandaRoot
combinePlotsEtac.C
Go to the documentation of this file.
1 
2 // --------------------------------------------------------------------
3 
4 void confgraph(TGraph *g, TString tit, int col=1, int marker=20, double shift=0.)
5 {
6  if (tit!="") g->GetHistogram()->SetTitle(tit);
7  g->GetHistogram()->SetMinimum(0);
8  g->SetLineColor(col);
9  g->SetMarkerColor(col);
10  g->SetMarkerStyle(marker);
11  g->SetMarkerSize(1.5);
12  g->SetLineWidth(2);
13 
14  TF1 *f1 = g->GetFunction("f1");
15 
16  if (f1)
17  {
18  f1->SetLineColor(col);
19  f1->SetLineStyle(2);
20  }
21 
22  for (int i=0;i<g->GetN();++i)
23  {
24  double x,y;
25  g->GetPoint(i,x,y);
26  g->SetPoint(i,x+shift,y);
27 
28  // cout <<x<<" "<<y<<endl;
29  }
30 }
31 
32 // --------------------------------------------------------------------
33 
34 
35 TH1F* createHistoGraph(TGraph *g, TString tit="", double yymax=0, double xmin=0, double xmax=0)
36 {
37  static int cnt=0;
38  if (tit=="") tit=g->GetTitle();
39 
40  double ymax = TMath::MaxElement(g->GetN(), g->GetY());
41  double dymax = g->GetErrorY(TMath::LocMax(g->GetN(), g->GetEY()));
42 
43  if (xmin>=xmax)
44  {
45  xmin = TMath::MinElement(g->GetN(), g->GetX());
46  xmax = TMath::MaxElement(g->GetN(), g->GetX());
47  }
48  TH1F *h=new TH1F(Form("h%03d",cnt++),tit,g->GetN(),xmin-0.5*(xmax-xmin)/g->GetN(), xmax+0.5*(xmax-xmin)/g->GetN());
49 
50  h->GetXaxis()->SetLabelSize(0.05);
51  h->GetXaxis()->SetTitleSize(0.05);
52  h->GetYaxis()->SetLabelSize(0.05);
53  h->GetYaxis()->SetTitleSize(0.05);
54  h->GetYaxis()->SetTitleOffset(1.4);
55 
56  if (yymax==0)
57  h->SetMaximum((ymax+dymax)*1.05);
58  else
59  h->SetMaximum(yymax);
60  h->SetMinimum(0);
61 
62  h->SetStats(0);
63 
64  return h;
65 }
66 
67 // --------------------------------------------------------------------
68 
69 void combinePlotsEtac(TString fname="ana_etac.root")
70 {
71  gStyle->SetOptStat(0);
72  gStyle->SetOptFit(0);
73 
74  TFile *f=new TFile(fname);
75 
76  TString plotnam[2]={"etac1_A","etac1_B"};
77  TString lab[4] = { "signal efficiency;EMC missing (polar #theta) [%];signal efficiency [%]", "background efficiency;EMC missing (polar #theta) [%];background efficiency [%]", "signal to noise;EMC missing (polar #theta) [%];S/B", "significance;EMC missing (polar #theta) [%];significance [#sigma]"};
78 
79  TGraphErrors *geffs[2];
80  TGraphErrors *geffb[2];
81  TGraphErrors *gston[2];
82  TGraphErrors *gsign[2];
83 
84  TCanvas *c1=new TCanvas("c1","c1",10,10,1300,1000);
85  c1->Divide(2,2,0.0001,0.0001);
86 
87  int colors[2] = {kBlue,kCyan-2};
88  //int colors[2] = {2,kRed-7};
89 
90  TH1F *h[4]={0};
91  double hmaxy[4] = {20., 1e-5, 0.25, 7.};
92 
93  for (int i=0;i<2;++i)
94  {
95  c1->cd(1);
96  geffs[i]=(TGraphErrors*)f->Get(Form("effs_%s",plotnam[i].Data()));
97  confgraph(geffs[i],"",colors[i],20+(i%2)*3,i);
98  if (h[0]==0) h[0]=createHistoGraph(geffs[i],lab[0], hmaxy[0]);
99  if (i==0) h[0]->Draw();
100  geffs[i]->Draw("P same");
101 
102  c1->cd(2); gPad->SetLogy();
103  geffb[i]=(TGraphErrors*)f->Get(Form("effb_%s",plotnam[i].Data()));
104  confgraph(geffb[i],"",colors[i],20+(i%2)*3,i);
105  if (h[1]==0) h[1]=createHistoGraph(geffb[i],lab[1], hmaxy[1]);
106  h[1]->SetMinimum(1e-8);
107  if (i==0) h[1]->Draw();
108  geffb[i]->Draw("P same");
109 
110  c1->cd(3);
111  gston[i]=(TGraphErrors*)f->Get(Form("sn_%s",plotnam[i].Data()));
112  confgraph(gston[i],"",colors[i],20+(i%2)*3,i);
113  if (h[2]==0) h[2]=createHistoGraph(gston[i],lab[2], hmaxy[2]);
114  if (i==0) h[2]->Draw();
115  gston[i]->Draw("P same");
116 
117  c1->cd(4);
118  gsign[i]=(TGraphErrors*)f->Get(Form("sign_%s",plotnam[i].Data()));
119  confgraph(gsign[i],"",colors[i],20+(i%2)*3,i);
120  if (h[3]==0) h[3]=createHistoGraph(gsign[i],lab[3], hmaxy[3]);
121  if (i==0) h[3]->Draw();
122  gsign[i]->Draw("P same");
123  }
124 
125  c1->cd(1);
126  TLegend *leg1=new TLegend(0.6,0.8,0.94,0.92);
127  leg1->AddEntry(geffs[0],"#eta_{c1}#eta - Setup A","lep");
128  leg1->AddEntry(geffs[1],"#eta_{c1}#eta - Setup B","lep");
129  leg1->Draw();
130 
131  c1->cd(2);
132  TLegend *leg2=new TLegend(0.6,0.8,0.94,0.92);
133  leg2->AddEntry(geffb[0],"#eta_{c1}#eta - Setup A","lep");
134  leg2->AddEntry(geffb[1],"#eta_{c1}#eta - Setup B","lep");
135  leg2->Draw();
136 
137  c1->cd(3);
138  TLegend *leg3=new TLegend(0.6,0.8,0.94,0.92);
139  leg3->AddEntry(gston[0],"#eta_{c1}#eta - Setup A","lep");
140  leg3->AddEntry(gston[1],"#eta_{c1}#eta - Setup B","lep");
141  leg3->Draw();
142 
143  c1->cd(4);
144  TLegend *leg4=new TLegend(0.6,0.8,0.94,0.92);
145  leg4->AddEntry(gsign[0],"#eta_{c1}#eta - Setup A","lep");
146  leg4->AddEntry(gsign[1],"#eta_{c1}#eta - Setup B","lep");
147  leg4->Draw();
148 
149  c1->SaveAs("fig/comb_etac.gif");
150 }
Int_t i
Definition: run_full.C:25
TF1 * f1
Definition: reco_analys2.C:50
Double_t xmax
int col
Definition: anaLmdDigi.C:67
TFile * g
TH1F * createHistoGraph(TGraph *g, TString tit="", double xmin=0, double xmax=0)
Definition: analyse_etac1.C:60
void confgraph(TGraph *g, TString tit, int col=1, int marker=20)
Definition: analyse_etac1.C:47
void combinePlotsEtac(TString fname="ana_etac.root")
TFile * f
Definition: bump_analys.C:12
c1
Definition: plot_dirc.C:35
Double_t x
Int_t cnt
Definition: hist-t7.C:106
Double_t xmin
Double_t y