AliPhysics  2c6b7ad (2c6b7ad)
CompareTH3DataAndMCProd.C
Go to the documentation of this file.
1 
17 #if !defined(__CINT__) || defined(__MAKECINT__)
18 
19 #include <TFile.h>
20 #include <TDirectoryFile.h>
21 #include <TList.h>
22 #include <TString.h>
23 #include <TROOT.h>
24 #include <TStyle.h>
25 #include <TH1D.h>
26 #include <TH2F.h>
27 #include <TH3F.h>
28 #include <TCanvas.h>
29 #include <TPad.h>
30 #include <TLegend.h>
31 #include <TObject.h>
32 #include <TAxis.h>
33 #include <TGaxis.h>
34 #include <TLine.h>
35 #include <TF1.h>
36 #include <TMath.h>
37 #include <TArrayD.h>
38 #include <TGraphErrors.h>
39 #include "PlotUtils.C"
40 #endif
41 
43 (TString histoName,
44  Float_t & xmin , Float_t & xmax,
45  Float_t & xNormMin, Float_t & xNormMax,
46  Bool_t & normtomax, Int_t & rebin );
47 
49 ( TH1D* histo, TString histoName, Int_t iprod,
50  Int_t rebin, Float_t xmin, Float_t xmax,
51  Bool_t normtomax, Float_t xNormMin, Float_t xNormMax,
52  Float_t lowEBin, Float_t highEBin, Bool_t debug );
53 
54 
55 //------------------------------------------------------------------------------
79 //------------------------------------------------------------------------------
81 (
82  TString & outputFileName,
83  TString histoName = "SMM02NoCut",
84 
85  const Int_t nProd = 3,
86  TString * prod = 0x0,
87  TString * prodLeg = 0x0,
88 
89  TString clusterization = "",//"_V1_Ecell100_Eseed500",
90  TString tm = "_TMDep",//"TMFix",
91  TString pid = "_Neutral",//"_Electron", "_Hadron","Neutral"
92 
93  TString titleMC = "JJDecLow", // "JJDecHigh", "MB", "JJDecLow"
94  TString mcLeg = "MC: #gammaJ+JJ({p^{EMCal}_{T,#gamma}>3.5 GeV/#it{c})",
95  TString titleData = "LHC11cd_EMC7",
96  TString daLeg = "pp@7 TeV, LHC11c+d EMC7",
97 
98  Int_t firstP = 0,
99  Int_t lastP = 9,
100  TArrayD binE = 0,
101  Int_t firstMC = 1,
102 
103  Bool_t plotRatio = kFALSE,
104  Bool_t saveHisto = kFALSE,
105  TString opt = "",
106  Bool_t debug = kFALSE
107 )
108 {
109  TString fileFormat = ".eps";
110 
111  if(histoName.Contains("CellModule")) pid = "";
112  if(histoName.Contains("SMEMaxEClusterRat")) pid = "";
113  if(histoName.Contains("TCardChannel")) pid = "";
114 
115  Float_t xmin = -1;
116  Float_t xmax = 10000;
117  Float_t xNormMin = -1;
118  Float_t xNormMax = 10000;
119  Int_t rebin = 1;
120  Bool_t normtomax = kFALSE;
121  DefineHistogramSettings(histoName, xmin, xmax, xNormMin, xNormMax, normtomax, rebin);
122 
123  if ( debug ) printf("Histo: %s, range [%2.2f,%2.2f], Norm %d, range [%2.2f, %2.2f], rebin %d, param range [%d,%d]\n",
124  histoName.Data(), xmin,xmax, normtomax, xNormMin,xNormMax,rebin, firstP,lastP);
125 
126  // Energy bins and productions
127  //
128  const Int_t nEBins = binE.GetSize()-1;
129  Int_t ncolE = 5;
130  Int_t nrowE = 5;
131  GetCanvasColRowNumber(nEBins,ncolE,nrowE); // PlotUtils.C
132 
133  Double_t lowE[nEBins];
134  Double_t higE[nEBins];
135 
136  // SM or TC bins
137  //
138  const Int_t nparam = lastP-firstP+1;
139  Int_t ncolPar = 5;
140  Int_t nrowPar = 5;
141  GetCanvasColRowNumber(nparam,ncolPar,nrowPar); // PlotUtils.C
142 
143  // Merge good/bad SMs or TC
144  //
145  const Int_t nGroup = 4;
146  Int_t ngroupmax = 3;
147  if(histoName.Contains("TCardChannel"))
148  ngroupmax = 4;
149  // printf("N GROUP MAX %d\n",ngroupmax);
150 
151  TString groupSM[] = {"0,4,5,6,8,9","1,2","3,7"};
152  TString groupTC[] = {"Border","Border+1","Center+1","Center"};
153 
154 
155  // Histogram/file arrays
156  //
157  TH3F * h3 [nProd];
158  TH1D * h [nProd][nEBins][nparam];
159  TH1D * hA [nProd][nEBins];
160  TH1D * hGroup[nProd][nEBins][nGroup];
161 
162  TFile * file[nProd];
163 
164  //
165  //Open the histogram files and get the TH3 histogram
166  //
167  // Data
168  //
169  for(Int_t iprod = 0; iprod < firstMC; iprod++)
170  {
171  file[iprod] = TFile::Open(Form("%s%s.root",prod[iprod].Data(),clusterization.Data()));
172  if ( debug ) printf("Read: %s%s.root, %p\n",prod[iprod].Data(),clusterization.Data(),file[iprod]);
173 
174  if(!file[iprod])
175  {
176  printf("Missing file %d\n",iprod);
177  continue;
178  }
179 
180  h3[iprod] = (TH3F*) file[iprod]->Get(Form("Shape%s_h%s%s" ,tm.Data(),histoName.Data(),pid.Data()));
181  if ( debug ) printf("Data, Shape%s_h%s%s %p\n",tm.Data(),histoName.Data(),pid.Data(),h3[iprod]);
182  if ( !h3[iprod] ) return;
183 
184  h3[iprod]->Sumw2();
185 
186  //prod[iprod].ReplaceAll("/","_");
187 
188  if ( debug ) printf("Entries %e Integral %e\n",h3[iprod]->GetEntries(),h3[iprod]->Integral());
189  }
190 
191  // Simu
192  //
193  for(Int_t iprod = firstMC; iprod < nProd; iprod++)
194  {
195  if ( !prod[iprod].Contains("root") )
196  file[iprod] = TFile::Open(Form("%s/ScaledMerged%s.root",prod[iprod].Data(),clusterization.Data()));
197  else
198  file[iprod] = TFile::Open(Form("%s",prod[iprod].Data()));
199 
200  if ( debug ) printf("Simu %d file %s, Shape_%s_h%s%s, %p\n",
201  iprod, prod[iprod].Data(), tm.Data(),histoName.Data(),pid.Data(), file[iprod]);
202 
203  if(!file[iprod])
204  {
205  h3[iprod] = 0;
206  continue;
207  }
208 
209  h3[iprod] = (TH3F*) file[iprod]->Get(Form("Shape%s_h%s%s" ,tm.Data(),histoName.Data(), pid.Data()));
210  if ( debug ) printf("\t histo %p\n",h3[iprod]);
211 
212  if ( !h3[iprod] ) return;
213 
214  if ( debug ) printf("Entries %e Integral %e\n",h3[iprod]->GetEntries(),h3[iprod]->Integral());
215 
216 // prod[iprod].ReplaceAll("/","_");
217 // prod[iprod].ReplaceAll("_sum","");
218  }
219 
220  //
221  // Project
222  //
223  if ( debug ) printf("Project per E bin, SM/TC bin\n");
224 
225  Double_t width = 0;
226  for(Int_t iprod = 0; iprod < nProd; iprod++)
227  {
228  if ( !file[iprod] )
229  continue;
230 
231  if ( debug ) printf("iprod %d\n",iprod);
232 
233  for(Int_t iebin = 0; iebin < nEBins; iebin++)
234  {
235  if ( debug ) printf("\t ebin %d\n",iebin);
236  h3[iprod]->SetAxisRange(-1000,1000,"Y");
237 
238  Int_t ebinMin = h3[iprod]->GetXaxis()->FindBin(binE[iebin ]);
239  Int_t ebinMax = h3[iprod]->GetXaxis()->FindBin(binE[iebin+1])-1;
240  //if(ebinMin==ebinMax) ebinMax = 1000;
241  lowE[iebin] = h3[iprod]->GetXaxis()->GetBinLowEdge(ebinMin);
242  width = h3[iprod]->GetXaxis()->GetBinWidth (ebinMax);
243  higE[iebin] = h3[iprod]->GetXaxis()->GetBinLowEdge(ebinMax)+width;
244  //if(lowE[iebin] == higE[iebin]) higE[iebin] = 100;
245  if ( debug && iprod==0 )
246  {
247  printf("\t iE %d, ebinMin %d, emin %2.1f, low edge %2.1f, ebinMax %d, emax %2.1f, high edge %2.1f, width %2.2f\n",
248  iebin, ebinMin, binE[iebin], lowE[iebin], ebinMax, binE[iebin+1], higE[iebin], width);
249  }
250 
251  for(Int_t ipbin = firstP; ipbin <= lastP; ipbin++)
252  {
253  Int_t pbinMax = h3[iprod]->GetYaxis()->FindBin(ipbin);
254  Int_t pbinMin = h3[iprod]->GetYaxis()->FindBin(ipbin);
255 
256  if ( debug ) printf("\t \t ipbin %d - first %d = %d, last %d, total %d\n",ipbin,firstP,ipbin-firstP, lastP, nparam);
257 
258  h[iprod][iebin][ipbin-firstP] =
259  (TH1D*) h3[iprod]->ProjectionZ(Form("%sProd%d_BinE%d_BinP%d",histoName.Data(),iprod,iebin,ipbin),ebinMin,ebinMax, pbinMin,pbinMax);
260 
262  (h[iprod][iebin][ipbin-firstP],histoName, iprod,
263  rebin, xmin,xmax,
264  normtomax, xNormMin, xNormMax, lowE[iebin], higE[iebin],debug);
265 
266  if ( !ok )
267  continue;
268  }
269 
270  //
271  // All param
272  //
273  if ( debug ) printf("\t \t Merge all SM\n");
274  {
275  hA[iprod][iebin] =
276  (TH1D*) h3[iprod]->ProjectionZ(Form("%sProd%d_BinE%d_All",histoName.Data(),iprod,iebin),ebinMin,ebinMax, -1,10000);
277 
279  (hA[iprod][iebin],histoName, iprod,
280  rebin, xmin,xmax,
281  normtomax, xNormMin, xNormMax, lowE[iebin],higE[iebin],debug);
282 
283  if ( !ok )
284  printf("Histogram with sum of all not available\n");
285  }
286 
287  if ( debug ) printf("\t \t Merge groups\n");
288 
289  //
290  // Merged SM
291  //
292  Float_t colorGroup[] = {kBlue,kViolet,kRed,kBlack,6,8,3,5};
293 
294  if ( histoName.Contains("SM") )
295  {
296 // printf("\t \t ie %d, iprod %d\n",iebin,iprod);
297 // printf("\t \t 0-%p, 1-%p, 2-%p, 3-%p, 4-%p\n",h[iprod][iebin][0],h[iprod][iebin][1], h[iprod][iebin][2], h[iprod][iebin][3], h[iprod][iebin][4]);
298 // printf("\t \t 5-%p, 6-%p, 7-%p, 8-%p, 9-%p\n",h[iprod][iebin][5],h[iprod][iebin][6], h[iprod][iebin][7], h[iprod][iebin][8], h[iprod][iebin][9]);
299 
300  hGroup[iprod][iebin][0] = 0;
301  hGroup[iprod][iebin][1] = 0;
302  hGroup[iprod][iebin][2] = 0;
303 
304  if ( h[iprod][iebin][0] ) hGroup[iprod][iebin][0] = (TH1D*) h[iprod][iebin][0]->Clone(Form("SM_Group0_Ebin%d_Prod%d",iebin,iprod));
305  if ( h[iprod][iebin][1] ) hGroup[iprod][iebin][1] = (TH1D*) h[iprod][iebin][1]->Clone(Form("SM_Group1_Ebin%d_Prod%d",iebin,iprod));
306  if ( h[iprod][iebin][3] ) hGroup[iprod][iebin][2] = (TH1D*) h[iprod][iebin][3]->Clone(Form("SM_Group2_Ebin%d_Prod%d",iebin,iprod));
307 
308  if( hGroup[iprod][iebin][0] )
309  {
310  hGroup[iprod][iebin][0]->Add( h[iprod][iebin][4] );
311  hGroup[iprod][iebin][0]->Add( h[iprod][iebin][5] );
312  hGroup[iprod][iebin][0]->Add( h[iprod][iebin][6] );
313  hGroup[iprod][iebin][0]->Add( h[iprod][iebin][8] );
314  hGroup[iprod][iebin][0]->Add( h[iprod][iebin][9] );
315 
316  hGroup[iprod][iebin][0]->Scale(1./6.);
317  }
318 
319  if( hGroup[iprod][iebin][1] )
320  {
321  hGroup[iprod][iebin][1]->Add( h[iprod][iebin][2] );
322 
323  hGroup[iprod][iebin][1]->Scale(1./2.);
324  }
325 
326  if( hGroup[iprod][iebin][2] )
327  {
328  hGroup[iprod][iebin][2]->Add( h[iprod][iebin][7] );
329 
330  hGroup[iprod][iebin][2]->Scale(1./2.);
331  }
332  } // SM
333 
334  if ( histoName.Contains("TCardChannel") )
335  {
336  hGroup[iprod][iebin][0] = 0;
337  hGroup[iprod][iebin][1] = 0;
338  hGroup[iprod][iebin][2] = 0;
339  hGroup[iprod][iebin][3] = 0;
340 
341  if ( h[iprod][iebin][0] ) hGroup[iprod][iebin][0] = (TH1D*) h[iprod][iebin][0]->Clone(Form("TC_Group0_Ebin%d_Prod%d",iebin,iprod));
342  if ( h[iprod][iebin][1] ) hGroup[iprod][iebin][1] = (TH1D*) h[iprod][iebin][1]->Clone(Form("TC_Group1_Ebin%d_Prod%d",iebin,iprod));
343  if ( h[iprod][iebin][2] ) hGroup[iprod][iebin][2] = (TH1D*) h[iprod][iebin][2]->Clone(Form("TC_Group2_Ebin%d_Prod%d",iebin,iprod));
344  if ( h[iprod][iebin][3] ) hGroup[iprod][iebin][3] = (TH1D*) h[iprod][iebin][3]->Clone(Form("TC_Group3_Ebin%d_Prod%d",iebin,iprod));
345 
346  if ( debug )
347  {
348  printf("ie %d, iprod %d\n",iebin,iprod);
349  printf(" 0-%p, 1-%p, 2-%p, 3-%p, 4-%p\n",h[iprod][iebin][ 0],h[iprod][iebin][ 1], h[iprod][iebin][ 2], h[iprod][iebin][ 3], h[iprod][iebin][ 4]);
350  printf(" 5-%p, 6-%p, 7-%p, 8-%p, 9-%p\n",h[iprod][iebin][ 5],h[iprod][iebin][ 6], h[iprod][iebin][ 7], h[iprod][iebin][ 8], h[iprod][iebin][ 9]);
351  printf("10-%p, 11-%p, 12-%p, 13-%p, 14-%p\n",h[iprod][iebin][10],h[iprod][iebin][11], h[iprod][iebin][12], h[iprod][iebin][13], h[iprod][iebin][14]);
352  printf("15-%p, 16-%p \n" ,h[iprod][iebin][15],h[iprod][iebin][16]);
353  }
354 
355  if( hGroup[iprod][iebin][0] )
356  {
357  hGroup[iprod][iebin][0]->Add( h[iprod][iebin][ 7] );
358  hGroup[iprod][iebin][0]->Add( h[iprod][iebin][ 8] );
359  hGroup[iprod][iebin][0]->Add( h[iprod][iebin][15] );
360 
361  hGroup[iprod][iebin][0]->Scale(1./4.);
362  }
363 
364  if( hGroup[iprod][iebin][1] )
365  {
366  hGroup[iprod][iebin][1]->Add( h[iprod][iebin][ 6] );
367  hGroup[iprod][iebin][1]->Add( h[iprod][iebin][ 9] );
368  hGroup[iprod][iebin][1]->Add( h[iprod][iebin][14] );
369 
370  hGroup[iprod][iebin][1]->Scale(1./4.);
371  }
372 
373  if( hGroup[iprod][iebin][2] )
374  {
375  hGroup[iprod][iebin][2]->Add( h[iprod][iebin][ 5] );
376  hGroup[iprod][iebin][2]->Add( h[iprod][iebin][10] );
377  hGroup[iprod][iebin][2]->Add( h[iprod][iebin][13] );
378 
379  hGroup[iprod][iebin][2]->Scale(1./4.);
380  }
381 
382  if( hGroup[iprod][iebin][3] )
383  {
384  hGroup[iprod][iebin][3]->Add( h[iprod][iebin][ 4] );
385  hGroup[iprod][iebin][3]->Add( h[iprod][iebin][11] );
386  hGroup[iprod][iebin][3]->Add( h[iprod][iebin][12] );
387 
388  hGroup[iprod][iebin][3]->Scale(1./4.);
389  }
390 
391  } // TCard
392 
393  for(Int_t igroup = 0; igroup < ngroupmax; igroup++)
394  {
395  if( !hGroup[iprod][iebin][igroup] ) continue;
396  hGroup[iprod][iebin][igroup]->SetLineColor (colorGroup[igroup]);
397  hGroup[iprod][iebin][igroup]->SetMarkerColor(colorGroup[igroup]);
398  }
399 
400  } // ebins
401  } // prod bins
402 
403  //
404  // Save the projected histograms in file for further processing
405  // In such case, do not do plotting.
406  //
407  TString outputFileName2 = "";//Form("%s%s%s",clusterization.Data(),pid.Data(),tm.Data());
408  //printf("Opt name %s\n",opt.Data());
409  outputFileName= Form("%s_%s%s%s",titleData.Data(),titleMC.Data(),outputFileName2.Data(),opt.Data());
410 
411  if ( debug )
412  printf("Output string: <%s>",outputFileName.Data());
413 
414  if ( saveHisto )
415  {
416  TFile* fout = new TFile(Form("figures/%s/Projections_%s.root",
417  histoName.Data(),outputFileName.Data()),"recreate");
418 
419  for(Int_t iprod = 0; iprod < nProd; iprod++)
420  {
421  for(Int_t iebin= 0; iebin < nEBins; iebin++)
422  {
423  for(Int_t ipbin = firstP; ipbin <= lastP; ipbin++)
424  {
425  if( !h[iprod][iebin][ipbin-firstP] ) continue;
426  h[iprod][iebin][ipbin-firstP]->SetName(Form("Prod%d_Ebin%d_Param%d",iprod,iebin,ipbin));
427  h[iprod][iebin][ipbin-firstP]->Write();
428  }
429 
430  for(Int_t igroup = 0; igroup < ngroupmax; igroup++)
431  {
432  if( !hGroup[iprod][iebin][igroup] ) continue;
433  hGroup[iprod][iebin][igroup]->SetName(Form("Prod%d_Ebin%d_ParamGroup%d",iprod,iebin,igroup));
434  hGroup[iprod][iebin][igroup]->Write();
435  }
436 
437  if ( hA[iprod][iebin] )
438  {
439  hA[iprod][iebin]->SetName(Form("Prod%d_Ebin%d_AllParam",iprod,iebin));
440  hA[iprod][iebin]->Write();
441  }
442 
443  } // iebin
444  } // iprod
445  fout->Close();
446  printf("Create: %s\n",fout->GetName());
447  // do no more
448  return;
449  }
450 
451  //
452  // Plot per E bin per Param: SM, TC, ...
453  //
454 
455  TString fileName ;
456  titleData.ReplaceAll("/","_");
457 
458  gStyle->SetPadRightMargin(0.01);
459  gStyle->SetPadLeftMargin(0.12);
460  gStyle->SetTitleFontSize(0.06);
461  // gStyle->SetStatFontSize(0.06);
462  gStyle->SetOptStat(0);
463 
464  //---------------------------------------
465  // One file per E bin, each canvas one SM/TC
466  //---------------------------------------
467  for(Int_t iebin = 0; iebin < nEBins; iebin++)
468  {
469  gStyle->SetOptTitle(1);
470  gStyle->SetPadTopMargin(0.1);
471 
472  TCanvas * c = new TCanvas(Form("c_ebin%d_%s",
473  iebin,histoName.Data()),
474  Form("%2.1f < E < %2.1f, %s",
475  lowE[iebin],higE[iebin],
476  histoName.Data()),
477  ncolPar*2000,nrowPar*2000);
478  c->Divide(ncolPar,nrowPar);
479 
480  TLegend *l = new TLegend(-0.04,0,1,1);
481  if(ncolPar!=nrowPar)
482  {
483  l = new TLegend(-0.04,0.,1,1);
484  l->SetTextSize(0.06);
485  }
486  else
487  {
488  l = new TLegend(0.35,0.6,0.9,0.9);
489  l->SetTextSize(0.045);
490  }
491  l->SetFillColor(0);
492  l->SetFillStyle(0);
493  l->SetLineColor(0);
494  l->SetBorderSize(0);
495  l->AddEntry("",daLeg,"");
496  l->AddEntry("",mcLeg,"");
497  if((histoName.Contains("MM02") || histoName.Contains("MM20")) && !histoName.Contains("NoCut") )
498  l->SetHeader(Form(" %2.1f < #it{E} < %2.1f GeV, #it{n}^{w}_{cells} > 4",lowE[iebin],higE[iebin]));
499  else
500  l->SetHeader(Form(" %2.1f < #it{E} < %2.1f GeV",lowE[iebin],higE[iebin]));
501 
502  for(Int_t ipbin = firstP; ipbin <= lastP; ipbin++)
503  {
504  c->cd(ipbin+1);
505 
506  if ( (histoName.Contains("ECell") && !histoName.Contains("Tot")) || histoName.Contains("NLocMax"))gPad->SetLogy();
507  gPad->SetGridy();
508 
509  if(!h[0][iebin][ipbin-firstP]) continue;
510 
511  for(Int_t iprod = 0; iprod < nProd; iprod++)
512  {
513  if(!h[iprod][iebin][ipbin-firstP]) continue;
514 
515  h[iprod][iebin][ipbin-firstP]->SetTitle(Form("SM %d",ipbin));
516 
517  if(iprod==0) h[iprod][iebin][ipbin-firstP]->Draw("H");
518  else h[iprod][iebin][ipbin-firstP]->Draw("H same");
519 
520  if(h[iprod][iebin][ipbin-firstP]->GetMaximum() > h[0][iebin][ipbin-firstP]->GetMaximum())
521  h[0][iebin][ipbin-firstP]->SetMaximum(h[iprod][iebin][ipbin-firstP]->GetMaximum()*1.2);
522 
523  if(ipbin==0)
524  l->AddEntry(h[iprod][iebin][ipbin-firstP],Form("%s",prodLeg[iprod].Data()),"PL");
525  } // iprod
526 
527  h[0][iebin][ipbin-firstP]->Draw("H same");
528 
529  } // param
530 
531  if(ncolPar!=nrowPar && ncolPar*nrowPar!=nparam)
532  c->cd(nparam+1);
533  l->Draw();
534 
535  fileName = Form("figures/%s/ProductionComparisonPerSM_%s_Ebin%d",
536  histoName.Data(),outputFileName.Data(),iebin);
537  fileName+=fileFormat;
538  c->Print(fileName);
539 
540  if ( !plotRatio ) continue;
541 
542  TCanvas * cR = new TCanvas(Form("cRat_ebin_%d_%s",
543  iebin,histoName.Data()),
544  Form("%2.1f < E < %2.1f, %s",
545  lowE[iebin],higE[iebin],
546  histoName.Data()),
547  ncolPar*2000,nrowPar*2000);
548  cR->Divide(ncolPar,nrowPar);
549 
550 
551  for(Int_t ipbin = firstP; ipbin <= lastP; ipbin++)
552  {
553  cR->cd(ipbin+1);
554 
555  gPad->SetGridy();
556 
557  if(!h[1][iebin][ipbin-firstP]) continue;
558 
559  for(Int_t iprod = 1; iprod < nProd; iprod++)
560  {
561  if(!h[iprod][iebin][ipbin-firstP]) continue;
562 
563  TH1F* hRat = (TH1F*) h[iprod][iebin][ipbin-firstP]->Clone(Form("%s_Ratio",h[iprod][iebin][ipbin-firstP]->GetName()));
564  hRat->Divide(h[0][iebin][ipbin-firstP]);
565 
566  if(iprod==0) hRat->Draw("H");
567  else hRat->Draw("H same");
568 
569  hRat->SetYTitle("Ratio MC to Data");
570  hRat->SetMaximum(2);
571  hRat->SetMinimum(0);
572 
573  } // iprod
574 
575  } // param
576 
577  cR->cd(ncolPar*nrowPar);
578  l->Draw();
579 
580  fileName = Form("figures/%s/ProductionComparisonPerSM_%s_Ebin%d_Ratios",
581  histoName.Data(),outputFileName.Data(),iebin);
582  fileName+=fileFormat;
583  cR->Print(fileName);
584 
585  } // e bin
586 
587  //---------------------------------------
588  // All SM, each canvas one energy bin
589  //---------------------------------------
590  TLegend *l2 = 0;
591  if(nEBins > 2 && ncolE!=nrowE)
592  {
593  l2 = new TLegend(-0.04,0.,1,1);
594  l2->SetTextSize(0.06);
595  }
596  else
597  {
598  l2 = new TLegend(0.35,0.7,0.9,0.9);
599  l2->SetTextSize(0.025);
600  }
601  l2->SetFillColor(0);
602  l2->SetFillStyle(0);
603  l2->SetLineColor(0);
604  l2->SetBorderSize(0);
605  l2->AddEntry("",daLeg,"");
606  l2->AddEntry("",mcLeg,"");
607 
608  if(ncolE==nrowE) l2->SetTextSize(0.04);
609 
610  TCanvas * cA = new TCanvas(Form("cAllSM_%s",histoName.Data()),
611  Form("All SM, %s",histoName.Data()),
612  ncolE*2000,nrowE*2000);
613 
614  cA->Divide(ncolE,nrowE);
615 
616  for(Int_t iebin = 0; iebin < nEBins; iebin++)
617  {
618  cA->cd(iebin+1);
619 
620  if(!hA[0][iebin]) continue;
621 
622  if((histoName.Contains("ECell") && !histoName.Contains("Tot")) || histoName.Contains("NLocMax"))
623  gPad->SetLogy();
624 
625  gStyle->SetOptTitle(1);
626  gStyle->SetPadTopMargin(0.1);
627 
628  hA[0][iebin]->Draw("H");
629 
630  for(Int_t iprod = 0; iprod < nProd; iprod++)
631  {
632  if(!hA[iprod][iebin]) continue;
633 
634  hA[iprod][iebin]->SetTitle(Form("%2.1f < #it{E}^{clus} < %2.1f GeV",lowE[iebin],higE[iebin]));
635 
636  if((histoName.Contains("MM02") || histoName.Contains("MM20")) && !histoName.Contains("NoCut") )
637  {
638  hA[iprod][iebin]->SetTitle(Form("%2.1f < #it{E}^{clus} < %2.1f GeV, #it{n}^{w}_{cells} > 4",lowE[iebin],higE[iebin]));
639  }
640 
641  hA[iprod][iebin]->Draw("H same");
642 
643  if(hA[iprod][iebin]->GetMaximum() > hA[0][iebin]->GetMaximum())
644  hA[0][iebin]->SetMaximum(hA[iprod][iebin]->GetMaximum()*1.2);
645 
646  if(hA[iprod][iebin] && iebin==0) l2->AddEntry(hA[iprod][iebin],Form("%s",prodLeg[iprod].Data()),"L");
647  }
648 
649  hA[0][iebin]->Draw("H same");
650  }
651 
652  if ( nEBins > 1 && ncolE!=nrowE)
653  cA->cd(ncolE*nrowE);
654 
655  l2->Draw("same");
656 
657  fileName = Form("figures/%s/ProductionComparisonPerEbin_%s_AllSM",
658  histoName.Data(),outputFileName.Data());
659  fileName+=fileFormat;
660  cA->Print(fileName);
661 
662  if(plotRatio)
663  {
664  TCanvas * cAR = new TCanvas(Form("cAllSM_Rat_%s",histoName.Data()),
665  Form("All SM, %s",histoName.Data()),
666  ncolE*2000,nrowE*2000);
667 
668  cAR->Divide(ncolE,nrowE);
669 
670  for(Int_t iebin = 0; iebin < nEBins; iebin++)
671  {
672  cAR->cd(iebin+1);
673 
674  if(!hA[0][iebin]) continue;
675 
676  //if(histoName.Contains("ECell"))gPad->SetLogy();
677 
678  gStyle->SetOptTitle(1);
679  gStyle->SetPadTopMargin(0.1);
680 
681  hA[0][iebin]->Draw("H");
682 
683  for(Int_t iprod = 1; iprod < nProd; iprod++)
684  {
685  if(!hA[iprod][iebin]) continue;
686 
687  TH1F* hRat = (TH1F*) hA[iprod][iebin]->Clone(Form("%s_Ratio",hA[iprod][iebin]->GetName()));
688  hRat->Divide(hA[0][iebin]);
689 
690  if(iprod==1) hRat->Draw("H");
691  else hRat->Draw("H same");
692 
693  hRat->SetYTitle("Ratio MC to Data");
694  hRat->SetMaximum(2);
695  hRat->SetMinimum(0);
696  }
697  }
698 
699  if ( nEBins > 1 && ncolE!=nrowE)
700  cAR->cd(ncolE*nrowE);
701 
702  l2->Draw("same");
703 
704  fileName = Form("figures/%s/ProductionComparisonPerEbin_%s_AllSM_Ratios",
705  histoName.Data(),outputFileName.Data());
706  fileName+=fileFormat;
707  cAR->Print(fileName);
708  }
709 
710  //---------------------------------------
711  // Each file one SM, each canvas one energy bin
712  //---------------------------------------
713  for(Int_t ipbin = firstP; ipbin <= lastP; ipbin++)
714  {
715  gStyle->SetOptTitle(1);
716  gStyle->SetPadTopMargin(0.1);
717 
718  TCanvas * c = new TCanvas(Form("c_par%d_%s",
719  ipbin,histoName.Data()),
720  Form("param %d, %s",
721  ipbin,
722  histoName.Data()),
723  3*2000,2*2000);
724  c->Divide(3,2);
725 
726  TLegend *l = new TLegend(-0.04,0,1,1);
727  l->SetFillColor(0);
728  l->SetFillStyle(0);
729  l->SetLineColor(0);
730  l->SetBorderSize(0);
731  l->SetTextSize(0.07);
732  l->SetHeader(Form(" SM %d",ipbin));
733  for(Int_t iebin = 0; iebin < nEBins; iebin++)
734  {
735  c->cd(iebin+1);
736 
737  if(histoName.Contains("ECell") && !histoName.Contains("Tot"))gPad->SetLogy();
738  gPad->SetGridy();
739 
740  if(!h[0][iebin][ipbin-firstP]) continue;
741 
742  for(Int_t iprod = 0; iprod < nProd; iprod++)
743  {
744  if(!h[iprod][iebin][ipbin-firstP]) continue;
745 
746  h[iprod][iebin][ipbin-firstP]->SetTitle(Form("%2.1f < #it{E}^{clus} < %2.1f GeV",lowE[iebin],higE[iebin]));
747  if((histoName.Contains("MM02") || histoName.Contains("MM20")) && !histoName.Contains("NoCut") )
748  h[iprod][iebin][ipbin-firstP]->SetTitle(Form("%2.1f < #it{E}^{clus} < %2.1f GeV, #it{n}^{w}_{cells} > 4",lowE[iebin],higE[iebin]));
749 
750  if(iprod==0) h[iprod][iebin][ipbin-firstP]->Draw("H");
751  else h[iprod][iebin][ipbin-firstP]->Draw("H same");
752 
753  if(h[iprod][iebin][ipbin-firstP]->GetMaximum() > h[0][iebin][ipbin-firstP]->GetMaximum())
754  h[0][iebin][ipbin-firstP]->SetMaximum(h[iprod][iebin][ipbin-firstP]->GetMaximum()*1.2);
755 
756  if(iebin==0)
757  l->AddEntry(h[iprod][iebin][ipbin-firstP],Form("%s",prodLeg[iprod].Data()),"PL");
758  } // iprod
759 
760  h[0][iebin][ipbin-firstP]->Draw("H same");
761  } // param
762 
763  c->cd(6);
764  l->Draw();
765 
766  fileName = Form("figures/%s/ProductionComparisonPerEbin_%s_SM%d",
767  histoName.Data(),outputFileName.Data(),ipbin);
768  fileName+=fileFormat;
769  c->Print(fileName);
770 
771  } // param
772 
773  Int_t colorTC [] = {1,2,6,4,4,6,2,1,1,2,6,4,4,6,2,1};
774  Int_t lineStyleTC[] = {1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4};
775 
776  Int_t colorSM []= { 1, 1, 2, 2, 3, 3, 4, 4, 7, 7, 6, 6, 8, 8, kOrange, kOrange, kRose, kRose, kMagenta, kMagenta};
777  Int_t lineStyleSM[]= { 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2};
778 
779  //Int_t markerStyleSM[]={24,25,25,24,25,24,25,24,25,24,25,21,21,21,21,21,22,26,22,26,22,26,22,26};
780 
781  //---------------------------------------
782  // Each file per production Data/MC,
783  // each canvas one energy bin, each pad several param
784  //---------------------------------------
785  for(Int_t iprod = 0; iprod < nProd; iprod++)
786  {
787  gStyle->SetOptTitle(1);
788  gStyle->SetPadTopMargin(0.1);
789 
790  TCanvas * c = new TCanvas(Form("c_iprod%d_%s",iprod,histoName.Data()),
791  Form("%s, %s" ,prod[iprod].Data(), histoName.Data()),
792  ncolE*2000,nrowE*2000);
793  c->Divide(ncolE,nrowE);
794 
795  TLegend *l = new TLegend(-0.04,0,1,1);
796  l->SetFillColor(0);
797  l->SetFillStyle(0);
798  l->SetLineColor(0);
799  l->SetBorderSize(0);
800  l->SetTextSize(0.07);
801  l->SetHeader(Form(" %s",prodLeg[iprod].Data()));
802  for(Int_t iebin = 0; iebin < nEBins; iebin++)
803  {
804  c->cd(iebin+1);
805  gPad->SetGridy();
806 
807  if(!h[iprod][iebin][0]) continue;
808 
809  for(Int_t iparam = firstP; iparam <= lastP; iparam++)
810  {
811  if(!h[iprod][iebin][iparam]) continue;
812 
813  h[iprod][iebin][iparam]->SetTitle(Form("%2.1f < #it{E} < %2.1f GeV",lowE[iebin],higE[iebin]));
814  if((histoName.Contains("MM02") || histoName.Contains("MM20")) && !histoName.Contains("NoCut") )
815  h[iprod][iebin][iparam]->SetTitle(Form("%2.1f < #it{E}^{clus} < %2.1f GeV, #it{n}^{w}_{cells} > 4",lowE[iebin],higE[iebin]));
816 
817  if(histoName.Contains("TCardChan"))
818  {
819  h[iprod][iebin][iparam]->SetLineColor(colorTC[iparam]);
820  h[iprod][iebin][iparam]->SetLineStyle(lineStyleTC[iparam]);
821  }
822  else
823  {
824  h[iprod][iebin][iparam]->SetLineColor(colorSM[iparam]);
825  h[iprod][iebin][iparam]->SetLineStyle(lineStyleSM[iparam]);
826  }
827 
828  if(iparam==0) h[iprod][iebin][iparam]->Draw("H");
829  else h[iprod][iebin][iparam]->Draw("H same");
830 
831  if(h[0][iebin][iparam] && h[iprod][iebin][iparam]->GetMaximum() > h[0][iebin][iparam]->GetMaximum())
832  h[0][iebin][iparam]->SetMaximum(h[iprod][iebin][iparam]->GetMaximum()*1.2);
833 
834  if(iebin==0)
835  {
836  if(histoName.Contains("SM"))
837  l->AddEntry(h[iprod][iebin][iparam],Form("SM = %d",iparam),"PL");
838  else
839  l->AddEntry(h[iprod][iebin][iparam],Form("T-Card i = %d",iparam),"PL");
840  }
841  } // param
842  }//iebin
843  c->cd(ncolE*nrowE);
844  l->Draw();
845 
846 // fileName = Form("figures/%s/Comparison_PerParam_%s%s",
847 // histoName.Data(),prod[iprod].Data(),outputFileName2.Data());
848 
849  if ( prod[iprod].Contains("data") )
850  fileName = Form("figures/%s/SMComparison_PerEbin_%s%s",
851  histoName.Data(),titleData.Data(),outputFileName2.Data());
852  else
853  {
854  fileName = Form("figures/%s/SMComparison_PerEbin_%s_%d%s",
855  histoName.Data(),titleMC.Data(),iprod,outputFileName2.Data());
856  }
857  fileName+=fileFormat;
858  c->Print(fileName);
859 
860  //---------------------------------------
861  // Each file, one production MC/Data
862  // Grouped plots, each canvas one energy bin, each pad different groups
863  //---------------------------------------
864  {
865  gStyle->SetOptTitle(1);
866  gStyle->SetPadTopMargin(0.1);
867  TCanvas * cGroup = new TCanvas(Form("cGroups_%s_%s",histoName.Data(),prod[iprod].Data()),
868  Form("Groups, %s %s",histoName.Data(),prod[iprod].Data()),
869  ncolE*2000,nrowE*2000);
870 
871  cGroup->Divide(ncolE,nrowE);
872 
873  TLegend *lG = new TLegend(0,0,1,1);
874  lG->SetFillColor(0);
875  lG->SetFillStyle(0);
876  lG->SetLineColor(0);
877  lG->SetBorderSize(0);
878  lG->SetTextSize(0.07);
879  lG->SetHeader(Form(" %s",prodLeg[iprod].Data()));
880 
881 
882  for(Int_t iebin = 0; iebin < nEBins; iebin++)
883  {
884  cGroup->cd(iebin+1);
885  for(Int_t igroup = 0; igroup < ngroupmax; igroup++)
886  {
887  if(!hGroup[iprod][iebin][igroup]) continue;
888 
889  hGroup[iprod][iebin][igroup]->SetTitle(Form("%2.1f < #it{E} < %2.1f GeV",lowE[iebin],higE[iebin]));
890  if((histoName.Contains("MM02") || histoName.Contains("MM20")) && !histoName.Contains("NoCut") )
891  hGroup[iprod][iebin][igroup]->SetTitle(Form("%2.1f < #it{E}^{clus} < %2.1f GeV, #it{n}^{w}_{cells} > 4",lowE[iebin],higE[iebin]));
892 
893  if(igroup==0) hGroup[iprod][iebin][igroup]->Draw("H");
894  else hGroup[iprod][iebin][igroup]->Draw("H same");
895 
896  if(hGroup[0][iebin][igroup] && hGroup[iprod][iebin][igroup]->GetMaximum() > hGroup[0][iebin][igroup]->GetMaximum())
897  hGroup[0][iebin][igroup]->SetMaximum(hGroup[iprod][iebin][igroup]->GetMaximum()*1.2);
898 
899  if(iebin==0)
900  {
901  if(histoName.Contains("SM"))lG->AddEntry(hGroup[iprod][iebin][igroup],Form("SM = %s",groupSM[igroup].Data()),"PL");
902  if(histoName.Contains("TCardChannel"))lG->AddEntry(hGroup[iprod][iebin][igroup],Form("T-Card cell in %s",groupTC[igroup].Data()),"PL");
903  }
904 
905  } // param
906  }//iebin
907  cGroup->cd(ncolE*nrowE);
908  lG->Draw();
909 
910 // fileName = Form("figures/%s/Comparison_Groups_PerParam_%s%s",
911 // histoName.Data(),prod[iprod].Data(),outputFileName2.Data());
912 
913  if ( prod[iprod].Contains("data") )
914  fileName = Form("figures/%s/GroupComparison_PerEbin_%s%s",
915  histoName.Data(),titleData.Data(),outputFileName2.Data());
916  else
917  {
918  fileName = Form("figures/%s/GroupComparison_PerEbin_%s_%d%s",
919  histoName.Data(),titleMC.Data(),iprod,outputFileName2.Data());
920  }
921  fileName+=fileFormat;
922  cGroup->Print(fileName);
923  } // GROUPS
924 
925  if(!plotRatio) continue;
926 
927  TCanvas * cR = new TCanvas(Form("cRat_prod_%d_%s",iprod,histoName.Data()),
928  Form("%s, %s",prod[iprod].Data(),histoName.Data()),
929  ncolE*2000,nrowE*2000);
930  cR->Divide(ncolE,nrowE);
931 
932  for(Int_t iebin = 0; iebin < nEBins; iebin++)
933  {
934  cR->cd(iebin+1);
935 
936  //if(histoName.Contains("ECell"))gPad->SetLogy();
937  gPad->SetGridy();
938 
939  if(!h[iprod][iebin][0]) continue;
940 
941  for(Int_t iparam = 1; iparam < nparam; iparam++)
942  {
943  if(!h[iprod][iebin][iparam]) continue;
944 
945  TH1F* hRat = (TH1F*) h[iprod][iebin][iparam]->Clone(Form("%s_Ratio_PerParam_%s",h[iprod][iebin][iparam]->GetName(),prod[iprod].Data()));
946  hRat->Divide(hA[iprod][iebin]);
947 
948  if(iparam==0) hRat->Draw("H");
949  else hRat->Draw("H same");
950 
951  hRat->SetYTitle("Ratio to no selection");
952  hRat->SetMaximum(2);
953  hRat->SetMinimum(0);
954 
955  } // iparam
956 
957  } // ebin
958 
959  cR->cd(ncolE*nrowE);
960  l->Draw();
961 
962 // fileName = Form("figures/%s/Comparison_PerParam_%s%s_Ratios",
963 // histoName.Data(),prod[iprod].Data(),outputFileName2.Data());
964 
965  if ( prod[iprod].Contains("data") )
966  fileName = Form("figures/%s/SMComparison_PerEbin_%s%s_Ratios",
967  histoName.Data(),titleData.Data(),outputFileName2.Data());
968  else
969  {
970  fileName = Form("figures/%s/SMComparison_PerEbin_%s_%d%s_Ratios",
971  histoName.Data(),titleMC.Data(),iprod,outputFileName2.Data());
972  }
973  fileName+=fileFormat;
974  cR->Print(fileName);
975  }
976 }
977 
978 //-------------------------------------------------------------------------
981 //-------------------------------------------------------------------------
983  Float_t & xmin , Float_t & xmax,
984  Float_t & xNormMin, Float_t & xNormMax,
985  Bool_t & normtomax, Int_t & rebin )
986 {
987  xmin = -1;
988  xmax = 10000;
989  xNormMin = -1;
990  xNormMax = 10000;
991  rebin = 1;
992  normtomax = kFALSE;
993  if ( histoName == "SMM02" )
994  {
995  xmin = 0.1; xmax = 1.10;
996  xNormMin = 0.6; xNormMax = 2;
997  rebin = 4;
998  normtomax = 0;
999  }
1000  if ( histoName == "SMM02NoCut" )
1001  {
1002  xmin = 0.1; xmax = 1.0;
1003  xNormMin = 0.1; xNormMax = 0.4;
1004  rebin = 2;
1005  normtomax = 1;
1006  }
1007  if ( histoName == "SMNCell" && !histoName.Contains("Module") )
1008  {
1009  xmin = 2 ; xmax = 12 ;
1010  rebin = 1;
1011  normtomax = 0;
1012  }
1013  if ( histoName.Contains("SMM20Low") )
1014  {
1015  xmin = 0.05; xmax = 0.25;
1016  //xNormMin = 0.6; xNormMax = 2;
1017  rebin = 1;
1018  normtomax = 0;
1019  }
1020  if ( histoName.Contains("SMM20Hig") )
1021  {
1022  xmin = 0.05; xmax = 0.30;
1023  //xNormMin = 0.6; xNormMax = 2;
1024  rebin = 1;
1025  normtomax = 0;
1026  }
1027  if ( histoName.Contains("Module") )
1028  {
1029  xmin = 0.0; xmax = 100000;
1030  rebin = 1;
1031  normtomax = 0;
1032 
1033  if ( histoName.Contains("Rat") )
1034  {
1035  rebin = 5;
1036  }
1037  else if ( histoName.Contains("Tot") )
1038  {
1039  xmin = 0.0; xmax = 20;
1040  rebin = 1;
1041 
1042  }
1043  else if ( histoName.Contains("ECellModuleMax") ||
1044  histoName.Contains("ECellModuleOut") )
1045  {
1046  xmin = 0.0; xmax = 10;
1047  rebin = 5;
1048  }
1049  }
1050 
1051  if ( histoName.Contains("TCardChannelM02") )
1052  {
1053  xmin = 0.1; xmax = 0.5;
1054  rebin = 2;
1055  normtomax = 0;
1056  if( histoName.Contains("NoCut") ) normtomax = 1;
1057  }
1058 
1059  if ( histoName.Contains ( "SMEMaxEClusterRat") )
1060  {
1061  xmin = 0 ; xmax = 1 ;
1062  rebin = 5;
1063  normtomax = 0;
1064  if ( histoName.Contains("LowM02") ) xmin = 0.4 ;
1065  if ( histoName.Contains("HighM02") ) xmax = 0.8 ;
1066  }
1067 }
1068 
1069 //-------------------------------------------------------------------------
1072 //-------------------------------------------------------------------------
1075  TH1D* histo, TString histoName, Int_t iprod,
1076  Int_t rebin, Float_t xmin, Float_t xmax,
1077  Bool_t normtomax, Float_t xNormMin, Float_t xNormMax,
1078  Float_t lowEBin, Float_t highEBin, Bool_t debug
1079 )
1080 {
1081  if ( !histo )
1082  return kFALSE;
1083 
1084  Int_t color [] = {1,4,2,kYellow-2,8,kCyan,kOrange+2,kViolet,kOrange-2,4,2,6,8,9,kYellow-6,kCyan,kOrange+2,kViolet,kOrange-2};
1085  Int_t lineStyle[] = {1,1,1,1,1,1, 1, 1, 1, 1, 1,2,2,2,2,2, 2, 2, 2, 2, 2,2,2,2,2,2,2,2,2,2,2,2};
1086  Int_t marker [] = {20,20,20,21,24,24,24,24,24,24,24};
1087 
1088  histo->SetLineColor(color[iprod]);
1089 
1090  histo->SetLineWidth(2);
1091 
1092  histo->SetLineStyle(lineStyle[iprod]);
1093 
1094  histo->SetMarkerStyle(marker[iprod]);
1095 
1096  histo->SetMarkerColor(color[iprod]);
1097 
1098  histo->SetMarkerSize(0.5);
1099 
1100  histo->SetTitleOffset(1.8,"Y");
1101 
1102  histo->SetTitle(Form("%2.1f < #it{E} < %2.1f GeV",lowEBin,highEBin));
1103 
1104  if(rebin > 1)
1105  {
1106  histo->Rebin(rebin);
1107  }
1108 
1109  histo->SetAxisRange(xmin,xmax,"X");
1110 
1111  if ( !normtomax )
1112  {
1113  Int_t xNormMinBin = histo->FindBin(xNormMin);
1114  Int_t xNormMaxBin = histo->FindBin(xNormMax);
1115 
1116  Double_t integral = histo->Integral(xNormMinBin, xNormMaxBin);
1117 
1118  if ( debug )
1119  printf("\t \t Integral %e bins [%d, %d], range [%2.2f, %2.2f]\n",
1120  integral,xNormMinBin,xNormMaxBin,xNormMin,xNormMax);
1121 
1122  if ( integral < 1e-10 )
1123  return kFALSE;
1124 
1125  histo->Scale(1./integral);
1126 
1127  if(!histoName.Contains("Module"))
1128  {
1129  if(histoName.Contains("MEtaPhi"))
1130  histo->SetYTitle("1/ integral d #it{N} / d #sigma_{#eta#varphi}^{2}");
1131  else if(histoName.Contains("MEta"))
1132  histo->SetYTitle("1/ integral d #it{N} / d #sigma_{#eta}^{2}");
1133  else if(histoName.Contains("MPhi"))
1134  histo->SetYTitle("1/ integral d #it{N} / d #sigma_{#varphi}^{2}");
1135  else if(histoName.Contains("SMEMaxEClusterRat"))
1136  histo->SetYTitle("1/ integral d #it{N} / d (#it{E}_{cell}^{max}/#it{E}_{cluster})");
1137  else if(histoName.Contains("MNCell"))
1138  histo->SetYTitle("1/ integral d #it{N} / d #it{n}^{w}_{cell}");
1139  else if(histoName.Contains("MNLocMax"))
1140  histo->SetYTitle("1/ integral d #it{N} / d #it{n}_{LM}");
1141  else if(histoName.Contains("M20"))
1142  histo->SetYTitle("1/ integral d #it{N} / d #sigma_{short}^{2}");
1143  else if(histoName.Contains("M02"))
1144  histo->SetYTitle("1/ integral d #it{N} / d #sigma_{long}^{2}");
1145  }
1146  else histo->SetYTitle("1/ integral d #it{N} ");
1147 
1148  } // normalize to integral
1149  else
1150  {
1151  Double_t scale = histo->GetBinContent(histo->FindBin(0.245));
1152  if ( debug ) printf("\t \t \t Norm to max scale %2.2e\n",scale);
1153 
1154  if ( scale < 1e-10 )
1155  return kFALSE;
1156 
1157  histo->Scale(1./scale);
1158  histo->SetYTitle("Norm. to max at 0.25");
1159 
1160  } // normalize to maximum at photon peak
1161 
1162  if(!histoName.Contains("Module"))
1163  {
1164  if(histoName.Contains("MEtaPhi"))
1165  histo->SetXTitle("#sigma_{#eta#varphi}^{2}");
1166  else if(histoName.Contains("MEta"))
1167  histo->SetXTitle("#sigma_{#eta}^{2}");
1168  else if(histoName.Contains("MPhi"))
1169  histo->SetXTitle("#sigma_{#varphi}^{2}");
1170  else if(histoName.Contains("MNCell"))
1171  histo->SetXTitle("#it{n}_{cell}^{w}");
1172  else if(histoName.Contains("MNLocMax"))
1173  histo->SetXTitle("#it{n}_{LM}");
1174  else if(histoName.Contains("M20"))
1175  histo->SetXTitle("#sigma_{#short}^{2}");
1176  else if(histoName.Contains("M02"))
1177  histo->SetXTitle("#sigma_{long}^{2}");
1178  }
1179  else if(histoName.Contains("ECell"))
1180  {
1181  histo->SetAxisRange(0,highEBin*1.05,"X");
1182  }
1183  return kTRUE;
1184 }
Int_t color[]
print message on plot with ok/not ok
double Double_t
Definition: External.C:58
Definition: External.C:260
TString fileName
TCanvas * c
Definition: TestFitELoss.C:172
Plotting utilities.
int Int_t
Definition: External.C:63
const Int_t nProd
float Float_t
Definition: External.C:68
Definition: External.C:212
TString prodLeg[]
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)
void CompareTH3DataAndMCProd(TString &outputFileName, TString histoName="SMM02NoCut", const Int_t nProd=3, TString *prod=0x0, TString *prodLeg=0x0, TString clusterization="", TString tm="_TMDep", TString pid="_Neutral", TString titleMC="JJDecLow", TString mcLeg="MC: #gammaJ+JJ({p^{EMCal}_{T,#gamma}>3.5 GeV/#it{c})", TString titleData="LHC11cd_EMC7", TString daLeg="pp@7 TeV, LHC11c+d EMC7", Int_t firstP=0, Int_t lastP=9, TArrayD binE=0, Int_t firstMC=1, Bool_t plotRatio=kFALSE, Bool_t saveHisto=kFALSE, TString opt="", Bool_t debug=kFALSE)
Bool_t SetHistogramRangesAndTitles(TH1D *histo, TString histoName, Int_t iprod, Int_t rebin, Float_t xmin, Float_t xmax, Bool_t normtomax, Float_t xNormMin, Float_t xNormMax, Float_t lowEBin, Float_t highEBin, Bool_t debug)
TFile * file
TList with histograms for a given trigger.
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
TFile * fout
input train file
TString fileFormat
TString prod[]
productions to be compared, directory name
void DefineHistogramSettings(TString histoName, Float_t &xmin, Float_t &xmax, Float_t &xNormMin, Float_t &xNormMax, Bool_t &normtomax, Int_t &rebin)