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