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