New Calorimeter Calibration directory, now only PHOS
[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("QAHistos") ; 
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()) { 
864                 stack =  GetMCStack() ;
865                 if(!stack) {
866                         printf("Stack not available, have you switched on the MC data?\n");
867                         return;
868                 }
869         }
870         
871         //Get List with clusters  
872         TRefArray * partList = new TRefArray();
873         if(fCalorimeter == "EMCAL") partList = GetAODEMCAL();
874         else if(fCalorimeter == "PHOS") partList = GetAODPHOS();
875         else {
876                 printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Wrong calorimeter name <%s>, END\n", fCalorimeter.Data());
877                 abort();
878         }
879         
880         if(!partList || partList->GetEntriesFast() == 0) return ;
881         
882         Int_t nclusters = partList->GetEntriesFast() ; 
883         fhNClusters->Fill(nclusters);
884         
885         if(GetDebug() > 0)
886                 printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - In %s there are %d clusters \n", fCalorimeter.Data(), nclusters);
887         
888         //Get vertex for photon momentum calculation
889         Double_t v[3] ; //vertex ;
890         GetReader()->GetVertex(v);
891
892         for(Int_t iclus = 0; iclus < partList->GetEntriesFast(); iclus++){
893                 //printf(" cluster %d\n",iclus);
894                 AliAODCaloCluster * calo =  (AliAODCaloCluster*) (partList->At(iclus));
895                 //if(calo->GetNCells() <= 2) continue;
896                 //Get cluster kinematics
897                 calo->GetMomentum(mom,v);
898                 Float_t e   = mom.E();
899                 //if(e < 0.5) continue;
900                 //printf("e %2.2f, n %f\n",e, calo->GetNCells());
901                 Float_t pt  = mom.Pt();
902                 Float_t eta = mom.Eta();
903                 Float_t phi = mom.Phi();
904                 if(phi < 0) phi +=TMath::TwoPi();
905                 
906                 fhE     ->Fill(e);              
907                 fhPt    ->Fill(pt);
908                 fhPhi   ->Fill(phi);
909                 fhEta   ->Fill(eta);
910                 fhEtaPhi->Fill(eta,phi);
911                 
912                 //matched cluster with tracks
913                 Int_t ntracksmatched = calo->GetNTracksMatched();
914
915                 //Fill histograms only possible when simulation
916                 if(IsDataMC()){
917                 //Play with the MC stack if available
918                     Int_t label = calo->GetLabel(0);
919                         
920                 if(label < 0 || !stack) {
921                                 printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() *** bad label or no stack ***:  label %d \n", label);
922                                 continue;
923                 }
924                 
925                 if(label >=  stack->GetNtrack()) {
926                                 printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() *** large label ***:  label %d, n tracks %d \n", label, stack->GetNtrack());
927                                 continue ;
928                 }
929                         
930                 //cout<<"LABEL  "<<label<<endl;
931                 primary = GetMCStack()->Particle(label);
932
933                     Int_t pdg = primary->GetPdgCode();
934                     Float_t vx = primary->Vx();
935                     Float_t vy = primary->Vy();
936                     //Float_t vz = primary->Vz();
937                     Float_t r = TMath::Sqrt(vx*vx + vy*vy);
938                     if((pdg == 22 || TMath::Abs(pdg)==11) && primary->GetStatusCode()!=1) {
939                                 fhEMVxyz   ->Fill(vx,vy);//,vz);
940                                 fhEMR      ->Fill(e,r);
941                     }
942                     
943                     //printf("reco e %f, pt %f, phi %f, eta %f \n", e, pt, phi, eta);
944                     //printf("prim e %f, pt %f, phi %f, eta %f \n", primary->Energy(),primary->Pt() ,primary->Phi() ,primary->Eta() );
945                     //printf("vertex: vx %f, vy %f, vz %f, r %f \n", vx, vy, vz, r);
946                     
947                     //Get final particle, no conversion products
948                     Int_t status =  primary->GetStatusCode();
949                     Int_t mother= primary->GetFirstMother();
950                     if(status == 0){
951                                 while(mother >= 0){
952                                         primary = GetMCStack()->Particle(mother);
953                                         status = primary->GetStatusCode();
954                                         mother= primary->GetFirstMother();
955                                         if(status == 1) break;             
956                                         //printf("mother %d\n",mother);
957                                 }       
958                     }
959                     
960                         fh2E      ->Fill(e, primary->Energy());
961                         fh2Pt     ->Fill(pt, primary->Pt());
962                         fh2Phi    ->Fill(phi, primary->Phi());
963                         fh2Eta    ->Fill(eta, primary->Eta());
964                         fhDeltaE  ->Fill(primary->Energy()-e);
965                         fhDeltaPt ->Fill(primary->Pt()-pt);
966                         fhDeltaPhi->Fill(primary->Phi()-phi);
967                         fhDeltaEta->Fill(primary->Eta()-eta);
968                         if(primary->Energy() > 0) fhRatioE  ->Fill(e/primary->Energy());
969                     if(primary->Pt()     > 0) fhRatioPt ->Fill(pt/primary->Pt());
970                     if(primary->Phi()    > 0) fhRatioPhi->Fill(phi/primary->Phi());
971                     if(primary->Eta()    > 0) fhRatioEta->Fill(eta/primary->Eta());                     
972                         
973                     //cout<<"Final Label "<<finallabel<<" mother "<<mother<<endl;
974                     pdg = primary->GetPdgCode();
975                     Double_t  charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
976                         
977                     if(pdg == 22){
978                                 //cout<<"pdg "<<pdg<<" status "<<status<<" "<<primary->GetStatusCode()<<endl;   
979                                 TParticle *pi0 = 0x0;
980                                 TParticle *p1 = 0x0;
981                                 TParticle *p2 = 0x0;
982                                 TParticle * tmp = 0x0;
983                                 Int_t pdgpi0 = 0;
984                                 Int_t mothertmp = 0;
985                                 //Check if it is a decay photon from pi0, in this case, check if both decay contribute cluster
986                                 Bool_t ok1 = kFALSE;
987                                 Bool_t ok2 = kFALSE;
988                                 
989                                 if(calo->GetNLabel() > 1){
990                                         if(pdg !=111){
991                                                 while(mother >= 0){
992                                                         pi0 = GetMCStack()->Particle(mother);
993                                                         pdgpi0 = pi0->GetPdgCode();
994                                                         if(pdgpi0 == 111) {
995                                                           //cout<<"pi0!!!"<<endl;
996                                                           break;
997                                                         }
998                                                         mother= pi0->GetFirstMother();
999                                                         //printf("mother %d\n",mother);
1000                                                 }
1001                                         }
1002                                         else   pi0 = primary;
1003                                 
1004                                         if(!pi0 || mother < 0 ) continue ;
1005                                         cout<<"pi0 pointer "<<pi0<<" pdg "<<pdgpi0<<" "<<pi0->GetPdgCode()<<endl;
1006                                         cout<<"MOTHER PI0 LABEL "<<mother<<" pt" << pi0->Pt()<<" status "<<pi0->GetStatusCode()<<endl;
1007                                         if(pi0->GetNDaughters() == 2){
1008                                           cout<<"pi0, 2 daughters "<<endl;
1009                                                 Int_t id1 = pi0->GetFirstDaughter();
1010                                                 Int_t id2 = pi0->GetFirstDaughter()+1;
1011                                                 p1=GetMCStack()->Particle(id1);
1012                                                 p2=GetMCStack()->Particle(id2);
1013                                                 
1014                                                 if(p1->GetFirstMother()!=p2->GetFirstMother()) cout <<"Decay photon mothers are not the same!!"<<endl;
1015                                                 if(p1->GetPdgCode()==22 && p2->GetPdgCode()==22){
1016                                                         // cout<<"2 photons, labels "<< id1<<" "<<id2<<endl;
1017                                                         for(UInt_t ilabel = 0; ilabel < calo->GetNLabel(); ilabel++){
1018                                                                 Int_t iprim = calo->GetLabel(ilabel);
1019                                                                 //cout<<"iprim "<<iprim<<endl;
1020                                                                 if (iprim == id1) ok1 = kTRUE;
1021                                                                 else if (iprim == id2) ok2 = kTRUE;
1022                                                                 mothertmp = iprim;
1023                                                                 while(mothertmp >= 0){
1024                                                                         tmp = GetMCStack()->Particle(mothertmp);                                    
1025                                                                         mothertmp= tmp->GetFirstMother();
1026                                                                         //      cout<<"mothertmp "<<mothertmp<<" "<<tmp->GetName()<< " pt "<<tmp->Pt()<<endl;
1027                                                                         if (mothertmp == id1) ok1 = kTRUE;
1028                                                                         else if (mothertmp == id2) ok2 = kTRUE;
1029                                                                         if(ok1 && ok2) break;
1030                                                                         //printf("mother %d\n",mother);
1031                                                                 }
1032                                                         } 
1033                                                 }//2 photon daughters
1034                                         }////mother pi0, 2 daughers
1035                                 }//more than one contribution to clust
1036                                 
1037                                 if(ok1 && ok2){
1038                                         //cout<<"Fill pi0"<< "E  "<< e <<" prim E "<<primary->Energy()<<endl;
1039                                         fhPi0E     ->Fill(e,primary->Energy()); 
1040                                         fhPi0Pt    ->Fill(pt,primary->Pt());
1041                                         fhPi0Eta   ->Fill(eta,primary->Eta());  
1042                                         fhPi0Phi   ->Fill(phi,primary->Phi());
1043                                         if( ntracksmatched > 0){
1044                                                 fhPi0ECharged     ->Fill(e,primary->Energy());          
1045                                                 fhPi0PtCharged    ->Fill(pt,primary->Pt());
1046                                                 fhPi0PhiCharged   ->Fill(phi,primary->Phi());
1047                                                 fhPi0EtaCharged   ->Fill(eta,primary->Eta());
1048                                         }
1049                                 }
1050                                 else{
1051                                         fhGamE     ->Fill(e,primary->Energy()); 
1052                                         fhGamPt    ->Fill(pt,primary->Pt());
1053                                         fhGamEta   ->Fill(eta,primary->Eta());  
1054                                         fhGamPhi   ->Fill(phi,primary->Phi());
1055                                         fhGamDeltaE  ->Fill(primary->Energy()-e);
1056                                         fhGamDeltaPt ->Fill(primary->Pt()-pt);  
1057                                         fhGamDeltaPhi->Fill(primary->Phi()-phi);
1058                                         fhGamDeltaEta->Fill(primary->Eta()-eta);
1059                                         if(primary->Energy() > 0) fhGamRatioE  ->Fill(e/primary->Energy());
1060                                         if(primary->Pt()     > 0) fhGamRatioPt ->Fill(pt/primary->Pt());
1061                                         if(primary->Phi()    > 0) fhGamRatioPhi->Fill(phi/primary->Phi());
1062                                         if(primary->Eta()    > 0) fhGamRatioEta->Fill(eta/primary->Eta());
1063                                         if( ntracksmatched > 0){
1064                                                 fhGamECharged     ->Fill(e,primary->Energy());          
1065                                                 fhGamPtCharged    ->Fill(pt,primary->Pt());
1066                                                 fhGamPhiCharged   ->Fill(phi,primary->Phi());
1067                                                 fhGamEtaCharged   ->Fill(eta,primary->Eta());
1068                                         }
1069                                 }
1070                     }//pdg == 22
1071                     else if(TMath::Abs(pdg) == 11) {
1072                                 fhEleE     ->Fill(e,primary->Energy()); 
1073                                 fhElePt    ->Fill(pt,primary->Pt());
1074                                 fhEleEta   ->Fill(eta,primary->Eta());  
1075                                 fhElePhi   ->Fill(phi,primary->Phi());
1076                                 fhEMVxyz   ->Fill(vx,vy);//,vz);
1077                                 fhEMR      ->Fill(e,r);
1078                                 if( ntracksmatched > 0){
1079                                         fhEleECharged     ->Fill(e,primary->Energy());          
1080                                         fhElePtCharged    ->Fill(pt,primary->Pt());
1081                                         fhElePhiCharged   ->Fill(phi,primary->Phi());
1082                                         fhEleEtaCharged   ->Fill(eta,primary->Eta());
1083                                 }
1084                     }
1085                     else if(pdg == 111) {
1086                                 fhPi0E     ->Fill(e,primary->Energy()); 
1087                                 fhPi0Pt    ->Fill(pt,primary->Pt());
1088                                 fhPi0Eta   ->Fill(eta,primary->Eta());  
1089                                 fhPi0Phi   ->Fill(phi,primary->Phi());
1090                                 if( ntracksmatched > 0){
1091                                         fhPi0ECharged     ->Fill(e,primary->Energy());          
1092                                         fhPi0PtCharged    ->Fill(pt,primary->Pt());
1093                                         fhPi0PhiCharged   ->Fill(phi,primary->Phi());
1094                                         fhPi0EtaCharged   ->Fill(eta,primary->Eta());
1095                                 }
1096                     }
1097                     else if(charge == 0){
1098                                 fhNeHadE     ->Fill(e,primary->Energy());       
1099                                 fhNeHadPt    ->Fill(pt,primary->Pt());
1100                                 fhNeHadEta   ->Fill(eta,primary->Eta());        
1101                                 fhNeHadPhi   ->Fill(phi,primary->Phi());        
1102                                 fhHaVxyz     ->Fill(vx,vy);//,vz);
1103                                 fhHaR        ->Fill(e,r);
1104                                 if( ntracksmatched > 0){
1105                                         fhNeHadECharged     ->Fill(e,primary->Energy());                
1106                                         fhNeHadPtCharged    ->Fill(pt,primary->Pt());
1107                                         fhNeHadPhiCharged   ->Fill(phi,primary->Phi());
1108                                         fhNeHadEtaCharged   ->Fill(eta,primary->Eta());
1109                                 }
1110                     }
1111                     else if(charge!=0){
1112                                 fhChHadE     ->Fill(e,primary->Energy());       
1113                                 fhChHadPt    ->Fill(pt,primary->Pt());
1114                                 fhChHadEta   ->Fill(eta,primary->Eta());        
1115                                 fhChHadPhi   ->Fill(phi,primary->Phi());        
1116                                 fhHaVxyz     ->Fill(vx,vy);//,vz);
1117                                 fhHaR        ->Fill(e,r);
1118                                 if( ntracksmatched > 0){
1119                                         fhChHadECharged     ->Fill(e,primary->Energy());                
1120                                         fhChHadPtCharged    ->Fill(pt,primary->Pt());
1121                                         fhChHadPhiCharged   ->Fill(phi,primary->Phi());
1122                                         fhChHadEtaCharged   ->Fill(eta,primary->Eta());
1123                                 }
1124                     }
1125                 }//Work with stack also
1126                 
1127                 //matched cluster with tracks
1128                 if( ntracksmatched > 0){
1129                         fhECharged     ->Fill(e);               
1130                         fhPtCharged    ->Fill(pt);
1131                         fhPhiCharged   ->Fill(phi);
1132                         fhEtaCharged   ->Fill(eta);
1133                         fhEtaPhiCharged->Fill(eta,phi);                         
1134                         if((!strcmp(GetReader()->GetInputEvent()->GetName(),"AliESDEvent"))) {
1135                                 AliESDEvent *esd = (AliESDEvent*) GetReader()->GetInputEvent();
1136                                 AliESDCaloCluster * esdcalo = (AliESDCaloCluster*) esd->GetCaloCluster(calo->GetID());
1137                                 Int_t trackIndex = esdcalo->GetTrackMatched();
1138                                 //printf("track index %d ntracks %d\n", trackIndex, esd->GetNumberOfTracks());
1139                                 if(trackIndex >= 0){
1140                                         AliESDtrack* track = (AliESDtrack*) esd->GetTrack(trackIndex);
1141                                         if (track && track->GetOuterParam() ) {
1142
1143                                                 Double_t tphi = track->GetOuterParam()->Phi();
1144                                                 Double_t teta = track->GetOuterParam()->Eta();
1145                                                 Double_t tmom = track->GetOuterParam()->P();
1146
1147                                                 Double_t deta = teta - eta;
1148                                                 Double_t dphi = tphi - phi;
1149                                                 if(dphi > TMath::Pi()) dphi -= 2*TMath::Pi();
1150                                                 if(dphi < -TMath::Pi()) dphi += 2*TMath::Pi();
1151                                                 Double_t dR = sqrt(dphi*dphi + deta*deta);
1152                                                 
1153                                                 Double_t pOverE = tmom/e;
1154                                                 
1155                                                 fh1pOverE->Fill(pOverE);
1156                                                 if(dR < 0.02) fh1pOverER02->Fill(pOverE);
1157                                                 
1158                                                 fh1dR->Fill(dR);
1159                                                 fh2MatchdEdx->Fill(track->P(),track->GetTPCsignal());
1160                                         
1161                                                 if(IsDataMC() && primary){ 
1162                                                          Int_t pdg = primary->GetPdgCode();
1163                                                          Double_t  charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
1164                                                         
1165                                                         if(TMath::Abs(pdg) == 11){
1166                                                                 fhMCEle1pOverE->Fill(pOverE);
1167                                                                 fhMCEle1dR->Fill(dR);
1168                                                                 fhMCEle2MatchdEdx->Fill(track->P(),track->GetTPCsignal());              
1169                                                                 if(dR < 0.02) fhMCEle1pOverER02->Fill(pOverE);
1170                                                         }
1171                                                         else if(charge!=0){
1172                                                                 fhMCChHad1pOverE->Fill(pOverE);
1173                                                                 fhMCChHad1dR->Fill(dR);
1174                                                                 fhMCChHad2MatchdEdx->Fill(track->P(),track->GetTPCsignal());    
1175                                                                 if(dR < 0.02) fhMCChHad1pOverER02->Fill(pOverE);
1176                                                         }
1177                                                         else if(charge == 0){
1178                                                                 fhMCNeutral1pOverE->Fill(pOverE);
1179                                                                 fhMCNeutral1dR->Fill(dR);
1180                                                                 fhMCNeutral2MatchdEdx->Fill(track->P(),track->GetTPCsignal());  
1181                                                                 if(dR < 0.02) fhMCNeutral1pOverER02->Fill(pOverE);
1182                                                         }
1183                                                 }
1184                                                 int nITS = track->GetNcls(0);
1185                                                 int nTPC = track->GetNcls(1);
1186                                                 if(dR < 0.02 && pOverE > 0.5 && pOverE < 1.5
1187                                                    && calo->GetNCells() > 1 && nITS > 3 && nTPC > 20) {
1188                                                         fh2EledEdx->Fill(track->P(),track->GetTPCsignal());
1189                                                 }
1190                                         } 
1191                                         else if(!track->GetOuterParam()){
1192                                                 ULong_t status=AliESDtrack::kTPCrefit;
1193                                                 status|=AliESDtrack::kITSrefit;
1194                                                 //printf("track status %d\n", track->GetStatus() );
1195                                                 fhEChargedNoOut     ->Fill(e);          
1196                                                 fhPtChargedNoOut     ->Fill(pt);
1197                                                 fhPhiChargedNoOut    ->Fill(phi);
1198                                                 fhEtaChargedNoOut    ->Fill(eta);
1199                                                 fhEtaPhiChargedNoOut ->Fill(eta,phi);   
1200                                                 if ( (track->GetStatus() & status) == status) printf("ITS+TPC\n");
1201                                         }
1202                                         else {
1203                                                 printf("ERROR: Could not receive track %d\n", trackIndex);
1204                                         }
1205                                 }// non negative track index
1206                         }//do only if input are ESDs
1207                 }// at least one track matched          
1208                 
1209                 //Invariant mass
1210                 if (nclusters > 1 ) {
1211                         for(Int_t jclus = iclus + 1 ; jclus < nclusters ; jclus++) {
1212                                 AliAODCaloCluster * calo2 =  (AliAODCaloCluster*) (partList->At(jclus));
1213                                 //Get cluster kinematics
1214                                 calo2->GetMomentum(mom2,v);
1215                                 fhIM  ->Fill((mom+mom2).E(),(mom+mom2).M());
1216                                 fhAsym->Fill((mom+mom2).E(),TMath::Abs((e-mom2.E())/(e+mom2.E())));
1217                         }// 2nd cluster loop
1218                 }////more than 1 cluster in calorimeter    
1219                 
1220                 //Cells per cluster
1221                 fhNCellsPerCluster->Fill(e,calo->GetNCells());
1222                 
1223         }// 1st cluster loop
1224         
1225         //CaloCells
1226         AliAODCaloCells * cell = new AliAODCaloCells ;
1227         if(fCalorimeter == "PHOS") 
1228                 cell = (AliAODCaloCells *) GetPHOSCells();
1229         else  
1230                 cell = (AliAODCaloCells *) GetEMCALCells();     
1231         
1232         if(!cell) {
1233                 printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - ABORT: No CELLS available for analysis");
1234                 abort();
1235         }
1236         
1237         //Some prints
1238         if(GetDebug() > 0 && cell )
1239                 printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - In ESD %s cell entries %d\n", fCalorimeter.Data(), cell->GetNumberOfCells());    
1240         
1241         Int_t ncells = cell->GetNumberOfCells() ;
1242         fhNCells->Fill(ncells) ;
1243         
1244         for (Int_t iCell = 0; iCell < ncells; iCell++) {      
1245                 if(GetDebug() > 10)  printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Cell : amp %f, absId %d \n", cell->GetAmplitude(iCell), cell->GetCellNumber(iCell));
1246                 fhAmplitude->Fill(cell->GetAmplitude(iCell));
1247         }
1248         
1249         if(GetDebug() > 0) 
1250                 printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - end \n");  
1251         
1252         //Monte Carlo
1253         if(IsDataMC()){
1254                 //Play with the MC stack if available
1255                 for(Int_t i=8 ; i<stack->GetNprimary(); i++){
1256                         primary = stack->Particle(i) ;
1257                         
1258                         //if (!primary->IsPrimary()) continue;
1259                         if (TMath::Abs(primary->Eta()) > 1) continue;
1260                         
1261                         Int_t kf = primary->GetPdgCode();
1262                         //printf("kf %d\n",kf);
1263                         
1264                         Bool_t in = kTRUE;
1265                         primary->Momentum(mom);
1266                         if(IsFidutialCutOn()) in =  GetFidutialCut()->IsInFidutialCut(mom,fCalorimeter) ;
1267                         
1268                         if (kf==22) {
1269                                 fhGenGamPt ->Fill(primary->Pt());
1270                                 fhGenGamEta->Fill(primary->Eta());
1271                                 fhGenGamPhi->Fill(primary->Phi());
1272                                 if(in){
1273                                         fhGenGamAccE  ->Fill(primary->Energy());
1274                                         fhGenGamAccPt ->Fill(primary->Pt());
1275                                         fhGenGamAccEta->Fill(primary->Eta());
1276                                         fhGenGamAccPhi->Fill(primary->Phi());                                   
1277                                 }
1278                         }
1279                         else if (kf==111) {
1280                                 fhGenPi0Pt ->Fill(primary->Pt());
1281                                 fhGenPi0Eta->Fill(primary->Eta());
1282                                 fhGenPi0Phi->Fill(primary->Phi());
1283                                 if(in){
1284                                         fhGenPi0AccE  ->Fill(primary->Energy());                                        
1285                                         fhGenPi0AccPt ->Fill(primary->Pt());
1286                                         fhGenPi0AccEta->Fill(primary->Eta());
1287                                         fhGenPi0AccPhi->Fill(primary->Phi());                                   
1288                                 }
1289                         }
1290                         else if (kf==221) {
1291                                 fhGenEtaPt ->Fill(primary->Pt());
1292                                 fhGenEtaEta->Fill(primary->Eta());
1293                                 fhGenEtaPhi->Fill(primary->Phi());
1294                         }
1295                         else if (kf==223) {
1296                                 fhGenOmegaPt ->Fill(primary->Pt());
1297                                 fhGenOmegaEta->Fill(primary->Eta());
1298                                 fhGenOmegaPhi->Fill(primary->Phi());
1299                         }
1300                         else if (TMath::Abs(kf)==11) {
1301                                 fhGenElePt ->Fill(primary->Pt());
1302                                 fhGenEleEta->Fill(primary->Eta());
1303                                 fhGenElePhi->Fill(primary->Phi());
1304                         }
1305                 } //primary loop
1306         } //Is data MC
1307         
1308         if(GetDebug() > 0)
1309                 printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - End \n");
1310         
1311         
1312 }
1313
1314 //________________________________________________________________________
1315 void AliAnaCalorimeterQA::ReadHistograms(TList* outputList)
1316 {
1317         // Needed when Terminate is executed in distributed environment
1318         // Refill analysis histograms of this class with corresponding histograms in output list. 
1319         
1320         // Histograms of this analsys are kept in the same list as other analysis, recover the position of
1321         // the first one and then add the next 
1322         Int_t index = outputList->IndexOf(outputList->FindObject(GetAddedHistogramsStringToName()+"hE"));
1323         //printf("Calo: %s, index: %d\n",fCalorimeter.Data(),index);
1324         //Read histograms, must be in the same order as in GetCreateOutputObject.
1325         fhE      = (TH1F *) outputList->At(index++);    
1326         fhPt     = (TH1F *) outputList->At(index++); 
1327         fhPhi    = (TH1F *) outputList->At(index++); 
1328         fhEta    = (TH1F *) outputList->At(index++);
1329         fhEtaPhi = (TH2F *) outputList->At(index++);
1330         
1331         fhECharged      = (TH1F *) outputList->At(index++);     
1332         fhPtCharged     = (TH1F *) outputList->At(index++); 
1333         fhPhiCharged    = (TH1F *) outputList->At(index++); 
1334         fhEtaCharged    = (TH1F *) outputList->At(index++);
1335         fhEtaPhiCharged = (TH2F *) outputList->At(index++);
1336         
1337         fhEChargedNoOut      = (TH1F *) outputList->At(index++);        
1338         fhPtChargedNoOut     = (TH1F *) outputList->At(index++); 
1339         fhPhiChargedNoOut    = (TH1F *) outputList->At(index++); 
1340         fhEtaChargedNoOut    = (TH1F *) outputList->At(index++);
1341         fhEtaPhiChargedNoOut = (TH2F *) outputList->At(index++);
1342
1343         fhIM     = (TH2F *) outputList->At(index++);
1344         fhAsym   = (TH2F *) outputList->At(index++);
1345         
1346         fhNCellsPerCluster = (TH2F *) outputList->At(index++);
1347         fhNClusters  = (TH1F *) outputList->At(index++); 
1348         fhNCells     = (TH1F *) outputList->At(index++); 
1349         fhAmplitude  = (TH1F *) outputList->At(index++); 
1350         
1351         if(IsDataMC()){
1352                 fhDeltaE   = (TH1F *) outputList->At(index++); 
1353                 fhDeltaPt  = (TH1F *) outputList->At(index++); 
1354                 fhDeltaPhi = (TH1F *) outputList->At(index++); 
1355                 fhDeltaEta = (TH1F *) outputList->At(index++); 
1356                 
1357                 fhRatioE   = (TH1F *) outputList->At(index++); 
1358                 fhRatioPt  = (TH1F *) outputList->At(index++); 
1359                 fhRatioPhi = (TH1F *) outputList->At(index++); 
1360                 fhRatioEta = (TH1F *) outputList->At(index++); 
1361                 
1362                 fh2E       = (TH2F *) outputList->At(index++); 
1363                 fh2Pt      = (TH2F *) outputList->At(index++); 
1364                 fh2Phi     = (TH2F *) outputList->At(index++); 
1365                 fh2Eta     = (TH2F *) outputList->At(index++); 
1366                 
1367                 fhGamE     = (TH2F *) outputList->At(index++); 
1368                 fhGamPt    = (TH2F *) outputList->At(index++); 
1369                 fhGamPhi   = (TH2F *) outputList->At(index++); 
1370                 fhGamEta   = (TH2F *) outputList->At(index++); 
1371                 
1372                 fhGamDeltaE   = (TH1F *) outputList->At(index++); 
1373                 fhGamDeltaPt  = (TH1F *) outputList->At(index++); 
1374                 fhGamDeltaPhi = (TH1F *) outputList->At(index++); 
1375                 fhGamDeltaEta = (TH1F *) outputList->At(index++); 
1376                 
1377                 fhGamRatioE   = (TH1F *) outputList->At(index++); 
1378                 fhGamRatioPt  = (TH1F *) outputList->At(index++); 
1379                 fhGamRatioPhi = (TH1F *) outputList->At(index++); 
1380                 fhGamRatioEta = (TH1F *) outputList->At(index++); 
1381
1382                 fhPi0E     = (TH2F *) outputList->At(index++); 
1383                 fhPi0Pt    = (TH2F *) outputList->At(index++); 
1384                 fhPi0Phi   = (TH2F *) outputList->At(index++); 
1385                 fhPi0Eta   = (TH2F *) outputList->At(index++);          
1386                 
1387                 fhEleE     = (TH2F *) outputList->At(index++); 
1388                 fhElePt    = (TH2F *) outputList->At(index++); 
1389                 fhElePhi   = (TH2F *) outputList->At(index++); 
1390                 fhEleEta   = (TH2F *) outputList->At(index++);          
1391                 
1392                 fhNeHadE     = (TH2F *) outputList->At(index++); 
1393                 fhNeHadPt    = (TH2F *) outputList->At(index++); 
1394                 fhNeHadPhi   = (TH2F *) outputList->At(index++); 
1395                 fhNeHadEta   = (TH2F *) outputList->At(index++);                
1396                 
1397                 fhChHadE     = (TH2F *) outputList->At(index++); 
1398                 fhChHadPt    = (TH2F *) outputList->At(index++); 
1399                 fhChHadPhi   = (TH2F *) outputList->At(index++); 
1400                 fhChHadEta   = (TH2F *) outputList->At(index++);                                
1401                 
1402                 fhGamECharged     = (TH2F *) outputList->At(index++); 
1403                 fhGamPtCharged    = (TH2F *) outputList->At(index++); 
1404                 fhGamPhiCharged   = (TH2F *) outputList->At(index++); 
1405                 fhGamEtaCharged   = (TH2F *) outputList->At(index++); 
1406                                 
1407                 fhPi0ECharged     = (TH2F *) outputList->At(index++); 
1408                 fhPi0PtCharged    = (TH2F *) outputList->At(index++); 
1409                 fhPi0PhiCharged   = (TH2F *) outputList->At(index++); 
1410                 fhPi0EtaCharged   = (TH2F *) outputList->At(index++);           
1411                 
1412                 fhEleECharged     = (TH2F *) outputList->At(index++); 
1413                 fhElePtCharged    = (TH2F *) outputList->At(index++); 
1414                 fhElePhiCharged   = (TH2F *) outputList->At(index++); 
1415                 fhEleEtaCharged   = (TH2F *) outputList->At(index++);           
1416                 
1417                 fhNeHadECharged     = (TH2F *) outputList->At(index++); 
1418                 fhNeHadPtCharged    = (TH2F *) outputList->At(index++); 
1419                 fhNeHadPhiCharged   = (TH2F *) outputList->At(index++); 
1420                 fhNeHadEtaCharged   = (TH2F *) outputList->At(index++);                 
1421                 
1422                 fhChHadECharged     = (TH2F *) outputList->At(index++); 
1423                 fhChHadPtCharged    = (TH2F *) outputList->At(index++); 
1424                 fhChHadPhiCharged   = (TH2F *) outputList->At(index++); 
1425                 fhChHadEtaCharged   = (TH2F *) outputList->At(index++);                                 
1426                 
1427 //              fhEMVxyz     = (TH3F *) outputList->At(index++); 
1428 //              fhHaVxyz     = (TH3F *) outputList->At(index++); 
1429                 
1430                 fhEMVxyz     = (TH2F *) outputList->At(index++); 
1431                 fhHaVxyz     = (TH2F *) outputList->At(index++); 
1432                 fhEMR        = (TH2F *) outputList->At(index++); 
1433                 fhHaR        = (TH2F *) outputList->At(index++); 
1434                 
1435                 fhGenGamPt    = (TH1F *) outputList->At(index++); 
1436                 fhGenGamEta   = (TH1F *) outputList->At(index++); 
1437                 fhGenGamPhi   = (TH1F *) outputList->At(index++); 
1438                 
1439                 fhGenPi0Pt    = (TH1F *) outputList->At(index++); 
1440                 fhGenPi0Eta   = (TH1F *) outputList->At(index++); 
1441                 fhGenPi0Phi   = (TH1F *) outputList->At(index++); 
1442                 
1443                 fhGenEtaPt    = (TH1F *) outputList->At(index++); 
1444                 fhGenEtaEta   = (TH1F *) outputList->At(index++); 
1445                 fhGenEtaPhi   = (TH1F *) outputList->At(index++); 
1446                 
1447                 fhGenOmegaPt  = (TH1F *) outputList->At(index++); 
1448                 fhGenOmegaEta = (TH1F *) outputList->At(index++); 
1449                 fhGenOmegaPhi = (TH1F *) outputList->At(index++); 
1450                 
1451                 fhGenElePt    = (TH1F *) outputList->At(index++); 
1452                 fhGenEleEta   = (TH1F *) outputList->At(index++); 
1453                 fhGenElePhi   = (TH1F *) outputList->At(index++); 
1454                 
1455                 fhGenGamAccE   = (TH1F *) outputList->At(index++);              
1456                 fhGenGamAccPt  = (TH1F *) outputList->At(index++); 
1457                 fhGenGamAccEta = (TH1F *) outputList->At(index++); 
1458                 fhGenGamAccPhi = (TH1F *) outputList->At(index++); 
1459                 
1460                 fhGenPi0AccE   = (TH1F *) outputList->At(index++);              
1461                 fhGenPi0AccPt  = (TH1F *) outputList->At(index++); 
1462                 fhGenPi0AccEta = (TH1F *) outputList->At(index++); 
1463                 fhGenPi0AccPhi = (TH1F *) outputList->At(index++); 
1464                 
1465         }//Is data MC   
1466         
1467         fh1pOverE =    (TH1F *) outputList->At(index++);
1468         fh1dR =        (TH1F *) outputList->At(index++);
1469         fh2MatchdEdx = (TH2F *) outputList->At(index++);
1470         fh2EledEdx =   (TH2F *) outputList->At(index++);
1471         
1472         if(IsDataMC()){
1473                 fhMCEle1pOverE =    (TH1F *) outputList->At(index++);
1474                 fhMCEle1dR =        (TH1F *) outputList->At(index++);
1475                 fhMCEle2MatchdEdx = (TH2F *) outputList->At(index++);
1476                 
1477                 fhMCChHad1pOverE =    (TH1F *) outputList->At(index++);
1478                 fhMCChHad1dR =        (TH1F *) outputList->At(index++);
1479                 fhMCChHad2MatchdEdx = (TH2F *) outputList->At(index++);
1480                 
1481                 fhMCNeutral1pOverE    = (TH1F *) outputList->At(index++);
1482                 fhMCNeutral1dR        = (TH1F *) outputList->At(index++);
1483                 fhMCNeutral2MatchdEdx = (TH2F *) outputList->At(index++);
1484                 
1485                 fh1pOverER02          =    (TH1F *) outputList->At(index++);
1486                 fhMCEle1pOverER02     =    (TH1F *) outputList->At(index++);
1487                 fhMCChHad1pOverER02   =    (TH1F *) outputList->At(index++);
1488                 fhMCNeutral1pOverER02 =    (TH1F *) outputList->At(index++);
1489         }
1490         //for(Int_t i = 0;  i<index ; i++) cout<<outputList->At(i)->GetName()<<endl;
1491 }
1492
1493 //__________________________________________________________________
1494 void  AliAnaCalorimeterQA::Terminate(TList* outputList) 
1495 {
1496         
1497         //Do some plots to end
1498          if(fStyleMacro!="")gROOT->Macro(fStyleMacro); 
1499         //Recover histograms from output histograms list, needed for distributed analysis.      
1500         ReadHistograms(outputList);
1501         
1502         //printf(" AliAnaCalorimeterQA::Terminate()  *** %s Report:", GetName()) ; 
1503         //printf(" AliAnaCalorimeterQA::Terminate()        pt         : %5.3f , RMS : %5.3f \n", fhPt->GetMean(),   fhPt->GetRMS() ) ;
1504
1505         char name[128];
1506         char cname[128];
1507                 
1508         //Reconstructed distributions
1509         //printf("c1\n");
1510         sprintf(cname,"QA_%s_rec",fCalorimeter.Data());
1511         TCanvas  * c = new TCanvas(cname, "Reconstructed distributions", 400, 400) ;
1512         c->Divide(2, 2);
1513         
1514         c->cd(1) ; 
1515         gPad->SetLogy();
1516         fhE->SetLineColor(4);
1517         fhE->Draw();
1518         
1519         c->cd(2) ; 
1520         gPad->SetLogy();
1521         fhPt->SetLineColor(4);
1522         fhPt->Draw();
1523         
1524         c->cd(3) ; 
1525         fhPhi->SetLineColor(4);
1526         fhPhi->Draw();
1527         
1528         c->cd(4) ; 
1529         fhEta->SetLineColor(4);
1530         fhEta->Draw();
1531         
1532         sprintf(name,"QA_%s_ReconstructedDistributions.eps",fCalorimeter.Data());
1533         c->Print(name);
1534         
1535         //Reconstructed distributions, matched with tracks
1536         //printf("c2\n");
1537         sprintf(cname,"QA_%s_rectrackmatch",fCalorimeter.Data());
1538         TCanvas  * c2 = new TCanvas(cname, "Reconstructed distributions, matched with tracks", 400, 400) ;
1539         c2->Divide(2, 2);
1540         
1541         c2->cd(1) ; 
1542         gPad->SetLogy();
1543         fhECharged->SetLineColor(4);
1544         fhECharged->Draw();
1545         
1546         c2->cd(2) ; 
1547         gPad->SetLogy();
1548         fhPtCharged->SetLineColor(4);
1549         fhPtCharged->Draw();
1550         
1551         c2->cd(3) ; 
1552         fhPhiCharged->SetLineColor(4);
1553         fhPhiCharged->Draw();
1554         
1555         c2->cd(4) ; 
1556         fhEtaCharged->SetLineColor(4);
1557         fhEtaCharged->Draw();
1558         
1559         sprintf(name,"QA_%s_ReconstructedDistributions_TrackMatched.eps",fCalorimeter.Data());
1560         c2->Print(name);
1561         
1562         TH1F *  hEChargedClone   = (TH1F*)   fhECharged->Clone("EChargedClone");
1563         TH1F *  hPtChargedClone  = (TH1F*)   fhPtCharged->Clone("PtChargedClone");
1564         TH1F *  hEtaChargedClone = (TH1F*)   fhEtaCharged->Clone("EtaChargedClone");
1565         TH1F *  hPhiChargedClone = (TH1F*)   fhPhiCharged->Clone("PhiChargedClone");
1566         
1567         TH1F *  hEChargedClone2   = (TH1F*)   fhECharged->Clone("EChargedClone2");
1568         TH1F *  hPtChargedClone2  = (TH1F*)   fhPtCharged->Clone("PtChargedClone2");
1569         TH1F *  hEtaChargedClone2 = (TH1F*)   fhEtaCharged->Clone("EtaChargedClone2");
1570         TH1F *  hPhiChargedClone2 = (TH1F*)   fhPhiCharged->Clone("PhiChargedClone2");
1571         
1572         //Ratio: reconstructed track matched/ all reconstructed
1573         //printf("c3\n");
1574         sprintf(cname,"QA_%s_rectrackmatchrat",fCalorimeter.Data());
1575         TCanvas  * c3 = new TCanvas(cname, "Ratio: reconstructed track matched/ all reconstructed", 400, 400) ;
1576         c3->Divide(2, 2);
1577         
1578         c3->cd(1) ;
1579         gPad->SetLogy();
1580         hEChargedClone->SetTitleOffset(1.6,"Y");
1581     hEChargedClone->SetYTitle("track matched / all   ");
1582         hEChargedClone->SetXTitle("E (GeV)");
1583         hEChargedClone->Divide(fhE);
1584         hEChargedClone->Draw();
1585         
1586         c3->cd(2) ; 
1587         gPad->SetLogy();
1588         hPtChargedClone->SetTitleOffset(1.6,"Y");
1589         hPtChargedClone->SetYTitle("track matched / all   ");
1590     hPtChargedClone->SetXTitle("p_{T} (GeV/c)");
1591         hPtChargedClone->Divide(fhPt);
1592         hPtChargedClone->Draw();
1593         
1594         c3->cd(3) ;
1595         gPad->SetLogy();
1596         hPhiChargedClone->SetTitleOffset(1.6,"Y");
1597         hPhiChargedClone->SetYTitle("track matched / all   ");
1598         hPhiChargedClone->SetXTitle("#phi (rad)");
1599         hPhiChargedClone->Divide(fhPhi);
1600         hPhiChargedClone->Draw();
1601         
1602         c3->cd(4) ; 
1603         gPad->SetLogy();
1604         hEtaChargedClone->SetTitleOffset(1.6,"Y");
1605         hEtaChargedClone->SetYTitle("track matched / all   ");
1606         hEtaChargedClone->SetXTitle("#eta");
1607     hEtaChargedClone->Divide(fhEta);
1608         hEtaChargedClone->Draw();
1609         
1610         sprintf(name,"QA_%s_RatioReconstructedMatchedDistributions.eps",fCalorimeter.Data());
1611         c3->Print(name);
1612         
1613         //Ratio: reconstructed track matched (minus no track param) / all
1614         //printf("c3\n");
1615         sprintf(cname,"QA_%s_rectrackmatchratout",fCalorimeter.Data());
1616         TCanvas  * c333 = new TCanvas(cname, "Ratio: reconstructed track matched (with outer track param)/ all", 400, 400) ;
1617         c333->Divide(2, 2);
1618         
1619         c333->cd(1) ;
1620         hEChargedClone2->Add(fhEChargedNoOut,-1);
1621         hEChargedClone2->SetYTitle("track matched / all");
1622         hEChargedClone2->SetXTitle("E (GeV)");
1623         hEChargedClone2->Divide(fhE);
1624         hEChargedClone2->Draw();
1625         
1626         c333->cd(2) ; 
1627         hPtChargedClone2->Add(fhPtChargedNoOut,-1);
1628         hPtChargedClone2->SetYTitle("track matched / all");
1629         hPtChargedClone2->SetXTitle("p_{T} (GeV/c)");
1630         hPtChargedClone2->Divide(fhPt);
1631         hPtChargedClone2->Draw();
1632         
1633         c333->cd(3) ;
1634         hPhiChargedClone2->Add(fhPhiChargedNoOut,-1);
1635         hPhiChargedClone2->SetYTitle("track matched / all");
1636         hPhiChargedClone2->SetXTitle("#phi (rad)");
1637         hPhiChargedClone2->Divide(fhPhi);
1638         hPhiChargedClone2->Draw();
1639         
1640         c333->cd(4) ; 
1641         hEtaChargedClone2->Add(fhEtaChargedNoOut,-1);
1642         hEtaChargedClone2->SetYTitle("track matched / all");
1643         hEtaChargedClone2->SetXTitle("#eta");
1644         hEtaChargedClone2->Divide(fhEta);
1645         hEtaChargedClone2->Draw();
1646         
1647         sprintf(name,"QA_%s_RatioReconstructedMatchedDistributionsOuter.eps",fCalorimeter.Data());
1648         c333->Print(name);
1649         
1650         //Reconstructed distributions, matched with tracks but no outer param
1651         //printf("c2\n");
1652         sprintf(cname,"QA_%s_rectrackmatch_noout",fCalorimeter.Data());
1653         TCanvas  * c22 = new TCanvas(cname, "Reconstructed distributions, matched with tracks, no outer track param", 400, 400) ;
1654         c22->Divide(2, 2);
1655         
1656         c22->cd(1) ; 
1657         gPad->SetLogy();
1658         fhEChargedNoOut->SetLineColor(4);
1659         fhEChargedNoOut->Draw();
1660         
1661         c22->cd(2) ; 
1662         gPad->SetLogy();
1663         fhPtChargedNoOut->SetLineColor(4);
1664         fhPtChargedNoOut->Draw();
1665         
1666         c22->cd(3) ; 
1667         fhPhiChargedNoOut->SetLineColor(4);
1668         fhPhiChargedNoOut->Draw();
1669         
1670         c22->cd(4) ; 
1671         fhEtaChargedNoOut->SetLineColor(4);
1672         fhEtaChargedNoOut->Draw();
1673         
1674         sprintf(name,"QA_%s_ReconstructedDistributions_TrackMatched_NoOutParam.eps",fCalorimeter.Data());
1675         c22->Print(name);
1676         
1677         //Ratio: reconstructed track matched/ all reconstructed
1678         //printf("c3\n");
1679         
1680 //      TH1F *  hEChargedNoOutClone   = (TH1F*)   fhEChargedNoOut->Clone("EChargedNoOutClone");
1681 //      TH1F *  hPtChargedNoOutClone  = (TH1F*)   fhPtChargedNoOut->Clone("PtChargedNoOutClone");
1682 //      TH1F *  hEtaChargedNoOutClone = (TH1F*)   fhEtaChargedNoOut->Clone("EtaChargedNoOutClone");
1683 //      TH1F *  hPhiChargedNoOutClone = (TH1F*)   fhPhiChargedNoOut->Clone("PhiChargedNoOutClone");     
1684         
1685 //      sprintf(cname,"QA_%s_rectrackmatchratnoout",fCalorimeter.Data());
1686 //      TCanvas  * c33 = new TCanvas(cname, "Ratio: reconstructed track matched/ all reconstructed", 400, 400) ;
1687 //      c33->Divide(2, 2);
1688 //      
1689 //      c33->cd(1) ;
1690 //      hEChargedNoOutClone->SetYTitle("track matched no out/ all matched");
1691 //      hEChargedNoOutClone->SetXTitle("E (GeV)");
1692 //      hEChargedNoOutClone->Divide(fhECharged);
1693 //      hEChargedNoOutClone->Draw();
1694 //      
1695 //      c33->cd(2) ; 
1696 //      hPtChargedNoOutClone->SetYTitle("track matched no out / all matched");
1697 //      hPtChargedNoOutClone->SetXTitle("p_{T} (GeV/c)");
1698 //      hPtChargedNoOutClone->Divide(fhPtCharged);
1699 //      hPtChargedNoOutClone->Draw();
1700 //      
1701 //      c33->cd(3) ;
1702 //      hPhiChargedNoOutClone->SetYTitle("track matched no out/ all matched");
1703 //      hPhiChargedNoOutClone->SetXTitle("#phi (rad)");
1704 //      hPhiChargedNoOutClone->Divide(fhPhiCharged);
1705 //      hPhiChargedNoOutClone->Draw();
1706 //      
1707 //      c33->cd(4) ; 
1708 //      hEtaChargedNoOutClone->SetYTitle("track matched no out/ all matched");
1709 //      hEtaChargedNoOutClone->SetXTitle("#eta");
1710 //      hEtaChargedNoOutClone->Divide(fhEtaCharged);
1711 //      hEtaChargedNoOutClone->Draw();
1712 //      
1713 //      sprintf(name,"QA_%s_RatioMatchedDistributionsAllToNoOut.eps",fCalorimeter.Data());
1714 //      c33->Print(name);
1715         
1716         
1717         //eta vs phi
1718         //printf("c4\n");
1719         sprintf(cname,"QA_%s_etavsphi",fCalorimeter.Data());
1720         //      TCanvas  * c4 = new TCanvas(cname, "reconstructed #eta vs #phi", 600, 200) ;
1721         //      c4->Divide(3, 1);
1722         
1723         TCanvas  * c4 = new TCanvas(cname, "reconstructed #eta vs #phi", 400, 200) ;
1724         c4->Divide(2, 1);
1725         
1726         c4->cd(1) ;
1727         fhEtaPhi->Draw("cont");
1728         
1729         c4->cd(2) ; 
1730         fhEtaPhiCharged->Draw("cont");
1731         
1732         //      c4->cd(3) ; 
1733         //      fhEtaPhiChargedNoOut->Draw("cont");
1734         
1735         sprintf(name,"QA_%s_ReconstructedEtaVsPhi.eps",fCalorimeter.Data());
1736         c4->Print(name);
1737         
1738         //Invariant mass
1739         Int_t binmin = -1;
1740         Int_t binmax = -1;
1741         
1742         if(fhIM->GetEntries() > 1){
1743                 Int_t nebins  = fhIM->GetNbinsX();
1744                 Int_t emax = (Int_t) fhIM->GetXaxis()->GetXmax();
1745                 Int_t emin = (Int_t) fhIM->GetXaxis()->GetXmin();
1746                 if (emin != 0 ) printf("emin != 0 \n");
1747                 //printf("IM: nBinsX %d, emin %2.2f, emax %2.2f\n",nebins,emin,emax);
1748                 
1749                 sprintf(cname,"QA_%s_IM",fCalorimeter.Data());
1750                 //      printf("c5\n");
1751                 TCanvas  * c5 = new TCanvas(cname, "Invariant mass", 400, 400) ;
1752                 c5->Divide(2, 2);
1753                 
1754                 c5->cd(1) ; 
1755                 fhIM->SetLineColor(4);
1756                 fhIM->Draw();
1757                 
1758                 c5->cd(2) ; 
1759                 binmin = 0;
1760                 binmax =  (Int_t) (5-emin)*nebins/emax;
1761                 TH1D *pyim5 = fhIM->ProjectionY("pyim5",binmin,binmax);
1762                 pyim5->SetTitle("E_{pair} < 5 GeV");
1763                 pyim5->SetLineColor(4);
1764                 pyim5->Draw();
1765                 
1766                 c5->cd(3) ; 
1767                 binmin =  (Int_t) (5-emin)*nebins/emax;
1768                 binmax =  (Int_t) (10-emin)*nebins/emax;
1769                 TH1D *pyim510 = fhIM->ProjectionY("pyim5_10",binmin,binmax);
1770                 pyim510->SetTitle("5 < E_{pair} < 10 GeV");
1771                 pyim510->SetLineColor(4);
1772                 pyim510->Draw();
1773                 
1774                 c5->cd(4) ;
1775                 binmin =  (Int_t) (10-emin)*nebins/emax;
1776                 binmax = -1;
1777                 TH1D *pyim10 = fhIM->ProjectionY("pyim10",binmin,binmax);
1778                 pyim10->SetTitle("E_{pair} > 10 GeV");
1779                 pyim10->SetLineColor(4);
1780                 pyim10->Draw();
1781                 
1782                 sprintf(name,"QA_%s_InvariantMass.eps",fCalorimeter.Data());
1783                 c5->Print(name);
1784         }
1785         
1786         //Asymmetry
1787         if(fhAsym->GetEntries() > 1){
1788                 Int_t nebins  = fhAsym->GetNbinsX();
1789                 Int_t emax = (Int_t) fhAsym->GetXaxis()->GetXmax();
1790                 Int_t emin = (Int_t) fhAsym->GetXaxis()->GetXmin();
1791                 if (emin != 0 ) printf("emin != 0 \n");
1792                 //printf("Asym: nBinsX %d, emin %2.2f, emax %2.2f\n",nebins,emin,emax);
1793                 
1794                 sprintf(cname,"QA_%s_Asym",fCalorimeter.Data());
1795                 //      printf("c5\n");
1796                 TCanvas  * c5b = new TCanvas(cname, "Asymmetry", 400, 400) ;
1797                 c5b->Divide(2, 2);
1798                 
1799                 c5b->cd(1) ; 
1800                 fhAsym->SetTitleOffset(1.6,"Y");
1801                 fhAsym->SetLineColor(4);
1802                 fhAsym->Draw();
1803                 
1804                 c5b->cd(2) ; 
1805                 binmin = 0;
1806                 binmax = (Int_t) (5-emin)*nebins/emax;
1807                 TH1D *pyAsym5 = fhAsym->ProjectionY("pyAsym5",binmin,binmax);
1808                 pyAsym5->SetTitle("E_{pair} < 5 GeV");
1809                 pyAsym5->SetLineColor(4);
1810                 pyAsym5->Draw();
1811                 
1812                 c5b->cd(3) ; 
1813                 binmin = (Int_t) (5-emin)*nebins/emax;
1814                 binmax = (Int_t) (10-emin)*nebins/emax;
1815                 TH1D *pyAsym510 = fhAsym->ProjectionY("pyAsym5_10",binmin,binmax);
1816                 pyAsym510->SetTitle("5 < E_{pair} < 10 GeV");
1817                 pyAsym510->SetLineColor(4);
1818                 pyAsym510->Draw();
1819                 
1820                 c5b->cd(4) ;
1821                 binmin = (Int_t) (10-emin)*nebins/emax;
1822                 binmax = -1;
1823                 TH1D *pyAsym10 = fhAsym->ProjectionY("pyAsym10",binmin,binmax);
1824                 pyAsym10->SetTitle("E_{pair} > 10 GeV");
1825                 pyAsym10->SetLineColor(4);
1826                 pyAsym10->Draw();
1827                 
1828                 sprintf(name,"QA_%s_Asymmetry.eps",fCalorimeter.Data());
1829                 c5b->Print(name);
1830         }
1831         
1832         
1833         //Reconstructed vs MC distributions
1834         //printf("c6\n");
1835         sprintf(cname,"QA_%s_recvsmc",fCalorimeter.Data());
1836         TCanvas  * c6 = new TCanvas(cname, "Reconstructed vs MC distributions", 400, 400) ;
1837         c6->Divide(2, 2);
1838         
1839         c6->cd(1) ; 
1840         fh2E->SetTitleOffset(1.6,"Y");
1841         fh2E->SetLineColor(4);
1842         fh2E->Draw();
1843         
1844         c6->cd(2) ; 
1845         fh2Pt->SetTitleOffset(1.6,"Y");
1846         fh2Pt->SetLineColor(4);
1847         fh2Pt->Draw();
1848         
1849         c6->cd(3) ; 
1850         fh2Phi->SetTitleOffset(1.6,"Y");
1851         fh2Phi->SetLineColor(4);
1852         fh2Phi->Draw();
1853         
1854         c6->cd(4) ; 
1855         fh2Eta->SetTitleOffset(1.6,"Y");
1856         fh2Eta->SetLineColor(4);
1857         fh2Eta->Draw();
1858         
1859         sprintf(name,"QA_%s_ReconstructedVSMCDistributions.eps",fCalorimeter.Data());
1860         c6->Print(name);        
1861         
1862         //Reconstructed vs MC distributions
1863         //printf("c6\n");
1864         sprintf(cname,"QA_%s_gamrecvsmc",fCalorimeter.Data());
1865         TCanvas  * c6Gam = new TCanvas(cname, "Reconstructed vs MC distributions", 400, 400) ;
1866         c6Gam->Divide(2, 2);
1867         
1868         c6Gam->cd(1) ; 
1869         fhGamE->Draw();
1870         
1871         c6Gam->cd(2) ; 
1872         fhGamPt->Draw();
1873         
1874         c6Gam->cd(3) ; 
1875         fhGamPhi->Draw();
1876         
1877         c6Gam->cd(4) ; 
1878         fhGamEta->Draw();
1879         
1880         sprintf(name,"QA_%s_GammaReconstructedVSMCDistributions.eps",fCalorimeter.Data());
1881         c6->Print(name);        
1882         
1883         //Generated - reconstructed  
1884         //printf("c7\n");
1885         sprintf(cname,"QA_%s_diffgenrec",fCalorimeter.Data());
1886         TCanvas  * c7 = new TCanvas(cname, "generated - reconstructed", 400, 400) ;
1887         c7->Divide(2, 2);
1888         
1889         c7->cd(1) ; 
1890         gPad->SetLogy();
1891         fhGamDeltaE->SetLineColor(4);
1892         fhDeltaE->Draw();
1893         fhGamDeltaE->Draw("same");
1894         
1895         TLegend pLegendd(0.65,0.55,0.9,0.8);
1896         pLegendd.SetTextSize(0.06);
1897         pLegendd.AddEntry(fhDeltaE,"all","L");
1898         pLegendd.AddEntry(fhGamDeltaE,"from  #gamma","L");
1899         pLegendd.SetFillColor(10);
1900         pLegendd.SetBorderSize(1);
1901         pLegendd.Draw();
1902         
1903         c7->cd(2) ; 
1904         gPad->SetLogy();
1905         fhGamDeltaPt->SetLineColor(4);
1906         fhDeltaPt->Draw();
1907         fhGamDeltaPt->Draw("same");
1908         
1909         c7->cd(3) ; 
1910         fhGamDeltaPhi->SetLineColor(4);
1911         fhDeltaPhi->Draw();
1912         fhGamDeltaPhi->Draw("same");
1913         
1914         c7->cd(4) ; 
1915         fhGamDeltaEta->SetLineColor(4);
1916         fhDeltaEta->Draw();
1917         fhGamDeltaEta->Draw("same");
1918         
1919         sprintf(name,"QA_%s_DiffGeneratedReconstructed.eps",fCalorimeter.Data());
1920         c7->Print(name);
1921         
1922         // Reconstructed / Generated 
1923         //printf("c8\n");
1924         sprintf(cname,"QA_%s_ratiorecgen",fCalorimeter.Data());
1925         TCanvas  * c8 = new TCanvas(cname, " reconstructed / generated", 400, 400) ;
1926         c8->Divide(2, 2);
1927         
1928         c8->cd(1) ; 
1929         gPad->SetLogy();
1930         fhGamRatioE->SetLineColor(4);
1931         fhRatioE->Draw();
1932         fhGamRatioE->Draw("same");
1933         
1934         TLegend pLegendr(0.65,0.55,0.9,0.8);
1935         pLegendr.SetTextSize(0.06);
1936         pLegendr.AddEntry(fhRatioE,"all","L");
1937         pLegendr.AddEntry(fhGamRatioE,"from  #gamma","L");
1938         pLegendr.SetFillColor(10);
1939         pLegendr.SetBorderSize(1);
1940         pLegendr.Draw();
1941         
1942         c8->cd(2) ; 
1943         gPad->SetLogy();
1944         fhGamRatioPt->SetLineColor(4);
1945         fhRatioPt->Draw();
1946         fhGamRatioPt->Draw("same");
1947         
1948         c8->cd(3) ; 
1949         fhGamRatioPhi->SetLineColor(4);
1950         fhRatioPhi->Draw();
1951         fhGamRatioPhi->Draw("same");
1952         
1953         c8->cd(4) ; 
1954         fhGamRatioEta->SetLineColor(4);
1955         fhRatioEta->Draw();
1956         fhGamRatioEta->Draw("same");
1957         
1958         sprintf(name,"QA_%s_ReconstructedDivGenerated.eps",fCalorimeter.Data());
1959         c8->Print(name);
1960         
1961         
1962         // CaloClusters CaloCells
1963         //printf("c9\n");
1964         sprintf(cname,"QA_%s_nclustercellsamp",fCalorimeter.Data());
1965         TCanvas  * c9 = new TCanvas(cname, " CaloClusters and CaloCells", 400, 400) ;
1966         c9->Divide(2, 2);
1967         
1968         c9->cd(1) ; 
1969         gPad->SetLogy();
1970         gPad->SetLogx();
1971         fhNClusters->SetLineColor(4);
1972         fhNClusters->Draw();
1973         
1974         c9->cd(2) ; 
1975         gPad->SetLogy();
1976         gPad->SetLogx();
1977         fhNCells->SetLineColor(4);
1978         fhNCells->Draw();
1979         
1980         c9->cd(3) ; 
1981         gPad->SetLogy();
1982         gPad->SetLogx();
1983         fhNCellsPerCluster->SetLineColor(4);
1984         fhNCellsPerCluster->Draw();
1985         
1986         c9->cd(4) ; 
1987         gPad->SetLogy();
1988         //gPad->SetLogx();
1989         fhAmplitude->SetLineColor(4);
1990         fhAmplitude->Draw();
1991         
1992         sprintf(name,"QA_%s_CaloClustersAndCaloCells.eps",fCalorimeter.Data());
1993         c9->Print(name);
1994         
1995         
1996         //MC
1997         
1998         //Generated distributions
1999         //printf("c1\n");
2000         sprintf(cname,"QA_%s_gen",fCalorimeter.Data());
2001         TCanvas  * c10 = new TCanvas(cname, "Generated distributions", 600, 200) ;
2002         c10->Divide(3, 1);
2003         
2004         c10->cd(1) ; 
2005         gPad->SetLogy();
2006         TH1F * haxispt  = (TH1F*) fhGenPi0Pt->Clone("axispt");  
2007         haxispt->SetTitle("Generated Particles p_{T}, |#eta| < 1");
2008         fhGenPi0Pt->SetLineColor(1);
2009         fhGenGamPt->SetLineColor(4);
2010         fhGenEtaPt->SetLineColor(2);
2011         fhGenOmegaPt->SetLineColor(7);
2012         fhGenElePt->SetLineColor(6);
2013         
2014         //Select the maximum of the histogram to show all lines.
2015         if(fhGenPi0Pt->GetMaximum() >= fhGenGamPt->GetMaximum() && fhGenPi0Pt->GetMaximum() >= fhGenEtaPt->GetMaximum() && 
2016            fhGenPi0Pt->GetMaximum() >= fhGenOmegaPt->GetMaximum() && fhGenPi0Pt->GetMaximum() >= fhGenElePt->GetMaximum())
2017                 haxispt->SetMaximum(fhGenPi0Pt->GetMaximum());
2018         else if(fhGenGamPt->GetMaximum() >= fhGenPi0Pt->GetMaximum() && fhGenGamPt->GetMaximum() >= fhGenEtaPt->GetMaximum() && 
2019                         fhGenGamPt->GetMaximum() >= fhGenOmegaPt->GetMaximum() && fhGenGamPt->GetMaximum() >= fhGenElePt->GetMaximum())
2020                 haxispt->SetMaximum(fhGenGamPt->GetMaximum());
2021         else if(fhGenEtaPt->GetMaximum() >= fhGenPi0Pt->GetMaximum() && fhGenEtaPt->GetMaximum() >= fhGenGamPt->GetMaximum() && 
2022                         fhGenEtaPt->GetMaximum() >= fhGenOmegaPt->GetMaximum() && fhGenEtaPt->GetMaximum() >= fhGenElePt->GetMaximum())
2023                 haxispt->SetMaximum(fhGenEtaPt->GetMaximum());  
2024         else if(fhGenOmegaPt->GetMaximum() >= fhGenPi0Pt->GetMaximum() && fhGenOmegaPt->GetMaximum() >= fhGenEtaPt->GetMaximum() && 
2025                         fhGenOmegaPt->GetMaximum() >= fhGenGamPt->GetMaximum() && fhGenOmegaPt->GetMaximum() >= fhGenElePt->GetMaximum())
2026                 haxispt->SetMaximum(fhGenOmegaPt->GetMaximum());
2027         else if(fhGenElePt->GetMaximum() >= fhGenPi0Pt->GetMaximum() && fhGenElePt->GetMaximum() >= fhGenEtaPt->GetMaximum() && 
2028                         fhGenElePt->GetMaximum() >= fhGenOmegaPt->GetMaximum() && fhGenElePt->GetMaximum() >= fhGenGamPt->GetMaximum())
2029                 haxispt->SetMaximum(fhGenElePt->GetMaximum());
2030         haxispt->SetMinimum(1);
2031         haxispt->Draw("axis");
2032         fhGenPi0Pt->Draw("same");
2033         fhGenGamPt->Draw("same");
2034         fhGenEtaPt->Draw("same");
2035         fhGenOmegaPt->Draw("same");
2036         fhGenElePt->Draw("same");
2037         
2038         TLegend pLegend(0.85,0.65,0.95,0.93);
2039         pLegend.SetTextSize(0.06);
2040         pLegend.AddEntry(fhGenPi0Pt,"  #pi^{0}","L");
2041         pLegend.AddEntry(fhGenGamPt,"  #gamma","L");
2042         pLegend.AddEntry(fhGenEtaPt,"  #eta","L");
2043         pLegend.AddEntry(fhGenOmegaPt,"  #omega","L");
2044         pLegend.AddEntry(fhGenElePt,"  e^{#pm}","L");
2045         pLegend.SetFillColor(10);
2046         pLegend.SetBorderSize(1);
2047         pLegend.Draw();
2048         
2049         c10->cd(2) ;
2050         gPad->SetLogy();
2051         TH1F * haxiseta  = (TH1F*) fhGenPi0Eta->Clone("axiseta");  
2052         haxiseta->SetTitle("Generated Particles #eta, |#eta| < 1");
2053         fhGenPi0Eta->SetLineColor(1);
2054         fhGenGamEta->SetLineColor(4);
2055         fhGenEtaEta->SetLineColor(2);
2056         fhGenOmegaEta->SetLineColor(7);
2057         fhGenEleEta->SetLineColor(6);
2058         //Select the maximum of the histogram to show all lines.
2059         if(fhGenPi0Eta->GetMaximum() >= fhGenGamEta->GetMaximum() && fhGenPi0Eta->GetMaximum() >= fhGenEtaEta->GetMaximum() && 
2060            fhGenPi0Eta->GetMaximum() >= fhGenOmegaEta->GetMaximum() && fhGenPi0Eta->GetMaximum() >= fhGenEleEta->GetMaximum())
2061                 haxiseta->SetMaximum(fhGenPi0Eta->GetMaximum());
2062         else if(fhGenGamEta->GetMaximum() >= fhGenPi0Eta->GetMaximum() && fhGenGamEta->GetMaximum() >= fhGenEtaEta->GetMaximum() && 
2063                         fhGenGamEta->GetMaximum() >= fhGenOmegaEta->GetMaximum() && fhGenGamEta->GetMaximum() >= fhGenEleEta->GetMaximum())
2064                 haxiseta->SetMaximum(fhGenGamEta->GetMaximum());
2065         else if(fhGenEtaEta->GetMaximum() >= fhGenPi0Eta->GetMaximum() && fhGenEtaEta->GetMaximum() >= fhGenGamEta->GetMaximum() && 
2066                         fhGenEtaEta->GetMaximum() >= fhGenOmegaEta->GetMaximum() && fhGenEtaEta->GetMaximum() >= fhGenEleEta->GetMaximum())
2067                 haxiseta->SetMaximum(fhGenEtaEta->GetMaximum());        
2068         else if(fhGenOmegaEta->GetMaximum() >= fhGenPi0Eta->GetMaximum() && fhGenOmegaEta->GetMaximum() >= fhGenEtaEta->GetMaximum() && 
2069                         fhGenOmegaEta->GetMaximum() >= fhGenGamEta->GetMaximum() && fhGenOmegaEta->GetMaximum() >= fhGenEleEta->GetMaximum())
2070                 haxiseta->SetMaximum(fhGenOmegaEta->GetMaximum());
2071         else if(fhGenEleEta->GetMaximum() >= fhGenPi0Eta->GetMaximum() && fhGenEleEta->GetMaximum() >= fhGenEtaEta->GetMaximum() && 
2072                         fhGenEleEta->GetMaximum() >= fhGenOmegaEta->GetMaximum() && fhGenEleEta->GetMaximum() >= fhGenGamEta->GetMaximum())
2073                 haxiseta->SetMaximum(fhGenEleEta->GetMaximum());
2074         haxiseta->SetMinimum(100);
2075         haxiseta->Draw("axis");
2076         fhGenPi0Eta->Draw("same");
2077         fhGenGamEta->Draw("same");
2078         fhGenEtaEta->Draw("same");
2079         fhGenOmegaEta->Draw("same");
2080         fhGenEleEta->Draw("same");
2081         
2082         
2083         c10->cd(3) ; 
2084         gPad->SetLogy();
2085         TH1F * haxisphi  = (TH1F*) fhGenPi0Phi->Clone("axisphi");  
2086         haxisphi->SetTitle("Generated Particles #phi, |#eta| < 1");
2087         fhGenPi0Phi->SetLineColor(1);
2088         fhGenGamPhi->SetLineColor(4);
2089         fhGenEtaPhi->SetLineColor(2);
2090         fhGenOmegaPhi->SetLineColor(7);
2091         fhGenElePhi->SetLineColor(6);
2092         //Select the maximum of the histogram to show all lines.
2093         if(fhGenPi0Phi->GetMaximum() >= fhGenGamPhi->GetMaximum() && fhGenPi0Phi->GetMaximum() >= fhGenEtaPhi->GetMaximum() && 
2094            fhGenPi0Phi->GetMaximum() >= fhGenOmegaPhi->GetMaximum() && fhGenPi0Phi->GetMaximum() >= fhGenElePhi->GetMaximum())
2095                 haxisphi->SetMaximum(fhGenPi0Phi->GetMaximum());
2096         else if(fhGenGamPhi->GetMaximum() >= fhGenPi0Phi->GetMaximum() && fhGenGamPhi->GetMaximum() >= fhGenEtaPhi->GetMaximum() && 
2097                         fhGenGamPhi->GetMaximum() >= fhGenOmegaPhi->GetMaximum() && fhGenGamPhi->GetMaximum() >= fhGenElePhi->GetMaximum())
2098                 haxisphi->SetMaximum(fhGenGamPhi->GetMaximum());
2099         else if(fhGenEtaPhi->GetMaximum() >= fhGenPi0Phi->GetMaximum() && fhGenEtaPhi->GetMaximum() >= fhGenGamPhi->GetMaximum() && 
2100                         fhGenEtaPhi->GetMaximum() >= fhGenOmegaPhi->GetMaximum() && fhGenEtaPhi->GetMaximum() >= fhGenElePhi->GetMaximum())
2101                 haxisphi->SetMaximum(fhGenEtaPhi->GetMaximum());        
2102         else if(fhGenOmegaPhi->GetMaximum() >= fhGenPi0Phi->GetMaximum() && fhGenOmegaPhi->GetMaximum() >= fhGenEtaPhi->GetMaximum() && 
2103                         fhGenOmegaPhi->GetMaximum() >= fhGenGamPhi->GetMaximum() && fhGenOmegaPhi->GetMaximum() >= fhGenElePhi->GetMaximum())
2104                 haxisphi->SetMaximum(fhGenOmegaPhi->GetMaximum());
2105         else if(fhGenElePhi->GetMaximum() >= fhGenPi0Phi->GetMaximum() && fhGenElePhi->GetMaximum() >= fhGenEtaPhi->GetMaximum() && 
2106                         fhGenElePhi->GetMaximum() >= fhGenOmegaPhi->GetMaximum() && fhGenElePhi->GetMaximum() >= fhGenGamPhi->GetMaximum())
2107                 haxisphi->SetMaximum(fhGenElePhi->GetMaximum());
2108         haxisphi->SetMinimum(100);
2109         haxisphi->Draw("axis");
2110         fhGenPi0Phi->Draw("same");
2111         fhGenGamPhi->Draw("same");
2112         fhGenEtaPhi->Draw("same");
2113         fhGenOmegaPhi->Draw("same");
2114         fhGenElePhi->Draw("same");
2115         
2116         sprintf(name,"QA_%s_GeneratedDistributions.eps",fCalorimeter.Data());
2117         c10->Print(name);
2118         
2119         
2120         //Reconstructed clusters depending on its original particle.
2121         //printf("c1\n");
2122         sprintf(cname,"QA_%s_recgenid",fCalorimeter.Data());
2123         TCanvas  * c11 = new TCanvas(cname, "Reconstructed particles, function of their original particle ID", 400, 400) ;
2124         c11->Divide(2, 2);
2125         
2126         
2127         c11->cd(1) ; 
2128         gPad->SetLogy();
2129         TH1F * hGamE   = (TH1F*) fhGamE->ProjectionX("hGamE",-1,-1);
2130         TH1F * hPi0E   = (TH1F*) fhPi0E->ProjectionX("hPi0E",-1,-1);
2131         TH1F * hEleE   = (TH1F*) fhEleE->ProjectionX("hEleE",-1,-1);
2132         TH1F * hNeHadE = (TH1F*) fhNeHadE->ProjectionX("hNeHadE",-1,-1);
2133         TH1F * hChHadE = (TH1F*) fhChHadE->ProjectionX("hChHadE",-1,-1);
2134         TH1F * haxisE  = (TH1F*) hPi0E->Clone("axisE");  
2135         haxisE->SetTitle("Reconstructed particles E, function of their original particle ID");
2136         hPi0E->SetLineColor(1);
2137         hGamE->SetLineColor(4);
2138         hNeHadE->SetLineColor(2);
2139         hChHadE->SetLineColor(7);
2140         hEleE->SetLineColor(6);
2141         
2142         //Select the maximum of the histogram to show all lines.
2143         if(hPi0E->GetMaximum() >= hGamE->GetMaximum() && hPi0E->GetMaximum() >= hNeHadE->GetMaximum() && 
2144            hPi0E->GetMaximum() >= hChHadE->GetMaximum() && hPi0E->GetMaximum() >= hEleE->GetMaximum())
2145                 haxisE->SetMaximum(hPi0E->GetMaximum());
2146         else if(hGamE->GetMaximum() >= hPi0E->GetMaximum() && hGamE->GetMaximum() >= hNeHadE->GetMaximum() && 
2147                         hGamE->GetMaximum() >= hChHadE->GetMaximum() && hGamE->GetMaximum() >= hEleE->GetMaximum())
2148                 haxisE->SetMaximum(hGamE->GetMaximum());
2149         else if(hNeHadE->GetMaximum() >= hPi0E->GetMaximum() && hNeHadE->GetMaximum() >= hGamE->GetMaximum() && 
2150                         hNeHadE->GetMaximum() >= hChHadE->GetMaximum() && hNeHadE->GetMaximum() >= hEleE->GetMaximum())
2151                 haxisE->SetMaximum(hNeHadE->GetMaximum());      
2152         else if(hChHadE->GetMaximum() >= hPi0E->GetMaximum() && hChHadE->GetMaximum() >= hNeHadE->GetMaximum() && 
2153                         hChHadE->GetMaximum() >= hGamE->GetMaximum() && hChHadE->GetMaximum() >= hEleE->GetMaximum())
2154                 haxisE->SetMaximum(hChHadE->GetMaximum());
2155         else if(hEleE->GetMaximum() >= hPi0E->GetMaximum() && hEleE->GetMaximum() >= hNeHadE->GetMaximum() && 
2156                         hEleE->GetMaximum() >= hChHadE->GetMaximum() && hEleE->GetMaximum() >= hGamE->GetMaximum())
2157                 haxisE->SetMaximum(hEleE->GetMaximum());
2158         haxisE->SetXTitle("E (GeV)");
2159         haxisE->SetMinimum(1);
2160         haxisE->Draw("axis");
2161         hPi0E->Draw("same");
2162         hGamE->Draw("same");
2163         hNeHadE->Draw("same");
2164         hChHadE->Draw("same");
2165         hEleE->Draw("same");
2166         
2167         TLegend pLegend2(0.8,0.65,0.95,0.93);
2168         pLegend2.SetTextSize(0.06);
2169         pLegend2.AddEntry(hPi0E,"  #pi^{0}","L");
2170         pLegend2.AddEntry(hGamE,"  #gamma","L");
2171         pLegend2.AddEntry(hEleE,"  e^{#pm}","L");
2172         pLegend2.AddEntry(hChHadE,"  h^{#pm}","L");
2173         pLegend2.AddEntry(hNeHadE,"  h^{0}","L");
2174         pLegend2.SetFillColor(10);
2175         pLegend2.SetBorderSize(1);
2176         pLegend2.Draw();
2177         
2178         
2179         c11->cd(2) ; 
2180         gPad->SetLogy();
2181         //printf("%s, %s, %s, %s, %s\n",fhGamPt->GetName(),fhPi0Pt->GetName(),fhElePt->GetName(),fhNeHadPt->GetName(), fhChHadPt->GetName());
2182         TH1F * hGamPt   = (TH1F*) fhGamPt->ProjectionX("hGamPt",-1,-1);
2183         TH1F * hPi0Pt   = (TH1F*) fhPi0Pt->ProjectionX("hPi0Pt",-1,-1);
2184         TH1F * hElePt   = (TH1F*) fhElePt->ProjectionX("hElePt",-1,-1);
2185         TH1F * hNeHadPt = (TH1F*) fhNeHadPt->ProjectionX("hNeHadPt",-1,-1);
2186         TH1F * hChHadPt = (TH1F*) fhChHadPt->ProjectionX("hChHadPt",-1,-1);
2187         haxispt  = (TH1F*) hPi0Pt->Clone("axispt");  
2188         haxispt->SetTitle("Reconstructed particles p_{T}, function of their original particle ID");
2189         hPi0Pt->SetLineColor(1);
2190         hGamPt->SetLineColor(4);
2191         hNeHadPt->SetLineColor(2);
2192         hChHadPt->SetLineColor(7);
2193         hElePt->SetLineColor(6);
2194         
2195         //Select the maximum of the histogram to show all lines.
2196         if(hPi0Pt->GetMaximum() >= hGamPt->GetMaximum() && hPi0Pt->GetMaximum() >= hNeHadPt->GetMaximum() && 
2197            hPi0Pt->GetMaximum() >= hChHadPt->GetMaximum() && hPi0Pt->GetMaximum() >= hElePt->GetMaximum())
2198                 haxispt->SetMaximum(hPi0Pt->GetMaximum());
2199         else if(hGamPt->GetMaximum() >= hPi0Pt->GetMaximum() && hGamPt->GetMaximum() >= hNeHadPt->GetMaximum() && 
2200                         hGamPt->GetMaximum() >= hChHadPt->GetMaximum() && hGamPt->GetMaximum() >= hElePt->GetMaximum())
2201                 haxispt->SetMaximum(hGamPt->GetMaximum());
2202         else if(hNeHadPt->GetMaximum() >= hPi0Pt->GetMaximum() && hNeHadPt->GetMaximum() >= hGamPt->GetMaximum() && 
2203                         hNeHadPt->GetMaximum() >= hChHadPt->GetMaximum() && hNeHadPt->GetMaximum() >= hElePt->GetMaximum())
2204                 haxispt->SetMaximum(hNeHadPt->GetMaximum());    
2205         else if(hChHadPt->GetMaximum() >= hPi0Pt->GetMaximum() && hChHadPt->GetMaximum() >= hNeHadPt->GetMaximum() && 
2206                         hChHadPt->GetMaximum() >= hGamPt->GetMaximum() && hChHadPt->GetMaximum() >= hElePt->GetMaximum())
2207                 haxispt->SetMaximum(hChHadPt->GetMaximum());
2208         else if(hElePt->GetMaximum() >= hPi0Pt->GetMaximum() && hElePt->GetMaximum() >= hNeHadPt->GetMaximum() && 
2209                         hElePt->GetMaximum() >= hChHadPt->GetMaximum() && hElePt->GetMaximum() >= hGamPt->GetMaximum())
2210                 haxispt->SetMaximum(hElePt->GetMaximum());
2211         haxispt->SetXTitle("p_{T} (GeV/c)");
2212         haxispt->SetMinimum(1);
2213         haxispt->Draw("axis");
2214         hPi0Pt->Draw("same");
2215         hGamPt->Draw("same");
2216         hNeHadPt->Draw("same");
2217         hChHadPt->Draw("same");
2218     hElePt->Draw("same");
2219         
2220         
2221         c11->cd(3) ;
2222         gPad->SetLogy();
2223         
2224         TH1F * hGamEta   = (TH1F*) fhGamEta->ProjectionX("hGamEta",-1,-1);
2225         TH1F * hPi0Eta   = (TH1F*) fhPi0Eta->ProjectionX("hPi0Eta",-1,-1);
2226         TH1F * hEleEta   = (TH1F*) fhEleEta->ProjectionX("hEleEta",-1,-1);
2227         TH1F * hNeHadEta = (TH1F*) fhNeHadEta->ProjectionX("hNeHadEta",-1,-1);
2228         TH1F * hChHadEta = (TH1F*) fhChHadEta->ProjectionX("hChHadEta",-1,-1);
2229         haxiseta  = (TH1F*) hPi0Eta->Clone("axiseta");  
2230         haxiseta->SetTitle("Reconstructed particles #eta, function of their original particle ID");
2231         hPi0Eta->SetLineColor(1);
2232         hGamEta->SetLineColor(4);
2233         hNeHadEta->SetLineColor(2);
2234         hChHadEta->SetLineColor(7);
2235         hEleEta->SetLineColor(6);
2236         //Select the maximum of the histogram to show all lines.
2237         if(hPi0Eta->GetMaximum() >= hGamEta->GetMaximum() && hPi0Eta->GetMaximum() >= hNeHadEta->GetMaximum() && 
2238            hPi0Eta->GetMaximum() >= hChHadEta->GetMaximum() && hPi0Eta->GetMaximum() >= hEleEta->GetMaximum())
2239                 haxiseta->SetMaximum(hPi0Eta->GetMaximum());
2240         else if(hGamEta->GetMaximum() >= hPi0Eta->GetMaximum() && hGamEta->GetMaximum() >= hNeHadEta->GetMaximum() && 
2241                         hGamEta->GetMaximum() >= hChHadEta->GetMaximum() && hGamEta->GetMaximum() >= hEleEta->GetMaximum())
2242                 haxiseta->SetMaximum(hGamEta->GetMaximum());
2243         else if(hNeHadEta->GetMaximum() >= hPi0Eta->GetMaximum() && hNeHadEta->GetMaximum() >= hGamEta->GetMaximum() && 
2244                         hNeHadEta->GetMaximum() >= hChHadEta->GetMaximum() && hNeHadEta->GetMaximum() >= hEleEta->GetMaximum())
2245                 haxiseta->SetMaximum(hNeHadEta->GetMaximum());  
2246         else if(hChHadEta->GetMaximum() >= hPi0Eta->GetMaximum() && hChHadEta->GetMaximum() >= hNeHadEta->GetMaximum() && 
2247                         hChHadEta->GetMaximum() >= hGamEta->GetMaximum() && hChHadEta->GetMaximum() >= hEleEta->GetMaximum())
2248                 haxiseta->SetMaximum(hChHadEta->GetMaximum());
2249         else if(hEleEta->GetMaximum() >= hPi0Eta->GetMaximum() && hEleEta->GetMaximum() >= hNeHadEta->GetMaximum() && 
2250                         hEleEta->GetMaximum() >= hChHadEta->GetMaximum() && hEleEta->GetMaximum() >= hGamEta->GetMaximum())
2251                 haxiseta->SetMaximum(hEleEta->GetMaximum());
2252         
2253     haxiseta->SetXTitle("#eta");
2254         haxiseta->Draw("axis");
2255         hPi0Eta->Draw("same");
2256         hGamEta->Draw("same");
2257         hNeHadEta->Draw("same");
2258         hChHadEta->Draw("same");
2259         hEleEta->Draw("same");
2260         
2261         
2262         c11->cd(4) ; 
2263         gPad->SetLogy();
2264         TH1F * hGamPhi   = (TH1F*) fhGamPhi->ProjectionX("hGamPhi",-1,-1);
2265         TH1F * hPi0Phi   = (TH1F*) fhPi0Phi->ProjectionX("hPi0Phi",-1,-1);
2266         TH1F * hElePhi   = (TH1F*) fhElePhi->ProjectionX("hElePhi",-1,-1);
2267         TH1F * hNeHadPhi = (TH1F*) fhNeHadPhi->ProjectionX("hNeHadPhi",-1,-1);
2268         TH1F * hChHadPhi = (TH1F*) fhChHadPhi->ProjectionX("hChHadPhi",-1,-1);
2269         haxisphi  = (TH1F*) hPi0Phi->Clone("axisphi");  
2270         haxisphi->SetTitle("Reconstructed particles #phi, function of their original particle ID");
2271         
2272         hPi0Phi->SetLineColor(1);
2273         hGamPhi->SetLineColor(4);
2274         hNeHadPhi->SetLineColor(2);
2275         hChHadPhi->SetLineColor(7);
2276         hElePhi->SetLineColor(6);
2277         //Select the maximum of the histogram to show all lines.
2278         if(hPi0Phi->GetMaximum() >= hGamPhi->GetMaximum() && hPi0Phi->GetMaximum() >= hNeHadPhi->GetMaximum() && 
2279            hPi0Phi->GetMaximum() >= hChHadPhi->GetMaximum() && hPi0Phi->GetMaximum() >= hElePhi->GetMaximum())
2280                 haxisphi->SetMaximum(hPi0Phi->GetMaximum());
2281         else if(hGamPhi->GetMaximum() >= hPi0Phi->GetMaximum() && hGamPhi->GetMaximum() >= hNeHadPhi->GetMaximum() && 
2282                         hGamPhi->GetMaximum() >= hChHadPhi->GetMaximum() && hGamPhi->GetMaximum() >= hElePhi->GetMaximum())
2283                 haxisphi->SetMaximum(hGamPhi->GetMaximum());
2284         else if(hNeHadPhi->GetMaximum() >= hPi0Phi->GetMaximum() && hNeHadPhi->GetMaximum() >= hGamPhi->GetMaximum() && 
2285                         hNeHadPhi->GetMaximum() >= hChHadPhi->GetMaximum() && hNeHadPhi->GetMaximum() >= hElePhi->GetMaximum())
2286                 haxisphi->SetMaximum(hNeHadPhi->GetMaximum());  
2287         else if(hChHadPhi->GetMaximum() >= hPi0Phi->GetMaximum() && hChHadPhi->GetMaximum() >= hNeHadPhi->GetMaximum() && 
2288                         hChHadPhi->GetMaximum() >= hGamPhi->GetMaximum() && hChHadPhi->GetMaximum() >= hElePhi->GetMaximum())
2289                 haxisphi->SetMaximum(hChHadPhi->GetMaximum());
2290         else if(hElePhi->GetMaximum() >= hPi0Phi->GetMaximum() && hElePhi->GetMaximum() >= hNeHadPhi->GetMaximum() && 
2291                         hElePhi->GetMaximum() >= hChHadPhi->GetMaximum() && hElePhi->GetMaximum() >= hGamPhi->GetMaximum())
2292                 haxisphi->SetMaximum(hElePhi->GetMaximum());
2293         haxisphi->SetXTitle("#phi (rad)");
2294         haxisphi->Draw("axis");
2295         hPi0Phi->Draw("same");
2296         hGamPhi->Draw("same");
2297         hNeHadPhi->Draw("same");
2298         hChHadPhi->Draw("same");
2299         hElePhi->Draw("same");
2300         
2301         sprintf(name,"QA_%s_RecDistributionsGenID.eps",fCalorimeter.Data());
2302         c11->Print(name);
2303         
2304         
2305         //Ratio reconstructed clusters / generated particles in acceptance, for different particle ID
2306         //printf("c1\n");
2307         
2308         TH1F *  hPi0EClone   = (TH1F*)   hPi0E  ->Clone("hPi0EClone");
2309         TH1F *  hGamEClone   = (TH1F*)   hGamE  ->Clone("hGamEClone");
2310         TH1F *  hPi0PtClone  = (TH1F*)   hPi0Pt ->Clone("hPi0PtClone");
2311         TH1F *  hGamPtClone  = (TH1F*)   hGamPt ->Clone("hGamPtClone"); 
2312         TH1F *  hPi0EtaClone = (TH1F*)   hPi0Eta->Clone("hPi0EtaClone");
2313         TH1F *  hGamEtaClone = (TH1F*)   hGamEta->Clone("hGamEtaClone");        
2314         TH1F *  hPi0PhiClone = (TH1F*)   hPi0Phi->Clone("hPi0PhiClone");
2315         TH1F *  hGamPhiClone = (TH1F*)   hGamPhi->Clone("hGamPhiClone");        
2316         
2317         sprintf(cname,"QA_%s_recgenidratio",fCalorimeter.Data());
2318         TCanvas  * c12 = new TCanvas(cname, "Ratio reconstructed clusters / generated particles in acceptance, for different particle ID", 400, 400) ;
2319         c12->Divide(2, 2);
2320         
2321         c12->cd(1) ; 
2322         gPad->SetLogy();
2323         haxisE->SetTitle("Ratio reconstructed clusters / generated particles in acceptance, for different particle ID");
2324         hPi0EClone->Divide(fhGenPi0AccE);
2325         hGamEClone->Divide(fhGenGamAccE);
2326         haxisE->SetMaximum(5);
2327         haxisE->SetMinimum(1e-2);
2328         haxisE->SetXTitle("E (GeV)");
2329         haxisE->SetYTitle("ratio = rec/gen");
2330         haxisE->Draw("axis");
2331         hPi0E->Draw("same");
2332         hGamE->Draw("same");
2333         
2334         TLegend pLegend3(0.75,0.2,0.9,0.4);
2335         pLegend3.SetTextSize(0.06);
2336         pLegend3.AddEntry(hPi0EClone,"  #pi^{0}","L");
2337         pLegend3.AddEntry(hGamEClone,"  #gamma","L");
2338         pLegend3.SetFillColor(10);
2339         pLegend3.SetBorderSize(1);
2340         pLegend3.Draw();
2341         
2342         c12->cd(2) ; 
2343         gPad->SetLogy();
2344         haxispt->SetTitle("Ratio reconstructed clusters / generated particles in acceptance, for different particle ID");
2345         hPi0PtClone->Divide(fhGenPi0AccPt);
2346         hGamPtClone->Divide(fhGenGamAccPt);
2347         haxispt->SetMaximum(5);
2348         haxispt->SetMinimum(1e-2);
2349         haxispt->SetXTitle("p_{T} (GeV/c)");
2350         haxispt->SetYTitle("ratio = rec/gen");
2351         haxispt->Draw("axis");
2352         hPi0PtClone->Draw("same");
2353         hGamPtClone->Draw("same");
2354         
2355         c12->cd(3) ;
2356         gPad->SetLogy();
2357         
2358         haxiseta->SetTitle("Ratio reconstructed clusters / generated particles in acceptance, for different particle ID");
2359         hPi0EtaClone->Divide(fhGenPi0AccEta);
2360         hGamEtaClone->Divide(fhGenGamAccEta);
2361         haxiseta->SetMaximum(1.2);
2362         haxiseta->SetMinimum(1e-2);
2363         haxiseta->SetYTitle("ratio = rec/gen");
2364         haxiseta->SetXTitle("#eta");
2365         haxiseta->Draw("axis");
2366         hPi0EtaClone->Draw("same");
2367         hGamEtaClone->Draw("same");
2368         
2369         
2370         c12->cd(4) ; 
2371         gPad->SetLogy();
2372         haxisphi->SetTitle("Ratio reconstructed clusters / generated particles in acceptance, for different particle ID");
2373         hPi0PhiClone->Divide(fhGenPi0AccPhi);
2374         hGamPhiClone->Divide(fhGenGamAccPhi);
2375     haxisphi->SetYTitle("ratio = rec/gen");
2376         haxisphi->SetXTitle("#phi (rad)");
2377         haxisphi->SetMaximum(1.2);
2378         haxisphi->SetMinimum(1e-2);
2379         haxisphi->Draw("axis");
2380         hPi0PhiClone->Draw("same");
2381         hGamPhiClone->Draw("same");
2382         
2383         sprintf(name,"QA_%s_EfficiencyGenID.eps",fCalorimeter.Data());
2384         c12->Print(name);
2385         
2386         
2387         //Reconstructed distributions
2388         //printf("c1\n");
2389         sprintf(cname,"QA_%s_vertex",fCalorimeter.Data());
2390         TCanvas  * c13 = new TCanvas(cname, "Particle vertex", 400, 400) ;
2391         c13->Divide(2, 2);
2392         
2393         c13->cd(1) ; 
2394         //gPad->SetLogy();
2395         fhEMVxyz->SetTitleOffset(1.6,"Y");
2396     fhEMVxyz->Draw();
2397         
2398         c13->cd(2) ; 
2399         //gPad->SetLogy();
2400         fhHaVxyz->SetTitleOffset(1.6,"Y");
2401         fhHaVxyz->Draw();
2402         
2403         c13->cd(3) ;
2404         gPad->SetLogy();
2405         TH1F * hEMR = (TH1F*) fhEMR->ProjectionY("hEM",-1,-1); 
2406         hEMR->SetLineColor(4);
2407         hEMR->Draw();
2408         
2409         c13->cd(4) ; 
2410         gPad->SetLogy();
2411         TH1F * hHaR = (TH1F*) fhHaR->ProjectionY("hHa",-1,-1); 
2412         hHaR->SetLineColor(4);
2413         hHaR->Draw();
2414         
2415         
2416         sprintf(name,"QA_%s_ParticleVertex.eps",fCalorimeter.Data());
2417         c13->Print(name);
2418         
2419         
2420         //Track-matching distributions
2421         
2422         
2423         //Reconstructed distributions, matched with tracks, generated particle dependence
2424         //printf("c2\n");
2425         sprintf(cname,"QA_%s_rectrackmatchGenID",fCalorimeter.Data());
2426         TCanvas  * c22ch = new TCanvas(cname, "Reconstructed distributions, matched with tracks, for different particle ID", 400, 400) ;
2427         c22ch->Divide(2, 2);
2428         
2429         c22ch->cd(1) ; 
2430         
2431         TH1F * hGamECharged   = (TH1F*) fhGamECharged->ProjectionX("hGamECharged",-1,-1);
2432         TH1F * hPi0ECharged   = (TH1F*) fhPi0ECharged->ProjectionX("hPi0ECharged",-1,-1);
2433         TH1F * hEleECharged   = (TH1F*) fhEleECharged->ProjectionX("hEleECharged",-1,-1);
2434         TH1F * hNeHadECharged = (TH1F*) fhNeHadECharged->ProjectionX("hNeHadECharged",-1,-1);
2435         TH1F * hChHadECharged = (TH1F*) fhChHadECharged->ProjectionX("hChHadECharged",-1,-1);
2436         hPi0ECharged->SetLineColor(1);
2437         hGamECharged->SetLineColor(4);
2438         hNeHadECharged->SetLineColor(2);
2439         hChHadECharged->SetLineColor(7);
2440         hEleECharged->SetLineColor(6);  
2441         gPad->SetLogy();
2442         fhECharged->SetLineColor(3);
2443         fhECharged->SetMinimum(0.5);
2444         fhECharged->Draw();
2445         hPi0ECharged->Draw("same");
2446         hGamECharged->Draw("same");
2447         hNeHadECharged->Draw("same");
2448         hChHadECharged->Draw("same");
2449         hEleECharged->Draw("same");
2450         TLegend pLegend22(0.75,0.45,0.9,0.8);
2451         pLegend22.SetTextSize(0.06);
2452         pLegend22.AddEntry(fhECharged,"all","L");
2453         pLegend22.AddEntry(hPi0ECharged,"#pi^{0}","L");
2454         pLegend22.AddEntry(hGamECharged,"#gamma","L");
2455         pLegend22.AddEntry(hEleECharged,"e^{#pm}","L");
2456         pLegend22.AddEntry(hChHadECharged,"h^{#pm}","L");
2457         pLegend22.AddEntry(hNeHadECharged,"h^{0}","L");
2458         pLegend22.SetFillColor(10);
2459         pLegend22.SetBorderSize(1);
2460         pLegend22.Draw();
2461         
2462         c22ch->cd(2) ; 
2463         
2464         TH1F * hGamPtCharged   = (TH1F*) fhGamPtCharged->ProjectionX("hGamPtCharged",-1,-1);
2465         TH1F * hPi0PtCharged   = (TH1F*) fhPi0PtCharged->ProjectionX("hPi0PtCharged",-1,-1);
2466         TH1F * hElePtCharged   = (TH1F*) fhElePtCharged->ProjectionX("hElePtCharged",-1,-1);
2467         TH1F * hNeHadPtCharged = (TH1F*) fhNeHadPtCharged->ProjectionX("hNeHadPtCharged",-1,-1);
2468         TH1F * hChHadPtCharged = (TH1F*) fhChHadPtCharged->ProjectionX("hChHadPtCharged",-1,-1);
2469         hPi0PtCharged->SetLineColor(1);
2470         hGamPtCharged->SetLineColor(4);
2471         hNeHadPtCharged->SetLineColor(2);
2472         hChHadPtCharged->SetLineColor(7);
2473         hElePtCharged->SetLineColor(6); 
2474         gPad->SetLogy();
2475         fhPtCharged->SetLineColor(3);
2476         fhPtCharged->SetMinimum(0.5);
2477         fhPtCharged->Draw();
2478         hPi0PtCharged->Draw("same");
2479         hGamPtCharged->Draw("same");
2480         hNeHadPtCharged->Draw("same");
2481         hChHadPtCharged->Draw("same");
2482         hElePtCharged->Draw("same");    
2483         
2484         c22ch->cd(4) ; 
2485         
2486         TH1F * hGamEtaCharged   = (TH1F*) fhGamEtaCharged->ProjectionX("hGamEtaCharged",-1,-1);
2487         TH1F * hPi0EtaCharged   = (TH1F*) fhPi0EtaCharged->ProjectionX("hPi0EtaCharged",-1,-1);
2488         TH1F * hEleEtaCharged   = (TH1F*) fhEleEtaCharged->ProjectionX("hEleEtaCharged",-1,-1);
2489         TH1F * hNeHadEtaCharged = (TH1F*) fhNeHadEtaCharged->ProjectionX("hNeHadEtaCharged",-1,-1);
2490         TH1F * hChHadEtaCharged = (TH1F*) fhChHadEtaCharged->ProjectionX("hChHadEtaCharged",-1,-1);
2491         hPi0EtaCharged->SetLineColor(1);
2492         hGamEtaCharged->SetLineColor(4);
2493         hNeHadEtaCharged->SetLineColor(2);
2494         hChHadEtaCharged->SetLineColor(7);
2495         hEleEtaCharged->SetLineColor(6);        
2496         gPad->SetLogy();
2497         fhEtaCharged->SetLineColor(3);
2498         fhEtaCharged->SetMinimum(0.5);
2499         fhEtaCharged->Draw();
2500         hPi0EtaCharged->Draw("same");
2501         hGamEtaCharged->Draw("same");
2502         hNeHadEtaCharged->Draw("same");
2503         hChHadEtaCharged->Draw("same");
2504         hEleEtaCharged->Draw("same");
2505         
2506         c22ch->cd(3) ; 
2507         
2508         TH1F * hGamPhiCharged   = (TH1F*) fhGamPhiCharged->ProjectionX("hGamPhiCharged",-1,-1);
2509         TH1F * hPi0PhiCharged   = (TH1F*) fhPi0PhiCharged->ProjectionX("hPi0PhiCharged",-1,-1);
2510         TH1F * hElePhiCharged   = (TH1F*) fhElePhiCharged->ProjectionX("hElePhiCharged",-1,-1);
2511         TH1F * hNeHadPhiCharged = (TH1F*) fhNeHadPhiCharged->ProjectionX("hNeHadPhiCharged",-1,-1);
2512         TH1F * hChHadPhiCharged = (TH1F*) fhChHadPhiCharged->ProjectionX("hChHadPhiCharged",-1,-1);
2513         hPi0PhiCharged->SetLineColor(1);
2514         hGamPhiCharged->SetLineColor(4);
2515         hNeHadPhiCharged->SetLineColor(2);
2516         hChHadPhiCharged->SetLineColor(7);
2517         hElePhiCharged->SetLineColor(6);        
2518         gPad->SetLogy();
2519         fhPhiCharged->SetLineColor(3);
2520         fhPhiCharged->SetMinimum(0.5);
2521         fhPhiCharged->Draw();
2522         hPi0PhiCharged->Draw("same");
2523         hGamPhiCharged->Draw("same");
2524         hNeHadPhiCharged->Draw("same");
2525         hChHadPhiCharged->Draw("same");
2526         hElePhiCharged->Draw("same");
2527         
2528         
2529         sprintf(name,"QA_%s_ReconstructedDistributions_TrackMatchedGenID.eps",fCalorimeter.Data());
2530         c22ch->Print(name);
2531         
2532         TH1F *  hGamEChargedClone   = (TH1F*)   hGamECharged->Clone("GamEChargedClone");
2533         TH1F *  hGamPtChargedClone  = (TH1F*)   hGamPtCharged->Clone("GamPtChargedClone");
2534         TH1F *  hGamEtaChargedClone = (TH1F*)   hGamEtaCharged->Clone("GamEtaChargedClone");
2535         TH1F *  hGamPhiChargedClone = (TH1F*)   hGamPhiCharged->Clone("GamPhiChargedClone");
2536         
2537         TH1F *  hPi0EChargedClone   = (TH1F*)   hPi0ECharged->Clone("Pi0EChargedClone");
2538         TH1F *  hPi0PtChargedClone  = (TH1F*)   hPi0PtCharged->Clone("Pi0PtChargedClone");
2539         TH1F *  hPi0EtaChargedClone = (TH1F*)   hPi0EtaCharged->Clone("Pi0EtaChargedClone");
2540         TH1F *  hPi0PhiChargedClone = (TH1F*)   hPi0PhiCharged->Clone("Pi0PhiChargedClone");
2541         
2542         TH1F *  hEleEChargedClone   = (TH1F*)   hEleECharged->Clone("EleEChargedClone");
2543         TH1F *  hElePtChargedClone  = (TH1F*)   hElePtCharged->Clone("ElePtChargedClone");
2544         TH1F *  hEleEtaChargedClone = (TH1F*)   hEleEtaCharged->Clone("EleEtaChargedClone");
2545         TH1F *  hElePhiChargedClone = (TH1F*)   hElePhiCharged->Clone("ElePhiChargedClone");    
2546         
2547         TH1F *  hNeHadEChargedClone   = (TH1F*)   hNeHadECharged->Clone("NeHadEChargedClone");
2548         TH1F *  hNeHadPtChargedClone  = (TH1F*)   hNeHadPtCharged->Clone("NeHadPtChargedClone");
2549         TH1F *  hNeHadEtaChargedClone = (TH1F*)   hNeHadEtaCharged->Clone("NeHadEtaChargedClone");
2550         TH1F *  hNeHadPhiChargedClone = (TH1F*)   hNeHadPhiCharged->Clone("NeHadPhiChargedClone");
2551         
2552         TH1F *  hChHadEChargedClone   = (TH1F*)   hChHadECharged->Clone("ChHadEChargedClone");
2553         TH1F *  hChHadPtChargedClone  = (TH1F*)   hChHadPtCharged->Clone("ChHadPtChargedClone");
2554         TH1F *  hChHadEtaChargedClone = (TH1F*)   hChHadEtaCharged->Clone("ChHadEtaChargedClone");
2555         TH1F *  hChHadPhiChargedClone = (TH1F*)   hChHadPhiCharged->Clone("ChHadPhiChargedClone");      
2556         
2557         //Ratio: reconstructed track matched/ all reconstructed
2558         //printf("c3\n");
2559         sprintf(cname,"QA_%s_rectrackmatchratGenID",fCalorimeter.Data());
2560         TCanvas  * c3ch = new TCanvas(cname, "Ratio: reconstructed track matched/ all reconstructed, for different particle ID", 400, 400) ;
2561         c3ch->Divide(2, 2);
2562         
2563         c3ch->cd(1) ;
2564         hEChargedClone->SetMaximum(1.2);
2565         hEChargedClone->SetMinimum(0.001);      
2566         hEChargedClone->SetLineColor(3);
2567         hEChargedClone->SetYTitle("track matched / all");
2568         hPi0EChargedClone->Divide(hPi0E);
2569         hGamEChargedClone->Divide(hGamE);
2570         hEleEChargedClone->Divide(hEleE);
2571         hNeHadEChargedClone->Divide(hNeHadE);
2572         hChHadEChargedClone->Divide(hChHadE);
2573         hEChargedClone->Draw();
2574         hPi0EChargedClone->Draw("same");
2575         hGamEChargedClone->Draw("same");
2576         hEleEChargedClone->Draw("same");
2577         hNeHadEChargedClone->Draw("same");
2578         hChHadEChargedClone->Draw("same");
2579         
2580         TLegend pLegend3ch(0.75,0.45,0.9,0.8);
2581         pLegend3ch.SetTextSize(0.06);
2582         pLegend3ch.AddEntry(hEChargedClone,"all","L");
2583         pLegend3ch.AddEntry(hPi0EChargedClone,"#pi^{0}","L");
2584         pLegend3ch.AddEntry(hGamEChargedClone,"#gamma","L");
2585         pLegend3ch.AddEntry(hEleEChargedClone,"e^{#pm}","L");
2586         pLegend3ch.AddEntry(hChHadEChargedClone,"h^{#pm}","L");
2587         pLegend3ch.AddEntry(hNeHadEChargedClone,"h^{0}","L");
2588         pLegend3ch.SetFillColor(10);
2589         pLegend3ch.SetBorderSize(1);
2590         pLegend3ch.Draw();
2591         
2592         c3ch->cd(2) ;
2593         hPtChargedClone->SetMaximum(1.2);
2594         hPtChargedClone->SetMinimum(0.001);     
2595         hPtChargedClone->SetLineColor(3);
2596         hPtChargedClone->SetYTitle("track matched / all");
2597         hPi0PtChargedClone->Divide(hPi0Pt);
2598         hGamPtChargedClone->Divide(hGamPt);
2599         hElePtChargedClone->Divide(hElePt);
2600         hNeHadPtChargedClone->Divide(hNeHadPt);
2601         hChHadPtChargedClone->Divide(hChHadPt);
2602         hPtChargedClone->Draw();
2603         hPi0PtChargedClone->Draw("same");
2604         hGamPtChargedClone->Draw("same");
2605         hElePtChargedClone->Draw("same");
2606         hNeHadPtChargedClone->Draw("same");
2607         hChHadPtChargedClone->Draw("same");
2608         
2609         c3ch->cd(4) ;
2610         hEtaChargedClone->SetMaximum(1.2);
2611         hEtaChargedClone->SetMinimum(0.001);    
2612         hEtaChargedClone->SetLineColor(3);
2613         hEtaChargedClone->SetYTitle("track matched / all");
2614         hPi0EtaChargedClone->Divide(hPi0Eta);
2615         hGamEtaChargedClone->Divide(hGamEta);
2616         hEleEtaChargedClone->Divide(hEleEta);
2617         hNeHadEtaChargedClone->Divide(hNeHadEta);
2618         hChHadEtaChargedClone->Divide(hChHadEta);
2619         hEtaChargedClone->Draw();
2620         hPi0EtaChargedClone->Draw("same");
2621         hGamEtaChargedClone->Draw("same");
2622         hEleEtaChargedClone->Draw("same");
2623         hNeHadEtaChargedClone->Draw("same");
2624         hChHadEtaChargedClone->Draw("same");
2625         
2626         c3ch->cd(3) ;
2627         hPhiChargedClone->SetMaximum(1.2);
2628         hPhiChargedClone->SetMinimum(0.001);
2629         hPhiChargedClone->SetLineColor(3);
2630         hPhiChargedClone->SetYTitle("track matched / all");
2631         hPi0PhiChargedClone->Divide(hPi0Phi);
2632         hGamPhiChargedClone->Divide(hGamPhi);
2633         hElePhiChargedClone->Divide(hElePhi);
2634         hNeHadPhiChargedClone->Divide(hNeHadPhi);
2635         hChHadPhiChargedClone->Divide(hChHadPhi);
2636         hPhiChargedClone->Draw();
2637         hPi0PhiChargedClone->Draw("same");
2638         hGamPhiChargedClone->Draw("same");
2639         hElePhiChargedClone->Draw("same");
2640         hNeHadPhiChargedClone->Draw("same");
2641         hChHadPhiChargedClone->Draw("same");
2642         
2643         sprintf(name,"QA_%s_RatioReconstructedMatchedDistributionsGenID.eps",fCalorimeter.Data());
2644         c3ch->Print(name);
2645         
2646         
2647         //Track-matching distributions
2648         if(!strcmp(GetReader()->GetInputEvent()->GetName(),"AliESDEvent")){
2649                 
2650                 
2651                 sprintf(cname,"QA_%s_trkmatch",fCalorimeter.Data());
2652                 TCanvas *cme = new TCanvas(cname,"Track-matching distributions", 400, 400);
2653                 cme->Divide(2,2);
2654                 
2655                 TLegend pLegendpE0(0.6,0.55,0.9,0.8);
2656                 pLegendpE0.SetTextSize(0.04);
2657                 pLegendpE0.AddEntry(fh1pOverE,"all","L");
2658                 pLegendpE0.AddEntry(fh1pOverER02,"dR < 0.02","L");
2659                 pLegendpE0.SetFillColor(10);
2660                 pLegendpE0.SetBorderSize(1);
2661                 //pLegendpE0.Draw();
2662                 
2663                 cme->cd(1);
2664                 gPad->SetLogy();
2665                 fh1pOverE->SetTitle("Track matches p/E");
2666                 fh1pOverE->Draw();
2667                 fh1pOverER02->SetLineColor(4);
2668                 fh1pOverER02->Draw("same");
2669                 pLegendpE0.Draw();
2670                 
2671                 cme->cd(2);
2672                 gPad->SetLogy();
2673                 fh1dR->Draw();
2674                 
2675                 cme->cd(3);
2676                 fh2MatchdEdx->Draw();
2677                 
2678                 cme->cd(4);
2679                 fh2EledEdx->Draw();
2680                 
2681                 sprintf(name,"QA_%s_TrackMatchingEleDist.eps",fCalorimeter.Data());
2682                 cme->Print(name);       
2683                 
2684                 
2685                 sprintf(cname,"QA_%s_trkmatchMCEle",fCalorimeter.Data());
2686                 TCanvas *cmemc = new TCanvas(cname,"Track-matching distributions from MC electrons", 600, 200);
2687                 cmemc->Divide(3,1);
2688                 
2689                 cmemc->cd(1);
2690                 gPad->SetLogy();
2691                 fhMCEle1pOverE->Draw();
2692                 fhMCEle1pOverER02->SetLineColor(4);
2693                 fhMCEle1pOverE->SetLineColor(1);
2694                 fhMCEle1pOverER02->Draw("same");
2695                 pLegendpE0.Draw();
2696                 
2697                 cmemc->cd(2);
2698                 gPad->SetLogy();
2699                 fhMCEle1dR->Draw();
2700                 
2701                 cmemc->cd(3);
2702                 fhMCEle2MatchdEdx->Draw();
2703                 
2704                 sprintf(name,"QA_%s_TrackMatchingDistMCEle.eps",fCalorimeter.Data());
2705                 cmemc->Print(name);  
2706                 
2707                 sprintf(cname,"QA_%s_trkmatchMCChHad",fCalorimeter.Data());
2708                 TCanvas *cmemchad = new TCanvas(cname,"Track-matching distributions from MC charged hadrons", 600, 200);
2709                 cmemchad->Divide(3,1);
2710                 
2711                 cmemchad->cd(1);
2712                 gPad->SetLogy();
2713                 fhMCChHad1pOverE->Draw();
2714                 fhMCChHad1pOverER02->SetLineColor(4);
2715                 fhMCChHad1pOverE->SetLineColor(1);
2716                 fhMCChHad1pOverER02->Draw("same");
2717                 pLegendpE0.Draw();
2718                 
2719                 cmemchad->cd(2);
2720                 gPad->SetLogy();
2721                 fhMCChHad1dR->Draw();
2722                 
2723                 cmemchad->cd(3);
2724                 fhMCChHad2MatchdEdx->Draw();
2725