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