AliPhysics  9c66e61 (9c66e61)
CompareShowerShapeLongPerAnaPerSM.C
Go to the documentation of this file.
1 #if !defined(__CINT__) || defined(__MAKECINT__)
14 
15 #include <TFile.h>
16 #include <TDirectoryFile.h>
17 #include <TList.h>
18 #include <TString.h>
19 #include <TROOT.h>
20 #include <TStyle.h>
21 #include <TH1D.h>
22 #include <TH2F.h>
23 #include <TH3F.h>
24 #include <TCanvas.h>
25 #include <TPad.h>
26 #include <TLegend.h>
27 #include <TObject.h>
28 #include <TAxis.h>
29 #include <TGaxis.h>
30 #include <TLine.h>
31 #include <TF1.h>
32 #include <TMath.h>
33 #include <TGraphErrors.h>
34 #include "PlotUtils.C"
35 #endif
36 
37 //----------------------------------------------------------------------------
38 // Global variables
39 //----------------------------------------------------------------------------
40 
41 Int_t color [] = {1,4,2,kYellow-2,8,kCyan,kYellow-6,kCyan,kOrange+2,kViolet,
42  kOrange-2,4,2,6,8,9,kYellow-6,kCyan,kOrange+2,kViolet,kOrange-2};
43 Int_t lineStyle[] = {1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,
44  2,2,2,2,2,2,2,2,2,2,2,2};
45 Int_t marker [] = {20,20,20,21,24,24,24,24,24,24,24};
46 
48 
49 //*****
50 // Set the energy bins and productions to analyze
51 //*****
52 const Int_t nEBins = 5;
53 const Int_t nProd = 3;
54 TFile * file[nProd];
55 
57 // Low JJ
58 Double_t binE [] = { 8,10,12,14,16,18,20,25};
59 
60 TString titleName = "LHC11cd_EMC7_MCGJ-JJLow";
62 {
63  "data/module/TCardChannel3/LHC11cd_EMC7"
64  , "simu/module/pp_7TeV_JJ_Dec_GJ/TCardChannel_Mimic0_Scaled2_v3/ScaledMerged"
65  , "simu/module/pp_7TeV_JJ_Dec_GJ/TCardChannel_Mimic10c_EcellCut_Scaled2_v3/ScaledMerged"
66 } ;
67 
69 {
70  "Data, pp@ 7 TeV, LHC11c+d"
71  , "MC default, GJ+JJ_{p^{EMCal}_{T,#gamma} > 3.5 GeV/#it{c}}"
72  , "MC xTalk, GJ+JJ_{p^{EMCal}_{T,#gamma} > 3.5 GeV/#it{c}}"
73 } ;
75 
77 // // High JJ
78 // Double_t binE [] = { 18,20, 25, 30, 35,40,50};
79 //
80 // TString titleName = "LHC11cd_EMC7_MCGJ-JJHigh";
81 // TString filePath[] =
82 // {
83 // "data/module/TCardChannel3/LHC11cd_EMC7"
84 // , "simu/module/pp_7TeV_JJ_Dec_High_GJ/TCardChannel_Mimic0_Scaled2_v3/ScaledMerged"
85 // , "simu/module/pp_7TeV_JJ_Dec_High_GJ/TCardChannel_Mimic10c_EcellCut_Scaled2_v3/ScaledMerged"
86 // } ;
87 //
88 // TString dataType[] =
89 // {
90 // "Data, pp@ 7 TeV, LHC11c+d"
91 // , "MC default, GJ+JJ_{p^{EMCal}_{T,#gamma} > 7 GeV/#it{c}}"
92 // , "MC xTalk, GJ+JJ_{p^{EMCal}_{T,#gamma} > 7 GeV/#it{c}}"
93 // } ;
95 //----------------------------------------------------------------------------
96 
97 
108 void DoIt ( Int_t iana = 0,
109  Bool_t cut = kFALSE,
110  Int_t firstSM = 0,
111  Int_t lastSM = 9,
112  Bool_t plotRat = kFALSE,
113  Bool_t bAllSM = kFALSE,
114  Bool_t debug = kFALSE
115  )
116 {
117  Double_t lowE[nEBins];
118  Double_t higE[nEBins];
119 
120  // SM
121  const Int_t nSM = lastSM-firstSM+2; // Last entry will be sum of all.
122 
123  if ( debug )
124  printf("Execute ana %d, cut %d, allSM %d, first SM %d, last SM %d, total SM+1 %d\n",
125  iana,cut,bAllSM,firstSM,lastSM, nSM);
126 
127  // histograms
128  //printf("N SM = %d\n",nSM);
129  TH2F* h2[nProd][nSM];
130  TH1D* h [nProd][nEBins][nSM];
131  TH1D* hA[nProd][nEBins];
132 
133  // Merge good/bad SMs
134  TH1D* hGroup[nProd][nEBins][3];
135 
136  Int_t rebin = 2;
137  Double_t xmin = 0.1;
138  Double_t xmax = 1.1;
139 
140  TString isoName [] = {"NoIso","Iso","Photon"};
141  TString isoTitle[] = {"NOT Isolated" ,"Isolated","Inclusive"};
142 
143  TString cutName [] = {"","_NCellCut"};
144  TString cutTitle[] = {"no #it{n}^{w} cut" ,"#it{n}^{w} > 4"};
145 
146 // for(Int_t iprod = 0; iprod < nProd; iprod++)
147 // {
148 // for(Int_t ism = 0; ism < nSM; ism++)
149 // {
150 // h2[iprod][ism] = 0;
151 // }
152 // }
153 
154  for(Int_t iprod = 0; iprod < nProd; iprod++)
155  {
156  if ( !file[iprod] ) continue;
157 
158  for(Int_t ism = 0; ism < nSM-1; ism++)
159  {
160  h2[iprod][ism] = 0;
161 
162  if ( iana == 2 && cut == 1 )
163  continue;
164 
165  if(iana < 2)
166  {
167  h2[iprod][ism] =
168  (TH2F*) file[iprod]->Get(Form("AnaIsolPhoton_hPtLambda0%s_SM%d_%s",
169  cutName[cut].Data(),ism+firstSM,isoName[iana].Data()));
170  }
171  else
172  {
173  h2[iprod][ism] =
174  (TH2F*) file[iprod]->Get(Form("AnaPhoton_hLam0_SM%d",ism+firstSM));
175  }
176 
177  if ( !h2[iprod][ism] )
178  {
179  printf("Histogram for ana %d, cut %d, sm %d not found\n",iana,cut,ism);
180  continue;
181  }
182 
183 // if ( debug )
184 // {
185 // printf("iana %d, sm %d, prod %d, %p\n",iana, ism, iprod, h2[iprod][ism]);
186 // printf("\t %s Entries %e Integral %e\n",
187 // h2[iprod][ism]->GetName(),h2[iprod][ism]->GetEntries(),h2[iprod][ism]->Integral());
188 // }
189 
190  // Merge all SM
191  if ( ism == 0 )
192  {
193  h2[iprod][nSM-1] = (TH2F*) h2[iprod][ism]->Clone(Form("AllSM_Prod%d_Ana%d_Cut%d",iprod,iana,cut));
194  //printf(" Clone ism %d %p\n",ism, h2[iprod][nSM]);
195  }
196  else
197  {
198  h2[iprod][nSM-1] -> Add (h2[iprod][ism]);
199  //printf(" Add ism %d to %p\n",ism, h2[iprod][nSM]);
200  }
201  } // ism
202 
203  // Get the histo for all SM from file
204  // or merge all SM, done before
205  if ( bAllSM && cut == 0 )
206  {
207  if ( debug )
208  printf("Recover histograms for ALL SM!!!!\n");
209 
210  if(iana < 2)
211  h2[iprod][nSM-1] =
212  (TH2F*) file[iprod]->Get(Form("AnaIsolPhoton_hPtLambda0%s",
213  isoName[iana].Data())); // hELambda0
214  else
215  h2[iprod][nSM-1] = (TH2F*) file[iprod]->Get("AnaPhoton_hLam0Pt"); // ("AnaPhoton_hLam0E");
216 
217  if ( !h2[iprod][nSM-1] )
218  {
219  printf("Histogram for ana %d, cut %d, All SM not found\n",iana,cut);
220  }
221 
222  } // Recover histo all SM from file
223 
224  } // prod loop
225 
226  // Apply Sumw2
227  //
228  for(Int_t iprod = 0; iprod < nProd; iprod++)
229  {
230  for(Int_t ism = 0; ism < nSM; ism++)
231  {
232  if ( !h2[iprod][ism] )
233  {
234  printf("Sumw2: Histogram for ana %d, cut %d, sm %d not found\n",iana,cut,ism);
235  continue;
236  }
237 
238  if ( filePath[iprod].Contains("data") ||
239  (filePath[iprod].Contains("simu") && filePath[iprod].Contains("MB")))
240  h2[iprod][ism]->Sumw2();
241  }
242  }
243 
244  //
245  // Project
246  //
247 
248  Double_t width = 0;
249  for(Int_t ism = 0; ism < nSM; ism++)
250  {
251  for(Int_t iprod = 0; iprod < nProd; iprod++)
252  {
253  for(Int_t iebin = 0; iebin < nEBins; iebin++)
254  {
255  if ( !h2[iprod][ism] )
256  {
257  printf("Projection Histogram for iprod %d, ana %d, cut %d, sm %d not found\n",
258  iprod, iana, cut, ism);
259  continue;
260  }
261 
262  Int_t ebinMin = h2[iprod][ism]->GetXaxis()->FindBin(binE[iebin ]);
263  Int_t ebinMax = h2[iprod][ism]->GetXaxis()->FindBin(binE[iebin+1])-1;
264  //if(ebinMin==ebinMax) ebinMax = 1000;
265  lowE[iebin] = h2[iprod][ism]->GetXaxis()->GetBinLowEdge(ebinMin);
266  width = h2[iprod][ism]->GetXaxis()->GetBinWidth (ebinMax);
267  higE[iebin] = h2[iprod][ism]->GetXaxis()->GetBinLowEdge(ebinMax)+width;
268 
269  h[iprod][iebin][ism] =
270  (TH1D*) h2[iprod][ism]->ProjectionY(Form("Histo%d_BinE%d_SM%d",iprod,iebin,ism),ebinMin,ebinMax);
271 
272 // if ( debug )
273 // {
274 // printf("project ism %d, iprod %d, ie %d [%2.1f,%2.1f] GeV\n",
275 // ism, iprod, iebin,lowE[iebin],higE[iebin]);
276 // printf("\t %p \n",h[iprod][iebin][ism]);
277 // }
278 
279  if ( !h[iprod][iebin][ism] ) continue;
280 
281  h[iprod][iebin][ism]->SetLineColor(color[iprod]);
282 
283  h[iprod][iebin][ism]->SetLineWidth(2);
284 
285  h[iprod][iebin][ism]->SetLineStyle(lineStyle[iprod]);
286 
287  h[iprod][iebin][ism]->SetMarkerStyle(marker[iprod]);
288 
289  h[iprod][iebin][ism]->SetMarkerColor(color[iprod]);
290 
291  h[iprod][iebin][ism]->SetMarkerSize(0.5);
292 
293  h[iprod][iebin][ism]->SetXTitle("#sigma_{long}^{2}");
294 
295  if(rebin > 1)
296  h[iprod][iebin][ism]->Rebin(rebin);
297 
298  h[iprod][iebin][ism]->SetAxisRange(xmin,xmax,"X");
299 
300  // Normalize to integral above 0.6 (n cell cut)
301  if ( cut )
302  {
303  Double_t integral = h[iprod][iebin][ism]->Integral(h[iprod][iebin][ism]->FindBin(0.6),
304  h[iprod][iebin][ism]->FindBin(2));
305  if(integral > 1e-9)
306  {
307  h[iprod][iebin][ism]->Scale(1./integral);
308  h[iprod][iebin][ism]->SetYTitle("Norm. integral 0.6<#lambda^{2}_{0}<2 ");
309  }
310  else
311  h[iprod][iebin][ism] = 0;
312  }
313  // Normalize to max at 0.25
314  else
315  {
316  Double_t scale = h[iprod][iebin][ism]->GetBinContent(h[iprod][iebin][ism]->FindBin(0.245));
317  if(scale > 1e-9)
318  {
319  h[iprod][iebin][ism]->Scale(1./scale);
320  h[iprod][iebin][ism]->SetYTitle("Norm. to max at 0.25");
321  }
322  else h[iprod][iebin][ism] = 0;
323  }
324  } // ie
325  } // iprod
326  } // ism
327 
328 
329  //
330  // Merge SM Groups
331  //
332  for(Int_t iprod = 0; iprod < nProd; iprod++)
333  {
334  for(Int_t iebin = 0; iebin < nEBins; iebin++)
335  {
336  if ( h[iprod][iebin][0] )
337  {
338  hGroup[iprod][iebin][0] = (TH1D*) h[iprod][iebin][0]->Clone(Form("SMGroup0_Prod%d_Ana%d_Cut%d",
339  iprod,iana,cut));
340 
341  hGroup[iprod][iebin][0]->Add( h[iprod][iebin][4] );
342  hGroup[iprod][iebin][0]->Add( h[iprod][iebin][5] );
343  hGroup[iprod][iebin][0]->Add( h[iprod][iebin][6] );
344  hGroup[iprod][iebin][0]->Add( h[iprod][iebin][8] );
345  hGroup[iprod][iebin][0]->Add( h[iprod][iebin][9] );
346 
347  hGroup[iprod][iebin][0]->Scale(1./6.);
348  }
349  else
350  {
351  hGroup[iprod][iebin][0] = 0;
352  }
353 
354  if(h[iprod][iebin][1])
355  {
356  hGroup[iprod][iebin][1] = (TH1D*) h[iprod][iebin][1]->Clone(Form("SMGroup1_Prod%d_Ana%d_Cut%d",
357  iprod,iana,cut));
358 
359  hGroup[iprod][iebin][1]->Add( h[iprod][iebin][1] );
360 
361  hGroup[iprod][iebin][1]->Scale(1./2.);
362  }
363  else
364  {
365  hGroup[iprod][iebin][1] = 0;
366  }
367 
368  if(h[iprod][iebin][3])
369  {
370  hGroup[iprod][iebin][2] = (TH1D*) h[iprod][iebin][3]->Clone(Form("SMGroup2_Prod%d_Ana%d_Cut%d",
371  iprod,iana,cut));
372 
373  hGroup[iprod][iebin][2]->Add( h[iprod][iebin][7] );
374 
375  hGroup[iprod][iebin][2]->Scale(1./2.);
376  }
377  else
378  {
379  hGroup[iprod][iebin][2] = 0;
380  }
381  } // ebins
382  } // prod bins
383 
384 
385  //
386  // Plots
387  //
388 
389  if ( debug )
390  printf("PLOT\n");
391 
392  TString fileName ;
393 
394  gStyle->SetPadRightMargin(0.01);
395  gStyle->SetPadLeftMargin(0.12);
396  gStyle->SetTitleFontSize(0.06);
397  // gStyle->SetStatFontSize(0.06);
398  gStyle->SetOptStat(0);
399 
400  // Plot in file different frames per E bin.
401  //
402  Int_t ncolE = 4;
403  Int_t nrowE = 3;
404  GetCanvasColRowNumber(nEBins,ncolE,nrowE); // PlotUtils.C
405 
406  TCanvas * cA = new TCanvas(Form("cAllSM_iana%d_cut%d",iana,cut),
407  Form("All SM, iana %d, cut %d",iana,cut),
408  ncolE*2000,nrowE*2000);
409 
410  cA->Divide(ncolE,nrowE);
411 
412  TLegend *l = 0;
413  if(ncolE*nrowE!=nSM)
414  {
415  l= new TLegend(-0.04,0.,1,1);
416  l->SetTextSize(0.06);
417  }
418  else
419  {
420  l= new TLegend(0.5,0.6,0.9,0.9);
421  l->SetTextSize(0.035);
422  }
423  l->SetFillColor(0);
424  l->SetFillStyle(0);
425  l->SetLineColor(0);
426  l->SetBorderSize(0);
427  l->AddEntry("",Form(isoTitle[iana].Data(), cutTitle[cut].Data()),"");
428 
429  for(Int_t iebin = 0; iebin < nEBins; iebin++)
430  {
431  cA->cd(iebin+1);
432 
433  //printf("ebin %d %p\n",iebin,h[0][iebin][nSM-1]);
434  if(!h[0][iebin][nSM-1]) continue;
435 
436  //gPad->SetLogy();
437 
438  gStyle->SetOptTitle(1);
439  gStyle->SetPadTopMargin(0.08);
440 
441  h[0][iebin][nSM-1]->Draw("H");
442 
443  for(Int_t iprod = 0; iprod < nProd; iprod++)
444  {
445  //printf("iprod %d %p\n",iprod,h[iprod][iebin][nSM-1]);
446  if(!h[iprod][iebin][nSM-1]) continue;
447 
448  h[iprod][iebin][nSM-1]->SetTitleOffset(1.8,"Y");
449 
450  //printf("\t low %f high %f\n",lowE[iebin],higE[iebin]);
451  h[iprod][iebin][nSM-1]->SetTitle(Form("%2.1f < #it{E}_{T}^{clus} < %2.1f GeV",lowE[iebin],higE[iebin]));
452 
453  h[iprod][iebin][nSM-1]->Draw("H same");
454 
455  if(h[iprod][iebin][nSM-1]->GetMaximum() > h[0][iebin][nSM-1]->GetMaximum())
456  h[0][iebin][nSM-1]->SetMaximum(h[iprod][iebin][nSM-1]->GetMaximum()*1.2);
457 
458  if(iebin==0)
459  l->AddEntry(h[iprod][iebin][nSM-1],Form("%s",dataType[iprod].Data()),"PL");
460  }
461  }
462 
463  cA->cd(ncolE*nrowE);
464  l->Draw("same");
465 
466  fileName = Form("figures/Comparison_M02_AllSM_%s%s_%s",
467  isoName[iana].Data(),cutName[cut].Data(),titleName.Data());
468  fileName+=fileFormat;
469  cA->Print(fileName);
470 
471  if ( plotRat )
472  {
473  TCanvas * cAR = new TCanvas(Form("cR_AllSM_iana%d_cut%d",iana, cut),
474  Form("All SM, iana %d, cut %d",iana, cut),
475  ncolE*2000,nrowE*2000);
476 
477  cAR->Divide(ncolE,nrowE);
478 
479  for(Int_t iebin = 0; iebin < nEBins; iebin++)
480  {
481  cAR->cd(iebin+1);
482 
483  if(!h[0][iebin][nSM-1]) continue;
484 
485  //if(quantity.Contains("ECell"))gPad->SetLogy();
486 
487  gStyle->SetOptTitle(1);
488  gStyle->SetPadTopMargin(0.08);
489 
490  h[0][iebin][nSM-1]->Draw("H");
491 
492  for(Int_t iprod = 1; iprod < nProd; iprod++)
493  {
494  if(!h[iprod][iebin][nSM-1]) continue;
495 
496  TH1F* hRat = (TH1F*) h[iprod][iebin][nSM-1]->Clone(Form("%s_Ratio",h[iprod][iebin][nSM-1]->GetName()));
497  hRat->Divide(h[0][iebin][nSM-1]);
498 
499  if(iprod==1) hRat->Draw("H");
500  else hRat->Draw("H same");
501 
502  hRat->SetYTitle("Ratio MC to Data");
503  hRat->SetMaximum(1.2);
504  hRat->SetMinimum(0);
505  }
506  }
507 
508  cAR->cd(ncolE*nrowE);
509  l->Draw("same");
510 
511  fileName = Form("figures/Comparison_Ratio_M02_AllSM_%s%s_%s",
512  isoName[iana].Data(),cutName[cut].Data(),titleName.Data());
513  fileName+=fileFormat;
514  cAR->Print(fileName);
515  }
516 
517  if ( bAllSM ) return;
518 
519  // One file per E bin
520  // Each file all SM and the sum
521  //
522 
523  Int_t ncolSM = 4;
524  Int_t nrowSM = 3;
525  GetCanvasColRowNumber(nSM,ncolSM,nrowSM); // PlotUtils.C
526 
527  for(Int_t iebin = 0; iebin < nEBins; iebin++)
528  {
529  gStyle->SetOptTitle(1);
530  gStyle->SetPadTopMargin(0.07);
531 
532  TCanvas * c = new TCanvas(Form("c_ebin%d_iso%d_cut%d",
533  iebin,iana,cut),
534  Form("iana %d, cut %d, %2.1f < E < %2.1f",
535  iana, cut,lowE[iebin],higE[iebin]),
536  ncolSM*2000,nrowSM*2000);
537  c->Divide(ncolSM,nrowSM);
538 
539  TLegend *lSM = 0;
540  if(ncolSM*ncolSM!=nSM)
541  {
542  lSM= new TLegend(-0.04,0,1,1);
543  lSM->SetTextSize(0.06);
544  }
545  else
546  {
547  lSM= new TLegend(0.5,0.6,0.9,0.9);
548  lSM->SetTextSize(0.035);
549  }
550 
551  lSM->SetFillColor(0);
552  lSM->SetFillStyle(0);
553  lSM->SetLineColor(0);
554  lSM->SetBorderSize(0);
555  lSM->SetHeader(Form(" %2.1f < #it{E} < %2.1f GeV", lowE[iebin],higE[iebin]));
556  lSM->AddEntry("",Form(isoTitle[iana].Data(), cutTitle[cut].Data()),"");
557  for(Int_t ism = 0; ism < nSM; ism++)
558  {
559  c->cd(ism+1);
560 
561  //gPad->SetLogy();
562 
563  //printf("iE %d ism %d\n",iebin,ism);
564  if(!h[0][iebin][ism]) continue;
565 
566  for(Int_t iprod = 0; iprod < nProd; iprod++)
567  {
568  //printf("\t prod %d %p\n",iprod,h[iprod][iebin][ism]);
569  if(!h[iprod][iebin][ism]) continue;
570 
571  h[iprod][iebin][ism]->SetTitle(Form("SM %d",ism));
572 
573  h[iprod][iebin][ism]->SetTitleOffset(1.8,"Y");
574  //h[iebin][0]->SetLineColor(1);
575  //h[iebin][0]->SetAxisRange(0.1,2.5,"X");
576 
577  if ( iprod == 0 ) h[iprod][iebin][ism]->Draw("H");
578  else h[iprod][iebin][ism]->Draw("H same");
579 
580  if(h[iprod][iebin][ism]->GetMaximum() > h[0][iebin][ism]->GetMaximum())
581  h[0][iebin][ism]->SetMaximum(h[iprod][iebin][ism]->GetMaximum()*1.2);
582 
583  if(ism==0)
584  lSM->AddEntry(h[iprod][iebin][ism],Form("%s",dataType[iprod].Data()),"PL");
585  } // iprod
586 
587  //printf("\t end\n");
588  } // param
589 
590  c->cd(ncolSM*nrowSM);
591  lSM->Draw();
592 
593  fileName = Form("figures/Comparison_M02_Ebin%d_%s%s_%s",
594  iebin,isoName[iana].Data(),cutName[cut].Data(),titleName.Data());
595  fileName+=fileFormat;
596  c->Print(fileName);
597 
598  if ( !plotRat ) continue;
599 
600  TCanvas * cR = new TCanvas(Form("cR_ebin%d_iana%d_cut%d",
601  iebin,iana,cut),
602  Form("Ratio iana %d, %2.1f < E < %2.1f",
603  iana, lowE[iebin],higE[iebin]),
604  ncolSM*2000,nrowSM*2000);
605  cR->Divide(ncolSM,nrowSM);
606 
607  for(Int_t ism = 0; ism < nSM; ism++)
608  {
609  cR->cd(ism+1);
610 
611  //gPad->SetLogy();
612 
613  //printf("iE %d ism %d\n",iebin,ism);
614  if(!h[1][iebin][ism]) continue;
615 
616  for(Int_t iprod = 1; iprod < nProd; iprod++)
617  {
618  //printf("\t prod %d %p\n",iprod,h[iprod][iebin][ism]);
619  if(!h[iprod][iebin][ism]) continue;
620 
621  TH1F* hRat = (TH1F*) h[iprod][iebin][ism]->Clone(Form("%s_Ratio",h[iprod][iebin][ism]->GetName()));
622  hRat->Divide(h[0][iebin][ism]);
623 
624  if(iprod==0) hRat->Draw("H");
625  else hRat->Draw("H same");
626 
627  hRat->SetYTitle("Ratio MC to Data");
628  hRat->SetMaximum(1.2);
629  hRat->SetMinimum(0);
630 
631  } // iprod
632 
633  } // param
634 
635  cR->cd(ncolSM*nrowSM);
636  lSM->Draw();
637 
638  fileName = Form("figures/Comparison_Ratio_M02_Ebin%d_%s%s_%s",
639  iebin,isoName[iana].Data(),cutName[cut].Data(),titleName.Data());
640 
641  fileName+=fileFormat;
642 
643  cR->Print(fileName);
644 
645  } // e bin
646 
647  // Each file is per SM
648  // each pad has an E bin
649  // last SM is the sum of all, already plotted before.
650  for(Int_t ism = 0; ism < nSM-1; ism++)
651  {
652  gStyle->SetOptTitle(1);
653  gStyle->SetPadTopMargin(0.07);
654 
655  TCanvas * c = new TCanvas(Form("c_sm%d_iana%d_cut%d",
656  ism,iana,cut),
657  Form("iana %d, cut %d, SM %d",
658  iana, cut, ism),
659  ncolE*2000,ncolE*2000);
660  c->Divide(ncolE,nrowE);
661 //
662 // TLegend *l = new TLegend(-0.04,0,1,1);
663 // l->SetFillColor(0);
664 // l->SetFillStyle(0);
665 // l->SetLineColor(0);
666 // l->SetBorderSize(0);
667 // l->SetTextSize(0.06);
668 // l->SetHeader(Form(" SM %d", ism));
669 // l->AddEntry("",Form(isoTitle[iana].Data(), cutTitle[cut].Data()),"");
670 // //if(higE[iebin] > 90) l->SetHeader(Form("#it{E} > %2.1f GeV",lowE[iebin]));
671  for(Int_t iebin = 0; iebin < nEBins; iebin++)
672  {
673  c->cd(iebin+1);
674 
675  //gPad->SetLogy();
676 
677  //printf("iE %d ism %d\n",iebin,ism);
678  if(!h[0][iebin][ism]) continue;
679 
680  for(Int_t iprod = 0; iprod < nProd; iprod++)
681  {
682  //printf("\t prod %d %p\n",iprod,h[iprod][iebin][ism]);
683  if(!h[iprod][iebin][ism]) continue;
684 
685  h[iprod][iebin][ism]->SetTitle(Form("%2.1f < #it{E}^{clus} < %2.1f GeV",lowE[iebin],higE[iebin]));
686 
687  h[iprod][iebin][ism]->SetTitleOffset(1.8,"Y");
688  //h[iebin][0]->SetLineColor(1);
689  //h[iebin][0]->SetAxisRange(0.1,2.5,"X");
690 
691  if ( iprod == 0 ) h[iprod][iebin][ism]->Draw("H");
692  else h[iprod][iebin][ism]->Draw("H same");
693 
694  if(h[iprod][iebin][ism]->GetMaximum() > h[0][iebin][ism]->GetMaximum())
695  h[0][iebin][ism]->SetMaximum(h[iprod][iebin][ism]->GetMaximum()*1.2);
696  } // iprod
697 
698  //printf("\t end\n");
699  } // param
700 
701  c->cd(ncolE*nrowE);
702  l->Draw();
703 
704  fileName = Form("figures/Comparison_M02_SM%d_%s%s_%s",
705  ism,isoName[iana].Data(),cutName[cut].Data(),titleName.Data());
706  fileName+=fileFormat;
707  c->Print(fileName);
708  } // sm bin
709 
710 }
711 
722 (Int_t firstSM = 0,
723  Int_t lastSM = 9,
724  Bool_t plotRat = kFALSE,
725  Bool_t bAllSM = kFALSE,
726  Bool_t debug = kFALSE )
727 {
728  for(Int_t iprod = 0; iprod < nProd; iprod++)
729  {
730  file[iprod] = TFile::Open(Form("%s.root",filePath[iprod].Data()));
731  if ( debug )
732  printf("Read: %s.root, %p\n",filePath[iprod].Data(),file);
733  }
734 
735  // Execute the analysis
736  //
737  DoIt(0, 0, firstSM, lastSM, plotRat, bAllSM, debug); // Not iso
738 // DoIt(1, 0, firstSM, lastSM, plotRat, bAllSM, debug); // Iso
739 // DoIt(2, 0, firstSM, lastSM, plotRat, bAllSM, debug); // Inclusive: AliAnaPhoton
740 //
741 // // With cut on Ncells
742 // DoIt(0, 1, firstSM, lastSM, plotRat, bAllSM, debug); // Not iso
743 // DoIt(1, 1, firstSM, lastSM, plotRat, bAllSM, debug); // Iso
744 }
745 
double Double_t
Definition: External.C:58
const Int_t nProd
Definition: External.C:236
TString fileName
int lastSM
TCanvas * c
Definition: TestFitELoss.C:172
Plotting utilities.
TFile * file[nProd]
void CompareShowerShapeLongPerAnaPerSM(Int_t firstSM=0, Int_t lastSM=9, Bool_t plotRat=kFALSE, Bool_t bAllSM=kFALSE, Bool_t debug=kFALSE)
int Int_t
Definition: External.C:63
Definition: External.C:212
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
Int_t rebin
void GetCanvasColRowNumber(Int_t npad, Int_t &ncol, Int_t &nrow, Bool_t square=kFALSE)
Definition: PlotUtils.C:304
bool Bool_t
Definition: External.C:53
void DoIt(Int_t iana=0, Bool_t cut=kFALSE, Int_t firstSM=0, Int_t lastSM=9, Bool_t plotRat=kFALSE, Bool_t bAllSM=kFALSE, Bool_t debug=kFALSE)
const Int_t nEBins