AliPhysics  5364b50 (5364b50)
DrawProductionComparison.C
Go to the documentation of this file.
1 
39 //---------------------------------------------------------
40 // Set includes and declare methods for compilation
41 
42 #if !defined(__CINT__) || defined(__MAKECINT__)
43 
44 #include <TFile.h>
45 #include <TDirectoryFile.h>
46 #include <TList.h>
47 #include <TString.h>
48 #include <TROOT.h>
49 #include <TStyle.h>
50 #include <TH1F.h>
51 #include <TH2F.h>
52 #include <TCanvas.h>
53 #include <TPad.h>
54 #include <TLegend.h>
55 #include <TObject.h>
56 #include <TAxis.h>
57 #include <TGaxis.h>
58 #include <TLine.h>
59 #include <TF1.h>
60 #include <TMath.h>
61 
62 #endif
63 
64 void ProcessTrigger
65 (TString trigName = "default",
66  TString fileName = "AnalysisResults.root",
67  TString listName = "Pi0IM_GammaTrackCorr_EMCAL");
68 
69 void Cluster (Int_t icalo);
70 void ClusterCells(Int_t icalo);
71 void Cell ();
72 void Correl (Int_t icalo);
73 void Isol (Int_t icalo);
74 void ShowerShape (Int_t icalo);
75 void InvMass (Int_t icalo, TString particle, TString fileName);
76 void MCParticle (Int_t icalo, TString particle);
77 void Track ();
78 void Vertex ();
79 void Centrality ();
80 
81 TObject * GetHisto (TString histoName, Int_t iprod);
83 //
84 //---------------------------------------------------------
85 
86 //-----------------------
87 // Some global variables
88 
90 //TString prod [] = {"DCAoffPIDoff","DCAonPIDoff","DCAoffPIDon","DCAonPIDon"};
92 //TString prodLeg[] = {"DCA off - PID off","DCA on - PID off","DCA off - PID on","DCA on - PID on"};
93 
94 //TString prod [] = {"LHC17l3b_fast","LHC17l4b_fast"};
95 TString prod [] = {"LHC17l3b_fast_TM","LHC17l4b_fast_TM"};
96 TString prodLeg[] = {"Geant3, b FAST","Geant4, b FAST"};
97 
98 //TString prod [] = {"LHC17l3b_cent","LHC17l4b_cent"};
99 //TString prodLeg[] = {"Geant3, b CENT","Geant4, b CENT"};
100 
101 const Int_t nProd = 2;
102 
103 TDirectoryFile *dir[nProd];
105 TFile *file [nProd];
107 
109 TString format = "eps";
110 TString errType = "B";//""; /// Error type in histogram division
111 
113 Int_t color[]={kBlack,kRed,kBlue,kOrange+1,kYellow+1,kGreen+2,kCyan+1,kViolet,kMagenta+2,kGray};
114 //-----------------------
115 
116 //_______________________________________________________________________
122 //_______________________________________________________________________
124 (
125  TString listName = "Pi0IM_GammaTrackCorr_EMCAL",
126  TString fileName = "AnalysisResults.root",
127  TString fileFormat = "pdf"
128  )
129 {
130  format = fileFormat;
131 
132  printf("Open <%s>; Get List : <%s>; format %s\n",fileName.Data(),listName.Data(),format.Data());
133 
134  // Process each of the triggers
135  //
136  ProcessTrigger("default" ,fileName,listName); // Data min bias, or only one for MC
137 
138  // EMC/DMC triggered data (not for MC)
139  ProcessTrigger("EMCAL_L0",fileName,listName);
140  ProcessTrigger("EMCAL_L1",fileName,listName);
141  ProcessTrigger("EMCAL_L2",fileName,listName);
142  ProcessTrigger("DCAL_L0" ,fileName,listName);
143  ProcessTrigger("DCAL_L1" ,fileName,listName);
144  ProcessTrigger("DCAL_L2" ,fileName,listName);
145 }
146 
161 //_______________________________________________________________________
162 void ProcessTrigger(TString trigName, TString fileName, TString listName)
163 {
164  // Access the file and list of histograms, global variables
165  // Check first that the requested trigger exist
166  Bool_t ok = GetFileAndList(fileName, listName, trigName);
167  if ( !ok ) return;
168 
169  gStyle->SetOptTitle(1);
170  gStyle->SetOptStat(0);
171  gStyle->SetOptFit(000000);
172  gStyle->SetPadRightMargin(0.02);
173  //gStyle->SetPadTopMargin(0.02);
174  //gStyle->SetPadLeftMargin(0.15);
175  gStyle->SetTitleFontSize(0.05);
176 
177  Int_t nCalo = 2;
178  Int_t calo = 0;
179  if (trigName.Contains("EMCAL")) { calo = 0 ; nCalo = 1 ; }
180  else if(trigName.Contains("DCAL" )) { calo = 1 ; nCalo = 2 ; }
181 
182  TString caloString [] = {"EMCAL","DCAL"};
183 
184  histoTag = trigName;
185 
186  // Plot basic Track QA
187  Track();
188 
189  // Plot basic Global event QAs
190  Vertex();
191 
192  Centrality();
193 
194  Cell();
195 
196  for(Int_t icalo = calo; icalo < nCalo; icalo++)
197  {
198  if(trigName.Contains("default")) histoTag=Form("%s_%s",caloString[icalo].Data(),trigName.Data());
199 
200  // Plot basic calorimeter, cluster, associated cells,
201  // track-matching, shower shape info
202  Cluster(icalo);
203  ClusterCells(icalo);
204  ShowerShape(icalo);
205 
206  // Plot clusters Origin, only MC
207 // MCParticle(icalo,"Photon");
208 // MCParticle(icalo,"PhotonPi0Decay");
209 // MCParticle(icalo,"Pi0");
210 // MCParticle(icalo,"Electron");
211 
212  // Run before InvMassFit.C
213  //InvMass(icalo,"Pi0",fileName);
214  //InvMass(icalo,"Eta",fileName);
215 
216  // Plot basic isolation energy
217  Isol(icalo);
218 
219  // Plot basic correlation
220  Correl(icalo);
221  }
222 }
223 
233 //______________________________________
234 void Cluster(Int_t icalo)
235 {
236  // Declare the different histograms, arrays input is production
237  TH1F* hRaw [nProd];
238  TH1F* hCorr[nProd];
239  TH1F* hTM [nProd];
240  TH1F* hShSh[nProd];
241 
242  TH1F* hRatRaw [nProd-1];
243  TH1F* hRatCorr[nProd-1];
244  TH1F* hRatTM [nProd-1];
245  TH1F* hRatShSh[nProd-1];
246 
247  TH2F* h2TrackMatchResEtaNeg[nProd];
248  TH2F* h2TrackMatchResEtaPos[nProd];
249  TH2F* h2TrackMatchResPhiNeg[nProd];
250  TH2F* h2TrackMatchResPhiPos[nProd];
251 
252  TH1F* hTrackMatchResEtaNeg[nProd];
253  TH1F* hTrackMatchResEtaPos[nProd];
254  TH1F* hTrackMatchResPhiNeg[nProd];
255  TH1F* hTrackMatchResPhiPos[nProd];
256 
257  TH1F* hRatTrackMatchResEtaNeg[nProd-1];
258  TH1F* hRatTrackMatchResEtaPos[nProd-1];
259  TH1F* hRatTrackMatchResPhiNeg[nProd-1];
260  TH1F* hRatTrackMatchResPhiPos[nProd-1];
261 
262  TH2F* h2TrackMatchResEtaNegTrackPt[nProd];
263  TH2F* h2TrackMatchResEtaPosTrackPt[nProd];
264  TH2F* h2TrackMatchResPhiNegTrackPt[nProd];
265  TH2F* h2TrackMatchResPhiPosTrackPt[nProd];
266 
267  TH1F* hTrackMatchResEtaNegTrackPt[nProd];
268  TH1F* hTrackMatchResEtaPosTrackPt[nProd];
269  TH1F* hTrackMatchResPhiNegTrackPt[nProd];
270  TH1F* hTrackMatchResPhiPosTrackPt[nProd];
271 
272  TH1F* hRatTrackMatchResEtaNegTrackPt[nProd-1];
273  TH1F* hRatTrackMatchResEtaPosTrackPt[nProd-1];
274  TH1F* hRatTrackMatchResPhiNegTrackPt[nProd-1];
275  TH1F* hRatTrackMatchResPhiPosTrackPt[nProd-1];
276 
277  //Legend for productions
278  TLegend lprod(0.65,0.475,0.95,0.675);
279  lprod.SetTextSize(0.04);
280  lprod.SetBorderSize(0);
281  lprod.SetFillColor(0);
282 
283  for(Int_t iprod = 0; iprod < nProd; iprod++)
284  {
285  hRaw [iprod] = (TH1F*) GetHisto(Form("AnaPhoton_Calo%d_hPt_Cut_0_Open" ,icalo),iprod);
286  hCorr[iprod] = (TH1F*) GetHisto(Form("AnaPhoton_Calo%d_hPt_Cut_4_NCells" ,icalo),iprod);
287  hTM [iprod] = (TH1F*) GetHisto(Form("AnaPhoton_Calo%d_hPt_Cut_7_Matching",icalo),iprod);
288  hShSh[iprod] = (TH1F*) GetHisto(Form("AnaPhoton_Calo%d_hPt_Cut_9_PID" ,icalo),iprod);
289 
290  if(!hRaw[iprod]) return;
291 
292  hRaw [iprod]->Rebin(5);
293  hCorr[iprod]->Rebin(5);
294  hTM [iprod]->Rebin(5);
295  hShSh[iprod]->Rebin(5);
296 
297  hRaw [iprod]->Sumw2();
298  hCorr[iprod]->Sumw2();
299  hTM [iprod]->Sumw2();
300  hShSh[iprod]->Sumw2();
301 
302  hRaw [iprod]->Scale(1./nEvents[iprod]);
303  hCorr[iprod]->Scale(1./nEvents[iprod]);
304  hTM [iprod]->Scale(1./nEvents[iprod]);
305  hShSh[iprod]->Scale(1./nEvents[iprod]);
306 
307  hRaw[iprod]->SetMarkerColor(color[iprod]);
308  hRaw[iprod]->SetMarkerStyle(24);
309 
310  hCorr[iprod]->SetTitle("Cluster spectra with/out cuts");
311  hCorr[iprod]->SetYTitle("1/N_{events} dN/dp_{T}");
312 
313  hCorr[iprod]->SetTitleOffset(1.5,"Y");
314  hCorr[iprod]->SetMarkerColor(color[iprod]);
315  hCorr[iprod]->SetMarkerStyle(20);
316  hCorr[iprod]->SetAxisRange(0.,30.,"X");
317  //hCorr[iprod]->SetMaximum(1.1);
318  //hCorr[iprod]->SetMinimum(0);
319 
320  hTM [iprod]->SetMarkerColor(color[iprod]);
321  hTM [iprod]->SetMarkerStyle(21);
322 
323  hShSh[iprod]->SetMarkerColor(color[iprod]);
324  hShSh[iprod]->SetMarkerStyle(22);
325 
326  hRaw [iprod]->SetTitleOffset(1.5,"Y");
327  hTM [iprod]->SetTitleOffset(1.5,"Y");
328  hShSh[iprod]->SetTitleOffset(1.5,"Y");
329  hCorr[iprod]->SetTitleOffset(1.5,"Y");
330 
331  if(iprod > 0)
332  {
333  hRatRaw [iprod-1] = (TH1F*)hRaw [iprod]->Clone(Form("hRatRaw%s_%s" ,prod[iprod].Data(),histoTag.Data()));
334  hRatCorr[iprod-1] = (TH1F*)hCorr[iprod]->Clone(Form("hRatCorr%s_%s",prod[iprod].Data(),histoTag.Data()));
335  hRatTM [iprod-1] = (TH1F*)hTM [iprod]->Clone(Form("hRatTM%s_%s" ,prod[iprod].Data(),histoTag.Data()));
336  hRatShSh[iprod-1] = (TH1F*)hShSh[iprod]->Clone(Form("hRatShSh%s_%s",prod[iprod].Data(),histoTag.Data()));
337 
338  // hRatRaw [iprod-1]->Divide(hRatRaw [iprod-1],hRaw [0],1.000,1,errType);
339  // hRatCorr[iprod-1]->Divide(hRatCorr[iprod-1],hCorr[0],0.975,1,errType);
340  // hRatTM [iprod-1]->Divide(hRatTM [iprod-1],hTM [0],0.950,1,errType);
341  // hRatShSh[iprod-1]->Divide(hRatShSh[iprod-1],hShSh[0],0.925,1,errType);
342 
343  hRatRaw [iprod-1]->Divide(hRatRaw [iprod-1],hRaw [0],1.000,1,errType);
344  hRatCorr[iprod-1]->Divide(hRatCorr[iprod-1],hCorr[0],1.000,1,errType);
345  hRatTM [iprod-1]->Divide(hRatTM [iprod-1],hTM [0],1.000,1,errType);
346  hRatShSh[iprod-1]->Divide(hRatShSh[iprod-1],hShSh[0],1.000,1,errType);
347  }
348 
349  // Cluster-Track Matching Residuals
350 
351  // E cluster bin
352  h2TrackMatchResEtaNeg[iprod] = (TH2F*) GetHisto(Form("AnaPhoton_Calo%d_hTrackMatchedDEtaNegNoCut",icalo),iprod);
353  h2TrackMatchResEtaPos[iprod] = (TH2F*) GetHisto(Form("AnaPhoton_Calo%d_hTrackMatchedDEtaPosNoCut",icalo),iprod);
354  h2TrackMatchResPhiNeg[iprod] = (TH2F*) GetHisto(Form("AnaPhoton_Calo%d_hTrackMatchedDPhiNegNoCut",icalo),iprod);
355  h2TrackMatchResPhiPos[iprod] = (TH2F*) GetHisto(Form("AnaPhoton_Calo%d_hTrackMatchedDPhiPosNoCut",icalo),iprod);
356 
357  Float_t emin = 0.5;
358  Float_t emax = 2.5;
359  if ( histoTag.Contains("L0") )
360  {
361  emin = 2.5;
362  emax = 5;
363  }
364  else if ( histoTag.Contains("L1") )
365  {
366  emin = 5;
367  emax = 15;
368  }
369  else if ( histoTag.Contains("L2") )
370  {
371  emin = 5;
372  emax = 15;
373  }
374 
375  Float_t binMin = h2TrackMatchResEtaNeg[iprod]->GetXaxis()->FindBin(emin);
376  Float_t binMax = h2TrackMatchResEtaNeg[iprod]->GetXaxis()->FindBin(emax);
377 
378  hTrackMatchResEtaNeg[iprod] =
379  (TH1F*) h2TrackMatchResEtaNeg[iprod]->ProjectionY(Form("TMProjEtaNeg%s_%s",
380  prod[iprod].Data(),histoTag.Data()),binMin, binMax);
381  hTrackMatchResEtaPos[iprod] =
382  (TH1F*) h2TrackMatchResEtaPos[iprod]->ProjectionY(Form("TMProjEtaPos%s_%s",
383  prod[iprod].Data(),histoTag.Data()),binMin, binMax);
384  hTrackMatchResPhiNeg[iprod] =
385  (TH1F*) h2TrackMatchResPhiNeg[iprod]->ProjectionY(Form("TMProjPhiNeg%s_%s",
386  prod[iprod].Data(),histoTag.Data()),binMin, binMax);
387  hTrackMatchResPhiPos[iprod] =
388  (TH1F*) h2TrackMatchResPhiPos[iprod]->ProjectionY(Form("TMProjPhiPos%s_%s",
389  prod[iprod].Data(),histoTag.Data()),binMin, binMax);
390 
391  hTrackMatchResEtaNeg[iprod]->SetXTitle("#Delta #eta");
392  hTrackMatchResEtaNeg[iprod]->SetYTitle("Entries / N events");
393  hTrackMatchResEtaNeg[iprod]->SetTitle(Form("Track-cluster #eta residuals, %2.1f < #it{E}^{cluster} < %2.1f GeV",emin,emax));
394  hTrackMatchResEtaNeg[iprod]->SetAxisRange(-0.025,0.025,"X");
395  hTrackMatchResEtaNeg[iprod]->Sumw2();
396  hTrackMatchResEtaNeg[iprod]->SetMarkerStyle(24);
397  hTrackMatchResEtaNeg[iprod]->SetMarkerColor(color[iprod]);
398 
399  hTrackMatchResEtaPos[iprod]->Sumw2();
400  hTrackMatchResEtaPos[iprod]->SetYTitle("Entries / N events");
401  hTrackMatchResEtaPos[iprod]->SetXTitle("#Delta #eta");
402  hTrackMatchResEtaPos[iprod]->SetTitle(Form("Track-cluster #eta residuals, %2.1f < #it{E}^{cluster} < %2.1f GeV",emin,emax));
403  hTrackMatchResEtaPos[iprod]->SetAxisRange(-0.025,0.025,"X");
404  hTrackMatchResEtaPos[iprod]->SetMarkerStyle(25);
405  hTrackMatchResEtaPos[iprod]->SetMarkerColor(color[iprod]);
406 
407  hTrackMatchResPhiNeg[iprod]->SetXTitle("#Delta #varphi");
408  hTrackMatchResPhiNeg[iprod]->SetTitle(Form("Track-cluster #varphi residuals, %2.1f < #it{E}^{cluster} < %2.1f GeV",emin,emax));
409  hTrackMatchResPhiNeg[iprod]->SetYTitle("entries / N events");
410  hTrackMatchResPhiNeg[iprod]->SetAxisRange(-0.035,0.035,"X");
411  hTrackMatchResPhiNeg[iprod]->Sumw2();
412  hTrackMatchResPhiNeg[iprod]->SetMarkerStyle(24);
413  hTrackMatchResPhiNeg[iprod]->SetMarkerColor(color[iprod]);
414 
415  hTrackMatchResPhiPos[iprod]->Sumw2();
416  hTrackMatchResPhiPos[iprod]->SetYTitle("Entries / N events");
417  hTrackMatchResPhiPos[iprod]->SetXTitle("#Delta #varphi");
418  hTrackMatchResPhiPos[iprod]->SetTitle(Form("Track-cluster #varphi residuals, %2.1f < #it{E}^{cluster} < %2.1f GeV",emin,emax));
419  hTrackMatchResPhiPos[iprod]->SetAxisRange(-0.035,0.035,"X");
420  hTrackMatchResPhiPos[iprod]->SetMarkerStyle(25);
421  hTrackMatchResPhiPos[iprod]->SetMarkerColor(color[iprod]);
422 
423  hTrackMatchResEtaNeg[iprod]->Scale(1./nEvents[iprod]);
424  hTrackMatchResEtaPos[iprod]->Scale(1./nEvents[iprod]);
425  hTrackMatchResPhiNeg[iprod]->Scale(1./nEvents[iprod]);
426  hTrackMatchResPhiPos[iprod]->Scale(1./nEvents[iprod]);
427 
428  hTrackMatchResEtaNeg[iprod]->SetTitleOffset(1.5,"Y");
429  hTrackMatchResEtaPos[iprod]->SetTitleOffset(1.5,"Y");
430  hTrackMatchResPhiNeg[iprod]->SetTitleOffset(1.5,"Y");
431  hTrackMatchResPhiPos[iprod]->SetTitleOffset(1.5,"Y");
432 
433  if(iprod > 0)
434  {
435  hRatTrackMatchResPhiPos[iprod-1] =
436  (TH1F*)hTrackMatchResPhiPos[iprod]->Clone(Form("hRatPhiPos%s_%s",prod[iprod].Data(),histoTag.Data()));
437  hRatTrackMatchResPhiNeg[iprod-1] =
438  (TH1F*)hTrackMatchResPhiNeg[iprod]->Clone(Form("hRatPhiNeg%s_%s",prod[iprod].Data(),histoTag.Data()));
439  hRatTrackMatchResEtaPos[iprod-1] =
440  (TH1F*)hTrackMatchResEtaPos[iprod]->Clone(Form("hRatEtaPos%s_%s",prod[iprod].Data(),histoTag.Data()));
441  hRatTrackMatchResEtaNeg[iprod-1] =
442  (TH1F*)hTrackMatchResEtaNeg[iprod]->Clone(Form("hRatEtaNeg%s_%s",prod[iprod].Data(),histoTag.Data()));
443 
444  hRatTrackMatchResPhiPos[iprod-1]->Divide(hRatTrackMatchResPhiPos[iprod-1],hTrackMatchResPhiPos[0],1.000,1,errType);
445  hRatTrackMatchResPhiNeg[iprod-1]->Divide(hRatTrackMatchResPhiNeg[iprod-1],hTrackMatchResPhiNeg[0],1.000,1,errType);
446  hRatTrackMatchResEtaPos[iprod-1]->Divide(hRatTrackMatchResEtaPos[iprod-1],hTrackMatchResEtaPos[0],1.000,1,errType);
447  hRatTrackMatchResEtaNeg[iprod-1]->Divide(hRatTrackMatchResEtaNeg[iprod-1],hTrackMatchResEtaNeg[0],1.000,1,errType);
448  }
449 
450  // pt track bin
451  h2TrackMatchResEtaNegTrackPt[iprod] = (TH2F*) GetHisto(Form("AnaPhoton_Calo%d_hTrackMatchedDEtaNegTrackPtNoCut",icalo),iprod);
452  h2TrackMatchResEtaPosTrackPt[iprod] = (TH2F*) GetHisto(Form("AnaPhoton_Calo%d_hTrackMatchedDEtaPosTrackPtNoCut",icalo),iprod);
453  h2TrackMatchResPhiNegTrackPt[iprod] = (TH2F*) GetHisto(Form("AnaPhoton_Calo%d_hTrackMatchedDPhiNegTrackPtNoCut",icalo),iprod);
454  h2TrackMatchResPhiPosTrackPt[iprod] = (TH2F*) GetHisto(Form("AnaPhoton_Calo%d_hTrackMatchedDPhiPosTrackPtNoCut",icalo),iprod);
455 
456  if ( !h2TrackMatchResEtaNegTrackPt[iprod] ) continue;
457 
458  binMin = h2TrackMatchResEtaNegTrackPt[iprod]->GetXaxis()->FindBin(emin);
459  binMax = h2TrackMatchResEtaNegTrackPt[iprod]->GetXaxis()->FindBin(emax);
460 
461  hTrackMatchResEtaNegTrackPt[iprod] =
462  (TH1F*) h2TrackMatchResEtaNegTrackPt[iprod]->ProjectionY(Form("TMProjEtaNegTrackPt%s_%s",
463  prod[iprod].Data(),histoTag.Data()),binMin, binMax);
464  hTrackMatchResEtaPosTrackPt[iprod] =
465  (TH1F*) h2TrackMatchResEtaPosTrackPt[iprod]->ProjectionY(Form("TMProjEtaPosTrackPt%s_%s",
466  prod[iprod].Data(),histoTag.Data()),binMin, binMax);
467  hTrackMatchResPhiNegTrackPt[iprod] =
468  (TH1F*) h2TrackMatchResPhiNegTrackPt[iprod]->ProjectionY(Form("TMProjPhiNegTrackPt%s_%s",
469  prod[iprod].Data(),histoTag.Data()),binMin, binMax);
470  hTrackMatchResPhiPosTrackPt[iprod] =
471  (TH1F*) h2TrackMatchResPhiPosTrackPt[iprod]->ProjectionY(Form("TMProjPhiPosTrackPt%s_%s",
472  prod[iprod].Data(),histoTag.Data()),binMin, binMax);
473 
474  hTrackMatchResEtaNegTrackPt[iprod]->SetXTitle("#Delta #eta");
475  hTrackMatchResEtaNegTrackPt[iprod]->SetYTitle("Entries / N events");
476  hTrackMatchResEtaNegTrackPt[iprod]->SetTitle(Form("Track-cluster #eta residuals, %2.1f < #it{p}_{T}^{track} < %2.1f GeV",emin,emax));
477  hTrackMatchResEtaNegTrackPt[iprod]->SetAxisRange(-0.025,0.025,"X");
478  hTrackMatchResEtaNegTrackPt[iprod]->Sumw2();
479  hTrackMatchResEtaNegTrackPt[iprod]->SetMarkerStyle(24);
480  hTrackMatchResEtaNegTrackPt[iprod]->SetMarkerColor(color[iprod]);
481 
482  hTrackMatchResEtaPosTrackPt[iprod]->Sumw2();
483  hTrackMatchResEtaPosTrackPt[iprod]->SetYTitle("Entries / N events");
484  hTrackMatchResEtaPosTrackPt[iprod]->SetXTitle("#Delta #eta");
485  hTrackMatchResEtaPosTrackPt[iprod]->SetTitle(Form("Track-cluster #eta residuals, %2.1f < #it{p}_{T}^{track} < %2.1f GeV",emin,emax));
486  hTrackMatchResEtaPosTrackPt[iprod]->SetAxisRange(-0.025,0.025,"X");
487  hTrackMatchResEtaPosTrackPt[iprod]->SetMarkerStyle(25);
488  hTrackMatchResEtaPosTrackPt[iprod]->SetMarkerColor(color[iprod]);
489 
490  hTrackMatchResPhiNegTrackPt[iprod]->SetXTitle("#Delta #varphi");
491  hTrackMatchResPhiNegTrackPt[iprod]->SetTitle(Form("Track-cluster #varphi residuals, %2.1f < #it{p}_{T}^{track} < %2.1f GeV",emin,emax));
492  hTrackMatchResPhiNegTrackPt[iprod]->SetYTitle("entries / N events");
493  hTrackMatchResPhiNegTrackPt[iprod]->SetAxisRange(-0.035,0.035,"X");
494  hTrackMatchResPhiNegTrackPt[iprod]->Sumw2();
495  hTrackMatchResPhiNegTrackPt[iprod]->SetMarkerStyle(24);
496  hTrackMatchResPhiNegTrackPt[iprod]->SetMarkerColor(color[iprod]);
497 
498  hTrackMatchResPhiPosTrackPt[iprod]->Sumw2();
499  hTrackMatchResPhiPosTrackPt[iprod]->SetYTitle("Entries / N events");
500  hTrackMatchResPhiPosTrackPt[iprod]->SetXTitle("#Delta #varphi");
501  hTrackMatchResPhiPosTrackPt[iprod]->SetTitle(Form("Track-cluster #varphi residuals, %2.1f < #it{p}_{T}^{track} < %2.1f GeV",emin,emax));
502  hTrackMatchResPhiPosTrackPt[iprod]->SetAxisRange(-0.035,0.035,"X");
503  hTrackMatchResPhiPosTrackPt[iprod]->SetMarkerStyle(25);
504  hTrackMatchResPhiPosTrackPt[iprod]->SetMarkerColor(color[iprod]);
505 
506  hTrackMatchResEtaNegTrackPt[iprod]->Scale(1./nEvents[iprod]);
507  hTrackMatchResEtaPosTrackPt[iprod]->Scale(1./nEvents[iprod]);
508  hTrackMatchResPhiNegTrackPt[iprod]->Scale(1./nEvents[iprod]);
509  hTrackMatchResPhiPosTrackPt[iprod]->Scale(1./nEvents[iprod]);
510 
511  hTrackMatchResEtaNegTrackPt[iprod]->SetTitleOffset(1.5,"Y");
512  hTrackMatchResEtaPosTrackPt[iprod]->SetTitleOffset(1.5,"Y");
513  hTrackMatchResPhiNegTrackPt[iprod]->SetTitleOffset(1.5,"Y");
514  hTrackMatchResPhiPosTrackPt[iprod]->SetTitleOffset(1.5,"Y");
515 
516  if(iprod > 0)
517  {
518  hRatTrackMatchResPhiPosTrackPt[iprod-1] =
519  (TH1F*)hTrackMatchResPhiPosTrackPt[iprod]->Clone(Form("hRatPhiPos%s_%s",prod[iprod].Data(),histoTag.Data()));
520  hRatTrackMatchResPhiNegTrackPt[iprod-1] =
521  (TH1F*)hTrackMatchResPhiNegTrackPt[iprod]->Clone(Form("hRatPhiNeg%s_%s",prod[iprod].Data(),histoTag.Data()));
522  hRatTrackMatchResEtaPosTrackPt[iprod-1] =
523  (TH1F*)hTrackMatchResEtaPosTrackPt[iprod]->Clone(Form("hRatEtaPos%s_%s",prod[iprod].Data(),histoTag.Data()));
524  hRatTrackMatchResEtaNegTrackPt[iprod-1] =
525  (TH1F*)hTrackMatchResEtaNegTrackPt[iprod]->Clone(Form("hRatEtaNeg%s_%s",prod[iprod].Data(),histoTag.Data()));
526 
527  hRatTrackMatchResPhiPosTrackPt[iprod-1]->Divide(hRatTrackMatchResPhiPosTrackPt[iprod-1],hTrackMatchResPhiPosTrackPt[0],1.000,1,errType);
528  hRatTrackMatchResPhiNegTrackPt[iprod-1]->Divide(hRatTrackMatchResPhiNegTrackPt[iprod-1],hTrackMatchResPhiNegTrackPt[0],1.000,1,errType);
529  hRatTrackMatchResEtaPosTrackPt[iprod-1]->Divide(hRatTrackMatchResEtaPosTrackPt[iprod-1],hTrackMatchResEtaPosTrackPt[0],1.000,1,errType);
530  hRatTrackMatchResEtaNegTrackPt[iprod-1]->Divide(hRatTrackMatchResEtaNegTrackPt[iprod-1],hTrackMatchResEtaNegTrackPt[0],1.000,1,errType);
531  }
532 
533  } // prod loop
534 
535 
537  // Make the plots
539  {
540  TCanvas * ccalo = new TCanvas(Form("Cluster_%s",histoTag.Data()),"",1000,500);
541  ccalo->Divide(2,1);
542 
543  ccalo->cd(1);
544  gPad->SetLogy();
545  //gPad->SetLogx();
546 
547  hCorr[0]->Draw();
548  for(Int_t iprod = 0; iprod < nProd; iprod++)
549  {
550  hRaw [iprod]->Draw("same");
551  hCorr[iprod]->Draw("same");
552  hTM [iprod]->Draw("same");
553  hShSh[iprod]->Draw("same");
554 
555  lprod.AddEntry(hRaw[iprod],prodLeg[iprod],"P");
556  }
557 
558  lprod.Draw();
559 
560  TLegend lcl(0.55,0.7,0.95,0.89);
561  lcl.SetTextSize(0.04);
562  lcl.SetBorderSize(0);
563  lcl.SetFillColor(0);
564  lcl.AddEntry(hRaw [0],"Raw","P");
565  lcl.AddEntry(hCorr[0],"No Exotics + non lin.","P");
566  lcl.AddEntry(hTM [0], "+ Track matching","P");
567  lcl.AddEntry(hShSh[0],"+ #lambda^{2}_{0} < 0.4","P");
568  lcl.Draw();
569 
570  ccalo->cd(2);
571  gPad->SetGridy();
572  //gPad->SetLogy();
573  //gPad->SetLogx();
574 
575  hRatCorr[0]->SetTitle("Cluster spectra ratio");
576  hRatCorr[0]->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
577  // hRatCorr[0]->SetMinimum(0.850);
578  // hRatCorr[0]->SetMaximum(1.025);
579  hRatCorr[0]->SetMinimum(0.7);
580  hRatCorr[0]->SetMaximum(1.3);
581  hRatCorr[0]->Draw("");
582 
583  for(Int_t iprod = 0; iprod < nProd-1; iprod++)
584  {
585  hRatRaw [iprod]->Draw("same");
586  hRatCorr[iprod]->Draw("same");
587  hRatTM [iprod]->Draw("same");
588  hRatShSh[iprod]->Draw("same");
589  }
590 
591  // TLine l1(0,1,30,1);
592  // TLine l2(0,0.975,30,0.975);
593  // TLine l3(0,0.95,30,0.95);
594  // TLine l4(0,0.925,30,0.925);
595  //
596  // l1.Draw("same");
597  // l2.Draw("same");
598  // l3.Draw("same");
599  // l4.Draw("same");
600 
601  ccalo->Print(Form("%s_ClusterSpectraComp.%s",histoTag.Data(),format.Data()));
602  }
603 
604  // Cluster-Track Matching Residual
605  {
606  TGaxis::SetMaxDigits(3);
607 
608  TLegend lres(0.6,0.75,0.84,0.89);
609  lres.SetTextSize(0.04);
610  //lres.SetBorderSize(0);
611  lres.SetFillColor(0);
612  lres.AddEntry(hTrackMatchResEtaNeg[0],"Negative","P");
613  lres.AddEntry(hTrackMatchResEtaPos[0],"Positive","P");
614  lres.Draw();
615 
616  TCanvas * ccalo2 = new TCanvas(Form("MatchingResiduals_%s",histoTag.Data()),"",1000,1000);
617  ccalo2->Divide(2,2);
618 
619  ccalo2->cd(1);
620  //gPad->SetLogy();
621 
622  Double_t max = hTrackMatchResEtaPos[0]->GetMaximum();
623  if(max < hTrackMatchResEtaNeg[0]->GetMaximum()) max = hTrackMatchResEtaNeg[0]->GetMaximum();
624 
625  hTrackMatchResEtaPos[0]->SetMaximum(max*1.2);
626 
627  hTrackMatchResEtaPos[0]->Draw("");
628  for(Int_t iprod = 0; iprod < nProd; iprod++)
629  {
630  hTrackMatchResEtaNeg[iprod]->Draw("same");
631  hTrackMatchResEtaPos[iprod]->Draw("same");
632  }
633 
634  TLine l0Eta(0,hTrackMatchResEtaPos[0]->GetMinimum(),0,hTrackMatchResEtaPos[0]->GetMaximum());
635  l0Eta.SetLineColor(2);
636  l0Eta.SetLineWidth(2);
637  l0Eta.Draw("same");
638 
639  lres.Draw();
640  lprod.Draw();
641  ccalo2->cd(2);
642 
643  max = hTrackMatchResPhiPos[0]->GetMaximum();
644  if(max < hTrackMatchResPhiNeg[0]->GetMaximum()) max = hTrackMatchResPhiNeg[0]->GetMaximum();
645 
646  hTrackMatchResPhiPos[0]->SetMaximum(max*1.2);
647 
648  hTrackMatchResPhiPos[0]->Draw("");
649  for(Int_t iprod = 0; iprod < nProd; iprod++)
650  {
651  hTrackMatchResPhiNeg[iprod]->Draw("same");
652  hTrackMatchResPhiPos[iprod]->Draw("same");
653  }
654 
655  TLine l0Phi(0,hTrackMatchResPhiPos[0]->GetMinimum(),0,hTrackMatchResPhiPos[0]->GetMaximum());
656  l0Phi.SetLineColor(2);
657  l0Phi.SetLineWidth(2);
658  l0Phi.Draw("same");
659 
660  ccalo2->cd(3);
661  //gPad->SetLogy();
662 
663  hRatTrackMatchResEtaPos[0]->SetMaximum(1.3);
664  hRatTrackMatchResEtaPos[0]->SetMinimum(0.9);
665  hRatTrackMatchResEtaPos[0]->Draw("");
666  hRatTrackMatchResEtaPos[0]->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
667  for(Int_t iprod = 0; iprod < nProd-1; iprod++)
668  {
669  hRatTrackMatchResEtaNeg[iprod]->Draw("same");
670  hRatTrackMatchResEtaPos[iprod]->Draw("same");
671  }
672 
673  //l0.Draw("same");
674 
675  ccalo2->cd(4);
676 
677  hRatTrackMatchResPhiPos[0]->SetMaximum(1.3);
678  hRatTrackMatchResPhiPos[0]->SetMinimum(0.9);
679  hRatTrackMatchResPhiPos[0]->Draw("");
680  hRatTrackMatchResPhiPos[0]->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
681  for(Int_t iprod = 0; iprod < nProd-1; iprod++)
682  {
683  hRatTrackMatchResPhiNeg[iprod]->Draw("same");
684  hRatTrackMatchResPhiPos[iprod]->Draw("same");
685  }
686 
687  ccalo2->Print(Form("%s_MatchingResidualsComp.%s",histoTag.Data(),format.Data()));
688  }
689 
690  // Cluster-Track Matching Residual, pT track bin
691  if ( h2TrackMatchResEtaNegTrackPt[0] )
692  {
693  TGaxis::SetMaxDigits(3);
694 
695  TLine l0Eta(0,hTrackMatchResEtaNeg[0]->GetMinimum(),0,hTrackMatchResEtaNeg[0]->GetMaximum());
696 
697  TLegend lres(0.6,0.75,0.84,0.89);
698  lres.SetTextSize(0.04);
699  //lres.SetBorderSize(0);
700  lres.SetFillColor(0);
701  lres.AddEntry(hTrackMatchResEtaNeg[0],"Negative","P");
702  lres.AddEntry(hTrackMatchResEtaPos[0],"Positive","P");
703  lres.Draw();
704 
705  TCanvas * ccalo3 = new TCanvas(Form("MatchingResiduals_TrackPtBin_%s",histoTag.Data()),"",1000,1000);
706  ccalo3->Divide(2,2);
707 
708  ccalo3->cd(1);
709  //gPad->SetLogy();
710 
711  hTrackMatchResEtaPosTrackPt[0]->SetMaximum(hTrackMatchResEtaPosTrackPt[0]->GetMaximum()*1.3);
712 
713  hTrackMatchResEtaPosTrackPt[0]->Draw("");
714  for(Int_t iprod = 0; iprod < nProd; iprod++)
715  {
716  hTrackMatchResEtaNegTrackPt[iprod]->Draw("same");
717  hTrackMatchResEtaPosTrackPt[iprod]->Draw("same");
718  }
719 
720  l0Eta.SetLineColor(2);
721  l0Eta.SetLineWidth(2);
722  l0Eta.Draw("same");
723 
724  lres.Draw();
725  lprod.Draw();
726  ccalo3->cd(2);
727 
728  hTrackMatchResPhiPosTrackPt[0]->Draw("");
729  for(Int_t iprod = 0; iprod < nProd; iprod++)
730  {
731  hTrackMatchResPhiNegTrackPt[iprod]->Draw("same");
732  hTrackMatchResPhiPosTrackPt[iprod]->Draw("same");
733  }
734 
735  TLine l0Phi(0,hTrackMatchResPhiNegTrackPt[0]->GetMinimum(),0,hTrackMatchResPhiNegTrackPt[0]->GetMaximum());
736  l0Phi.SetLineColor(2);
737  l0Phi.SetLineWidth(2);
738  l0Phi.Draw("same");
739 
740  ccalo3->cd(3);
741  //gPad->SetLogy();
742 
743  hRatTrackMatchResEtaPosTrackPt[0]->SetMaximum(1.2);
744  hRatTrackMatchResEtaPosTrackPt[0]->SetMinimum(0.8);
745  hRatTrackMatchResEtaPosTrackPt[0]->Draw("");
746  hRatTrackMatchResEtaPosTrackPt[0]->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
747  for(Int_t iprod = 0; iprod < nProd-1; iprod++)
748  {
749  hRatTrackMatchResEtaNegTrackPt[iprod]->Draw("same");
750  hRatTrackMatchResEtaPosTrackPt[iprod]->Draw("same");
751  }
752 
753  //l0.Draw("same");
754 
755  ccalo3->cd(4);
756 
757  hRatTrackMatchResPhiPosTrackPt[0]->SetMaximum(1.2);
758  hRatTrackMatchResPhiPosTrackPt[0]->SetMinimum(0.8);
759  hRatTrackMatchResPhiPosTrackPt[0]->Draw("");
760  hRatTrackMatchResPhiPosTrackPt[0]->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
761  for(Int_t iprod = 0; iprod < nProd-1; iprod++)
762  {
763  hRatTrackMatchResPhiNegTrackPt[iprod]->Draw("same");
764  hRatTrackMatchResPhiPosTrackPt[iprod]->Draw("same");
765  }
766 
767  ccalo3->Print(Form("%s_MatchingResidualsTrackPtBinComp.%s",histoTag.Data(),format.Data()));
768  }
769 }
770 
777 //______________________________________
778 void Cell()
779 {
780  // Declare the different histograms, arrays input is production
781  TH1F* hNC1[nProd];
782  TH1F* hNC2[nProd];
783  TH1F* hAmp[nProd];
784 
785  TH1F* hRatNC1[nProd-1];
786  TH1F* hRatNC2[nProd-1];
787  TH1F* hRatAmp[nProd-1];
788 
789  //Legend for productions
790  TLegend lprod(0.65,0.525,0.95,0.675);
791  lprod.SetTextSize(0.04);
792  lprod.SetBorderSize(0);
793  lprod.SetFillColor(0);
794 
795  for(Int_t iprod = 0; iprod < nProd; iprod++)
796  {
797  hAmp[iprod] = (TH1F*) GetHisto("QA_Cell_hAmplitude",iprod);
798  hNC1[iprod] = (TH1F*) GetHisto("QA_Cell_hNCells",iprod);
799  hNC2[iprod] = (TH1F*) GetHisto("QA_Cell_hNCellsCutAmpMin",iprod);
800 
801  if(!hAmp[iprod]) return;
802 
803  hAmp[iprod]->Rebin(2);
804  hNC1[iprod]->Rebin(2);
805  hNC2[iprod]->Rebin(2);
806 
807  hAmp[iprod]->Sumw2();
808  hNC1[iprod]->Sumw2();
809  hNC2[iprod]->Sumw2();
810 
811  hAmp[iprod]->Scale(1./nEvents[iprod]);
812  hNC1[iprod]->Scale(1./nEvents[iprod]);
813  hNC2[iprod]->Scale(1./nEvents[iprod]);
814 
815  hAmp[iprod]->SetMarkerColor(color[iprod]);
816  hAmp[iprod]->SetMarkerStyle(20);
817  hAmp[iprod]->SetTitle("Cell energy spectra");
818  hAmp[iprod]->SetYTitle("1/N_{events} dN/dp_{T}");
819  hAmp[iprod]->SetTitleOffset(1.5,"Y");
820  hAmp[iprod]->SetAxisRange(0.,10.,"X");
821 // hAmp[iprod]->SetMaximum(5);
822 // hAmp[iprod]->SetMinimum(1e-10);
823 
824 
825  hNC1[iprod]->SetTitle("Number of EMCal/DCal cells");
826  hNC1[iprod]->SetYTitle("1/N_{events} dN/dp_{T}");
827 
828  hNC1[iprod]->SetTitleOffset(1.5,"Y");
829  hNC1[iprod]->SetMarkerColor(color[iprod]);
830  hNC1[iprod]->SetMarkerStyle(20);
831  hNC1[iprod]->SetAxisRange(0.,100.,"X");
832  hNC1[iprod]->SetMaximum(5);
833  hNC1[iprod]->SetMinimum(1e-10);
834 
835  hNC2[iprod]->SetMarkerColor(color[iprod]);
836  hNC2[iprod]->SetMarkerStyle(21);
837 
838 
839  hAmp[iprod]->SetTitleOffset(1.5,"Y");
840  hNC2[iprod]->SetTitleOffset(1.5,"Y");
841  hNC1[iprod]->SetTitleOffset(1.5,"Y");
842 
843  if(iprod > 0)
844  {
845  hRatAmp[iprod-1] = (TH1F*)hAmp[iprod]->Clone(Form("hRatAmp%s_%s",prod[iprod].Data(),histoTag.Data()));
846  hRatNC1[iprod-1] = (TH1F*)hNC1[iprod]->Clone(Form("hRatNC1%s_%s",prod[iprod].Data(),histoTag.Data()));
847  hRatNC2[iprod-1] = (TH1F*)hNC2[iprod]->Clone(Form("hRatNC2%s_%s",prod[iprod].Data(),histoTag.Data()));
848 
849  // hRatAmp[iprod-1]->Divide(hRatAmp [iprod-1],hAmp [0],1.000,1,errType);
850  // hRatNC1[iprod-1]->Divide(hRatNC1[iprod-1],hNC1[0],0.975,1,errType);
851  // hRatNC2[iprod-1]->Divide(hRatNC2 [iprod-1],hNC2 [0],0.950,1,errType);
852 
853  hRatAmp[iprod-1]->Divide(hRatAmp[iprod-1],hAmp[0],1.000,1,errType);
854  hRatNC1[iprod-1]->Divide(hRatNC1[iprod-1],hNC1[0],1.000,1,errType);
855  hRatNC2[iprod-1]->Divide(hRatNC2[iprod-1],hNC2[0],1.000,1,errType);
856  }
857 
858  } // prod loop
859 
860 
862  // Make the plots
864  {
865  TCanvas * cn = new TCanvas(Form("NCell_%s",histoTag.Data()),"",1000,500);
866  cn->Divide(2,1);
867 
868  cn->cd(1);
869  gPad->SetLogy();
870  //gPad->SetLogx();
871 
872  hNC1[0]->Draw();
873  for(Int_t iprod = 0; iprod < nProd; iprod++)
874  {
875  hNC1[iprod]->Draw("same");
876  hNC2[iprod]->Draw("same");
877 
878  lprod.AddEntry(hNC1[iprod],prodLeg[iprod],"P");
879  }
880 
881  lprod.Draw();
882 
883  TLegend lcl(0.55,0.7,0.95,0.89);
884  lcl.SetTextSize(0.04);
885  lcl.SetBorderSize(0);
886  lcl.SetFillColor(0);
887  lcl.AddEntry(hNC1[0],"E > 50 MeV","P");
888  lcl.AddEntry(hNC2[0],"E > 200 MeV","P");
889  lcl.Draw();
890 
891  cn->cd(2);
892  gPad->SetGridy();
893  //gPad->SetLogy();
894  //gPad->SetLogx();
895 
896  hRatNC1[0]->SetTitle("N cell ratio");
897  hRatNC1[0]->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
898 // hRatNC1[0]->SetMinimum(0.850);
899 // hRatNC1[0]->SetMaximum(1.025);
900  hRatNC1[0]->SetMinimum(0.7);
901  hRatNC1[0]->SetMaximum(1.3);
902  hRatNC1[0]->Draw("");
903 
904  for(Int_t iprod = 0; iprod < nProd-1; iprod++)
905  {
906  hRatNC1[iprod]->Draw("same");
907  hRatNC2[iprod]->Draw("same");
908  }
909 
910  cn->Print(Form("%s_NCellComp.%s",histoTag.Data(),format.Data()));
911  }
912 
913  {
914  TCanvas * cE = new TCanvas(Form("Cell_Energy_%s",histoTag.Data()),"",1000,500);
915  cE->Divide(2,1);
916 
917  cE->cd(1);
918  gPad->SetLogy();
919  //gPad->SetLogx();
920 
921  hAmp[0]->Draw();
922  for(Int_t iprod = 0; iprod < nProd; iprod++)
923  {
924  hAmp[iprod]->Draw("same");
925  }
926 
927  lprod.Draw();
928 
929 
930  cE->cd(2);
931  gPad->SetGridy();
932  //gPad->SetLogy();
933  //gPad->SetLogx();
934 
935  hRatAmp[0]->SetTitle("Cell E spectra ratio");
936  hRatAmp[0]->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
937  // hRatAmp[0]->SetMinimum(0.850);
938  // hRatAmp[0]->SetMaximum(1.025);
939  hRatAmp[0]->SetMinimum(0.7);
940  hRatAmp[0]->SetMaximum(1.3);
941  hRatAmp[0]->Draw("");
942 
943  for(Int_t iprod = 0; iprod < nProd-1; iprod++)
944  {
945  hRatAmp[iprod]->Draw("same");
946  }
947 
948  cE->Print(Form("%s_CellEnergyComp.%s",histoTag.Data(),format.Data()));
949  }
950 
951 }
952 
957 //______________________________________
958 void ClusterCells(Int_t icalo)
959 {
960  // Declare the different histograms, arrays input is production
961 
962  const Int_t nEbins = 4;
963  Float_t ebins [] = {2,4,6,8,10,12,16,20};
964 
965  TH2F* h2NCell [nProd];
966  TH1F* hNCell [nProd][nEbins];
967  TH1F* hNCellRat[nProd][nEbins];
968  TH2F* h2ECell [nProd];
969  TH1F* hECell [nProd][nEbins];
970  TH1F* hECellRat[nProd][nEbins];
971 
972  //Legend for productions
973  TLegend lprod(0.6,0.7,0.95,0.89);
974  lprod.SetTextSize(0.04);
975  lprod.SetBorderSize(0);
976  lprod.SetFillColor(0);
977 
978  for(Int_t iprod = 0; iprod < nProd; iprod++)
979  {
980  // E cluster bin
981  h2NCell[iprod] = (TH2F*) GetHisto(Form("AnaPhoton_Calo%d_hNCellsE",icalo),iprod);
982  h2ECell[iprod] = (TH2F*) GetHisto(Form("AnaPhoton_Calo%d_hCellsE" ,icalo),iprod);
983 
984  if(!h2NCell[iprod] || !h2ECell[iprod]) return;
985 
986  for(Int_t ie = 0; ie < nEbins; ie++)
987  {
988  Float_t binMin = h2NCell[iprod]->GetXaxis()->FindBin(ebins[ie]);
989  Float_t binMax = h2NCell[iprod]->GetXaxis()->FindBin(ebins[ie+1])-1;
990 
991  hNCell[iprod][ie] =
992  (TH1F*) h2NCell[iprod]->ProjectionY(Form("DeltaProjNCell_%s_MC%s_ie%d",
993  prod[iprod].Data(),histoTag.Data(),ie),
994  binMin, binMax);
995 
996  hECell[iprod][ie] =
997  (TH1F*) h2ECell[iprod]->ProjectionY(Form("DeltaProjECell_%s_MC%s_ie%d",
998  prod[iprod].Data(),histoTag.Data(),ie),
999  binMin, binMax);
1000 
1001  //hNCell[iprod][ie]->SetXTitle("#it{E}_{reco}-#it{E}_{gen} (GeV)");
1002  hNCell[iprod][ie]->SetYTitle("Entries / N events");
1003  hNCell[iprod][ie]->SetTitle(Form("%2.1f < #it{E}^{cluster} < %2.1f GeV",ebins[ie],ebins[ie+1]));
1004  hNCell[iprod][ie]->SetAxisRange(0.,15,"X");
1005  hNCell[iprod][ie]->Sumw2();
1006  //hNCell[iprod][ie]->SetMarkerStyle(24);
1007  hNCell[iprod][ie]->SetMarkerColor(color[iprod]);
1008  hNCell[iprod][ie]->SetLineColor (color[iprod]);
1009 
1010  hNCell[iprod][ie]->Scale(1./nEvents[iprod]);
1011 
1012  hNCell[iprod][ie]->SetTitleOffset(1.5,"Y");
1013 
1014  //hECell[iprod][ie]->SetXTitle("#it{E}_{reco}-#it{E}_{gen} (GeV)");
1015  hECell[iprod][ie]->SetYTitle("Entries / N events");
1016  hECell[iprod][ie]->SetTitle(Form("%2.1f < #it{E}^{cluster} < %2.1f GeV",ebins[ie],ebins[ie+1]));
1017  hECell[iprod][ie]->SetAxisRange(0.0,ebins[ie+1],"X");
1018  hECell[iprod][ie]->Sumw2();
1019  //hECell[iprod][ie]->SetMarkerStyle(24);
1020  hECell[iprod][ie]->SetMarkerColor(color[iprod]);
1021  hECell[iprod][ie]->SetLineColor (color[iprod]);
1022 
1023  hECell[iprod][ie]->Scale(1./nEvents[iprod]);
1024 
1025  hECell[iprod][ie]->SetTitleOffset(1.5,"Y");
1026 
1027  if(iprod > 0)
1028  {
1029  hECellRat[iprod][ie] = (TH1F*) hECell[iprod][ie]->Clone(Form("Ratio_%s",hECell[iprod][ie]->GetName()));
1030  hNCellRat[iprod][ie] = (TH1F*) hNCell[iprod][ie]->Clone(Form("Ratio_%s",hNCell[iprod][ie]->GetName()));
1031 
1032  hECellRat[iprod][ie]->Divide(hECell[iprod][ie],hECell[0][ie],1,1,errType);
1033  hNCellRat[iprod][ie]->Divide(hNCell[iprod][ie],hNCell[0][ie],1,1,errType);
1034  }
1035  else
1036  {
1037  hECellRat[iprod][ie] = 0;
1038  hNCellRat[iprod][ie] = 0;
1039  }
1040  }
1041 
1042  lprod.AddEntry(hNCell[iprod][0],prodLeg[iprod],"LP");
1043 
1044  } // prod loop
1045 
1046 
1048  // Make the plots
1050 
1051  {
1052  TGaxis::SetMaxDigits(3);
1053 
1054  TCanvas * cNCell = new TCanvas(Form("NCell_%s",histoTag.Data()),"",1000,1000);
1055  cNCell->Divide(2,2);
1056 
1057  for(Int_t ie = 0; ie < nEbins; ie++)
1058  {
1059  cNCell->cd(ie+1);
1060  gPad->SetLogy();
1061 
1062  hNCell[0][ie]->Draw("H");
1063  for(Int_t iprod = 0; iprod < nProd; iprod++)
1064  {
1065  hNCell[iprod][ie]->Draw("Hsame");
1066  }
1067 
1068  lprod.Draw();
1069  }
1070 
1071  cNCell->Print(Form("%s_NCell.%s",histoTag.Data(),format.Data()));
1072 
1073  TCanvas * cECell = new TCanvas(Form("ECell_%s",histoTag.Data()),"",1000,1000);
1074  cECell->Divide(2,2);
1075 
1076  for(Int_t ie = 0; ie < nEbins; ie++)
1077  {
1078  cECell->cd(ie+1);
1079  gPad->SetLogy();
1080 
1081  hECell[0][ie]->Draw("H");
1082  for(Int_t iprod = 0; iprod < nProd; iprod++)
1083  {
1084  hECell[iprod][ie]->Draw("Hsame");
1085  }
1086 
1087  lprod.Draw();
1088  }
1089 
1090  cECell->Print(Form("%s_ECell.%s",histoTag.Data(),format.Data()));
1091 
1092  // RATIOS
1093 
1094  TCanvas * cNCellR = new TCanvas(Form("RatioNCell_%s",histoTag.Data()),"",1000,1000);
1095  cNCellR->Divide(2,2);
1096 
1097  for(Int_t ie = 0; ie < nEbins; ie++)
1098  {
1099  cNCellR->cd(ie+1);
1100  //gPad->SetLogy();
1101 
1102  hNCellRat[1][ie]->Draw("H");
1103  hNCellRat[1][ie]->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
1104  //hNCellRat[1][ie]->SetMaximum(1.2);
1105  //hNCellRat[1][ie]->SetMinimum(0.6);
1106  for(Int_t iprod = 1; iprod < nProd; iprod++)
1107  {
1108  hNCellRat[iprod][ie]->Draw("Hsame");
1109  }
1110 
1111  lprod.Draw();
1112  }
1113 
1114  cNCellR->Print(Form("%s_NCell_Ratio.%s",histoTag.Data(),format.Data()));
1115 
1116  TCanvas * cECellR = new TCanvas(Form("RatioECell_%s",histoTag.Data()),"",1000,1000);
1117  cECellR->Divide(2,2);
1118 
1119  for(Int_t ie = 0; ie < nEbins; ie++)
1120  {
1121  cECellR->cd(ie+1);
1122  //gPad->SetLogy();
1123 
1124  hECellRat[1][ie]->Draw("H");
1125  hECellRat[1][ie]->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
1126  hECellRat[1][ie]->SetMaximum(1.2);
1127  hECellRat[1][ie]->SetMinimum(0.6);
1128  for(Int_t iprod = 1; iprod < nProd; iprod++)
1129  {
1130  hECellRat[iprod][ie]->Draw("Hsame");
1131  }
1132 
1133  lprod.Draw();
1134  }
1135 
1136  cECellR->Print(Form("%s_ECell_Ratio.%s",histoTag.Data(),format.Data()));
1137 
1138  }
1139 }
1140 
1141 
1149 //______________________________________
1150 void MCParticle(Int_t icalo, TString particle)
1151 {
1152  // Declare the different histograms, arrays input is production
1153 
1154  const Int_t nEbins = 4;
1155  Float_t ebins [] = {1,2,4,6,10};
1156 
1157  TH1F* hParticleRecoE[nProd];
1158  TH1F* hRatParticleRecoE [nProd-1];
1159 
1160  TH2F* h2ParticleRecoEDelta[nProd];
1161  TH1F* hParticleRecoEDelta[nProd][nEbins];
1162 
1163  //Legend for productions
1164  TLegend lprod(0.6,0.475,0.95,0.675);
1165  lprod.SetTextSize(0.04);
1166  lprod.SetBorderSize(0);
1167  lprod.SetFillColor(0);
1168 
1169  for(Int_t iprod = 0; iprod < nProd; iprod++)
1170  {
1171  hParticleRecoE [iprod] = (TH1F*) GetHisto(Form("AnaPhoton_Calo%d_hE_MC%s",icalo,particle.Data()),iprod);
1172 
1173  if(!hParticleRecoE[iprod]) return;
1174 
1175  hParticleRecoE[iprod]->Rebin(5);
1176  hParticleRecoE[iprod]->Sumw2();
1177  hParticleRecoE[iprod]->Scale(1./nEvents[iprod]);
1178  hParticleRecoE[iprod]->SetMarkerColor(color[iprod]);
1179  hParticleRecoE[iprod]->SetMarkerStyle(24);
1180 
1181  hParticleRecoE[iprod]->SetTitle(Form("Reconstructed cluster spectra from generated %s",particle.Data()));
1182  hParticleRecoE[iprod]->SetYTitle("1/N_{events} dN/dp_{T}");
1183 
1184  hParticleRecoE[iprod]->SetTitleOffset(1.5,"Y");
1185  hParticleRecoE[iprod]->SetMarkerColor(color[iprod]);
1186  hParticleRecoE[iprod]->SetMarkerStyle(20);
1187  hParticleRecoE[iprod]->SetAxisRange(0.,30.,"X");
1188  //hParticleRecoE[iprod]->SetMaximum(1.1);
1189  //hParticleRecoE[iprod]->SetMinimum(0);
1190 
1191  if(iprod > 0)
1192  {
1193  hRatParticleRecoE [iprod-1] = (TH1F*)hParticleRecoE [iprod]->Clone(Form("hRatParticleRecoE%s_MC%s_%s" ,prod[iprod].Data(),particle.Data(),histoTag.Data()));
1194 
1195  hRatParticleRecoE [iprod-1]->Divide(hRatParticleRecoE [iprod-1],hParticleRecoE [0],1,1,errType);
1196  }
1197 
1198  // Cluster-Track Matching Residuals
1199 
1200  // E cluster bin
1201  h2ParticleRecoEDelta[iprod] = (TH2F*) GetHisto(Form("AnaPhoton_Calo%d_hDeltaE_MC%s",icalo,particle.Data()),iprod);
1202 
1203  for(Int_t ie = 0; ie < nEbins; ie++)
1204  {
1205  Float_t binMin = h2ParticleRecoEDelta[iprod]->GetXaxis()->FindBin(ebins[ie]);
1206  Float_t binMax = h2ParticleRecoEDelta[iprod]->GetXaxis()->FindBin(ebins[ie+1])-1;
1207 
1208  hParticleRecoEDelta[iprod][ie] =
1209  (TH1F*) h2ParticleRecoEDelta[iprod]->ProjectionY(Form("DeltaProj_%s_%s_MC%s_ie%d",
1210  prod[iprod].Data(),histoTag.Data(),particle.Data(),ie),
1211  binMin, binMax);
1212 
1213 
1214  hParticleRecoEDelta[iprod][ie]->SetXTitle("#it{E}_{reco}-#it{E}_{gen} (GeV)");
1215  hParticleRecoEDelta[iprod][ie]->SetYTitle("Entries / N events");
1216  hParticleRecoEDelta[iprod][ie]->SetTitle(Form("Reco MC %s, %2.1f < #it{E}^{cluster} < %2.1f GeV",particle.Data(),ebins[ie],ebins[ie+1]));
1217  hParticleRecoEDelta[iprod][ie]->SetAxisRange(-3,3,"X");
1218  hParticleRecoEDelta[iprod][ie]->Sumw2();
1219  hParticleRecoEDelta[iprod][ie]->SetMarkerStyle(24);
1220  hParticleRecoEDelta[iprod][ie]->SetMarkerColor(color[iprod]);
1221 
1222  hParticleRecoEDelta[iprod][ie]->Scale(1./nEvents[iprod]);
1223 
1224  hParticleRecoEDelta[iprod][ie]->SetTitleOffset(1.5,"Y");
1225  }
1226 
1227  } // prod loop
1228 
1229 
1231  // Make the plots
1233  {
1234  TCanvas * ccalo = new TCanvas(Form("Cluster_MC%s_%s",particle.Data(),histoTag.Data()),"",1000,500);
1235  ccalo->Divide(2,1);
1236 
1237  ccalo->cd(1);
1238  gPad->SetLogy();
1239  //gPad->SetLogx();
1240 
1241  hParticleRecoE[0]->Draw();
1242  for(Int_t iprod = 0; iprod < nProd; iprod++)
1243  {
1244  hParticleRecoE [iprod]->Draw("same");
1245 
1246  lprod.AddEntry(hParticleRecoE[iprod],prodLeg[iprod],"P");
1247  }
1248 
1249  lprod.Draw();
1250 
1251  ccalo->cd(2);
1252  gPad->SetGridy();
1253  //gPad->SetLogy();
1254  //gPad->SetLogx();
1255 
1256  hRatParticleRecoE[0]->SetTitle(Form("MC %s reco cluster spectra ratio",particle.Data()));
1257  hRatParticleRecoE[0]->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
1258  // hRatParticleRecoE[0]->SetMinimum(0.850);
1259  // hRatParticleRecoE[0]->SetMaximum(1.025);
1260  hRatParticleRecoE[0]->SetMinimum(0.7);
1261  hRatParticleRecoE[0]->SetMaximum(1.3);
1262  hRatParticleRecoE[0]->Draw("");
1263 
1264  for(Int_t iprod = 0; iprod < nProd-1; iprod++)
1265  {
1266  hRatParticleRecoE[iprod]->Draw("same");
1267  }
1268 
1269  ccalo->Print(Form("%s_ClusterSpectra_MC%s.%s",histoTag.Data(),particle.Data(),format.Data()));
1270  }
1271 
1272  // Cluster energy residual
1273  {
1274  TGaxis::SetMaxDigits(3);
1275 
1276  TCanvas * ccalo2 = new TCanvas(Form("Resolution_MC%s_%s",particle.Data(),histoTag.Data()),"",1000,1000);
1277  ccalo2->Divide(2,2);
1278 
1279  for(Int_t ie = 0; ie < nEbins; ie++)
1280  {
1281  ccalo2->cd(ie+1);
1282  //gPad->SetLogy();
1283 
1284  hParticleRecoEDelta[0][ie]->Draw("");
1285  for(Int_t iprod = 0; iprod < nProd; iprod++)
1286  {
1287  hParticleRecoEDelta[iprod][ie]->Draw("same");
1288  }
1289 
1290  lprod.Draw();
1291  }
1292 
1293  ccalo2->Print(Form("%s_ClusterERecoGenDiff_MC%s.%s",histoTag.Data(),particle.Data(),format.Data()));
1294  }
1295 
1296 }
1297 
1302 //______________________________________
1303 void ShowerShape(Int_t icalo)
1304 {
1305  // Declare the different histograms, arrays input is production
1306 
1307  const Int_t nEbins = 7;
1308  Float_t ebins [] = {2,4,6,8,10,12,16,20};
1309 
1310  TH2F* h2M02[nProd];
1311  TH1F* hM02 [nProd][nEbins];
1312  TH2F* h2M20[nProd];
1313  TH1F* hM20 [nProd][nEbins];
1314 
1315  //Legend for productions
1316  TLegend lprod(0.6,0.475,0.95,0.675);
1317  lprod.SetTextSize(0.04);
1318  lprod.SetBorderSize(0);
1319  lprod.SetFillColor(0);
1320 
1321  for(Int_t iprod = 0; iprod < nProd; iprod++)
1322  {
1323  // E cluster bin
1324  h2M02[iprod] = (TH2F*) GetHisto(Form("AnaPhoton_Calo%d_hLam0E",icalo),iprod);
1325  h2M20[iprod] = (TH2F*) GetHisto(Form("AnaPhoton_Calo%d_hLam1E",icalo),iprod);
1326 
1327  if(!h2M02[iprod] || !h2M20[iprod]) return;
1328 
1329  for(Int_t ie = 0; ie < nEbins; ie++)
1330  {
1331  Float_t binMin = h2M02[iprod]->GetXaxis()->FindBin(ebins[ie]);
1332  Float_t binMax = h2M02[iprod]->GetXaxis()->FindBin(ebins[ie+1])-1;
1333 
1334  hM02[iprod][ie] =
1335  (TH1F*) h2M02[iprod]->ProjectionY(Form("DeltaProjM02_%s_MC%s_ie%d",
1336  prod[iprod].Data(),histoTag.Data(),ie),
1337  binMin, binMax);
1338 
1339  hM20[iprod][ie] =
1340  (TH1F*) h2M20[iprod]->ProjectionY(Form("DeltaProjM20_%s_MC%s_ie%d",
1341  prod[iprod].Data(),histoTag.Data(),ie),
1342  binMin, binMax);
1343 
1344  //hM02[iprod][ie]->SetXTitle("#it{E}_{reco}-#it{E}_{gen} (GeV)");
1345  hM02[iprod][ie]->SetYTitle("Entries / N events");
1346  hM02[iprod][ie]->SetTitle(Form("%2.1f < #it{E}^{cluster} < %2.1f GeV",ebins[ie],ebins[ie+1]));
1347  hM02[iprod][ie]->SetAxisRange(0.1,0.8,"X");
1348  hM02[iprod][ie]->Sumw2();
1349  //hM02[iprod][ie]->SetMarkerStyle(24);
1350  hM02[iprod][ie]->SetMarkerColor(color[iprod]);
1351  hM02[iprod][ie]->SetLineColor (color[iprod]);
1352 
1353  hM02[iprod][ie]->Scale(1./nEvents[iprod]);
1354 
1355  hM02[iprod][ie]->SetTitleOffset(1.5,"Y");
1356 
1357 
1358  //hM20[iprod][ie]->SetXTitle("#it{E}_{reco}-#it{E}_{gen} (GeV)");
1359  hM20[iprod][ie]->SetYTitle("Entries / N events");
1360  hM20[iprod][ie]->SetTitle(Form("%2.1f < #it{E}^{cluster} < %2.1f GeV",ebins[ie],ebins[ie+1]));
1361  hM20[iprod][ie]->SetAxisRange(0.0,0.5,"X");
1362  hM20[iprod][ie]->Sumw2();
1363  //hM20[iprod][ie]->SetMarkerStyle(24);
1364  hM20[iprod][ie]->SetMarkerColor(color[iprod]);
1365  hM20[iprod][ie]->SetLineColor (color[iprod]);
1366 
1367  hM20[iprod][ie]->Scale(1./nEvents[iprod]);
1368 
1369  hM20[iprod][ie]->SetTitleOffset(1.5,"Y");
1370  }
1371 
1372  lprod.AddEntry(hM02[iprod][0],prodLeg[iprod],"LP");
1373 
1374  } // prod loop
1375 
1376 
1378  // Make the plots
1380 
1381  {
1382  TGaxis::SetMaxDigits(3);
1383 
1384  TCanvas * cM02 = new TCanvas(Form("M02_%s",histoTag.Data()),"",1000,1000);
1385  cM02->Divide(2,2);
1386 
1387  for(Int_t ie = 0; ie < nEbins; ie++)
1388  {
1389  cM02->cd(ie+1);
1390  //gPad->SetLogy();
1391 
1392  hM02[0][ie]->Draw("H");
1393  for(Int_t iprod = 0; iprod < nProd; iprod++)
1394  {
1395  hM02[iprod][ie]->Draw("Hsame");
1396  }
1397 
1398  lprod.Draw();
1399  }
1400 
1401  cM02->Print(Form("%s_M02.%s",histoTag.Data(),format.Data()));
1402 
1403  TCanvas * cM20 = new TCanvas(Form("M20_%s",histoTag.Data()),"",1000,1000);
1404  cM20->Divide(2,2);
1405 
1406  for(Int_t ie = 0; ie < nEbins; ie++)
1407  {
1408  cM20->cd(ie+1);
1409  //gPad->SetLogy();
1410 
1411  hM20[0][ie]->Draw("H");
1412  for(Int_t iprod = 0; iprod < nProd; iprod++)
1413  {
1414  hM20[iprod][ie]->Draw("Hsame");
1415  }
1416 
1417  lprod.Draw();
1418  }
1419 
1420  cM20->Print(Form("%s_M20.%s",histoTag.Data(),format.Data()));
1421 
1422  }
1423 
1424 }
1425 
1426 
1427 
1431 //______________________________________
1432 void Track()
1433 {
1434  TH1F * hTrackPt[nProd] ;
1435  TH1F * hTrackPtSPD[nProd] ;
1436  TH1F * hTrackPtNoSPD[nProd] ;
1437  TH1F * hRatTrackPt[nProd-1] ;
1438  TH1F * hRatTrackPtSPD[nProd-1] ;
1439  TH1F * hRatTrackPtNoSPD[nProd-1] ;
1440 
1441  TH2F * hTrackEtaPhi[nProd] ;
1442  TH2F * hTrackEtaPhiSPD[nProd] ;
1443  TH2F * hTrackEtaPhiNoSPD[nProd] ;
1444  TH1F * hTrackPhi[nProd] ;
1445  TH1F * hTrackPhiSPD[nProd] ;
1446  TH1F * hTrackPhiNoSPD[nProd] ;
1447  TH1F * hRatTrackPhi[nProd-1] ;
1448  TH1F * hRatTrackPhiSPD[nProd-1] ;
1449  TH1F * hRatTrackPhiNoSPD[nProd-1] ;
1450 
1451  //Legend for productions
1452  TLegend lprod(0.5,0.475,0.84,0.675);
1453  lprod.SetTextSize(0.04);
1454  lprod.SetBorderSize(0);
1455  lprod.SetFillColor(0);
1456 
1457  for(Int_t iprod = 0; iprod < nProd; iprod++)
1458  {
1459  hTrackPt [iprod] = (TH1F*) GetHisto("AnaHadrons_hPt" ,iprod);
1460  if ( !hTrackPt[iprod] ) return;
1461 
1462  hTrackPtSPD [iprod] = (TH1F*) GetHisto("AnaHadrons_hPtSPDRefit" ,iprod);
1463  hTrackPtNoSPD [iprod] = (TH1F*) GetHisto("AnaHadrons_hPtNoSPDRefit" ,iprod);
1464  hTrackEtaPhiSPD [iprod] = (TH2F*) GetHisto("AnaHadrons_hEtaPhiSPDRefitPt02" ,iprod);
1465  hTrackEtaPhiNoSPD[iprod] = (TH2F*) GetHisto("AnaHadrons_hEtaPhiNoSPDRefitPt02",iprod);
1466  hTrackEtaPhi [iprod] = (TH2F*) GetHisto("AnaHadrons_hEtaPhiPositive" ,iprod);
1467  hTrackEtaPhi [iprod]->Add((TH2F*) GetHisto("AnaHadrons_hEtaPhiNegative" ,iprod));
1468 
1469  hTrackPhiSPD [iprod] = (TH1F*)hTrackEtaPhiSPD [iprod]->ProjectionY(Form("hTrackPhiSPD%s" ,prod[iprod].Data()),0,1000);
1470  hTrackPhiNoSPD [iprod] = (TH1F*)hTrackEtaPhiNoSPD[iprod]->ProjectionY(Form("hTrackPhiNoSPD%s",prod[iprod].Data()),0,1000);
1471  hTrackPhi [iprod] = (TH1F*)hTrackEtaPhi [iprod]->ProjectionY(Form("hTrackPhi%s" ,prod[iprod].Data()),0,1000);
1472 
1473  hTrackPt [iprod]->Rebin(5);
1474  hTrackPtSPD [iprod]->Rebin(5);
1475  hTrackPtNoSPD[iprod]->Rebin(5);
1476 
1477  hTrackPt [iprod]->Sumw2();
1478  hTrackPtSPD [iprod]->Sumw2();
1479  hTrackPtNoSPD[iprod]->Sumw2();
1480 
1481  hTrackPt [iprod]->Scale(1./nEvents[iprod]);
1482  hTrackPtSPD [iprod]->Scale(1./nEvents[iprod]);
1483  hTrackPtNoSPD[iprod]->Scale(1./nEvents[iprod]);
1484 
1485  hTrackPhi [iprod]->Rebin(5);
1486  hTrackPhiSPD [iprod]->Rebin(5);
1487  hTrackPhiNoSPD[iprod]->Rebin(5);
1488 
1489  hTrackPhi [iprod]->Sumw2();
1490  hTrackPhiSPD [iprod]->Sumw2();
1491  hTrackPhiNoSPD[iprod]->Sumw2();
1492 
1493  hTrackPhi [iprod]->Scale(1./nEvents[iprod]);
1494  hTrackPhiSPD [iprod]->Scale(1./nEvents[iprod]);
1495  hTrackPhiNoSPD[iprod]->Scale(1./nEvents[iprod]);
1496 
1497  hTrackPt[iprod]->SetTitle("Track spectra with/out SPD");
1498  hTrackPt[iprod]->SetYTitle("1/N_{events} dN/dp_{T}");
1499  hTrackPt[iprod]->SetTitleOffset(1.5,"Y");
1500  hTrackPt[iprod]->SetMarkerColor(color[iprod]);
1501  hTrackPt[iprod]->SetMarkerStyle(20);
1502  hTrackPt[iprod]->SetAxisRange(0.,30.,"X");
1503  //hTrackPt[iprod]->SetMaximum(1.1);
1504  //hTrackPt[iprod]->SetMinimum(0);
1505 
1506  hTrackPtSPD[iprod]->SetMarkerColor(color[iprod]);
1507  hTrackPtSPD[iprod]->SetMarkerStyle(26);
1508 
1509  hTrackPtNoSPD[iprod]->SetMarkerColor(color[iprod]);
1510  hTrackPtNoSPD[iprod]->SetMarkerStyle(25);
1511 
1512  hTrackPhi[iprod]->SetTitle("Track #varphi with/out SPD");
1513  hTrackPhi[iprod]->SetYTitle("1/N_{events} dN/d#varphi");
1514  hTrackPhi[iprod]->SetTitleOffset(1.5,"Y");
1515  hTrackPhi[iprod]->SetMarkerColor(color[iprod]);
1516  hTrackPhi[iprod]->SetMarkerStyle(20);
1517  hTrackPhi[iprod]->SetAxisRange(0.,30.,"X");
1518  //hTrackPhi[iprod]->SetMaximum(1.1);
1519  //hTrackPhi[iprod]->SetMinimum(0);
1520 
1521  hTrackPhiSPD[iprod]->SetMarkerColor(color[iprod]);
1522  hTrackPhiSPD[iprod]->SetMarkerStyle(26);
1523 
1524  hTrackPhiNoSPD[iprod]->SetMarkerColor(color[iprod]);
1525  hTrackPhiNoSPD[iprod]->SetMarkerStyle(25);
1526 
1527  lprod.AddEntry(hTrackPt[iprod],prodLeg[iprod],"P");
1528 
1529  if(iprod > 0)
1530  {
1531  hRatTrackPhi [iprod-1] = (TH1F*)hTrackPhi [iprod]->Clone(Form("hRatTrackPhi%s" ,prod[iprod].Data()));
1532  hRatTrackPhiNoSPD[iprod-1] = (TH1F*)hTrackPhiNoSPD[iprod]->Clone(Form("hRatTrackPhiNoSPD%s",prod[iprod].Data()));
1533  hRatTrackPhiSPD [iprod-1] = (TH1F*)hTrackPhiSPD [iprod]->Clone(Form("hRatTrackPhiSPD%s" ,prod[iprod].Data()));
1534 
1535  hRatTrackPhi [iprod-1]->Divide(hRatTrackPhi [iprod-1],hTrackPhi [0],1.000,1,errType);
1536  hRatTrackPhiSPD [iprod-1]->Divide(hRatTrackPhiSPD [iprod-1],hTrackPhiSPD [0],1.000,1,errType);
1537  hRatTrackPhiNoSPD[iprod-1]->Divide(hRatTrackPhiNoSPD[iprod-1],hTrackPhiNoSPD[0],1.000,1,errType);
1538 
1539  hRatTrackPt [iprod-1] = (TH1F*)hTrackPt [iprod]->Clone(Form("hRatTrackPt%s" ,prod[iprod].Data()));
1540  hRatTrackPtNoSPD[iprod-1] = (TH1F*)hTrackPtNoSPD[iprod]->Clone(Form("hRatTrackPtNoSPD%s",prod[iprod].Data()));
1541  hRatTrackPtSPD [iprod-1] = (TH1F*)hTrackPtSPD [iprod]->Clone(Form("hRatTrackPtSPD%s" ,prod[iprod].Data()));
1542 
1543  hRatTrackPt [iprod-1]->Divide(hRatTrackPt [iprod-1],hTrackPt [0],1.000,1,errType);
1544  hRatTrackPtSPD [iprod-1]->Divide(hRatTrackPtSPD [iprod-1],hTrackPtSPD [0],1.000,1,errType);
1545  hRatTrackPtNoSPD[iprod-1]->Divide(hRatTrackPtNoSPD[iprod-1],hTrackPtNoSPD[0],1.000,1,errType);
1546  }
1547  }
1548 
1549 
1551  // Make the plots
1553 
1554  // Hybrid tracks
1555  {
1556  TLegend ltrack(0.6,0.75,0.84,0.89);
1557  ltrack.SetTextSize(0.04);
1558  //ltrack.SetBorderSize(0);
1559  ltrack.SetFillColor(0);
1560  ltrack.AddEntry(hTrackPt [0],"All","P");
1561  ltrack.AddEntry(hTrackPtSPD [0],"SPD","P");
1562  ltrack.AddEntry(hTrackPtNoSPD[0],"No SPD","P");
1563 
1564  TCanvas * ctrack = new TCanvas(Form("TrackHisto_%s",histoTag.Data()),"",1500,1500);
1565  ctrack->Divide(2,2);
1566  ctrack->cd(1);
1567  gPad->SetLogy();
1568  hTrackPt[0]->Draw("");
1569  hTrackPt[0]->SetMinimum(1e-8);
1570  for(Int_t iprod = 0; iprod < nProd; iprod++)
1571  {
1572  hTrackPt [iprod]->Draw("same");
1573  hTrackPtSPD [iprod]->Draw("same");
1574  hTrackPtNoSPD[iprod]->Draw("same");
1575  }
1576 
1577  ltrack.Draw();
1578  lprod.Draw();
1579 
1580  ctrack->cd(2);
1581  gPad->SetGridy();
1582 
1583  hRatTrackPt[0]->SetMaximum(1.2);
1584  hRatTrackPt[0]->SetMinimum(0.8);
1585  hRatTrackPt[0]->Draw("");
1586  hRatTrackPt[0]->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
1587  for(Int_t iprod = 0; iprod < nProd-1; iprod++)
1588  {
1589  hRatTrackPt [iprod]->Draw("same");
1590  hRatTrackPtSPD [iprod]->Draw("same");
1591  hRatTrackPtNoSPD[iprod]->Draw("same");
1592  }
1593 
1594  ctrack->cd(3);
1595  hTrackPhi[0]->SetMaximum(0.2);
1596  hTrackPhi[0]->SetMinimum(0.);
1597  hTrackPhi[0]->Draw("");
1598  for(Int_t iprod = 0; iprod < nProd; iprod++)
1599  {
1600  hTrackPhi [iprod]->Draw("same");
1601  hTrackPhiSPD [iprod]->Draw("same");
1602  hTrackPhiNoSPD[iprod]->Draw("same");
1603  }
1604 
1605  ctrack->cd(4);
1606  gPad->SetGridy();
1607 
1608  hRatTrackPhi[0]->SetMaximum(1.02);
1609  hRatTrackPhi[0]->SetMinimum(0.95);
1610  hRatTrackPhi[0]->Draw("");
1611  hRatTrackPhi[0]->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
1612  for(Int_t iprod = 0; iprod < nProd-1; iprod++)
1613  {
1614  hRatTrackPhi [iprod]->Draw("same");
1615  hRatTrackPhiSPD [iprod]->Draw("same");
1616  hRatTrackPhiNoSPD[iprod]->Draw("same");
1617  }
1618 
1619  ctrack->Print(Form("%s_TrackComp.%s",histoTag.Data(),format.Data()));
1620  }
1621 }
1622 
1629 //______________________________________
1630 void Correl(Int_t icalo)
1631 {
1632  TH2F* h2XE[nProd];
1633  TH2F* h2XEUE[nProd];
1634  TH1F* hXE[nProd];
1635  TH1F* hXEUE[nProd];
1636  TH1F* hRatXE[nProd-1];
1637  TH1F* hRatXEUE[nProd-1];
1638 
1639  //Legend for productions
1640  TLegend lprod(0.5,0.475,0.84,0.675);
1641  lprod.SetTextSize(0.04);
1642  lprod.SetBorderSize(0);
1643  lprod.SetFillColor(0);
1644 
1645  for(Int_t iprod = 0; iprod < nProd; iprod++)
1646  {
1647  h2XE [iprod]= (TH2F*) GetHisto(Form("AnaPhotonHadronCorr_Calo%d_hXECharged" ,icalo),iprod);
1648  h2XEUE [iprod]= (TH2F*) GetHisto(Form("AnaPhotonHadronCorr_Calo%d_hXEUeCharged",icalo),iprod);
1649 
1650  if ( !h2XE[iprod] ) return;
1651 
1652  Float_t minClusterE = 5;
1653  TH1F * hTrigger = (TH1F*) GetHisto(Form("AnaPhotonHadronCorr_Calo%d_hPtTrigger",icalo),iprod);
1654  if(!hTrigger)
1655  {
1656  printf("Null trigger histo for prod %d\n",iprod);
1657  return;
1658  }
1659  Int_t minClusterEBin = hTrigger->FindBin(minClusterE);
1660  Float_t nTrig = hTrigger->Integral(minClusterE,100000);
1661 
1662  hXE [iprod] = (TH1F*)h2XE [iprod]->ProjectionY(Form("hXE%s_%s" ,prod[iprod].Data(),histoTag.Data()),minClusterEBin,1000);
1663  hXEUE[iprod] = (TH1F*)h2XEUE[iprod]->ProjectionY(Form("hXEUE%s_%s",prod[iprod].Data(),histoTag.Data()),minClusterEBin,1000);
1664 
1665  hXE [iprod]->Sumw2();
1666  hXEUE[iprod]->Sumw2();
1667 
1668  hXE [iprod]->Rebin(5);
1669  hXEUE[iprod]->Rebin(5);
1670 
1671  hXE [iprod]->Scale(1./nTrig);
1672  hXEUE[iprod]->Scale(1./nTrig);
1673 
1674  hXE[iprod]->SetTitle(Form("#gamma-hadron x_{E}, p_{T,Trig}>%2.1f GeV/c",minClusterE));
1675  hXE[iprod]->SetYTitle("1/N_{trigger} dN/dx_{E}");
1676  hXE[iprod]->SetTitleOffset(1.5,"Y");
1677  hXE[iprod]->SetMarkerColor(color[iprod]);
1678  hXE[iprod]->SetMarkerStyle(20);
1679  hXE[iprod]->SetAxisRange(0.,1.,"X");
1680  //hXE[iprod]->SetMaximum(1.1);
1681  //hXE[iprod]->SetMinimum(0);
1682 
1683  lprod.AddEntry(hXE[iprod],prodLeg[iprod],"P");
1684 
1685  hXEUE[iprod]->SetMarkerColor(color[iprod]);
1686  hXEUE[iprod]->SetMarkerStyle(25);
1687 
1688  if(iprod > 0)
1689  {
1690  hRatXE [iprod-1] = (TH1F*)hXE [iprod]->Clone(Form("hRatXE%s_%s" ,prod[iprod].Data(),histoTag.Data()));
1691  hRatXEUE[iprod-1] = (TH1F*)hXEUE[iprod]->Clone(Form("hRatXEUE%s_%s",prod[iprod].Data(),histoTag.Data()));
1692 
1693  hRatXE [iprod-1]->Divide(hRatXE [iprod-1],hXE [0],1.000,1,errType);
1694  hRatXEUE[iprod-1]->Divide(hRatXEUE[iprod-1],hXEUE[0],1.000,1,errType);
1695  }
1696  }
1697 
1699  // Make the plots
1701 
1702  // XE
1703  {
1704  TLegend lxe(0.6,0.75,0.84,0.89);
1705  lxe.SetTextSize(0.04);
1706  //lxe.SetBorderSize(0);
1707  lxe.SetFillColor(0);
1708  lxe.AddEntry(hXE [0],"Signal+bkg","P");
1709  lxe.AddEntry(hXEUE[0],"Und. Event","P");
1710 
1711  TCanvas * cxe = new TCanvas(Form("XEHisto_%s_%s",histoTag.Data(),histoTag.Data()),"",1000,500);
1712  cxe->Divide(2,1);
1713  cxe->cd(1);
1714  gPad->SetLogy();
1715  hXE[0]->Draw("");
1716  for(Int_t iprod = 0; iprod < nProd; iprod++)
1717  {
1718  hXE [iprod]->Draw("same");
1719  hXEUE[iprod]->Draw("same");
1720  }
1721 
1722  lxe.Draw();
1723  lprod.Draw();
1724 
1725  cxe->cd(2);
1726 
1727  hRatXE[0]->SetMaximum(1.5);
1728  hRatXE[0]->SetMinimum(0.5);
1729  hRatXE[0]->Draw("");
1730  hRatXE[0]->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
1731  for(Int_t iprod = 0; iprod < nProd-1; iprod++)
1732  {
1733  hRatXE [iprod]->Draw("same");
1734  hRatXEUE[iprod]->Draw("same");
1735  }
1736 
1737  cxe->Print(Form("%s_XEComp.%s",histoTag.Data(),format.Data()));
1738  }
1739 
1740 }
1741 
1742 
1749 //______________________________________
1750 void Isol(Int_t icalo)
1751 {
1752  TH2F* h2Ne[nProd];
1753  TH2F* h2Ch[nProd];
1754  TH1F* hNe[nProd];
1755  TH1F* hCh[nProd];
1756  TH1F* hRatNe[nProd-1];
1757  TH1F* hRatCh[nProd-1];
1758 
1759  //Legend for productions
1760  TLegend lprod(0.15,0.15,0.35,0.35);
1761  lprod.SetTextSize(0.04);
1762  lprod.SetBorderSize(0);
1763  lprod.SetFillColor(0);
1764 
1765  for(Int_t iprod = 0; iprod < nProd; iprod++)
1766  {
1767  h2Ne [iprod]= (TH2F*) GetHisto(Form("AnaIsolPhoton_Calo%d_hConePtSumCluster",icalo),iprod);
1768  h2Ch [iprod]= (TH2F*) GetHisto(Form("AnaIsolPhoton_Calo%d_hConePtSumTrack" ,icalo),iprod);
1769 
1770  if ( !h2Ne[iprod] ) return;
1771 
1772  Float_t minClusterE = 5;
1773  TH1F * hTrigger = (TH1F*) GetHisto(Form("AnaIsolPhoton_Calo%d_hE",icalo),iprod);
1774  hTrigger ->Add((TH1F*) GetHisto(Form("AnaIsolPhoton_Calo%d_hENoIso",icalo),iprod));
1775  if(!hTrigger)
1776  {
1777  printf("Null trigger histo for prod %d\n",iprod);
1778  return;
1779  }
1780 
1781  Int_t minClusterEBin = hTrigger->FindBin(minClusterE);
1782  Float_t nTrig = hTrigger->Integral(minClusterE,100000);
1783 
1784  hNe[iprod] = (TH1F*)h2Ne[iprod]->ProjectionY(Form("hNe%s_%s",prod[iprod].Data(),histoTag.Data()),minClusterEBin,1000);
1785  hCh[iprod] = (TH1F*)h2Ch[iprod]->ProjectionY(Form("hCh%s_%s",prod[iprod].Data(),histoTag.Data()),minClusterEBin,1000);
1786 
1787  hNe[iprod]->Sumw2();
1788  hCh[iprod]->Sumw2();
1789 
1790 // hNe[iprod]->Rebin(5);
1791 // hCh[iprod]->Rebin(5);
1792 
1793  hNe[iprod]->Scale(1./nTrig);
1794  hCh[iprod]->Scale(1./nTrig);
1795 
1796  hNe[iprod]->SetTitle(Form("#Sigma p_{T} in cone R=0.4, p_{T,Trig}>%2.1f GeV/c",minClusterE));
1797  hNe[iprod]->SetYTitle("1/N_{trigger} dN/d#Sigma p_{T}");
1798  hNe[iprod]->SetTitleOffset(1.5,"Y");
1799  hNe[iprod]->SetMarkerColor(color[iprod]);
1800  hNe[iprod]->SetMarkerStyle(20);
1801  hNe[iprod]->SetAxisRange(0.,30.,"X");
1802  //hNe[iprod]->SetMaximum(1.1);
1803  //hNe[iprod]->SetMinimum(0);
1804 
1805  lprod.AddEntry(hNe[iprod],prodLeg[iprod],"P");
1806 
1807  hCh[iprod]->SetMarkerColor(color[iprod]);
1808  hCh[iprod]->SetMarkerStyle(25);
1809 
1810  if(iprod > 0)
1811  {
1812  hRatNe[iprod-1] = (TH1F*)hNe[iprod]->Clone(Form("hRatNe%s_%s",prod[iprod].Data(),histoTag.Data()));
1813  hRatCh[iprod-1] = (TH1F*)hCh[iprod]->Clone(Form("hRatCh%s_%s",prod[iprod].Data(),histoTag.Data()));
1814 
1815  hRatNe[iprod-1]->Divide(hRatNe[iprod-1],hNe[0],1.000,1,errType);
1816  hRatCh[iprod-1]->Divide(hRatCh[iprod-1],hCh[0],1.000,1,errType);
1817  }
1818  }
1819 
1821  // Make the plots
1823 
1824  // Ne
1825  {
1826  TLegend lNe(0.6,0.75,0.84,0.89);
1827  lNe.SetTextSize(0.04);
1828  //lNe.SetBorderSize(0);
1829  lNe.SetFillColor(0);
1830  lNe.AddEntry(hNe[0],"Clusters","P");
1831  lNe.AddEntry(hCh[0],"Tracks","P");
1832 
1833  TCanvas * cNe = new TCanvas(Form("SumPtHisto_%s_%s",histoTag.Data(),histoTag.Data()),"",1000,500);
1834  cNe->Divide(2,1);
1835  cNe->cd(1);
1836  gPad->SetLogy();
1837  hNe[0]->Draw("");
1838  for(Int_t iprod = 0; iprod < nProd; iprod++)
1839  {
1840  hNe[iprod]->Draw("same");
1841  hCh[iprod]->Draw("same");
1842  }
1843 
1844  lNe.Draw();
1845  lprod.Draw();
1846 
1847  cNe->cd(2);
1848 
1849  hRatNe[0]->SetMaximum(1.5);
1850  hRatNe[0]->SetMinimum(0.5);
1851  hRatNe[0]->Draw("");
1852  hRatNe[0]->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
1853  for(Int_t iprod = 0; iprod < nProd-1; iprod++)
1854  {
1855  hRatNe [iprod]->Draw("same");
1856  hRatCh[iprod]->Draw("same");
1857  }
1858 
1859  cNe->Print(Form("%s_ConeSumPt.%s",histoTag.Data(),format.Data()));
1860  }
1861 
1862 }
1863 
1864 
1872 //______________________________________
1873 void InvMass(Int_t icalo, TString particle, TString fileName)
1874 {
1875  const Int_t nEbins = 12;
1876  TH1F * hIM [nProd][nEbins];
1877  TGraphErrors* gMass [nProd];
1878  TGraphErrors* gWidth[nProd];
1879  TGraphErrors* gPt [nProd];
1880 
1881  TGraphErrors* gRatMass [nProd];
1882  TGraphErrors* gRatWidth[nProd];
1883  TGraphErrors* gRatPt [nProd];
1884 
1885  // Open files per production and trigger, get histograms/graphs
1886 
1887  //Legend for productions
1888  TLegend lprod(0.6,0.7,0.84,0.89);
1889  lprod.SetTextSize(0.04);
1890  lprod.SetBorderSize(0);
1891  lprod.SetFillColor(0);
1892 
1893  fileName.ReplaceAll(".root","");
1894 
1895  TString calorimeter = "EMCAL";
1896  if(icalo == 1) calorimeter = "DCAL";
1897 
1898  for(Int_t iprod = 0; iprod < nProd; iprod++)
1899  {
1900  TFile * filIM = TFile::Open(Form("IMfigures/%s_%s_MassWidthPtHistograms_%s_%s_AllSM.root",
1901  prod[iprod].Data(),calorimeter.Data(),particle.Data(),fileName.Data()));
1902 // printf("IMfigures/%s_%s_MassWidthPtHistograms_%s_%s_AllSM.root %p\n",
1903 // prod[iprod].Data(),calorimeter.Data(),particle.Data(),fileName.Data(),filIM);
1904 
1905  for(Int_t ie = 0; ie < nEbins; ie++)
1906  {
1907  hIM[iprod][ie] = (TH1F*) filIM->Get(Form("IM_Comb0_PtBin%d",ie));
1908  //
1909  // hIM[iprod][ie] ->Rebin(5);
1910  //
1911  // hIM[iprod][ie] ->Scale(1./nTrig);
1912  hIM[iprod][ie]->SetTitleOffset(1.5,"Y");
1913  hIM[iprod][ie]->SetYTitle("1/N_{events} dN/dM");
1914  hIM[iprod][ie]->SetMarkerColor(color[iprod]);
1915  hIM[iprod][ie]->SetLineColor(color[iprod]);
1916  // hIM[iprod][ie]->SetMarkerStyle(20);
1917  // hIM[iprod][ie]->SetAxisRange(0.,1.,"X");
1918  }
1919 
1920  gMass [iprod] = (TGraphErrors*) filIM->Get("gMass_AllSM");
1921  gWidth[iprod] = (TGraphErrors*) filIM->Get("gWidth_AllSM");
1922  gPt [iprod] = (TGraphErrors*) filIM->Get("gPt_AllSM");
1923 
1924  gMass [iprod]->SetMarkerColor(color[iprod]);
1925  gWidth[iprod]->SetMarkerColor(color[iprod]);
1926  gPt [iprod]->SetMarkerColor(color[iprod]);
1927 
1928  gMass [iprod]->SetMarkerStyle(20);
1929  gWidth[iprod]->SetMarkerStyle(20);
1930  gPt [iprod]->SetMarkerStyle(20);
1931 
1932  lprod.AddEntry(gMass[iprod],prodLeg[iprod],"PL");
1933 
1934  } // prod
1935 
1936  // Ratio
1937  const Int_t nPoints = gMass [0]->GetN();
1938  Double_t * x = gMass [0]->GetX();
1939  Double_t * ex = gMass [0]->GetEX();
1940 
1941  Double_t massR[nPoints];
1942  Double_t emassR[nPoints];
1943  Double_t widthR[nPoints];
1944  Double_t ewidthR[nPoints];
1945  Double_t ptR[nPoints];
1946  Double_t eptR[nPoints];
1947 
1948  Double_t * massD = gMass [0]->GetY();
1949  Double_t * emassD = gMass [0]->GetEY();
1950 
1951  Double_t * widthD = gWidth[0]->GetY();
1952  Double_t * ewidthD = gWidth[0]->GetEY();
1953 
1954  Double_t * ptD = gPt [0]->GetY();
1955  Double_t * eptD = gPt [0]->GetEY();
1956 
1957  for(Int_t iprod = 1; iprod < nProd; iprod++)
1958  {
1959  Double_t * massN = gMass [iprod]->GetY() ;
1960  Double_t * emassN = gMass [iprod]->GetEY();
1961 
1962  Double_t * widthN = gWidth[iprod]->GetY();
1963  Double_t * ewidthN = gWidth[iprod]->GetEY();
1964 
1965  Double_t * ptN = gPt [iprod]->GetY();
1966  Double_t * eptN = gPt [iprod]->GetEY();
1967 
1968  for(Int_t ie = 0; ie < nPoints ; ie++)
1969  {
1970  if ( massD[ie] > 0 && massN [ie] > 0 )
1971  {
1972  massR[ie] = massN[ie]/massD[ie];
1973  emassR[ie] = massR[ie] * TMath::Sqrt((emassN[ie]/massN[ie])*(emassN[ie]/massN[ie]) +
1974  (emassD[ie]/massD[ie])*(emassD[ie]/massD[ie]));
1975  }
1976 
1977  if ( widthD[ie] > 0 && widthN [ie] > 0 )
1978  {
1979  widthR[ie] = widthN[ie]/widthD[ie];
1980  ewidthR[ie] = widthR[ie] * TMath::Sqrt((ewidthN[ie]/widthN[ie])*(ewidthN[ie]/widthN[ie]) +
1981  (ewidthD[ie]/widthD[ie])*(ewidthD[ie]/widthD[ie]));
1982  }
1983 
1984  if ( ptD[ie] > 0 && ptN [ie] > 0 )
1985  {
1986  ptR[ie] = ptN[ie]/ptD[ie];
1987  eptR[ie] = ptR[ie] * TMath::Sqrt((eptN[ie]/ptN[ie])*(eptN[ie]/ptN[ie]) +
1988  (eptD[ie]/ptD[ie])*(eptD[ie]/ptD[ie]));
1989  }
1990 
1991  } // points
1992 
1993  gRatMass [iprod] = new TGraphErrors(nPoints,x,massR ,ex,emassR);
1994  gRatWidth[iprod] = new TGraphErrors(nPoints,x,widthR,ex,ewidthR);
1995  gRatPt [iprod] = new TGraphErrors(nPoints,x,ptR ,ex,eptR);
1996 
1997  gRatMass [iprod]->SetMarkerColor(color[iprod]);
1998  gRatMass [iprod]->SetLineColor(color[iprod]);
1999  gRatWidth[iprod]->SetMarkerColor(color[iprod]);
2000  gRatWidth[iprod]->SetLineColor(color[iprod]);
2001  gRatPt [iprod]->SetMarkerColor(color[iprod]);
2002  gRatPt [iprod]->SetLineColor(color[iprod]);
2003 
2004  } // prod
2005 
2007  // Make the plots
2009 
2010  // Mass
2011  {
2012  TCanvas * cMass = new TCanvas(Form("Mass_%s_%s",particle.Data(), histoTag.Data()),"",1000,500);
2013  cMass->Divide(2,1);
2014 
2015  cMass->cd(1);
2016  //gPad->SetLogy();
2017 
2018  gMass[1]->SetMinimum(120);
2019  gMass[1]->SetMaximum(170);
2020  gMass[0]->Draw("AP");
2021  for(Int_t iprod = 0; iprod < nProd; iprod++)
2022  {
2023  gMass[iprod]->Draw("P");
2024  }
2025 
2026  lprod.Draw();
2027 
2028  cMass->cd(2);
2029  gPad->SetGridy();
2030 
2031  gRatMass[1]->SetTitle("Mass Ratio");
2032  gRatMass[1]->GetHistogram()->SetXTitle("p_{T} (GeV/c)");
2033  gRatMass[1]->GetHistogram()->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
2034  gRatMass[1]->GetHistogram()->SetTitleOffset(1.4,"Y");
2035  gRatMass[1]->SetMinimum(0.97);
2036  gRatMass[1]->SetMaximum(1.05);
2037  gRatMass[1]->Draw("AP");
2038 
2039  for(Int_t iprod = 1; iprod < nProd-1; iprod++)
2040  {
2041  gMass [iprod]->Draw("P");
2042  }
2043 
2044 
2045  cMass->Print(Form("%s_Mass_%s.%s",histoTag.Data(),particle.Data(),format.Data()));
2046  }
2047  // Width
2048  {
2049  TCanvas * cWidth = new TCanvas(Form("Width_%s_%s",particle.Data(), histoTag.Data()),"",1000,500);
2050  cWidth->Divide(2,1);
2051 
2052  cWidth->cd(1);
2053  //gPad->SetLogy();
2054 
2055  gWidth[0]->SetMinimum(8);
2056  gWidth[0]->SetMaximum(20);
2057  gWidth[0]->Draw("AP");
2058  for(Int_t iprod = 0; iprod < nProd; iprod++)
2059  {
2060  gWidth[iprod]->Draw("P");
2061  }
2062 
2063  lprod.Draw();
2064 
2065  cWidth->cd(2);
2066  gPad->SetGridy();
2067 
2068  gRatWidth[1]->SetTitle("Width Ratio");
2069  gRatWidth[1]->GetHistogram()->SetXTitle("p_{T} (GeV/c)");
2070  gRatWidth[1]->GetHistogram()->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
2071  gRatWidth[1]->GetHistogram()->SetTitleOffset(1.4,"Y");
2072  gRatWidth[1]->SetMinimum(0.9);
2073  gRatWidth[1]->SetMaximum(1.1);
2074  gRatWidth[1]->Draw("AP");
2075 
2076  for(Int_t iprod = 1; iprod < nProd-1; iprod++)
2077  {
2078  gWidth [iprod]->Draw("P");
2079  }
2080 
2081 
2082  cWidth->Print(Form("%s_Width_%s.%s",histoTag.Data(),particle.Data(),format.Data()));
2083  }
2084 
2085 
2086  // Pt
2087  {
2088  TCanvas * cPt = new TCanvas(Form("Pt_%s_%s",particle.Data(), histoTag.Data()),"",1000,500);
2089  cPt->Divide(2,1);
2090 
2091  cPt->cd(1);
2092  gPad->SetLogy();
2093 
2094  gPt[0]->Draw("AP");
2095  for(Int_t iprod = 0; iprod < nProd; iprod++)
2096  {
2097  gPt[iprod]->Draw("P");
2098  }
2099 
2100  lprod.Draw();
2101 
2102  cPt->cd(2);
2103  gPad->SetGridy();
2104 
2105  gRatPt[1]->SetTitle("Pt Ratio");
2106  gRatPt[1]->GetHistogram()->SetXTitle("p_{T} (GeV/c)");
2107  gRatPt[1]->GetHistogram()->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
2108  gRatPt[1]->GetHistogram()->SetTitleOffset(1.4,"Y");
2109  gRatPt[1]->SetMinimum(0.7);
2110  gRatPt[1]->SetMaximum(1.3);
2111  gRatPt[1]->Draw("AP");
2112 
2113  for(Int_t iprod = 1; iprod < nProd-1; iprod++)
2114  {
2115  gPt [iprod]->Draw("P");
2116  }
2117 
2118 
2119  cPt->Print(Form("%s_Pt_%s.%s",histoTag.Data(),particle.Data(),format.Data()));
2120  }
2121 
2122  // Invariant Mass
2123  {
2124  TGaxis::SetMaxDigits(3);
2125 
2126  TCanvas * cIM = new TCanvas(Form("IM_%s_%s",particle.Data(),histoTag.Data()),"",1000,1000);
2127  cIM->Divide(4,3);
2128 
2129  for(Int_t ie = 0; ie < nEbins; ie++)
2130  {
2131  cIM->cd(ie+1);
2132  //gPad->SetLogy();
2133 
2134  hIM[0][ie]->Draw("");
2135  for(Int_t iprod = 0; iprod < nProd; iprod++)
2136  {
2137  hIM[iprod][ie]->Draw("same");
2138  }
2139 
2140  lprod.Draw();
2141  }
2142 
2143  cIM->Print(Form("%s_IM_%s.%s",histoTag.Data(),particle.Data(),format.Data()));
2144  }
2145 
2146 }
2147 
2150 //______________________________________
2151 void Centrality()
2152 {
2153  TH1F* hCen [nProd];
2154  TH1F* hRatCen[nProd-1];
2155 
2156  //Legend for productions
2157  TLegend lprod(0.3,0.475,0.84,0.675);
2158  lprod.SetTextSize(0.04);
2159  lprod.SetBorderSize(0);
2160  lprod.SetFillColor(0);
2161 
2162  for(Int_t iprod = 0; iprod < nProd; iprod++)
2163  {
2164  hCen[iprod] = (TH1F*) GetHisto("hCentrality",iprod);
2165 
2166  if ( !hCen[iprod] ) return;
2167 
2168 
2169  hCen[iprod]->Sumw2();
2170 
2171  hCen[iprod]->Scale(1./nEvents[iprod]);
2172 
2173  hCen[iprod]->SetTitle("Centrality");
2174  hCen[iprod]->SetYTitle("1/N_{events} dN/d centrality");
2175  hCen[iprod]->SetTitleOffset(1.5,"Y");
2176  hCen[iprod]->SetMarkerColor(color[iprod]);
2177  hCen[iprod]->SetMarkerStyle(20);
2178  //hCen[iprod]->SetAxisRange(0.,30.,"X");
2179  //hCen[iprod]->SetMaximum(1.1);
2180  //hCen[iprod]->SetMinimum(0);
2181  lprod.AddEntry(hCen[iprod],prodLeg[iprod],"P");
2182 
2183  if(iprod > 0)
2184  {
2185  hRatCen[iprod-1] = (TH1F*)hCen[iprod]->Clone(Form("hRatCen%s" ,prod[iprod].Data()));
2186 
2187  hRatCen[iprod-1]->Divide(hRatCen[iprod-1],hCen [0],1.000,1,errType);
2188  }
2189  }
2190 
2192  // Make the plots
2194  // Centrality
2195  {
2196  TCanvas * ccen = new TCanvas(Form("Centrality_%s",histoTag.Data()),"",1000,500);
2197  ccen->Divide(2,1);
2198 
2199  ccen->cd(1);
2200  //gPad->SetLogy();
2201 
2202  hCen[0]->Draw();
2203 
2204  for(Int_t iprod = 0; iprod < nProd; iprod++)
2205  {
2206  hCen[iprod]->Draw("same");
2207  }
2208 
2209  lprod.Draw();
2210 
2211  ccen->cd(2);
2212  //gPad->SetLogy();
2213 
2214  hRatCen[0]->SetTitle("Centrality");
2215  hRatCen[0]->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
2216  hRatCen[0]->SetMinimum(0.95);
2217  hRatCen[0]->SetMaximum(1.05);
2218  hRatCen[0]->Draw("");
2219 
2220  for(Int_t iprod = 0; iprod < nProd-1; iprod++)
2221  {
2222  hRatCen [iprod]->Draw("same");
2223  }
2224 
2225  TLine l1(0,1,100,1);
2226 
2227  l1.Draw("same");
2228 
2229  ccen->Print(Form("%s_CentralityComp.%s",histoTag.Data(),format.Data()));
2230  }
2231 
2232 }
2233 
2237 //______________________________________
2238 void Vertex()
2239 {
2240  TH1F* hVertex [3][nProd];
2241  TH1F* hRatVertex[3][nProd-1];
2242 
2243  //Legend for productions
2244  TLegend lprod(0.6,0.6,0.97,0.85);
2245  lprod.SetTextSize(0.04);
2246  lprod.SetBorderSize(0);
2247  lprod.SetFillColor(0);
2248 
2249  for(Int_t iprod = 0; iprod < nProd; iprod++)
2250  {
2251  hVertex[0][iprod] = (TH1F*) GetHisto("hZVertex",iprod);
2252  hVertex[1][iprod] = (TH1F*) GetHisto("hYVertex",iprod);
2253  hVertex[2][iprod] = (TH1F*) GetHisto("hXVertex",iprod);
2254 
2255  if ( !hVertex[0][iprod] ) return;
2256 
2257  hVertex[0][iprod]->Sumw2();
2258  hVertex[1][iprod]->Sumw2();
2259  hVertex[2][iprod]->Sumw2();
2260 
2261  lprod.AddEntry(hVertex[0][iprod],prodLeg[iprod],"P");
2262 
2263  for(Int_t ivertex = 0; ivertex < 3; ivertex++)
2264  {
2265  //hVertex[ivertex][iprod]->Sumw2();
2266 
2267  hVertex[ivertex][iprod]->Scale(1./nEvents[iprod]);
2268 
2269  //hVertex[ivertex][iprod]->SetTitle("Centrality");
2270  hVertex[ivertex][iprod]->SetYTitle("1/N_{events} dN/ d vertex");
2271  hVertex[ivertex][iprod]->SetTitleOffset(1.5,"Y");
2272  hVertex[ivertex][iprod]->SetMarkerColor(color[iprod]);
2273  hVertex[ivertex][iprod]->SetLineColor(color[iprod]);
2274  hVertex[ivertex][iprod]->SetMarkerStyle(20);
2275  if(ivertex==0)hVertex[ivertex][iprod]->SetAxisRange(-10,10.,"X");
2276  else hVertex[ivertex][iprod]->SetAxisRange(-1.5,1.5,"X");
2277  //hVertex[ivertex][iprod]->SetMaximum(1.1);
2278  //hVertex[ivertex][iprod]->SetMinimum(0);
2279 
2280  if(iprod > 0)
2281  {
2282  hRatVertex[ivertex][iprod-1] = (TH1F*)hVertex[ivertex][iprod]->Clone(Form("hRatVertex%s_%d" ,prod[iprod].Data(),ivertex));
2283 
2284  hRatVertex[ivertex][iprod-1]->Divide(hRatVertex[ivertex][iprod-1],hVertex[ivertex][0],1.000,1,errType);
2285  }
2286  }
2287  }
2288 
2290  // Make the plots
2292  // Vertex
2293  {
2294  TCanvas * cvertex = new TCanvas(Form("Vertex_%s",histoTag.Data()),"",3*500,2*500);
2295  cvertex->Divide(3,2);
2296  Int_t npannel = 1;
2297  for(Int_t ivertex = 0; ivertex < 3; ivertex++)
2298  {
2299  cvertex->cd(npannel);
2300  //gPad->SetLogy();
2301 
2302  //hVertex[ivertex][0]->Draw();
2303  for(Int_t iprod = 0; iprod < nProd; iprod++)
2304  {
2305  hVertex[ivertex][iprod]->Draw("same");
2306  }
2307 
2308  //lprod.Draw();
2309 
2310  cvertex->cd(npannel+3);
2311  gPad->SetGridy();
2312 
2313  //hRatVertex[ivertex][0]->SetTitle("");
2314  hRatVertex[ivertex][0]->SetYTitle(Form("Ratio data X / %s",prodLeg[0].Data()));
2315  hRatVertex[ivertex][0]->SetMinimum(0.90);
2316  hRatVertex[ivertex][0]->SetMaximum(1.10);
2317  hRatVertex[ivertex][0]->Draw("");
2318 
2319  for(Int_t iprod = 0; iprod < nProd-1; iprod++)
2320  {
2321  hRatVertex[ivertex][iprod]->Draw("same");
2322  }
2323  lprod.Draw();
2324 
2325  npannel++;
2326  }
2327  cvertex->Print(Form("%s_VertexComp.%s",histoTag.Data(),format.Data()));
2328  }
2329 }
2330 
2338 //_____________________________________________________
2340 {
2341  Bool_t ok = kTRUE;
2342  for(Int_t iprod = 0; iprod < nProd; iprod++)
2343  {
2344  // First, init to 0
2345  file [iprod] = 0;
2346  dir [iprod] = 0;
2347  histArr[iprod] = 0;
2348  nEvents[iprod] = 0;
2349 
2350  // now get them
2351  file[iprod] = new TFile(Form("%s/%s",prod[iprod].Data(),fileName.Data()),"read");
2352  if(file[iprod]->Get("hNEvents"))
2353  {
2354  nEvents[iprod] = ((TH1F*)file[iprod]->Get("hNEvents"))->GetEntries();
2355  printf("%s: nEvents %e\n",prod[iprod].Data(),nEvents[iprod]);
2356  }
2357 
2358  dir[iprod] = (TDirectoryFile*) file[iprod]->Get(listName);
2359  if(dir[iprod])
2360  {
2361  histArr[iprod] = (TList*) dir[iprod]->Get(trigName);
2362 
2363  if ( !histArr[iprod] ) continue;
2364  if ( histArr[iprod]->GetEntries() <= 0 ) continue;
2365 
2366  nEvents[iprod] = ((TH1F*)histArr[iprod]->FindObject("hNEvents"))->GetEntries();
2367  printf("%s: nEvents %e\n",prod[iprod].Data(),nEvents[iprod]);
2368  }
2369  else
2370  {
2371  histArr[iprod] = (TList*) file[iprod]->Get(trigName);
2372 
2373  if ( !histArr[iprod] ) continue;
2374  if ( histArr[iprod]->GetEntries() <= 0 ) continue;
2375 
2376  nEvents[iprod] = ((TH1F*)histArr[iprod]->FindObject("hNEvents"))->GetEntries();
2377  printf("%s: nEvents %e\n",prod[iprod].Data(),nEvents[iprod]);
2378  }
2379 
2380  if(!histArr[iprod])
2381  {
2382  printf("list %s not found\n",trigName.Data());
2383  ok = kFALSE;
2384  }
2385  }
2386 
2387  return ok;
2388 }
2389 
2398 //___________________________________
2399 TObject * GetHisto(TString histoName, Int_t iprod)
2400 {
2401  if ( histArr[iprod] )
2402  return histArr[iprod]->FindObject(histoName);
2403  else
2404  return file[iprod]->Get (histoName);
2405 }
2406 
2407 
void DrawProductionComparison(TString listName="Pi0IM_GammaTrackCorr_EMCAL", TString fileName="AnalysisResults.root", TString fileFormat="pdf")
TObject * GetHisto(TString histoName, Int_t iprod)
TString errType
output plots format: eps, pdf, etc.
double Double_t
Definition: External.C:58
Definition: External.C:236
TString fileName
TString format
file names tag, basically the trigger and calorimeter combination
void Centrality()
void InvMass(Int_t icalo, TString particle, TString fileName)
void Vertex()
TList * histArr[nProd]
TDirectory file where lists per trigger are stored in train ouput.
const TString calorimeter
Definition: anaM.C:36
void ClusterCells(Int_t icalo)
void Isol(Int_t icalo)
Double_t massD
int Int_t
Definition: External.C:63
const Int_t nProd
float Float_t
Definition: External.C:68
void Cell()
void MCParticle(Int_t icalo, TString particle)
TDirectoryFile * dir[nProd]
total number of productions to compare
TString prodLeg[]
TFile * file[nProd]
TList with histograms for a given trigger.
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)
TObject * FindObject(int bin, const char *nameH, const TList *lst, Bool_t normPerEvent=kTRUE)
void Track()
void Cluster(Int_t icalo)
Float_t nEvents[nProd]
Input train file.
TString histoTag
number of events container
void Correl(Int_t icalo)
Int_t color[]
pre-defined colors list
bool Bool_t
Definition: External.C:53
void ProcessTrigger(TString trigName="default", TString fileName="AnalysisResults.root", TString listName="Pi0IM_GammaTrackCorr_EMCAL")
TString prod[]
productions to be compared, directory name
void ShowerShape(Int_t icalo)
Bool_t GetFileAndList(TString fileName, TString listName, TString trigName)