AliPhysics  b8420c0 (b8420c0)
AddChi2JJDecLowHighGraphs.C
Go to the documentation of this file.
1 #if !defined(__CINT__) || defined(__MAKECINT__)
13 
14 #include <TFile.h>
15 #include <TDirectoryFile.h>
16 #include <TList.h>
17 #include <TString.h>
18 #include <TROOT.h>
19 #include <TStyle.h>
20 #include <TH1D.h>
21 #include <TH2F.h>
22 #include <TH3F.h>
23 #include <TCanvas.h>
24 #include <TPad.h>
25 #include <TLegend.h>
26 #include <TObject.h>
27 #include <TAxis.h>
28 #include <TGaxis.h>
29 #include <TLine.h>
30 #include <TF1.h>
31 #include <TMath.h>
32 #include <TGraphErrors.h>
33 #endif
34 
35 //------------------------------------------------------------------------------
43 //------------------------------------------------------------------------------
45 (
46  TString quantity = "SMM02NoCut",//"SMM02NoCut","SMM02","SMM20LowM02NoCut","SMM02LowM02","SMM20HighM02NoCut","SMM02HighM02","SMNCell"
47  TString titleData = "LHC11cd_EMC7",
48  TString opt = "", //"TMDep_Neutral_V1_..."
49  TString fileFormat = ".eps"
50  )
51 {
52  // SM
53  const Int_t nparam = 10;
54  Double_t pbins[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
55  Int_t ncol = 4;
56  Int_t nrow = 3;
57 
58 // Float_t eBinsL[] = {2.5,3.5,5.5,7.5,9.5,11.5,13.5,16.5,18.5};
59 // Float_t eBinsH[] = {16.5,18.5,20.5,22.5,24.5,26.5,50.5};
60 
61  Float_t eBinsL[] = { 7.5, 9.5,11.5,13.5,15.5,17.5,19.5};
62  Float_t eBinsH[] = {17.5,19.5,24.5,29.5,34.5,39.5,49.5};
63 
64  const Int_t nEBins = 8;
65 
66  Int_t colorL[] = {1,4,2,6,8,9,kYellow-6,kCyan,kOrange+2,kViolet,kOrange-2};
67  Int_t colorH[] = {9,kOrange+2,kViolet,kOrange-2,kRed-3,kRed+3,kBlue-3,kBlue+3};
68 
69  TFile* fileL = TFile::Open(Form("figures/%s/Chi2Distributions_%s_JJDecLow%s_PerSM_Ebin.root",
70  quantity.Data(),titleData.Data(),opt.Data()));
71  TFile* fileH = TFile::Open(Form("figures/%s/Chi2Distributions_%s_JJDecHigh%s_PerSM_Ebin.root",
72  quantity.Data(),titleData.Data(),opt.Data()));
73 
74  printf("File JJ Low %p %s\n",fileL,fileL->GetName());
75  printf("File JJ High %p %s\n",fileH,fileH->GetName());
76 
77  TGraphErrors* gChi2L [nEBins][nparam];
78  TGraphErrors* gChi2LMin [nparam];
79  TGraphErrors* gChi2H [nEBins][nparam];
80  TGraphErrors* gChi2HMin [nparam];
81 
82  for(Int_t ipbin = 0; ipbin < nparam; ipbin++)
83  {
84  gChi2LMin[ipbin] = (TGraphErrors*) fileL->Get(Form("Chi2Min_SM%d",ipbin));
85  if( gChi2LMin[ipbin] )
86  {
87  gChi2LMin[ipbin]->SetMarkerStyle(20);
88  gChi2LMin[ipbin]->SetMarkerColor(4);
89  gChi2LMin[ipbin]->SetLineColor (4);
90  }
91 
92  gChi2HMin[ipbin] = (TGraphErrors*) fileH->Get(Form("Chi2Min_SM%d",ipbin));
93  if( gChi2HMin[ipbin] )
94  {
95  gChi2HMin[ipbin]->SetMarkerStyle(24);
96  gChi2HMin[ipbin]->SetMarkerColor(4);
97  gChi2HMin[ipbin]->SetLineColor (4);
98  }
99  //printf("\t SM %d, %p %p\n",ipbin,gChi2LMin[ipbin],gChi2LMin[ipbin]);
100 
101  for(Int_t iebin = 0; iebin < nEBins; iebin++)
102  {
103  gChi2L[iebin][ipbin] = (TGraphErrors*) fileL->Get(Form("Chi2_SM%d_EBin%d",ipbin,iebin));
104  if(gChi2L[iebin][ipbin])
105  {
106  gChi2L[iebin][ipbin]->SetMarkerStyle(20);
107  gChi2L[iebin][ipbin]->SetMarkerSize(4);
108  gChi2L[iebin][ipbin]->SetMarkerColor(colorL[iebin]);
109  gChi2L[iebin][ipbin]->SetLineColor(colorL[iebin]);
110  }
111 
112  gChi2H[iebin][ipbin] = (TGraphErrors*)fileH->Get(Form("Chi2_SM%d_EBin%d",ipbin,iebin));
113  if(gChi2H[iebin][ipbin])
114  {
115  gChi2H[iebin][ipbin]->SetMarkerStyle(24);
116  gChi2H[iebin][ipbin]->SetMarkerSize(4);
117  gChi2H[iebin][ipbin]->SetMarkerColor(colorH[iebin]);
118  gChi2H[iebin][ipbin]->SetLineColor(colorH[iebin]);
119  }
120  //printf("\t ie %d, %p %p\n",iebin,gChi2L[iebin][ipbin],gChi2H[iebin][ipbin]);
121  }
122  }
123 
124  //
125  TCanvas * gChi2graph = new TCanvas(Form("cChi2_graph_%s",quantity.Data()),
126  Form("Chi2, %s",quantity.Data()),
127  ncol*1000,nrow*1000);
128  gChi2graph->Divide(ncol,nrow);
129 
130  TLegend *lgchi2 = new TLegend(0,0,1,1);
131  lgchi2->SetFillColor(0);
132  lgchi2->SetFillStyle(0);
133  lgchi2->SetLineColor(0);
134  lgchi2->SetBorderSize(0);
135  lgchi2->SetTextSize(0.07);
136 
137  for(Int_t ipbin = 0; ipbin < nparam; ipbin++)
138  {
139  gChi2graph->cd(ipbin+1);
140 
141  gPad->SetLogy();
142  gPad->SetGridy();
143  gPad->SetGridx();
144 
145  // LOW
146  Bool_t set = kFALSE;
147  for(Int_t iebin = 0; iebin < 5; iebin++)
148  {
149  if(!gChi2L[iebin][ipbin]) continue;
150 
151  gChi2L[iebin][ipbin]->GetHistogram()->SetTitleOffset(1.5,"Y");
152  //gChi2L[iebin][ipbin]->GetHistogram()->SetYTitle("#chi^{2} / #nu");
153  // gChi2L[iebin][ipbin]->SetAxisRange(0,0.8,"X");
154 
155  //printf("iebin %d, ipbin %d 0 %d %p\n",iebin,ipbin,0,h[0][iebin][ipbin]);
156 
157  if(!set) {
158  set = kTRUE;
159  gChi2L[iebin][ipbin]->Draw("APL");
160  }
161  else
162  gChi2L[iebin][ipbin]->Draw("PL");
163 
164  // gChi2L[iebin][ipbin]->SetMaximum(200);
165  // gChi2L[iebin][ipbin]->SetMinimum(0.25);
166 
167  if(ipbin==0)
168  {
169  lgchi2->AddEntry(gChi2L[iebin][ipbin],
170  gChi2L[iebin][ipbin]->GetTitle(),
171  "PL");
172  }
173  if(quantity.Contains("SM")) gChi2L[iebin][ipbin]->SetTitle(Form("SM %d",ipbin));
174 
175  } // iebin
176 
177  // HIGH
178  for(Int_t iebin = 0; iebin < 2; iebin++)
179  {
180  if(!gChi2H[iebin][ipbin]) continue;
181 
182  gChi2H[iebin][ipbin]->Draw("PL");
183 
184  if(ipbin==0)
185  {
186  lgchi2->AddEntry(gChi2H[iebin][ipbin],
187  gChi2H[iebin][ipbin]->GetTitle(),
188  "PL");
189  }
190  } // iebin
191  //printf("\t end\n");
192  } // param
193 
194  gChi2graph->cd(ncol*nrow-1);
195  lgchi2->Draw();
196 
197  gChi2graph->cd(ncol*nrow);
198  TLegend *legend2 = new TLegend(0.,0.,0.9,0.9);
199  legend2->SetFillColor(0);
200  legend2->SetFillStyle(0);
201  legend2->SetLineColor(0);
202  legend2->SetBorderSize(0);
203  legend2->SetTextSize(0.07);
204  legend2->SetHeader("#chi^{2}/#nu of Data-MC");
205  legend2->AddEntry("","Data: LHC11c+d, EMC7","");
206  legend2->AddEntry("","MC:","");
207  legend2->AddEntry(gChi2L[0][0],"#gammaJ+JJ #it{p}^{#gamma,EMC}_{T}>3.5 GeV/#it{c}","PL");
208  legend2->AddEntry(gChi2H[0][0],"#gammaJ+JJ #it{p}^{#gamma,EMC}_{T}>7 GeV/#it{c}","PL");
209 
210  legend2->Draw();
211 
212  TString fileName = Form("figures/%s/Comparison_Chi2_%s_JJDecLowHigh%s_PerSM_Ebin",
213  quantity.Data(),titleData.Data(),opt.Data());
214  fileName+=fileFormat;
215  gChi2graph->Print(fileName);
216 
217  gStyle->SetOptStat(0);
218  gStyle->SetOptTitle(1);
219  gStyle->SetPadTopMargin(0.01);
220  gStyle->SetPadRightMargin(0.01);
221 
222  TCanvas * gChi2Mingraph = new TCanvas(Form("cChi2Min_graph_%s",
223  quantity.Data()),
224  Form("Diff, %s",
225  quantity.Data()),
226  ncol*500,nrow*500);
227  gChi2Mingraph->Divide(ncol,nrow);
228 
229  for(Int_t ipbin = 0; ipbin < nparam; ipbin++)
230  {
231  gChi2Mingraph->cd(ipbin+1);
232 
233  if(!gChi2LMin[ipbin]) continue;
234 
235  //gChi2LMin[ipbin]->GetHistogram()->SetTitleOffset(1.8,"Y");
236 
237  //gChi2LMin[ipbin]->GetHistogram()->SetYTitle("#mu_{1} (%)");
238  //if(quantity.Contains("SM" )) gChi2LMin[ipbin]->SetTitle(Form("SM %2.0f" ,pbins[ipbin]));
239 
240  TH1F* haxis= new TH1F(Form("haxis%d",ipbin),Form("SM %d",ipbin),30,0.5,45.5);
241  haxis->SetYTitle(gChi2LMin[ipbin]->GetHistogram()->GetYaxis()->GetTitle());
242  haxis->SetXTitle(gChi2LMin[ipbin]->GetHistogram()->GetXaxis()->GetTitle());
243  haxis->SetTitle(Form("SM %d",ipbin));
244  haxis->SetMaximum(1.8);
245  haxis->SetMinimum(0.0);
246 
247  //gPad->SetLogy();
248  gPad->SetGridy();
249  gPad->SetGridx();
250 
251  haxis->Draw("axis");
252  //printf("iebin %d, ipbin %d 0 %d %p\n",iebin,ipbin,0,h[0][ipbin]);
253  gChi2LMin[ipbin]->Draw("PL");
254  gChi2HMin[ipbin]->Draw("PL");
255 
256  //gChi2LMin[ipbin]->SetMaximum(1.7);
257  //gChi2LMin[ipbin]->SetMinimum(-0.1);
258  TLegend *lgChi2Min = 0;
259  if(ipbin==3 ||ipbin==7) lgChi2Min= new TLegend(0.15,0.20,0.98,0.43);
260  else lgChi2Min= new TLegend(0.15,0.75,0.98,0.98);
261  lgChi2Min->SetFillColor(0);
262  lgChi2Min->SetFillStyle(0);
263  lgChi2Min->SetLineColor(0);
264  lgChi2Min->SetBorderSize(0);
265  lgChi2Min->SetTextSize(0.06);
266  lgChi2Min->SetHeader(Form("SM %d",ipbin));
267  lgChi2Min->Draw();
268 
269  Bool_t doFit = kFALSE;
270  if(doFit)
271  {
272  gChi2HMin[ipbin]->Fit("pol0","QR","",16,30);
273  TF1* fun0 = gChi2HMin[ipbin]->GetFunction("pol0");
274  Float_t par0 = fun0->GetParameter(0);
275  printf("sm %d parameter0 %2.2f\n",ipbin,par0);
276 
277  TF1* fun1 = new TF1("plin1","[0]-x*[1]",2.5,16.);
278  fun1->SetParameters(par0,-1.1);
279  fun1->SetParLimits(0,par0*0.001,par0*5.1);
280  fun1->SetParLimits(1,0.07,0.1);
281  gChi2LMin[ipbin]->Fit("plin1","","",7.5,16.);
282  fun1->SetRange(0.5,16.0);
283  fun1->Draw("same");
284  }
285  else
286  {
287  if(ipbin == 3 || ipbin == 7)
288  {
289  TF1* fun1 = new TF1("plin1","2.2-x*0.09",0.5,16.);
290  TF1* fun0 = new TF1("plin0","0.8",16,45);
291  fun1->Draw("same");
292  fun0->Draw("same");
293  fun0->SetLineColor(kViolet);
294  lgChi2Min->AddEntry(fun0,"0.8%","L");
295  lgChi2Min->AddEntry(fun1,"2.2% - #it{E}_{cluster} #times 0.09%","L");
296  }
297 
298  else if(ipbin == 1 || ipbin == 2)
299  {
300  TF1* fun1 = new TF1("plin1","1.5-x*0.08",0.5,13.);
301  TF1* fun0 = new TF1("plin0","0.5",13,45);
302  fun1->Draw("same");
303  fun0->Draw("same");
304  fun0->SetLineColor(kViolet);
305  lgChi2Min->AddEntry(fun0,"0.5%","L");
306  lgChi2Min->AddEntry(fun1,"1.5% - #it{E}_{cluster} #times 0.08%","L");
307  }
308  else //if(ipbin == 1 || ipbin == 2)
309  {
310  TF1* fun1 = new TF1("plin1","1.1-x*0.08",0.5,9);
311  TF1* fun0 = new TF1("plin0","0.4",9,45);
312  fun1->Draw("same");
313  fun0->Draw("same");
314  fun0->SetLineColor(kViolet);
315  lgChi2Min->AddEntry(fun0,"0.4%","L");
316  lgChi2Min->AddEntry(fun1,"1.1% - #it{E}_{cluster} #times 0.08%","L");
317  }
318 
319  }
320 
321  } // param
322 
323  gChi2Mingraph->cd(ncol*nrow);
324 
325  TLegend *legend = new TLegend(0.,0.,0.9,0.9);
326  legend->SetFillColor(0);
327  legend->SetFillStyle(0);
328  legend->SetLineColor(0);
329  legend->SetBorderSize(0);
330  legend->SetTextSize(0.07);
331  legend->SetHeader("Min of #chi^{2}/#nu of Data-MC");
332  legend->AddEntry("","Data: LHC11c+d, EMC7","");
333  legend->AddEntry("","MC:","");
334  legend->AddEntry(gChi2LMin[0],"#gammaJ+JJ #it{p}^{#gamma,EMC}_{T}>3.5 GeV/#it{c}","PL");
335  legend->AddEntry(gChi2HMin[0],"#gammaJ+JJ #it{p}^{#gamma,EMC}_{T}>7 GeV/#it{c}","PL");
336 
337  legend->Draw();
338 
339  fileName = Form("figures/%s/Comparison_Chi2Min_%s_JJDecLowHigh%s_PerSM_Ebin",
340  quantity.Data(),titleData.Data(),opt.Data());
341  fileName+=fileFormat;
342  gChi2Mingraph->Print(fileName);
343 }
344 
double Double_t
Definition: External.C:58
TString fileName
void AddChi2JJDecLowHighGraphs(TString quantity="SMM02NoCut", TString titleData="LHC11cd_EMC7", TString opt="", TString fileFormat=".eps")
int Int_t
Definition: External.C:63
float Float_t
Definition: External.C:68
TString fileFormat
bool Bool_t
Definition: External.C:53