]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/PartCorrDep/AliAnaCalorimeterQA.cxx
MC reading in AOD not implemented yet in AliAnaCalorimeterQA, change the train wagon
[u/mrichter/AliRoot.git] / PWG4 / PartCorrDep / AliAnaCalorimeterQA.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15 /* $Id: $ */
16
17 //_________________________________________________________________________
18 // Class to check results from simulations or reconstructed real data. 
19 // Fill few histograms and do some checking plots
20 //
21 //-- Author: Gustavo Conesa (INFN-LNF)
22 //_________________________________________________________________________
23
24
25 // --- ROOT system ---
26 //#include "Riostream.h"
27 #include "TObjArray.h"
28 #include "TParticle.h"
29 #include "TDatabasePDG.h"
30 #include "TCanvas.h"
31 #include "TPad.h"
32 #include "TROOT.h"
33 //#include "TH3F.h"
34 #include "TH2F.h"
35 #include "TLegend.h"
36
37 //---- AliRoot system ----
38 #include "AliAnaCalorimeterQA.h"
39 #include "AliCaloTrackReader.h"
40 #include "AliStack.h"
41 #include "AliAODCaloCells.h"
42 #include "AliAODCaloCluster.h"
43 #include "AliFidutialCut.h"
44 #include "AliESDtrack.h"
45 #include "AliESDCaloCluster.h"
46 #include "AliESDEvent.h"
47
48 ClassImp(AliAnaCalorimeterQA)
49   
50 //____________________________________________________________________________
51   AliAnaCalorimeterQA::AliAnaCalorimeterQA() : 
52     AliAnaPartCorrBaseClass(), fCalorimeter(""), fStyleMacro(""), fMakePlots(kFALSE),
53         fhE(0),fhPt(0),fhPhi(0),fhEta(0), fhEtaPhi(0), 
54     fhECharged(0),fhPtCharged(0),fhPhiCharged(0),fhEtaCharged(0), fhEtaPhiCharged(0), 
55     fhEChargedNoOut(0),fhPtChargedNoOut(0),fhPhiChargedNoOut(0),fhEtaChargedNoOut(0), fhEtaPhiChargedNoOut(0), 
56     fhDeltaE(0), fhDeltaPt(0),fhDeltaPhi(0),fhDeltaEta(0), fhRatioE(0), fhRatioPt(0),fhRatioPhi(0),fhRatioEta(0),
57     fh2E(0),fh2Pt(0),fh2Phi(0),fh2Eta(0), fhIM(0), fhAsym(0), fhNCellsPerCluster(0), fhNClusters(0), fhNCells(0), fhAmplitude(0), 
58     fhGenGamPt(0),fhGenGamEta(0),fhGenGamPhi(0),fhGenPi0Pt(0),fhGenPi0Eta(0),fhGenPi0Phi(0),
59     fhGenEtaPt(0),fhGenEtaEta(0),fhGenEtaPhi(0),fhGenOmegaPt(0),fhGenOmegaEta(0),fhGenOmegaPhi(0),
60     fhGenElePt(0),fhGenEleEta(0),fhGenElePhi(0), fhEMVxyz(0),  fhEMR(0), fhHaVxyz(0),  fhHaR(0),
61     fhGamE(0),fhGamPt(0),fhGamPhi(0),fhGamEta(0), 
62     fhGamDeltaE(0), fhGamDeltaPt(0),fhGamDeltaPhi(0),fhGamDeltaEta(0), fhGamRatioE(0), fhGamRatioPt(0),fhGamRatioPhi(0),fhGamRatioEta(0),
63     fhEleE(0),fhElePt(0),fhElePhi(0),fhEleEta(0),
64     fhPi0E(0),fhPi0Pt(0),fhPi0Phi(0),fhPi0Eta(0), fhNeHadE(0),fhNeHadPt(0),fhNeHadPhi(0),fhNeHadEta(0), 
65     fhChHadE(0),fhChHadPt(0),fhChHadPhi(0),fhChHadEta(0),
66         fhGamECharged(0),fhGamPtCharged(0),fhGamPhiCharged(0),fhGamEtaCharged(0), 
67         fhEleECharged(0),fhElePtCharged(0),fhElePhiCharged(0),fhEleEtaCharged(0),
68         fhPi0ECharged(0),fhPi0PtCharged(0),fhPi0PhiCharged(0),fhPi0EtaCharged(0), 
69         fhNeHadECharged(0),fhNeHadPtCharged(0),fhNeHadPhiCharged(0),fhNeHadEtaCharged(0), 
70         fhChHadECharged(0),fhChHadPtCharged(0),fhChHadPhiCharged(0),fhChHadEtaCharged(0),
71     fhGenGamAccE(0),fhGenGamAccPt(0),fhGenGamAccEta(0),fhGenGamAccPhi(0),
72     fhGenPi0AccE(0),fhGenPi0AccPt(0),fhGenPi0AccEta(0),fhGenPi0AccPhi(0),
73     fh1pOverE(0),fh1dR(0),fh2EledEdx(0), fh2MatchdEdx(0),fhMCEle1pOverE(0),fhMCEle1dR(0),fhMCEle2MatchdEdx(0),
74         fhMCChHad1pOverE(0),fhMCChHad1dR(0),fhMCChHad2MatchdEdx(0),fhMCNeutral1pOverE(0),fhMCNeutral1dR(0),fhMCNeutral2MatchdEdx(0),
75     fh1pOverER02(0), fhMCEle1pOverER02(0), fhMCChHad1pOverER02(0), fhMCNeutral1pOverER02(0)
76 {
77   //Default Ctor
78
79   //Initialize parameters
80   InitParameters();
81 }
82
83 //____________________________________________________________________________
84 AliAnaCalorimeterQA::AliAnaCalorimeterQA(const AliAnaCalorimeterQA & qa) :   
85   AliAnaPartCorrBaseClass(qa), fCalorimeter(qa.fCalorimeter), fStyleMacro(qa.fStyleMacro), fMakePlots(qa.fMakePlots),
86   fhE(qa.fhE),fhPt(qa.fhPt), fhPhi(qa.fhPhi), fhEta(qa.fhEta), 
87   fhEtaPhi(qa.fhEtaPhi), fhECharged(qa.fhECharged),fhPtCharged(qa.fhPtCharged),fhPhiCharged(qa.fhPhiCharged),
88   fhEtaCharged(qa.fhEtaCharged), fhEtaPhiCharged(qa.fhEtaPhiCharged), 
89   fhEChargedNoOut(qa.fhEChargedNoOut),fhPtChargedNoOut(qa.fhPtChargedNoOut),fhPhiChargedNoOut(qa.fhPhiChargedNoOut),
90   fhEtaChargedNoOut(qa.fhEtaChargedNoOut), fhEtaPhiChargedNoOut(qa.fhEtaPhiChargedNoOut), 
91   fhDeltaE(qa.fhDeltaE), fhDeltaPt(qa.fhDeltaPt), fhDeltaPhi(qa.fhDeltaPhi), fhDeltaEta(qa.fhDeltaEta),
92   fhRatioE(qa.fhRatioE), fhRatioPt(qa.fhRatioPt), fhRatioPhi(qa.fhRatioPhi), fhRatioEta(qa.fhRatioEta),
93   fh2E(qa.fh2E), fh2Pt(qa.fh2Pt), fh2Phi(qa.fh2Phi),fh2Eta(qa.fh2Eta), 
94   fhIM(qa.fhIM), fhAsym(qa.fhAsym), fhNCellsPerCluster(qa.fhNCellsPerCluster), fhNClusters(qa.fhNClusters), 
95   fhNCells(qa.fhNCells), fhAmplitude(qa.fhAmplitude),
96   fhGenGamPt(qa.fhGenGamPt), fhGenGamEta(qa.fhGenGamEta), fhGenGamPhi(qa.fhGenGamPhi),
97   fhGenPi0Pt(qa.fhGenPi0Pt), fhGenPi0Eta(qa.fhGenPi0Eta), fhGenPi0Phi(qa.fhGenPi0Phi),
98   fhGenEtaPt(qa.fhGenEtaPt), fhGenEtaEta(qa.fhGenEtaEta), fhGenEtaPhi(qa.fhGenEtaPhi),
99   fhGenOmegaPt(qa.fhGenOmegaPt), fhGenOmegaEta(qa.fhGenOmegaEta), fhGenOmegaPhi(qa.fhGenOmegaPhi),
100   fhGenElePt(qa.fhGenElePt), fhGenEleEta(qa.fhGenEleEta), fhGenElePhi(qa.fhGenElePhi), 
101   fhEMVxyz(qa.fhEMVxyz),  fhEMR(qa.fhEMR), fhHaVxyz(qa.fhHaVxyz),  fhHaR(qa.fhHaR),
102   fhGamE(qa.fhGamE),fhGamPt(qa.fhGamPt),fhGamPhi(qa.fhGamPhi),fhGamEta(qa.fhGamEta), 
103   fhGamDeltaE(qa.fhGamDeltaE), fhGamDeltaPt(qa.fhGamDeltaPt), fhGamDeltaPhi(qa.fhGamDeltaPhi), fhGamDeltaEta(qa.fhGamDeltaEta),
104   fhGamRatioE(qa.fhGamRatioE), fhGamRatioPt(qa.fhGamRatioPt), fhGamRatioPhi(qa.fhGamRatioPhi), fhGamRatioEta(qa.fhGamRatioEta),
105   fhEleE(qa.fhEleE),fhElePt(qa.fhElePt),fhElePhi(qa.fhElePhi),fhEleEta(qa.fhEleEta),
106   fhPi0E(qa.fhPi0E),fhPi0Pt(qa.fhPi0Pt),fhPi0Phi(qa.fhPi0Phi),fhPi0Eta(qa.fhPi0Eta), 
107   fhNeHadE(qa.fhNeHadE),fhNeHadPt(qa.fhNeHadPt),fhNeHadPhi(qa.fhNeHadPhi),fhNeHadEta(qa.fhNeHadEta), 
108   fhChHadE(qa.fhChHadE),fhChHadPt(qa.fhChHadPt),fhChHadPhi(qa.fhChHadPhi),fhChHadEta(qa.fhChHadEta),
109   fhGamECharged(qa.fhGamECharged),fhGamPtCharged(qa.fhGamPtCharged),fhGamPhiCharged(qa.fhGamPhiCharged),fhGamEtaCharged(qa.fhGamEtaCharged), 
110   fhEleECharged(qa.fhEleECharged),fhElePtCharged(qa.fhElePtCharged),fhElePhiCharged(qa.fhElePhiCharged),fhEleEtaCharged(qa.fhEleEtaCharged),
111   fhPi0ECharged(qa.fhPi0ECharged),fhPi0PtCharged(qa.fhPi0PtCharged),fhPi0PhiCharged(qa.fhPi0PhiCharged),fhPi0EtaCharged(qa.fhPi0EtaCharged), 
112   fhNeHadECharged(qa.fhNeHadECharged),fhNeHadPtCharged(qa.fhNeHadPtCharged),fhNeHadPhiCharged(qa.fhNeHadPhiCharged),fhNeHadEtaCharged(qa.fhNeHadEtaCharged), 
113   fhChHadECharged(qa.fhChHadECharged),fhChHadPtCharged(qa.fhChHadPtCharged),fhChHadPhiCharged(qa.fhChHadPhiCharged),fhChHadEtaCharged(qa.fhChHadEtaCharged),
114   fhGenGamAccE(qa.fhGenGamAccE),fhGenGamAccPt(qa.fhGenGamAccPt),fhGenGamAccEta(qa.fhGenGamAccEta),fhGenGamAccPhi(qa.fhGenGamAccPhi),
115   fhGenPi0AccE(qa.fhGenPi0AccE),fhGenPi0AccPt(qa.fhGenPi0AccPt),fhGenPi0AccEta(qa.fhGenPi0AccEta),fhGenPi0AccPhi(qa.fhGenPi0AccPhi),
116   fh1pOverE(qa.fh1pOverE),fh1dR(qa.fh1dR),fh2EledEdx(qa.fh2EledEdx), fh2MatchdEdx(qa.fh2MatchdEdx),
117   fhMCEle1pOverE(qa.fhMCEle1pOverE),fhMCEle1dR(qa.fhMCEle1dR), fhMCEle2MatchdEdx(qa.fhMCEle2MatchdEdx),
118   fhMCChHad1pOverE(qa.fhMCChHad1pOverE),fhMCChHad1dR(qa.fhMCChHad1dR), fhMCChHad2MatchdEdx(qa.fhMCChHad2MatchdEdx),
119   fhMCNeutral1pOverE(qa.fhMCNeutral1pOverE),fhMCNeutral1dR(qa.fhMCNeutral1dR), fhMCNeutral2MatchdEdx(qa.fhMCNeutral2MatchdEdx),
120   fh1pOverER02(qa.fh1pOverER02), fhMCEle1pOverER02(qa.fhMCEle1pOverER02),fhMCChHad1pOverER02(qa.fhMCChHad1pOverER02), fhMCNeutral1pOverER02(qa.fhMCNeutral1pOverER02)
121 {
122   // cpy ctor
123   
124 }
125
126 //_________________________________________________________________________
127 AliAnaCalorimeterQA & AliAnaCalorimeterQA::operator = (const AliAnaCalorimeterQA & qa)
128 {
129   // assignment operator
130
131   if(this == &qa)return *this;
132   ((AliAnaPartCorrBaseClass *)this)->operator=(qa);
133
134   fCalorimeter  = qa.fCalorimeter;
135   fStyleMacro   = qa.fStyleMacro;       
136   fMakePlots  = qa.fMakePlots;
137   
138   fhE      = qa.fhE;
139   fhPt     = qa.fhPt;
140   fhPhi    = qa.fhPhi;
141   fhEta    = qa.fhEta;
142   fhEtaPhi = qa.fhEtaPhi;
143
144   fhECharged      = qa.fhECharged;
145   fhPtCharged     = qa.fhPtCharged;
146   fhPhiCharged    = qa.fhPhiCharged;
147   fhEtaCharged    = qa.fhEtaCharged;
148   fhEtaPhiCharged = qa.fhEtaPhiCharged;
149
150   fhEChargedNoOut      = qa.fhEChargedNoOut;
151   fhPtChargedNoOut     = qa.fhPtChargedNoOut;
152   fhPhiChargedNoOut    = qa.fhPhiChargedNoOut;
153   fhEtaChargedNoOut    = qa.fhEtaChargedNoOut;
154   fhEtaPhiChargedNoOut = qa.fhEtaPhiChargedNoOut;
155         
156   fhIM   = qa.fhIM;
157   fhAsym = qa.fhAsym;
158         
159   fhNCellsPerCluster = qa.fhNCellsPerCluster;
160   fhNClusters        = qa.fhNClusters;
161         
162   fhDeltaE   = qa.fhDeltaE;     
163   fhDeltaPt  = qa.fhDeltaPt;
164   fhDeltaPhi = qa.fhDeltaPhi;
165   fhDeltaEta = qa.fhDeltaEta;
166         
167   fhRatioE   = qa.fhRatioE;     
168   fhRatioPt  = qa.fhRatioPt;
169   fhRatioPhi = qa.fhRatioPhi;
170   fhRatioEta = qa.fhRatioEta;
171         
172         
173   fh2E   = qa.fh2E;     
174   fh2Pt  = qa.fh2Pt;
175   fh2Phi = qa.fh2Phi;
176   fh2Eta = qa.fh2Eta;
177         
178   fhNCells    = qa.fhNCells;
179   fhAmplitude = qa.fhAmplitude;
180
181   fhGenGamPt = qa.fhGenGamPt  ; fhGenGamEta = qa.fhGenGamEta  ; fhGenGamPhi = qa.fhGenGamPhi  ;
182   fhGenPi0Pt = qa.fhGenPi0Pt  ; fhGenPi0Eta = qa.fhGenPi0Eta  ; fhGenPi0Phi = qa.fhGenPi0Phi  ;
183   fhGenEtaPt = qa.fhGenEtaPt  ; fhGenEtaEta = qa.fhGenEtaEta  ; fhGenEtaPhi = qa.fhGenEtaPhi  ;
184   fhGenOmegaPt = qa.fhGenOmegaPt  ; fhGenOmegaEta = qa.fhGenOmegaEta  ; fhGenOmegaPhi = qa.fhGenOmegaPhi  ;
185   fhGenElePt = qa.fhGenElePt  ; fhGenEleEta = qa.fhGenEleEta  ; fhGenElePhi = qa.fhGenElePhi ;  
186
187   fhEMVxyz = qa.fhEMVxyz ;  fhEMR = qa.fhEMR ; fhHaVxyz = qa.fhHaVxyz ;  fhHaR = qa.fhHaR ;
188   fhGamE = qa.fhGamE ;fhGamPt = qa.fhGamPt ;fhGamPhi = qa.fhGamPhi ;fhGamEta = qa.fhGamEta ; 
189   fhGamDeltaE   = qa.fhDeltaE; fhGamDeltaPt  = qa.fhDeltaPt; fhGamDeltaPhi = qa.fhDeltaPhi; fhGamDeltaEta = qa.fhDeltaEta;
190         
191   fhGamRatioE   = qa.fhGamRatioE;  fhGamRatioPt  = qa.fhGamRatioPt;  fhGamRatioPhi = qa.fhGamRatioPhi;  fhGamRatioEta = qa.fhGamRatioEta;
192
193   fhEleE = qa.fhEleE ;fhElePt = qa.fhElePt ;fhElePhi = qa.fhElePhi ;fhEleEta = qa.fhEleEta ;
194   fhPi0E = qa.fhPi0E ;fhPi0Pt = qa.fhPi0Pt ;fhPi0Phi = qa.fhPi0Phi ;fhPi0Eta = qa.fhPi0Eta ; 
195   fhNeHadE = qa.fhNeHadE ;fhNeHadPt = qa.fhNeHadPt ;fhNeHadPhi = qa.fhNeHadPhi ;fhNeHadEta = qa.fhNeHadEta ; 
196   fhChHadE = qa.fhChHadE ;fhChHadPt = qa.fhChHadPt ;fhChHadPhi = qa.fhChHadPhi ;fhChHadEta = qa.fhChHadEta ;
197   fhGenGamAccE = qa.fhGenGamAccE ;  fhGenPi0AccE = qa.fhGenPi0AccE ;
198   fhGenGamAccPt = qa.fhGenGamAccPt ;fhGenGamAccEta = qa.fhGenGamAccEta ;fhGenGamAccPhi = qa.fhGenGamAccPhi ;
199   fhGenPi0AccPt = qa.fhGenPi0AccPt ;fhGenPi0AccEta = qa.fhGenPi0AccEta; fhGenPi0AccPhi = qa.fhGenPi0AccPhi ;    
200                 
201   fhGamECharged = qa.fhGamECharged; fhGamPtCharged = qa.fhGamPtCharged; fhGamPhiCharged = qa.fhGamPhiCharged; fhGamEtaCharged = qa.fhGamEtaCharged;  
202   fhEleECharged = qa.fhEleECharged; fhElePtCharged = qa.fhElePtCharged; fhElePhiCharged = qa.fhElePhiCharged; fhEleEtaCharged = qa.fhEleEtaCharged; 
203   fhPi0ECharged = qa.fhPi0ECharged; fhPi0PtCharged = qa.fhPi0PtCharged; fhPi0PhiCharged = qa.fhPi0PhiCharged; fhPi0EtaCharged = qa.fhPi0EtaCharged;  
204   fhNeHadECharged = qa.fhNeHadECharged; fhNeHadPtCharged = qa.fhNeHadPtCharged; fhNeHadPhiCharged = qa.fhNeHadPhiCharged; fhNeHadEtaCharged = qa.fhNeHadEtaCharged;  
205   fhChHadECharged = qa.fhChHadECharged; fhChHadPtCharged = qa.fhChHadPtCharged; fhChHadPhiCharged = qa.fhChHadPhiCharged; fhChHadEtaCharged = qa.fhChHadEtaCharged;     
206         
207   fh1pOverE    = qa.fh1pOverE;
208   fh1dR        = qa.fh1dR;
209   fh2MatchdEdx = qa.fh2MatchdEdx;
210   fh2EledEdx   = qa.fh2EledEdx; 
211         
212   fhMCEle1pOverE    = qa.fhMCEle1pOverE; 
213   fhMCEle1dR        = qa.fhMCEle1dR; 
214   fhMCEle2MatchdEdx = qa.fhMCEle2MatchdEdx ;
215         
216   fhMCChHad1pOverE = qa.fhMCChHad1pOverE; fhMCChHad1dR = qa.fhMCChHad1dR;  fhMCChHad2MatchdEdx = qa.fhMCChHad2MatchdEdx; 
217   fhMCNeutral1pOverE = qa.fhMCNeutral1pOverE; fhMCNeutral1dR = qa.fhMCNeutral1dR;  fhMCNeutral2MatchdEdx = qa.fhMCNeutral2MatchdEdx; 
218   fh1pOverER02 = qa.fh1pOverER02;  fhMCEle1pOverER02 = qa.fhMCEle1pOverER02;  fhMCChHad1pOverER02 = qa.fhMCChHad1pOverER02;  
219   fhMCNeutral1pOverER02 = qa.fhMCNeutral1pOverER02;
220         
221   return *this;
222
223 }
224
225 //________________________________________________________________________
226 TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
227 {  
228         // Create histograms to be saved in output file and 
229         // store them in fOutputContainer
230     
231         TList * outputContainer = new TList() ; 
232         outputContainer->SetName("QAHistos") ; 
233         
234         Int_t nptbins  = GetHistoNPtBins();
235         Int_t nphibins = GetHistoNPhiBins();
236         Int_t netabins = GetHistoNEtaBins();
237         Float_t ptmax  = GetHistoPtMax();
238         Float_t phimax = GetHistoPhiMax();
239         Float_t etamax = GetHistoEtaMax();
240         Float_t ptmin  = GetHistoPtMin();
241         Float_t phimin = GetHistoPhiMin();
242         Float_t etamin = GetHistoEtaMin();      
243         
244         fhE  = new TH1F ("hE","E reconstructed", nptbins,ptmin,ptmax); 
245         fhE->SetXTitle("E (GeV)");
246         outputContainer->Add(fhE);
247         
248         fhPt  = new TH1F ("hPt","p_{T} reconstructed", nptbins,ptmin,ptmax); 
249         fhPt->SetXTitle("p_{T} (GeV/c)");
250         outputContainer->Add(fhPt);
251         
252         fhPhi  = new TH1F ("hPhi","#phi reconstructed",nphibins,phimin,phimax); 
253         fhPhi->SetXTitle("#phi (rad)");
254         outputContainer->Add(fhPhi);
255         
256         fhEta  = new TH1F ("hEta","#eta reconstructed",netabins,etamin,etamax); 
257         fhEta->SetXTitle("#eta ");
258         outputContainer->Add(fhEta);
259         
260         fhEtaPhi  = new TH2F ("hEtaPhi","#eta vs #phi, reconstructed",netabins,etamin,etamax,nphibins,phimin,phimax); 
261         fhEtaPhi->SetXTitle("#eta ");
262         fhEtaPhi->SetYTitle("#phi ");
263         outputContainer->Add(fhEtaPhi);
264         
265         fhECharged  = new TH1F ("hECharged","E reconstructed, matched with track", nptbins,ptmin,ptmax); 
266         fhECharged->SetXTitle("E (GeV)");
267         outputContainer->Add(fhECharged);
268         
269         fhPtCharged  = new TH1F ("hPtCharged","p_{T} reconstructed, matched with track", nptbins,ptmin,ptmax); 
270         fhPtCharged->SetXTitle("p_{T} (GeV/c)");
271         outputContainer->Add(fhPtCharged);
272         
273         fhPhiCharged  = new TH1F ("hPhiCharged","#phi reconstructed, matched with track",nphibins,phimin,phimax); 
274         fhPhiCharged->SetXTitle("#phi (rad)");
275         outputContainer->Add(fhPhiCharged);
276         
277         fhEtaCharged  = new TH1F ("hEtaCharged","#eta reconstructed, matched with track",netabins,etamin,etamax); 
278         fhEtaCharged->SetXTitle("#eta ");
279         outputContainer->Add(fhEtaCharged);
280         
281         fhEtaPhiCharged  = new TH2F ("hEtaPhiCharged","#eta vs #phi, reconstructed , matched with track",netabins,etamin,etamax,nphibins,phimin,phimax); 
282         fhEtaPhiCharged->SetXTitle("#eta ");
283         fhEtaPhiCharged->SetYTitle("#phi ");
284         outputContainer->Add(fhEtaPhiCharged);  
285         
286
287         fhEChargedNoOut  = new TH1F ("hEChargedNoOut","E reconstructed, matched with track, no output track params", nptbins,ptmin,ptmax); 
288         fhEChargedNoOut->SetXTitle("E (GeV)");
289         outputContainer->Add(fhEChargedNoOut);
290         
291         fhPtChargedNoOut  = new TH1F ("hPtChargedNoOut","p_{T} reconstructed, matched with track, no output track params", nptbins,ptmin,ptmax); 
292         fhPtChargedNoOut->SetXTitle("p_{T} (GeV/c)");
293         outputContainer->Add(fhPtChargedNoOut);
294         
295         fhPhiChargedNoOut  = new TH1F ("hPhiChargedNoOut","#phi reconstructed, matched with track, no output track params",nphibins,phimin,phimax); 
296         fhPhiChargedNoOut->SetXTitle("#phi (rad)");
297         outputContainer->Add(fhPhiChargedNoOut);
298         
299         fhEtaChargedNoOut  = new TH1F ("hEtaChargedNoOut","#eta reconstructed, matched with track, no output track params",netabins,etamin,etamax); 
300         fhEtaChargedNoOut->SetXTitle("#eta ");
301         outputContainer->Add(fhEtaChargedNoOut);
302         
303         fhEtaPhiChargedNoOut  = new TH2F ("hEtaPhiChargedNoOut","#eta vs #phi, reconstructed , matched with track, no output track params",netabins,etamin,etamax,nphibins,phimin,phimax); 
304         fhEtaPhiChargedNoOut->SetXTitle("#eta ");
305         fhEtaPhiChargedNoOut->SetYTitle("#phi ");
306         outputContainer->Add(fhEtaPhiChargedNoOut);     
307
308         fhIM  = new TH2F ("hIM","Cluster pairs Invariant mass vs reconstructed pair energy",nptbins,ptmin,ptmax,200,0,1); 
309         fhIM->SetXTitle("E_{cluster pairs} (GeV) ");
310         fhIM->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
311         outputContainer->Add(fhIM);
312         
313         fhAsym  = new TH2F ("hAssym","Cluster pairs Asymmetry vs reconstructed pair energy",nptbins,ptmin,ptmax,100,0,1); 
314         fhAsym->SetXTitle("E_{cluster pairs} (GeV) ");
315         fhAsym->SetYTitle("Asymmetry");
316         outputContainer->Add(fhAsym);   
317         
318         fhNCellsPerCluster  = new TH2F ("hNCellsPerCluster","# cells per cluster vs cluster energy", nptbins,ptmin,ptmax, 100,0,1000); 
319         fhNCellsPerCluster->SetXTitle("E (GeV)");
320         fhNCellsPerCluster->SetYTitle("n cells");
321         outputContainer->Add(fhNCellsPerCluster);
322         
323         fhNClusters  = new TH1F ("hNClusters","# clusters", 300,0,300); 
324         fhNClusters->SetXTitle("number of clusters");
325         outputContainer->Add(fhNClusters);
326         
327         //Calo cells
328         fhNCells  = new TH1F ("hNCells","# cells", 13000,0,13000); 
329         fhNCells->SetXTitle("n cells");
330         outputContainer->Add(fhNCells);
331     
332         fhAmplitude  = new TH1F ("hAmplitude","Amplitude", 100,0,1000); 
333         fhAmplitude->SetXTitle("Amplitude ");
334         outputContainer->Add(fhAmplitude);
335         
336         if(IsDataMC()){
337                 
338                 fhDeltaE  = new TH1F ("hDeltaE","MC - Reco E ", 200,-50,50); 
339                 fhDeltaE->SetXTitle("#Delta E (GeV)");
340                 outputContainer->Add(fhDeltaE);
341                 
342                 fhDeltaPt  = new TH1F ("hDeltaPt","MC - Reco p_{T} ", 200,-50,50); 
343                 fhDeltaPt->SetXTitle("#Delta p_{T} (GeV/c)");
344                 outputContainer->Add(fhDeltaPt);
345                 
346                 fhDeltaPhi  = new TH1F ("hDeltaPhi","MC - Reco #phi ",100,-2,2); 
347                 fhDeltaPhi->SetXTitle("#Delta #phi (rad)");
348                 outputContainer->Add(fhDeltaPhi);
349                 
350                 fhDeltaEta  = new TH1F ("hDeltaEta","MC- Reco #eta",100,-1,1); 
351                 fhDeltaEta->SetXTitle("#Delta #eta ");
352                 outputContainer->Add(fhDeltaEta);
353                 
354                 fhRatioE  = new TH1F ("hRatioE","Reco/MC E ", 200,0,2); 
355                 fhRatioE->SetXTitle("E_{reco}/E_{gen}");
356                 outputContainer->Add(fhRatioE);
357                 
358                 fhRatioPt  = new TH1F ("hRatioPt","Reco/MC p_{T} ", 200,0,2); 
359                 fhRatioPt->SetXTitle("p_{T, reco}/p_{T, gen}");
360                 outputContainer->Add(fhRatioPt);
361                 
362                 fhRatioPhi  = new TH1F ("hRatioPhi","Reco/MC #phi ",200,0,2); 
363                 fhRatioPhi->SetXTitle("#phi_{reco}/#phi_{gen}");
364                 outputContainer->Add(fhRatioPhi);
365                 
366                 fhRatioEta  = new TH1F ("hRatioEta","Reco/MC #eta",200,0,2); 
367                 fhRatioEta->SetXTitle("#eta_{reco}/#eta_{gen} ");
368                 outputContainer->Add(fhRatioEta);
369                 
370                 fh2E  = new TH2F ("h2E","E distribution, reconstructed vs generated", nptbins,ptmin,ptmax,nptbins,ptmin,ptmax); 
371                 fh2E->SetXTitle("E_{rec} (GeV)");
372                 fh2E->SetYTitle("E_{gen} (GeV)");
373                 outputContainer->Add(fh2E);       
374                 
375                 fh2Pt  = new TH2F ("h2Pt","p_T distribution, reconstructed vs generated", nptbins,ptmin,ptmax,nptbins,ptmin,ptmax); 
376                 fh2Pt->SetXTitle("p_{T,rec} (GeV/c)");
377                 fh2Pt->SetYTitle("p_{T,gen} (GeV/c)");
378                 outputContainer->Add(fh2Pt);
379                 
380                 fh2Phi  = new TH2F ("h2Phi","#phi distribution, reconstructed vs generated", nphibins,phimin,phimax, nphibins,phimin,phimax); 
381                 fh2Phi->SetXTitle("#phi_{rec} (rad)");
382                 fh2Phi->SetYTitle("#phi_{gen} (rad)");
383                 outputContainer->Add(fh2Phi);
384                 
385                 fh2Eta  = new TH2F ("h2Eta","#eta distribution, reconstructed vs generated", netabins,etamin,etamax,netabins,etamin,etamax); 
386                 fh2Eta->SetXTitle("#eta_{rec} ");
387                 fh2Eta->SetYTitle("#eta_{gen} ");
388                 outputContainer->Add(fh2Eta);
389                 
390                 //Fill histos depending on origin of cluster
391                 fhGamE  = new TH2F ("hGamE","E reconstructed vs E generated from #gamma", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
392                 fhGamE->SetXTitle("E_{rec} (GeV)");
393                 fhGamE->SetXTitle("E_{gen} (GeV)");
394                 outputContainer->Add(fhGamE);
395                 
396                 fhGamPt  = new TH2F ("hGamPt","p_{T} reconstructed vs E generated from #gamma", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
397                 fhGamPt->SetXTitle("p_{T rec} (GeV/c)");
398                 fhGamPt->SetYTitle("p_{T gen} (GeV/c)");
399                 outputContainer->Add(fhGamPt);
400                 
401                 fhGamPhi  = new TH2F ("hGamPhi","#phi reconstructed vs E generated from #gamma",nphibins,phimin,phimax,nphibins,phimin,phimax); 
402                 fhGamPhi->SetXTitle("#phi_{rec} (rad)");
403                 fhGamPhi->SetYTitle("#phi_{gen} (rad)");
404                 outputContainer->Add(fhGamPhi);
405                 
406                 fhGamEta  = new TH2F ("hGamEta","#eta reconstructed vs E generated from #gamma",netabins,etamin,etamax,netabins,etamin,etamax); 
407                 fhGamEta->SetXTitle("#eta_{rec} ");
408                 fhGamEta->SetYTitle("#eta_{gen} ");
409                 outputContainer->Add(fhGamEta);
410                 
411                 fhGamDeltaE  = new TH1F ("hGamDeltaE","#gamma MC - Reco E ", 200,-50,50); 
412                 fhGamDeltaE->SetXTitle("#Delta E (GeV)");
413                 outputContainer->Add(fhGamDeltaE);
414                 
415                 fhGamDeltaPt  = new TH1F ("hGamDeltaPt","#gamma MC - Reco p_{T} ", 200,-50,50); 
416                 fhGamDeltaPt->SetXTitle("#Delta p_{T} (GeV/c)");
417                 outputContainer->Add(fhGamDeltaPt);
418                 
419                 fhGamDeltaPhi  = new TH1F ("hGamDeltaPhi","#gamma MC - Reco #phi ",100,-2,2); 
420                 fhGamDeltaPhi->SetXTitle("#Delta #phi (rad)");
421                 outputContainer->Add(fhGamDeltaPhi);
422                 
423                 fhGamDeltaEta  = new TH1F ("hGamDeltaEta","#gamma MC- Reco #eta",100,-1,1); 
424                 fhGamDeltaEta->SetXTitle("#Delta #eta ");
425                 outputContainer->Add(fhGamDeltaEta);
426                 
427                 fhGamRatioE  = new TH1F ("hGamRatioE","#gamma Reco/MC E ", 200,0,2); 
428                 fhGamRatioE->SetXTitle("E_{reco}/E_{gen}");
429                 outputContainer->Add(fhGamRatioE);
430                 
431                 fhGamRatioPt  = new TH1F ("hGamRatioPt","#gamma Reco/MC p_{T} ", 200,0,2); 
432                 fhGamRatioPt->SetXTitle("p_{T, reco}/p_{T, gen}");
433                 outputContainer->Add(fhGamRatioPt);
434                 
435                 fhGamRatioPhi  = new TH1F ("hGamRatioPhi","#gamma Reco/MC #phi ",200,0,2); 
436                 fhGamRatioPhi->SetXTitle("#phi_{reco}/#phi_{gen}");
437                 outputContainer->Add(fhGamRatioPhi);
438                 
439                 fhGamRatioEta  = new TH1F ("hGamRatioEta","#gamma Reco/MC #eta",200,0,2); 
440                 fhGamRatioEta->SetXTitle("#eta_{reco}/#eta_{gen} ");
441                 outputContainer->Add(fhGamRatioEta);
442
443                 fhPi0E  = new TH2F ("hPi0E","E reconstructed vs E generated from #pi^{0}", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
444                 fhPi0E->SetXTitle("E_{rec} (GeV)");
445                 fhPi0E->SetYTitle("E_{gen} (GeV)");
446                 outputContainer->Add(fhPi0E);
447                 
448                 fhPi0Pt  = new TH2F ("hPi0Pt","p_{T} reconstructed vs E generated from #pi^{0}", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
449                 fhPi0Pt->SetXTitle("p_{T rec} (GeV/c)");
450                 fhPi0Pt->SetYTitle("p_{T gen} (GeV/c)");
451                 outputContainer->Add(fhPi0Pt);
452                 
453                 fhPi0Phi  = new TH2F ("hPi0Phi","#phi reconstructed vs E generated from #pi^{0}",nphibins,phimin,phimax,nphibins,phimin,phimax); 
454                 fhPi0Phi->SetXTitle("#phi_{rec} (rad)");
455                 fhPi0Phi->SetYTitle("#phi_{gen} (rad)");
456                 outputContainer->Add(fhPi0Phi);
457                 
458                 fhPi0Eta  = new TH2F ("hPi0Eta","#eta reconstructed vs E generated from #pi^{0}",netabins,etamin,etamax,netabins,etamin,etamax); 
459                 fhPi0Eta->SetXTitle("#eta_{rec} ");
460                 fhPi0Eta->SetYTitle("#eta_{gen} ");
461                 outputContainer->Add(fhPi0Eta);
462                 
463                 fhEleE  = new TH2F ("hEleE","E reconstructed vs E generated from e^{#pm}", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
464                 fhEleE->SetXTitle("E_{rec} (GeV)");
465                 fhEleE->SetXTitle("E_{gen} (GeV)");             
466                 outputContainer->Add(fhEleE);           
467                 
468                 fhElePt  = new TH2F ("hElePt","p_{T} reconstructed vs E generated from e^{#pm}", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
469                 fhElePt->SetXTitle("p_{T rec} (GeV/c)");
470                 fhElePt->SetYTitle("p_{T gen} (GeV/c)");
471                 outputContainer->Add(fhElePt);
472                 
473                 fhElePhi  = new TH2F ("hElePhi","#phi reconstructed vs E generated from e^{#pm}",nphibins,phimin,phimax,nphibins,phimin,phimax); 
474                 fhElePhi->SetXTitle("#phi_{rec} (rad)");
475                 fhElePhi->SetYTitle("#phi_{gen} (rad)");
476                 outputContainer->Add(fhElePhi);
477                 
478                 fhEleEta  = new TH2F ("hEleEta","#eta reconstructed vs E generated from e^{#pm}",netabins,etamin,etamax,netabins,etamin,etamax); 
479                 fhEleEta->SetXTitle("#eta_{rec} ");
480                 fhEleEta->SetYTitle("#eta_{gen} ");
481                 outputContainer->Add(fhEleEta);
482                 
483                 fhNeHadE  = new TH2F ("hNeHadE","E reconstructed vs E generated from neutral hadron", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
484                 fhNeHadE->SetXTitle("E_{rec} (GeV)");
485                 fhNeHadE->SetYTitle("E_{gen} (GeV)");
486                 outputContainer->Add(fhNeHadE);
487                 
488                 fhNeHadPt  = new TH2F ("hNeHadPt","p_{T} reconstructed vs E generated from neutral hadron", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
489                 fhNeHadPt->SetXTitle("p_{T rec} (GeV/c)");
490                 fhNeHadPt->SetYTitle("p_{T gen} (GeV/c)");
491                 outputContainer->Add(fhNeHadPt);
492                 
493                 fhNeHadPhi  = new TH2F ("hNeHadPhi","#phi reconstructed vs E generated from neutral hadron",nphibins,phimin,phimax,nphibins,phimin,phimax); 
494                 fhNeHadPhi->SetXTitle("#phi_{rec} (rad)");
495                 fhNeHadPhi->SetYTitle("#phi_{gen} (rad)");
496                 outputContainer->Add(fhNeHadPhi);
497                 
498                 fhNeHadEta  = new TH2F ("hNeHadEta","#eta reconstructed vs E generated from neutral hadron",netabins,etamin,etamax,netabins,etamin,etamax); 
499                 fhNeHadEta->SetXTitle("#eta_{rec} ");
500                 fhNeHadEta->SetYTitle("#eta_{gen} ");
501                 outputContainer->Add(fhNeHadEta);
502                 
503                 fhChHadE  = new TH2F ("hChHadE","E reconstructed vs E generated from charged hadron", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
504                 fhChHadE->SetXTitle("E_{rec} (GeV)");
505                 fhChHadE->SetYTitle("E_{gen} (GeV)");
506                 outputContainer->Add(fhChHadE);
507                 
508                 fhChHadPt  = new TH2F ("hChHadPt","p_{T} reconstructed vs E generated from charged hadron", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
509                 fhChHadPt->SetXTitle("p_{T rec} (GeV/c)");
510                 fhChHadPt->SetYTitle("p_{T gen} (GeV/c)");
511                 outputContainer->Add(fhChHadPt);
512                 
513                 fhChHadPhi  = new TH2F ("hChHadPhi","#phi reconstructed vs E generated from charged hadron",nphibins,phimin,phimax,nphibins,phimin,phimax); 
514                 fhChHadPhi->SetXTitle("#phi_{rec} (rad)");
515                 fhChHadPhi->SetYTitle("#phi_{gen} (rad)");
516                 outputContainer->Add(fhChHadPhi);
517                 
518                 fhChHadEta  = new TH2F ("hChHadEta","#eta reconstructed vs E generated from charged hadron",netabins,etamin,etamax,netabins,etamin,etamax); 
519                 fhChHadEta->SetXTitle("#eta_{rec} ");
520                 fhChHadEta->SetYTitle("#eta_{gen} ");
521                 outputContainer->Add(fhChHadEta);
522                 
523                 //Charged clusters
524                 
525                 fhGamECharged  = new TH2F ("hGamECharged","E reconstructed vs E generated from #gamma, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
526                 fhGamECharged->SetXTitle("E_{rec} (GeV)");
527                 fhGamECharged->SetXTitle("E_{gen} (GeV)");
528                 outputContainer->Add(fhGamECharged);
529                 
530                 fhGamPtCharged  = new TH2F ("hGamPtCharged","p_{T} reconstructed vs E generated from #gamma, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
531                 fhGamPtCharged->SetXTitle("p_{T rec} (GeV/c)");
532                 fhGamPtCharged->SetYTitle("p_{T gen} (GeV/c)");
533                 outputContainer->Add(fhGamPtCharged);
534                 
535                 fhGamPhiCharged  = new TH2F ("hGamPhiCharged","#phi reconstructed vs E generated from #gamma, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
536                 fhGamPhiCharged->SetXTitle("#phi_{rec} (rad)");
537                 fhGamPhiCharged->SetYTitle("#phi_{gen} (rad)");
538                 outputContainer->Add(fhGamPhiCharged);
539                 
540                 fhGamEtaCharged  = new TH2F ("hGamEtaCharged","#eta reconstructed vs E generated from #gamma, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
541                 fhGamEtaCharged->SetXTitle("#eta_{rec} ");
542                 fhGamEtaCharged->SetYTitle("#eta_{gen} ");
543                 outputContainer->Add(fhGamEtaCharged);
544                 
545                 fhPi0ECharged  = new TH2F ("hPi0ECharged","E reconstructed vs E generated from #pi^{0}, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
546                 fhPi0ECharged->SetXTitle("E_{rec} (GeV)");
547                 fhPi0ECharged->SetYTitle("E_{gen} (GeV)");
548                 outputContainer->Add(fhPi0ECharged);
549                 
550                 fhPi0PtCharged  = new TH2F ("hPi0PtCharged","p_{T} reconstructed vs E generated from #pi^{0}, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
551                 fhPi0PtCharged->SetXTitle("p_{T rec} (GeV/c)");
552                 fhPi0PtCharged->SetYTitle("p_{T gen} (GeV/c)");
553                 outputContainer->Add(fhPi0PtCharged);
554                 
555                 fhPi0PhiCharged  = new TH2F ("hPi0PhiCharged","#phi reconstructed vs E generated from #pi^{0}, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
556                 fhPi0PhiCharged->SetXTitle("#phi_{rec} (rad)");
557                 fhPi0PhiCharged->SetYTitle("#phi_{gen} (rad)");
558                 outputContainer->Add(fhPi0PhiCharged);
559                 
560                 fhPi0EtaCharged  = new TH2F ("hPi0EtaCharged","#eta reconstructed vs E generated from #pi^{0}, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
561                 fhPi0EtaCharged->SetXTitle("#eta_{rec} ");
562                 fhPi0EtaCharged->SetYTitle("#eta_{gen} ");
563                 outputContainer->Add(fhPi0EtaCharged);
564                 
565                 fhEleECharged  = new TH2F ("hEleECharged","E reconstructed vs E generated from e^{#pm}, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
566                 fhEleECharged->SetXTitle("E_{rec} (GeV)");
567                 fhEleECharged->SetXTitle("E_{gen} (GeV)");              
568                 outputContainer->Add(fhEleECharged);            
569                 
570                 fhElePtCharged  = new TH2F ("hElePtCharged","p_{T} reconstructed vs E generated from e^{#pm}, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
571                 fhElePtCharged->SetXTitle("p_{T rec} (GeV/c)");
572                 fhElePtCharged->SetYTitle("p_{T gen} (GeV/c)");
573                 outputContainer->Add(fhElePtCharged);
574                 
575                 fhElePhiCharged  = new TH2F ("hElePhiCharged","#phi reconstructed vs E generated from e^{#pm}, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
576                 fhElePhiCharged->SetXTitle("#phi_{rec} (rad)");
577                 fhElePhiCharged->SetYTitle("#phi_{gen} (rad)");
578                 outputContainer->Add(fhElePhiCharged);
579                 
580                 fhEleEtaCharged  = new TH2F ("hEleEtaCharged","#eta reconstructed vs E generated from e^{#pm}, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
581                 fhEleEtaCharged->SetXTitle("#eta_{rec} ");
582                 fhEleEtaCharged->SetYTitle("#eta_{gen} ");
583                 outputContainer->Add(fhEleEtaCharged);
584                 
585                 fhNeHadECharged  = new TH2F ("hNeHadECharged","E reconstructed vs E generated from neutral hadron, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
586                 fhNeHadECharged->SetXTitle("E_{rec} (GeV)");
587                 fhNeHadECharged->SetYTitle("E_{gen} (GeV)");
588                 outputContainer->Add(fhNeHadECharged);
589                 
590                 fhNeHadPtCharged  = new TH2F ("hNeHadPtCharged","p_{T} reconstructed vs E generated from neutral hadron, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
591                 fhNeHadPtCharged->SetXTitle("p_{T rec} (GeV/c)");
592                 fhNeHadPtCharged->SetYTitle("p_{T gen} (GeV/c)");
593                 outputContainer->Add(fhNeHadPtCharged);
594                 
595                 fhNeHadPhiCharged  = new TH2F ("hNeHadPhiCharged","#phi reconstructed vs E generated from neutral hadron, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
596                 fhNeHadPhiCharged->SetXTitle("#phi_{rec} (rad)");
597                 fhNeHadPhiCharged->SetYTitle("#phi_{gen} (rad)");
598                 outputContainer->Add(fhNeHadPhiCharged);
599                 
600                 fhNeHadEtaCharged  = new TH2F ("hNeHadEtaCharged","#eta reconstructed vs E generated from neutral hadron, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
601                 fhNeHadEtaCharged->SetXTitle("#eta_{rec} ");
602                 fhNeHadEtaCharged->SetYTitle("#eta_{gen} ");
603                 outputContainer->Add(fhNeHadEtaCharged);
604                 
605                 fhChHadECharged  = new TH2F ("hChHadECharged","E reconstructed vs E generated from charged hadron, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
606                 fhChHadECharged->SetXTitle("E_{rec} (GeV)");
607                 fhChHadECharged->SetYTitle("E_{gen} (GeV)");
608                 outputContainer->Add(fhChHadECharged);
609                 
610                 fhChHadPtCharged  = new TH2F ("hChHadPtCharged","p_{T} reconstructed vs E generated from charged hadron, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
611                 fhChHadPtCharged->SetXTitle("p_{T rec} (GeV/c)");
612                 fhChHadPtCharged->SetYTitle("p_{T gen} (GeV/c)");
613                 outputContainer->Add(fhChHadPtCharged);
614                 
615                 fhChHadPhiCharged  = new TH2F ("hChHadPhiCharged","#phi reconstructed vs E generated from charged hadron, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
616                 fhChHadPhiCharged->SetXTitle("#phi (rad)");
617                 fhChHadPhiCharged->SetXTitle("#phi_{rec} (rad)");
618                 fhChHadPhiCharged->SetYTitle("#phi_{gen} (rad)");
619                 outputContainer->Add(fhChHadPhiCharged);
620                 
621                 fhChHadEtaCharged  = new TH2F ("hChHadEtaCharged","#eta reconstructed vs E generated from charged hadron, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
622                 fhChHadEtaCharged->SetXTitle("#eta_{rec} ");
623                 fhChHadEtaCharged->SetYTitle("#eta_{gen} ");
624                 outputContainer->Add(fhChHadEtaCharged);
625                 
626                 //Vertex of generated particles 
627                 
628                 fhEMVxyz  = new TH2F ("hEMVxyz","Production vertex of reconstructed ElectroMagnetic particles",100,0,500,100,0,500);//,100,0,500); 
629                 fhEMVxyz->SetXTitle("v_{x}");
630                 fhEMVxyz->SetYTitle("v_{y}");
631                 //fhEMVxyz->SetZTitle("v_{z}");
632                 outputContainer->Add(fhEMVxyz);
633                 
634                 fhHaVxyz  = new TH2F ("hHaVxyz","Production vertex of reconstructed hadrons",100,0,500,100,0,500);//,100,0,500); 
635                 fhHaVxyz->SetXTitle("v_{x}");
636                 fhHaVxyz->SetYTitle("v_{y}");
637                 //fhHaVxyz->SetZTitle("v_{z}");
638                 outputContainer->Add(fhHaVxyz);
639                 
640                 fhEMR  = new TH2F ("hEMR","Distance to production vertex of reconstructed ElectroMagnetic particles vs E rec",nptbins,ptmin,ptmax,100,0,500); 
641                 fhEMR->SetXTitle("E (GeV)");
642                 fhEMR->SetYTitle("TMath::Sqrt(v_{x}^{2}+v_{y}^{2})");
643                 outputContainer->Add(fhEMR);
644                 
645                 fhHaR  = new TH2F ("hHaR","Distance to production vertex of reconstructed Hadrons vs E rec",nptbins,ptmin,ptmax,100,0,500); 
646                 fhHaR->SetXTitle("E (GeV)");
647                 fhHaR->SetYTitle("TMath::Sqrt(v_{x}^{2}+v_{y}^{2})");
648                 outputContainer->Add(fhHaR);
649                 
650
651                 
652                 //Pure MC
653                 fhGenGamPt  = new TH1F("hGenGamPt" ,"p_{T} of generated #gamma",nptbins,ptmin,ptmax);
654                 fhGenGamEta = new TH1F("hGenGamEta","Y of generated #gamma",netabins,etamin,etamax);
655                 fhGenGamPhi = new TH1F("hGenGamPhi","#phi of generated #gamma",nphibins,phimin,phimax);
656                 
657                 fhGenPi0Pt  = new TH1F("hGenPi0Pt" ,"p_{T} of generated #pi^{0}",nptbins,ptmin,ptmax);
658                 fhGenPi0Eta = new TH1F("hGenPi0Eta","Y of generated #pi^{0}",netabins,etamin,etamax);
659                 fhGenPi0Phi = new TH1F("hGenPi0Phi","#phi of generated #pi^{0}",nphibins,phimin,phimax);
660                 
661                 fhGenEtaPt  = new TH1F("hGenEtaPt" ,"p_{T} of generated #eta",nptbins,ptmin,ptmax);
662                 fhGenEtaEta = new TH1F("hGenEtaEta","Y of generated #eta",netabins,etamin,etamax);
663                 fhGenEtaPhi = new TH1F("hGenEtaPhi","#phi of generated #eta",nphibins,phimin,phimax);
664                 
665                 fhGenOmegaPt  = new TH1F("hGenOmegaPt" ,"p_{T} of generated #omega",nptbins,ptmin,ptmax);
666                 fhGenOmegaEta = new TH1F("hGenOmegaEta","Y of generated #omega",netabins,etamin,etamax);
667                 fhGenOmegaPhi = new TH1F("hGenOmegaPhi","#phi of generated #omega",nphibins,phimin,phimax);             
668                 
669                 fhGenElePt  = new TH1F("hGenElePt" ,"p_{T} of generated e^{#pm}",nptbins,ptmin,ptmax);
670                 fhGenEleEta = new TH1F("hGenEleEta","Y of generated  e^{#pm}",netabins,etamin,etamax);
671                 fhGenElePhi = new TH1F("hGenElePhi","#phi of generated  e^{#pm}",nphibins,phimin,phimax);               
672                 
673                 fhGenGamPt->SetXTitle("p_{T} (GeV/c)");
674                 fhGenGamEta->SetXTitle("#eta");
675                 fhGenGamPhi->SetXTitle("#phi (rad)");
676                 outputContainer->Add(fhGenGamPt);
677                 outputContainer->Add(fhGenGamEta);
678                 outputContainer->Add(fhGenGamPhi);
679
680                 fhGenPi0Pt->SetXTitle("p_{T} (GeV/c)");
681                 fhGenPi0Eta->SetXTitle("#eta");
682                 fhGenPi0Phi->SetXTitle("#phi (rad)");
683                 outputContainer->Add(fhGenPi0Pt);
684                 outputContainer->Add(fhGenPi0Eta);
685                 outputContainer->Add(fhGenPi0Phi);
686                 
687                 fhGenEtaPt->SetXTitle("p_{T} (GeV/c)");
688                 fhGenEtaEta->SetXTitle("#eta");
689                 fhGenEtaPhi->SetXTitle("#phi (rad)");
690                 outputContainer->Add(fhGenEtaPt);
691                 outputContainer->Add(fhGenEtaEta);
692                 outputContainer->Add(fhGenEtaPhi);
693                                 
694                 fhGenOmegaPt->SetXTitle("p_{T} (GeV/c)");
695                 fhGenOmegaEta->SetXTitle("#eta");
696                 fhGenOmegaPhi->SetXTitle("#phi (rad)");
697                 outputContainer->Add(fhGenOmegaPt);
698                 outputContainer->Add(fhGenOmegaEta);
699                 outputContainer->Add(fhGenOmegaPhi);
700                 
701                 fhGenElePt->SetXTitle("p_{T} (GeV/c)");
702                 fhGenEleEta->SetXTitle("#eta");
703                 fhGenElePhi->SetXTitle("#phi (rad)");
704                 outputContainer->Add(fhGenElePt);
705                 outputContainer->Add(fhGenEleEta);
706                 outputContainer->Add(fhGenElePhi);
707                 
708                 fhGenGamAccE   = new TH1F("hGenGamAccE" ,"E of generated #gamma in calorimeter acceptance",nptbins,ptmin,ptmax);
709                 fhGenGamAccPt  = new TH1F("hGenGamAccPt" ,"p_{T} of generated #gamma in calorimeter acceptance",nptbins,ptmin,ptmax);
710                 fhGenGamAccEta = new TH1F("hGenGamAccEta","Y of generated #gamma in calorimeter acceptance",netabins,etamin,etamax);
711                 fhGenGamAccPhi = new TH1F("hGenGamAccPhi","#phi of generated #gamma  in calorimeter acceptance",nphibins,phimin,phimax);
712                 
713                 fhGenPi0AccE  = new TH1F("hGenPi0AccE" ,"E of generated #pi^{0} in calorimeter acceptance",nptbins,ptmin,ptmax);
714                 fhGenPi0AccPt  = new TH1F("hGenPi0AccPt" ,"p_{T} of generated #pi^{0} in calorimeter acceptance",nptbins,ptmin,ptmax);
715                 fhGenPi0AccEta = new TH1F("hGenPi0AccEta","Y of generated #pi^{0} in calorimeter acceptance",netabins,etamin,etamax);
716                 fhGenPi0AccPhi = new TH1F("hGenPi0AccPhi","#phi of generated #pi^{0} in calorimeter acceptance",nphibins,phimin,phimax);
717                 
718                 fhGenGamAccE  ->SetXTitle("E (GeV)");
719                 fhGenGamAccPt ->SetXTitle("p_{T} (GeV/c)");
720                 fhGenGamAccEta->SetXTitle("#eta");
721                 fhGenGamAccPhi->SetXTitle("#phi (rad)");
722                 outputContainer->Add(fhGenGamAccE);             
723                 outputContainer->Add(fhGenGamAccPt);
724                 outputContainer->Add(fhGenGamAccEta);
725                 outputContainer->Add(fhGenGamAccPhi);
726                 
727                 fhGenPi0AccE  ->SetXTitle("E (GeV)");           
728                 fhGenPi0AccPt ->SetXTitle("p_{T} (GeV/c)");
729                 fhGenPi0AccEta->SetXTitle("#eta");
730                 fhGenPi0AccPhi->SetXTitle("#phi (rad)");
731                 outputContainer->Add(fhGenPi0AccE);             
732                 outputContainer->Add(fhGenPi0AccPt);
733                 outputContainer->Add(fhGenPi0AccEta);
734                 outputContainer->Add(fhGenPi0AccPhi);
735                 
736         }
737         
738         
739         fh1pOverE = new TH1F("h1pOverE","TRACK matches p/E",100,0.,10.);
740         fh1pOverE->SetXTitle("p/E");
741         outputContainer->Add(fh1pOverE);
742         
743         fh1dR = new TH1F("h1dR","TRACK matches dR",300, 0.,TMath::Pi());
744         fh1dR->SetXTitle("#Delta R (rad)");
745         outputContainer->Add(fh1dR) ;
746         
747         fh2MatchdEdx = new TH2F("h2MatchdEdx","dE/dx vs. p for all matches",200,0.,50.,200,0.,400.);
748         fh2MatchdEdx->SetXTitle("p (GeV/c)");
749         fh2MatchdEdx->SetYTitle("<dE/dx>");
750         outputContainer->Add(fh2MatchdEdx);
751         
752         fh2EledEdx = new TH2F("h2EledEdx","dE/dx vs. p for electrons",200,0.,50.,200,0.,400.);
753         fh2EledEdx->SetXTitle("p (GeV/c)");
754         fh2EledEdx->SetYTitle("<dE/dx>");
755         outputContainer->Add(fh2EledEdx) ;
756         
757         fhMCEle1pOverE = new TH1F("hMCEle1pOverE","TRACK matches p/E, MC electrons",100,0.,10.);
758         fhMCEle1pOverE->SetXTitle("p/E");
759         outputContainer->Add(fhMCEle1pOverE);
760         
761         fhMCEle1dR = new TH1F("hMCEle1dR","TRACK matches dR, MC electrons",300, 0.,TMath::Pi());
762         fhMCEle1dR->SetXTitle("#Delta R (rad)");
763         outputContainer->Add(fhMCEle1dR) ;
764         
765         fhMCEle2MatchdEdx = new TH2F("hMCEle2MatchdEdx","dE/dx vs. p for all matches, MC electrons",200,0.,50.,200,0.,400.);
766         fhMCEle2MatchdEdx->SetXTitle("p (GeV/c)");
767         fhMCEle2MatchdEdx->SetYTitle("<dE/dx>");
768         outputContainer->Add(fhMCEle2MatchdEdx);
769         
770         fhMCChHad1pOverE = new TH1F("hMCChHad1pOverE","TRACK matches p/E, MC charged hadrons",100,0.,10.);
771         fhMCChHad1pOverE->SetXTitle("p/E");
772         outputContainer->Add(fhMCChHad1pOverE);
773         
774         fhMCChHad1dR = new TH1F("hMCChHad1dR","TRACK matches dR, MC charged hadrons",300, 0.,TMath::Pi());
775         fhMCChHad1dR->SetXTitle("#Delta R (rad)");
776         outputContainer->Add(fhMCChHad1dR) ;
777         
778         fhMCChHad2MatchdEdx = new TH2F("hMCChHad2MatchdEdx","dE/dx vs. p for all matches, MC charged hadrons",200,0.,50.,200,0.,400.);
779         fhMCChHad2MatchdEdx->SetXTitle("p (GeV/c)");
780         fhMCChHad2MatchdEdx->SetYTitle("<dE/dx>");
781         outputContainer->Add(fhMCChHad2MatchdEdx);
782         
783         fhMCNeutral1pOverE = new TH1F("hMCNeutral1pOverE","TRACK matches p/E, MC neutrals",100,0.,10.);
784         fhMCNeutral1pOverE->SetXTitle("p/E");
785         outputContainer->Add(fhMCNeutral1pOverE);
786         
787         fhMCNeutral1dR = new TH1F("hMCNeutral1dR","TRACK matches dR, MC neutrals",300, 0.,TMath::Pi());
788         fhMCNeutral1dR->SetXTitle("#Delta R (rad)");
789         outputContainer->Add(fhMCNeutral1dR) ;
790         
791         fhMCNeutral2MatchdEdx = new TH2F("hMCNeutral2MatchdEdx","dE/dx vs. p for all matches, MC neutrals",200,0.,50.,200,0.,400.);
792         fhMCNeutral2MatchdEdx->SetXTitle("p (GeV/c)");
793         fhMCNeutral2MatchdEdx->SetYTitle("<dE/dx>");
794         outputContainer->Add(fhMCNeutral2MatchdEdx);
795         
796         fh1pOverER02 = new TH1F("h1pOverER02","TRACK matches p/E, all",100,0.,10.);
797         fh1pOverER02->SetXTitle("p/E");
798         outputContainer->Add(fh1pOverER02);
799         
800         fhMCEle1pOverER02 = new TH1F("hMCEle1pOverER02","TRACK matches p/E, MC electrons",100,0.,10.);
801         fhMCEle1pOverER02->SetXTitle("p/E");
802         outputContainer->Add(fhMCEle1pOverER02);
803         
804         fhMCChHad1pOverER02 = new TH1F("hMCChHad1pOverER02","TRACK matches p/E, MC charged hadrons",100,0.,10.);
805         fhMCChHad1pOverER02->SetXTitle("p/E");
806         outputContainer->Add(fhMCChHad1pOverER02);
807         
808         fhMCNeutral1pOverER02 = new TH1F("hMCNeutral1pOverER02","TRACK matches p/E, MC neutrals",100,0.,10.);
809         fhMCNeutral1pOverER02->SetXTitle("p/E");
810         outputContainer->Add(fhMCNeutral1pOverER02);
811         
812         return outputContainer;
813 }
814
815 //__________________________________________________
816 void AliAnaCalorimeterQA::Init()
817
818         //Check if the data or settings are ok
819         if(fCalorimeter != "PHOS" && fCalorimeter !="EMCAL"){
820                 printf("AliAnaCalorimeterQA::Init() - Wrong calorimeter name <%s>, END\n", fCalorimeter.Data());
821                 abort();
822         }       
823         
824         if(GetReader()->GetDataType()== AliCaloTrackReader::kMC){
825                 printf("AliAnaCalorimeterQA::Init() - Analysis of reconstructed data, MC reader not aplicable\n");
826                 abort();
827         }       
828         
829 }
830
831
832 //__________________________________________________
833 void AliAnaCalorimeterQA::InitParameters()
834
835   //Initialize the parameters of the analysis.
836   AddToHistogramsName("AnaCaloQA_");
837
838   fCalorimeter = "EMCAL"; //or PHOS
839   fStyleMacro = "" ;
840 }
841
842 //__________________________________________________________________
843 void AliAnaCalorimeterQA::Print(const Option_t * opt) const
844 {
845   //Print some relevant parameters set for the analysis
846   if(! opt)
847     return;
848   
849   printf("**** Print %s %s ****\n", GetName(), GetTitle() ) ;
850   AliAnaPartCorrBaseClass::Print(" ");
851
852   printf("Select Calorimeter %s \n",fCalorimeter.Data());
853   printf("Plots style macro %s \n",fStyleMacro.Data()); 
854
855
856 //__________________________________________________________________
857 void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms() 
858 {
859         //Do analysis and fill histograms
860         TLorentzVector mom ;
861         TLorentzVector mom2 ;
862         //Play with the MC stack if available
863         AliStack * stack = 0x0;
864         TParticle * primary = 0x0;
865         if(IsDataMC()) { 
866                 stack =  GetMCStack() ;
867                 if(!stack) {
868                         printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Stack not available, have you switched on the MC data?\n");
869                         return;
870                 }
871         }
872         
873         //Get List with clusters  
874         TObjArray * partList = new TObjArray();
875         if(fCalorimeter == "EMCAL") partList = GetAODEMCAL();
876         else if(fCalorimeter == "PHOS") partList = GetAODPHOS();
877         else {
878                 printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Wrong calorimeter name <%s>, END\n", fCalorimeter.Data());
879                 abort();
880         }
881         
882         if(!partList || partList->GetEntriesFast() == 0) return ;
883         
884         Int_t nclusters = partList->GetEntriesFast() ; 
885         fhNClusters->Fill(nclusters);
886         
887         if(GetDebug() > 0)
888                 printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - In %s there are %d clusters \n", fCalorimeter.Data(), nclusters);
889         
890         //Get vertex for photon momentum calculation
891         Double_t v[3] ; //vertex ;
892         GetReader()->GetVertex(v);
893
894         for(Int_t iclus = 0; iclus < partList->GetEntriesFast(); iclus++){
895                 //printf(" cluster %d\n",iclus);
896                 AliAODCaloCluster * calo =  (AliAODCaloCluster*) (partList->At(iclus));
897                 //if(calo->GetNCells() <= 2) continue;
898                 //Get cluster kinematics
899                 calo->GetMomentum(mom,v);
900                 Float_t e   = mom.E();
901                 //if(e < 0.5) continue;
902                 //printf("e %2.2f, n %f\n",e, calo->GetNCells());
903                 Float_t pt  = mom.Pt();
904                 Float_t eta = mom.Eta();
905                 Float_t phi = mom.Phi();
906                 if(phi < 0) phi +=TMath::TwoPi();
907                 if(GetDebug() > 0) printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - cluster %d: E %2.3f, pT %2.3f, eta %2.3f, phi %2.3f \n",iclus,e,pt,eta,phi*TMath::RadToDeg());
908                 fhE     ->Fill(e);              
909                 fhPt    ->Fill(pt);
910                 fhPhi   ->Fill(phi);
911                 fhEta   ->Fill(eta);
912                 fhEtaPhi->Fill(eta,phi);
913                 
914                 //matched cluster with tracks
915                 Int_t ntracksmatched = calo->GetNTracksMatched();
916
917                 //Fill histograms only possible when simulation
918                 if(IsDataMC()){
919                 //Play with the MC stack if available
920                     Int_t label = calo->GetLabel(0);
921                         
922                 if(label < 0 || !stack) {
923                                 if(GetDebug() >= 0) printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() *** bad label or no stack ***:  label %d \n", label);
924                                 continue;
925                 }
926                 
927                 if(label >=  stack->GetNtrack()) {
928                                 if(GetDebug() >= 0) printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() *** large label ***:  label %d, n tracks %d \n", label, stack->GetNtrack());
929                                 continue ;
930                 }
931                         
932                 //cout<<"LABEL  "<<label<<endl;
933                 primary = GetMCStack()->Particle(label);
934
935                     Int_t pdg = primary->GetPdgCode();
936                     Float_t vx = primary->Vx();
937                     Float_t vy = primary->Vy();
938                     //Float_t vz = primary->Vz();
939                     Float_t r = TMath::Sqrt(vx*vx + vy*vy);
940                     if((pdg == 22 || TMath::Abs(pdg)==11) && primary->GetStatusCode()!=1) {
941                                 fhEMVxyz   ->Fill(vx,vy);//,vz);
942                                 fhEMR      ->Fill(e,r);
943                     }
944                     
945                     //printf("reco e %f, pt %f, phi %f, eta %f \n", e, pt, phi, eta);
946                     //printf("prim e %f, pt %f, phi %f, eta %f \n", primary->Energy(),primary->Pt() ,primary->Phi() ,primary->Eta() );
947                     //printf("vertex: vx %f, vy %f, vz %f, r %f \n", vx, vy, vz, r);
948                     
949                     //Get final particle, no conversion products
950                     Int_t status =  primary->GetStatusCode();
951                     Int_t mother= primary->GetFirstMother();
952                     if(status == 0){
953                                 while(mother >= 0){
954                                         primary = GetMCStack()->Particle(mother);
955                                         status = primary->GetStatusCode();
956                                         mother= primary->GetFirstMother();
957                                         if(status == 1) break;             
958                                         //printf("mother %d\n",mother);
959                                 }       
960                     }
961                     
962                         fh2E      ->Fill(e, primary->Energy());
963                         fh2Pt     ->Fill(pt, primary->Pt());
964                         fh2Phi    ->Fill(phi, primary->Phi());
965                         fh2Eta    ->Fill(eta, primary->Eta());
966                         fhDeltaE  ->Fill(primary->Energy()-e);
967                         fhDeltaPt ->Fill(primary->Pt()-pt);
968                         fhDeltaPhi->Fill(primary->Phi()-phi);
969                         fhDeltaEta->Fill(primary->Eta()-eta);
970                         if(primary->Energy() > 0) fhRatioE  ->Fill(e/primary->Energy());
971                     if(primary->Pt()     > 0) fhRatioPt ->Fill(pt/primary->Pt());
972                     if(primary->Phi()    > 0) fhRatioPhi->Fill(phi/primary->Phi());
973                     if(primary->Eta()    > 0) fhRatioEta->Fill(eta/primary->Eta());                     
974                         
975                     //cout<<"Final Label "<<finallabel<<" mother "<<mother<<endl;
976                     pdg = primary->GetPdgCode();
977                     Double_t  charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
978                         
979                     if(pdg == 22){
980                                 //cout<<"pdg "<<pdg<<" status "<<status<<" "<<primary->GetStatusCode()<<endl;   
981                                 TParticle *pi0 = 0x0;
982                                 TParticle *p1 = 0x0;
983                                 TParticle *p2 = 0x0;
984                                 TParticle * tmp = 0x0;
985                                 Int_t pdgpi0 = 0;
986                                 Int_t mothertmp = 0;
987                                 //Check if it is a decay photon from pi0, in this case, check if both decay contribute cluster
988                                 Bool_t ok1 = kFALSE;
989                                 Bool_t ok2 = kFALSE;
990                                 
991                                 if(calo->GetNLabel() > 1){
992                                         if(pdg !=111){
993                                                 while(mother >= 0){
994                                                         pi0 = GetMCStack()->Particle(mother);
995                                                         pdgpi0 = pi0->GetPdgCode();
996                                                         if(pdgpi0 == 111) {
997                                                           //cout<<"pi0!!!"<<endl;
998                                                           break;
999                                                         }
1000                                                         mother= pi0->GetFirstMother();
1001                                                         //printf("mother %d\n",mother);
1002                                                 }
1003                                         }
1004                                         else   pi0 = primary;
1005                                 
1006                                         if(!pi0 || mother < 0 ) continue ;
1007                                         //cout<<"pi0 pointer "<<pi0<<" pdg "<<pdgpi0<<" "<<pi0->GetPdgCode()<<endl;
1008                                         //cout<<"MOTHER PI0 LABEL "<<mother<<" pt" << pi0->Pt()<<" status "<<pi0->GetStatusCode()<<endl;
1009                                         if(pi0->GetNDaughters() == 2){
1010                                           //cout<<"pi0, 2 daughters "<<endl;
1011                                                 Int_t id1 = pi0->GetFirstDaughter();
1012                                                 Int_t id2 = pi0->GetFirstDaughter()+1;
1013                                                 p1=GetMCStack()->Particle(id1);
1014                                                 p2=GetMCStack()->Particle(id2);
1015                                                 
1016                                                 //if(p1->GetFirstMother()!=p2->GetFirstMother()) cout <<"Decay photon mothers are not the same!!"<<endl;
1017                                                 if(p1->GetPdgCode()==22 && p2->GetPdgCode()==22){
1018                                                         // cout<<"2 photons, labels "<< id1<<" "<<id2<<endl;
1019                                                         for(UInt_t ilabel = 0; ilabel < calo->GetNLabel(); ilabel++){
1020                                                                 Int_t iprim = calo->GetLabel(ilabel);
1021                                                                 //cout<<"iprim "<<iprim<<endl;
1022                                                                 if (iprim == id1) ok1 = kTRUE;
1023                                                                 else if (iprim == id2) ok2 = kTRUE;
1024                                                                 mothertmp = iprim;
1025                                                                 while(mothertmp >= 0){
1026                                                                         tmp = GetMCStack()->Particle(mothertmp);                                    
1027                                                                         mothertmp= tmp->GetFirstMother();
1028                                                                         //      cout<<"mothertmp "<<mothertmp<<" "<<tmp->GetName()<< " pt "<<tmp->Pt()<<endl;
1029                                                                         if (mothertmp == id1) ok1 = kTRUE;
1030                                                                         else if (mothertmp == id2) ok2 = kTRUE;
1031                                                                         if(ok1 && ok2) break;
1032                                                                         //printf("mother %d\n",mother);
1033                                                                 }
1034                                                         } 
1035                                                 }//2 photon daughters
1036                                         }////mother pi0, 2 daughers
1037                                 }//more than one contribution to clust
1038                                 
1039                                 if(ok1 && ok2){
1040                                         //cout<<"Fill pi0"<< "E  "<< e <<" prim E "<<primary->Energy()<<endl;
1041                                         fhPi0E     ->Fill(e,primary->Energy()); 
1042                                         fhPi0Pt    ->Fill(pt,primary->Pt());
1043                                         fhPi0Eta   ->Fill(eta,primary->Eta());  
1044                                         fhPi0Phi   ->Fill(phi,primary->Phi());
1045                                         if( ntracksmatched > 0){
1046                                                 fhPi0ECharged     ->Fill(e,primary->Energy());          
1047                                                 fhPi0PtCharged    ->Fill(pt,primary->Pt());
1048                                                 fhPi0PhiCharged   ->Fill(phi,primary->Phi());
1049                                                 fhPi0EtaCharged   ->Fill(eta,primary->Eta());
1050                                         }
1051                                 }
1052                                 else{
1053                                         fhGamE     ->Fill(e,primary->Energy()); 
1054                                         fhGamPt    ->Fill(pt,primary->Pt());
1055                                         fhGamEta   ->Fill(eta,primary->Eta());  
1056                                         fhGamPhi   ->Fill(phi,primary->Phi());
1057                                         fhGamDeltaE  ->Fill(primary->Energy()-e);
1058                                         fhGamDeltaPt ->Fill(primary->Pt()-pt);  
1059                                         fhGamDeltaPhi->Fill(primary->Phi()-phi);
1060                                         fhGamDeltaEta->Fill(primary->Eta()-eta);
1061                                         if(primary->Energy() > 0) fhGamRatioE  ->Fill(e/primary->Energy());
1062                                         if(primary->Pt()     > 0) fhGamRatioPt ->Fill(pt/primary->Pt());
1063                                         if(primary->Phi()    > 0) fhGamRatioPhi->Fill(phi/primary->Phi());
1064                                         if(primary->Eta()    > 0) fhGamRatioEta->Fill(eta/primary->Eta());
1065                                         if( ntracksmatched > 0){
1066                                                 fhGamECharged     ->Fill(e,primary->Energy());          
1067                                                 fhGamPtCharged    ->Fill(pt,primary->Pt());
1068                                                 fhGamPhiCharged   ->Fill(phi,primary->Phi());
1069                                                 fhGamEtaCharged   ->Fill(eta,primary->Eta());
1070                                         }
1071                                 }
1072                     }//pdg == 22
1073                     else if(TMath::Abs(pdg) == 11) {
1074                                 fhEleE     ->Fill(e,primary->Energy()); 
1075                                 fhElePt    ->Fill(pt,primary->Pt());
1076                                 fhEleEta   ->Fill(eta,primary->Eta());  
1077                                 fhElePhi   ->Fill(phi,primary->Phi());
1078                                 fhEMVxyz   ->Fill(vx,vy);//,vz);
1079                                 fhEMR      ->Fill(e,r);
1080                                 if( ntracksmatched > 0){
1081                                         fhEleECharged     ->Fill(e,primary->Energy());          
1082                                         fhElePtCharged    ->Fill(pt,primary->Pt());
1083                                         fhElePhiCharged   ->Fill(phi,primary->Phi());
1084                                         fhEleEtaCharged   ->Fill(eta,primary->Eta());
1085                                 }
1086                     }
1087                     else if(pdg == 111) {
1088                                 fhPi0E     ->Fill(e,primary->Energy()); 
1089                                 fhPi0Pt    ->Fill(pt,primary->Pt());
1090                                 fhPi0Eta   ->Fill(eta,primary->Eta());  
1091                                 fhPi0Phi   ->Fill(phi,primary->Phi());
1092                                 if( ntracksmatched > 0){
1093                                         fhPi0ECharged     ->Fill(e,primary->Energy());          
1094                                         fhPi0PtCharged    ->Fill(pt,primary->Pt());
1095                                         fhPi0PhiCharged   ->Fill(phi,primary->Phi());
1096                                         fhPi0EtaCharged   ->Fill(eta,primary->Eta());
1097                                 }
1098                     }
1099                     else if(charge == 0){
1100                                 fhNeHadE     ->Fill(e,primary->Energy());       
1101                                 fhNeHadPt    ->Fill(pt,primary->Pt());
1102                                 fhNeHadEta   ->Fill(eta,primary->Eta());        
1103                                 fhNeHadPhi   ->Fill(phi,primary->Phi());        
1104                                 fhHaVxyz     ->Fill(vx,vy);//,vz);
1105                                 fhHaR        ->Fill(e,r);
1106                                 if( ntracksmatched > 0){
1107                                         fhNeHadECharged     ->Fill(e,primary->Energy());                
1108                                         fhNeHadPtCharged    ->Fill(pt,primary->Pt());
1109                                         fhNeHadPhiCharged   ->Fill(phi,primary->Phi());
1110                                         fhNeHadEtaCharged   ->Fill(eta,primary->Eta());
1111                                 }
1112                     }
1113                     else if(charge!=0){
1114                                 fhChHadE     ->Fill(e,primary->Energy());       
1115                                 fhChHadPt    ->Fill(pt,primary->Pt());
1116                                 fhChHadEta   ->Fill(eta,primary->Eta());        
1117                                 fhChHadPhi   ->Fill(phi,primary->Phi());        
1118                                 fhHaVxyz     ->Fill(vx,vy);//,vz);
1119                                 fhHaR        ->Fill(e,r);
1120                                 if( ntracksmatched > 0){
1121                                         fhChHadECharged     ->Fill(e,primary->Energy());                
1122                                         fhChHadPtCharged    ->Fill(pt,primary->Pt());
1123                                         fhChHadPhiCharged   ->Fill(phi,primary->Phi());
1124                                         fhChHadEtaCharged   ->Fill(eta,primary->Eta());
1125                                 }
1126                     }
1127                 }//Work with stack also
1128                 
1129                 //matched cluster with tracks
1130                 if( ntracksmatched > 0){
1131                         fhECharged     ->Fill(e);               
1132                         fhPtCharged    ->Fill(pt);
1133                         fhPhiCharged   ->Fill(phi);
1134                         fhEtaCharged   ->Fill(eta);
1135                         fhEtaPhiCharged->Fill(eta,phi);                         
1136                         if((!strcmp(GetReader()->GetInputEvent()->GetName(),"AliESDEvent"))) {
1137                                 AliESDEvent *esd = (AliESDEvent*) GetReader()->GetInputEvent();
1138                                 AliESDCaloCluster * esdcalo = (AliESDCaloCluster*) esd->GetCaloCluster(calo->GetID());
1139                                 Int_t trackIndex = esdcalo->GetTrackMatched();
1140                                 //printf("track index %d ntracks %d\n", trackIndex, esd->GetNumberOfTracks());
1141                                 if(trackIndex >= 0){
1142                                         AliESDtrack* track = (AliESDtrack*) esd->GetTrack(trackIndex);
1143                                         if (track && track->GetOuterParam() ) {
1144
1145                                                 Double_t tphi = track->GetOuterParam()->Phi();
1146                                                 Double_t teta = track->GetOuterParam()->Eta();
1147                                                 Double_t tmom = track->GetOuterParam()->P();
1148
1149                                                 Double_t deta = teta - eta;
1150                                                 Double_t dphi = tphi - phi;
1151                                                 if(dphi > TMath::Pi()) dphi -= 2*TMath::Pi();
1152                                                 if(dphi < -TMath::Pi()) dphi += 2*TMath::Pi();
1153                                                 Double_t dR = sqrt(dphi*dphi + deta*deta);
1154                                                 
1155                                                 Double_t pOverE = tmom/e;
1156                                                 
1157                                                 fh1pOverE->Fill(pOverE);
1158                                                 if(dR < 0.02) fh1pOverER02->Fill(pOverE);
1159                                                 
1160                                                 fh1dR->Fill(dR);
1161                                                 fh2MatchdEdx->Fill(track->P(),track->GetTPCsignal());
1162                                         
1163                                                 if(IsDataMC() && primary){ 
1164                                                          Int_t pdg = primary->GetPdgCode();
1165                                                          Double_t  charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
1166                                                         
1167                                                         if(TMath::Abs(pdg) == 11){
1168                                                                 fhMCEle1pOverE->Fill(pOverE);
1169                                                                 fhMCEle1dR->Fill(dR);
1170                                                                 fhMCEle2MatchdEdx->Fill(track->P(),track->GetTPCsignal());              
1171                                                                 if(dR < 0.02) fhMCEle1pOverER02->Fill(pOverE);
1172                                                         }
1173                                                         else if(charge!=0){
1174                                                                 fhMCChHad1pOverE->Fill(pOverE);
1175                                                                 fhMCChHad1dR->Fill(dR);
1176                                                                 fhMCChHad2MatchdEdx->Fill(track->P(),track->GetTPCsignal());    
1177                                                                 if(dR < 0.02) fhMCChHad1pOverER02->Fill(pOverE);
1178                                                         }
1179                                                         else if(charge == 0){
1180                                                                 fhMCNeutral1pOverE->Fill(pOverE);
1181                                                                 fhMCNeutral1dR->Fill(dR);
1182                                                                 fhMCNeutral2MatchdEdx->Fill(track->P(),track->GetTPCsignal());  
1183                                                                 if(dR < 0.02) fhMCNeutral1pOverER02->Fill(pOverE);
1184                                                         }
1185                                                 }
1186                                                 int nITS = track->GetNcls(0);
1187                                                 int nTPC = track->GetNcls(1);
1188                                                 if(dR < 0.02 && pOverE > 0.5 && pOverE < 1.5
1189                                                    && calo->GetNCells() > 1 && nITS > 3 && nTPC > 20) {
1190                                                         fh2EledEdx->Fill(track->P(),track->GetTPCsignal());
1191                                                 }
1192                                         } 
1193                                         else if(!track->GetOuterParam()){
1194                                                 ULong_t status=AliESDtrack::kTPCrefit;
1195                                                 status|=AliESDtrack::kITSrefit;
1196                                                 //printf("track status %d\n", track->GetStatus() );
1197                                                 fhEChargedNoOut     ->Fill(e);          
1198                                                 fhPtChargedNoOut     ->Fill(pt);
1199                                                 fhPhiChargedNoOut    ->Fill(phi);
1200                                                 fhEtaChargedNoOut    ->Fill(eta);
1201                                                 fhEtaPhiChargedNoOut ->Fill(eta,phi);   
1202                                                 if(GetDebug() >= 0 && ((track->GetStatus() & status) == status)) printf("ITS+TPC\n");
1203                                         }
1204                                         else {
1205                                                 if(GetDebug() >= 0) printf("ERROR: Could not receive track %d\n", trackIndex);
1206                                         }
1207                                 }// non negative track index
1208                         }//do only if input are ESDs
1209                 }// at least one track matched          
1210                 
1211                 //Invariant mass
1212                 if (nclusters > 1 ) {
1213                         for(Int_t jclus = iclus + 1 ; jclus < nclusters ; jclus++) {
1214                                 AliAODCaloCluster * calo2 =  (AliAODCaloCluster*) (partList->At(jclus));
1215                                 //Get cluster kinematics
1216                                 calo2->GetMomentum(mom2,v);
1217                                 fhIM  ->Fill((mom+mom2).E(),(mom+mom2).M());
1218                                 fhAsym->Fill((mom+mom2).E(),TMath::Abs((e-mom2.E())/(e+mom2.E())));
1219                         }// 2nd cluster loop
1220                 }////more than 1 cluster in calorimeter    
1221                 
1222                 //Cells per cluster
1223                 fhNCellsPerCluster->Fill(e,calo->GetNCells());
1224                 
1225         }// 1st cluster loop
1226         
1227         //CaloCells
1228         AliAODCaloCells * cell = new AliAODCaloCells ;
1229         if(fCalorimeter == "PHOS") 
1230                 cell = (AliAODCaloCells *) GetPHOSCells();
1231         else  
1232                 cell = (AliAODCaloCells *) GetEMCALCells();     
1233         
1234         if(!cell) {
1235                 printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - STOP: No CELLS available for analysis");
1236                 abort();
1237         }
1238         
1239         //Some prints
1240         if(GetDebug() > 0 && cell )
1241                 printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - In ESD %s cell entries %d\n", fCalorimeter.Data(), cell->GetNumberOfCells());    
1242         
1243         Int_t ncells = cell->GetNumberOfCells() ;
1244         fhNCells->Fill(ncells) ;
1245         
1246         for (Int_t iCell = 0; iCell < ncells; iCell++) {      
1247                 if(GetDebug() > 0)  printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Cell : amp %f, absId %d \n", cell->GetAmplitude(iCell), cell->GetCellNumber(iCell));
1248                 fhAmplitude->Fill(cell->GetAmplitude(iCell));
1249         }
1250         
1251         //Monte Carlo
1252         if(IsDataMC()){
1253                 //Play with the MC stack if available
1254                 for(Int_t i=8 ; i<stack->GetNprimary(); i++){
1255                         primary = stack->Particle(i) ;
1256                         
1257                         //if (!primary->IsPrimary()) continue;
1258                         if (TMath::Abs(primary->Eta()) > 1) continue;
1259                         
1260                         Int_t kf = primary->GetPdgCode();
1261                         //printf("kf %d\n",kf);
1262                         
1263                         Bool_t in = kTRUE;
1264                         primary->Momentum(mom);
1265                         if(IsFidutialCutOn()) in =  GetFidutialCut()->IsInFidutialCut(mom,fCalorimeter) ;
1266                         
1267                         if (kf==22) {
1268                                 fhGenGamPt ->Fill(primary->Pt());
1269                                 fhGenGamEta->Fill(primary->Eta());
1270                                 fhGenGamPhi->Fill(primary->Phi());
1271                                 if(in){
1272                                         fhGenGamAccE  ->Fill(primary->Energy());
1273                                         fhGenGamAccPt ->Fill(primary->Pt());
1274                                         fhGenGamAccEta->Fill(primary->Eta());
1275                                         fhGenGamAccPhi->Fill(primary->Phi());                                   
1276                                 }
1277                         }
1278                         else if (kf==111) {
1279                                 fhGenPi0Pt ->Fill(primary->Pt());
1280                                 fhGenPi0Eta->Fill(primary->Eta());
1281                                 fhGenPi0Phi->Fill(primary->Phi());
1282                                 if(in){
1283                                         fhGenPi0AccE  ->Fill(primary->Energy());                                        
1284                                         fhGenPi0AccPt ->Fill(primary->Pt());
1285                                         fhGenPi0AccEta->Fill(primary->Eta());
1286                                         fhGenPi0AccPhi->Fill(primary->Phi());                                   
1287                                 }
1288                         }
1289                         else if (kf==221) {
1290                                 fhGenEtaPt ->Fill(primary->Pt());
1291                                 fhGenEtaEta->Fill(primary->Eta());
1292                                 fhGenEtaPhi->Fill(primary->Phi());
1293                         }
1294                         else if (kf==223) {
1295                                 fhGenOmegaPt ->Fill(primary->Pt());
1296                                 fhGenOmegaEta->Fill(primary->Eta());
1297                                 fhGenOmegaPhi->Fill(primary->Phi());
1298                         }
1299                         else if (TMath::Abs(kf)==11) {
1300                                 fhGenElePt ->Fill(primary->Pt());
1301                                 fhGenEleEta->Fill(primary->Eta());
1302                                 fhGenElePhi->Fill(primary->Phi());
1303                         }
1304                 } //primary loop
1305         } //Is data MC
1306         
1307         if(GetDebug() > 0)
1308                 printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - End \n");
1309         
1310         
1311 }
1312
1313 //________________________________________________________________________
1314 void AliAnaCalorimeterQA::ReadHistograms(TList* outputList)
1315 {
1316         // Needed when Terminate is executed in distributed environment
1317         // Refill analysis histograms of this class with corresponding histograms in output list. 
1318         
1319         // Histograms of this analsys are kept in the same list as other analysis, recover the position of
1320         // the first one and then add the next 
1321         Int_t index = outputList->IndexOf(outputList->FindObject(GetAddedHistogramsStringToName()+"hE"));
1322         //printf("Calo: %s, index: %d\n",fCalorimeter.Data(),index);
1323         //Read histograms, must be in the same order as in GetCreateOutputObject.
1324         fhE      = (TH1F *) outputList->At(index++);    
1325         fhPt     = (TH1F *) outputList->At(index++); 
1326         fhPhi    = (TH1F *) outputList->At(index++); 
1327         fhEta    = (TH1F *) outputList->At(index++);
1328         fhEtaPhi = (TH2F *) outputList->At(index++);
1329         
1330         fhECharged      = (TH1F *) outputList->At(index++);     
1331         fhPtCharged     = (TH1F *) outputList->At(index++); 
1332         fhPhiCharged    = (TH1F *) outputList->At(index++); 
1333         fhEtaCharged    = (TH1F *) outputList->At(index++);
1334         fhEtaPhiCharged = (TH2F *) outputList->At(index++);
1335         
1336         fhEChargedNoOut      = (TH1F *) outputList->At(index++);        
1337         fhPtChargedNoOut     = (TH1F *) outputList->At(index++); 
1338         fhPhiChargedNoOut    = (TH1F *) outputList->At(index++); 
1339         fhEtaChargedNoOut    = (TH1F *) outputList->At(index++);
1340         fhEtaPhiChargedNoOut = (TH2F *) outputList->At(index++);
1341
1342         fhIM     = (TH2F *) outputList->At(index++);
1343         fhAsym   = (TH2F *) outputList->At(index++);
1344         
1345         fhNCellsPerCluster = (TH2F *) outputList->At(index++);
1346         fhNClusters  = (TH1F *) outputList->At(index++); 
1347         fhNCells     = (TH1F *) outputList->At(index++); 
1348         fhAmplitude  = (TH1F *) outputList->At(index++); 
1349         
1350         if(IsDataMC()){
1351                 fhDeltaE   = (TH1F *) outputList->At(index++); 
1352                 fhDeltaPt  = (TH1F *) outputList->At(index++); 
1353                 fhDeltaPhi = (TH1F *) outputList->At(index++); 
1354                 fhDeltaEta = (TH1F *) outputList->At(index++); 
1355                 
1356                 fhRatioE   = (TH1F *) outputList->At(index++); 
1357                 fhRatioPt  = (TH1F *) outputList->At(index++); 
1358                 fhRatioPhi = (TH1F *) outputList->At(index++); 
1359                 fhRatioEta = (TH1F *) outputList->At(index++); 
1360                 
1361                 fh2E       = (TH2F *) outputList->At(index++); 
1362                 fh2Pt      = (TH2F *) outputList->At(index++); 
1363                 fh2Phi     = (TH2F *) outputList->At(index++); 
1364                 fh2Eta     = (TH2F *) outputList->At(index++); 
1365                 
1366                 fhGamE     = (TH2F *) outputList->At(index++); 
1367                 fhGamPt    = (TH2F *) outputList->At(index++); 
1368                 fhGamPhi   = (TH2F *) outputList->At(index++); 
1369                 fhGamEta   = (TH2F *) outputList->At(index++); 
1370                 
1371                 fhGamDeltaE   = (TH1F *) outputList->At(index++); 
1372                 fhGamDeltaPt  = (TH1F *) outputList->At(index++); 
1373                 fhGamDeltaPhi = (TH1F *) outputList->At(index++); 
1374                 fhGamDeltaEta = (TH1F *) outputList->At(index++); 
1375                 
1376                 fhGamRatioE   = (TH1F *) outputList->At(index++); 
1377                 fhGamRatioPt  = (TH1F *) outputList->At(index++); 
1378                 fhGamRatioPhi = (TH1F *) outputList->At(index++); 
1379                 fhGamRatioEta = (TH1F *) outputList->At(index++); 
1380
1381                 fhPi0E     = (TH2F *) outputList->At(index++); 
1382                 fhPi0Pt    = (TH2F *) outputList->At(index++); 
1383                 fhPi0Phi   = (TH2F *) outputList->At(index++); 
1384                 fhPi0Eta   = (TH2F *) outputList->At(index++);          
1385                 
1386                 fhEleE     = (TH2F *) outputList->At(index++); 
1387                 fhElePt    = (TH2F *) outputList->At(index++); 
1388                 fhElePhi   = (TH2F *) outputList->At(index++); 
1389                 fhEleEta   = (TH2F *) outputList->At(index++);          
1390                 
1391                 fhNeHadE     = (TH2F *) outputList->At(index++); 
1392                 fhNeHadPt    = (TH2F *) outputList->At(index++); 
1393                 fhNeHadPhi   = (TH2F *) outputList->At(index++); 
1394                 fhNeHadEta   = (TH2F *) outputList->At(index++);                
1395                 
1396                 fhChHadE     = (TH2F *) outputList->At(index++); 
1397                 fhChHadPt    = (TH2F *) outputList->At(index++); 
1398                 fhChHadPhi   = (TH2F *) outputList->At(index++); 
1399                 fhChHadEta   = (TH2F *) outputList->At(index++);                                
1400                 
1401                 fhGamECharged     = (TH2F *) outputList->At(index++); 
1402                 fhGamPtCharged    = (TH2F *) outputList->At(index++); 
1403                 fhGamPhiCharged   = (TH2F *) outputList->At(index++); 
1404                 fhGamEtaCharged   = (TH2F *) outputList->At(index++); 
1405                                 
1406                 fhPi0ECharged     = (TH2F *) outputList->At(index++); 
1407                 fhPi0PtCharged    = (TH2F *) outputList->At(index++); 
1408                 fhPi0PhiCharged   = (TH2F *) outputList->At(index++); 
1409                 fhPi0EtaCharged   = (TH2F *) outputList->At(index++);           
1410                 
1411                 fhEleECharged     = (TH2F *) outputList->At(index++); 
1412                 fhElePtCharged    = (TH2F *) outputList->At(index++); 
1413                 fhElePhiCharged   = (TH2F *) outputList->At(index++); 
1414                 fhEleEtaCharged   = (TH2F *) outputList->At(index++);           
1415                 
1416                 fhNeHadECharged     = (TH2F *) outputList->At(index++); 
1417                 fhNeHadPtCharged    = (TH2F *) outputList->At(index++); 
1418                 fhNeHadPhiCharged   = (TH2F *) outputList->At(index++); 
1419                 fhNeHadEtaCharged   = (TH2F *) outputList->At(index++);                 
1420                 
1421                 fhChHadECharged     = (TH2F *) outputList->At(index++); 
1422                 fhChHadPtCharged    = (TH2F *) outputList->At(index++); 
1423                 fhChHadPhiCharged   = (TH2F *) outputList->At(index++); 
1424                 fhChHadEtaCharged   = (TH2F *) outputList->At(index++);                                 
1425                 
1426 //              fhEMVxyz     = (TH3F *) outputList->At(index++); 
1427 //              fhHaVxyz     = (TH3F *) outputList->At(index++); 
1428                 
1429                 fhEMVxyz     = (TH2F *) outputList->At(index++); 
1430                 fhHaVxyz     = (TH2F *) outputList->At(index++); 
1431                 fhEMR        = (TH2F *) outputList->At(index++); 
1432                 fhHaR        = (TH2F *) outputList->At(index++); 
1433                 
1434                 fhGenGamPt    = (TH1F *) outputList->At(index++); 
1435                 fhGenGamEta   = (TH1F *) outputList->At(index++); 
1436                 fhGenGamPhi   = (TH1F *) outputList->At(index++); 
1437                 
1438                 fhGenPi0Pt    = (TH1F *) outputList->At(index++); 
1439                 fhGenPi0Eta   = (TH1F *) outputList->At(index++); 
1440                 fhGenPi0Phi   = (TH1F *) outputList->At(index++); 
1441                 
1442                 fhGenEtaPt    = (TH1F *) outputList->At(index++); 
1443                 fhGenEtaEta   = (TH1F *) outputList->At(index++); 
1444                 fhGenEtaPhi   = (TH1F *) outputList->At(index++); 
1445                 
1446                 fhGenOmegaPt  = (TH1F *) outputList->At(index++); 
1447                 fhGenOmegaEta = (TH1F *) outputList->At(index++); 
1448                 fhGenOmegaPhi = (TH1F *) outputList->At(index++); 
1449                 
1450                 fhGenElePt    = (TH1F *) outputList->At(index++); 
1451                 fhGenEleEta   = (TH1F *) outputList->At(index++); 
1452                 fhGenElePhi   = (TH1F *) outputList->At(index++); 
1453                 
1454                 fhGenGamAccE   = (TH1F *) outputList->At(index++);              
1455                 fhGenGamAccPt  = (TH1F *) outputList->At(index++); 
1456                 fhGenGamAccEta = (TH1F *) outputList->At(index++); 
1457                 fhGenGamAccPhi = (TH1F *) outputList->At(index++); 
1458                 
1459                 fhGenPi0AccE   = (TH1F *) outputList->At(index++);              
1460                 fhGenPi0AccPt  = (TH1F *) outputList->At(index++); 
1461                 fhGenPi0AccEta = (TH1F *) outputList->At(index++); 
1462                 fhGenPi0AccPhi = (TH1F *) outputList->At(index++); 
1463                 
1464         }//Is data MC   
1465         
1466         fh1pOverE =    (TH1F *) outputList->At(index++);
1467         fh1dR =        (TH1F *) outputList->At(index++);
1468         fh2MatchdEdx = (TH2F *) outputList->At(index++);
1469         fh2EledEdx =   (TH2F *) outputList->At(index++);
1470         
1471         if(IsDataMC()){
1472                 fhMCEle1pOverE =    (TH1F *) outputList->At(index++);
1473                 fhMCEle1dR =        (TH1F *) outputList->At(index++);
1474                 fhMCEle2MatchdEdx = (TH2F *) outputList->At(index++);
1475                 
1476                 fhMCChHad1pOverE =    (TH1F *) outputList->At(index++);
1477                 fhMCChHad1dR =        (TH1F *) outputList->At(index++);
1478                 fhMCChHad2MatchdEdx = (TH2F *) outputList->At(index++);
1479                 
1480                 fhMCNeutral1pOverE    = (TH1F *) outputList->At(index++);
1481                 fhMCNeutral1dR        = (TH1F *) outputList->At(index++);
1482                 fhMCNeutral2MatchdEdx = (TH2F *) outputList->At(index++);
1483                 
1484                 fh1pOverER02          =    (TH1F *) outputList->At(index++);
1485                 fhMCEle1pOverER02     =    (TH1F *) outputList->At(index++);
1486                 fhMCChHad1pOverER02   =    (TH1F *) outputList->At(index++);
1487                 fhMCNeutral1pOverER02 =    (TH1F *) outputList->At(index++);
1488         }
1489         //for(Int_t i = 0;  i<index ; i++) cout<<outputList->At(i)->GetName()<<endl;
1490 }
1491
1492 //__________________________________________________________________
1493 void  AliAnaCalorimeterQA::Terminate(TList* outputList) 
1494 {
1495         //Do plots if requested
1496         if(!fMakePlots) return;
1497         
1498         //Do some plots to end
1499          if(fStyleMacro!="")gROOT->Macro(fStyleMacro); 
1500         //Recover histograms from output histograms list, needed for distributed analysis.      
1501         ReadHistograms(outputList);
1502         
1503         //printf(" AliAnaCalorimeterQA::Terminate()  *** %s Report:", GetName()) ; 
1504         //printf(" AliAnaCalorimeterQA::Terminate()        pt         : %5.3f , RMS : %5.3f \n", fhPt->GetMean(),   fhPt->GetRMS() ) ;
1505
1506         char name[128];
1507         char cname[128];
1508                 
1509         //CaloCells
1510         //printf("c9\n");
1511         sprintf(cname,"QA_%s_nclustercellsamp",fCalorimeter.Data());
1512         TCanvas  * c9 = new TCanvas(cname, " CaloClusters and CaloCells", 400, 400) ;
1513         c9->Divide(2, 2);
1514         
1515         c9->cd(1) ; 
1516         if(fhNClusters->GetEntries() > 0) gPad->SetLogy();
1517         gPad->SetLogx();
1518         fhNClusters->SetLineColor(4);
1519         fhNClusters->Draw();
1520         
1521         c9->cd(2) ; 
1522         if(fhNCells->GetEntries() > 0) gPad->SetLogy();
1523         gPad->SetLogx();
1524         fhNCells->SetLineColor(4);
1525         fhNCells->Draw();
1526         
1527         c9->cd(3) ; 
1528         if(fhNCellsPerCluster->GetEntries() > 0) gPad->SetLogy();
1529         gPad->SetLogx();
1530         fhNCellsPerCluster->SetLineColor(4);
1531         fhNCellsPerCluster->Draw();
1532         
1533         c9->cd(4) ; 
1534         if(fhAmplitude->GetEntries() > 0) gPad->SetLogy();
1535         //gPad->SetLogx();
1536         fhAmplitude->SetLineColor(4);
1537         fhAmplitude->Draw();
1538         
1539         sprintf(name,"QA_%s_CaloClustersAndCaloCells.eps",fCalorimeter.Data());
1540         c9->Print(name); printf("Plot: %s\n",name);
1541         
1542         
1543         //Reconstructed distributions
1544         //printf("c1\n");
1545         sprintf(cname,"QA_%s_rec",fCalorimeter.Data());
1546         TCanvas  * c = new TCanvas(cname, "Reconstructed distributions", 400, 400) ;
1547         c->Divide(2, 2);
1548         
1549         c->cd(1) ; 
1550         if(fhE->GetEntries() > 0) gPad->SetLogy();
1551         fhE->SetLineColor(4);
1552         fhE->Draw();
1553         
1554         c->cd(2) ; 
1555         if(fhPt->GetEntries() > 0) gPad->SetLogy();
1556         fhPt->SetLineColor(4);
1557         fhPt->Draw();
1558         
1559         c->cd(3) ; 
1560         fhPhi->SetLineColor(4);
1561         fhPhi->Draw();
1562         
1563         c->cd(4) ; 
1564         fhEta->SetLineColor(4);
1565         fhEta->Draw();
1566         
1567         sprintf(name,"QA_%s_ReconstructedDistributions.eps",fCalorimeter.Data());
1568         c->Print(name); printf("Plot: %s\n",name);
1569         
1570         //Reconstructed distributions, matched with tracks
1571         //printf("c2\n");
1572         sprintf(cname,"QA_%s_rectrackmatch",fCalorimeter.Data());
1573         TCanvas  * c2 = new TCanvas(cname, "Reconstructed distributions, matched with tracks", 400, 400) ;
1574         c2->Divide(2, 2);
1575         
1576         c2->cd(1) ; 
1577         if(fhECharged->GetEntries() > 0) gPad->SetLogy();
1578         fhECharged->SetLineColor(4);
1579         fhECharged->Draw();
1580         
1581         c2->cd(2) ; 
1582         if(fhPtCharged->GetEntries() > 0) gPad->SetLogy();
1583         fhPtCharged->SetLineColor(4);
1584         fhPtCharged->Draw();
1585         
1586         c2->cd(3) ; 
1587         fhPhiCharged->SetLineColor(4);
1588         fhPhiCharged->Draw();
1589         
1590         c2->cd(4) ; 
1591         fhEtaCharged->SetLineColor(4);
1592         fhEtaCharged->Draw();
1593         
1594         sprintf(name,"QA_%s_ReconstructedDistributions_TrackMatched.eps",fCalorimeter.Data());
1595         c2->Print(name); printf("Plot: %s\n",name);
1596         
1597         TH1F *  hEChargedClone   = (TH1F*)   fhECharged->Clone("EChargedClone");
1598         TH1F *  hPtChargedClone  = (TH1F*)   fhPtCharged->Clone("PtChargedClone");
1599         TH1F *  hEtaChargedClone = (TH1F*)   fhEtaCharged->Clone("EtaChargedClone");
1600         TH1F *  hPhiChargedClone = (TH1F*)   fhPhiCharged->Clone("PhiChargedClone");
1601         
1602         TH1F *  hEChargedClone2   = (TH1F*)   fhECharged->Clone("EChargedClone2");
1603         TH1F *  hPtChargedClone2  = (TH1F*)   fhPtCharged->Clone("PtChargedClone2");
1604         TH1F *  hEtaChargedClone2 = (TH1F*)   fhEtaCharged->Clone("EtaChargedClone2");
1605         TH1F *  hPhiChargedClone2 = (TH1F*)   fhPhiCharged->Clone("PhiChargedClone2");
1606         
1607         //Ratio: reconstructed track matched/ all reconstructed
1608         //printf("c3\n");
1609         sprintf(cname,"QA_%s_rectrackmatchrat",fCalorimeter.Data());
1610         TCanvas  * c3 = new TCanvas(cname, "Ratio: reconstructed track matched/ all reconstructed", 400, 400) ;
1611         c3->Divide(2, 2);
1612         
1613         c3->cd(1) ;
1614         if(hEChargedClone->GetEntries() > 0) gPad->SetLogy();
1615         hEChargedClone->SetTitleOffset(1.6,"Y");
1616     hEChargedClone->SetYTitle("track matched / all   ");
1617         hEChargedClone->SetXTitle("E (GeV)");
1618         hEChargedClone->Divide(fhE);
1619         hEChargedClone->Draw();
1620         
1621         c3->cd(2) ; 
1622         if(hPtChargedClone->GetEntries() > 0) gPad->SetLogy();
1623         hPtChargedClone->SetTitleOffset(1.6,"Y");
1624         hPtChargedClone->SetYTitle("track matched / all   ");
1625     hPtChargedClone->SetXTitle("p_{T} (GeV/c)");
1626         hPtChargedClone->Divide(fhPt);
1627         hPtChargedClone->Draw();
1628         
1629         c3->cd(3) ;
1630         if(hPhiChargedClone->GetEntries() > 0) gPad->SetLogy();
1631         hPhiChargedClone->SetTitleOffset(1.6,"Y");
1632         hPhiChargedClone->SetYTitle("track matched / all   ");
1633         hPhiChargedClone->SetXTitle("#phi (rad)");
1634         hPhiChargedClone->Divide(fhPhi);
1635         hPhiChargedClone->Draw();
1636         
1637         c3->cd(4) ; 
1638         if(hEtaChargedClone->GetEntries() > 0) gPad->SetLogy();
1639         hEtaChargedClone->SetTitleOffset(1.6,"Y");
1640         hEtaChargedClone->SetYTitle("track matched / all   ");
1641         hEtaChargedClone->SetXTitle("#eta");
1642     hEtaChargedClone->Divide(fhEta);
1643         hEtaChargedClone->Draw();
1644         
1645         sprintf(name,"QA_%s_RatioReconstructedMatchedDistributions.eps",fCalorimeter.Data());
1646         c3->Print(name); printf("Plot: %s\n",name);
1647         
1648         //Ratio: reconstructed track matched (minus no track param) / all
1649         //printf("c3\n");
1650         sprintf(cname,"QA_%s_rectrackmatchratout",fCalorimeter.Data());
1651         TCanvas  * c333 = new TCanvas(cname, "Ratio: reconstructed track matched (with outer track param)/ all", 400, 400) ;
1652         c333->Divide(2, 2);
1653         
1654         c333->cd(1) ;
1655         hEChargedClone2->Add(fhEChargedNoOut,-1);
1656         hEChargedClone2->SetYTitle("track matched / all");
1657         hEChargedClone2->SetXTitle("E (GeV)");
1658         hEChargedClone2->Divide(fhE);
1659         hEChargedClone2->Draw();
1660         
1661         c333->cd(2) ; 
1662         hPtChargedClone2->Add(fhPtChargedNoOut,-1);
1663         hPtChargedClone2->SetYTitle("track matched / all");
1664         hPtChargedClone2->SetXTitle("p_{T} (GeV/c)");
1665         hPtChargedClone2->Divide(fhPt);
1666         hPtChargedClone2->Draw();
1667         
1668         c333->cd(3) ;
1669         hPhiChargedClone2->Add(fhPhiChargedNoOut,-1);
1670         hPhiChargedClone2->SetYTitle("track matched / all");
1671         hPhiChargedClone2->SetXTitle("#phi (rad)");
1672         hPhiChargedClone2->Divide(fhPhi);
1673         hPhiChargedClone2->Draw();
1674         
1675         c333->cd(4) ; 
1676         hEtaChargedClone2->Add(fhEtaChargedNoOut,-1);
1677         hEtaChargedClone2->SetYTitle("track matched / all");
1678         hEtaChargedClone2->SetXTitle("#eta");
1679         hEtaChargedClone2->Divide(fhEta);
1680         hEtaChargedClone2->Draw();
1681         
1682         sprintf(name,"QA_%s_RatioReconstructedMatchedDistributionsOuter.eps",fCalorimeter.Data());
1683         c333->Print(name); printf("Plot: %s\n",name);
1684         
1685         //Reconstructed distributions, matched with tracks but no outer param
1686         //printf("c2\n");
1687         sprintf(cname,"QA_%s_rectrackmatch_noout",fCalorimeter.Data());
1688         TCanvas  * c22 = new TCanvas(cname, "Reconstructed distributions, matched with tracks, no outer track param", 400, 400) ;
1689         c22->Divide(2, 2);
1690         
1691         c22->cd(1) ; 
1692         if(fhEChargedNoOut->GetEntries() > 0) gPad->SetLogy();
1693         fhEChargedNoOut->SetLineColor(4);
1694         fhEChargedNoOut->Draw();
1695         
1696         c22->cd(2) ; 
1697         if(fhEChargedNoOut->GetEntries() > 0) gPad->SetLogy();
1698         fhPtChargedNoOut->SetLineColor(4);
1699         fhPtChargedNoOut->Draw();
1700         
1701         c22->cd(3) ; 
1702         fhPhiChargedNoOut->SetLineColor(4);
1703         fhPhiChargedNoOut->Draw();
1704         
1705         c22->cd(4) ; 
1706         fhEtaChargedNoOut->SetLineColor(4);
1707         fhEtaChargedNoOut->Draw();
1708         
1709         sprintf(name,"QA_%s_ReconstructedDistributions_TrackMatched_NoOutParam.eps",fCalorimeter.Data());
1710         c22->Print(name); printf("Plot: %s\n",name);
1711         
1712         //Ratio: reconstructed track matched/ all reconstructed
1713         //printf("c3\n");
1714         
1715 //      TH1F *  hEChargedNoOutClone   = (TH1F*)   fhEChargedNoOut->Clone("EChargedNoOutClone");
1716 //      TH1F *  hPtChargedNoOutClone  = (TH1F*)   fhPtChargedNoOut->Clone("PtChargedNoOutClone");
1717 //      TH1F *  hEtaChargedNoOutClone = (TH1F*)   fhEtaChargedNoOut->Clone("EtaChargedNoOutClone");
1718 //      TH1F *  hPhiChargedNoOutClone = (TH1F*)   fhPhiChargedNoOut->Clone("PhiChargedNoOutClone");     
1719         
1720 //      sprintf(cname,"QA_%s_rectrackmatchratnoout",fCalorimeter.Data());
1721 //      TCanvas  * c33 = new TCanvas(cname, "Ratio: reconstructed track matched/ all reconstructed", 400, 400) ;
1722 //      c33->Divide(2, 2);
1723 //      
1724 //      c33->cd(1) ;
1725 //      hEChargedNoOutClone->SetYTitle("track matched no out/ all matched");
1726 //      hEChargedNoOutClone->SetXTitle("E (GeV)");
1727 //      hEChargedNoOutClone->Divide(fhECharged);
1728 //      hEChargedNoOutClone->Draw();
1729 //      
1730 //      c33->cd(2) ; 
1731 //      hPtChargedNoOutClone->SetYTitle("track matched no out / all matched");
1732 //      hPtChargedNoOutClone->SetXTitle("p_{T} (GeV/c)");
1733 //      hPtChargedNoOutClone->Divide(fhPtCharged);
1734 //      hPtChargedNoOutClone->Draw();
1735 //      
1736 //      c33->cd(3) ;
1737 //      hPhiChargedNoOutClone->SetYTitle("track matched no out/ all matched");
1738 //      hPhiChargedNoOutClone->SetXTitle("#phi (rad)");
1739 //      hPhiChargedNoOutClone->Divide(fhPhiCharged);
1740 //      hPhiChargedNoOutClone->Draw();
1741 //      
1742 //      c33->cd(4) ; 
1743 //      hEtaChargedNoOutClone->SetYTitle("track matched no out/ all matched");
1744 //      hEtaChargedNoOutClone->SetXTitle("#eta");
1745 //      hEtaChargedNoOutClone->Divide(fhEtaCharged);
1746 //      hEtaChargedNoOutClone->Draw();
1747 //      
1748 //      sprintf(name,"QA_%s_RatioMatchedDistributionsAllToNoOut.eps",fCalorimeter.Data());
1749 //      c33->Print(name); printf("Plot: %s\n",name);
1750         
1751         
1752         //eta vs phi
1753         //printf("c4\n");
1754         sprintf(cname,"QA_%s_etavsphi",fCalorimeter.Data());
1755         //      TCanvas  * c4 = new TCanvas(cname, "reconstructed #eta vs #phi", 600, 200) ;
1756         //      c4->Divide(3, 1);
1757         
1758         TCanvas  * c4 = new TCanvas(cname, "reconstructed #eta vs #phi", 400, 200) ;
1759         c4->Divide(2, 1);
1760         
1761         c4->cd(1) ;
1762         fhEtaPhi->Draw("cont");
1763         
1764         c4->cd(2) ; 
1765         fhEtaPhiCharged->Draw("cont");
1766         
1767         //      c4->cd(3) ; 
1768         //      fhEtaPhiChargedNoOut->Draw("cont");
1769         
1770         sprintf(name,"QA_%s_ReconstructedEtaVsPhi.eps",fCalorimeter.Data());
1771         c4->Print(name); printf("Plot: %s\n",name);
1772         
1773         //Invariant mass
1774         Int_t binmin = -1;
1775         Int_t binmax = -1;
1776         
1777         if(fhIM->GetEntries() > 1){
1778                 Int_t nebins  = fhIM->GetNbinsX();
1779                 Int_t emax = (Int_t) fhIM->GetXaxis()->GetXmax();
1780                 Int_t emin = (Int_t) fhIM->GetXaxis()->GetXmin();
1781                 if (emin != 0 ) printf("emin != 0 \n");
1782                 //printf("IM: nBinsX %d, emin %2.2f, emax %2.2f\n",nebins,emin,emax);
1783                 
1784                 sprintf(cname,"QA_%s_IM",fCalorimeter.Data());
1785                 //      printf("c5\n");
1786                 TCanvas  * c5 = new TCanvas(cname, "Invariant mass", 400, 400) ;
1787                 c5->Divide(2, 2);
1788                 
1789                 c5->cd(1) ; 
1790                 fhIM->SetLineColor(4);
1791                 fhIM->Draw();
1792                 
1793                 c5->cd(2) ; 
1794                 binmin = 0;
1795                 binmax =  (Int_t) (5-emin)*nebins/emax;
1796                 TH1D *pyim5 = fhIM->ProjectionY("pyim5",binmin,binmax);
1797                 pyim5->SetTitle("E_{pair} < 5 GeV");
1798                 pyim5->SetLineColor(4);
1799                 pyim5->Draw();
1800                 
1801                 c5->cd(3) ; 
1802                 binmin =  (Int_t) (5-emin)*nebins/emax;
1803                 binmax =  (Int_t) (10-emin)*nebins/emax;
1804                 TH1D *pyim510 = fhIM->ProjectionY("pyim5_10",binmin,binmax);
1805                 pyim510->SetTitle("5 < E_{pair} < 10 GeV");
1806                 pyim510->SetLineColor(4);
1807                 pyim510->Draw();
1808                 
1809                 c5->cd(4) ;
1810                 binmin =  (Int_t) (10-emin)*nebins/emax;
1811                 binmax = -1;
1812                 TH1D *pyim10 = fhIM->ProjectionY("pyim10",binmin,binmax);
1813                 pyim10->SetTitle("E_{pair} > 10 GeV");
1814                 pyim10->SetLineColor(4);
1815                 pyim10->Draw();
1816                 
1817                 sprintf(name,"QA_%s_InvariantMass.eps",fCalorimeter.Data());
1818                 c5->Print(name); printf("Plot: %s\n",name);
1819         }
1820         
1821         //Asymmetry
1822         if(fhAsym->GetEntries() > 1){
1823                 Int_t nebins  = fhAsym->GetNbinsX();
1824                 Int_t emax = (Int_t) fhAsym->GetXaxis()->GetXmax();
1825                 Int_t emin = (Int_t) fhAsym->GetXaxis()->GetXmin();
1826                 if (emin != 0 ) printf("emin != 0 \n");
1827                 //printf("Asym: nBinsX %d, emin %2.2f, emax %2.2f\n",nebins,emin,emax);
1828                 
1829                 sprintf(cname,"QA_%s_Asym",fCalorimeter.Data());
1830                 //      printf("c5\n");
1831                 TCanvas  * c5b = new TCanvas(cname, "Asymmetry", 400, 400) ;
1832                 c5b->Divide(2, 2);
1833                 
1834                 c5b->cd(1) ; 
1835                 fhAsym->SetTitleOffset(1.6,"Y");
1836                 fhAsym->SetLineColor(4);
1837                 fhAsym->Draw();
1838                 
1839                 c5b->cd(2) ; 
1840                 binmin = 0;
1841                 binmax = (Int_t) (5-emin)*nebins/emax;
1842                 TH1D *pyAsym5 = fhAsym->ProjectionY("pyAsym5",binmin,binmax);
1843                 pyAsym5->SetTitle("E_{pair} < 5 GeV");
1844                 pyAsym5->SetLineColor(4);
1845                 pyAsym5->Draw();
1846                 
1847                 c5b->cd(3) ; 
1848                 binmin = (Int_t) (5-emin)*nebins/emax;
1849                 binmax = (Int_t) (10-emin)*nebins/emax;
1850                 TH1D *pyAsym510 = fhAsym->ProjectionY("pyAsym5_10",binmin,binmax);
1851                 pyAsym510->SetTitle("5 < E_{pair} < 10 GeV");
1852                 pyAsym510->SetLineColor(4);
1853                 pyAsym510->Draw();
1854                 
1855                 c5b->cd(4) ;
1856                 binmin = (Int_t) (10-emin)*nebins/emax;
1857                 binmax = -1;
1858                 TH1D *pyAsym10 = fhAsym->ProjectionY("pyAsym10",binmin,binmax);
1859                 pyAsym10->SetTitle("E_{pair} > 10 GeV");
1860                 pyAsym10->SetLineColor(4);
1861                 pyAsym10->Draw();
1862                 
1863                 sprintf(name,"QA_%s_Asymmetry.eps",fCalorimeter.Data());
1864                 c5b->Print(name); printf("Plot: %s\n",name);
1865         }
1866         
1867         if(IsDataMC()){
1868         //Reconstructed vs MC distributions
1869         //printf("c6\n");
1870         sprintf(cname,"QA_%s_recvsmc",fCalorimeter.Data());
1871         TCanvas  * c6 = new TCanvas(cname, "Reconstructed vs MC distributions", 400, 400) ;
1872         c6->Divide(2, 2);
1873         
1874         c6->cd(1) ; 
1875         fh2E->SetTitleOffset(1.6,"Y");
1876         fh2E->SetLineColor(4);
1877         fh2E->Draw();
1878         
1879         c6->cd(2) ; 
1880         fh2Pt->SetTitleOffset(1.6,"Y");
1881         fh2Pt->SetLineColor(4);
1882         fh2Pt->Draw();
1883         
1884         c6->cd(3) ; 
1885         fh2Phi->SetTitleOffset(1.6,"Y");
1886         fh2Phi->SetLineColor(4);
1887         fh2Phi->Draw();
1888         
1889         c6->cd(4) ; 
1890         fh2Eta->SetTitleOffset(1.6,"Y");
1891         fh2Eta->SetLineColor(4);
1892         fh2Eta->Draw();
1893         
1894         sprintf(name,"QA_%s_ReconstructedVSMCDistributions.eps",fCalorimeter.Data());
1895         c6->Print(name); printf("Plot: %s\n",name);     
1896         
1897         //Reconstructed vs MC distributions
1898         //printf("c6\n");
1899         sprintf(cname,"QA_%s_gamrecvsmc",fCalorimeter.Data());
1900         TCanvas  * c6Gam = new TCanvas(cname, "Reconstructed vs MC distributions", 400, 400) ;
1901         c6Gam->Divide(2, 2);
1902         
1903         c6Gam->cd(1) ; 
1904         fhGamE->Draw();
1905         
1906         c6Gam->cd(2) ; 
1907         fhGamPt->Draw();
1908         
1909         c6Gam->cd(3) ; 
1910         fhGamPhi->Draw();
1911         
1912         c6Gam->cd(4) ; 
1913         fhGamEta->Draw();
1914         
1915         sprintf(name,"QA_%s_GammaReconstructedVSMCDistributions.eps",fCalorimeter.Data());
1916         c6->Print(name); printf("Plot: %s\n",name);     
1917         
1918         //Generated - reconstructed  
1919         //printf("c7\n");
1920         sprintf(cname,"QA_%s_diffgenrec",fCalorimeter.Data());
1921         TCanvas  * c7 = new TCanvas(cname, "generated - reconstructed", 400, 400) ;
1922         c7->Divide(2, 2);
1923         
1924         c7->cd(1) ; 
1925         if(fhDeltaE->GetEntries() > 0) gPad->SetLogy();
1926         fhGamDeltaE->SetLineColor(4);
1927         fhDeltaE->Draw();
1928         fhGamDeltaE->Draw("same");
1929         
1930         TLegend pLegendd(0.65,0.55,0.9,0.8);
1931         pLegendd.SetTextSize(0.06);
1932         pLegendd.AddEntry(fhDeltaE,"all","L");
1933         pLegendd.AddEntry(fhGamDeltaE,"from  #gamma","L");
1934         pLegendd.SetFillColor(10);
1935         pLegendd.SetBorderSize(1);
1936         pLegendd.Draw();
1937         
1938         c7->cd(2) ; 
1939         if(fhDeltaPt->GetEntries() > 0) gPad->SetLogy();
1940         fhGamDeltaPt->SetLineColor(4);
1941         fhDeltaPt->Draw();
1942         fhGamDeltaPt->Draw("same");
1943         
1944         c7->cd(3) ; 
1945         fhGamDeltaPhi->SetLineColor(4);
1946         fhDeltaPhi->Draw();
1947         fhGamDeltaPhi->Draw("same");
1948         
1949         c7->cd(4) ; 
1950         fhGamDeltaEta->SetLineColor(4);
1951         fhDeltaEta->Draw();
1952         fhGamDeltaEta->Draw("same");
1953         
1954         sprintf(name,"QA_%s_DiffGeneratedReconstructed.eps",fCalorimeter.Data());
1955         c7->Print(name); printf("Plot: %s\n",name);
1956         
1957         // Reconstructed / Generated 
1958         //printf("c8\n");
1959         sprintf(cname,"QA_%s_ratiorecgen",fCalorimeter.Data());
1960         TCanvas  * c8 = new TCanvas(cname, " reconstructed / generated", 400, 400) ;
1961         c8->Divide(2, 2);
1962         
1963         c8->cd(1) ; 
1964         if(fhRatioE->GetEntries() > 0) gPad->SetLogy();
1965         fhGamRatioE->SetLineColor(4);
1966         fhRatioE->Draw();
1967         fhGamRatioE->Draw("same");
1968         
1969         TLegend pLegendr(0.65,0.55,0.9,0.8);
1970         pLegendr.SetTextSize(0.06);
1971         pLegendr.AddEntry(fhRatioE,"all","L");
1972         pLegendr.AddEntry(fhGamRatioE,"from  #gamma","L");
1973         pLegendr.SetFillColor(10);
1974         pLegendr.SetBorderSize(1);
1975         pLegendr.Draw();
1976         
1977         c8->cd(2) ; 
1978         if(fhRatioPt->GetEntries() > 0) gPad->SetLogy();
1979         fhGamRatioPt->SetLineColor(4);
1980         fhRatioPt->Draw();
1981         fhGamRatioPt->Draw("same");
1982         
1983         c8->cd(3) ; 
1984         fhGamRatioPhi->SetLineColor(4);
1985         fhRatioPhi->Draw();
1986         fhGamRatioPhi->Draw("same");
1987         
1988         c8->cd(4) ; 
1989         fhGamRatioEta->SetLineColor(4);
1990         fhRatioEta->Draw();
1991         fhGamRatioEta->Draw("same");
1992         
1993         sprintf(name,"QA_%s_ReconstructedDivGenerated.eps",fCalorimeter.Data());
1994         c8->Print(name); printf("Plot: %s\n",name);
1995         
1996         //MC
1997         
1998         //Generated distributions
1999         //printf("c1\n");
2000         sprintf(cname,"QA_%s_gen",fCalorimeter.Data());
2001         TCanvas  * c10 = new TCanvas(cname, "Generated distributions", 600, 200) ;
2002         c10->Divide(3, 1);
2003         
2004         c10->cd(1) ; 
2005         gPad->SetLogy();
2006         TH1F * haxispt  = (TH1F*) fhGenPi0Pt->Clone("axispt");  
2007         haxispt->SetTitle("Generated Particles p_{T}, |#eta| < 1");
2008         fhGenPi0Pt->SetLineColor(1);
2009         fhGenGamPt->SetLineColor(4);
2010         fhGenEtaPt->SetLineColor(2);
2011         fhGenOmegaPt->SetLineColor(7);
2012         fhGenElePt->SetLineColor(6);
2013         
2014         //Select the maximum of the histogram to show all lines.
2015         if(fhGenPi0Pt->GetMaximum() >= fhGenGamPt->GetMaximum() && fhGenPi0Pt->GetMaximum() >= fhGenEtaPt->GetMaximum() && 
2016            fhGenPi0Pt->GetMaximum() >= fhGenOmegaPt->GetMaximum() && fhGenPi0Pt->GetMaximum() >= fhGenElePt->GetMaximum())
2017                 haxispt->SetMaximum(fhGenPi0Pt->GetMaximum());
2018         else if(fhGenGamPt->GetMaximum() >= fhGenPi0Pt->GetMaximum() && fhGenGamPt->GetMaximum() >= fhGenEtaPt->GetMaximum() && 
2019                         fhGenGamPt->GetMaximum() >= fhGenOmegaPt->GetMaximum() && fhGenGamPt->GetMaximum() >= fhGenElePt->GetMaximum())
2020                 haxispt->SetMaximum(fhGenGamPt->GetMaximum());
2021         else if(fhGenEtaPt->GetMaximum() >= fhGenPi0Pt->GetMaximum() && fhGenEtaPt->GetMaximum() >= fhGenGamPt->GetMaximum() && 
2022                         fhGenEtaPt->GetMaximum() >= fhGenOmegaPt->GetMaximum() && fhGenEtaPt->GetMaximum() >= fhGenElePt->GetMaximum())
2023                 haxispt->SetMaximum(fhGenEtaPt->GetMaximum());  
2024         else if(fhGenOmegaPt->GetMaximum() >= fhGenPi0Pt->GetMaximum() && fhGenOmegaPt->GetMaximum() >= fhGenEtaPt->GetMaximum() && 
2025                         fhGenOmegaPt->GetMaximum() >= fhGenGamPt->GetMaximum() && fhGenOmegaPt->GetMaximum() >= fhGenElePt->GetMaximum())
2026                 haxispt->SetMaximum(fhGenOmegaPt->GetMaximum());
2027         else if(fhGenElePt->GetMaximum() >= fhGenPi0Pt->GetMaximum() && fhGenElePt->GetMaximum() >= fhGenEtaPt->GetMaximum() && 
2028                         fhGenElePt->GetMaximum() >= fhGenOmegaPt->GetMaximum() && fhGenElePt->GetMaximum() >= fhGenGamPt->GetMaximum())
2029                 haxispt->SetMaximum(fhGenElePt->GetMaximum());
2030         haxispt->SetMinimum(1);
2031         haxispt->Draw("axis");
2032         fhGenPi0Pt->Draw("same");
2033         fhGenGamPt->Draw("same");
2034         fhGenEtaPt->Draw("same");
2035         fhGenOmegaPt->Draw("same");
2036         fhGenElePt->Draw("same");
2037         
2038         TLegend pLegend(0.85,0.65,0.95,0.93);
2039         pLegend.SetTextSize(0.06);
2040         pLegend.AddEntry(fhGenPi0Pt,"  #pi^{0}","L");
2041         pLegend.AddEntry(fhGenGamPt,"  #gamma","L");
2042         pLegend.AddEntry(fhGenEtaPt,"  #eta","L");
2043         pLegend.AddEntry(fhGenOmegaPt,"  #omega","L");
2044         pLegend.AddEntry(fhGenElePt,"  e^{#pm}","L");
2045         pLegend.SetFillColor(10);
2046         pLegend.SetBorderSize(1);
2047         pLegend.Draw();
2048         
2049         c10->cd(2) ;
2050         gPad->SetLogy();
2051         TH1F * haxiseta  = (TH1F*) fhGenPi0Eta->Clone("axiseta");  
2052         haxiseta->SetTitle("Generated Particles #eta, |#eta| < 1");
2053         fhGenPi0Eta->SetLineColor(1);
2054         fhGenGamEta->SetLineColor(4);
2055         fhGenEtaEta->SetLineColor(2);
2056         fhGenOmegaEta->SetLineColor(7);
2057         fhGenEleEta->SetLineColor(6);
2058         //Select the maximum of the histogram to show all lines.
2059         if(fhGenPi0Eta->GetMaximum() >= fhGenGamEta->GetMaximum() && fhGenPi0Eta->GetMaximum() >= fhGenEtaEta->GetMaximum() && 
2060            fhGenPi0Eta->GetMaximum() >= fhGenOmegaEta->GetMaximum() && fhGenPi0Eta->GetMaximum() >= fhGenEleEta->GetMaximum())
2061                 haxiseta->SetMaximum(fhGenPi0Eta->GetMaximum());
2062         else if(fhGenGamEta->GetMaximum() >= fhGenPi0Eta->GetMaximum() && fhGenGamEta->GetMaximum() >= fhGenEtaEta->GetMaximum() && 
2063                         fhGenGamEta->GetMaximum() >= fhGenOmegaEta->GetMaximum() && fhGenGamEta->GetMaximum() >= fhGenEleEta->GetMaximum())
2064                 haxiseta->SetMaximum(fhGenGamEta->GetMaximum());
2065         else if(fhGenEtaEta->GetMaximum() >= fhGenPi0Eta->GetMaximum() && fhGenEtaEta->GetMaximum() >= fhGenGamEta->GetMaximum() && 
2066                         fhGenEtaEta->GetMaximum() >= fhGenOmegaEta->GetMaximum() && fhGenEtaEta->GetMaximum() >= fhGenEleEta->GetMaximum())
2067                 haxiseta->SetMaximum(fhGenEtaEta->GetMaximum());        
2068         else if(fhGenOmegaEta->GetMaximum() >= fhGenPi0Eta->GetMaximum() && fhGenOmegaEta->GetMaximum() >= fhGenEtaEta->GetMaximum() && 
2069                         fhGenOmegaEta->GetMaximum() >= fhGenGamEta->GetMaximum() && fhGenOmegaEta->GetMaximum() >= fhGenEleEta->GetMaximum())
2070                 haxiseta->SetMaximum(fhGenOmegaEta->GetMaximum());
2071         else if(fhGenEleEta->GetMaximum() >= fhGenPi0Eta->GetMaximum() && fhGenEleEta->GetMaximum() >= fhGenEtaEta->GetMaximum() && 
2072                         fhGenEleEta->GetMaximum() >= fhGenOmegaEta->GetMaximum() && fhGenEleEta->GetMaximum() >= fhGenGamEta->GetMaximum())
2073                 haxiseta->SetMaximum(fhGenEleEta->GetMaximum());
2074         haxiseta->SetMinimum(100);
2075         haxiseta->Draw("axis");
2076         fhGenPi0Eta->Draw("same");
2077         fhGenGamEta->Draw("same");
2078         fhGenEtaEta->Draw("same");
2079         fhGenOmegaEta->Draw("same");
2080         fhGenEleEta->Draw("same");
2081         
2082         
2083         c10->cd(3) ; 
2084         gPad->SetLogy();
2085         TH1F * haxisphi  = (TH1F*) fhGenPi0Phi->Clone("axisphi");  
2086         haxisphi->SetTitle("Generated Particles #phi, |#eta| < 1");
2087         fhGenPi0Phi->SetLineColor(1);
2088         fhGenGamPhi->SetLineColor(4);
2089         fhGenEtaPhi->SetLineColor(2);
2090         fhGenOmegaPhi->SetLineColor(7);
2091         fhGenElePhi->SetLineColor(6);
2092         //Select the maximum of the histogram to show all lines.
2093         if(fhGenPi0Phi->GetMaximum() >= fhGenGamPhi->GetMaximum() && fhGenPi0Phi->GetMaximum() >= fhGenEtaPhi->GetMaximum() && 
2094            fhGenPi0Phi->GetMaximum() >= fhGenOmegaPhi->GetMaximum() && fhGenPi0Phi->GetMaximum() >= fhGenElePhi->GetMaximum())
2095                 haxisphi->SetMaximum(fhGenPi0Phi->GetMaximum());
2096         else if(fhGenGamPhi->GetMaximum() >= fhGenPi0Phi->GetMaximum() && fhGenGamPhi->GetMaximum() >= fhGenEtaPhi->GetMaximum() && 
2097                         fhGenGamPhi->GetMaximum() >= fhGenOmegaPhi->GetMaximum() && fhGenGamPhi->GetMaximum() >= fhGenElePhi->GetMaximum())
2098                 haxisphi->SetMaximum(fhGenGamPhi->GetMaximum());
2099         else if(fhGenEtaPhi->GetMaximum() >= fhGenPi0Phi->GetMaximum() && fhGenEtaPhi->GetMaximum() >= fhGenGamPhi->GetMaximum() && 
2100                         fhGenEtaPhi->GetMaximum() >= fhGenOmegaPhi->GetMaximum() && fhGenEtaPhi->GetMaximum() >= fhGenElePhi->GetMaximum())
2101                 haxisphi->SetMaximum(fhGenEtaPhi->GetMaximum());        
2102         else if(fhGenOmegaPhi->GetMaximum() >= fhGenPi0Phi->GetMaximum() && fhGenOmegaPhi->GetMaximum() >= fhGenEtaPhi->GetMaximum() && 
2103                         fhGenOmegaPhi->GetMaximum() >= fhGenGamPhi->GetMaximum() && fhGenOmegaPhi->GetMaximum() >= fhGenElePhi->GetMaximum())
2104                 haxisphi->SetMaximum(fhGenOmegaPhi->GetMaximum());
2105         else if(fhGenElePhi->GetMaximum() >= fhGenPi0Phi->GetMaximum() && fhGenElePhi->GetMaximum() >= fhGenEtaPhi->GetMaximum() && 
2106                         fhGenElePhi->GetMaximum() >= fhGenOmegaPhi->GetMaximum() && fhGenElePhi->GetMaximum() >= fhGenGamPhi->GetMaximum())
2107                 haxisphi->SetMaximum(fhGenElePhi->GetMaximum());
2108         haxisphi->SetMinimum(100);
2109         haxisphi->Draw("axis");
2110         fhGenPi0Phi->Draw("same");
2111         fhGenGamPhi->Draw("same");
2112         fhGenEtaPhi->Draw("same");
2113         fhGenOmegaPhi->Draw("same");
2114         fhGenElePhi->Draw("same");
2115         
2116         sprintf(name,"QA_%s_GeneratedDistributions.eps",fCalorimeter.Data());
2117         c10->Print(name); printf("Plot: %s\n",name);
2118         
2119         
2120         //Reconstructed clusters depending on its original particle.
2121         //printf("c1\n");
2122         sprintf(cname,"QA_%s_recgenid",fCalorimeter.Data());
2123         TCanvas  * c11 = new TCanvas(cname, "Reconstructed particles, function of their original particle ID", 400, 400) ;
2124         c11->Divide(2, 2);
2125         
2126         
2127         c11->cd(1) ; 
2128         gPad->SetLogy();
2129         TH1F * hGamE   = (TH1F*) fhGamE->ProjectionX("hGamE",-1,-1);
2130         TH1F * hPi0E   = (TH1F*) fhPi0E->ProjectionX("hPi0E",-1,-1);
2131         TH1F * hEleE   = (TH1F*) fhEleE->ProjectionX("hEleE",-1,-1);
2132         TH1F * hNeHadE = (TH1F*) fhNeHadE->ProjectionX("hNeHadE",-1,-1);
2133         TH1F * hChHadE = (TH1F*) fhChHadE->ProjectionX("hChHadE",-1,-1);
2134         TH1F * haxisE  = (TH1F*) hPi0E->Clone("axisE");  
2135         haxisE->SetTitle("Reconstructed particles E, function of their original particle ID");
2136         hPi0E->SetLineColor(1);
2137         hGamE->SetLineColor(4);
2138         hNeHadE->SetLineColor(2);
2139         hChHadE->SetLineColor(7);
2140         hEleE->SetLineColor(6);
2141         
2142         //Select the maximum of the histogram to show all lines.
2143         if(hPi0E->GetMaximum() >= hGamE->GetMaximum() && hPi0E->GetMaximum() >= hNeHadE->GetMaximum() && 
2144            hPi0E->GetMaximum() >= hChHadE->GetMaximum() && hPi0E->GetMaximum() >= hEleE->GetMaximum())
2145                 haxisE->SetMaximum(hPi0E->GetMaximum());
2146         else if(hGamE->GetMaximum() >= hPi0E->GetMaximum() && hGamE->GetMaximum() >= hNeHadE->GetMaximum() && 
2147                         hGamE->GetMaximum() >= hChHadE->GetMaximum() && hGamE->GetMaximum() >= hEleE->GetMaximum())
2148                 haxisE->SetMaximum(hGamE->GetMaximum());
2149         else if(hNeHadE->GetMaximum() >= hPi0E->GetMaximum() && hNeHadE->GetMaximum() >= hGamE->GetMaximum() && 
2150                         hNeHadE->GetMaximum() >= hChHadE->GetMaximum() && hNeHadE->GetMaximum() >= hEleE->GetMaximum())
2151                 haxisE->SetMaximum(hNeHadE->GetMaximum());      
2152         else if(hChHadE->GetMaximum() >= hPi0E->GetMaximum() && hChHadE->GetMaximum() >= hNeHadE->GetMaximum() && 
2153                         hChHadE->GetMaximum() >= hGamE->GetMaximum() && hChHadE->GetMaximum() >= hEleE->GetMaximum())
2154                 haxisE->SetMaximum(hChHadE->GetMaximum());
2155         else if(hEleE->GetMaximum() >= hPi0E->GetMaximum() && hEleE->GetMaximum() >= hNeHadE->GetMaximum() && 
2156                         hEleE->GetMaximum() >= hChHadE->GetMaximum() && hEleE->GetMaximum() >= hGamE->GetMaximum())
2157                 haxisE->SetMaximum(hEleE->GetMaximum());
2158         haxisE->SetXTitle("E (GeV)");
2159         haxisE->SetMinimum(1);
2160         haxisE->Draw("axis");
2161         hPi0E->Draw("same");
2162         hGamE->Draw("same");
2163         hNeHadE->Draw("same");
2164         hChHadE->Draw("same");
2165         hEleE->Draw("same");
2166         
2167         TLegend pLegend2(0.8,0.65,0.95,0.93);
2168         pLegend2.SetTextSize(0.06);
2169         pLegend2.AddEntry(hPi0E,"  #pi^{0}","L");
2170         pLegend2.AddEntry(hGamE,"  #gamma","L");
2171         pLegend2.AddEntry(hEleE,"  e^{#pm}","L");
2172         pLegend2.AddEntry(hChHadE,"  h^{#pm}","L");
2173         pLegend2.AddEntry(hNeHadE,"  h^{0}","L");
2174         pLegend2.SetFillColor(10);
2175         pLegend2.SetBorderSize(1);
2176         pLegend2.Draw();
2177         
2178         
2179         c11->cd(2) ; 
2180         gPad->SetLogy();
2181         //printf("%s, %s, %s, %s, %s\n",fhGamPt->GetName(),fhPi0Pt->GetName(),fhElePt->GetName(),fhNeHadPt->GetName(), fhChHadPt->GetName());
2182         TH1F * hGamPt   = (TH1F*) fhGamPt->ProjectionX("hGamPt",-1,-1);
2183         TH1F * hPi0Pt   = (TH1F*) fhPi0Pt->ProjectionX("hPi0Pt",-1,-1);
2184         TH1F * hElePt   = (TH1F*) fhElePt->ProjectionX("hElePt",-1,-1);
2185         TH1F * hNeHadPt = (TH1F*) fhNeHadPt->ProjectionX("hNeHadPt",-1,-1);
2186         TH1F * hChHadPt = (TH1F*) fhChHadPt->ProjectionX("hChHadPt",-1,-1);
2187         haxispt  = (TH1F*) hPi0Pt->Clone("axispt");  
2188         haxispt->SetTitle("Reconstructed particles p_{T}, function of their original particle ID");
2189         hPi0Pt->SetLineColor(1);
2190         hGamPt->SetLineColor(4);
2191         hNeHadPt->SetLineColor(2);
2192         hChHadPt->SetLineColor(7);
2193         hElePt->SetLineColor(6);
2194         
2195         //Select the maximum of the histogram to show all lines.
2196         if(hPi0Pt->GetMaximum() >= hGamPt->GetMaximum() && hPi0Pt->GetMaximum() >= hNeHadPt->GetMaximum() && 
2197            hPi0Pt->GetMaximum() >= hChHadPt->GetMaximum() && hPi0Pt->GetMaximum() >= hElePt->GetMaximum())
2198                 haxispt->SetMaximum(hPi0Pt->GetMaximum());
2199         else if(hGamPt->GetMaximum() >= hPi0Pt->GetMaximum() && hGamPt->GetMaximum() >= hNeHadPt->GetMaximum() && 
2200                         hGamPt->GetMaximum() >= hChHadPt->GetMaximum() && hGamPt->GetMaximum() >= hElePt->GetMaximum())
2201                 haxispt->SetMaximum(hGamPt->GetMaximum());
2202         else if(hNeHadPt->GetMaximum() >= hPi0Pt->GetMaximum() && hNeHadPt->GetMaximum() >= hGamPt->GetMaximum() && 
2203                         hNeHadPt->GetMaximum() >= hChHadPt->GetMaximum() && hNeHadPt->GetMaximum() >= hElePt->GetMaximum())
2204                 haxispt->SetMaximum(hNeHadPt->GetMaximum());    
2205         else if(hChHadPt->GetMaximum() >= hPi0Pt->GetMaximum() && hChHadPt->GetMaximum() >= hNeHadPt->GetMaximum() && 
2206                         hChHadPt->GetMaximum() >= hGamPt->GetMaximum() && hChHadPt->GetMaximum() >= hElePt->GetMaximum())
2207                 haxispt->SetMaximum(hChHadPt->GetMaximum());
2208         else if(hElePt->GetMaximum() >= hPi0Pt->GetMaximum() && hElePt->GetMaximum() >= hNeHadPt->GetMaximum() && 
2209                         hElePt->GetMaximum() >= hChHadPt->GetMaximum() && hElePt->GetMaximum() >= hGamPt->GetMaximum())
2210                 haxispt->SetMaximum(hElePt->GetMaximum());
2211         haxispt->SetXTitle("p_{T} (GeV/c)");
2212         haxispt->SetMinimum(1);
2213         haxispt->Draw("axis");
2214         hPi0Pt->Draw("same");
2215         hGamPt->Draw("same");
2216         hNeHadPt->Draw("same");
2217         hChHadPt->Draw("same");
2218     hElePt->Draw("same");
2219         
2220         
2221         c11->cd(3) ;
2222         gPad->SetLogy();
2223         
2224         TH1F * hGamEta   = (TH1F*) fhGamEta->ProjectionX("hGamEta",-1,-1);
2225         TH1F * hPi0Eta   = (TH1F*) fhPi0Eta->ProjectionX("hPi0Eta",-1,-1);
2226         TH1F * hEleEta   = (TH1F*) fhEleEta->ProjectionX("hEleEta",-1,-1);
2227         TH1F * hNeHadEta = (TH1F*) fhNeHadEta->ProjectionX("hNeHadEta",-1,-1);
2228         TH1F * hChHadEta = (TH1F*) fhChHadEta->ProjectionX("hChHadEta",-1,-1);
2229         haxiseta  = (TH1F*) hPi0Eta->Clone("axiseta");  
2230         haxiseta->SetTitle("Reconstructed particles #eta, function of their original particle ID");
2231         hPi0Eta->SetLineColor(1);
2232         hGamEta->SetLineColor(4);
2233         hNeHadEta->SetLineColor(2);
2234         hChHadEta->SetLineColor(7);
2235         hEleEta->SetLineColor(6);
2236         //Select the maximum of the histogram to show all lines.
2237         if(hPi0Eta->GetMaximum() >= hGamEta->GetMaximum() && hPi0Eta->GetMaximum() >= hNeHadEta->GetMaximum() && 
2238            hPi0Eta->GetMaximum() >= hChHadEta->GetMaximum() && hPi0Eta->GetMaximum() >= hEleEta->GetMaximum())
2239                 haxiseta->SetMaximum(hPi0Eta->GetMaximum());
2240         else if(hGamEta->GetMaximum() >= hPi0Eta->GetMaximum() && hGamEta->GetMaximum() >= hNeHadEta->GetMaximum() && 
2241                         hGamEta->GetMaximum() >= hChHadEta->GetMaximum() && hGamEta->GetMaximum() >= hEleEta->GetMaximum())
2242                 haxiseta->SetMaximum(hGamEta->GetMaximum());
2243         else if(hNeHadEta->GetMaximum() >= hPi0Eta->GetMaximum() && hNeHadEta->GetMaximum() >= hGamEta->GetMaximum() && 
2244                         hNeHadEta->GetMaximum() >= hChHadEta->GetMaximum() && hNeHadEta->GetMaximum() >= hEleEta->GetMaximum())
2245                 haxiseta->SetMaximum(hNeHadEta->GetMaximum());  
2246         else if(hChHadEta->GetMaximum() >= hPi0Eta->GetMaximum() && hChHadEta->GetMaximum() >= hNeHadEta->GetMaximum() && 
2247                         hChHadEta->GetMaximum() >= hGamEta->GetMaximum() && hChHadEta->GetMaximum() >= hEleEta->GetMaximum())
2248                 haxiseta->SetMaximum(hChHadEta->GetMaximum());
2249         else if(hEleEta->GetMaximum() >= hPi0Eta->GetMaximum() && hEleEta->GetMaximum() >= hNeHadEta->GetMaximum() && 
2250                         hEleEta->GetMaximum() >= hChHadEta->GetMaximum() && hEleEta->GetMaximum() >= hGamEta->GetMaximum())
2251                 haxiseta->SetMaximum(hEleEta->GetMaximum());
2252         
2253     haxiseta->SetXTitle("#eta");
2254         haxiseta->Draw("axis");
2255         hPi0Eta->Draw("same");
2256         hGamEta->Draw("same");
2257         hNeHadEta->Draw("same");
2258         hChHadEta->Draw("same");
2259         hEleEta->Draw("same");
2260         
2261         
2262         c11->cd(4) ; 
2263         gPad->SetLogy();
2264         TH1F * hGamPhi   = (TH1F*) fhGamPhi->ProjectionX("hGamPhi",-1,-1);
2265         TH1F * hPi0Phi   = (TH1F*) fhPi0Phi->ProjectionX("hPi0Phi",-1,-1);
2266         TH1F * hElePhi   = (TH1F*) fhElePhi->ProjectionX("hElePhi",-1,-1);
2267         TH1F * hNeHadPhi = (TH1F*) fhNeHadPhi->ProjectionX("hNeHadPhi",-1,-1);
2268         TH1F * hChHadPhi = (TH1F*) fhChHadPhi->ProjectionX("hChHadPhi",-1,-1);
2269         haxisphi  = (TH1F*) hPi0Phi->Clone("axisphi");  
2270         haxisphi->SetTitle("Reconstructed particles #phi, function of their original particle ID");
2271         
2272         hPi0Phi->SetLineColor(1);
2273         hGamPhi->SetLineColor(4);
2274         hNeHadPhi->SetLineColor(2);
2275         hChHadPhi->SetLineColor(7);
2276         hElePhi->SetLineColor(6);
2277         //Select the maximum of the histogram to show all lines.
2278         if(hPi0Phi->GetMaximum() >= hGamPhi->GetMaximum() && hPi0Phi->GetMaximum() >= hNeHadPhi->GetMaximum() && 
2279            hPi0Phi->GetMaximum() >= hChHadPhi->GetMaximum() && hPi0Phi->GetMaximum() >= hElePhi->GetMaximum())
2280                 haxisphi->SetMaximum(hPi0Phi->GetMaximum());
2281         else if(hGamPhi->GetMaximum() >= hPi0Phi->GetMaximum() && hGamPhi->GetMaximum() >= hNeHadPhi->GetMaximum() && 
2282                         hGamPhi->GetMaximum() >= hChHadPhi->GetMaximum() && hGamPhi->GetMaximum() >= hElePhi->GetMaximum())
2283                 haxisphi->SetMaximum(hGamPhi->GetMaximum());
2284         else if(hNeHadPhi->GetMaximum() >= hPi0Phi->GetMaximum() && hNeHadPhi->GetMaximum() >= hGamPhi->GetMaximum() && 
2285                         hNeHadPhi->GetMaximum() >= hChHadPhi->GetMaximum() && hNeHadPhi->GetMaximum() >= hElePhi->GetMaximum())
2286                 haxisphi->SetMaximum(hNeHadPhi->GetMaximum());  
2287         else if(hChHadPhi->GetMaximum() >= hPi0Phi->GetMaximum() && hChHadPhi->GetMaximum() >= hNeHadPhi->GetMaximum() && 
2288                         hChHadPhi->GetMaximum() >= hGamPhi->GetMaximum() && hChHadPhi->GetMaximum() >= hElePhi->GetMaximum())
2289                 haxisphi->SetMaximum(hChHadPhi->GetMaximum());
2290         else if(hElePhi->GetMaximum() >= hPi0Phi->GetMaximum() && hElePhi->GetMaximum() >= hNeHadPhi->GetMaximum() && 
2291                         hElePhi->GetMaximum() >= hChHadPhi->GetMaximum() && hElePhi->GetMaximum() >= hGamPhi->GetMaximum())
2292                 haxisphi->SetMaximum(hElePhi->GetMaximum());
2293         haxisphi->SetXTitle("#phi (rad)");
2294         haxisphi->Draw("axis");
2295         hPi0Phi->Draw("same");
2296         hGamPhi->Draw("same");
2297         hNeHadPhi->Draw("same");
2298         hChHadPhi->Draw("same");
2299         hElePhi->Draw("same");
2300         
2301         sprintf(name,"QA_%s_RecDistributionsGenID.eps",fCalorimeter.Data());
2302         c11->Print(name); printf("Plot: %s\n",name);
2303         
2304         
2305         //Ratio reconstructed clusters / generated particles in acceptance, for different particle ID
2306         //printf("c1\n");
2307         
2308         TH1F *  hPi0EClone   = (TH1F*)   hPi0E  ->Clone("hPi0EClone");
2309         TH1F *  hGamEClone   = (TH1F*)   hGamE  ->Clone("hGamEClone");
2310         TH1F *  hPi0PtClone  = (TH1F*)   hPi0Pt ->Clone("hPi0PtClone");
2311         TH1F *  hGamPtClone  = (TH1F*)   hGamPt ->Clone("hGamPtClone"); 
2312         TH1F *  hPi0EtaClone = (TH1F*)   hPi0Eta->Clone("hPi0EtaClone");
2313         TH1F *  hGamEtaClone = (TH1F*)   hGamEta->Clone("hGamEtaClone");        
2314         TH1F *  hPi0PhiClone = (TH1F*)   hPi0Phi->Clone("hPi0PhiClone");
2315         TH1F *  hGamPhiClone = (TH1F*)   hGamPhi->Clone("hGamPhiClone");        
2316         
2317         sprintf(cname,"QA_%s_recgenidratio",fCalorimeter.Data());
2318         TCanvas  * c12 = new TCanvas(cname, "Ratio reconstructed clusters / generated particles in acceptance, for different particle ID", 400, 400) ;
2319         c12->Divide(2, 2);
2320         
2321         c12->cd(1) ; 
2322         gPad->SetLogy();
2323         haxisE->SetTitle("Ratio reconstructed clusters / generated particles in acceptance, for different particle ID");
2324         hPi0EClone->Divide(fhGenPi0AccE);
2325         hGamEClone->Divide(fhGenGamAccE);
2326         haxisE->SetMaximum(5);
2327         haxisE->SetMinimum(1e-2);
2328         haxisE->SetXTitle("E (GeV)");
2329         haxisE->SetYTitle("ratio = rec/gen");
2330         haxisE->Draw("axis");
2331         hPi0E->Draw("same");
2332         hGamE->Draw("same");
2333         
2334         TLegend pLegend3(0.75,0.2,0.9,0.4);
2335         pLegend3.SetTextSize(0.06);
2336         pLegend3.AddEntry(hPi0EClone,"  #pi^{0}","L");
2337         pLegend3.AddEntry(hGamEClone,"  #gamma","L");
2338         pLegend3.SetFillColor(10);
2339         pLegend3.SetBorderSize(1);
2340         pLegend3.Draw();
2341         
2342         c12->cd(2) ; 
2343         gPad->SetLogy();
2344         haxispt->SetTitle("Ratio reconstructed clusters / generated particles in acceptance, for different particle ID");
2345         hPi0PtClone->Divide(fhGenPi0AccPt);
2346         hGamPtClone->Divide(fhGenGamAccPt);
2347         haxispt->SetMaximum(5);
2348         haxispt->SetMinimum(1e-2);
2349         haxispt->SetXTitle("p_{T} (GeV/c)");
2350         haxispt->SetYTitle("ratio = rec/gen");
2351         haxispt->Draw("axis");
2352         hPi0PtClone->Draw("same");
2353         hGamPtClone->Draw("same");
2354         
2355         c12->cd(3) ;
2356         gPad->SetLogy();
2357         
2358         haxiseta->SetTitle("Ratio reconstructed clusters / generated particles in acceptance, for different particle ID");
2359         hPi0EtaClone->Divide(fhGenPi0AccEta);
2360         hGamEtaClone->Divide(fhGenGamAccEta);
2361         haxiseta->SetMaximum(1.2);
2362         haxiseta->SetMinimum(1e-2);
2363         haxiseta->SetYTitle("ratio = rec/gen");
2364         haxiseta->SetXTitle("#eta");
2365         haxiseta->Draw("axis");
2366         hPi0EtaClone->Draw("same");
2367         hGamEtaClone->Draw("same");
2368         
2369         
2370         c12->cd(4) ; 
2371         gPad->SetLogy();
2372         haxisphi->SetTitle("Ratio reconstructed clusters / generated particles in acceptance, for different particle ID");
2373         hPi0PhiClone->Divide(fhGenPi0AccPhi);
2374         hGamPhiClone->Divide(fhGenGamAccPhi);
2375     haxisphi->SetYTitle("ratio = rec/gen");
2376         haxisphi->SetXTitle("#phi (rad)");
2377         haxisphi->SetMaximum(1.2);
2378         haxisphi->SetMinimum(1e-2);
2379         haxisphi->Draw("axis");
2380         hPi0PhiClone->Draw("same");
2381         hGamPhiClone->Draw("same");
2382         
2383         sprintf(name,"QA_%s_EfficiencyGenID.eps",fCalorimeter.Data());
2384         c12->Print(name); printf("Plot: %s\n",name);
2385         
2386         
2387         
2388         //Reconstructed distributions
2389         //printf("c1\n");
2390         sprintf(cname,"QA_%s_vertex",fCalorimeter.Data());
2391         TCanvas  * c13 = new TCanvas(cname, "Particle vertex", 400, 400) ;
2392         c13->Divide(2, 2);
2393         
2394         c13->cd(1) ; 
2395         //gPad->SetLogy();
2396         fhEMVxyz->SetTitleOffset(1.6,"Y");
2397     fhEMVxyz->Draw();
2398         
2399         c13->cd(2) ; 
2400         //gPad->SetLogy();
2401         fhHaVxyz->SetTitleOffset(1.6,"Y");
2402         fhHaVxyz->Draw();
2403         
2404         c13->cd(3) ;
2405         gPad->SetLogy();
2406         TH1F * hEMR = (TH1F*) fhEMR->ProjectionY("hEM",-1,-1); 
2407         hEMR->SetLineColor(4);
2408         hEMR->Draw();
2409         
2410         c13->cd(4) ; 
2411         gPad->SetLogy();
2412         TH1F * hHaR = (TH1F*) fhHaR->ProjectionY("hHa",-1,-1); 
2413         hHaR->SetLineColor(4);
2414         hHaR->Draw();
2415         
2416         
2417         sprintf(name,"QA_%s_ParticleVertex.eps",fCalorimeter.Data());
2418         c13->Print(name); printf("Plot: %s\n",name);
2419         
2420         
2421         //Track-matching distributions
2422
2423         //Reconstructed distributions, matched with tracks, generated particle dependence
2424         //printf("c2\n");
2425         sprintf(cname,"QA_%s_rectrackmatchGenID",fCalorimeter.Data());
2426         TCanvas  * c22ch = new TCanvas(cname, "Reconstructed distributions, matched with tracks, for different particle ID", 400, 400) ;
2427         c22ch->Divide(2, 2);
2428         
2429         c22ch->cd(1) ; 
2430         
2431         TH1F * hGamECharged   = (TH1F*) fhGamECharged->ProjectionX("hGamECharged",-1,-1);
2432         TH1F * hPi0ECharged   = (TH1F*) fhPi0ECharged->ProjectionX("hPi0ECharged",-1,-1);
2433         TH1F * hEleECharged   = (TH1F*) fhEleECharged->ProjectionX("hEleECharged",-1,-1);
2434         TH1F * hNeHadECharged = (TH1F*) fhNeHadECharged->ProjectionX("hNeHadECharged",-1,-1);
2435         TH1F * hChHadECharged = (TH1F*) fhChHadECharged->ProjectionX("hChHadECharged",-1,-1);
2436         hPi0ECharged->SetLineColor(1);
2437         hGamECharged->SetLineColor(4);
2438         hNeHadECharged->SetLineColor(2);
2439         hChHadECharged->SetLineColor(7);
2440         hEleECharged->SetLineColor(6);  
2441         gPad->SetLogy();
2442         fhECharged->SetLineColor(3);
2443         fhECharged->SetMinimum(0.5);
2444         fhECharged->Draw();
2445         hPi0ECharged->Draw("same");
2446         hGamECharged->Draw("same");
2447         hNeHadECharged->Draw("same");
2448         hChHadECharged->Draw("same");
2449         hEleECharged->Draw("same");
2450         TLegend pLegend22(0.75,0.45,0.9,0.8);
2451         pLegend22.SetTextSize(0.06);
2452         pLegend22.AddEntry(fhECharged,"all","L");
2453         pLegend22.AddEntry(hPi0ECharged,"#pi^{0}","L");
2454         pLegend22.AddEntry(hGamECharged,"#gamma","L");
2455         pLegend22.AddEntry(hEleECharged,"e^{#pm}","L");
2456         pLegend22.AddEntry(hChHadECharged,"h^{#pm}","L");
2457         pLegend22.AddEntry(hNeHadECharged,"h^{0}","L");
2458         pLegend22.SetFillColor(10);
2459         pLegend22.SetBorderSize(1);
2460         pLegend22.Draw();
2461         
2462         c22ch->cd(2) ; 
2463         
2464         TH1F * hGamPtCharged   = (TH1F*) fhGamPtCharged->ProjectionX("hGamPtCharged",-1,-1);
2465         TH1F * hPi0PtCharged   = (TH1F*) fhPi0PtCharged->ProjectionX("hPi0PtCharged",-1,-1);
2466         TH1F * hElePtCharged   = (TH1F*) fhElePtCharged->ProjectionX("hElePtCharged",-1,-1);
2467         TH1F * hNeHadPtCharged = (TH1F*) fhNeHadPtCharged->ProjectionX("hNeHadPtCharged",-1,-1);
2468         TH1F * hChHadPtCharged = (TH1F*) fhChHadPtCharged->ProjectionX("hChHadPtCharged",-1,-1);
2469         hPi0PtCharged->SetLineColor(1);
2470         hGamPtCharged->SetLineColor(4);
2471         hNeHadPtCharged->SetLineColor(2);
2472         hChHadPtCharged->SetLineColor(7);
2473         hElePtCharged->SetLineColor(6); 
2474         gPad->SetLogy();
2475         fhPtCharged->SetLineColor(3);
2476         fhPtCharged->SetMinimum(0.5);
2477         fhPtCharged->Draw();
2478         hPi0PtCharged->Draw("same");
2479         hGamPtCharged->Draw("same");
2480         hNeHadPtCharged->Draw("same");
2481         hChHadPtCharged->Draw("same");
2482         hElePtCharged->Draw("same");    
2483         
2484         c22ch->cd(4) ; 
2485         
2486         TH1F * hGamEtaCharged   = (TH1F*) fhGamEtaCharged->ProjectionX("hGamEtaCharged",-1,-1);
2487         TH1F * hPi0EtaCharged   = (TH1F*) fhPi0EtaCharged->ProjectionX("hPi0EtaCharged",-1,-1);
2488         TH1F * hEleEtaCharged   = (TH1F*) fhEleEtaCharged->ProjectionX("hEleEtaCharged",-1,-1);
2489         TH1F * hNeHadEtaCharged = (TH1F*) fhNeHadEtaCharged->ProjectionX("hNeHadEtaCharged",-1,-1);
2490         TH1F * hChHadEtaCharged = (TH1F*) fhChHadEtaCharged->ProjectionX("hChHadEtaCharged",-1,-1);
2491         hPi0EtaCharged->SetLineColor(1);
2492         hGamEtaCharged->SetLineColor(4);
2493         hNeHadEtaCharged->SetLineColor(2);
2494         hChHadEtaCharged->SetLineColor(7);
2495         hEleEtaCharged->SetLineColor(6);        
2496         gPad->SetLogy();
2497         fhEtaCharged->SetLineColor(3);
2498         fhEtaCharged->SetMinimum(0.5);
2499         fhEtaCharged->Draw();
2500         hPi0EtaCharged->Draw("same");
2501         hGamEtaCharged->Draw("same");
2502         hNeHadEtaCharged->Draw("same");
2503         hChHadEtaCharged->Draw("same");
2504         hEleEtaCharged->Draw("same");
2505         
2506         c22ch->cd(3) ; 
2507         
2508         TH1F * hGamPhiCharged   = (TH1F*) fhGamPhiCharged->ProjectionX("hGamPhiCharged",-1,-1);
2509         TH1F * hPi0PhiCharged   = (TH1F*) fhPi0PhiCharged->ProjectionX("hPi0PhiCharged",-1,-1);
2510         TH1F * hElePhiCharged   = (TH1F*) fhElePhiCharged->ProjectionX("hElePhiCharged",-1,-1);
2511         TH1F * hNeHadPhiCharged = (TH1F*) fhNeHadPhiCharged->ProjectionX("hNeHadPhiCharged",-1,-1);
2512         TH1F * hChHadPhiCharged = (TH1F*) fhChHadPhiCharged->ProjectionX("hChHadPhiCharged",-1,-1);
2513         hPi0PhiCharged->SetLineColor(1);
2514         hGamPhiCharged->SetLineColor(4);
2515         hNeHadPhiCharged->SetLineColor(2);
2516         hChHadPhiCharged->SetLineColor(7);
2517         hElePhiCharged->SetLineColor(6);        
2518         gPad->SetLogy();
2519         fhPhiCharged->SetLineColor(3);
2520         fhPhiCharged->SetMinimum(0.5);
2521         fhPhiCharged->Draw();
2522         hPi0PhiCharged->Draw("same");
2523         hGamPhiCharged->Draw("same");
2524         hNeHadPhiCharged->Draw("same");
2525         hChHadPhiCharged->Draw("same");
2526         hElePhiCharged->Draw("same");
2527         
2528         
2529         sprintf(name,"QA_%s_ReconstructedDistributions_TrackMatchedGenID.eps",fCalorimeter.Data());
2530         c22ch->Print(name); printf("Plot: %s\n",name);
2531         
2532         TH1F *  hGamEChargedClone   = (TH1F*)   hGamECharged->Clone("GamEChargedClone");
2533         TH1F *  hGamPtChargedClone  = (TH1F*)   hGamPtCharged->Clone("GamPtChargedClone");
2534         TH1F *  hGamEtaChargedClone = (TH1F*)   hGamEtaCharged->Clone("GamEtaChargedClone");
2535         TH1F *  hGamPhiChargedClone = (TH1F*)   hGamPhiCharged->Clone("GamPhiChargedClone");
2536         
2537         TH1F *  hPi0EChargedClone   = (TH1F*)   hPi0ECharged->Clone("Pi0EChargedClone");
2538         TH1F *  hPi0PtChargedClone  = (TH1F*)   hPi0PtCharged->Clone("Pi0PtChargedClone");
2539         TH1F *  hPi0EtaChargedClone = (TH1F*)   hPi0EtaCharged->Clone("Pi0EtaChargedClone");
2540         TH1F *  hPi0PhiChargedClone = (TH1F*)   hPi0PhiCharged->Clone("Pi0PhiChargedClone");
2541         
2542         TH1F *  hEleEChargedClone   = (TH1F*)   hEleECharged->Clone("EleEChargedClone");
2543         TH1F *  hElePtChargedClone  = (TH1F*)   hElePtCharged->Clone("ElePtChargedClone");
2544         TH1F *  hEleEtaChargedClone = (TH1F*)   hEleEtaCharged->Clone("EleEtaChargedClone");
2545         TH1F *  hElePhiChargedClone = (TH1F*)   hElePhiCharged->Clone("ElePhiChargedClone");    
2546         
2547         TH1F *  hNeHadEChargedClone   = (TH1F*)   hNeHadECharged->Clone("NeHadEChargedClone");
2548         TH1F *  hNeHadPtChargedClone  = (TH1F*)   hNeHadPtCharged->Clone("NeHadPtChargedClone");
2549         TH1F *  hNeHadEtaChargedClone = (TH1F*)   hNeHadEtaCharged->Clone("NeHadEtaChargedClone");
2550         TH1F *  hNeHadPhiChargedClone = (TH1F*)   hNeHadPhiCharged->Clone("NeHadPhiChargedClone");
2551         
2552         TH1F *  hChHadEChargedClone   = (TH1F*)   hChHadECharged->Clone("ChHadEChargedClone");
2553         TH1F *  hChHadPtChargedClone  = (TH1F*)   hChHadPtCharged->Clone("ChHadPtChargedClone");
2554         TH1F *  hChHadEtaChargedClone = (TH1F*)   hChHadEtaCharged->Clone("ChHadEtaChargedClone");
2555         TH1F *  hChHadPhiChargedClone = (TH1F*)   hChHadPhiCharged->Clone("ChHadPhiChargedClone");      
2556         
2557         //Ratio: reconstructed track matched/ all reconstructed
2558         //printf("c3\n");
2559         sprintf(cname,"QA_%s_rectrackmatchratGenID",fCalorimeter.Data());
2560         TCanvas  * c3ch = new TCanvas(cname, "Ratio: reconstructed track matched/ all reconstructed, for different particle ID", 400, 400) ;
2561         c3ch->Divide(2, 2);
2562         
2563         c3ch->cd(1) ;
2564         hEChargedClone->SetMaximum(1.2);
2565         hEChargedClone->SetMinimum(0.001);      
2566         hEChargedClone->SetLineColor(3);
2567         hEChargedClone->SetYTitle("track matched / all");
2568         hPi0EChargedClone->Divide(hPi0E);
2569         hGamEChargedClone->Divide(hGamE);
2570         hEleEChargedClone->Divide(hEleE);
2571         hNeHadEChargedClone->Divide(hNeHadE);
2572         hChHadEChargedClone->Divide(hChHadE);
2573         hEChargedClone->Draw();
2574         hPi0EChargedClone->Draw("same");
2575         hGamEChargedClone->Draw("same");
2576         hEleEChargedClone->Draw("same");
2577         hNeHadEChargedClone->Draw("same");
2578         hChHadEChargedClone->Draw("same");
2579         
2580         TLegend pLegend3ch(0.75,0.45,0.9,0.8);
2581         pLegend3ch.SetTextSize(0.06);
2582         pLegend3ch.AddEntry(hEChargedClone,"all","L");
2583         pLegend3ch.AddEntry(hPi0EChargedClone,"#pi^{0}","L");
2584         pLegend3ch.AddEntry(hGamEChargedClone,"#gamma","L");
2585         pLegend3ch.AddEntry(hEleEChargedClone,"e^{#pm}","L");
2586         pLegend3ch.AddEntry(hChHadEChargedClone,"h^{#pm}","L");
2587         pLegend3ch.AddEntry(hNeHadEChargedClone,"h^{0}","L");
2588         pLegend3ch.SetFillColor(10);
2589         pLegend3ch.SetBorderSize(1);
2590         pLegend3ch.Draw();
2591         
2592         c3ch->cd(2) ;
2593         hPtChargedClone->SetMaximum(1.2);
2594         hPtChargedClone->SetMinimum(0.001);     
2595         hPtChargedClone->SetLineColor(3);
2596         hPtChargedClone->SetYTitle("track matched / all");
2597         hPi0PtChargedClone->Divide(hPi0Pt);
2598         hGamPtChargedClone->Divide(hGamPt);
2599         hElePtChargedClone->Divide(hElePt);
2600         hNeHadPtChargedClone->Divide(hNeHadPt);
2601         hChHadPtChargedClone->Divide(hChHadPt);
2602         hPtChargedClone->Draw();
2603         hPi0PtChargedClone->Draw("same");
2604         hGamPtChargedClone->Draw("same");
2605         hElePtChargedClone->Draw("same");
2606         hNeHadPtChargedClone->Draw("same");
2607         hChHadPtChargedClone->Draw("same");
2608         
2609         c3ch->cd(4) ;
2610         hEtaChargedClone->SetMaximum(1.2);
2611         hEtaChargedClone->SetMinimum(0.001);    
2612         hEtaChargedClone->SetLineColor(3);
2613         hEtaChargedClone->SetYTitle("track matched / all");
2614         hPi0EtaChargedClone->Divide(hPi0Eta);
2615         hGamEtaChargedClone->Divide(hGamEta);
2616         hEleEtaChargedClone->Divide(hEleEta);
2617         hNeHadEtaChargedClone->Divide(hNeHadEta);
2618         hChHadEtaChargedClone->Divide(hChHadEta);
2619         hEtaChargedClone->Draw();
2620         hPi0EtaChargedClone->Draw("same");
2621         hGamEtaChargedClone->Draw("same");
2622         hEleEtaChargedClone->Draw("same");
2623         hNeHadEtaChargedClone->Draw("same");
2624         hChHadEtaChargedClone->Draw("same");
2625         
2626         c3ch->cd(3) ;
2627         hPhiChargedClone->SetMaximum(1.2);
2628         hPhiChargedClone->SetMinimum(0.001);
2629         hPhiChargedClone->SetLineColor(3);
2630         hPhiChargedClone->SetYTitle("track matched / all");
2631         hPi0PhiChargedClone->Divide(hPi0Phi);
2632         hGamPhiChargedClone->Divide(hGamPhi);
2633         hElePhiChargedClone->Divide(hElePhi);
2634         hNeHadPhiChargedClone->Divide(hNeHadPhi);
2635         hChHadPhiChargedClone->Divide(hChHadPhi);
2636         hPhiChargedClone->Draw();
2637         hPi0PhiChargedClone->Draw("same");
2638         hGamPhiChargedClone->Draw("same");
2639         hElePhiChargedClone->Draw("same");
2640         hNeHadPhiChargedClone->Draw("same");
2641         hChHadPhiChargedClone->Draw("same");
2642         
2643         sprintf(name,"QA_%s_RatioReconstructedMatchedDistributionsGenID.eps",fCalorimeter.Data());
2644         c3ch->Print(name); printf("Plot: %s\n",name);
2645         
2646         }       
2647         //Track-matching distributions
2648         if(!strcmp(GetReader()->GetInputEvent()->GetName(),"AliESDEvent")){
2649                 
2650                 
2651                 sprintf(cname,"QA_%s_trkmatch",fCalorimeter.Data());
2652                 TCanvas *cme = new TCanvas(cname,"Track-matching distributions", 400, 400);
2653                 cme->Divide(2,2);
2654                 
2655                 TLegend pLegendpE0(0.6,0.55,0.9,0.8);
2656                 pLegendpE0.SetTextSize(0.04);
2657                 pLegendpE0.AddEntry(fh1pOverE,"all","L");
2658                 pLegendpE0.AddEntry(fh1pOverER02,"dR < 0.02","L");
2659                 pLegendpE0.SetFillColor(10);
2660                 pLegendpE0.SetBorderSize(1);
2661                 //pLegendpE0.Draw();
2662                 
2663                 cme->cd(1);
2664                 if(fh1pOverE->GetEntries() > 0) gPad->SetLogy();
2665                 fh1pOverE->SetTitle("Track matches p/E");
2666                 fh1pOverE->Draw();
2667                 fh1pOverER02->SetLineColor(4);
2668                 fh1pOverER02->Draw("same");
2669                 pLegendpE0.Draw();
2670                 
2671                 cme->cd(2);
2672                 if(fh1dR->GetEntries() > 0) gPad->SetLogy();
2673                 fh1dR->Draw();
2674                 
2675                 cme->cd(3);
2676                 fh2MatchdEdx->Draw();
2677                 
2678                 cme->cd(4);
2679                 fh2EledEdx->Draw();
2680                 
2681                 sprintf(name,"QA_%s_TrackMatchingEleDist.eps",fCalorimeter.Data());
2682                 cme->Print(name); printf("Plot: %s\n",name);       
2683                 
2684                 if(IsDataMC()){
2685                 sprintf(cname,"QA_%s_trkmatchMCEle",fCalorimeter.Data());
2686                 TCanvas *cmemc = new TCanvas(cname,"Track-matching distributions from MC electrons", 600, 200);
2687                 cmemc->Divide(3,1);
2688                 
2689                 cmemc->cd(1);
2690                 gPad->SetLogy();
2691                 fhMCEle1pOverE->Draw();
2692                 fhMCEle1pOverER02->SetLineColor(4);
2693                 fhMCEle1pOverE->SetLineColor(1);
2694                 fhMCEle1pOverER02->Draw("same");
2695                 pLegendpE0.Draw();
2696                 
2697                 cmemc->cd(2);
2698                 gPad->SetLogy();
2699                 fhMCEle1dR->Draw();
2700                 
2701                 cmemc->cd(3);
2702                 fhMCEle2MatchdEdx->Draw();
2703                 
2704                 sprintf(name,"QA_%s_TrackMatchingDistMCEle.eps",fCalorimeter.Data());
2705                 cmemc->Print(name); printf("Plot: %s\n",name);  
2706         
2707                 
2708                 sprintf(cname,"QA_%s_trkmatchMCChHad",fCalorimeter.Data());
2709                 TCanvas *cmemchad = new TCanvas(cname,"Track-matching distributions from MC charged hadrons", 600, 200);
2710                 cmemchad->Divide(3,1);
2711                 
2712                 cmemchad->cd(1);
2713                 gPad->SetLogy();
2714                 fhMCChHad1pOverE->Draw();
2715                 fhMCChHad1pOverER02->SetLineColor(4);
2716                 fhMCChHad1pOverE->SetLineColor(1);
2717                 fhMCChHad1pOverER02->Draw("same");
2718                 pLegendpE0.Draw();
2719                 
2720                 cmemchad->cd(2);
2721                 gPad->SetLogy();
2722                 fhMCChHad1dR->Draw();
2723                 
2724                 cmemchad->cd(3);
2725                 fhMCChHad2MatchdEdx->Draw();
2726                 
2727                 sprintf(name,"QA_%s_TrackMatchingDistMCChHad.eps",fCalorimeter.Data());
2728                 cmemchad->Print(name); printf("Plot: %s\n",name);       
2729                 
2730                 sprintf(cname,"QA_%s_trkmatchMCNeutral",fCalorimeter.Data());
2731                 TCanvas *cmemcn = new TCanvas(cname,"Track-matching distributions from MC neutrals", 600, 200);
2732                 cmemcn->Divide(3,1);
2733                 
2734                 cmemcn->cd(1);
2735                 gPad->SetLogy();
2736                 fhMCNeutral1pOverE->Draw();
2737                 fhMCNeutral1pOverE->SetLineColor(1);
2738                 fhMCNeutral1pOverER02->SetLineColor(4);
2739                 fhMCNeutral1pOverER02->Draw("same");
2740                 pLegendpE0.Draw();
2741                 
2742                 cmemcn->cd(2);
2743                 gPad->SetLogy();
2744                 fhMCNeutral1dR->Draw();
2745                 
2746                 cmemcn->cd(3);
2747                 fhMCNeutral2MatchdEdx->Draw();
2748                 
2749                 sprintf(name,"QA_%s_TrackMatchingDistMCNeutral.eps",fCalorimeter.Data());
2750                 cmemcn->Print(name); printf("Plot: %s\n",name);       
2751                 
2752                 sprintf(cname,"QA_%s_trkmatchpE",fCalorimeter.Data());
2753                 TCanvas *cmpoe = new TCanvas(cname,"Track-matching distributions, p/E", 400, 200);
2754                 cmpoe->Divide(2,1);
2755                 
2756                 cmpoe->cd(1);
2757                 gPad->SetLogy();
2758                 fh1pOverE->SetLineColor(1);
2759                 fhMCEle1pOverE->SetLineColor(4);
2760                 fhMCChHad1pOverE->SetLineColor(2);
2761                 fhMCNeutral1pOverE->SetLineColor(7);
2762                 fh1pOverER02->SetMinimum(0.5);
2763                 fh1pOverE->Draw();
2764                 fhMCEle1pOverE->Draw("same");
2765                 fhMCChHad1pOverE->Draw("same");
2766                 fhMCNeutral1pOverE->Draw("same");
2767                 TLegend pLegendpE(0.65,0.55,0.9,0.8);
2768                 pLegendpE.SetTextSize(0.06);
2769                 pLegendpE.AddEntry(fh1pOverE,"all","L");
2770                 pLegendpE.AddEntry(fhMCEle1pOverE,"e^{#pm}","L");
2771                 pLegendpE.AddEntry(fhMCChHad1pOverE,"h^{#pm}","L");
2772                 pLegendpE.AddEntry(fhMCNeutral1pOverE,"neutrals","L");
2773                 pLegendpE.SetFillColor(10);
2774                 pLegendpE.SetBorderSize(1);
2775                 pLegendpE.Draw();
2776                 
2777                 cmpoe->cd(2);
2778                 gPad->SetLogy();
2779                 fh1pOverER02->SetTitle("Track matches p/E, dR<0.2");
2780                 fh1pOverER02->SetLineColor(1);
2781                 fhMCEle1pOverER02->SetLineColor(4);
2782                 fhMCChHad1pOverER02->SetLineColor(2);
2783                 fhMCNeutral1pOverER02->SetLineColor(7);
2784                 fh1pOverER02->SetMaximum(fh1pOverE->GetMaximum());
2785                 fh1pOverER02->SetMinimum(0.5);
2786                 fh1pOverER02->Draw();
2787                 fhMCEle1pOverER02->Draw("same");
2788                 fhMCChHad1pOverER02->Draw("same");
2789                 fhMCNeutral1pOverER02->Draw("same");
2790                 
2791                 //              TLegend pLegendpE2(0.65,0.55,0.9,0.8);
2792                 //              pLegendpE2.SetTextSize(0.06);
2793                 //              pLegendpE2.SetHeader("dR < 0.02");
2794                 //              pLegendpE2.SetFillColor(10);
2795                 //              pLegendpE2.SetBorderSize(1);
2796                 //              pLegendpE2.Draw();
2797                 
2798                 sprintf(name,"QA_%s_TrackMatchingPOverE.eps",fCalorimeter.Data());
2799                 cmpoe->Print(name); printf("Plot: %s\n",name);                          
2800                 }
2801                 
2802         }
2803         
2804         char line[1024] ; 
2805         sprintf(line, ".!tar -zcf QA_%s_%s.tar.gz *%s*.eps", fCalorimeter.Data(), GetName(),fCalorimeter.Data()) ; 
2806         gROOT->ProcessLine(line);
2807         sprintf(line, ".!rm -fR *.eps"); 
2808         gROOT->ProcessLine(line);
2809         
2810         printf("AliAnaCalorimeterQA::Terminate() - !! All the eps files are in QA_%s_%s.tar.gz !!!\n",  fCalorimeter.Data(), GetName());
2811         
2812 }