]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/PartCorrDep/AliAnaCalorimeterQA.cxx
Initialize in maker the reader and calorimeter utils pointers only if requested and...
[u/mrichter/AliRoot.git] / PWG4 / PartCorrDep / AliAnaCalorimeterQA.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15 /* $Id: $ */
16
17 //_________________________________________________________________________
18 // Class to check results from simulations or reconstructed real data. 
19 // Fill few histograms and do some checking plots
20 //
21 //-- Author: Gustavo Conesa (INFN-LNF)
22 //_________________________________________________________________________
23
24
25 // --- ROOT system ---
26 //#include "Riostream.h"
27 #include "TObjArray.h"
28 #include "TParticle.h"
29 #include "TDatabasePDG.h"
30 #include "TCanvas.h"
31 #include "TPad.h"
32 #include "TROOT.h"
33 #include "TH3F.h"
34 #include "TH2F.h"
35 #include "TLegend.h"
36 #include "TStyle.h"
37 #include <TObjString.h>
38
39 //---- AliRoot system ----
40 #include "AliAnaCalorimeterQA.h"
41 #include "AliCaloTrackReader.h"
42 #include "AliStack.h"
43 #include "AliAODCaloCells.h"
44 #include "AliESDCaloCells.h"
45 #include "AliAODCaloCluster.h"
46 #include "AliFiducialCut.h"
47 #include "AliESDtrack.h"
48 #include "AliAODTrack.h"
49 #include "AliESDCaloCluster.h"
50 #include "AliESDEvent.h"
51 #include "AliAODEvent.h"
52 #include "AliVEventHandler.h"
53 #include "AliAnalysisManager.h"
54 #include "AliAODMCParticle.h"
55 #include "AliMCAnalysisUtils.h"
56 #include "AliAODPid.h"
57
58 ClassImp(AliAnaCalorimeterQA)
59   
60 //____________________________________________________________________________
61   AliAnaCalorimeterQA::AliAnaCalorimeterQA() : 
62     AliAnaPartCorrBaseClass(), fCalorimeter(""), fStyleMacro(""), 
63     fMakePlots(kFALSE), fCorrelateCalos(kFALSE), fNModules(12), fNRCU(2),
64     fTimeCutMin(-1), fTimeCutMax(9999999),
65     fHistoPOverEBins(100),     fHistoPOverEMax(100.),     fHistoPOverEMin(0.),
66     fHistodEdxBins(100),       fHistodEdxMax(100.),       fHistodEdxMin(0.),
67     fHistodRBins(100),         fHistodRMax(100.),         fHistodRMin(0.),
68     fHistoTimeBins(100),       fHistoTimeMax(100.),       fHistoTimeMin(0.),
69     fHistoNBins(100),          fHistoNMax(100),           fHistoNMin(0),
70     fHistoRatioBins(100),      fHistoRatioMax(100.),      fHistoRatioMin(0.),
71     fHistoVertexDistBins(100), fHistoVertexDistMax(100.), fHistoVertexDistMin(0.),
72     fHistoRBins(100),          fHistoRMax(1000),           fHistoRMin(-1000),
73     fHistoXBins(100),          fHistoXMax(1000),           fHistoXMin(-1000),
74     fHistoYBins(100),          fHistoYMax(1000),           fHistoYMin(-1000),
75     fHistoZBins(100),          fHistoZMax(1000),           fHistoZMin(-1000),
76     fHistoSSBins(40),          fHistoSSMax(10),            fHistoSSMin(0),
77     fhE(0),fhPt(0),fhPhi(0),fhEta(0),   fhEtaPhiE(0),
78     fhECharged(0),fhPtCharged(0),fhPhiCharged(0),fhEtaCharged(0), fhEtaPhiECharged(0), 
79     //fhEChargedNoOut(0),fhPtChargedNoOut(0),fhPhiChargedNoOut(0),fhEtaChargedNoOut(0), fhEtaPhiChargedNoOut(0), 
80     fhDeltaE(0), fhDeltaPt(0),fhDeltaPhi(0),fhDeltaEta(0), fhRatioE(0), fhRatioPt(0),fhRatioPhi(0),fhRatioEta(0),
81     fh2E(0),fh2Pt(0),fh2Phi(0),fh2Eta(0),
82     fhLambda(0), fhDispersion(0), 
83     fhIM(0), fhIMCellCut(0),fhAsym(0), 
84     fhNCellsPerCluster(0),fhNCellsPerClusterMIP(0), fhNCellsPerClusterMIPCharged(0), fhNClusters(0), 
85     fhClusterTimeEnergy(0),fhCellTimeSpreadRespectToCellMax(0),fhCellIdCellLargeTimeSpread(0),
86     fhRNCells(0),fhXNCells(0),fhYNCells(0),fhZNCells(0),
87     fhRE(0),     fhXE(0),     fhYE(0),     fhZE(0),    fhXYZ(0),
88     fhRCellE(0), fhXCellE(0), fhYCellE(0), fhZCellE(0),fhXYZCell(0),
89     fhDeltaCellClusterRNCells(0),fhDeltaCellClusterXNCells(0),fhDeltaCellClusterYNCells(0),fhDeltaCellClusterZNCells(0),
90     fhDeltaCellClusterRE(0),     fhDeltaCellClusterXE(0),     fhDeltaCellClusterYE(0),     fhDeltaCellClusterZE(0),
91     fhNCells(0), fhAmplitude(0), fhAmpId(0), fhEtaPhiAmp(0), 
92     fhTime(0), fhTimeId(0), fhTimeAmp(0), //fhT0Time(0), fhT0TimeId(0), fhT0TimeAmp(0), 
93     fhCaloCorrNClusters(0), fhCaloCorrEClusters(0), fhCaloCorrNCells(0), fhCaloCorrECells(0),
94     fhEMod(0), fhNClustersMod(0), fhNCellsPerClusterMod(0), fhNCellsMod(0),  
95     fhGridCellsMod(0), fhGridCellsEMod(0), fhGridCellsTimeMod(0), 
96     fhAmplitudeMod(0), fhAmplitudeModFraction(0),fhTimeAmpPerRCU(0), //fhT0TimeAmpPerRCU(0), 
97     //fhTimeCorrRCU(0),
98     fhIMMod(0),  fhIMCellCutMod(0),
99     fhGenGamPt(0),fhGenGamEta(0),fhGenGamPhi(0),fhGenPi0Pt(0),fhGenPi0Eta(0),fhGenPi0Phi(0),
100     fhGenEtaPt(0),fhGenEtaEta(0),fhGenEtaPhi(0),fhGenOmegaPt(0),fhGenOmegaEta(0),fhGenOmegaPhi(0),
101     fhGenElePt(0),fhGenEleEta(0),fhGenElePhi(0), fhEMVxyz(0),  fhEMR(0), fhHaVxyz(0),  fhHaR(0),
102     fhGamE(0),fhGamPt(0),fhGamPhi(0),fhGamEta(0), 
103     fhGamDeltaE(0), fhGamDeltaPt(0),fhGamDeltaPhi(0),fhGamDeltaEta(0), 
104     fhGamRatioE(0), fhGamRatioPt(0),fhGamRatioPhi(0),fhGamRatioEta(0),
105     fhEleE(0),fhElePt(0),fhElePhi(0),fhEleEta(0),
106     fhPi0E(0),fhPi0Pt(0),fhPi0Phi(0),fhPi0Eta(0), 
107     fhNeHadE(0),fhNeHadPt(0),fhNeHadPhi(0),fhNeHadEta(0), 
108     fhChHadE(0),fhChHadPt(0),fhChHadPhi(0),fhChHadEta(0),
109     fhGamECharged(0),fhGamPtCharged(0),fhGamPhiCharged(0),fhGamEtaCharged(0), 
110     fhEleECharged(0),fhElePtCharged(0),fhElePhiCharged(0),fhEleEtaCharged(0),
111     fhPi0ECharged(0),fhPi0PtCharged(0),fhPi0PhiCharged(0),fhPi0EtaCharged(0), 
112     fhNeHadECharged(0),fhNeHadPtCharged(0),fhNeHadPhiCharged(0),fhNeHadEtaCharged(0), 
113     fhChHadECharged(0),fhChHadPtCharged(0),fhChHadPhiCharged(0),fhChHadEtaCharged(0),
114     fhGenGamAccE(0),fhGenGamAccPt(0),fhGenGamAccEta(0),fhGenGamAccPhi(0),
115     fhGenPi0AccE(0),fhGenPi0AccPt(0),fhGenPi0AccEta(0),fhGenPi0AccPhi(0),
116     fh1pOverE(0),fh1dR(0),fh2EledEdx(0), fh2MatchdEdx(0),fhMCEle1pOverE(0),fhMCEle1dR(0),fhMCEle2MatchdEdx(0),
117     fhMCChHad1pOverE(0),  fhMCChHad1dR(0),  fhMCChHad2MatchdEdx(0),
118     fhMCNeutral1pOverE(0),fhMCNeutral1dR(0),fhMCNeutral2MatchdEdx(0),
119     fh1pOverER02(0), fhMCEle1pOverER02(0), fhMCChHad1pOverER02(0), fhMCNeutral1pOverER02(0)
120 {
121   //Default Ctor
122   
123   //Initialize parameters
124   InitParameters();
125 }
126 /*
127 //____________________________________________________________________________
128 AliAnaCalorimeterQA::AliAnaCalorimeterQA(const AliAnaCalorimeterQA & qa) :   
129   AliAnaPartCorrBaseClass(qa), fCalorimeter(qa.fCalorimeter), fStyleMacro(qa.fStyleMacro), 
130   fMakePlots(qa.fMakePlots), fCorrelateCalos(qa.fCorrelateCalos), fNModules(qa.fNModules), fNRCU(qa.fNRCU),
131   fTimeCutMin(qa.fTimeCutMin), fTimeCutMax(qa.fTimeCutMax),     
132   fHistoPOverEBins(qa.fHistoPOverEBins), fHistoPOverEMax(qa.fHistoPOverEMax), fHistoPOverEMin(qa.fHistoPOverEMin),
133   fHistodEdxBins(qa.fHistodEdxBins), fHistodEdxMax(qa.fHistodEdxMax), fHistodEdxMin(qa.fHistodEdxMin), 
134   fHistodRBins(qa.fHistodRBins), fHistodRMax(qa.fHistodRMax), fHistodRMin(qa.fHistodRMin),
135   fHistoTimeBins(qa.fHistoTimeBins), fHistoTimeMax(qa.fHistoTimeMax), fHistoTimeMin(qa.fHistoTimeMin),
136   fHistoNBins(qa.fHistoNBins), fHistoNMax(qa.fHistoNMax), fHistoNMin(qa.fHistoNMin),
137   fHistoRatioBins(qa.fHistoRatioBins), fHistoRatioMax(qa.fHistoRatioMax), fHistoRatioMin(qa.fHistoRatioMin),
138   fHistoVertexDistBins(qa.fHistoVertexDistBins), fHistoVertexDistMax(qa.fHistoVertexDistMax), fHistoVertexDistMin(qa.fHistoVertexDistMin),
139   fHistoRBins(qa.fHistoRBins), fHistoRMax(qa.fHistoRMax),  fHistoRMin(qa.fHistoRMin),
140   fHistoXBins(qa.fHistoXBins), fHistoXMax(qa.fHistoXMax),  fHistoXMin(qa.fHistoXMin),
141   fHistoYBins(qa.fHistoYBins), fHistoYMax(qa.fHistoYMax),  fHistoYMin(qa.fHistoYMin),
142   fHistoZBins(qa.fHistoZBins), fHistoZMax(qa.fHistoZMax),  fHistoZMin(qa.fHistoZMin),
143   fHistoSSBins(qa.fHistoSSBins),fHistoSSMax(qa.fHistoSSMax), fHistoSSMin(qa.fHistoSSMin),
144   fhE(qa.fhE),fhPt(qa.fhPt), fhPhi(qa.fhPhi), fhEta(qa.fhEta), fhEtaPhiE(qa.fhEtaPhiE), 
145   fhECharged(qa.fhECharged),fhPtCharged(qa.fhPtCharged),fhPhiCharged(qa.fhPhiCharged),
146   fhEtaCharged(qa.fhEtaCharged), fhEtaPhiECharged(qa.fhEtaPhiECharged), 
147   //fhEChargedNoOut(qa.fhEChargedNoOut),fhPtChargedNoOut(qa.fhPtChargedNoOut),fhPhiChargedNoOut(qa.fhPhiChargedNoOut),
148   //fhEtaChargedNoOut(qa.fhEtaChargedNoOut), fhEtaPhiChargedNoOut(qa.fhEtaPhiChargedNoOut), 
149   fhDeltaE(qa.fhDeltaE), fhDeltaPt(qa.fhDeltaPt), fhDeltaPhi(qa.fhDeltaPhi), fhDeltaEta(qa.fhDeltaEta),
150   fhRatioE(qa.fhRatioE), fhRatioPt(qa.fhRatioPt), fhRatioPhi(qa.fhRatioPhi), fhRatioEta(qa.fhRatioEta),
151   fh2E(qa.fh2E), fh2Pt(qa.fh2Pt), fh2Phi(qa.fh2Phi),fh2Eta(qa.fh2Eta), 
152   fhLambda(qa.fhLambda), fhDispersion(qa.fhDispersion), 
153   fhIM(qa.fhIM), fhIMCellCut(qa.fhIMCellCut), fhAsym(qa.fhAsym), 
154   fhNCellsPerCluster(qa.fhNCellsPerCluster), fhNCellsPerClusterMIP(qa.fhNCellsPerClusterMIP),
155   fhNCellsPerClusterMIPCharged(qa.fhNCellsPerClusterMIPCharged),fhNClusters(qa.fhNClusters),
156   fhClusterTimeEnergy(qa.fhClusterTimeEnergy),  
157   fhCellTimeSpreadRespectToCellMax(qa.fhCellTimeSpreadRespectToCellMax),
158   fhCellIdCellLargeTimeSpread(qa.fhCellIdCellLargeTimeSpread),
159   fhRNCells(qa.fhRNCells),fhXNCells(qa.fhXNCells),fhYNCells(qa.fhYNCells),fhZNCells(qa.fhZNCells),
160   fhRE(qa.fhRE),          fhXE(qa.fhXE),          fhYE(qa.fhYE),          fhZE(qa.fhZE),        fhXYZ(qa.fhXYZ),
161   fhRCellE(qa.fhXCellE),  fhXCellE(qa.fhXCellE),  fhYCellE(qa.fhYCellE),  fhZCellE(qa.fhZCellE),fhXYZCell(qa.fhXYZCell),
162   fhDeltaCellClusterRNCells(qa.fhDeltaCellClusterRNCells),fhDeltaCellClusterXNCells(qa.fhDeltaCellClusterXNCells),
163   fhDeltaCellClusterYNCells(qa.fhDeltaCellClusterYNCells),fhDeltaCellClusterZNCells(qa.fhDeltaCellClusterZNCells),
164   fhDeltaCellClusterRE(qa.fhDeltaCellClusterRE),          fhDeltaCellClusterXE(qa.fhDeltaCellClusterXE),
165   fhDeltaCellClusterYE(qa.fhDeltaCellClusterYE),          fhDeltaCellClusterZE(qa.fhDeltaCellClusterZE),
166   fhNCells(qa.fhNCells), fhAmplitude(qa.fhAmplitude), fhAmpId(fhAmpId), fhEtaPhiAmp(qa.fhEtaPhiAmp),
167   fhTime(qa.fhTime), fhTimeId(qa.fhTimeId),fhTimeAmp(qa.fhTimeAmp),
168   //fhT0Time(qa.fhT0Time),fhT0TimeId(qa.fhT0TimeId), fhT0TimeAmp(qa.fhT0TimeAmp), 
169   fhCaloCorrNClusters(qa.fhCaloCorrNClusters), fhCaloCorrEClusters(qa.fhCaloCorrEClusters),
170   fhCaloCorrNCells(qa.fhCaloCorrNCells), fhCaloCorrECells(qa.fhCaloCorrECells),
171   fhEMod(qa.fhEMod), fhNClustersMod(qa.fhNClustersMod), 
172   fhNCellsPerClusterMod(qa.fhNCellsPerClusterMod), fhNCellsMod(qa.fhNCellsMod),  
173   fhGridCellsMod(qa.fhGridCellsMod),  fhGridCellsEMod(qa.fhGridCellsEMod), fhGridCellsTimeMod(qa.fhGridCellsTimeMod), 
174   fhAmplitudeMod(qa.fhAmplitudeMod), fhAmplitudeModFraction(qa.fhAmplitudeModFraction),
175   fhTimeAmpPerRCU(qa.fhTimeAmpPerRCU), //fhT0TimeAmpPerRCU(qa.fhT0TimeAmpPerRCU), fhTimeCorrRCU(qa.fhTimeCorrRCU),
176   fhIMMod(qa.fhIMMod),fhIMCellCutMod(qa.fhIMCellCutMod),
177   fhGenGamPt(qa.fhGenGamPt), fhGenGamEta(qa.fhGenGamEta), fhGenGamPhi(qa.fhGenGamPhi),
178   fhGenPi0Pt(qa.fhGenPi0Pt), fhGenPi0Eta(qa.fhGenPi0Eta), fhGenPi0Phi(qa.fhGenPi0Phi),
179   fhGenEtaPt(qa.fhGenEtaPt), fhGenEtaEta(qa.fhGenEtaEta), fhGenEtaPhi(qa.fhGenEtaPhi),
180   fhGenOmegaPt(qa.fhGenOmegaPt), fhGenOmegaEta(qa.fhGenOmegaEta), fhGenOmegaPhi(qa.fhGenOmegaPhi),
181   fhGenElePt(qa.fhGenElePt), fhGenEleEta(qa.fhGenEleEta), fhGenElePhi(qa.fhGenElePhi), 
182   fhEMVxyz(qa.fhEMVxyz),  fhEMR(qa.fhEMR), fhHaVxyz(qa.fhHaVxyz),  fhHaR(qa.fhHaR),
183   fhGamE(qa.fhGamE),fhGamPt(qa.fhGamPt),fhGamPhi(qa.fhGamPhi),fhGamEta(qa.fhGamEta), 
184   fhGamDeltaE(qa.fhGamDeltaE), fhGamDeltaPt(qa.fhGamDeltaPt), fhGamDeltaPhi(qa.fhGamDeltaPhi), fhGamDeltaEta(qa.fhGamDeltaEta),
185   fhGamRatioE(qa.fhGamRatioE), fhGamRatioPt(qa.fhGamRatioPt), fhGamRatioPhi(qa.fhGamRatioPhi), fhGamRatioEta(qa.fhGamRatioEta),
186   fhEleE(qa.fhEleE),fhElePt(qa.fhElePt),fhElePhi(qa.fhElePhi),fhEleEta(qa.fhEleEta),
187   fhPi0E(qa.fhPi0E),fhPi0Pt(qa.fhPi0Pt),fhPi0Phi(qa.fhPi0Phi),fhPi0Eta(qa.fhPi0Eta), 
188   fhNeHadE(qa.fhNeHadE),fhNeHadPt(qa.fhNeHadPt),fhNeHadPhi(qa.fhNeHadPhi),fhNeHadEta(qa.fhNeHadEta), 
189   fhChHadE(qa.fhChHadE),fhChHadPt(qa.fhChHadPt),fhChHadPhi(qa.fhChHadPhi),fhChHadEta(qa.fhChHadEta),
190   fhGamECharged(qa.fhGamECharged),fhGamPtCharged(qa.fhGamPtCharged),fhGamPhiCharged(qa.fhGamPhiCharged),fhGamEtaCharged(qa.fhGamEtaCharged), 
191   fhEleECharged(qa.fhEleECharged),fhElePtCharged(qa.fhElePtCharged),fhElePhiCharged(qa.fhElePhiCharged),fhEleEtaCharged(qa.fhEleEtaCharged),
192   fhPi0ECharged(qa.fhPi0ECharged),fhPi0PtCharged(qa.fhPi0PtCharged),fhPi0PhiCharged(qa.fhPi0PhiCharged),fhPi0EtaCharged(qa.fhPi0EtaCharged), 
193   fhNeHadECharged(qa.fhNeHadECharged),fhNeHadPtCharged(qa.fhNeHadPtCharged),fhNeHadPhiCharged(qa.fhNeHadPhiCharged),fhNeHadEtaCharged(qa.fhNeHadEtaCharged), 
194   fhChHadECharged(qa.fhChHadECharged),fhChHadPtCharged(qa.fhChHadPtCharged),fhChHadPhiCharged(qa.fhChHadPhiCharged),fhChHadEtaCharged(qa.fhChHadEtaCharged),
195   fhGenGamAccE(qa.fhGenGamAccE),fhGenGamAccPt(qa.fhGenGamAccPt),fhGenGamAccEta(qa.fhGenGamAccEta),fhGenGamAccPhi(qa.fhGenGamAccPhi),
196   fhGenPi0AccE(qa.fhGenPi0AccE),fhGenPi0AccPt(qa.fhGenPi0AccPt),fhGenPi0AccEta(qa.fhGenPi0AccEta),fhGenPi0AccPhi(qa.fhGenPi0AccPhi),
197   fh1pOverE(qa.fh1pOverE),fh1dR(qa.fh1dR),fh2EledEdx(qa.fh2EledEdx), fh2MatchdEdx(qa.fh2MatchdEdx),
198   fhMCEle1pOverE(qa.fhMCEle1pOverE),fhMCEle1dR(qa.fhMCEle1dR), fhMCEle2MatchdEdx(qa.fhMCEle2MatchdEdx),
199   fhMCChHad1pOverE(qa.fhMCChHad1pOverE),fhMCChHad1dR(qa.fhMCChHad1dR), fhMCChHad2MatchdEdx(qa.fhMCChHad2MatchdEdx),
200   fhMCNeutral1pOverE(qa.fhMCNeutral1pOverE),fhMCNeutral1dR(qa.fhMCNeutral1dR), fhMCNeutral2MatchdEdx(qa.fhMCNeutral2MatchdEdx),
201   fh1pOverER02(qa.fh1pOverER02), fhMCEle1pOverER02(qa.fhMCEle1pOverER02),fhMCChHad1pOverER02(qa.fhMCChHad1pOverER02), fhMCNeutral1pOverER02(qa.fhMCNeutral1pOverER02)
202 {
203   // cpy ctor
204   
205 }
206 */
207 //________________________________________________________________________________________________________________________________________________
208 //AliAnaCalorimeterQA::~AliAnaCalorimeterQA() {
209         // dtor
210         
211 //}
212
213 //________________________________________________________________________
214 TObjString *  AliAnaCalorimeterQA::GetAnalysisCuts()
215 {       
216         //Save parameters used for analysis
217         TString parList ; //this will be list of parameters used for this analysis.
218         char onePar[255] ;
219         
220         sprintf(onePar,"--- AliAnaCalorimeterQA ---\n") ;
221         parList+=onePar ;       
222         sprintf(onePar,"Calorimeter: %s\n",fCalorimeter.Data()) ;
223         parList+=onePar ;
224         sprintf(onePar,"Time Cut : %2.2f < T < %2.2f ns  \n",fTimeCutMin, fTimeCutMax) ;
225         parList+=onePar ;
226                 
227         //Get parameters set in base class.
228         //parList += GetBaseParametersList() ;
229         
230         //Get parameters set in FiducialCut class (not available yet)
231         //parlist += GetFidCut()->GetFidCutParametersList() 
232         
233         return new TObjString(parList) ;
234 }
235
236
237 //________________________________________________________________________
238 TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
239 {  
240         // Create histograms to be saved in output file and 
241         // store them in outputContainer
242         
243         TList * outputContainer = new TList() ; 
244         outputContainer->SetName("QAHistos") ; 
245         
246         //Histograms
247         Int_t nptbins     = GetHistoPtBins();           Float_t ptmax     = GetHistoPtMax();           Float_t ptmin     = GetHistoPtMin();
248         Int_t nphibins    = GetHistoPhiBins();              Float_t phimax    = GetHistoPhiMax();          Float_t phimin    = GetHistoPhiMin();
249         Int_t netabins    = GetHistoEtaBins();          Float_t etamax    = GetHistoEtaMax();          Float_t etamin    = GetHistoEtaMin();    
250         Int_t nmassbins   = GetHistoMassBins();         Float_t massmax   = GetHistoMassMax();         Float_t massmin   = GetHistoMassMin();
251         Int_t nasymbins   = GetHistoAsymmetryBins();    Float_t asymmax   = GetHistoAsymmetryMax();    Float_t asymmin   = GetHistoAsymmetryMin();
252         Int_t nPoverEbins = GetHistoPOverEBins();       Float_t pOverEmax = GetHistoPOverEMax();       Float_t pOverEmin = GetHistoPOverEMin();
253         Int_t ndedxbins   = GetHistodEdxBins();         Float_t dedxmax   = GetHistodEdxMax();         Float_t dedxmin   = GetHistodEdxMin();
254         Int_t ndRbins     = GetHistodRBins();           Float_t dRmax     = GetHistodRMax();           Float_t dRmin     = GetHistodRMin();
255         Int_t ntimebins   = GetHistoTimeBins();         Float_t timemax   = GetHistoTimeMax();         Float_t timemin   = GetHistoTimeMin();       
256         Int_t nbins       = GetHistoNClusterCellBins(); Int_t nmax        = GetHistoNClusterCellMax(); Int_t nmin        = GetHistoNClusterCellMin(); 
257         Int_t nratiobins  = GetHistoRatioBins();        Float_t ratiomax  = GetHistoRatioMax();        Float_t ratiomin  = GetHistoRatioMin();
258         Int_t nvdistbins  = GetHistoVertexDistBins();   Float_t vdistmax  = GetHistoVertexDistMax();   Float_t vdistmin  = GetHistoVertexDistMin();
259         Int_t rbins       = GetHistoRBins();            Float_t rmax      = GetHistoRMax();            Float_t rmin      = GetHistoRMin(); 
260         Int_t xbins       = GetHistoXBins();            Float_t xmax      = GetHistoXMax();            Float_t xmin      = GetHistoXMin(); 
261         Int_t ybins       = GetHistoYBins();            Float_t ymax      = GetHistoYMax();            Float_t ymin      = GetHistoYMin(); 
262         Int_t zbins       = GetHistoZBins();            Float_t zmax      = GetHistoZMax();            Float_t zmin      = GetHistoZMin(); 
263         Int_t ssbins      = GetHistoShowerShapeBins();  Float_t ssmax     = GetHistoShowerShapeMax();  Float_t ssmin     = GetHistoShowerShapeMin();
264         
265         //EMCAL
266         Int_t colmax = 48;
267         Int_t rowmax = 24;
268         fNRCU   = 2 ;
269         //PHOS
270         if(fCalorimeter=="PHOS"){
271                 colmax = 56;
272                 rowmax = 64;
273                 fNRCU   = 4 ;
274         }
275         
276         
277         fhE  = new TH1F ("hE","E reconstructed clusters ", nptbins,ptmin,ptmax); 
278         fhE->SetXTitle("E (GeV)");
279         outputContainer->Add(fhE);
280         
281         fhPt  = new TH1F ("hPt","p_{T} reconstructed clusters", nptbins,ptmin,ptmax); 
282         fhPt->SetXTitle("p_{T} (GeV/c)");
283         outputContainer->Add(fhPt);
284         
285         fhPhi  = new TH1F ("hPhi","#phi reconstructed clusters ",nphibins,phimin,phimax); 
286         fhPhi->SetXTitle("#phi (rad)");
287         outputContainer->Add(fhPhi);
288         
289         fhEta  = new TH1F ("hEta","#eta reconstructed clusters ",netabins,etamin,etamax); 
290         fhEta->SetXTitle("#eta ");
291         outputContainer->Add(fhEta);
292         
293         fhEtaPhiE  = new TH3F ("hEtaPhiE","#eta vs #phi vs energy, reconstructed clusters",
294                                                    netabins,etamin,etamax,nphibins,phimin,phimax,nptbins,ptmin,ptmax); 
295         fhEtaPhiE->SetXTitle("#eta ");
296         fhEtaPhiE->SetYTitle("#phi (rad)");
297         fhEtaPhiE->SetZTitle("E (GeV) ");
298         outputContainer->Add(fhEtaPhiE);
299         
300         fhClusterTimeEnergy  = new TH2F ("hClusterTimeEnergy","energy vs TOF, reconstructed clusters",
301                                                    nptbins,ptmin,ptmax, ntimebins,timemin,timemax); 
302         fhClusterTimeEnergy->SetXTitle("E (GeV) ");
303         fhClusterTimeEnergy->SetYTitle("TOF (ns)");
304         outputContainer->Add(fhClusterTimeEnergy);
305         
306         
307         //Shower shape
308         fhLambda  = new TH3F ("hLambda","#lambda_{0}^{2} vs #lambda_{1}^{2} vs energy, reconstructed clusters",
309                                                    ssbins,ssmin,ssmax,ssbins,ssmin,ssmax,nptbins,ptmin,ptmax); 
310         fhLambda->SetXTitle("#lambda_{0}^{2}  ");
311         fhLambda->SetYTitle("#lambda_{1}^{2}  ");
312         fhLambda->SetZTitle("E (GeV) ");
313         outputContainer->Add(fhLambda);
314         
315         fhDispersion  = new TH2F ("hDispersion"," dispersion vs energy, reconstructed clusters",
316                                                   ssbins,ssmin,ssmax,nptbins,ptmin,ptmax); 
317         fhDispersion->SetXTitle("Dispersion  ");
318         fhDispersion->SetYTitle("E (GeV) ");
319         outputContainer->Add(fhDispersion);
320         
321         //Track Matching
322
323         fhECharged  = new TH1F ("hECharged","E reconstructed clusters, matched with track", nptbins,ptmin,ptmax); 
324         fhECharged->SetXTitle("E (GeV)");
325         outputContainer->Add(fhECharged);
326         
327         fhPtCharged  = new TH1F ("hPtCharged","p_{T} reconstructed clusters, matched with track", nptbins,ptmin,ptmax); 
328         fhPtCharged->SetXTitle("p_{T} (GeV/c)");
329         outputContainer->Add(fhPtCharged);
330         
331         fhPhiCharged  = new TH1F ("hPhiCharged","#phi reconstructed clusters, matched with track",nphibins,phimin,phimax); 
332         fhPhiCharged->SetXTitle("#phi (rad)");
333         outputContainer->Add(fhPhiCharged);
334         
335         fhEtaCharged  = new TH1F ("hEtaCharged","#eta reconstructed clusters, matched with track",netabins,etamin,etamax); 
336         fhEtaCharged->SetXTitle("#eta ");
337         outputContainer->Add(fhEtaCharged);
338         
339         fhEtaPhiECharged  = new TH3F ("hEtaPhiECharged","#eta vs #phi, reconstructed clusters, matched with track",
340                                                                   netabins,etamin,etamax,nphibins,phimin,phimax,nptbins,ptmin,ptmax); 
341         fhEtaPhiECharged->SetXTitle("#eta ");
342         fhEtaPhiECharged->SetYTitle("#phi ");
343         fhEtaPhiECharged->SetZTitle("E (GeV) ");
344         outputContainer->Add(fhEtaPhiECharged); 
345
346
347 //      fhEChargedNoOut  = new TH1F ("hEChargedNoOut","E reconstructed clusters, matched with track, no output track params", nptbins,ptmin,ptmax);                                     
348 //      fhEChargedNoOut->SetXTitle("E (GeV)");                                                                                                                                          
349 //      outputContainer->Add(fhEChargedNoOut);                                                                                                                                         
350 //                                                                                                                                                                      
351 //      fhPtChargedNoOut  = new TH1F ("hPtChargedNoOut","p_{T} reconstructed clusters, matched with track, no output track params", nptbins,ptmin,ptmax);                               
352 //      fhPtChargedNoOut->SetXTitle("p_{T} (GeV/c)");                                                                                                                               
353 //      outputContainer->Add(fhPtChargedNoOut);                                                                                                                                       
354 //                                                                                                                                                                              
355 //      fhPhiChargedNoOut  = new TH1F ("hPhiChargedNoOut","#phi reconstructed clusters, matched with track, no output track params",nphibins,phimin,phimax);                    
356 //      fhPhiChargedNoOut->SetXTitle("#phi (rad)");                                                                                                                               
357 //      outputContainer->Add(fhPhiChargedNoOut);                                                                                                                        
358 //                                                                                                                                                                        
359 //      fhEtaChargedNoOut  = new TH1F ("hEtaChargedNoOut","#eta reconstructed clusters, matched with track, no output track params",netabins,etamin,etamax);               
360 //      fhEtaChargedNoOut->SetXTitle("#eta ");                                                                                                                           
361 //      outputContainer->Add(fhEtaChargedNoOut);                                                                                                                             
362 //                                                                                                                                                                            
363 //      fhEtaPhiChargedNoOut  = new TH2F ("hEtaPhiChargedNoOut","#eta vs #phi, reconstructed clusters, matched with track, no output track params",netabins,etamin,etamax,nphibins,phimin,phimax); 
364 //      fhEtaPhiChargedNoOut->SetXTitle("#eta ");                                                                                                    
365 //      fhEtaPhiChargedNoOut->SetYTitle("#phi ");                                                                                                                       
366 //      outputContainer->Add(fhEtaPhiChargedNoOut);     
367
368         fh1pOverE = new TH2F("h1pOverE","TRACK matches p/E",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
369         fh1pOverE->SetYTitle("p/E");
370         fh1pOverE->SetXTitle("p_{T} (GeV/c)");
371         outputContainer->Add(fh1pOverE);
372         
373         fh1dR = new TH1F("h1dR","TRACK matches dR",ndRbins,dRmin,dRmax);
374         fh1dR->SetXTitle("#Delta R (rad)");
375         outputContainer->Add(fh1dR) ;
376         
377         fh2MatchdEdx = new TH2F("h2MatchdEdx","dE/dx vs. p for all matches",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
378         fh2MatchdEdx->SetXTitle("p (GeV/c)");
379         fh2MatchdEdx->SetYTitle("<dE/dx>");
380         outputContainer->Add(fh2MatchdEdx);
381         
382         fh2EledEdx = new TH2F("h2EledEdx","dE/dx vs. p for electrons",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
383         fh2EledEdx->SetXTitle("p (GeV/c)");
384         fh2EledEdx->SetYTitle("<dE/dx>");
385         outputContainer->Add(fh2EledEdx) ;
386         
387         fh1pOverER02 = new TH2F("h1pOverER02","TRACK matches p/E, all",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
388         fh1pOverER02->SetYTitle("p/E");
389         fh1pOverER02->SetXTitle("p_{T} (GeV/c)");
390         outputContainer->Add(fh1pOverER02);     
391         
392         fhIM  = new TH2F ("hIM","Cluster pairs Invariant mass vs reconstructed pair energy",nptbins,ptmin,ptmax,nmassbins,massmin,massmax); 
393         fhIM->SetXTitle("p_{T, cluster pairs} (GeV) ");
394         fhIM->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
395         outputContainer->Add(fhIM);
396         
397         fhIMCellCut  = new TH2F ("hIMCellCut","Cluster (n cell > 1) pairs Invariant mass vs reconstructed pair energy",nptbins,ptmin,ptmax,nmassbins,massmin,massmax); 
398         fhIMCellCut->SetXTitle("p_{T, cluster pairs} (GeV) ");
399         fhIMCellCut->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
400         outputContainer->Add(fhIMCellCut);
401         
402         fhAsym  = new TH2F ("hAssym","Cluster pairs Asymmetry vs reconstructed pair energy",nptbins,ptmin,ptmax,nasymbins,asymmin,asymmax); 
403         fhAsym->SetXTitle("p_{T, cluster pairs} (GeV) ");
404         fhAsym->SetYTitle("Asymmetry");
405         outputContainer->Add(fhAsym);   
406         
407         fhNCellsPerCluster  = new TH3F ("hNCellsPerCluster","# cells per cluster vs energy vs #eta",nptbins,ptmin,ptmax, nbins,nmin,nmax, netabins,etamin,etamax); 
408         fhNCellsPerCluster->SetXTitle("E (GeV)");
409         fhNCellsPerCluster->SetYTitle("n cells");
410         fhNCellsPerCluster->SetZTitle("#eta");
411         outputContainer->Add(fhNCellsPerCluster);
412         
413         
414         fhNCellsPerClusterMIP  = new TH3F ("hNCellsPerClusterMIP","# cells per cluster vs energy vs #eta, smaller bin for MIP search", 
415                                                                                 100,0.,1., 6,0,5,netabins,etamin,etamax); 
416         fhNCellsPerClusterMIP->SetXTitle("E (GeV)");
417         fhNCellsPerClusterMIP->SetYTitle("n cells");
418         fhNCellsPerClusterMIP->SetZTitle("#eta");
419         outputContainer->Add(fhNCellsPerClusterMIP);
420         
421         
422         fhNCellsPerClusterMIPCharged  = new TH3F ("hNCellsPerClusterMIPCharged","# cells per track-matched cluster vs energy vs #eta, smaller bin for MIP search", 
423                                                                                                 100,0.,1., 6,0,5,netabins,etamin,etamax); 
424         fhNCellsPerClusterMIPCharged->SetXTitle("E (GeV)");
425         fhNCellsPerClusterMIPCharged->SetYTitle("n cells");
426         fhNCellsPerClusterMIPCharged->SetZTitle("#eta");
427         outputContainer->Add(fhNCellsPerClusterMIPCharged);
428         
429         
430         fhNClusters  = new TH1F ("hNClusters","# clusters", nbins,nmin,nmax); 
431         fhNClusters->SetXTitle("number of clusters");
432         outputContainer->Add(fhNClusters);
433         
434         fhRNCells  = new TH2F ("hRNCells","Cluster R position vs N Clusters per Cell",rbins,rmin,rmax,nbins,nmin,nmax); 
435         fhRNCells->SetXTitle("r = #sqrt{x^{2}+y^{2}} (cm)");
436         fhRNCells->SetYTitle("N cells per cluster");
437         outputContainer->Add(fhRNCells);
438         
439         fhXNCells  = new TH2F ("hXNCells","Cluster X position vs N Clusters per Cell",xbins,xmin,xmax,nbins,nmin,nmax); 
440         fhXNCells->SetXTitle("x (cm)");
441         fhXNCells->SetYTitle("N cells per cluster");
442         outputContainer->Add(fhXNCells);
443         
444         fhYNCells  = new TH2F ("hYNCells","Cluster Y position vs N Clusters per Cell",ybins,ymin,ymax,nbins,nmin,nmax); 
445         fhYNCells->SetXTitle("y (cm)");
446         fhYNCells->SetYTitle("N cells per cluster");
447         outputContainer->Add(fhYNCells);
448         
449         fhZNCells  = new TH2F ("hZNCells","Cluster Z position vs N Clusters per Cell",zbins,zmin,zmax,nbins,nmin,nmax); 
450         fhZNCells->SetXTitle("z (cm)");
451         fhZNCells->SetYTitle("N cells per cluster");
452         outputContainer->Add(fhZNCells);
453         
454         fhRE  = new TH2F ("hRE","Cluster R position vs cluster energy",rbins,rmin,rmax,nptbins,ptmin,ptmax); 
455         fhRE->SetXTitle("r = #sqrt{x^{2}+y^{2}} (cm)");
456         fhRE->SetYTitle("E (GeV)");
457         outputContainer->Add(fhRE);
458         
459         fhXE  = new TH2F ("hXE","Cluster X position vs cluster energy",xbins,xmin,xmax,nptbins,ptmin,ptmax); 
460         fhXE->SetXTitle("x (cm)");
461         fhXE->SetYTitle("E (GeV)");
462         outputContainer->Add(fhXE);
463
464         fhYE  = new TH2F ("hYE","Cluster Y position vs cluster energy",ybins,ymin,ymax,nptbins,ptmin,ptmax); 
465         fhYE->SetXTitle("y (cm)");
466         fhYE->SetYTitle("E (GeV)");
467         outputContainer->Add(fhYE);
468         
469         fhZE  = new TH2F ("hZE","Cluster Z position vs cluster energy",zbins,zmin,zmax,nptbins,ptmin,ptmax); 
470         fhZE->SetXTitle("z (cm)");
471         fhZE->SetYTitle("E (GeV)");
472         outputContainer->Add(fhZE);
473         
474         fhXYZ  = new TH3F ("hXYZ","Cluster: x vs y vs z",xbins,xmin,xmax,ybins,ymin,ymax,zbins,zmin,zmax); 
475         fhXYZ->SetXTitle("x (cm)");
476         fhXYZ->SetYTitle("y (cm)");
477         fhXYZ->SetZTitle("z (cm) ");
478         outputContainer->Add(fhXYZ);
479                 
480         fhRCellE  = new TH2F ("hRCellE","Cell R position vs cell energy",rbins,rmin,rmax,nptbins,ptmin,ptmax); 
481         fhRCellE->SetXTitle("r = #sqrt{x^{2}+y^{2}} (cm)");
482         fhRCellE->SetYTitle("E (GeV)");
483         outputContainer->Add(fhRCellE);
484         
485         fhXCellE  = new TH2F ("hXCellE","Cell X position vs cell energy",xbins,xmin,xmax,nptbins,ptmin,ptmax); 
486         fhXCellE->SetXTitle("x (cm)");
487         fhXCellE->SetYTitle("E (GeV)");
488         outputContainer->Add(fhXCellE);
489
490         fhYCellE  = new TH2F ("hYCellE","Cell Y position vs cell energy",ybins,ymin,ymax,nptbins,ptmin,ptmax); 
491         fhYCellE->SetXTitle("y (cm)");
492         fhYCellE->SetYTitle("E (GeV)");
493         outputContainer->Add(fhYCellE);
494         
495         fhZCellE  = new TH2F ("hZCellE","Cell Z position vs cell energy",zbins,zmin,zmax,nptbins,ptmin,ptmax); 
496         fhZCellE->SetXTitle("z (cm)");
497         fhZCellE->SetYTitle("E (GeV)");
498         outputContainer->Add(fhZCellE);
499         
500         fhXYZCell  = new TH3F ("hXYZCell","Cell : x vs y vs z",xbins,xmin,xmax,ybins,ymin,ymax,zbins,zmin,zmax); 
501         fhXYZCell->SetXTitle("x (cm)");
502         fhXYZCell->SetYTitle("y (cm)");
503         fhXYZCell->SetZTitle("z (cm)");
504         outputContainer->Add(fhXYZCell);
505
506
507         Float_t dx = TMath::Abs(xmin)+TMath::Abs(xmax);
508         Float_t dy = TMath::Abs(ymin)+TMath::Abs(ymax);
509         Float_t dz = TMath::Abs(zmin)+TMath::Abs(zmax);
510         Float_t dr = TMath::Abs(rmin)+TMath::Abs(rmax);
511
512         fhDeltaCellClusterRNCells  = new TH2F ("hDeltaCellClusterRNCells","Cluster-Cell R position vs N Clusters per Cell",rbins*2,-dr,dr,nbins,nmin,nmax); 
513         fhDeltaCellClusterRNCells->SetXTitle("r = #sqrt{x^{2}+y^{2}} (cm)");
514         fhDeltaCellClusterRNCells->SetYTitle("N cells per cluster");
515         outputContainer->Add(fhDeltaCellClusterRNCells);
516         
517         fhDeltaCellClusterXNCells  = new TH2F ("hDeltaCellClusterXNCells","Cluster-Cell X position vs N Clusters per Cell",xbins*2,-dx,dx,nbins,nmin,nmax); 
518         fhDeltaCellClusterXNCells->SetXTitle("x (cm)");
519         fhDeltaCellClusterXNCells->SetYTitle("N cells per cluster");
520         outputContainer->Add(fhDeltaCellClusterXNCells);
521         
522         fhDeltaCellClusterYNCells  = new TH2F ("hDeltaCellClusterYNCells","Cluster-Cell Y position vs N Clusters per Cell",ybins*2,-dy,dy,nbins,nmin,nmax); 
523         fhDeltaCellClusterYNCells->SetXTitle("y (cm)");
524         fhDeltaCellClusterYNCells->SetYTitle("N cells per cluster");
525         outputContainer->Add(fhDeltaCellClusterYNCells);
526         
527         fhDeltaCellClusterZNCells  = new TH2F ("hDeltaCellClusterZNCells","Cluster-Cell Z position vs N Clusters per Cell",zbins*2,-dz,dz,nbins,nmin,nmax); 
528         fhDeltaCellClusterZNCells->SetXTitle("z (cm)");
529         fhDeltaCellClusterZNCells->SetYTitle("N cells per cluster");
530         outputContainer->Add(fhDeltaCellClusterZNCells);
531         
532         fhDeltaCellClusterRE  = new TH2F ("hDeltaCellClusterRE","Cluster-Cell R position vs cluster energy",rbins*2,-dr,dr,nptbins,ptmin,ptmax); 
533         fhDeltaCellClusterRE->SetXTitle("r = #sqrt{x^{2}+y^{2}} (cm)");
534         fhDeltaCellClusterRE->SetYTitle("E (GeV)");
535         outputContainer->Add(fhDeltaCellClusterRE);             
536         
537         fhDeltaCellClusterXE  = new TH2F ("hDeltaCellClusterXE","Cluster-Cell X position vs cluster energy",xbins*2,-dx,dx,nptbins,ptmin,ptmax); 
538         fhDeltaCellClusterXE->SetXTitle("x (cm)");
539         fhDeltaCellClusterXE->SetYTitle("E (GeV)");
540         outputContainer->Add(fhDeltaCellClusterXE);
541         
542         fhDeltaCellClusterYE  = new TH2F ("hDeltaCellClusterYE","Cluster-Cell Y position vs cluster energy",ybins*2,-dy,dy,nptbins,ptmin,ptmax); 
543         fhDeltaCellClusterYE->SetXTitle("y (cm)");
544         fhDeltaCellClusterYE->SetYTitle("E (GeV)");
545         outputContainer->Add(fhDeltaCellClusterYE);
546         
547         fhDeltaCellClusterZE  = new TH2F ("hDeltaCellClusterZE","Cluster-Cell Z position vs cluster energy",zbins*2,-dz,dz,nptbins,ptmin,ptmax); 
548         fhDeltaCellClusterZE->SetXTitle("z (cm)");
549         fhDeltaCellClusterZE->SetYTitle("E (GeV)");
550         outputContainer->Add(fhDeltaCellClusterZE);
551         
552         fhEtaPhiAmp  = new TH3F ("hEtaPhiAmp","Cell #eta vs cell #phi vs cell energy",netabins,etamin,etamax,nphibins,phimin,phimax,nptbins,ptmin,ptmax); 
553         fhEtaPhiAmp->SetXTitle("#eta ");
554         fhEtaPhiAmp->SetYTitle("#phi (rad)");
555         fhEtaPhiAmp->SetZTitle("E (GeV) ");
556         outputContainer->Add(fhEtaPhiAmp);              
557
558
559         //Calo cells
560         fhNCells  = new TH1F ("hNCells","# cells", colmax*rowmax*fNModules,0,colmax*rowmax*fNModules); 
561         fhNCells->SetXTitle("n cells");
562         outputContainer->Add(fhNCells);
563     
564         fhAmplitude  = new TH1F ("hAmplitude","Cell Energy", nptbins*2,ptmin,ptmax); 
565         fhAmplitude->SetXTitle("Cell Energy (GeV)");
566         outputContainer->Add(fhAmplitude);
567         Int_t nb = 5000;
568         Float_t ptmax2 = 5.;
569         if(fCalorimeter == "EMCAL") ptmax2 = 20.;
570         fhAmpId  = new TH2F ("hAmpId","Cell Energy", nb,0,ptmax2,rowmax*colmax*fNModules,0,rowmax*colmax*fNModules); 
571         fhAmpId->SetXTitle("Cell Energy (GeV)");
572         outputContainer->Add(fhAmpId);
573         
574         
575         //Cell Time histograms, time only available in ESDs
576         if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
577                 
578                 fhCellTimeSpreadRespectToCellMax = new TH1F ("hCellTimeSpreadRespectToCellMax","t_{cell max}-t_{cell i} per cluster", 100,-200,200); 
579                 fhCellTimeSpreadRespectToCellMax->SetXTitle("#Delta t (ns)");
580                 outputContainer->Add(fhCellTimeSpreadRespectToCellMax);
581                 
582                 fhCellIdCellLargeTimeSpread= new TH1F ("hCellIdCellLargeTimeSpread","", colmax*rowmax*fNModules,0,colmax*rowmax*fNModules); 
583                 fhCellIdCellLargeTimeSpread->SetXTitle("Absolute Cell Id");
584                 outputContainer->Add(fhCellIdCellLargeTimeSpread);
585                 
586                 fhTime  = new TH1F ("hTime","Cell Time",ntimebins,timemin,timemax); 
587                 fhTime->SetXTitle("Cell Time (ns)");
588                 outputContainer->Add(fhTime);
589
590                 fhTimeId  = new TH2F ("hTimeId","Cell Time vs Absolute Id",ntimebins,timemin,timemax,rowmax*colmax*fNModules,0,rowmax*colmax*fNModules); 
591                 fhTimeId->SetXTitle("Cell Time (ns)");
592                 fhTimeId->SetYTitle("Cell Absolute Id");
593                 outputContainer->Add(fhTimeId);
594         
595                 fhTimeAmp  = new TH2F ("hTimeAmp","Cell Time vs Cell Energy",nptbins*2,ptmin,ptmax,ntimebins,timemin,timemax); 
596                 fhTimeAmp->SetYTitle("Cell Time (ns)");
597                 fhTimeAmp->SetXTitle("Cell Energy (GeV)");
598                 outputContainer->Add(fhTimeAmp);
599                 
600 //              fhT0Time  = new TH1F ("hT0Time","Cell Time",ntimebins,timemin,timemax); 
601 //              fhT0Time->SetXTitle("T_{0} - T_{EMCal} (ns)");
602 //              outputContainer->Add(fhT0Time);
603 //              
604 //              fhT0TimeId  = new TH2F ("hT0TimeId","Cell Time vs Absolute Id",ntimebins,timemin,timemax,rowmax*colmax*fNModules,0,rowmax*colmax*fNModules); 
605 //              fhT0TimeId->SetXTitle("T_{0} - T_{EMCal} (ns)");
606 //              fhT0TimeId->SetYTitle("Cell Absolute Id");
607 //              outputContainer->Add(fhT0TimeId);
608 //              
609 //              fhT0TimeAmp  = new TH2F ("hT0TimeAmp","Cell Time vs Cell Energy",nptbins*2,ptmin,ptmax,ntimebins,timemin,timemax); 
610 //              fhT0TimeAmp->SetYTitle("T_{0} - T_{EMCal} (ns)");
611 //              fhT0TimeAmp->SetXTitle("Cell Energy (GeV)");
612 //              outputContainer->Add(fhT0TimeAmp);
613         }
614         
615         
616         
617         if(fCorrelateCalos){
618                 fhCaloCorrNClusters  = new TH2F ("hCaloCorrNClusters","# clusters in EMCAL vs PHOS", nbins,nmin,nmax,nbins,nmin,nmax); 
619                 fhCaloCorrNClusters->SetXTitle("number of clusters in EMCAL");
620                 fhCaloCorrNClusters->SetYTitle("number of clusters in PHOS");
621                 outputContainer->Add(fhCaloCorrNClusters);
622         
623                 fhCaloCorrEClusters  = new TH2F ("hCaloCorrEClusters","summed energy of clusters in EMCAL vs PHOS", nptbins*2,ptmin,ptmax*2,nptbins,ptmin,ptmax*2); 
624                 fhCaloCorrEClusters->SetXTitle("#Sigma E of clusters in EMCAL (GeV)");
625                 fhCaloCorrEClusters->SetYTitle("#Sigma E of clusters in PHOS (GeV)");
626                 outputContainer->Add(fhCaloCorrEClusters);
627         
628                 fhCaloCorrNCells  = new TH2F ("hCaloCorrNCells","# Cells in EMCAL vs PHOS", nbins,nmin,nmax, nbins,nmin,nmax); 
629                 fhCaloCorrNCells->SetXTitle("number of Cells in EMCAL");
630                 fhCaloCorrNCells->SetYTitle("number of Cells in PHOS");
631                 outputContainer->Add(fhCaloCorrNCells);
632         
633                 fhCaloCorrECells  = new TH2F ("hCaloCorrECells","summed energy of Cells in EMCAL vs PHOS", nptbins*2,ptmin,ptmax*2,nptbins,ptmin,ptmax*2); 
634                 fhCaloCorrECells->SetXTitle("#Sigma E of Cells in EMCAL (GeV)");
635                 fhCaloCorrECells->SetYTitle("#Sigma E of Cells in PHOS (GeV)");
636                 outputContainer->Add(fhCaloCorrECells);
637         }//correlate calorimeters
638         
639         //Module histograms
640         fhEMod                 = new TH1F*[fNModules];
641         fhNClustersMod         = new TH1F*[fNModules];
642         fhNCellsPerClusterMod  = new TH2F*[fNModules];
643         fhNCellsMod            = new TH1F*[fNModules];
644         fhGridCellsMod         = new TH2F*[fNModules];
645         fhGridCellsEMod        = new TH2F*[fNModules];
646         fhGridCellsTimeMod     = new TH2F*[fNModules];
647         fhAmplitudeMod         = new TH1F*[fNModules];
648         if(fCalorimeter=="EMCAL")
649                 fhAmplitudeModFraction = new TH1F*[fNModules*3];
650
651         fhTimeAmpPerRCU        = new TH2F*[fNModules*fNRCU];
652         //fhT0TimeAmpPerRCU      = new TH2F*[fNModules*fNRCU];
653         //fhTimeCorrRCU          = new TH2F*[fNModules*fNRCU*fNModules*fNRCU];
654         
655         fhIMMod                = new TH2F*[fNModules];
656         fhIMCellCutMod         = new TH2F*[fNModules];
657
658         for(Int_t imod = 0; imod < fNModules; imod++){
659                 
660                 fhEMod[imod]  = new TH1F (Form("hE_Mod%d",imod),Form("Cluster reconstructed Energy in Module %d ",imod), nptbins,ptmin,ptmax); 
661                 fhEMod[imod]->SetXTitle("E (GeV)");
662                 outputContainer->Add(fhEMod[imod]);
663                 
664                 fhNClustersMod[imod]  = new TH1F (Form("hNClusters_Mod%d",imod),Form("# clusters in Module %d",imod), nbins,nmin,nmax); 
665                 fhNClustersMod[imod]->SetXTitle("number of clusters");
666                 outputContainer->Add(fhNClustersMod[imod]);
667                 
668                 fhNCellsPerClusterMod[imod]  = new TH2F (Form("hNCellsPerCluster_Mod%d",imod),
669                                                                                                  Form("# cells per cluster vs cluster energy in Module %d",imod), 
670                                                                                                  nptbins,ptmin,ptmax, nbins,nmin,nmax); 
671                 fhNCellsPerClusterMod[imod]->SetXTitle("E (GeV)");
672                 fhNCellsPerClusterMod[imod]->SetYTitle("n cells");
673                 outputContainer->Add(fhNCellsPerClusterMod[imod]);
674                 
675                 fhNCellsMod[imod]  = new TH1F (Form("hNCells_Mod%d",imod),Form("# cells in Module %d",imod), colmax*rowmax,0,colmax*rowmax); 
676                 fhNCellsMod[imod]->SetXTitle("n cells");
677                 outputContainer->Add(fhNCellsMod[imod]);
678                 fhGridCellsMod[imod]  = new TH2F (Form("hGridCells_Mod%d",imod),Form("Entries in grid of cells in Module %d",imod), 
679                                                                                   colmax+2,-1.5,colmax+0.5, rowmax+2,-1.5,rowmax+0.5); 
680                 fhGridCellsMod[imod]->SetYTitle("row (phi direction)");
681                 fhGridCellsMod[imod]->SetXTitle("column (eta direction)");
682                 outputContainer->Add(fhGridCellsMod[imod]);
683
684                 fhGridCellsEMod[imod]  = new TH2F (Form("hGridCellsE_Mod%d",imod),Form("Accumulated energy in grid of cells in Module %d",imod), 
685                                                                                    colmax+2,-1.5,colmax+0.5, rowmax+2,-1.5,rowmax+0.5); 
686                 fhGridCellsEMod[imod]->SetYTitle("row (phi direction)");
687                 fhGridCellsEMod[imod]->SetXTitle("column (eta direction)");
688                 outputContainer->Add(fhGridCellsEMod[imod]);
689                 
690                 fhGridCellsTimeMod[imod]  = new TH2F (Form("hGridCellsTime_Mod%d",imod),Form("Accumulated time in grid of cells in Module %d, with E > 0.5 GeV",imod), 
691                                                                                    colmax+2,-1.5,colmax+0.5, rowmax+2,-1.5,rowmax+0.5); 
692                 fhGridCellsTimeMod[imod]->SetYTitle("row (phi direction)");
693                 fhGridCellsTimeMod[imod]->SetXTitle("column (eta direction)");
694                 outputContainer->Add(fhGridCellsTimeMod[imod]);
695                 
696                 fhAmplitudeMod[imod]  = new TH1F (Form("hAmplitude_Mod%d",imod),Form("Cell Energy in Module %d",imod), nptbins*2,ptmin,ptmax); 
697                 fhAmplitudeMod[imod]->SetXTitle("Cell Energy (GeV)");
698                 outputContainer->Add(fhAmplitudeMod[imod]);
699                 
700                 if(fCalorimeter == "EMCAL"){
701                         for(Int_t ifrac = 0; ifrac < 3; ifrac++){
702                                 fhAmplitudeModFraction[imod*3+ifrac]  = new TH1F (Form("hAmplitude_Mod%d_Frac%d",imod,ifrac),Form("Cell reconstructed Energy in Module %d, Fraction %d ",imod,ifrac), nptbins,ptmin,ptmax); 
703                                 fhAmplitudeModFraction[imod*3+ifrac]->SetXTitle("E (GeV)");
704                                 outputContainer->Add(fhAmplitudeModFraction[imod*3+ifrac]);
705                         }
706                         
707                 }
708                 
709                 for(Int_t ircu = 0; ircu < fNRCU; ircu++){
710                                 fhTimeAmpPerRCU[imod*fNRCU+ircu]  = new TH2F (Form("hTimeAmp_Mod%d_RCU%d",imod,ircu),
711                                                                                                                    Form("Cell Energy vs Cell Time in Module %d, RCU %d ",imod,ircu), 
712                                                                                                                    nptbins,ptmin,ptmax,ntimebins,timemin,timemax); 
713                                 fhTimeAmpPerRCU[imod*fNRCU+ircu]->SetXTitle("E (GeV)");
714                                 fhTimeAmpPerRCU[imod*fNRCU+ircu]->SetYTitle("time (ns)");
715                                 outputContainer->Add(fhTimeAmpPerRCU[imod*fNRCU+ircu]);
716                         
717 //                              fhT0TimeAmpPerRCU[imod*fNRCU+ircu]  = new TH2F (Form("hT0TimeAmp_Mod%d_RCU%d",imod,ircu),
718 //                                                                                                                        Form("Cell Energy vs T0-Cell Time in Module %d, RCU %d ",imod,ircu), 
719 //                                                                                                                        nptbins,ptmin,ptmax,ntimebins,timemin,timemax); 
720 //                              fhT0TimeAmpPerRCU[imod*fNRCU+ircu]->SetXTitle("E (GeV)");
721 //                              fhT0TimeAmpPerRCU[imod*fNRCU+ircu]->SetYTitle("T_{0} - T_{EMCal} (ns)");
722 //                              outputContainer->Add(fhT0TimeAmpPerRCU[imod*fNRCU+ircu]);
723 //                      
724                         
725 //                              for(Int_t imod2 = 0; imod2 < fNModules; imod2++){
726 //                                              for(Int_t ircu2 = 0; ircu2 < fNModules; ircu2++){
727 //                                                      Int_t index =  (imod2*fNRCU+ircu2)+(fNModules*fNRCU)*(ircu+imod)+fNRCU*fNModules*imod; 
728 //                                                      fhTimeCorrRCU[index]  = new TH2F (Form("hTimeCorrRCU_Mod%d_RCU%d_CompareTo_Mod%d_RCU%d",imod, ircu,imod2, ircu2),
729 //                                                                                                                                                      Form("Cell Energy > 0.3, Correlate cell Time in Module %d, RCU %d to Module %d, RCU %d",imod,ircu,imod2, ircu2),
730 //                                                                                                                                                      ntimebins,timemin,timemax,ntimebins,timemin,timemax); 
731 //                                                      fhTimeCorrRCU[index]->SetXTitle("Trigger Cell Time (ns)");
732 //                                                      fhTimeCorrRCU[index]->SetYTitle("Cell Time (ns)");
733 //                                                      outputContainer->Add(fhTimeCorrRCU[index]);
734 //                                              }
735 //                              }
736                 }
737                 
738                 
739                 fhIMMod[imod]  = new TH2F (Form("hIM_Mod%d",imod),
740                                                                    Form("Cluster pairs Invariant mass vs reconstructed pair energy in Module %d",imod),
741                                                                    nptbins,ptmin,ptmax,nmassbins,massmin,massmax); 
742                 fhIMMod[imod]->SetXTitle("p_{T, cluster pairs} (GeV) ");
743                 fhIMMod[imod]->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
744                 outputContainer->Add(fhIMMod[imod]);
745                                 
746                 fhIMCellCutMod[imod]  = new TH2F (Form("hIMCellCut_Mod%d",imod),
747                                                                    Form("Cluster (n cells > 1) pairs Invariant mass vs reconstructed pair energy in Module %d",imod),
748                                                                    nptbins,ptmin,ptmax,nmassbins,massmin,massmax); 
749                 fhIMCellCutMod[imod]->SetXTitle("p_{T, cluster pairs} (GeV) ");
750                 fhIMCellCutMod[imod]->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
751                 outputContainer->Add(fhIMCellCutMod[imod]);
752                 
753         }
754         
755         
756         //Monte Carlo Histograms
757         if(IsDataMC()){
758                 
759                 fhDeltaE  = new TH1F ("hDeltaE","MC - Reco E ", nptbins*2,-ptmax,ptmax); 
760                 fhDeltaE->SetXTitle("#Delta E (GeV)");
761                 outputContainer->Add(fhDeltaE);
762                 
763                 fhDeltaPt  = new TH1F ("hDeltaPt","MC - Reco p_{T} ", nptbins*2,-ptmax,ptmax); 
764                 fhDeltaPt->SetXTitle("#Delta p_{T} (GeV/c)");
765                 outputContainer->Add(fhDeltaPt);
766                 
767                 fhDeltaPhi  = new TH1F ("hDeltaPhi","MC - Reco #phi ",nphibins*2,-phimax,phimax); 
768                 fhDeltaPhi->SetXTitle("#Delta #phi (rad)");
769                 outputContainer->Add(fhDeltaPhi);
770                 
771                 fhDeltaEta  = new TH1F ("hDeltaEta","MC- Reco #eta",netabins*2,-etamax,etamax); 
772                 fhDeltaEta->SetXTitle("#Delta #eta ");
773                 outputContainer->Add(fhDeltaEta);
774                 
775                 fhRatioE  = new TH1F ("hRatioE","Reco/MC E ", nratiobins,ratiomin,ratiomax); 
776                 fhRatioE->SetXTitle("E_{reco}/E_{gen}");
777                 outputContainer->Add(fhRatioE);
778                 
779                 fhRatioPt  = new TH1F ("hRatioPt","Reco/MC p_{T} ", nratiobins,ratiomin,ratiomax); 
780                 fhRatioPt->SetXTitle("p_{T, reco}/p_{T, gen}");
781                 outputContainer->Add(fhRatioPt);
782                 
783                 fhRatioPhi  = new TH1F ("hRatioPhi","Reco/MC #phi ",nratiobins,ratiomin,ratiomax); 
784                 fhRatioPhi->SetXTitle("#phi_{reco}/#phi_{gen}");
785                 outputContainer->Add(fhRatioPhi);
786                 
787                 fhRatioEta  = new TH1F ("hRatioEta","Reco/MC #eta",nratiobins,ratiomin,ratiomax); 
788                 fhRatioEta->SetXTitle("#eta_{reco}/#eta_{gen} ");
789                 outputContainer->Add(fhRatioEta);
790                 
791                 fh2E  = new TH2F ("h2E","E distribution, reconstructed vs generated", nptbins,ptmin,ptmax,nptbins,ptmin,ptmax); 
792                 fh2E->SetXTitle("E_{rec} (GeV)");
793                 fh2E->SetYTitle("E_{gen} (GeV)");
794                 outputContainer->Add(fh2E);       
795                 
796                 fh2Pt  = new TH2F ("h2Pt","p_T distribution, reconstructed vs generated", nptbins,ptmin,ptmax,nptbins,ptmin,ptmax); 
797                 fh2Pt->SetXTitle("p_{T,rec} (GeV/c)");
798                 fh2Pt->SetYTitle("p_{T,gen} (GeV/c)");
799                 outputContainer->Add(fh2Pt);
800                 
801                 fh2Phi  = new TH2F ("h2Phi","#phi distribution, reconstructed vs generated", nphibins,phimin,phimax, nphibins,phimin,phimax); 
802                 fh2Phi->SetXTitle("#phi_{rec} (rad)");
803                 fh2Phi->SetYTitle("#phi_{gen} (rad)");
804                 outputContainer->Add(fh2Phi);
805                 
806                 fh2Eta  = new TH2F ("h2Eta","#eta distribution, reconstructed vs generated", netabins,etamin,etamax,netabins,etamin,etamax); 
807                 fh2Eta->SetXTitle("#eta_{rec} ");
808                 fh2Eta->SetYTitle("#eta_{gen} ");
809                 outputContainer->Add(fh2Eta);
810                 
811                 //Fill histos depending on origin of cluster
812                 fhGamE  = new TH2F ("hGamE","E reconstructed vs E generated from #gamma", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
813                 fhGamE->SetXTitle("E_{rec} (GeV)");
814                 fhGamE->SetXTitle("E_{gen} (GeV)");
815                 outputContainer->Add(fhGamE);
816                 
817                 fhGamPt  = new TH2F ("hGamPt","p_{T} reconstructed vs E generated from #gamma", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
818                 fhGamPt->SetXTitle("p_{T rec} (GeV/c)");
819                 fhGamPt->SetYTitle("p_{T gen} (GeV/c)");
820                 outputContainer->Add(fhGamPt);
821                 
822                 fhGamPhi  = new TH2F ("hGamPhi","#phi reconstructed vs E generated from #gamma",nphibins,phimin,phimax,nphibins,phimin,phimax); 
823                 fhGamPhi->SetXTitle("#phi_{rec} (rad)");
824                 fhGamPhi->SetYTitle("#phi_{gen} (rad)");
825                 outputContainer->Add(fhGamPhi);
826                 
827                 fhGamEta  = new TH2F ("hGamEta","#eta reconstructed vs E generated from #gamma",netabins,etamin,etamax,netabins,etamin,etamax); 
828                 fhGamEta->SetXTitle("#eta_{rec} ");
829                 fhGamEta->SetYTitle("#eta_{gen} ");
830                 outputContainer->Add(fhGamEta);
831                 
832                 fhGamDeltaE  = new TH1F ("hGamDeltaE","#gamma MC - Reco E ", nptbins*2,-ptmax,ptmax); 
833                 fhGamDeltaE->SetXTitle("#Delta E (GeV)");
834                 outputContainer->Add(fhGamDeltaE);
835                 
836                 fhGamDeltaPt  = new TH1F ("hGamDeltaPt","#gamma MC - Reco p_{T} ", nptbins*2,-ptmax,ptmax); 
837                 fhGamDeltaPt->SetXTitle("#Delta p_{T} (GeV/c)");
838                 outputContainer->Add(fhGamDeltaPt);
839                 
840                 fhGamDeltaPhi  = new TH1F ("hGamDeltaPhi","#gamma MC - Reco #phi ",nphibins*2,-phimax,phimax); 
841                 fhGamDeltaPhi->SetXTitle("#Delta #phi (rad)");
842                 outputContainer->Add(fhGamDeltaPhi);
843                 
844                 fhGamDeltaEta  = new TH1F ("hGamDeltaEta","#gamma MC- Reco #eta",netabins*2,-etamax,etamax); 
845                 fhGamDeltaEta->SetXTitle("#Delta #eta ");
846                 outputContainer->Add(fhGamDeltaEta);
847                 
848                 fhGamRatioE  = new TH1F ("hGamRatioE","#gamma Reco/MC E ", nratiobins,ratiomin,ratiomax); 
849                 fhGamRatioE->SetXTitle("E_{reco}/E_{gen}");
850                 outputContainer->Add(fhGamRatioE);
851                 
852                 fhGamRatioPt  = new TH1F ("hGamRatioPt","#gamma Reco/MC p_{T} ", nratiobins,ratiomin,ratiomax); 
853                 fhGamRatioPt->SetXTitle("p_{T, reco}/p_{T, gen}");
854                 outputContainer->Add(fhGamRatioPt);
855                 
856                 fhGamRatioPhi  = new TH1F ("hGamRatioPhi","#gamma Reco/MC #phi ",nratiobins,ratiomin,ratiomax); 
857                 fhGamRatioPhi->SetXTitle("#phi_{reco}/#phi_{gen}");
858                 outputContainer->Add(fhGamRatioPhi);
859                 
860                 fhGamRatioEta  = new TH1F ("hGamRatioEta","#gamma Reco/MC #eta",nratiobins,ratiomin,ratiomax); 
861                 fhGamRatioEta->SetXTitle("#eta_{reco}/#eta_{gen} ");
862                 outputContainer->Add(fhGamRatioEta);
863
864                 fhPi0E  = new TH2F ("hPi0E","E reconstructed vs E generated from #pi^{0}", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
865                 fhPi0E->SetXTitle("E_{rec} (GeV)");
866                 fhPi0E->SetYTitle("E_{gen} (GeV)");
867                 outputContainer->Add(fhPi0E);
868                 
869                 fhPi0Pt  = new TH2F ("hPi0Pt","p_{T} reconstructed vs E generated from #pi^{0}", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
870                 fhPi0Pt->SetXTitle("p_{T rec} (GeV/c)");
871                 fhPi0Pt->SetYTitle("p_{T gen} (GeV/c)");
872                 outputContainer->Add(fhPi0Pt);
873                 
874                 fhPi0Phi  = new TH2F ("hPi0Phi","#phi reconstructed vs E generated from #pi^{0}",nphibins,phimin,phimax,nphibins,phimin,phimax); 
875                 fhPi0Phi->SetXTitle("#phi_{rec} (rad)");
876                 fhPi0Phi->SetYTitle("#phi_{gen} (rad)");
877                 outputContainer->Add(fhPi0Phi);
878                 
879                 fhPi0Eta  = new TH2F ("hPi0Eta","#eta reconstructed vs E generated from #pi^{0}",netabins,etamin,etamax,netabins,etamin,etamax); 
880                 fhPi0Eta->SetXTitle("#eta_{rec} ");
881                 fhPi0Eta->SetYTitle("#eta_{gen} ");
882                 outputContainer->Add(fhPi0Eta);
883                 
884                 fhEleE  = new TH2F ("hEleE","E reconstructed vs E generated from e^{#pm}", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
885                 fhEleE->SetXTitle("E_{rec} (GeV)");
886                 fhEleE->SetXTitle("E_{gen} (GeV)");             
887                 outputContainer->Add(fhEleE);           
888                 
889                 fhElePt  = new TH2F ("hElePt","p_{T} reconstructed vs E generated from e^{#pm}", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
890                 fhElePt->SetXTitle("p_{T rec} (GeV/c)");
891                 fhElePt->SetYTitle("p_{T gen} (GeV/c)");
892                 outputContainer->Add(fhElePt);
893                 
894                 fhElePhi  = new TH2F ("hElePhi","#phi reconstructed vs E generated from e^{#pm}",nphibins,phimin,phimax,nphibins,phimin,phimax); 
895                 fhElePhi->SetXTitle("#phi_{rec} (rad)");
896                 fhElePhi->SetYTitle("#phi_{gen} (rad)");
897                 outputContainer->Add(fhElePhi);
898                 
899                 fhEleEta  = new TH2F ("hEleEta","#eta reconstructed vs E generated from e^{#pm}",netabins,etamin,etamax,netabins,etamin,etamax); 
900                 fhEleEta->SetXTitle("#eta_{rec} ");
901                 fhEleEta->SetYTitle("#eta_{gen} ");
902                 outputContainer->Add(fhEleEta);
903                 
904                 fhNeHadE  = new TH2F ("hNeHadE","E reconstructed vs E generated from neutral hadron", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
905                 fhNeHadE->SetXTitle("E_{rec} (GeV)");
906                 fhNeHadE->SetYTitle("E_{gen} (GeV)");
907                 outputContainer->Add(fhNeHadE);
908                 
909                 fhNeHadPt  = new TH2F ("hNeHadPt","p_{T} reconstructed vs E generated from neutral hadron", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
910                 fhNeHadPt->SetXTitle("p_{T rec} (GeV/c)");
911                 fhNeHadPt->SetYTitle("p_{T gen} (GeV/c)");
912                 outputContainer->Add(fhNeHadPt);
913                 
914                 fhNeHadPhi  = new TH2F ("hNeHadPhi","#phi reconstructed vs E generated from neutral hadron",nphibins,phimin,phimax,nphibins,phimin,phimax); 
915                 fhNeHadPhi->SetXTitle("#phi_{rec} (rad)");
916                 fhNeHadPhi->SetYTitle("#phi_{gen} (rad)");
917                 outputContainer->Add(fhNeHadPhi);
918                 
919                 fhNeHadEta  = new TH2F ("hNeHadEta","#eta reconstructed vs E generated from neutral hadron",netabins,etamin,etamax,netabins,etamin,etamax); 
920                 fhNeHadEta->SetXTitle("#eta_{rec} ");
921                 fhNeHadEta->SetYTitle("#eta_{gen} ");
922                 outputContainer->Add(fhNeHadEta);
923                 
924                 fhChHadE  = new TH2F ("hChHadE","E reconstructed vs E generated from charged hadron", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
925                 fhChHadE->SetXTitle("E_{rec} (GeV)");
926                 fhChHadE->SetYTitle("E_{gen} (GeV)");
927                 outputContainer->Add(fhChHadE);
928                 
929                 fhChHadPt  = new TH2F ("hChHadPt","p_{T} reconstructed vs E generated from charged hadron", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
930                 fhChHadPt->SetXTitle("p_{T rec} (GeV/c)");
931                 fhChHadPt->SetYTitle("p_{T gen} (GeV/c)");
932                 outputContainer->Add(fhChHadPt);
933                 
934                 fhChHadPhi  = new TH2F ("hChHadPhi","#phi reconstructed vs E generated from charged hadron",nphibins,phimin,phimax,nphibins,phimin,phimax); 
935                 fhChHadPhi->SetXTitle("#phi_{rec} (rad)");
936                 fhChHadPhi->SetYTitle("#phi_{gen} (rad)");
937                 outputContainer->Add(fhChHadPhi);
938                 
939                 fhChHadEta  = new TH2F ("hChHadEta","#eta reconstructed vs E generated from charged hadron",netabins,etamin,etamax,netabins,etamin,etamax); 
940                 fhChHadEta->SetXTitle("#eta_{rec} ");
941                 fhChHadEta->SetYTitle("#eta_{gen} ");
942                 outputContainer->Add(fhChHadEta);
943                 
944                 //Charged clusters
945                 
946                 fhGamECharged  = new TH2F ("hGamECharged","E reconstructed vs E generated from #gamma, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
947                 fhGamECharged->SetXTitle("E_{rec} (GeV)");
948                 fhGamECharged->SetXTitle("E_{gen} (GeV)");
949                 outputContainer->Add(fhGamECharged);
950                 
951                 fhGamPtCharged  = new TH2F ("hGamPtCharged","p_{T} reconstructed vs E generated from #gamma, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
952                 fhGamPtCharged->SetXTitle("p_{T rec} (GeV/c)");
953                 fhGamPtCharged->SetYTitle("p_{T gen} (GeV/c)");
954                 outputContainer->Add(fhGamPtCharged);
955                 
956                 fhGamPhiCharged  = new TH2F ("hGamPhiCharged","#phi reconstructed vs E generated from #gamma, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
957                 fhGamPhiCharged->SetXTitle("#phi_{rec} (rad)");
958                 fhGamPhiCharged->SetYTitle("#phi_{gen} (rad)");
959                 outputContainer->Add(fhGamPhiCharged);
960                 
961                 fhGamEtaCharged  = new TH2F ("hGamEtaCharged","#eta reconstructed vs E generated from #gamma, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
962                 fhGamEtaCharged->SetXTitle("#eta_{rec} ");
963                 fhGamEtaCharged->SetYTitle("#eta_{gen} ");
964                 outputContainer->Add(fhGamEtaCharged);
965                 
966                 fhPi0ECharged  = new TH2F ("hPi0ECharged","E reconstructed vs E generated from #pi^{0}, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
967                 fhPi0ECharged->SetXTitle("E_{rec} (GeV)");
968                 fhPi0ECharged->SetYTitle("E_{gen} (GeV)");
969                 outputContainer->Add(fhPi0ECharged);
970                 
971                 fhPi0PtCharged  = new TH2F ("hPi0PtCharged","p_{T} reconstructed vs E generated from #pi^{0}, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
972                 fhPi0PtCharged->SetXTitle("p_{T rec} (GeV/c)");
973                 fhPi0PtCharged->SetYTitle("p_{T gen} (GeV/c)");
974                 outputContainer->Add(fhPi0PtCharged);
975                 
976                 fhPi0PhiCharged  = new TH2F ("hPi0PhiCharged","#phi reconstructed vs E generated from #pi^{0}, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
977                 fhPi0PhiCharged->SetXTitle("#phi_{rec} (rad)");
978                 fhPi0PhiCharged->SetYTitle("#phi_{gen} (rad)");
979                 outputContainer->Add(fhPi0PhiCharged);
980                 
981                 fhPi0EtaCharged  = new TH2F ("hPi0EtaCharged","#eta reconstructed vs E generated from #pi^{0}, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
982                 fhPi0EtaCharged->SetXTitle("#eta_{rec} ");
983                 fhPi0EtaCharged->SetYTitle("#eta_{gen} ");
984                 outputContainer->Add(fhPi0EtaCharged);
985                 
986                 fhEleECharged  = new TH2F ("hEleECharged","E reconstructed vs E generated from e^{#pm}, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
987                 fhEleECharged->SetXTitle("E_{rec} (GeV)");
988                 fhEleECharged->SetXTitle("E_{gen} (GeV)");              
989                 outputContainer->Add(fhEleECharged);            
990                 
991                 fhElePtCharged  = new TH2F ("hElePtCharged","p_{T} reconstructed vs E generated from e^{#pm}, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
992                 fhElePtCharged->SetXTitle("p_{T rec} (GeV/c)");
993                 fhElePtCharged->SetYTitle("p_{T gen} (GeV/c)");
994                 outputContainer->Add(fhElePtCharged);
995                 
996                 fhElePhiCharged  = new TH2F ("hElePhiCharged","#phi reconstructed vs E generated from e^{#pm}, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
997                 fhElePhiCharged->SetXTitle("#phi_{rec} (rad)");
998                 fhElePhiCharged->SetYTitle("#phi_{gen} (rad)");
999                 outputContainer->Add(fhElePhiCharged);
1000                 
1001                 fhEleEtaCharged  = new TH2F ("hEleEtaCharged","#eta reconstructed vs E generated from e^{#pm}, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
1002                 fhEleEtaCharged->SetXTitle("#eta_{rec} ");
1003                 fhEleEtaCharged->SetYTitle("#eta_{gen} ");
1004                 outputContainer->Add(fhEleEtaCharged);
1005                 
1006                 fhNeHadECharged  = new TH2F ("hNeHadECharged","E reconstructed vs E generated from neutral hadron, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
1007                 fhNeHadECharged->SetXTitle("E_{rec} (GeV)");
1008                 fhNeHadECharged->SetYTitle("E_{gen} (GeV)");
1009                 outputContainer->Add(fhNeHadECharged);
1010                 
1011                 fhNeHadPtCharged  = new TH2F ("hNeHadPtCharged","p_{T} reconstructed vs E generated from neutral hadron, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
1012                 fhNeHadPtCharged->SetXTitle("p_{T rec} (GeV/c)");
1013                 fhNeHadPtCharged->SetYTitle("p_{T gen} (GeV/c)");
1014                 outputContainer->Add(fhNeHadPtCharged);
1015                 
1016                 fhNeHadPhiCharged  = new TH2F ("hNeHadPhiCharged","#phi reconstructed vs E generated from neutral hadron, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
1017                 fhNeHadPhiCharged->SetXTitle("#phi_{rec} (rad)");
1018                 fhNeHadPhiCharged->SetYTitle("#phi_{gen} (rad)");
1019                 outputContainer->Add(fhNeHadPhiCharged);
1020                 
1021                 fhNeHadEtaCharged  = new TH2F ("hNeHadEtaCharged","#eta reconstructed vs E generated from neutral hadron, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
1022                 fhNeHadEtaCharged->SetXTitle("#eta_{rec} ");
1023                 fhNeHadEtaCharged->SetYTitle("#eta_{gen} ");
1024                 outputContainer->Add(fhNeHadEtaCharged);
1025                 
1026                 fhChHadECharged  = new TH2F ("hChHadECharged","E reconstructed vs E generated from charged hadron, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
1027                 fhChHadECharged->SetXTitle("E_{rec} (GeV)");
1028                 fhChHadECharged->SetYTitle("E_{gen} (GeV)");
1029                 outputContainer->Add(fhChHadECharged);
1030                 
1031                 fhChHadPtCharged  = new TH2F ("hChHadPtCharged","p_{T} reconstructed vs E generated from charged hadron, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
1032                 fhChHadPtCharged->SetXTitle("p_{T rec} (GeV/c)");
1033                 fhChHadPtCharged->SetYTitle("p_{T gen} (GeV/c)");
1034                 outputContainer->Add(fhChHadPtCharged);
1035                 
1036                 fhChHadPhiCharged  = new TH2F ("hChHadPhiCharged","#phi reconstructed vs E generated from charged hadron, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
1037                 fhChHadPhiCharged->SetXTitle("#phi (rad)");
1038                 fhChHadPhiCharged->SetXTitle("#phi_{rec} (rad)");
1039                 fhChHadPhiCharged->SetYTitle("#phi_{gen} (rad)");
1040                 outputContainer->Add(fhChHadPhiCharged);
1041                 
1042                 fhChHadEtaCharged  = new TH2F ("hChHadEtaCharged","#eta reconstructed vs E generated from charged hadron, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
1043                 fhChHadEtaCharged->SetXTitle("#eta_{rec} ");
1044                 fhChHadEtaCharged->SetYTitle("#eta_{gen} ");
1045                 outputContainer->Add(fhChHadEtaCharged);
1046                 
1047                 //Vertex of generated particles 
1048                 
1049                 fhEMVxyz  = new TH2F ("hEMVxyz","Production vertex of reconstructed ElectroMagnetic particles",nvdistbins,vdistmin,vdistmax,nvdistbins,vdistmin,vdistmax);//,100,0,500); 
1050                 fhEMVxyz->SetXTitle("v_{x}");
1051                 fhEMVxyz->SetYTitle("v_{y}");
1052                 //fhEMVxyz->SetZTitle("v_{z}");
1053                 outputContainer->Add(fhEMVxyz);
1054                 
1055                 fhHaVxyz  = new TH2F ("hHaVxyz","Production vertex of reconstructed hadrons",nvdistbins,vdistmin,vdistmax,nvdistbins,vdistmin,vdistmax);//,100,0,500); 
1056                 fhHaVxyz->SetXTitle("v_{x}");
1057                 fhHaVxyz->SetYTitle("v_{y}");
1058                 //fhHaVxyz->SetZTitle("v_{z}");
1059                 outputContainer->Add(fhHaVxyz);
1060                 
1061                 fhEMR  = new TH2F ("hEMR","Distance to production vertex of reconstructed ElectroMagnetic particles vs E rec",nptbins,ptmin,ptmax,nvdistbins,vdistmin,vdistmax); 
1062                 fhEMR->SetXTitle("E (GeV)");
1063                 fhEMR->SetYTitle("TMath::Sqrt(v_{x}^{2}+v_{y}^{2})");
1064                 outputContainer->Add(fhEMR);
1065                 
1066                 fhHaR  = new TH2F ("hHaR","Distance to production vertex of reconstructed Hadrons vs E rec",nptbins,ptmin,ptmax,nvdistbins,vdistmin,vdistmax); 
1067                 fhHaR->SetXTitle("E (GeV)");
1068                 fhHaR->SetYTitle("TMath::Sqrt(v_{x}^{2}+v_{y}^{2})");
1069                 outputContainer->Add(fhHaR);
1070                 
1071
1072                 
1073                 //Pure MC
1074                 fhGenGamPt  = new TH1F("hGenGamPt" ,"p_{T} of generated #gamma",nptbins,ptmin,ptmax);
1075                 fhGenGamEta = new TH1F("hGenGamEta","Y of generated #gamma",netabins,etamin,etamax);
1076                 fhGenGamPhi = new TH1F("hGenGamPhi","#phi of generated #gamma",nphibins,phimin,phimax);
1077                 
1078                 fhGenPi0Pt  = new TH1F("hGenPi0Pt" ,"p_{T} of generated #pi^{0}",nptbins,ptmin,ptmax);
1079                 fhGenPi0Eta = new TH1F("hGenPi0Eta","Y of generated #pi^{0}",netabins,etamin,etamax);
1080                 fhGenPi0Phi = new TH1F("hGenPi0Phi","#phi of generated #pi^{0}",nphibins,phimin,phimax);
1081                 
1082                 fhGenEtaPt  = new TH1F("hGenEtaPt" ,"p_{T} of generated #eta",nptbins,ptmin,ptmax);
1083                 fhGenEtaEta = new TH1F("hGenEtaEta","Y of generated #eta",netabins,etamin,etamax);
1084                 fhGenEtaPhi = new TH1F("hGenEtaPhi","#phi of generated #eta",nphibins,phimin,phimax);
1085                 
1086                 fhGenOmegaPt  = new TH1F("hGenOmegaPt" ,"p_{T} of generated #omega",nptbins,ptmin,ptmax);
1087                 fhGenOmegaEta = new TH1F("hGenOmegaEta","Y of generated #omega",netabins,etamin,etamax);
1088                 fhGenOmegaPhi = new TH1F("hGenOmegaPhi","#phi of generated #omega",nphibins,phimin,phimax);             
1089                 
1090                 fhGenElePt  = new TH1F("hGenElePt" ,"p_{T} of generated e^{#pm}",nptbins,ptmin,ptmax);
1091                 fhGenEleEta = new TH1F("hGenEleEta","Y of generated  e^{#pm}",netabins,etamin,etamax);
1092                 fhGenElePhi = new TH1F("hGenElePhi","#phi of generated  e^{#pm}",nphibins,phimin,phimax);               
1093                 
1094                 fhGenGamPt->SetXTitle("p_{T} (GeV/c)");
1095                 fhGenGamEta->SetXTitle("#eta");
1096                 fhGenGamPhi->SetXTitle("#phi (rad)");
1097                 outputContainer->Add(fhGenGamPt);
1098                 outputContainer->Add(fhGenGamEta);
1099                 outputContainer->Add(fhGenGamPhi);
1100
1101                 fhGenPi0Pt->SetXTitle("p_{T} (GeV/c)");
1102                 fhGenPi0Eta->SetXTitle("#eta");
1103                 fhGenPi0Phi->SetXTitle("#phi (rad)");
1104                 outputContainer->Add(fhGenPi0Pt);
1105                 outputContainer->Add(fhGenPi0Eta);
1106                 outputContainer->Add(fhGenPi0Phi);
1107                 
1108                 fhGenEtaPt->SetXTitle("p_{T} (GeV/c)");
1109                 fhGenEtaEta->SetXTitle("#eta");
1110                 fhGenEtaPhi->SetXTitle("#phi (rad)");
1111                 outputContainer->Add(fhGenEtaPt);
1112                 outputContainer->Add(fhGenEtaEta);
1113                 outputContainer->Add(fhGenEtaPhi);
1114                                 
1115                 fhGenOmegaPt->SetXTitle("p_{T} (GeV/c)");
1116                 fhGenOmegaEta->SetXTitle("#eta");
1117                 fhGenOmegaPhi->SetXTitle("#phi (rad)");
1118                 outputContainer->Add(fhGenOmegaPt);
1119                 outputContainer->Add(fhGenOmegaEta);
1120                 outputContainer->Add(fhGenOmegaPhi);
1121                 
1122                 fhGenElePt->SetXTitle("p_{T} (GeV/c)");
1123                 fhGenEleEta->SetXTitle("#eta");
1124                 fhGenElePhi->SetXTitle("#phi (rad)");
1125                 outputContainer->Add(fhGenElePt);
1126                 outputContainer->Add(fhGenEleEta);
1127                 outputContainer->Add(fhGenElePhi);
1128                 
1129                 fhGenGamAccE   = new TH1F("hGenGamAccE" ,"E of generated #gamma in calorimeter acceptance",nptbins,ptmin,ptmax);
1130                 fhGenGamAccPt  = new TH1F("hGenGamAccPt" ,"p_{T} of generated #gamma in calorimeter acceptance",nptbins,ptmin,ptmax);
1131                 fhGenGamAccEta = new TH1F("hGenGamAccEta","Y of generated #gamma in calorimeter acceptance",netabins,etamin,etamax);
1132                 fhGenGamAccPhi = new TH1F("hGenGamAccPhi","#phi of generated #gamma  in calorimeter acceptance",nphibins,phimin,phimax);
1133                 
1134                 fhGenPi0AccE  = new TH1F("hGenPi0AccE" ,"E of generated #pi^{0} in calorimeter acceptance",nptbins,ptmin,ptmax);
1135                 fhGenPi0AccPt  = new TH1F("hGenPi0AccPt" ,"p_{T} of generated #pi^{0} in calorimeter acceptance",nptbins,ptmin,ptmax);
1136                 fhGenPi0AccEta = new TH1F("hGenPi0AccEta","Y of generated #pi^{0} in calorimeter acceptance",netabins,etamin,etamax);
1137                 fhGenPi0AccPhi = new TH1F("hGenPi0AccPhi","#phi of generated #pi^{0} in calorimeter acceptance",nphibins,phimin,phimax);
1138                 
1139                 fhGenGamAccE  ->SetXTitle("E (GeV)");
1140                 fhGenGamAccPt ->SetXTitle("p_{T} (GeV/c)");
1141                 fhGenGamAccEta->SetXTitle("#eta");
1142                 fhGenGamAccPhi->SetXTitle("#phi (rad)");
1143                 outputContainer->Add(fhGenGamAccE);             
1144                 outputContainer->Add(fhGenGamAccPt);
1145                 outputContainer->Add(fhGenGamAccEta);
1146                 outputContainer->Add(fhGenGamAccPhi);
1147                 
1148                 fhGenPi0AccE  ->SetXTitle("E (GeV)");           
1149                 fhGenPi0AccPt ->SetXTitle("p_{T} (GeV/c)");
1150                 fhGenPi0AccEta->SetXTitle("#eta");
1151                 fhGenPi0AccPhi->SetXTitle("#phi (rad)");
1152                 outputContainer->Add(fhGenPi0AccE);             
1153                 outputContainer->Add(fhGenPi0AccPt);
1154                 outputContainer->Add(fhGenPi0AccEta);
1155                 outputContainer->Add(fhGenPi0AccPhi);
1156                 
1157                 //Track Matching 
1158                 
1159           fhMCEle1pOverE = new TH2F("hMCEle1pOverE","TRACK matches p/E, MC electrons",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
1160           fhMCEle1pOverE->SetYTitle("p/E");
1161           fhMCEle1pOverE->SetXTitle("p_{T} (GeV/c)");
1162           outputContainer->Add(fhMCEle1pOverE);
1163           
1164           fhMCEle1dR = new TH1F("hMCEle1dR","TRACK matches dR, MC electrons",ndRbins,dRmin,dRmax);
1165           fhMCEle1dR->SetXTitle("#Delta R (rad)");
1166           outputContainer->Add(fhMCEle1dR) ;
1167           
1168           fhMCEle2MatchdEdx = new TH2F("hMCEle2MatchdEdx","dE/dx vs. p for all matches, MC electrons",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
1169           fhMCEle2MatchdEdx->SetXTitle("p (GeV/c)");
1170           fhMCEle2MatchdEdx->SetYTitle("<dE/dx>");
1171           outputContainer->Add(fhMCEle2MatchdEdx);
1172           
1173           fhMCChHad1pOverE = new TH2F("hMCChHad1pOverE","TRACK matches p/E, MC charged hadrons",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
1174           fhMCChHad1pOverE->SetYTitle("p/E");
1175           fhMCChHad1pOverE->SetXTitle("p_{T} (GeV/c)");
1176           outputContainer->Add(fhMCChHad1pOverE);
1177           
1178           fhMCChHad1dR = new TH1F("hMCChHad1dR","TRACK matches dR, MC charged hadrons",ndRbins,dRmin,dRmax);
1179           fhMCChHad1dR->SetXTitle("#Delta R (rad)");
1180           outputContainer->Add(fhMCChHad1dR) ;
1181           
1182           fhMCChHad2MatchdEdx = new TH2F("hMCChHad2MatchdEdx","dE/dx vs. p for all matches, MC charged hadrons",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
1183           fhMCChHad2MatchdEdx->SetXTitle("p (GeV/c)");
1184           fhMCChHad2MatchdEdx->SetYTitle("<dE/dx>");
1185           outputContainer->Add(fhMCChHad2MatchdEdx);
1186           
1187           fhMCNeutral1pOverE = new TH2F("hMCNeutral1pOverE","TRACK matches p/E, MC neutrals",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
1188           fhMCNeutral1pOverE->SetYTitle("p/E");
1189           fhMCNeutral1pOverE->SetXTitle("p_{T} (GeV/c)");
1190           outputContainer->Add(fhMCNeutral1pOverE);
1191           
1192           fhMCNeutral1dR = new TH1F("hMCNeutral1dR","TRACK matches dR, MC neutrals",ndRbins,dRmin,dRmax);
1193           fhMCNeutral1dR->SetXTitle("#Delta R (rad)");
1194           outputContainer->Add(fhMCNeutral1dR) ;
1195           
1196           fhMCNeutral2MatchdEdx = new TH2F("hMCNeutral2MatchdEdx","dE/dx vs. p for all matches, MC neutrals",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
1197           fhMCNeutral2MatchdEdx->SetXTitle("p (GeV/c)");
1198           fhMCNeutral2MatchdEdx->SetYTitle("<dE/dx>");
1199           outputContainer->Add(fhMCNeutral2MatchdEdx);
1200                   
1201           fhMCEle1pOverER02 = new TH2F("hMCEle1pOverER02","TRACK matches p/E, MC electrons",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
1202           fhMCEle1pOverER02->SetYTitle("p/E");
1203           fhMCEle1pOverER02->SetXTitle("p_{T} (GeV/c)");
1204           outputContainer->Add(fhMCEle1pOverER02);
1205           
1206           fhMCChHad1pOverER02 = new TH2F("hMCChHad1pOverER02","TRACK matches p/E, MC charged hadrons",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
1207           fhMCChHad1pOverER02->SetYTitle("p/E");
1208           fhMCChHad1pOverER02->SetXTitle("p_{T} (GeV/c)");
1209           outputContainer->Add(fhMCChHad1pOverER02);
1210           
1211           fhMCNeutral1pOverER02 = new TH2F("hMCNeutral1pOverER02","TRACK matches p/E, MC neutrals",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
1212           fhMCNeutral1pOverER02->SetYTitle("p/E");
1213           fhMCNeutral1pOverER02->SetXTitle("p_{T} (GeV/c)");
1214           outputContainer->Add(fhMCNeutral1pOverER02);
1215         }
1216
1217         return outputContainer;
1218 }
1219
1220 //_______________________________________________________________________________________________________________________________________
1221 Int_t AliAnaCalorimeterQA::GetNewRebinForRePlotting(TH1D* histo, const Float_t newXmin, const Float_t newXmax,const Int_t newXnbins) const
1222 {
1223   //Calculate the rebinning for the new requested bin size, only used when replotting executing the Terminte
1224   Float_t oldbinsize =  histo->GetBinWidth(0);
1225   Float_t newbinsize = TMath::Abs(newXmax-newXmin) / newXnbins;
1226   //printf("bin size, old %f, new %f\n",oldbinsize,newbinsize);
1227   if(newbinsize > oldbinsize) return (Int_t) (newbinsize/oldbinsize);
1228   else  return 1;
1229 }
1230
1231 //__________________________________________________
1232 void AliAnaCalorimeterQA::Init()
1233
1234         //Check if the data or settings are ok
1235         if(fCalorimeter != "PHOS" && fCalorimeter !="EMCAL"){
1236                 printf("AliAnaCalorimeterQA::Init() - Wrong calorimeter name <%s>, END\n", fCalorimeter.Data());
1237                 abort();
1238         }       
1239         
1240         if(GetReader()->GetDataType()== AliCaloTrackReader::kMC){
1241                 printf("AliAnaCalorimeterQA::Init() - Analysis of reconstructed data, MC reader not aplicable\n");
1242                 abort();
1243         }       
1244         
1245 }
1246
1247
1248 //__________________________________________________
1249 void AliAnaCalorimeterQA::InitParameters()
1250
1251   //Initialize the parameters of the analysis.
1252   AddToHistogramsName("AnaCaloQA_");
1253
1254   fCalorimeter = "EMCAL"; //or PHOS
1255   fStyleMacro  = "" ;
1256   fNModules    = 12; // set maximum to maximum number of EMCAL modules
1257   fNRCU        = 2;  // set maximum number of RCU in EMCAL per SM
1258   fTimeCutMin  = -1;
1259   fTimeCutMax  = 9999999;
1260         
1261   fHistoPOverEBins     = 100 ;  fHistoPOverEMax     = 10.  ;  fHistoPOverEMin     = 0. ;
1262   fHistodEdxBins       = 200 ;  fHistodEdxMax       = 400. ;  fHistodEdxMin       = 0. ;  
1263   fHistodRBins         = 300 ;  fHistodRMax         = 3.15 ;  fHistodRMin         = 0. ;
1264   fHistoTimeBins       = 1000;  fHistoTimeMax       = 1.e3 ;  fHistoTimeMin       = 0. ;//ns
1265   fHistoNBins          = 300 ;  fHistoNMax          = 300  ;  fHistoNMin          = 0  ;
1266   fHistoRatioBins      = 200 ;  fHistoRatioMax      = 2    ;  fHistoRatioMin      = 0. ;
1267   fHistoVertexDistBins = 100 ;  fHistoVertexDistMax = 500. ;  fHistoVertexDistMin = 0. ;
1268   fHistoRBins          = 100 ;  fHistoRMax          = 500  ;  fHistoRMin          = -500  ;//cm
1269   fHistoXBins          = 100 ;  fHistoXMax          = 500  ;  fHistoXMin          = -500  ;//cm
1270   fHistoYBins          = 100 ;  fHistoYMax          = 500  ;  fHistoYMin          = -500  ;//cm
1271   fHistoZBins          = 100 ;  fHistoZMax          = 600  ;  fHistoZMin          = -500  ;//cm
1272   fHistoSSBins         = 40  ;  fHistoSSMax         = 10  ;   fHistoSSMin         = 0  ;
1273         
1274 }
1275
1276 //__________________________________________________________________
1277 void AliAnaCalorimeterQA::Print(const Option_t * opt) const
1278 {
1279   //Print some relevant parameters set for the analysis
1280   if(! opt)
1281     return;
1282   
1283   printf("**** Print %s %s ****\n", GetName(), GetTitle() ) ;
1284   AliAnaPartCorrBaseClass::Print(" ");
1285
1286   printf("Select Calorimeter %s \n",fCalorimeter.Data());
1287   printf("Make plots?        %d \n",fMakePlots);        
1288   printf("Plots style macro  %s \n",fStyleMacro.Data()); 
1289   printf("Time Cut: %3.1f < TOF  < %3.1f\n", fTimeCutMin, fTimeCutMax);
1290   printf("Histograms: %3.1f < p/E  < %3.1f, Nbin = %d\n", fHistoPOverEMin, fHistoPOverEMax, fHistoPOverEBins);
1291   printf("Histograms: %3.1f < dEdx < %3.1f, Nbin = %d\n", fHistodEdxMin,   fHistodEdxMax,   fHistodEdxBins);
1292   printf("Histograms: %3.1f < dR (track cluster)   < %3.1f, Nbin = %d\n", fHistodRMin,     fHistodRMax,     fHistodRBins);
1293   printf("Histograms: %3.1f < R=sqrt{x^2+y^2}    < %3.1f, Nbin = %d\n", fHistoRMin,      fHistoRMax,      fHistoRBins);
1294   printf("Histograms: %3.1f < X    < %3.1f, Nbin = %d\n", fHistoXMin,      fHistoXMax,      fHistoXBins);
1295   printf("Histograms: %3.1f < Y    < %3.1f, Nbin = %d\n", fHistoYMin,      fHistoYMax,      fHistoYBins);
1296   printf("Histograms: %3.1f < Z    < %3.1f, Nbin = %d\n", fHistoZMin,      fHistoZMax,      fHistoZBins);
1297   printf("Histograms: %g < Time < %g, Nbin = %d\n"      , fHistoTimeMin,   fHistoTimeMax,   fHistoTimeBins);
1298   printf("Histograms: %d < N    < %d, Nbin = %d\n"      , fHistoNMin,      fHistoNMax,      fHistoNBins);
1299   printf("Histograms: %3.1f < Ratio< %3.1f, Nbin = %d\n", fHistoRatioMin,  fHistoRatioMax,  fHistoRatioBins);
1300   printf("Histograms: %3.1f < Vertex Distance < %3.1f, Nbin = %d\n", fHistoVertexDistMin, fHistoVertexDistMax, fHistoVertexDistBins);
1301
1302
1303
1304 //__________________________________________________________________
1305 void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms() 
1306 {
1307         //Fill Calorimeter QA histograms
1308         TLorentzVector mom ;
1309         TLorentzVector mom2 ;
1310         TRefArray * caloClusters = new TRefArray();
1311         Int_t nLabel = 0;
1312         Int_t *labels=0x0;
1313         Int_t nCaloClusters = 0;
1314         Int_t nCaloCellsPerCluster = 0;
1315         Int_t nTracksMatched = 0;
1316         Int_t trackIndex = 0;
1317         Int_t nModule = -1;
1318
1319         //Play with the MC stack if available   
1320         //Get the MC arrays and do some checks
1321         if(IsDataMC()){
1322                 if(GetReader()->ReadStack()){
1323
1324                         if(!GetMCStack()) {
1325                                 printf("AliAnaPhoton::MakeAnalysisFillHistograms() - Stack not available, is the MC handler called? STOP\n");
1326                                 abort();
1327                         }
1328                         //Fill some pure MC histograms, only primaries.
1329                         for(Int_t i=0 ; i<GetMCStack()->GetNprimary(); i++){//Only primary particles, for all MC transport put GetNtrack()
1330                                 TParticle *primary = GetMCStack()->Particle(i) ;
1331                                 //printf("i %d, %s: status = %d, primary? %d\n",i, primary->GetName(), primary->GetStatusCode(), primary->IsPrimary());
1332                                 if (primary->GetStatusCode() > 11) continue; //Working for PYTHIA and simple generators, check for HERWIG 
1333                                 primary->Momentum(mom);
1334                                 MCHistograms(mom,TMath::Abs(primary->GetPdgCode()));
1335                         } //primary loop
1336                 }
1337                 else if(GetReader()->ReadAODMCParticles()){
1338
1339                         if(!GetReader()->GetAODMCParticles(0))  {
1340                                 printf("AliAnaPhoton::MakeAnalysisFillHistograms() -  AODMCParticles not available!\n");
1341                                 abort();
1342                         }
1343                         //Fill some pure MC histograms, only primaries.
1344                         for(Int_t i=0 ; i < (GetReader()->GetAODMCParticles(0))->GetEntriesFast(); i++){
1345                                 AliAODMCParticle *aodprimary = (AliAODMCParticle*) (GetReader()->GetAODMCParticles(0))->At(i) ;
1346                                 //printf("i %d, %s: primary? %d physical primary? %d, flag %d\n",
1347                                 //         i,(TDatabasePDG::Instance()->GetParticle(aodprimary->GetPdgCode()))->GetName(), 
1348                                 //         aodprimary->IsPrimary(), aodprimary->IsPhysicalPrimary(), aodprimary->GetFlag());
1349                                 if (!aodprimary->IsPrimary()) continue; //accept all which is not MC transport generated. Don't know how to avoid partons
1350                                 //aodprimary->Momentum(mom);
1351                                 mom.SetPxPyPzE(aodprimary->Px(),aodprimary->Py(),aodprimary->Pz(),aodprimary->E());
1352                                 MCHistograms(mom,TMath::Abs(aodprimary->GetPdgCode()));
1353                         } //primary loop
1354                         
1355                 }
1356         }// is data and MC      
1357         
1358         
1359         //Get List with CaloClusters  
1360         
1361         if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
1362                 if     (fCalorimeter == "EMCAL") ((AliESDEvent*)GetReader()->GetInputEvent())->GetEMCALClusters(caloClusters);//GetAODEMCAL();
1363                 else if(fCalorimeter == "PHOS")  ((AliESDEvent*)GetReader()->GetInputEvent())->GetPHOSClusters (caloClusters);//GetAODPHOS();
1364                 else {
1365                         printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Wrong calorimeter name <%s>, END\n", fCalorimeter.Data());
1366                         abort();
1367                 }
1368         }
1369         else if(GetReader()->GetDataType()==AliCaloTrackReader::kAOD) {
1370                 if     (fCalorimeter == "EMCAL") ((AliAODEvent*)GetReader()->GetInputEvent())->GetEMCALClusters(caloClusters);//GetAODEMCAL();
1371                 else if(fCalorimeter == "PHOS")  ((AliAODEvent*)GetReader()->GetInputEvent())->GetPHOSClusters (caloClusters);//GetAODPHOS();
1372                 else {
1373                         printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Wrong calorimeter name <%s>, END\n", fCalorimeter.Data());
1374                         abort();
1375                 }
1376         }
1377         
1378         if(!caloClusters) {
1379                 printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - No CaloClusters available\n");
1380                 abort();
1381         }
1382         
1383         //----------------------------------------------------------
1384         //Correlate Calorimeters
1385         //----------------------------------------------------------
1386         if(fCorrelateCalos)     CorrelateCalorimeters(caloClusters);
1387                 
1388         
1389         //----------------------------------------------------------
1390         // CALOCLUSTERS
1391         //----------------------------------------------------------
1392         
1393         nCaloClusters = caloClusters->GetEntriesFast() ; 
1394         fhNClusters->Fill(nCaloClusters);
1395         Int_t *nClustersInModule = new Int_t[fNModules];
1396         for(Int_t imod = 0; imod < fNModules; imod++ ) nClustersInModule[imod] = 0;
1397         
1398         if(GetDebug() > 0)
1399                 printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - In %s there are %d clusters \n", fCalorimeter.Data(), nCaloClusters);
1400         
1401         //Get vertex for photon momentum calculation
1402         Double_t v[3] = {0,0,0}; //vertex ;
1403         GetReader()->GetVertex(v);
1404         TObject * track = 0x0;
1405         
1406         Float_t pos[3] ;
1407         Float_t showerShape[3] ;
1408         Double_t tof = 0;
1409         //Loop over CaloClusters
1410         //if(nCaloClusters > 0)printf("QA  : Vertex Cut passed %f, cut %f, entries %d, %s\n",v[2], 40., nCaloClusters, fCalorimeter.Data());
1411         for(Int_t iclus = 0; iclus < nCaloClusters; iclus++){
1412                 
1413                 if(GetDebug() > 0) printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - cluster: %d/%d, data %d \n",
1414                                                                         iclus+1,nCaloClusters,GetReader()->GetDataType());
1415                 
1416                 if(GetReader()->GetDataType()==AliCaloTrackReader::kESD){
1417                         AliESDCaloCluster* clus =  (AliESDCaloCluster*) (caloClusters->At(iclus));
1418                         AliESDCaloCells * cell = 0x0; 
1419                         if(fCalorimeter == "PHOS") cell =  ((AliESDEvent*)GetReader()->GetInputEvent())->GetPHOSCells();
1420                         else                               cell =  ((AliESDEvent*)GetReader()->GetInputEvent())->GetEMCALCells();
1421                         
1422                         //Check if the cluster contains any bad channel or it is close to the calorimeter borders
1423                         if( GetCaloUtils()->ClusterContainsBadChannel(fCalorimeter,clus->GetCellsAbsId(), clus->GetNCells())) continue; 
1424                         if(!GetCaloUtils()->CheckCellFiducialRegion(clus, cell)) continue;
1425                         //Recalibrate the cluster energy 
1426                         if( GetCaloUtils()->IsRecalibrationOn())        {
1427                                 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, cell);
1428                                 clus->SetE(energy);
1429                         }
1430                         
1431                         //Get cluster kinematics
1432                         clus->GetPosition(pos);
1433                         clus->GetMomentum(mom,v);
1434                         tof = clus->GetTOF()*1e9;
1435                         if(tof < fTimeCutMin || tof > fTimeCutMax) continue;
1436                         
1437                         //Check only certain regions
1438                         Bool_t in = kTRUE;
1439                         if(IsFiducialCutOn()) in =  GetFiducialCut()->IsInFiducialCut(mom,fCalorimeter) ;
1440                         if(!in) continue;
1441                         //Get module of cluster
1442                         nModule = GetModuleNumber(clus);
1443                         if(nModule < fNModules) nClustersInModule[nModule]++;
1444                         //MC labels
1445                         nLabel = clus->GetNLabels();
1446                         labels = clus->GetLabels();
1447                         //Cells per cluster
1448                         nCaloCellsPerCluster =  clus->GetNCells();
1449                         //if(mom.E() > 10 && nCaloCellsPerCluster == 1 ) printf("%s:************** E = %f ********** ncells = %d\n",fCalorimeter.Data(), mom.E(),nCaloCellsPerCluster);
1450                         //matched cluster with tracks
1451                         nTracksMatched = clus->GetNTracksMatched();
1452                         trackIndex     = clus->GetTrackMatched();
1453                         if(trackIndex >= 0){
1454                                 track = (AliESDtrack*) ((AliESDEvent*)GetReader()->GetInputEvent())->GetTrack(trackIndex);
1455                         }
1456                         else{
1457                                 if(nTracksMatched == 1) nTracksMatched = 0;
1458                                 track = 0;
1459                         }
1460                         
1461                         //Shower shape parameters
1462                         showerShape[0] = clus->GetM20();
1463                         showerShape[1] = clus->GetM02();
1464                         showerShape[2] = clus->GetDispersion();
1465
1466                         //======================
1467                         //Cells in cluster
1468                         //======================
1469
1470                         //Get list of contributors
1471                         UShort_t * indexList = clus->GetCellsAbsId() ;
1472                         // check time of cells respect to max energy cell
1473                         //Get maximum energy cell
1474                         Float_t emax  = -1;
1475                         Double_t tmax = -1;
1476                         Int_t imax    = -1;
1477                         Int_t absId   = -1 ;
1478                         //printf("nCaloCellsPerCluster %d\n",nCaloCellsPerCluster);
1479                         //Loop on cluster cells
1480                         for (Int_t ipos = 0; ipos < nCaloCellsPerCluster; ipos++) {
1481                           //    printf("Index %d\n",ipos);
1482                           absId  = indexList[ipos]; 
1483                           
1484                           //Get position of cell compare to cluster
1485                           if(fCalorimeter=="EMCAL" && GetCaloUtils()->IsEMCALGeoMatrixSet()){
1486                             
1487                             Double_t cellpos[] = {0, 0, 0};
1488                             GetEMCALGeometry()->GetGlobal(absId, cellpos);
1489                             
1490                             fhDeltaCellClusterXNCells->Fill(pos[0]-cellpos[0],nCaloCellsPerCluster) ; 
1491                             fhDeltaCellClusterYNCells->Fill(pos[1]-cellpos[1],nCaloCellsPerCluster) ; 
1492                             fhDeltaCellClusterZNCells->Fill(pos[2]-cellpos[2],nCaloCellsPerCluster) ;
1493                             
1494                             fhDeltaCellClusterXE->Fill(pos[0]-cellpos[0],mom.E())  ; 
1495                             fhDeltaCellClusterYE->Fill(pos[1]-cellpos[1],mom.E())  ; 
1496                             fhDeltaCellClusterZE->Fill(pos[2]-cellpos[2],mom.E())  ; 
1497                             
1498                             Float_t r     = TMath::Sqrt(pos[0]*pos[0]        +pos[1]*pos[1]);//     +pos[2]*pos[2]);
1499                             Float_t rcell = TMath::Sqrt(cellpos[0]*cellpos[0]+cellpos[1]*cellpos[1]);//+cellpos[2]*cellpos[2]);
1500                             fhDeltaCellClusterRNCells->Fill(r-rcell, nCaloCellsPerCluster) ; 
1501                             fhDeltaCellClusterRE     ->Fill(r-rcell, mom.E())  ; 
1502                         
1503 //                                      Float_t celleta = 0, cellphi = 0;
1504 //                                      GetEMCALGeometry()->EtaPhiFromIndex(absId, celleta, cellphi); 
1505 //                                      Int_t imod = -1, iTower = -1, iIphi = -1, iIeta = -1, iphi = -1, ieta = -1;
1506 //                                      GetEMCALGeometry()->GetCellIndex(absId,imod,iTower,iIphi,iIeta); 
1507 //                                      GetEMCALGeometry()->GetCellPhiEtaIndexInSModule(imod,iTower,
1508 //                                                                                                                                                               iIphi, iIeta,iphi,ieta);
1509 //                                      printf("AbsId %d, SM %d, Index eta %d, phi %d\n", absId, imod, ieta, iphi);
1510 //                                      printf("Cluster E %f, eta %f, phi %f; Cell: Amp %f, eta %f, phi%f\n", mom.E(),mom.Eta(), mom.Phi()*TMath::RadToDeg(), cell->GetCellAmplitude(absId),celleta, cellphi*TMath::RadToDeg());
1511 //                                      printf("x cluster %f, x cell %f, cluster-cell %f\n",pos[0], cellpos[0],pos[0]-cellpos[0]);
1512 //                                      printf("y cluster %f, y cell %f, cluster-cell %f\n",pos[1], cellpos[1],pos[1]-cellpos[1]);
1513 //                                      printf("z cluster %f, z cell %f, cluster-cell %f\n",pos[2], cellpos[2],pos[2]-cellpos[2]);
1514 //                                      printf("r cluster %f, r cell %f, cluster-cell %f\n",r,      rcell,     r-rcell);
1515 //                                      
1516
1517                           }//EMCAL and its matrices are available
1518                           else if(fCalorimeter=="PHOS" && GetCaloUtils()->IsPHOSGeoMatrixSet()){
1519                             TVector3 xyz;
1520                             Int_t relId[4], module;
1521                             Float_t xCell, zCell;
1522                             
1523                             GetPHOSGeometry()->AbsToRelNumbering(absId,relId);
1524                             module = relId[0];
1525                             GetPHOSGeometry()->RelPosInModule(relId,xCell,zCell);
1526                             GetPHOSGeometry()->Local2Global(module,xCell,zCell,xyz);
1527                             
1528                             fhDeltaCellClusterXNCells->Fill(pos[0]-xyz.X(),nCaloCellsPerCluster) ; 
1529                             fhDeltaCellClusterYNCells->Fill(pos[1]-xyz.Y(),nCaloCellsPerCluster) ; 
1530                             fhDeltaCellClusterZNCells->Fill(pos[2]-xyz.Z(),nCaloCellsPerCluster) ;
1531                             
1532                             fhDeltaCellClusterXE->Fill(pos[0]-xyz.X(),mom.E())  ; 
1533                             fhDeltaCellClusterYE->Fill(pos[1]-xyz.Y(),mom.E())  ; 
1534                             fhDeltaCellClusterZE->Fill(pos[2]-xyz.Z(),mom.E())  ; 
1535                             
1536                             Float_t r     = TMath::Sqrt(pos[0]*pos[0]  +pos[1]*pos[1]);//     +pos[2]*pos[2]);
1537                             Float_t rcell = TMath::Sqrt(xyz.X()*xyz.X()+xyz.Y()*xyz.Y());//+xyz.Z()*xyz.Z());
1538                             fhDeltaCellClusterRNCells->Fill(r-rcell, nCaloCellsPerCluster) ; 
1539                             fhDeltaCellClusterRE     ->Fill(r-rcell, mom.E())  ; 
1540                             
1541 //                              printf("x cluster %f, x cell %f, cluster-cell %f\n",pos[0], cellpos[0],pos[0]-cellpos[0]);
1542 //                              printf("y cluster %f, y cell %f, cluster-cell %f\n",pos[1], cellpos[1],pos[1]-cellpos[1]);
1543 //                              printf("z cluster %f, z cell %f, cluster-cell %f\n",pos[2], cellpos[2],pos[2]-cellpos[2]);
1544 //                              printf("r cluster %f, r cell %f, cluster-cell %f\n",r,      rcell,     r-rcell);
1545                           }//PHOS and its matrices are available
1546
1547                           //Find maximum energy cluster
1548                           if(cell->GetCellAmplitude(absId) > emax) {
1549                             imax = ipos;
1550                             emax = cell->GetCellAmplitude(absId);
1551                             tmax = cell->GetCellTime(absId);
1552                           } 
1553
1554                         }// cluster cell loop
1555                         
1556                         // check time of cells respect to max energy cell
1557                         if(nCaloCellsPerCluster > 1){
1558                           for (Int_t ipos = 0; ipos < nCaloCellsPerCluster; ipos++) {
1559                             if(imax == ipos) continue;
1560                             absId  = indexList[ipos]; 
1561                             Float_t diff = (tmax-cell->GetCellTime(absId))*1e9;
1562                             fhCellTimeSpreadRespectToCellMax->Fill(diff);
1563                             if(TMath::Abs(TMath::Abs(diff) > 100)) fhCellIdCellLargeTimeSpread->Fill(absId);
1564                           }// fill cell-cluster histogram loop
1565                           
1566                         }//check time of cells respect to max energy cell
1567                         
1568                         
1569                 }//ESDs
1570                 else{
1571                         AliAODCaloCluster* clus =  (AliAODCaloCluster*) (caloClusters->At(iclus));
1572                         AliAODCaloCells * cell = 0x0; 
1573                         if(fCalorimeter == "PHOS") cell =  ((AliAODEvent*)GetReader()->GetInputEvent())->GetPHOSCells();
1574                         else                                       cell =  ((AliAODEvent*)GetReader()->GetInputEvent())->GetEMCALCells();
1575                         
1576                         //Check if the cluster contains any bad channel or it is close to calorimeter borders
1577                         if( GetCaloUtils()->ClusterContainsBadChannel(fCalorimeter,clus->GetCellsAbsId(), clus->GetNCells())) continue;
1578                         if(!GetCaloUtils()->CheckCellFiducialRegion(clus, cell)) continue;
1579                         //Recalibrate the cluster energy 
1580                         if( GetCaloUtils()->IsRecalibrationOn())        {
1581                                 Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, cell);
1582                                 clus->SetE(energy);
1583                         }
1584                         
1585                         //Get cluster kinematics
1586                         clus->GetPosition(pos);
1587                         clus->GetMomentum(mom,v);
1588                         tof = clus->GetTOF()*1e9;
1589                         if(tof < fTimeCutMin || tof > fTimeCutMax) continue;
1590
1591                         //Check only certain regions
1592                         Bool_t in = kTRUE;
1593                         if(IsFiducialCutOn()) in =  GetFiducialCut()->IsInFiducialCut(mom,fCalorimeter) ;
1594                         if(!in) continue;                       
1595                         //Get module of cluster
1596                         nModule = GetModuleNumber(clus);
1597                         if(nModule < fNModules)  nClustersInModule[nModule]++;
1598                         //MC labels
1599                         nLabel = clus->GetNLabel();
1600                         labels = clus->GetLabels();
1601                         //Cells per cluster
1602                         nCaloCellsPerCluster = clus->GetNCells();
1603                         //matched cluster with tracks
1604                         nTracksMatched = clus->GetNTracksMatched();
1605                         if(nTracksMatched > 0)
1606                                 track  = (AliAODTrack*)clus->GetTrackMatched(0);
1607                         
1608                     //Shower shape parameters
1609                         showerShape[0] = clus->GetM20();
1610                         showerShape[1] = clus->GetM02();
1611                         showerShape[2] = clus->GetDispersion();
1612                         
1613                         //======================
1614                         //Cells in cluster
1615                         //======================
1616                                                 
1617                         //Get list of contributors
1618                         UShort_t * indexList = clus->GetCellsAbsId() ;
1619                         Int_t absId   = -1 ;
1620                         //printf("nCaloCellsPerCluster %d\n",nCaloCellsPerCluster);
1621                         //Loop on cluster cells
1622                         for (Int_t ipos = 0; ipos < nCaloCellsPerCluster; ipos++) {
1623                                 //      printf("Index %d\n",ipos);
1624                                 absId  = indexList[ipos]; 
1625                                 
1626                                 //Get position of cell compare to cluster
1627                                 if(fCalorimeter=="EMCAL" && GetCaloUtils()->IsEMCALGeoMatrixSet()){
1628                                         
1629                                         Double_t cellpos[] = {0, 0, 0};
1630                                         GetEMCALGeometry()->GetGlobal(absId, cellpos);
1631                                         
1632                                         fhDeltaCellClusterXNCells->Fill(pos[0]-cellpos[0],nCaloCellsPerCluster) ; 
1633                                         fhDeltaCellClusterYNCells->Fill(pos[1]-cellpos[1],nCaloCellsPerCluster) ; 
1634                                         fhDeltaCellClusterZNCells->Fill(pos[2]-cellpos[2],nCaloCellsPerCluster) ;
1635                                         
1636                                         fhDeltaCellClusterXE->Fill(pos[0]-cellpos[0],mom.E())  ; 
1637                                         fhDeltaCellClusterYE->Fill(pos[1]-cellpos[1],mom.E())  ; 
1638                                         fhDeltaCellClusterZE->Fill(pos[2]-cellpos[2],mom.E())  ; 
1639                                         
1640                                         Float_t r     = TMath::Sqrt(pos[0]*pos[0]        +pos[1]*pos[1]);//        +pos[2]*pos[2]);
1641                                         Float_t rcell = TMath::Sqrt(cellpos[0]*cellpos[0]+cellpos[1]*cellpos[1]);//+cellpos[2]*cellpos[2]);
1642                                         fhDeltaCellClusterRNCells->Fill(r-rcell, nCaloCellsPerCluster) ; 
1643                                         fhDeltaCellClusterRE     ->Fill(r-rcell, mom.E())  ; 
1644                                         
1645 //                                              printf("x cluster %f, x cell %f, cluster-cell %f\n",pos[0], cellpos[0],pos[0]-cellpos[0]);
1646 //                                              printf("y cluster %f, y cell %f, cluster-cell %f\n",pos[1], cellpos[1],pos[1]-cellpos[1]);
1647 //                                              printf("z cluster %f, z cell %f, cluster-cell %f\n",pos[2], cellpos[2],pos[2]-cellpos[2]);
1648 //                                              printf("r cluster %f, r cell %f, cluster-cell %f\n",r,      rcell,     r-rcell);                                        
1649                                         
1650                                 }// EMCAL and its matrices are available
1651                                 else if(fCalorimeter=="PHOS" && GetCaloUtils()->IsPHOSGeoMatrixSet()){
1652                                   TVector3 xyz;
1653                                   Int_t relId[4], module;
1654                                   Float_t xCell, zCell;
1655                                   
1656                                   GetPHOSGeometry()->AbsToRelNumbering(absId,relId);
1657                                   module = relId[0];
1658                                   GetPHOSGeometry()->RelPosInModule(relId,xCell,zCell);
1659                                   GetPHOSGeometry()->Local2Global(module,xCell,zCell,xyz);
1660                                   
1661                                   fhDeltaCellClusterXNCells->Fill(pos[0]-xyz.X(),nCaloCellsPerCluster) ; 
1662                                   fhDeltaCellClusterYNCells->Fill(pos[1]-xyz.Y(),nCaloCellsPerCluster) ; 
1663                                   fhDeltaCellClusterZNCells->Fill(pos[2]-xyz.Z(),nCaloCellsPerCluster) ;
1664                                   
1665                                   fhDeltaCellClusterXE->Fill(pos[0]-xyz.X(),mom.E())  ; 
1666                                   fhDeltaCellClusterYE->Fill(pos[1]-xyz.Y(),mom.E())  ; 
1667                                   fhDeltaCellClusterZE->Fill(pos[2]-xyz.Z(),mom.E())  ; 
1668                                   
1669                                   Float_t r     = TMath::Sqrt(pos[0]*pos[0]  +pos[1]*pos[1]);//     +pos[2]*pos[2]);
1670                                   Float_t rcell = TMath::Sqrt(xyz.X()*xyz.X()+xyz.Y()*xyz.Y());//+xyz.Z()*xyz.Z());
1671                                   fhDeltaCellClusterRNCells->Fill(r-rcell, nCaloCellsPerCluster) ; 
1672                                   fhDeltaCellClusterRE     ->Fill(r-rcell, mom.E())  ; 
1673                                   
1674 //                              printf("x cluster %f, x cell %f, cluster-cell %f\n",pos[0], cellpos[0],pos[0]-cellpos[0]);
1675 //                              printf("y cluster %f, y cell %f, cluster-cell %f\n",pos[1], cellpos[1],pos[1]-cellpos[1]);
1676 //                              printf("z cluster %f, z cell %f, cluster-cell %f\n",pos[2], cellpos[2],pos[2]-cellpos[2]);
1677 //                              printf("r cluster %f, r cell %f, cluster-cell %f\n",r,      rcell,     r-rcell);
1678
1679                                 }   //PHOS and its matrices are available
1680                         }// cluster cell loop
1681                         
1682                 }//AODs
1683                 
1684                 //-----------------------------------------------------------
1685                 //Fill histograms related to single cluster or track matching
1686                 //-----------------------------------------------------------
1687
1688                 ClusterHistograms(mom, tof, pos, showerShape, nCaloCellsPerCluster, nModule, nTracksMatched, track, labels, nLabel);    
1689                 
1690                          
1691                 //-----------------------------------------------------------
1692                 //Invariant mass
1693                 //-----------------------------------------------------------
1694                 if(GetDebug()>1) printf("Invariant mass \n");
1695
1696                 //do not do for bad vertex
1697                 Float_t fZvtxCut = 40. ;        
1698                 if(v[2]<-fZvtxCut || v[2]> fZvtxCut) continue ; //Event can not be used (vertex, centrality,... cuts not fulfilled)
1699                 
1700                 Int_t nModule2 = -1;
1701                 Int_t nCaloCellsPerCluster2=0;
1702                 if (nCaloClusters > 1 ) {
1703                         for(Int_t jclus = iclus + 1 ; jclus < nCaloClusters ; jclus++) {
1704                                 if(GetReader()->GetDataType()==AliCaloTrackReader::kESD){
1705                                         AliESDCaloCluster* clus2 =  (AliESDCaloCluster*) (caloClusters->At(jclus));
1706                                         AliESDCaloCells  * cell2 = 0x0; 
1707                                         if(fCalorimeter == "PHOS") cell2 =  ((AliESDEvent*)GetReader()->GetInputEvent())->GetPHOSCells();
1708                                         else                               cell2 =  ((AliESDEvent*)GetReader()->GetInputEvent())->GetEMCALCells();
1709                                         //Check if the cluster contains any bad channel or it is close to calorimeter borders
1710                                         if( GetCaloUtils()->ClusterContainsBadChannel(fCalorimeter,clus2->GetCellsAbsId(), clus2->GetNCells())) continue;
1711                                         if(!GetCaloUtils()->CheckCellFiducialRegion(clus2, cell2)) continue;
1712
1713                                         //Get cluster kinematics
1714                                         clus2->GetMomentum(mom2,v);
1715                                         //Check only certain regions
1716                                         Bool_t in2 = kTRUE;
1717                                         if(IsFiducialCutOn()) in2 =  GetFiducialCut()->IsInFiducialCut(mom2,fCalorimeter) ;
1718                                         if(!in2) continue;      
1719                                         //Get module of cluster
1720                                         nModule2 = GetModuleNumber(clus2);
1721                                         //Cells per cluster
1722                                         nCaloCellsPerCluster2 = clus2->GetNCells();
1723
1724                                 }
1725                                 else if(GetReader()->GetDataType()==AliCaloTrackReader::kAOD){
1726                                         AliAODCaloCluster* clus2 =  (AliAODCaloCluster*) (caloClusters->At(jclus));
1727                                         AliAODCaloCells  * cell2 = 0x0; 
1728                                         if(fCalorimeter == "PHOS") cell2 =  ((AliAODEvent*)GetReader()->GetInputEvent())->GetPHOSCells();
1729                                         else                               cell2 =  ((AliAODEvent*)GetReader()->GetInputEvent())->GetEMCALCells();
1730                                         //Check if the cluster contains any bad channel or it is close to calorimeter borders 
1731                                         if( GetCaloUtils()->ClusterContainsBadChannel(fCalorimeter,clus2->GetCellsAbsId(), clus2->GetNCells())) continue;
1732                                         if(!GetCaloUtils()->CheckCellFiducialRegion(clus2, cell2)) continue;
1733
1734                                         //Get cluster kinematics
1735                                         clus2->GetMomentum(mom2,v);
1736                                         //Check only certain regions
1737                                         Bool_t in2 = kTRUE;
1738                                         if(IsFiducialCutOn()) in2 =  GetFiducialCut()->IsInFiducialCut(mom2,fCalorimeter) ;
1739                                         if(!in2) continue;                                              
1740                                         //Get module of cluster
1741                                         nModule2 = GetModuleNumber(clus2);
1742                                         //Cells per cluster
1743                                         nCaloCellsPerCluster2 = clus2->GetNCells();
1744                                 }
1745
1746                                 //Fill invariant mass histograms
1747                                 //All modules
1748
1749                                 //printf("QA : Fill inv mass histo: pt1 %f, pt2 %f, pt12 %f, mass %f, calo %s \n",mom.Pt(),mom2.Pt(),(mom+mom2).Pt(),(mom+mom2).M(), fCalorimeter.Data());
1750                                 fhIM  ->Fill((mom+mom2).Pt(),(mom+mom2).M());
1751                                 //Single module
1752                                 if(nModule == nModule2 && nModule >=0 && nModule < fNModules)
1753                                   fhIMMod[nModule]->Fill((mom+mom2).Pt(),(mom+mom2).M());
1754
1755                                 //Select only clusters with at least 2 cells
1756                                 if(nCaloCellsPerCluster > 1 && nCaloCellsPerCluster2 > 1) {
1757                                   //All modules
1758                                   fhIMCellCut  ->Fill((mom+mom2).Pt(),(mom+mom2).M());
1759                                   //Single modules
1760                                   if(nModule == nModule2 && nModule >=0 && nModule < fNModules)
1761                                     fhIMCellCutMod[nModule]->Fill((mom+mom2).Pt(),(mom+mom2).M());
1762                                 }
1763
1764                                 //Asymetry histograms
1765                                 fhAsym->Fill((mom+mom2).Pt(),TMath::Abs((mom.E()-mom2.E())/(mom.E()+mom2.E())));
1766                                         
1767                         }// 2nd cluster loop
1768                 }////more than 1 cluster in calorimeter         
1769         }//cluster loop
1770         
1771         //Number of clusters per module
1772         for(Int_t imod = 0; imod < fNModules; imod++ ){ 
1773                 if(GetDebug() > 1) 
1774                         printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - module %d calo %s clusters %d\n", imod, fCalorimeter.Data(), nClustersInModule[imod]); 
1775                 fhNClustersMod[imod]->Fill(nClustersInModule[imod]);
1776         }
1777         delete [] nClustersInModule;
1778         delete caloClusters;
1779
1780         //----------------------------------------------------------
1781         // CALOCELLS
1782         //----------------------------------------------------------
1783         
1784         Int_t *nCellsInModule = new Int_t[fNModules];
1785         for(Int_t imod = 0; imod < fNModules; imod++ ) nCellsInModule[imod] = 0;
1786         Int_t icol     = -1;
1787         Int_t irow     = -1;
1788         Int_t iRCU     = -1;
1789         Float_t amp    = 0.;
1790         Float_t time   = 0.;
1791         Int_t id       = -1;
1792         Float_t recalF = 1.;
1793         
1794         if(GetReader()->GetDataType()==AliCaloTrackReader::kESD){
1795                 AliESDCaloCells * cell = 0x0; 
1796                 Int_t ncells = 0;
1797                 if(fCalorimeter == "PHOS") cell =  ((AliESDEvent*)GetReader()->GetInputEvent())->GetPHOSCells();
1798                 else                           cell =  ((AliESDEvent*)GetReader()->GetInputEvent())->GetEMCALCells();
1799                                 
1800                 if(!cell) {
1801                         printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - STOP: No %s ESD CELLS available for analysis\n",fCalorimeter.Data());
1802                         abort();
1803                 }
1804                 
1805                 ncells = cell->GetNumberOfCells() ;
1806                 fhNCells->Fill(ncells) ;
1807                 if(GetDebug() > 0) 
1808                         printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - In ESD %s cell entries %d\n", fCalorimeter.Data(), ncells);    
1809                 
1810                 for (Int_t iCell = 0; iCell < ncells; iCell++) {      
1811                         if(GetDebug() > 2)  printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Cell : amp %f, absId %d \n", cell->GetAmplitude(iCell), cell->GetCellNumber(iCell));
1812                         nModule = GetModuleNumberCellIndexes(cell->GetCellNumber(iCell),fCalorimeter, icol, irow, iRCU);
1813                         if(GetDebug() > 2) printf("\t module %d, column %d, row %d \n", nModule,icol,irow);
1814                         
1815                         if(nModule < fNModules) {       
1816                                 //Check if the cell is a bad channel
1817                                 if(GetCaloUtils()->IsBadChannelsRemovalSwitchedOn()){
1818                                         if(fCalorimeter=="EMCAL"){
1819                                                 if(GetCaloUtils()->GetEMCALChannelStatus(nModule,icol,irow)) continue;
1820                                         }
1821                                         else {
1822                                                 if(GetCaloUtils()->GetPHOSChannelStatus(nModule,icol,irow)) {
1823                                                         printf("PHOS bad channel\n");
1824                                                         continue;
1825                                                 }
1826                                         }
1827                                 }
1828                                 
1829                                 //Get Recalibration factor if set
1830                                 if (GetCaloUtils()->IsRecalibrationOn()) {
1831                                         if(fCalorimeter == "PHOS") recalF = GetCaloUtils()->GetPHOSChannelRecalibrationFactor(nModule,icol,irow);
1832                                         else                           recalF = GetCaloUtils()->GetEMCALChannelRecalibrationFactor(nModule,icol,irow);
1833                                     if(fCalorimeter == "PHOS")printf("Recalibration factor (sm,row,col)=(%d,%d,%d) -  %f\n",nModule,icol,irow,recalF);
1834                                 }
1835                                 
1836                                 amp     = cell->GetAmplitude(iCell)*recalF;
1837                                 time    = cell->GetTime(iCell)*1e9;//transform time to ns
1838
1839                                 //if(amp > 3 && fCalorimeter=="EMCAL") printf("Amp = %f, time = %f, (mod, col, row)= (%d,%d,%d)\n",
1840                                 //                                                                                 amp,time,nModule,icol,irow);
1841                                 
1842                                 if(time < fTimeCutMin || time > fTimeCutMax) continue;
1843
1844                                 //printf("%s: time %g\n",fCalorimeter.Data(), time);
1845                                 id      = cell->GetCellNumber(iCell);
1846                                 fhAmplitude->Fill(amp);
1847                                 fhAmpId    ->Fill(amp,id);
1848                                 fhTime     ->Fill(time);
1849                                 fhTimeId   ->Fill(time,id);
1850                                 fhTimeAmp  ->Fill(amp,time);
1851                                 //Double_t t0 = ((AliESDEvent*)GetReader()->GetInputEvent())->GetT0();
1852                                 //printf("---->>> Time EMCal %e, T0 %e, T0 vertex %e, T0 clock %e, T0 trig %d \n",time,t0, 
1853                                 //         ((AliESDEvent*)GetReader()->GetInputEvent())->GetT0zVertex(),
1854                                 //         ((AliESDEvent*)GetReader()->GetInputEvent())->GetT0clock(),
1855                                 //         ((AliESDEvent*)GetReader()->GetInputEvent())->GetT0Trig());
1856                                 //fhT0Time     ->Fill(time-t0);
1857                                 //fhT0TimeId   ->Fill(time-t0,id);
1858                                 //fhT0TimeAmp  ->Fill(amp,time-t0);
1859                                 
1860                                 fhAmplitudeMod[nModule]->Fill(amp);
1861                                 if(fCalorimeter=="EMCAL"){
1862                                         Int_t ifrac = 0;
1863                                         if(icol > 15 && icol < 32) ifrac = 1;
1864                                         else if(icol > 31) ifrac = 2;
1865                                         fhAmplitudeModFraction[nModule*3+ifrac]->Fill(amp);
1866                                         
1867                                                                                 
1868                                 }
1869                                 
1870                                 fhTimeAmpPerRCU  [nModule*fNRCU+iRCU]->Fill(amp, time);
1871                                 //printf("id %d, nModule %d, iRCU %d: Histo Name %s\n",id, nModule,iRCU, fhTimeAmpPerRCU[nModule*fNRCU+iRCU]->GetName());
1872                                 //fhT0TimeAmpPerRCU[nModule*fNRCU+iRCU]->Fill(amp, time-t0);
1873                                 nCellsInModule[nModule]++;
1874                                 fhGridCellsMod[nModule]    ->Fill(icol,irow);
1875                                 fhGridCellsEMod[nModule]   ->Fill(icol,irow,amp);
1876                                 if(amp > 0.3){
1877                                         fhGridCellsTimeMod[nModule]->Fill(icol,irow,time);
1878                                         
1879 //                                      AliESDCaloCells * cell2 = 0x0; 
1880 //                                      if(fCalorimeter == "PHOS") cell2 =  ((AliESDEvent*)GetReader()->GetInputEvent())->GetPHOSCells();
1881 //                                      else                       cell2 =  ((AliESDEvent*)GetReader()->GetInputEvent())->GetEMCALCells();
1882 //                                      Int_t icol2    = -1;
1883 //                                      Int_t irow2    = -1;
1884 //                                      Int_t iRCU2    = -1;
1885 //                                      Float_t amp2   =  0.;
1886 //                                      Float_t time2  =  0.;
1887 //                                      Int_t id2      = -1;
1888 //                                      Int_t nModule2 = -1;
1889 //                                      for (Int_t iCell2 = 0; iCell2 < ncells; iCell2++) {  
1890 //                                              amp2    = cell2->GetAmplitude(iCell2);
1891 //                                              if(amp2 < 0.3) continue;
1892 //                                              if(iCell2 == iCell) continue;
1893 //                                              time2    = cell2->GetTime(iCell2)*1e9;//transform time to ns
1894 //                                              //printf("%s: time %g\n",fCalorimeter.Data(), time);
1895 //                                              id2      = cell2->GetCellNumber(iCell2);
1896 //                                              nModule2 = GetModuleNumberCellIndexes(cell2->GetCellNumber(iCell2), fCalorimeter, icol2, irow2, iRCU2);
1897 //                                              Int_t index = (nModule2*fNRCU+iRCU2)+(fNModules*fNRCU)*(iRCU+fNRCU*nModule); 
1898 //                                              //printf("id %d, nModule %d, iRCU %d, id2 %d, nModule2 %d, iRCU2 %d, index %d: Histo Name %s\n",id, nModule,iRCU,cell2->GetCellNumber(iCell2),nModule2,iRCU2,index, fhTimeCorrRCU[index]->GetName());
1899 //                                              fhTimeCorrRCU[index]->Fill(time,time2); 
1900 //                                              
1901 //                                      }// second cell loop
1902                                 }// amplitude cut
1903                         }//nmodules
1904                         
1905                         //Get Eta-Phi position of Cell
1906                         if(fCalorimeter=="EMCAL" && GetCaloUtils()->IsEMCALGeoMatrixSet()){
1907                           Float_t celleta = 0.;
1908                           Float_t cellphi = 0.;
1909                           GetEMCALGeometry()->EtaPhiFromIndex(id, celleta, cellphi); 
1910                           fhEtaPhiAmp->Fill(celleta,cellphi,amp);
1911                           
1912                           Double_t cellpos[] = {0, 0, 0};
1913                           GetEMCALGeometry()->GetGlobal(id, cellpos);
1914                           fhXCellE->Fill(cellpos[0],amp)  ; 
1915                           fhYCellE->Fill(cellpos[1],amp)  ; 
1916                           fhZCellE->Fill(cellpos[2],amp)  ;
1917                           Float_t rcell = TMath::Sqrt(cellpos[0]*cellpos[0]+cellpos[1]*cellpos[1]);//+cellpos[2]*cellpos[2]);
1918                           fhRCellE->Fill(rcell,amp)  ;
1919                           
1920                           fhXYZCell->Fill(cellpos[0],cellpos[1],cellpos[2])  ;
1921                         }//EMCAL Cells
1922                         else if(fCalorimeter=="PHOS" && GetCaloUtils()->IsPHOSGeoMatrixSet()){
1923                           TVector3 xyz;
1924                           Int_t relId[4], module;
1925                           Float_t xCell, zCell;
1926                           
1927                           GetPHOSGeometry()->AbsToRelNumbering(id,relId);
1928                           module = relId[0];
1929                           GetPHOSGeometry()->RelPosInModule(relId,xCell,zCell);
1930                           GetPHOSGeometry()->Local2Global(module,xCell,zCell,xyz);
1931                           Float_t rcell = TMath::Sqrt(xyz.X()*xyz.X()+xyz.Y()*xyz.Y());
1932                           fhXCellE ->Fill(xyz.X(),amp)  ; 
1933                           fhYCellE ->Fill(xyz.Y(),amp)  ; 
1934                           fhZCellE ->Fill(xyz.Z(),amp)  ;
1935                           fhRCellE ->Fill(rcell  ,amp)  ;
1936                           fhXYZCell->Fill(xyz.X(),xyz.Y(),xyz.Z())  ;
1937                         }//PHOS cells
1938                         
1939                 }//cell loop
1940         }//ESD
1941         else{//AOD
1942                 AliAODCaloCells * cell = 0x0; 
1943                 Int_t ncells = 0;
1944                 
1945                 if(fCalorimeter == "PHOS") cell = ((AliAODEvent*)GetReader()->GetInputEvent())->GetPHOSCells();
1946                 else                           cell = ((AliAODEvent*)GetReader()->GetInputEvent())->GetEMCALCells();    
1947                 
1948                 if(!cell) {
1949                         printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - STOP: No %s AOD CELLS available for analysis\n",fCalorimeter.Data());
1950                         //abort();
1951                         return;
1952                 }
1953                 
1954                 ncells = cell->GetNumberOfCells() ;
1955                 fhNCells->Fill(ncells) ;
1956                 if(GetDebug() > 0) 
1957                         printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - In AOD %s cell entries %d\n", fCalorimeter.Data(), ncells); 
1958         
1959                 for (Int_t iCell = 0; iCell < ncells; iCell++) {  
1960                         id      = cell->GetCellNumber(iCell);
1961                         if(GetDebug() > 2 )  printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Cell : amp %f, absId %d \n", cell->GetAmplitude(iCell), id);
1962                         nModule = GetModuleNumberCellIndexes(id, fCalorimeter, icol, irow, iRCU);
1963                         if(GetDebug() > 2) printf("\t module %d, column %d, row %d \n", nModule,icol,irow);
1964                         
1965                         if(nModule < fNModules) {       
1966                                 //Check if the cell is a bad channel
1967                                 if(GetCaloUtils()->IsBadChannelsRemovalSwitchedOn()){
1968                                         if(fCalorimeter=="EMCAL"){
1969                                                 if(GetCaloUtils()->GetEMCALChannelStatus(nModule,icol,irow)) continue;
1970                                         }
1971                                         else{
1972                                                 if(GetCaloUtils()->GetPHOSChannelStatus(nModule,icol,irow)) continue;
1973                                         }       
1974                                 }
1975                                 
1976                                 //Get Recalibration factor if set
1977                                 if (GetCaloUtils()->IsRecalibrationOn()) {
1978                                         if(fCalorimeter == "PHOS") recalF = GetCaloUtils()->GetPHOSChannelRecalibrationFactor(nModule,icol,irow);
1979                                         else                           recalF = GetCaloUtils()->GetEMCALChannelRecalibrationFactor(nModule,icol,irow);
1980                                         //printf("Recalibration factor (sm,row,col)=(%d,%d,%d) -  %f\n",nModule,icol,irow,recalF);
1981                                 }                               
1982                                 
1983                                 amp     = cell->GetAmplitude(iCell)*recalF;
1984                                 fhAmplitude->Fill(amp);
1985                                 fhAmpId    ->Fill(amp,id);
1986                                 fhAmplitudeMod[nModule]->Fill(amp);
1987                                 if(fCalorimeter=="EMCAL"){
1988                                         Int_t ifrac = 0;
1989                                         if(icol > 15 && icol < 32) ifrac = 1;
1990                                         else if(icol > 31) ifrac = 2;
1991                                         fhAmplitudeModFraction[nModule*3+ifrac]->Fill(amp);
1992                                 }
1993                                 
1994                                 fhTimeAmpPerRCU[nModule*fNRCU+iRCU]->Fill(amp, -1);
1995                                 
1996                                 nCellsInModule[nModule]++;
1997                                 fhGridCellsMod[nModule] ->Fill(icol,irow);
1998                                 fhGridCellsEMod[nModule]->Fill(icol,irow,amp);
1999                                 
2000                         }//nmodules
2001                         
2002                         //Get Eta-Phi position of Cell
2003                         if(fCalorimeter=="EMCAL" && GetCaloUtils()->IsEMCALGeoMatrixSet()){
2004                           Float_t celleta = 0.;
2005                           Float_t cellphi = 0.;
2006                           GetEMCALGeometry()->EtaPhiFromIndex(id, celleta, cellphi); 
2007                           fhEtaPhiAmp->Fill(celleta,cellphi,amp);
2008                           
2009                           Double_t cellpos[] = {0, 0, 0};
2010                           GetEMCALGeometry()->GetGlobal(id, cellpos);
2011                           fhXCellE->Fill(cellpos[0],amp)  ; 
2012                           fhYCellE->Fill(cellpos[1],amp)  ; 
2013                           fhZCellE->Fill(cellpos[2],amp)  ;
2014                           Float_t rcell = TMath::Sqrt(cellpos[0]*cellpos[0]+cellpos[1]*cellpos[1]);//+cellpos[2]*cellpos[2]);
2015                           fhRCellE->Fill(rcell,amp)  ;
2016                           
2017                           fhXYZCell->Fill(cellpos[0],cellpos[1],cellpos[2])  ;
2018                         }//EMCAL Cells
2019                         else if(fCalorimeter=="PHOS" && GetCaloUtils()->IsPHOSGeoMatrixSet()){
2020                           TVector3 xyz;
2021                           Int_t relId[4], module;
2022                           Float_t xCell, zCell;
2023                           
2024                           GetPHOSGeometry()->AbsToRelNumbering(id,relId);
2025                           module = relId[0];
2026                           GetPHOSGeometry()->RelPosInModule(relId,xCell,zCell);
2027                           GetPHOSGeometry()->Local2Global(module,xCell,zCell,xyz);
2028                           Float_t rcell = TMath::Sqrt(xyz.X()*xyz.X()+xyz.Y()*xyz.Y());
2029                           fhXCellE ->Fill(xyz.X(),amp)  ; 
2030                           fhYCellE ->Fill(xyz.Y(),amp)  ; 
2031                           fhZCellE ->Fill(xyz.Z(),amp)  ;
2032                           fhRCellE ->Fill(rcell  ,amp)  ;
2033                           fhXYZCell->Fill(xyz.X(),xyz.Y(),xyz.Z())  ;
2034                         }//PHOS Cells
2035                 }//cell loop
2036         }//AOD
2037
2038         //Number of cells per module
2039         for(Int_t imod = 0; imod < fNModules; imod++ ) {
2040                 if(GetDebug() > 1) 
2041                         printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - module %d calo %s cells %d\n", imod, fCalorimeter.Data(), nCellsInModule[imod]); 
2042                 fhNCellsMod[imod]->Fill(nCellsInModule[imod]) ;
2043         }
2044         delete [] nCellsInModule;
2045         
2046         if(GetDebug() > 0)
2047                 printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - End \n");
2048 }
2049
2050
2051 //__________________________________
2052 void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Double_t tof, Float_t *pos, Float_t *showerShape,
2053                                             const Int_t nCaloCellsPerCluster,const Int_t nModule,
2054                                             const Int_t nTracksMatched,  const TObject * track,  
2055                                             const Int_t * labels, const Int_t nLabels){
2056         //Fill CaloCluster related histograms
2057         
2058         AliAODMCParticle * aodprimary  = 0x0;
2059         TParticle * primary = 0x0;
2060     Int_t tag = 0;      
2061         
2062         Float_t e   = mom.E();
2063         Float_t pt  = mom.Pt();
2064         Float_t eta = mom.Eta();
2065         Float_t phi = mom.Phi();
2066         if(phi < 0) phi +=TMath::TwoPi();
2067         if(GetDebug() > 0) {
2068                 printf("AliAnaCalorimeterQA::ClusterHistograms() - cluster: E %2.3f, pT %2.3f, eta %2.3f, phi %2.3f \n",e,pt,eta,phi*TMath::RadToDeg());
2069                 if(IsDataMC()) {
2070                         //printf("\t Primaries: nlabels %d, labels pointer %p\n",nLabels,labels);
2071                         printf("\t Primaries: nlabels %d\n",nLabels);
2072                         if(!nLabels || !labels) printf("\t Strange, no labels!!!\n");
2073                 }
2074         }
2075
2076         fhE     ->Fill(e);      
2077         if(nModule < fNModules) fhEMod[nModule]->Fill(e);
2078         fhPt     ->Fill(pt);
2079         fhPhi    ->Fill(phi);
2080         fhEta    ->Fill(eta);
2081         fhEtaPhiE->Fill(eta,phi,e);
2082         fhXE     ->Fill(pos[0],e);
2083         fhYE     ->Fill(pos[1],e);
2084         fhZE     ->Fill(pos[2],e);
2085         fhXYZ    ->Fill(pos[0], pos[1],pos[2]);
2086         Float_t rxyz = TMath::Sqrt(pos[0]*pos[0]+pos[1]*pos[1]);//+pos[2]*pos[2]);
2087         fhRE     ->Fill(rxyz,e);
2088         fhClusterTimeEnergy->Fill(e,tof);
2089         
2090         //Shower shape parameters
2091         fhLambda->Fill(showerShape[0], showerShape[1], e);
2092         fhDispersion->Fill(showerShape[2],e);
2093
2094         //Cells per cluster
2095         fhNCellsPerCluster   ->Fill(e, nCaloCellsPerCluster,eta);
2096         fhNCellsPerClusterMIP->Fill(e, nCaloCellsPerCluster,eta);
2097         fhXNCells->Fill(pos[0],nCaloCellsPerCluster);
2098         fhYNCells->Fill(pos[1],nCaloCellsPerCluster);
2099         fhZNCells->Fill(pos[2],nCaloCellsPerCluster);
2100         fhRNCells->Fill(rxyz  ,nCaloCellsPerCluster);
2101         
2102         if(nModule < fNModules) fhNCellsPerClusterMod[nModule]->Fill(e, nCaloCellsPerCluster);
2103         
2104         //Fill histograms only possible when simulation
2105         if(IsDataMC() && nLabels > 0 && labels){
2106
2107                 //Play with the MC stack if available
2108                 Int_t label = labels[0];
2109
2110                 if(label < 0) {
2111                         if(GetDebug() >= 0) printf("AliAnaCalorimeterQA::ClusterHistograms() *** bad label ***:  label %d \n", label);
2112                         return;
2113                 }
2114
2115                 Int_t pdg  =-1; Int_t pdg0  =-1;Int_t status = -1; Int_t iMother = -1; Int_t iParent = -1;
2116                 Float_t vxMC= 0; Float_t vyMC = 0;      
2117                 Float_t eMC = 0; Float_t ptMC= 0; Float_t phiMC =0; Float_t etaMC = 0;
2118                 Int_t charge = 0;       
2119                 
2120                 //Check the origin.
2121                 tag = GetMCAnalysisUtils()->CheckOrigin(labels,nLabels, GetReader(),0);
2122
2123                 if(GetReader()->ReadStack() && !GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCUnknown)){ //it MC stack and known tag
2124
2125                         if( label >= GetMCStack()->GetNtrack()) {
2126                                 if(GetDebug() >= 0) printf("AliAnaCalorimeterQA::ClusterHistograms() *** large label ***:  label %d, n tracks %d \n", label, GetMCStack()->GetNtrack());
2127                                 return ;
2128                         }
2129                         
2130                         primary = GetMCStack()->Particle(label);
2131                         iMother = label;
2132                         pdg0    = TMath::Abs(primary->GetPdgCode());
2133                         pdg     = pdg0;
2134                         status  = primary->GetStatusCode();
2135                         vxMC    = primary->Vx();
2136                         vyMC    = primary->Vy();
2137                         iParent = primary->GetFirstMother();
2138                                 
2139                         if(GetDebug() > 1 ) {
2140                                 printf("AliAnaCalorimeterQA::ClusterHistograms() - Cluster most contributing mother: \n");
2141                                 printf("\t Mother label %d, pdg %d, %s, status %d, parent %d \n",iMother, pdg0, primary->GetName(),status, iParent);
2142                         }
2143                                 
2144                         //Get final particle, no conversion products
2145                         if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCConversion)){
2146                                 //Get the parent
2147                                 primary = GetMCStack()->Particle(iParent);
2148                                 pdg = TMath::Abs(primary->GetPdgCode());
2149                                 if(GetDebug() > 1 ) printf("AliAnaCalorimeterQA::ClusterHistograms() - Converted cluster!. Find before conversion: \n");
2150                                 while((pdg == 22 || pdg == 11) && status != 1){
2151                                         iMother = iParent;
2152                                         primary = GetMCStack()->Particle(iMother);
2153                                         status  = primary->GetStatusCode();
2154                                         iParent = primary->GetFirstMother();
2155                                         pdg     = TMath::Abs(primary->GetPdgCode());
2156                                         if(GetDebug() > 1 )printf("\t pdg %d, index %d, %s, status %d \n",pdg, iMother,  primary->GetName(),status);    
2157                                 }       
2158                                         
2159                                 if(GetDebug() > 1 ) {
2160                                         printf("AliAnaCalorimeterQA::ClusterHistograms() - Converted Cluster mother before conversion: \n");
2161                                         printf("\t Mother label %d, pdg %d, %s, status %d, parent %d \n",iMother, pdg, primary->GetName(), status, iParent);
2162                                 }
2163                                         
2164                         }
2165                                 
2166                         //Overlapped pi0 (or eta, there will be very few), get the meson
2167                         if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCPi0) || 
2168                                 GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCEta)){
2169                                 if(GetDebug() > 1 ) printf("AliAnaCalorimeterQA::ClusterHistograms() - Overlapped Meson decay!, Find it: \n");
2170                                 while(pdg != 111 && pdg != 221){
2171                                         iMother = iParent;
2172                                         primary = GetMCStack()->Particle(iMother);
2173                                         status  = primary->GetStatusCode();
2174                                         iParent = primary->GetFirstMother();
2175                                         pdg     = TMath::Abs(primary->GetPdgCode());
2176                                         if(GetDebug() > 1 ) printf("\t pdg %d, %s, index %d\n",pdg,  primary->GetName(),iMother);
2177                                         if(iMother==-1) {
2178                                                 printf("AliAnaCalorimeterQA::ClusterHistograms() - Tagged as Overlapped photon but meson not found, why?\n");
2179                                                 //break;
2180                                         }
2181                                 }
2182
2183                                 if(GetDebug() > 2 ) printf("AliAnaCalorimeterQA::ClusterHistograms() - Overlapped %s decay, label %d \n", 
2184                                                                                 primary->GetName(),iMother);
2185                         }
2186                                 
2187                         eMC    = primary->Energy();
2188                         ptMC   = primary->Pt();
2189                         phiMC  = primary->Phi();
2190                         etaMC  = primary->Eta();
2191                         pdg    = TMath::Abs(primary->GetPdgCode());
2192                         charge = (Int_t) TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
2193
2194                 }
2195                 else if(GetReader()->ReadAODMCParticles() && !GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCUnknown)){//it MC AOD and known tag
2196                         //Get the list of MC particles
2197                         if(!GetReader()->GetAODMCParticles(0))  {
2198                                 printf("AliAnaCalorimeterQA::ClusterHistograms() -  MCParticles not available!\n");
2199                                 abort();
2200                         }               
2201                         
2202                         aodprimary = (AliAODMCParticle*) (GetReader()->GetAODMCParticles(0))->At(label);
2203                         iMother = label;
2204                         pdg0    = TMath::Abs(aodprimary->GetPdgCode());
2205                         pdg     = pdg0;
2206                         status  = aodprimary->IsPrimary();
2207                         vxMC    = aodprimary->Xv();
2208                         vyMC    = aodprimary->Yv();
2209                         iParent = aodprimary->GetMother();
2210                                 
2211                         if(GetDebug() > 1 ) {
2212                                 printf("AliAnaCalorimeterQA::ClusterHistograms() - Cluster most contributing mother: \n");
2213                                 printf("\t Mother label %d, pdg %d, Primary? %d, Physical Primary? %d, parent %d \n",
2214                                            iMother, pdg0, aodprimary->IsPrimary(), aodprimary->IsPhysicalPrimary(), iParent);
2215                         }
2216                         
2217                         //Get final particle, no conversion products
2218                         if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCConversion)){
2219                                 if(GetDebug() > 1 ) 
2220                                         printf("AliAnaCalorimeterQA::ClusterHistograms() - Converted cluster!. Find before conversion: \n");
2221                                 //Get the parent
2222                                 aodprimary = (AliAODMCParticle*)(GetReader()->GetAODMCParticles(0))->At(iParent);
2223                                 pdg = TMath::Abs(aodprimary->GetPdgCode());
2224                                 while ((pdg == 22 || pdg == 11) && !aodprimary->IsPhysicalPrimary()) {
2225                                         iMother    = iParent;
2226                                         aodprimary = (AliAODMCParticle*)(GetReader()->GetAODMCParticles(0))->At(iMother);
2227                                         status     = aodprimary->IsPrimary();
2228                                         iParent    = aodprimary->GetMother();
2229                                         pdg        = TMath::Abs(aodprimary->GetPdgCode());
2230                                         if(GetDebug() > 1 )
2231                                                 printf("\t pdg %d, index %d, Primary? %d, Physical Primary? %d \n",
2232                                                                 pdg, iMother, aodprimary->IsPrimary(), aodprimary->IsPhysicalPrimary());        
2233                                 }       
2234                                 
2235                                 if(GetDebug() > 1 ) {
2236                                         printf("AliAnaCalorimeterQA::ClusterHistograms() - Converted Cluster mother before conversion: \n");
2237                                         printf("\t Mother label %d, pdg %d, parent %d, Primary? %d, Physical Primary? %d \n",
2238                                                    iMother, pdg, iParent, aodprimary->IsPrimary(), aodprimary->IsPhysicalPrimary());
2239                                 }
2240                                 
2241                         }
2242                                 
2243                         //Overlapped pi0 (or eta, there will be very few), get the meson
2244                         if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCPi0) || 
2245                                 GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCEta)){
2246                                 if(GetDebug() > 1 ) printf("AliAnaCalorimeterQA::ClusterHistograms() - Overlapped Meson decay!, Find it: PDG %d, mom %d \n",pdg, iMother);
2247                                 while(pdg != 111 && pdg != 221){
2248                                         
2249                                         iMother    = iParent;
2250                                         aodprimary = (AliAODMCParticle*)(GetReader()->GetAODMCParticles(0))->At(iMother);
2251                                         status     = aodprimary->IsPrimary();
2252                                         iParent    = aodprimary->GetMother();
2253                                         pdg        = TMath::Abs(aodprimary->GetPdgCode());
2254
2255                                         if(GetDebug() > 1 ) printf("\t pdg %d, index %d\n",pdg, iMother);
2256                                         
2257                                         if(iMother==-1) {
2258                                                 printf("AliAnaCalorimeterQA::ClusterHistograms() - Tagged as Overlapped photon but meson not found, why?\n");
2259                                                 //break;
2260                                         }
2261                                 }       
2262                                 
2263                                 if(GetDebug() > 2 ) printf("AliAnaCalorimeterQA::ClusterHistograms() - Overlapped %s decay, label %d \n", 
2264                                                                                    aodprimary->GetName(),iMother);
2265                         }       
2266                                                 
2267                         status = aodprimary->IsPrimary();
2268                         eMC    = aodprimary->E();
2269                         ptMC   = aodprimary->Pt();
2270                         phiMC  = aodprimary->Phi();
2271                         etaMC  = aodprimary->Eta();
2272                         pdg    = TMath::Abs(aodprimary->GetPdgCode());
2273                         charge = aodprimary->Charge();
2274                                 
2275                 }
2276         
2277                 //Float_t vz = primary->Vz();
2278                 Float_t rVMC = TMath::Sqrt(vxMC*vxMC + vyMC*vyMC);
2279                 if((pdg == 22 || TMath::Abs(pdg)==11) && status!=1) {
2280                         fhEMVxyz   ->Fill(vxMC,vyMC);//,vz);
2281                         fhEMR      ->Fill(e,rVMC);
2282                 }
2283                     
2284                 //printf("reco e %f, pt %f, phi %f, eta %f \n", e, pt, phi, eta);
2285                 //printf("prim e %f, pt %f, phi %f, eta %f \n", eMC,ptMC,phiMC ,etaMC );
2286                 //printf("vertex: vx %f, vy %f, vz %f, r %f \n", vxMC, vyMC, vz, r);
2287                         
2288
2289                 fh2E      ->Fill(e, eMC);
2290                 fh2Pt     ->Fill(pt, ptMC);
2291                 fh2Phi    ->Fill(phi, phiMC);
2292                 fh2Eta    ->Fill(eta, etaMC);
2293                 fhDeltaE  ->Fill(eMC-e);
2294                 fhDeltaPt ->Fill(ptMC-pt);
2295                 fhDeltaPhi->Fill(phiMC-phi);
2296                 fhDeltaEta->Fill(etaMC-eta);
2297                 if(eMC   > 0) fhRatioE  ->Fill(e/eMC);
2298                 if(ptMC  > 0) fhRatioPt ->Fill(pt/ptMC);
2299                 if(phiMC > 0) fhRatioPhi->Fill(phi/phiMC);
2300                 if(etaMC > 0) fhRatioEta->Fill(eta/etaMC);                      
2301                         
2302                         
2303                 //Overlapped pi0 (or eta, there will be very few)
2304                 if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCPi0) || 
2305                         GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCEta)){
2306                                 fhPi0E     ->Fill(e,eMC);       
2307                                 fhPi0Pt    ->Fill(pt,ptMC);
2308                                 fhPi0Eta   ->Fill(eta,etaMC);   
2309                                 fhPi0Phi   ->Fill(phi,phiMC);
2310                                 if( nTracksMatched > 0){
2311                                         fhPi0ECharged     ->Fill(e,eMC);                
2312                                         fhPi0PtCharged    ->Fill(pt,ptMC);
2313                                         fhPi0PhiCharged   ->Fill(phi,phiMC);
2314                                         fhPi0EtaCharged   ->Fill(eta,etaMC);
2315                                 }
2316                 }//Overlapped pizero decay
2317                 else if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCPhoton)){
2318                                 fhGamE     ->Fill(e,eMC);       
2319                                 fhGamPt    ->Fill(pt,ptMC);
2320                                 fhGamEta   ->Fill(eta,etaMC);   
2321                                 fhGamPhi   ->Fill(phi,phiMC);
2322                                 fhGamDeltaE  ->Fill(eMC-e);
2323                                 fhGamDeltaPt ->Fill(ptMC-pt);   
2324                                 fhGamDeltaPhi->Fill(phiMC-phi);
2325                                 fhGamDeltaEta->Fill(etaMC-eta);
2326                                 if(eMC > 0) fhGamRatioE  ->Fill(e/eMC);
2327                                 if(ptMC     > 0) fhGamRatioPt ->Fill(pt/ptMC);
2328                                 if(phiMC    > 0) fhGamRatioPhi->Fill(phi/phiMC);
2329                                 if(etaMC    > 0) fhGamRatioEta->Fill(eta/etaMC);
2330                                 if( nTracksMatched > 0){
2331                                         fhGamECharged     ->Fill(e,eMC);                
2332                                         fhGamPtCharged    ->Fill(pt,ptMC);
2333                                         fhGamPhiCharged   ->Fill(phi,phiMC);
2334                                         fhGamEtaCharged   ->Fill(eta,etaMC);
2335                                 }
2336                 }//photon
2337                 else if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCElectron)){
2338                         fhEleE     ->Fill(e,eMC);       
2339                         fhElePt    ->Fill(pt,ptMC);
2340                         fhEleEta   ->Fill(eta,etaMC);   
2341                         fhElePhi   ->Fill(phi,phiMC);
2342                         fhEMVxyz   ->Fill(vxMC,vyMC);//,vz);
2343                         fhEMR      ->Fill(e,rVMC);
2344                         if( nTracksMatched > 0){
2345                                 fhEleECharged     ->Fill(e,eMC);                
2346                                 fhElePtCharged    ->Fill(pt,ptMC);
2347                                 fhElePhiCharged   ->Fill(phi,phiMC);
2348                                 fhEleEtaCharged   ->Fill(eta,etaMC);
2349                         }
2350                 }
2351                 else if(charge == 0){
2352                         fhNeHadE     ->Fill(e,eMC);     
2353                         fhNeHadPt    ->Fill(pt,ptMC);
2354                         fhNeHadEta   ->Fill(eta,etaMC); 
2355                         fhNeHadPhi   ->Fill(phi,phiMC); 
2356                         fhHaVxyz     ->Fill(vxMC,vyMC);//,vz);
2357                         fhHaR        ->Fill(e,rVMC);
2358                         if( nTracksMatched > 0){
2359                                 fhNeHadECharged     ->Fill(e,eMC);              
2360                                 fhNeHadPtCharged    ->Fill(pt,ptMC);
2361                                 fhNeHadPhiCharged   ->Fill(phi,phiMC);
2362                                 fhNeHadEtaCharged   ->Fill(eta,etaMC);
2363                         }
2364                 }
2365                 else if(charge!=0){
2366                         fhChHadE     ->Fill(e,eMC);     
2367                         fhChHadPt    ->Fill(pt,ptMC);
2368                         fhChHadEta   ->Fill(eta,etaMC); 
2369                         fhChHadPhi   ->Fill(phi,phiMC); 
2370                         fhHaVxyz     ->Fill(vxMC,vyMC);//,vz);
2371                         fhHaR        ->Fill(e,rVMC);
2372                         if( nTracksMatched > 0){
2373                                 fhChHadECharged     ->Fill(e,eMC);              
2374                                 fhChHadPtCharged    ->Fill(pt,ptMC);
2375                                 fhChHadPhiCharged   ->Fill(phi,phiMC);
2376                                 fhChHadEtaCharged   ->Fill(eta,etaMC);
2377                         }
2378                 }
2379         }//Work with MC
2380                 
2381         
2382         //Match tracks and clusters
2383         //To be Modified in case of AODs
2384         
2385         //if(ntracksmatched==1 && trackIndex==-1) ntracksmatched=0;
2386         
2387         if( nTracksMatched > 0){
2388                 fhECharged      ->Fill(e);              
2389                 fhPtCharged     ->Fill(pt);
2390                 fhPhiCharged    ->Fill(phi);
2391                 fhEtaCharged    ->Fill(eta);
2392                 fhEtaPhiECharged->Fill(eta,phi,e);              
2393                 fhNCellsPerClusterMIPCharged->Fill(e, nCaloCellsPerCluster,eta);
2394                 
2395                 //printf("track index %d ntracks %d\n", esd->GetNumberOfTracks());      
2396                 //Study the track and matched cluster if track exists.
2397                 if(!track) return;
2398                 Double_t emcpos[3] = {0.,0.,0.};
2399                 Double_t emcmom[3] = {0.,0.,0.};
2400                 Double_t radius    = 441.0; //[cm] EMCAL radius +13cm
2401                 Double_t bfield    = 0.;
2402                 Double_t tphi      = 0;
2403                 Double_t teta      = 0;
2404                 Double_t tmom      = 0;
2405                 Double_t tpt       = 0;
2406                 Double_t tmom2     = 0;
2407                 Double_t tpcSignal = 0;
2408                 Bool_t okpos = kFALSE;
2409                 Bool_t okmom = kFALSE;
2410                 Bool_t okout = kFALSE;
2411                 Int_t nITS   = 0;
2412                 Int_t nTPC   = 0;
2413                 
2414                 //In case of ESDs get the parameters in this way
2415                 if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
2416                         if (((AliESDtrack*)track)->GetOuterParam() ) {
2417                                 okout = kTRUE;
2418                                 
2419                                 bfield = ((AliESDEvent*)GetReader()->GetInputEvent())->GetMagneticField();
2420                                 okpos = ((AliESDtrack*)track)->GetOuterParam()->GetXYZAt(radius,bfield,emcpos);
2421                                 okmom = ((AliESDtrack*)track)->GetOuterParam()->GetPxPyPzAt(radius,bfield,emcmom);
2422                                 if(!(okpos && okmom)) return;
2423
2424                                 TVector3 position(emcpos[0],emcpos[1],emcpos[2]);
2425                                 TVector3 momentum(emcmom[0],emcmom[1],emcmom[2]);
2426                                 tphi = position.Phi();
2427                                 teta = position.Eta();
2428                                 tmom = momentum.Mag();
2429                                 
2430                                 //Double_t tphi  = ((AliESDtrack*)track)->GetOuterParam()->Phi();
2431                                 //Double_t teta  = ((AliESDtrack*)track)->GetOuterParam()->Eta();
2432                                 //Double_t tmom  = ((AliESDtrack*)track)->GetOuterParam()->P();
2433                                 tpt       = ((AliESDtrack*)track)->Pt();
2434                                 tmom2     = ((AliESDtrack*)track)->P();
2435                                 tpcSignal = ((AliESDtrack*)track)->GetTPCsignal();
2436                                 
2437                                 nITS = ((AliESDtrack*)track)->GetNcls(0);
2438                                 nTPC = ((AliESDtrack*)track)->GetNcls(1);
2439                                 }//Outer param available 
2440                         }// ESDs
2441                         else if(GetReader()->GetDataType()==AliCaloTrackReader::kAOD) {
2442                                 AliAODPid* pid = (AliAODPid*) ((AliAODTrack *) track)->GetDetPid();
2443                                 if (pid) {
2444                                         okout = kTRUE;
2445                                         pid->GetEMCALPosition(emcpos);
2446                                         pid->GetEMCALMomentum(emcmom);  
2447                                         
2448                                         TVector3 position(emcpos[0],emcpos[1],emcpos[2]);
2449                                         TVector3 momentum(emcmom[0],emcmom[1],emcmom[2]);
2450                                         tphi = position.Phi();
2451                                         teta = position.Eta();
2452                                         tmom = momentum.Mag();
2453                                         
2454                                         tpt       = ((AliAODTrack*)track)->Pt();
2455                                         tmom2     = ((AliAODTrack*)track)->P();
2456                                         tpcSignal = pid->GetTPCsignal();
2457                                 
2458                                         //nITS = ((AliAODTrack*)track)->GetNcls(0);
2459                                         //nTPC = ((AliAODTrack*)track)->GetNcls(1);
2460                                 }//Outer param available 
2461                         }//AODs
2462                         else return; //Do nothing case not implemented.
2463                 
2464                         if(okout){
2465                                 Double_t deta = teta - eta;
2466                                 Double_t dphi = tphi - phi;
2467                                 if(dphi > TMath::Pi()) dphi -= 2*TMath::Pi();
2468                                 if(dphi < -TMath::Pi()) dphi += 2*TMath::Pi();
2469                                 Double_t dR = sqrt(dphi*dphi + deta*deta);
2470                         
2471                                 Double_t pOverE = tmom/e;
2472                         
2473                                 fh1pOverE->Fill(tpt, pOverE);
2474                                 if(dR < 0.02) fh1pOverER02->Fill(tpt,pOverE);
2475                         
2476                                 fh1dR->Fill(dR);
2477                                 fh2MatchdEdx->Fill(tmom2,tpcSignal);
2478                         
2479                                 if(IsDataMC() && primary){ 
2480                                         Int_t pdg = primary->GetPdgCode();
2481                                         Double_t  charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
2482                                 
2483                                         if(TMath::Abs(pdg) == 11){
2484                                                 fhMCEle1pOverE->Fill(tpt,pOverE);
2485                                                 fhMCEle1dR->Fill(dR);
2486                                                 fhMCEle2MatchdEdx->Fill(tmom2,tpcSignal);               
2487                                                 if(dR < 0.02) fhMCEle1pOverER02->Fill(tpt,pOverE);
2488                                         }
2489                                         else if(charge!=0){
2490                                                 fhMCChHad1pOverE->Fill(tpt,pOverE);
2491                                                 fhMCChHad1dR->Fill(dR);
2492                                                 fhMCChHad2MatchdEdx->Fill(tmom2,tpcSignal);     
2493                                                 if(dR < 0.02) fhMCChHad1pOverER02->Fill(tpt,pOverE);
2494                                         }
2495                                         else if(charge == 0){
2496                                                 fhMCNeutral1pOverE->Fill(tpt,pOverE);
2497                                                 fhMCNeutral1dR->Fill(dR);
2498                                                 fhMCNeutral2MatchdEdx->Fill(tmom2,tpcSignal);   
2499                                                 if(dR < 0.02) fhMCNeutral1pOverER02->Fill(tpt,pOverE);
2500                                         }
2501                                 }//DataMC
2502
2503                                 if(dR < 0.02 && pOverE > 0.5 && pOverE < 1.5
2504                                    && nCaloCellsPerCluster > 1 && nITS > 3 && nTPC > 20) {
2505                                         fh2EledEdx->Fill(tmom2,tpcSignal);
2506                                 }
2507                         }
2508                         else{//no ESD external param or AODPid
2509 //                                      ULong_t status=AliESDtrack::kTPCrefit;
2510 //                              status|=AliESDtrack::kITSrefit;
2511                                 //printf("track status %d\n", track->GetStatus() );
2512 //                              fhEChargedNoOut      ->Fill(e);         
2513 //                              fhPtChargedNoOut     ->Fill(pt);
2514 //                              fhPhiChargedNoOut    ->Fill(phi);
2515 //                              fhEtaChargedNoOut    ->Fill(eta);
2516 //                              fhEtaPhiChargedNoOut ->Fill(eta,phi);
2517 //                              if(GetDebug() >= 0 && ((((AliESDtrack*)track)->GetStatus() & status) == status)) printf("ITS+TPC\n");
2518                                 if(GetDebug() >= 0) printf("No ESD external param or AliAODPid \n");
2519
2520                         }//No out params
2521         }//matched clusters with tracks
2522                 
2523 }// Clusters
2524         
2525 //__________________________________
2526 void AliAnaCalorimeterQA::CorrelateCalorimeters(TRefArray* refArray){
2527         // Correlate information from PHOS and EMCAL
2528         TRefArray * caloClustersEMCAL = 0;
2529         TRefArray * caloClustersPHOS  = 0;
2530         
2531         // Get once the array of clusters per calorimeter, avoid an extra loop.
2532         if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
2533                 if(fCalorimeter == "EMCAL"){ 
2534                         caloClustersPHOS = new TRefArray();
2535                         ((AliESDEvent*)GetReader()->GetInputEvent())->GetPHOSClusters(caloClustersPHOS);
2536                         caloClustersEMCAL = new TRefArray(*refArray);
2537                 }
2538                 else if(fCalorimeter == "PHOS") { 
2539                         caloClustersEMCAL = new TRefArray();
2540                         ((AliESDEvent*)GetReader()->GetInputEvent())->GetEMCALClusters (caloClustersEMCAL);
2541                         caloClustersPHOS = new TRefArray(*refArray);
2542                 }
2543                 
2544                 //Fill histograms with clusters
2545                 
2546                 fhCaloCorrNClusters->Fill(caloClustersEMCAL->GetEntriesFast(),caloClustersPHOS->GetEntriesFast());
2547                 Float_t sumClusterEnergyEMCAL = 0;
2548                 Float_t sumClusterEnergyPHOS  = 0;
2549                 Int_t iclus = 0;
2550                 for(iclus = 0 ; iclus <  caloClustersEMCAL->GetEntriesFast() ; iclus++) 
2551                                 sumClusterEnergyEMCAL += ((AliESDCaloCluster*) (caloClustersEMCAL->At(iclus)))->E();
2552                 for(iclus = 0 ; iclus <  caloClustersPHOS->GetEntriesFast(); iclus++) 
2553                         sumClusterEnergyPHOS += ((AliESDCaloCluster*) (caloClustersPHOS->At(iclus)))->E();
2554                 fhCaloCorrEClusters->Fill(sumClusterEnergyEMCAL,sumClusterEnergyPHOS);
2555                 
2556                 //Fill histograms with cells
2557                 
2558                 AliESDCaloCells * cellsEMCAL = ((AliESDEvent*)GetReader()->GetInputEvent())->GetEMCALCells();
2559                 AliESDCaloCells * cellsPHOS  = ((AliESDEvent*)GetReader()->GetInputEvent())->GetPHOSCells();
2560                 fhCaloCorrNCells   ->Fill(cellsEMCAL->GetNumberOfCells(),cellsPHOS->GetNumberOfCells());
2561                 
2562                 Int_t icell = 0;
2563                 Float_t sumCellEnergyEMCAL = 0;
2564                 Float_t sumCellEnergyPHOS  = 0;
2565                 for(icell = 0 ; icell < cellsEMCAL->GetNumberOfCells()  ; icell++) 
2566                         sumCellEnergyEMCAL += cellsEMCAL->GetAmplitude(icell);
2567                 for(icell = 0 ; icell <  cellsPHOS->GetNumberOfCells(); icell++) 
2568                         sumCellEnergyPHOS += cellsPHOS->GetAmplitude(icell);
2569                 fhCaloCorrECells->Fill(sumCellEnergyEMCAL,sumCellEnergyPHOS);
2570                 if(GetDebug() > 0 ){
2571                         printf("AliAnaCalorimeterQA::CorrelateCalorimeters() - ESD: \n");
2572                         printf("\t EMCAL: N cells %d, N clusters  %d, summed E cells %f, summed E clusters %f \n",
2573                                    cellsEMCAL->GetNumberOfCells(),caloClustersEMCAL->GetEntriesFast(),sumCellEnergyEMCAL,sumClusterEnergyEMCAL);
2574                         printf("\t PHOS : N cells %d, N clusters  %d, summed E cells %f, summed E clusters %f \n",
2575                                    cellsPHOS->GetNumberOfCells(),caloClustersPHOS->GetEntriesFast(),sumCellEnergyPHOS,sumClusterEnergyPHOS);
2576                 }
2577         }//ESD
2578         else if(GetReader()->GetDataType()==AliCaloTrackReader::kAOD) {
2579                 if(fCalorimeter == "EMCAL"){ 
2580                         ((AliAODEvent*)GetReader()->GetInputEvent())->GetPHOSClusters(caloClustersPHOS);
2581                         caloClustersEMCAL = refArray;
2582                 }
2583                 else if(fCalorimeter == "PHOS") { 
2584                         ((AliAODEvent*)GetReader()->GetInputEvent())->GetEMCALClusters (caloClustersEMCAL);
2585                         caloClustersEMCAL = refArray;
2586                 }
2587                 
2588                 //Fill histograms with clusters
2589                 
2590                 fhCaloCorrNClusters->Fill(caloClustersEMCAL->GetEntriesFast(),caloClustersPHOS->GetEntriesFast());
2591                 Float_t sumClusterEnergyEMCAL = 0;
2592                 Float_t sumClusterEnergyPHOS  = 0;
2593                 Int_t iclus = 0;
2594                 for(iclus = 0 ; iclus <  caloClustersEMCAL->GetEntriesFast() ; iclus++) 
2595                         sumClusterEnergyEMCAL += ((AliAODCaloCluster*) (caloClustersEMCAL->At(iclus)))->E();
2596                 for(iclus = 0 ; iclus <  caloClustersPHOS->GetEntriesFast(); iclus++) 
2597                         sumClusterEnergyPHOS += ((AliAODCaloCluster*) (caloClustersPHOS->At(iclus)))->E();
2598                 fhCaloCorrEClusters->Fill(sumClusterEnergyEMCAL,sumClusterEnergyPHOS);
2599                 
2600                 //Fill histograms with cells
2601                 
2602                 AliAODCaloCells * cellsEMCAL = ((AliAODEvent*)GetReader()->GetInputEvent())->GetEMCALCells();
2603                 AliAODCaloCells * cellsPHOS  = ((AliAODEvent*)GetReader()->GetInputEvent())->GetPHOSCells();
2604                 fhCaloCorrNCells   ->Fill(cellsEMCAL->GetNumberOfCells(),cellsPHOS->GetNumberOfCells());
2605                 
2606                 Int_t icell = 0;
2607                 Float_t sumCellEnergyEMCAL = 0;
2608                 Float_t sumCellEnergyPHOS  = 0;
2609                 for(icell = 0 ; icell < cellsEMCAL->GetNumberOfCells()  ; icell++) 
2610                         sumCellEnergyEMCAL += cellsEMCAL->GetAmplitude(icell);
2611                 for(icell = 0 ; icell <  cellsPHOS->GetNumberOfCells(); icell++) 
2612                         sumCellEnergyPHOS += cellsPHOS->GetAmplitude(icell);
2613                 fhCaloCorrECells->Fill(sumCellEnergyEMCAL,sumCellEnergyPHOS);           
2614                 if(GetDebug() > 0 ){
2615                         printf("AliAnaCalorimeterQA::CorrelateCalorimeters() - ESD: \n");
2616                         printf("\t EMCAL: N cells %d, N clusters  %d, summed E cells %f, summed E clusters %f \n",
2617                                    cellsEMCAL->GetNumberOfCells(),caloClustersEMCAL->GetEntriesFast(),sumCellEnergyEMCAL,sumClusterEnergyEMCAL);
2618                         printf("\t PHOS : N cells %d, N clusters  %d, summed E cells %f, summed E clusters %f \n",
2619                                    cellsPHOS->GetNumberOfCells(),caloClustersPHOS->GetEntriesFast(),sumCellEnergyPHOS,sumClusterEnergyPHOS);
2620                 }
2621         }//AOD  
2622         
2623         delete caloClustersEMCAL;
2624         delete caloClustersPHOS;
2625         
2626 }
2627
2628 //______________________________________________________________________________
2629 void AliAnaCalorimeterQA::MCHistograms(const TLorentzVector mom, const Int_t pdg){
2630         //Fill pure monte carlo related histograms
2631         
2632         Float_t eMC    = mom.E();
2633         Float_t ptMC   = mom.Pt();
2634         Float_t phiMC  = mom.Phi();
2635         if(phiMC < 0) 
2636                 phiMC  += TMath::TwoPi();
2637         Float_t etaMC  = mom.Eta();
2638         
2639         if (TMath::Abs(etaMC) > 1) return;
2640
2641         Bool_t in = kTRUE;
2642         if(IsFiducialCutOn()) in =  GetFiducialCut()->IsInFiducialCut(mom,fCalorimeter) ;
2643         
2644         if (pdg==22) {
2645                 fhGenGamPt ->Fill(ptMC);
2646                 fhGenGamEta->Fill(etaMC);
2647                 fhGenGamPhi->Fill(phiMC);
2648                 if(in){
2649                         fhGenGamAccE  ->Fill(eMC);
2650                         fhGenGamAccPt ->Fill(ptMC);
2651                         fhGenGamAccEta->Fill(etaMC);
2652                         fhGenGamAccPhi->Fill(phiMC);                                    
2653                 }
2654         }
2655         else if (pdg==111) {
2656                 fhGenPi0Pt ->Fill(ptMC);
2657                 fhGenPi0Eta->Fill(etaMC);
2658                 fhGenPi0Phi->Fill(phiMC);
2659                 if(in){
2660                         fhGenPi0AccE  ->Fill(eMC);                                      
2661                         fhGenPi0AccPt ->Fill(ptMC);
2662                         fhGenPi0AccEta->Fill(etaMC);
2663                         fhGenPi0AccPhi->Fill(phiMC);                                    
2664                 }
2665         }
2666         else if (pdg==221) {
2667                 fhGenEtaPt ->Fill(ptMC);
2668                 fhGenEtaEta->Fill(etaMC);
2669                 fhGenEtaPhi->Fill(phiMC);
2670         }
2671         else if (pdg==223) {
2672                 fhGenOmegaPt ->Fill(ptMC);
2673                 fhGenOmegaEta->Fill(etaMC);
2674                 fhGenOmegaPhi->Fill(phiMC);
2675         }
2676         else if (TMath::Abs(pdg)==11) {
2677                 fhGenElePt ->Fill(ptMC);
2678                 fhGenEleEta->Fill(etaMC);
2679                 fhGenElePhi->Fill(phiMC);
2680         }       
2681         
2682 }
2683         
2684 //________________________________________________________________________
2685 void AliAnaCalorimeterQA::ReadHistograms(TList* outputList)
2686 {
2687         // Needed when Terminate is executed in distributed environment
2688         // Refill analysis histograms of this class with corresponding histograms in output list. 
2689         
2690         // Histograms of this analsys are kept in the same list as other analysis, recover the position of
2691         // the first one and then add the next 
2692         Int_t index = outputList->IndexOf(outputList->FindObject(GetAddedHistogramsStringToName()+"hE"));
2693         //printf("Calo: %s, index: %d, nmodules %d\n",fCalorimeter.Data(),index,fNModules);
2694         
2695         //Read histograms, must be in the same order as in GetCreateOutputObject.
2696         fhE       = (TH1F *) outputList->At(index++);   
2697         fhPt      = (TH1F *) outputList->At(index++); 
2698         fhPhi     = (TH1F *) outputList->At(index++); 
2699         fhEta     = (TH1F *) outputList->At(index++);
2700         fhEtaPhiE = (TH3F *) outputList->At(index++);
2701         
2702         fhClusterTimeEnergy = (TH2F*) outputList->At(index++);
2703         
2704         fhLambda      = (TH3F *)  outputList->At(index++);
2705         fhDispersion  = (TH2F *)  outputList->At(index++);
2706         
2707         fhECharged       = (TH1F *) outputList->At(index++);    
2708         fhPtCharged      = (TH1F *) outputList->At(index++); 
2709         fhPhiCharged     = (TH1F *) outputList->At(index++); 
2710         fhEtaCharged     = (TH1F *) outputList->At(index++);
2711         fhEtaPhiECharged = (TH3F *) outputList->At(index++);
2712         
2713 //      fhEChargedNoOut      = (TH1F *) outputList->At(index++);        
2714 //      fhPtChargedNoOut     = (TH1F *) outputList->At(index++); 
2715 //      fhPhiChargedNoOut    = (TH1F *) outputList->At(index++); 
2716 //      fhEtaChargedNoOut    = (TH1F *) outputList->At(index++);
2717 //      fhEtaPhiChargedNoOut = (TH2F *) outputList->At(index++);
2718
2719         fh1pOverE =    (TH2F *) outputList->At(index++);
2720         fh1dR =        (TH1F *) outputList->At(index++);
2721         fh2MatchdEdx = (TH2F *) outputList->At(index++);
2722         fh2EledEdx =   (TH2F *) outputList->At(index++);
2723         fh1pOverER02 = (TH2F *) outputList->At(index++);
2724         
2725         fhIM        = (TH2F *) outputList->At(index++);
2726         fhIMCellCut = (TH2F *) outputList->At(index++);
2727         fhAsym      = (TH2F *) outputList->At(index++);
2728         
2729         fhNCellsPerCluster           = (TH3F *) outputList->At(index++);
2730         fhNCellsPerClusterMIP        = (TH3F *) outputList->At(index++);
2731         fhNCellsPerClusterMIPCharged = (TH3F *) outputList->At(index++);
2732         fhNClusters  = (TH1F *) outputList->At(index++); 
2733         
2734         fhRNCells = (TH2F *) outputList->At(index++);
2735         fhXNCells = (TH2F *) outputList->At(index++);
2736         fhYNCells = (TH2F *) outputList->At(index++);
2737         fhZNCells = (TH2F *) outputList->At(index++);
2738         fhRE      = (TH2F *) outputList->At(index++);
2739         fhXE      = (TH2F *) outputList->At(index++);
2740         fhYE      = (TH2F *) outputList->At(index++);
2741         fhZE      = (TH2F *) outputList->At(index++); 
2742         fhXYZ     = (TH3F *) outputList->At(index++); 
2743         
2744         fhRCellE          = (TH2F *) outputList->At(index++);
2745         fhXCellE          = (TH2F *) outputList->At(index++);
2746         fhYCellE          = (TH2F *) outputList->At(index++);
2747         fhZCellE          = (TH2F *) outputList->At(index++); 
2748         fhXYZCell         = (TH3F *) outputList->At(index++); 
2749         fhDeltaCellClusterRNCells = (TH2F *) outputList->At(index++);
2750         fhDeltaCellClusterXNCells = (TH2F *) outputList->At(index++);
2751         fhDeltaCellClusterYNCells = (TH2F *) outputList->At(index++);
2752         fhDeltaCellClusterZNCells = (TH2F *) outputList->At(index++);
2753         fhDeltaCellClusterRE      = (TH2F *) outputList->At(index++);
2754         fhDeltaCellClusterXE      = (TH2F *) outputList->At(index++);
2755         fhDeltaCellClusterYE      = (TH2F *) outputList->At(index++);
2756         fhDeltaCellClusterZE      = (TH2F *) outputList->At(index++); 
2757         fhEtaPhiAmp               = (TH3F *) outputList->At(index++); 
2758         
2759         fhNCells     = (TH1F *) outputList->At(index++); 
2760         fhAmplitude  = (TH1F *) outputList->At(index++); 
2761         fhAmpId      = (TH2F *) outputList->At(index++); 
2762
2763         if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
2764                 
2765                 fhCellTimeSpreadRespectToCellMax = (TH1F *) outputList->At(index++);
2766                 fhCellIdCellLargeTimeSpread      = (TH1F *) outputList->At(index++);
2767
2768                 fhTime       = (TH1F *) outputList->At(index++); 
2769                 fhTimeId     = (TH2F *) outputList->At(index++); 
2770                 fhTimeAmp    = (TH2F *) outputList->At(index++); 
2771                 
2772 //              fhT0Time       = (TH1F *) outputList->At(index++); 
2773 //              fhT0TimeId     = (TH2F *) outputList->At(index++); 
2774 //              fhT0TimeAmp    = (TH2F *) outputList->At(index++); 
2775                 
2776         }
2777         
2778         
2779         if(fCorrelateCalos){
2780                 fhCaloCorrNClusters = (TH2F *) outputList->At(index++);
2781                 fhCaloCorrEClusters = (TH2F *) outputList->At(index++); 
2782                 fhCaloCorrNCells    = (TH2F *) outputList->At(index++); 
2783                 fhCaloCorrECells    = (TH2F *) outputList->At(index++); 
2784         }
2785         
2786         //Module histograms
2787         fhEMod                 = new TH1F*[fNModules];
2788         fhNClustersMod         = new TH1F*[fNModules];
2789         fhNCellsPerClusterMod  = new TH2F*[fNModules];
2790         fhNCellsMod            = new TH1F*[fNModules];
2791         fhGridCellsMod         = new TH2F*[fNModules];
2792         fhGridCellsEMod        = new TH2F*[fNModules];
2793         if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) 
2794                 fhGridCellsTimeMod     = new TH2F*[fNModules];
2795         fhAmplitudeMod         = new TH1F*[fNModules];
2796         if(fCalorimeter=="EMCAL")
2797                 fhAmplitudeModFraction = new TH1F*[fNModules*3];
2798         
2799         //EMCAL
2800         fhTimeAmpPerRCU        = new TH2F*[fNModules*fNRCU];
2801         
2802         fhIMMod                = new TH2F*[fNModules];
2803         fhIMCellCutMod         = new TH2F*[fNModules];
2804                 
2805         for(Int_t imod = 0 ; imod < fNModules; imod++){
2806                 fhEMod[imod]                 = (TH1F *) outputList->At(index++);
2807                 fhNClustersMod[imod]         = (TH1F *) outputList->At(index++); 
2808                 fhNCellsPerClusterMod[imod]  = (TH2F *) outputList->At(index++); 
2809                 fhNCellsMod[imod]            = (TH1F *) outputList->At(index++);        
2810                 fhGridCellsMod[imod]         = (TH2F *) outputList->At(index++);
2811                 fhGridCellsEMod[imod]        = (TH2F *) outputList->At(index++); 
2812                 if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) 
2813                         fhGridCellsTimeMod[imod]     = (TH2F *) outputList->At(index++); 
2814                 fhAmplitudeMod[imod]         = (TH1F *) outputList->At(index++);
2815                 
2816                 if(fCalorimeter=="EMCAL"){
2817                         for(Int_t ifrac = 0; ifrac < 3; ifrac++){
2818                                 fhAmplitudeModFraction[imod*3+ifrac] = (TH1F *) outputList->At(index++); 
2819                         }
2820                 }
2821                 
2822                 for(Int_t ircu = 0; ircu < fNRCU; ircu++){
2823                         fhTimeAmpPerRCU[imod*fNRCU+ircu] = (TH2F *) outputList->At(index++); 
2824                         //fhT0TimeAmpPerRCU[imod*fNRCU+ircu] = (TH2F *) outputList->At(index++); 
2825 //                      for(Int_t imod2 = 0; imod2 < fNModules; imod2++){
2826 //                              for(Int_t ircu2 = 0; ircu2 < fNModules; ircu2++){
2827 //                                      fhTimeCorrRCU[imod*fNRCU+ircu+imod2*fNRCU+ircu2]  = (TH2F *) outputList->At(index++);
2828 //                              }
2829 //                      }
2830                 }
2831                 fhIMMod[imod]                = (TH2F *) outputList->At(index++); 
2832                 fhIMCellCutMod[imod]         = (TH2F *) outputList->At(index++);        
2833
2834         }
2835         
2836         if(IsDataMC()){
2837                 fhDeltaE   = (TH1F *) outputList->At(index++); 
2838                 fhDeltaPt  = (TH1F *) outputList->At(index++); 
2839                 fhDeltaPhi = (TH1F *) outputList->At(index++); 
2840                 fhDeltaEta = (TH1F *) outputList->At(index++); 
2841                 
2842                 fhRatioE   = (TH1F *) outputList->At(index++); 
2843                 fhRatioPt  = (TH1F *) outputList->At(index++); 
2844                 fhRatioPhi = (TH1F *) outputList->At(index++); 
2845                 fhRatioEta = (TH1F *) outputList->At(index++); 
2846                 
2847                 fh2E       = (TH2F *) outputList->At(index++); 
2848                 fh2Pt      = (TH2F *) outputList->At(index++); 
2849                 fh2Phi     = (TH2F *) outputList->At(index++); 
2850                 fh2Eta     = (TH2F *) outputList->At(index++); 
2851                 
2852                 fhGamE     = (TH2F *) outputList->At(index++); 
2853                 fhGamPt    = (TH2F *) outputList->At(index++); 
2854                 fhGamPhi   = (TH2F *) outputList->At(index++); 
2855                 fhGamEta   = (TH2F *) outputList->At(index++); 
2856                 
2857                 fhGamDeltaE   = (TH1F *) outputList->At(index++); 
2858                 fhGamDeltaPt  = (TH1F *) outputList->At(index++); 
2859                 fhGamDeltaPhi = (TH1F *) outputList->At(index++); 
2860                 fhGamDeltaEta = (TH1F *) outputList->At(index++); 
2861                 
2862                 fhGamRatioE   = (TH1F *) outputList->At(index++); 
2863                 fhGamRatioPt  = (TH1F *) outputList->At(index++); 
2864                 fhGamRatioPhi = (TH1F *) outputList->At(index++); 
2865                 fhGamRatioEta = (TH1F *) outputList->At(index++); 
2866
2867                 fhPi0E     = (TH2F *) outputList->At(index++); 
2868                 fhPi0Pt    = (TH2F *) outputList->At(index++); 
2869                 fhPi0Phi   = (TH2F *) outputList->At(index++); 
2870                 fhPi0Eta   = (TH2F *) outputList->At(index++);          
2871                 
2872                 fhEleE     = (TH2F *) outputList->At(index++); 
2873                 fhElePt    = (TH2F *) outputList->At(index++); 
2874                 fhElePhi   = (TH2F *) outputList->At(index++); 
2875                 fhEleEta   = (TH2F *) outputList->At(index++);          
2876                 
2877                 fhNeHadE     = (TH2F *) outputList->At(index++); 
2878                 fhNeHadPt    = (TH2F *) outputList->At(index++); 
2879                 fhNeHadPhi   = (TH2F *) outputList->At(index++); 
2880                 fhNeHadEta   = (TH2F *) outputList->At(index++);                
2881                 
2882                 fhChHadE     = (TH2F *) outputList->At(index++); 
2883                 fhChHadPt    = (TH2F *) outputList->At(index++); 
2884                 fhChHadPhi   = (TH2F *) outputList->At(index++); 
2885                 fhChHadEta   = (TH2F *) outputList->At(index++);                                
2886                 
2887                 fhGamECharged     = (TH2F *) outputList->At(index++); 
2888                 fhGamPtCharged    = (TH2F *) outputList->At(index++); 
2889                 fhGamPhiCharged   = (TH2F *) outputList->At(index++); 
2890                 fhGamEtaCharged   = (TH2F *) outputList->At(index++); 
2891                                 
2892                 fhPi0ECharged     = (TH2F *) outputList->At(index++); 
2893                 fhPi0PtCharged    = (TH2F *) outputList->At(index++); 
2894                 fhPi0PhiCharged   = (TH2F *) outputList->At(index++); 
2895                 fhPi0EtaCharged   = (TH2F *) outputList->At(index++);           
2896                 
2897                 fhEleECharged     = (TH2F *) outputList->At(index++); 
2898                 fhElePtCharged    = (TH2F *) outputList->At(index++); 
2899                 fhElePhiCharged   = (TH2F *) outputList->At(index++); 
2900                 fhEleEtaCharged   = (TH2F *) outputList->At(index++);           
2901                 
2902                 fhNeHadECharged     = (TH2F *) outputList->At(index++); 
2903                 fhNeHadPtCharged    = (TH2F *) outputList->At(index++); 
2904                 fhNeHadPhiCharged   = (TH2F *) outputList->At(index++); 
2905                 fhNeHadEtaCharged   = (TH2F *) outputList->At(index++);                 
2906                 
2907                 fhChHadECharged     = (TH2F *) outputList->At(index++); 
2908                 fhChHadPtCharged    = (TH2F *) outputList->At(index++); 
2909                 fhChHadPhiCharged   = (TH2F *) outputList->At(index++); 
2910                 fhChHadEtaCharged   = (TH2F *) outputList->At(index++);                                 
2911                 
2912 //              fhEMVxyz     = (TH3F *) outputList->At(index++); 
2913 //              fhHaVxyz     = (TH3F *) outputList->At(index++); 
2914                 
2915                 fhEMVxyz     = (TH2F *) outputList->At(index++); 
2916                 fhHaVxyz     = (TH2F *) outputList->At(index++); 
2917                 fhEMR        = (TH2F *) outputList->At(index++); 
2918                 fhHaR        = (TH2F *) outputList->At(index++); 
2919                 
2920                 fhGenGamPt    = (TH1F *) outputList->At(index++); 
2921                 fhGenGamEta   = (TH1F *) outputList->At(index++); 
2922                 fhGenGamPhi   = (TH1F *) outputList->At(index++); 
2923                 
2924                 fhGenPi0Pt    = (TH1F *) outputList->At(index++); 
2925                 fhGenPi0Eta   = (TH1F *) outputList->At(index++); 
2926                 fhGenPi0Phi   = (TH1F *) outputList->At(index++); 
2927                 
2928                 fhGenEtaPt    = (TH1F *) outputList->At(index++); 
2929                 fhGenEtaEta   = (TH1F *) outputList->At(index++); 
2930                 fhGenEtaPhi   = (TH1F *) outputList->At(index++); 
2931                 
2932                 fhGenOmegaPt  = (TH1F *) outputList->At(index++); 
2933                 fhGenOmegaEta = (TH1F *) outputList->At(index++); 
2934                 fhGenOmegaPhi = (TH1F *) outputList->At(index++); 
2935                 
2936                 fhGenElePt    = (TH1F *) outputList->At(index++); 
2937                 fhGenEleEta   = (TH1F *) outputList->At(index++); 
2938                 fhGenElePhi   = (TH1F *) outputList->At(index++); 
2939                 
2940                 fhGenGamAccE   = (TH1F *) outputList->At(index++);              
2941                 fhGenGamAccPt  = (TH1F *) outputList->At(index++); 
2942                 fhGenGamAccEta = (TH1F *) outputList->At(index++); 
2943                 fhGenGamAccPhi = (TH1F *) outputList->At(index++); 
2944                 
2945                 fhGenPi0AccE   = (TH1F *) outputList->At(index++);              
2946                 fhGenPi0AccPt  = (TH1F *) outputList->At(index++); 
2947                 fhGenPi0AccEta = (TH1F *) outputList->At(index++); 
2948                 fhGenPi0AccPhi = (TH1F *) outputList->At(index++); 
2949                 
2950                 fhMCEle1pOverE =    (TH2F *) outputList->At(index++);
2951                 fhMCEle1dR =        (TH1F *) outputList->At(index++);
2952                 fhMCEle2MatchdEdx = (TH2F *) outputList->At(index++);
2953                 
2954                 fhMCChHad1pOverE =    (TH2F *) outputList->At(index++);
2955                 fhMCChHad1dR =        (TH1F *) outputList->At(index++);
2956                 fhMCChHad2MatchdEdx = (TH2F *) outputList->At(index++);
2957                 
2958                 fhMCNeutral1pOverE    = (TH2F *) outputList->At(index++);
2959                 fhMCNeutral1dR        = (TH1F *) outputList->At(index++);
2960                 fhMCNeutral2MatchdEdx = (TH2F *) outputList->At(index++);
2961                 
2962                 fhMCEle1pOverER02     =    (TH2F *) outputList->At(index++);
2963                 fhMCChHad1pOverER02   =    (TH2F *) outputList->At(index++);
2964                 fhMCNeutral1pOverER02 =    (TH2F *) outputList->At(index++);
2965         }
2966 }
2967
2968 //__________________________________________________________________
2969 void  AliAnaCalorimeterQA::Terminate(TList* outputList) 
2970 {
2971         //Do plots if requested 
2972
2973         if(GetDebug() > 0) printf("AliAnaCalorimeterQA::Terminate() - Make plots for %s? %d\n",fCalorimeter.Data(), fMakePlots);
2974         if(!fMakePlots) return;
2975         
2976         //Do some plots to end
2977          if(fStyleMacro!="")gROOT->Macro(fStyleMacro); 
2978         //Recover histograms from output histograms list, needed for distributed analysis.      
2979         ReadHistograms(outputList);
2980         
2981         //printf(" AliAnaCalorimeterQA::Terminate()  *** %s Report:", GetName()) ; 
2982         //printf(" AliAnaCalorimeterQA::Terminate()        pt         : %5.3f , RMS : %5.3f \n", fhPt->GetMean(),   fhPt->GetRMS() ) ;
2983
2984         char name[128];
2985         char cname[128];
2986         
2987         //In case terminate is executed after the analysis, in a second step, and we want to rebin or to change the range of the histograms for plotting
2988         Int_t nptbins     = GetHistoPtBins();           Float_t ptmax     = GetHistoPtMax();           Float_t ptmin     = GetHistoPtMin();
2989         Int_t nphibins    = GetHistoPhiBins();          Float_t phimax    = GetHistoPhiMax();          Float_t phimin    = GetHistoPhiMin();
2990         Int_t netabins    = GetHistoEtaBins();          Float_t etamax    = GetHistoEtaMax();          Float_t etamin    = GetHistoEtaMin();    
2991 //      Int_t nmassbins   = GetHistoMassBins();         Float_t massmax   = GetHistoMassMax();         Float_t massmin   = GetHistoMassMin();
2992 //      Int_t nasymbins   = GetHistoAsymmetryBins();    Float_t asymmax   = GetHistoAsymmetryMax();    Float_t asymmin   = GetHistoAsymmetryMin();
2993 //      Int_t nPoverEbins = GetHistoPOverEBins();       Float_t pOverEmax = GetHistoPOverEMax();       Float_t pOverEmin = GetHistoPOverEMin();
2994 //      Int_t ndedxbins   = GetHistodEdxBins();         Float_t dedxmax   = GetHistodEdxMax();         Float_t dedxmin   = GetHistodEdxMin();
2995 //      Int_t ndRbins     = GetHistodRBins();           Float_t dRmax     = GetHistodRMax();           Float_t dRmin     = GetHistodRMin();
2996         Int_t ntimebins   = GetHistoTimeBins();         Float_t timemax   = GetHistoTimeMax();         Float_t timemin   = GetHistoTimeMin();       
2997         Int_t nbins       = GetHistoNClusterCellBins(); Int_t nmax        = GetHistoNClusterCellMax(); Int_t nmin        = GetHistoNClusterCellMin(); 
2998 //      Int_t nratiobins  = GetHistoRatioBins();        Float_t ratiomax  = GetHistoRatioMax();        Float_t ratiomin  = GetHistoRatioMin();
2999 //      Int_t nvdistbins  = GetHistoVertexDistBins();   Float_t vdistmax  = GetHistoVertexDistMax();   Float_t vdistmin  = GetHistoVertexDistMin();
3000         Int_t rbins       = GetHistoRBins();            Float_t rmax        = GetHistoRMax();          Float_t rmin      = GetHistoRMin(); 
3001         Int_t xbins       = GetHistoXBins();            Float_t xmax        = GetHistoXMax();          Float_t xmin      = GetHistoXMin(); 
3002         Int_t ybins       = GetHistoYBins();            Float_t ymax        = GetHistoYMax();          Float_t ymin      = GetHistoYMin(); 
3003         Int_t zbins       = GetHistoZBins();            Float_t zmax        = GetHistoZMax();          Float_t zmin      = GetHistoZMin(); 
3004         
3005         //Color code for the different modules
3006         Int_t modColorIndex[]={2,4,6,8};
3007         
3008         //--------------------------------------------------
3009         // Cluster energy distributions, module dependence
3010         //--------------------------------------------------
3011         sprintf(cname,"QA_%s_ClusterEnergy",fCalorimeter.Data());
3012         TCanvas  * c = new TCanvas(cname, "Energy distributions", 800, 400) ;
3013         c->Divide(2, 1);
3014         Int_t rbE = GetNewRebinForRePlotting((TH1D*)fhE, ptmin, ptmax,nptbins) ;
3015         //printf("new E rb %d\n",rbE);
3016         fhE->Rebin(rbE);
3017         fhE->SetAxisRange(ptmin,ptmax,"X");
3018         c->cd(1) ; 
3019         if(fhE->GetEntries() > 0) gPad->SetLogy();
3020         TLegend pLegendE(0.7,0.6,0.9,0.8);
3021         pLegendE.SetTextSize(0.03);
3022         pLegendE.AddEntry(fhE,"all modules","L");
3023         pLegendE.SetFillColor(10);
3024         pLegendE.SetBorderSize(1);
3025         
3026         fhE->SetMinimum(1);     
3027         fhE->SetLineColor(1);
3028         fhE->Draw("HE");
3029         for(Int_t imod = 0; imod < fNModules; imod++){
3030                 fhEMod[imod]->Rebin(rbE);
3031                 fhEMod[imod]->SetLineColor(modColorIndex[imod]);
3032                 fhEMod[imod]->Draw("HE same");
3033                 pLegendE.AddEntry(fhEMod[imod],Form("module %d",imod),"L");
3034         }
3035         pLegendE.Draw();
3036         
3037         //Ratio of modules
3038         c->cd(2) ; 
3039         TLegend pLegendER(0.55,0.8,0.9,0.9);
3040         pLegendER.SetTextSize(0.03);
3041         pLegendER.SetFillColor(10);
3042         pLegendER.SetBorderSize(1);
3043
3044         for(Int_t imod = 1; imod < fNModules; imod++){
3045                 TH1D * htmp = (TH1D*)fhEMod[imod]->Clone(Form("hERat%d",imod));
3046                 htmp->Divide(fhEMod[0]);
3047                 htmp->SetLineColor(modColorIndex[imod]);
3048                 if(imod==1){
3049                         htmp->SetTitle("Ratio module X / module 0");
3050                         htmp->SetAxisRange(ptmin,ptmax,"X");
3051                         htmp->SetMaximum(5);
3052                         htmp->SetMinimum(0);
3053                         htmp->SetAxisRange(ptmin,ptmax,"X");
3054                         htmp->Draw("HE");
3055                 }
3056                 else 
3057                         htmp->Draw("same HE");
3058                 
3059                 pLegendER.AddEntry(fhEMod[imod],Form("module %d / module 0",imod),"L");
3060         }
3061         pLegendER.Draw();
3062         
3063         sprintf(name,"QA_%s_ClusterEnergy.eps",fCalorimeter.Data());
3064         c->Print(name); printf("Plot: %s\n",name);
3065         
3066         //--------------------------------------------------
3067         // Cell energy distributions, module dependence
3068         //--------------------------------------------------
3069         sprintf(cname,"%s_QA_CellEnergy",fCalorimeter.Data());
3070         TCanvas  * ca = new TCanvas(cname, "Cell Energy distributions", 800, 400) ;
3071         ca->Divide(2, 1);
3072         
3073         Int_t rbAmp = GetNewRebinForRePlotting((TH1D*)fhAmplitude, ptmin, ptmax,nptbins*2) ;
3074         //printf("new Amp rb %d\n",rbAmp);
3075         fhAmplitude->Rebin(rbAmp);
3076         fhAmplitude->SetAxisRange(ptmin,ptmax,"X");
3077         
3078         ca->cd(1) ; 
3079         if(fhAmplitude->GetEntries() > 0) gPad->SetLogy();
3080         TLegend pLegendA(0.7,0.6,0.9,0.8);
3081         pLegendA.SetTextSize(0.03);
3082         pLegendA.AddEntry(fhE,"all modules","L");
3083         pLegendA.SetFillColor(10);
3084         pLegendA.SetBorderSize(1);
3085         fhAmplitude->SetMinimum(0.1);
3086         fhAmplitude->SetLineColor(1);
3087         fhAmplitude->Draw("HE");
3088         
3089         for(Int_t imod = 0; imod < fNModules; imod++){
3090                 fhAmplitudeMod[imod]->Rebin(rbAmp);
3091                 fhAmplitudeMod[imod]->SetLineColor(modColorIndex[imod]);
3092                 fhAmplitudeMod[imod]->Draw("HE same");
3093                 pLegendA.AddEntry(fhAmplitudeMod[imod],Form("module %d",imod),"L");
3094         }
3095         pLegendA.Draw();
3096         
3097         
3098         ca->cd(2) ; 
3099         TLegend pLegendAR(0.55,0.8,0.9,0.9);
3100         pLegendAR.SetTextSize(0.03);
3101         pLegendAR.SetFillColor(10);
3102         pLegendAR.SetBorderSize(1);
3103         
3104         for(Int_t imod = 1; imod < fNModules; imod++){
3105                 TH1D * htmp = (TH1D*)fhAmplitudeMod[imod]->Clone(Form("hAmpRat%d",imod));
3106                 htmp->Divide(fhAmplitudeMod[0]);
3107                 htmp->SetLineColor(modColorIndex[imod]);
3108                 if(imod==1){
3109                         htmp->SetTitle("Ratio cells energy in  module X / module 0");
3110                         htmp->SetAxisRange(ptmin,ptmax,"X");
3111                         htmp->SetMaximum(5);
3112                         htmp->SetMinimum(0);
3113                         htmp->Draw("HE");
3114                 }
3115                 else 
3116                         htmp->Draw("same HE");
3117                 pLegendAR.AddEntry(fhAmplitudeMod[imod],Form("module %d",imod),"L");
3118         }
3119         
3120         pLegendAR.Draw();
3121         sprintf(name,"QA_%s_CellEnergy.eps",fCalorimeter.Data());
3122         ca->Print(name); printf("Plot: %s\n",name);     
3123
3124         //----------------------------------------------------------
3125         // Cell energy distributions, FRACTION of module dependence
3126         // See Super Module calibration difference
3127         //---------------------------------------------------------     
3128         if(fCalorimeter=="EMCAL"){
3129                 //Close To Eta 0 
3130                 sprintf(cname,"%s_QA_SMThirds",fCalorimeter.Data());
3131                 TCanvas  * cfrac = new TCanvas(cname, "SM Thirds ratios", 800, 1200) ;
3132                 cfrac->Divide(2, 3);
3133                 cfrac->cd(1) ; 
3134                 if(fhAmplitude->GetEntries() > 0) 
3135                         gPad->SetLogy();
3136                 TLegend pLegend1(0.6,0.6,0.9,0.8);
3137                 pLegend1.SetTextSize(0.03);
3138                 pLegend1.SetFillColor(10);
3139                 pLegend1.SetBorderSize(1);
3140                 pLegend1.SetHeader("Third close to Eta=0");
3141                 fhAmplitudeModFraction[0]->SetTitle("Third close to Eta=0");
3142                 fhAmplitudeModFraction[0]->SetAxisRange(ptmin,ptmax,"X");
3143                 fhAmplitudeModFraction[0]->Draw("axis");
3144                 TH1D * hAverageThird1 = (TH1D *)fhAmplitudeModFraction[3*0+2]->Clone("AverageThird1");
3145                 for(Int_t imod = 0; imod < fNModules; imod++){
3146                         Int_t ifrac = 0;
3147                         if(imod%2==0) ifrac = 2;
3148                         if(imod > 0) hAverageThird1->Add( fhAmplitudeModFraction[3*imod+ifrac]);
3149                         fhAmplitudeModFraction[3*imod+ifrac]->SetLineColor(modColorIndex[imod]);
3150                         fhAmplitudeModFraction[3*imod+ifrac]->Draw("HE same");
3151                         pLegend1.AddEntry(fhAmplitudeModFraction[3*imod+ifrac],Form("super module %d",imod),"L");
3152                 }
3153                 hAverageThird1 ->Scale(1./fNModules);
3154                 pLegend1.Draw();
3155                 //Ratio
3156                 cfrac->cd(2) ; 
3157                 for(Int_t imod = 0; imod < fNModules; imod++){
3158                         Int_t ifrac = 0;
3159                         if(imod%2==0) ifrac = 2;
3160                         TH1D * htmp =  (TH1D*)fhAmplitudeModFraction[3*imod+ifrac]->Clone(Form("ThirdFractionAverage_%d_%d",imod,ifrac));
3161                         htmp->Divide(hAverageThird1);
3162                         if(imod ==0) {
3163                                 htmp ->SetTitle("Close to eta = 0");
3164                                 htmp ->SetMaximum(5);
3165                                 htmp ->SetMinimum(0);
3166                                 htmp ->SetAxisRange(ptmin,ptmax,"X");
3167                                 htmp ->SetYTitle("ratio third to average");
3168                                 htmp -> Draw("HE");
3169                         }
3170                         else htmp -> Draw("same HE");
3171                 }
3172                 //pLegend1.Draw();
3173                 
3174                 //Middle Eta
3175                 cfrac->cd(3) ; 
3176                 if(fhAmplitude->GetEntries() > 0) 
3177                         gPad->SetLogy();
3178                 TLegend pLegend2(0.6,0.6,0.9,0.8);
3179                 pLegend2.SetTextSize(0.03);
3180                 pLegend2.SetFillColor(10);
3181                 pLegend2.SetBorderSize(1);
3182                 pLegend2.SetHeader("Middle Third");
3183                 
3184                 fhAmplitudeModFraction[0]->SetTitle("Middle Third");
3185                 fhAmplitudeModFraction[0]->SetAxisRange(ptmin,ptmax,"X");
3186                 fhAmplitudeModFraction[0]->Draw("axis");
3187                 
3188                 TH1D * hAverageThird2 = (TH1D *)fhAmplitudeModFraction[3*0+1]->Clone("AverageThird2");
3189                 for(Int_t imod = 0; imod < fNModules; imod++){
3190                         Int_t ifrac = 1;
3191                         if(imod > 0) hAverageThird2->Add( fhAmplitudeModFraction[3*imod+ifrac]);
3192                         fhAmplitudeModFraction[3*imod+ifrac]->SetLineColor(modColorIndex[imod]);
3193                         fhAmplitudeModFraction[3*imod+ifrac]->Draw("HE same");
3194                         pLegend2.AddEntry(fhAmplitudeModFraction[3*imod+ifrac],Form("super module %d",imod),"L");
3195                 }
3196                 hAverageThird2->Scale(1./fNModules);
3197                 pLegend2.Draw();
3198                 
3199                 //Ratio
3200                 cfrac->cd(4) ; 
3201                 
3202                 for(Int_t imod = 0; imod < fNModules; imod++){
3203                         Int_t ifrac = 1;
3204                         TH1D * htmp =  (TH1D*)fhAmplitudeModFraction[3*imod+ifrac]->Clone(Form("ThirdFractionAverage_%d_%d",imod,ifrac));
3205                         htmp->Divide(hAverageThird2);
3206                         if(imod ==0) {
3207                                 htmp ->SetTitle("Middle");
3208                                 htmp ->SetMaximum(5);
3209                                 htmp ->SetMinimum(0);
3210                                 htmp ->SetAxisRange(ptmin,ptmax,"X");
3211                                 htmp ->SetYTitle("ratio third to average");
3212                                 htmp -> Draw("HE");
3213                         }
3214                         else htmp -> Draw("same HE");
3215                 }
3216                 //pLegend2.Draw();
3217                 
3218                 //Close To Eta 0.7 
3219                 cfrac->cd(5) ; 
3220                 if(fhAmplitude->GetEntries() > 0) 
3221                         gPad->SetLogy();
3222                 TLegend pLegend3(0.6,0.6,0.9,0.8);
3223                 pLegend3.SetTextSize(0.03);
3224                 pLegend3.SetFillColor(10);
3225                 pLegend3.SetBorderSize(1);
3226                 pLegend3.SetHeader("Third close to Eta=0.7");
3227                 
3228                 fhAmplitudeModFraction[0]->SetTitle("Third close to Eta=0.7");
3229                 fhAmplitudeModFraction[0]->SetAxisRange(ptmin,ptmax,"X");
3230                 fhAmplitudeModFraction[0]->Draw("axis");
3231                 
3232                 TH1D * hAverageThird3 = (TH1D *)fhAmplitudeModFraction[3*0+0]->Clone("AverageThird3");
3233                 for(Int_t imod = 0; imod < 4; imod++){
3234                         Int_t ifrac = 2;
3235                         if(imod%2==0) ifrac = 0;
3236                         if(imod > 0) hAverageThird3->Add( fhAmplitudeModFraction[3*imod+ifrac]);
3237                         fhAmplitudeModFraction[3*imod+ifrac]->SetLineColor(modColorIndex[imod]);
3238                         fhAmplitudeModFraction[3*imod+ifrac]->Draw("HE same");
3239                         pLegend3.AddEntry(fhAmplitudeModFraction[3*imod+ifrac],Form("super module %d",imod),"L");
3240                 }
3241                 hAverageThird3 ->Scale(1./fNModules);
3242                 pLegend3.Draw();
3243                 
3244                 cfrac->cd(6) ; 
3245                 
3246                 for(Int_t imod = 0; imod < fNModules; imod++){
3247                         Int_t ifrac = 2;
3248                         if(imod%2==0) ifrac = 0;
3249                         TH1D * htmp =  (TH1D*)fhAmplitudeModFraction[3*imod+ifrac]->Clone(Form("ThirdFractionAverage_%d_%d",imod,ifrac));
3250                         htmp->Divide(hAverageThird3);
3251                         if(imod ==0) {
3252                                 htmp ->SetTitle("Close to eta = 0.7");
3253                                 htmp ->SetMaximum(5);
3254                                 htmp ->SetMinimum(0);
3255                                 htmp ->SetAxisRange(ptmin,ptmax,"X");
3256                                 htmp ->SetYTitle("ratio third to average");
3257                                 htmp ->Draw("HE");
3258                         }
3259                         else htmp ->Draw("same HE");
3260                 }
3261                 //pLegend3.Draw();
3262                 
3263                 sprintf(name,"QA_%s_CellEnergyModuleFraction.eps",fCalorimeter.Data());
3264                 cfrac->Print(name); printf("Create plot %s\n",name);
3265         }//EMCAL        
3266         
3267         
3268         //----------------------------------------------------------
3269         // Cluster eta and phi distributions, energy cut dependence
3270         //---------------------------------------------------------     
3271         
3272         sprintf(cname,"%s_QA_EtaPhiCluster",fCalorimeter.Data());
3273         TCanvas  * cetaphic = new TCanvas(cname, "Eta-Phi Reconstructed distributions", 1200, 400) ;
3274         cetaphic->Divide(3, 1);
3275         Int_t binmin = 0;
3276         Int_t rbPhi  = 1;
3277         Int_t rbEta  = 1;
3278         Int_t ncuts  = 7;
3279         Float_t ecut[]     = {0.1, 0.3, 0.5, 0.7, 0.9, 1.1, 1.3};
3280         Int_t   ecutcolor[]= {2, 4, 6, 7, 8, 9, 12};
3281         TH1D * hE = fhEtaPhiE->ProjectionZ();
3282         
3283         //PHI
3284         cetaphic->cd(1) ; 
3285         gPad->SetLogy();
3286         gPad->SetGridy();
3287         
3288         TLegend pLegendPhiCl(0.83,0.6,0.95,0.93);
3289         pLegendPhiCl.SetTextSize(0.03);
3290         pLegendPhiCl.SetFillColor(10);
3291         pLegendPhiCl.SetBorderSize(1);
3292         
3293         TH1D * htmp = fhEtaPhiE->ProjectionY("hphi_cluster_nocut",0,-1,0,-1);
3294         if(htmp){
3295           htmp->SetMinimum(1);
3296           rbPhi =  GetNewRebinForRePlotting(htmp, phimin, phimax,nphibins) ;
3297           //printf("new Phi rb %d\n",rbPhi);
3298           htmp->Rebin(rbPhi);
3299           htmp->SetTitle("#phi of clusters for energy in cluster > threshold");
3300           htmp->SetAxisRange(phimin,phimax,"X");
3301           htmp->Draw("HE");
3302           pLegendPhiCl.AddEntry(htmp,"No cut","L");
3303
3304           for (Int_t i = 0; i < ncuts; i++) {
3305             binmin =  hE->FindBin(ecut[i]);
3306             //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
3307             htmp = fhEtaPhiE->ProjectionY(Form("hphi_cluster_cut%d",i),0,-1,binmin,-1);
3308             htmp->SetLineColor(ecutcolor[i]);
3309             htmp->Rebin(rbPhi);
3310             htmp->Draw("same HE");
3311             pLegendPhiCl.AddEntry(htmp,Form("E>%1.1f",ecut[i]),"L");
3312             
3313           }
3314         }
3315         pLegendPhiCl.Draw();
3316         
3317         //ETA
3318         cetaphic->cd(2) ; 
3319         gPad->SetLogy();
3320         gPad->SetGridy();
3321         
3322         htmp = fhEtaPhiE->ProjectionX("heta_cluster_nocut",0,-1,0,-1);
3323         htmp ->SetLineColor(1);
3324         rbEta =  GetNewRebinForRePlotting(htmp,etamin, etamax,netabins) ;
3325         //printf("new Eta rb %d\n",rbEta);
3326         if(htmp){
3327           htmp->Rebin(rbEta);
3328           htmp->SetMinimum(1);
3329           htmp->SetTitle("#eta of clusters for energy in cluster > threshold");
3330           htmp->SetAxisRange(etamin,etamax,"X");
3331           htmp->Draw("HE");
3332           
3333           for (Int_t i = 0; i < ncuts; i++) {
3334             binmin =  hE->FindBin(ecut[i]);
3335             //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
3336             htmp = fhEtaPhiE->ProjectionX(Form("heta_cluster_cut%d",i),0,-1,binmin,-1);
3337             htmp->SetLineColor(ecutcolor[i]);
3338             htmp->Rebin(rbEta);
3339             htmp->Draw("same HE");      
3340           }
3341         }
3342         //ETA vs PHI    
3343         cetaphic->cd(3) ;
3344         TH2D* hEtaPhiCl = (TH2D*) fhEtaPhiE->Project3D("xy");
3345         hEtaPhiCl->SetAxisRange(etamin,etamax,"X");
3346         hEtaPhiCl->SetAxisRange(phimin,phimax,"Y");
3347         hEtaPhiCl->Draw("colz");
3348                 
3349         sprintf(name,"QA_%s_ClusterEtaPhi.eps",fCalorimeter.Data());
3350         cetaphic->Print(name); printf("Create plot %s\n",name);
3351
3352         //----------------------------------------------------------
3353         // Cell eta and phi distributions, energy cut dependence
3354         //---------------------------------------------------------     
3355         
3356         sprintf(cname,"%s_QA_EtaPhiCell",fCalorimeter.Data());
3357         TCanvas  * cetaphicell = new TCanvas(cname, "Eta-Phi Cells distributions", 1200, 400) ;
3358         cetaphicell->Divide(3, 1);
3359         
3360         //PHI
3361         cetaphicell->cd(1) ; 
3362         gPad->SetLogy();
3363         gPad->SetGridy();
3364         
3365         TLegend pLegendPhiCell(0.83,0.6,0.95,0.93);
3366         pLegendPhiCell.SetTextSize(0.03);
3367         pLegendPhiCell.SetFillColor(10);
3368         pLegendPhiCell.SetBorderSize(1);
3369         
3370         htmp = fhEtaPhiAmp->ProjectionY("hphi_cell_nocut",0,-1,0,-1);
3371         if(htmp){
3372           htmp->SetMinimum(1);
3373           htmp->Rebin(rbPhi);
3374           htmp->SetTitle("#phi of cells for cell energy > threshold");
3375           htmp->SetAxisRange(phimin,phimax,"X");
3376           htmp->Draw("HE");
3377           pLegendPhiCell.AddEntry(htmp,"No cut","L");
3378           
3379           for (Int_t i = 0; i < ncuts; i++) {
3380             binmin =  hE->FindBin(ecut[i]);
3381             //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
3382             htmp = fhEtaPhiAmp->ProjectionY(Form("hphi_cell_cut%d",i),0,-1,binmin,-1);
3383             htmp->SetLineColor(ecutcolor[i]);
3384             htmp->Rebin(rbPhi);
3385             htmp->Draw("same HE");
3386             pLegendPhiCl.AddEntry(htmp,Form("E>%1.1f",ecut[i]),"L");
3387             
3388           }
3389         }
3390         pLegendPhiCell.Draw();
3391         
3392         //ETA
3393         cetaphicell->cd(2) ; 
3394         gPad->SetLogy();
3395         gPad->SetGridy();
3396         
3397         htmp = fhEtaPhiAmp->ProjectionX("heta_cell_nocut",0,-1,0,-1);
3398         if(htmp){
3399           htmp ->SetLineColor(1);
3400           htmp->Rebin(rbEta);
3401           htmp->SetMinimum(1);
3402           htmp->SetTitle("#eta of cells for cell energy > threshold");
3403           htmp->SetAxisRange(etamin,etamax,"X");
3404           htmp->Draw("HE");
3405           
3406           for (Int_t i = 0; i < ncuts; i++) {
3407             binmin =  hE->FindBin(ecut[i]);
3408             //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
3409             htmp = fhEtaPhiAmp->ProjectionX(Form("heta_cell_cut%d",i),0,-1,binmin,-1);
3410             htmp->SetLineColor(ecutcolor[i]);
3411             htmp->Rebin(rbEta);
3412             htmp->Draw("same HE");
3413             
3414           }
3415         }
3416         //ETA vs PHI    
3417         cetaphicell->cd(3) ;
3418         TH2D* hEtaPhiCell = (TH2D*) fhEtaPhiAmp->Project3D("xy");
3419         hEtaPhiCell->SetAxisRange(etamin,etamax,"X");
3420         hEtaPhiCell->SetAxisRange(phimin,phimax,"Y");
3421         hEtaPhiCell->Draw("colz");
3422         
3423         sprintf(name,"QA_%s_CellEtaPhi.eps",fCalorimeter.Data());
3424         cetaphicell->Print(name); printf("Create plot %s\n",name);
3425         
3426         ////////////////////////////////////////        
3427         ///////// Global Positions /////////////       
3428         ////////////////////////////////////////       
3429         
3430         //CLUSTERS
3431         sprintf(cname,"%s_QA_ClusterXY",fCalorimeter.Data());
3432         TCanvas  * cxyz = new TCanvas(cname, "Cluster XY distributions", 1200, 400) ;
3433         cxyz->Divide(3, 1);
3434         
3435         cxyz->cd(1) ; 
3436         TH2D * hXY = (TH2D*) fhXYZ->Project3D("yx" );
3437         hXY->SetTitle("Cluster X vs Y");
3438         hXY->GetYaxis()->SetTitleOffset(1.6);
3439         hXY->Draw("colz");
3440         cxyz->cd(2) ; 
3441         TH2D * hYZ = (TH2D*) fhXYZ->Project3D("yz" );
3442         hYZ->SetTitle("Cluster Z vs Y");
3443         hYZ->GetYaxis()->SetTitleOffset(1.6);
3444         hYZ->Draw("colz");      
3445         cxyz->cd(3) ; 
3446         TH2D * hXZ = (TH2D*) fhXYZ->Project3D("zx" );
3447         hXZ->SetTitle("Cluster X vs Z");
3448         hXZ->GetYaxis()->SetTitleOffset(1.6);
3449         hXZ->Draw("colz");
3450         
3451         sprintf(name,"QA_%s_ClusterXY_YZ_XZ.eps",fCalorimeter.Data());
3452         cxyz->Print(name); printf("Create plot %s\n",name);
3453         
3454         Int_t rbX = 1;
3455         Int_t rbY = 1;
3456         Int_t rbZ = 1;
3457         
3458         sprintf(cname,"QA_%s_ClusterX",fCalorimeter.Data());
3459         TCanvas  * cx = new TCanvas(cname, "Cluster X distributions", 1200, 400) ;
3460         cx->Divide(3, 1);
3461                 
3462         cx->cd(1) ; 
3463         TH1D * hX = (TH1D*) fhXYZ->Project3D("xe" );
3464         //gPad->SetLogy();
3465         gPad->SetGridy();
3466         hX->SetTitle("Cluster X ");
3467         hX->Draw("HE");
3468         rbX =  GetNewRebinForRePlotting(hX, xmin, xmax,xbins) ;
3469         //printf("new X rb %d\n",rbX);
3470         hX->Rebin(rbX);
3471         hX->SetMinimum(hX->GetMaximum()/2);
3472         hX->SetAxisRange(xmin,xmax);
3473
3474         cx->cd(2) ; 
3475         TH1D * hY = (TH1D*) fhXYZ->Project3D("ye" );
3476         //gPad->SetLogy();
3477         hY->SetTitle("Cluster Y ");
3478         rbY =  GetNewRebinForRePlotting(hY, ymin, ymax, ybins) ;
3479         //printf("new Y rb %d\n",rbY);
3480         hY->Rebin(rbY);
3481         hY->SetMinimum(1);
3482         hY->SetAxisRange(ymin,ymax);
3483         hY->Draw("HE"); 
3484         
3485         cx->cd(3) ; 
3486         TH1D * hZ = (TH1D*) fhXYZ->Project3D("ze" );
3487         //gPad->SetLogy();
3488         gPad->SetGridy();
3489         rbZ =  GetNewRebinForRePlotting(hZ,zmin, zmax,zbins) ;
3490         //printf("new Z rb %d\n",rbZ);
3491         hZ->Rebin(rbZ); 
3492         hZ->SetMinimum(hZ->GetMaximum()/2);
3493         hZ->SetAxisRange(zmin,zmax);
3494         hZ->Draw("HE");
3495         
3496         sprintf(name,"QA_%s_ClusterX_Y_Z.eps",fCalorimeter.Data());
3497         cx->Print(name); printf("Create plot %s\n",name);
3498
3499         //CELLS
3500         
3501         sprintf(cname,"%s_QA_CellXY",fCalorimeter.Data());
3502         TCanvas  * cellxyz = new TCanvas(cname, "Cell XY distributions", 1200, 400) ;
3503         cellxyz->Divide(3, 1);
3504         
3505         cellxyz->cd(1) ; 
3506         TH2D * hXYCell = (TH2D*) fhXYZCell->Project3D("yx" );
3507         hXYCell->SetTitle("Cell X vs Y");
3508         hXYCell->GetYaxis()->SetTitleOffset(1.6);
3509         hXYCell->Draw("colz");
3510         cellxyz->cd(2) ; 
3511         TH2D * hYZCell = (TH2D*) fhXYZCell->Project3D("yz" );
3512         hYZCell->SetTitle("Cell Z vs Y");
3513         hYZCell->GetYaxis()->SetTitleOffset(1.6);
3514         hYZCell->Draw("colz");  
3515         cellxyz->cd(3) ; 
3516         TH2D * hXZCell = (TH2D*) fhXYZCell->Project3D("zx" );
3517         hXZCell->SetTitle("Cell X vs Z");
3518         hXZCell->GetYaxis()->SetTitleOffset(1.6);
3519         hXZCell->Draw("colz");
3520
3521         sprintf(name,"QA_%s_CellXY_YZ_XZ.eps",fCalorimeter.Data());
3522         cellxyz->Print(name); printf("Create plot %s\n",name);
3523         
3524         
3525         sprintf(cname,"%s_QA_CellX",fCalorimeter.Data());
3526         TCanvas  * cellx = new TCanvas(cname, "Cell X distributions", 1200, 400) ;
3527         cellx->Divide(3, 1);
3528         
3529         cellx->cd(1) ; 
3530         TH1D * hXCell = (TH1D*) fhXYZCell->Project3D("xe" );
3531         //gPad->SetLogy();
3532         gPad->SetGridy();
3533         hXCell->SetTitle("Cell X ");
3534         hXCell->Rebin(rbX);
3535         hXCell->SetMinimum(hXCell->GetMaximum()/2);
3536         hXCell->SetAxisRange(xmin,xmax);
3537         hXCell->Draw("HE");
3538
3539         cellx->cd(2) ; 
3540         TH1D * hYCell = (TH1D*) fhXYZCell->Project3D("ye" );
3541         //gPad->SetLogy();
3542         hYCell->SetTitle("Cell Y ");
3543         hYCell->Rebin(rbY);
3544         hYCell->SetAxisRange(ymin,ymax);
3545         hYCell->SetMinimum(1);
3546         hYCell->Draw("HE");     
3547         
3548         cellx->cd(3) ; 
3549         TH1D * hZCell = (TH1D*) fhXYZCell->Project3D("ze" );
3550         //gPad->SetLogy();
3551         gPad->SetGridy();
3552         hZCell->SetAxisRange(zmin,zmax);
3553         hZCell->SetTitle("Cell Z ");
3554         hZCell->Rebin(rbZ);
3555         hZCell->SetMinimum(hZCell->GetMaximum()/2);
3556         hZCell->Draw("HE");
3557         
3558         sprintf(name,"QA_%s_CellX_Y_Z.eps",fCalorimeter.Data());
3559         cellx->Print(name); printf("Create plot %s\n",name);
3560                 
3561         
3562         //----------------------------------------------------------
3563         // Cluster X, Y, Z, R, energy cut dependence
3564         //---------------------------------------------------------     
3565         
3566         sprintf(cname,"%s_QA_ClusterX_Y_Z_R_ECut",fCalorimeter.Data());
3567         TCanvas  * cxe = new TCanvas(cname, "Cluster X Y Z R, E cut", 800, 800) ;
3568         cxe->Divide(2, 2);              
3569         //R
3570         cxe->cd(1) ; 
3571         gPad->SetLogy();
3572         gPad->SetGridy();
3573         
3574         TLegend pLegendXCl(0.83,0.6,0.95,0.93);
3575         pLegendXCl.SetTextSize(0.03);
3576         pLegendXCl.SetFillColor(10);
3577         pLegendXCl.SetBorderSize(1);
3578         
3579         htmp = fhRE->ProjectionX("hre_cluster_nocut",0,-1);
3580         Int_t rbR=1;
3581         if(htmp){
3582           htmp->SetMinimum(1);
3583           rbR =  GetNewRebinForRePlotting(htmp, rmin, rmax,rbins) ;
3584           //printf("new R rb %d\n",rbR);
3585           htmp->Rebin(rbR);
3586           htmp->SetTitle("r of clusters for energy in cluster > threshold");
3587           htmp->SetAxisRange(rmin,rmax,"X");
3588           htmp->Draw("HE");
3589           pLegendXCl.AddEntry(htmp,"No cut","L");
3590           
3591           for (Int_t i = 0; i < ncuts; i++) {
3592             binmin =  hE->FindBin(ecut[i]);
3593             //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
3594             htmp = fhRE->ProjectionX(Form("hre_cluster_cut%d",i),binmin,-1);
3595             htmp->SetLineColor(ecutcolor[i]);
3596             htmp->Rebin(rbR);
3597             htmp->Draw("same HE");
3598             pLegendXCl.AddEntry(htmp,Form("E>%1.1f",ecut[i]),"L");
3599           }
3600         }
3601         pLegendXCl.Draw();
3602         
3603         //X
3604         cxe->cd(2) ; 
3605         gPad->SetLogy();
3606         gPad->SetGridy();
3607         htmp = fhXE->ProjectionX("hxe_cluster_nocut",0,-1);
3608         if(htmp){
3609           htmp->SetMinimum(1);
3610           htmp->Rebin(rbX);
3611           htmp->SetTitle("x of clusters for energy in cluster > threshold");
3612           htmp->SetAxisRange(xmin,xmax,"X");
3613           htmp->Draw("HE");
3614           
3615           for (Int_t i = 0; i < ncuts; i++) {
3616             binmin =  hE->FindBin(ecut[i]);
3617             //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
3618             htmp = fhXE->ProjectionX(Form("hxe_cluster_cut%d",i),binmin,-1);
3619             htmp->SetLineColor(ecutcolor[i]);
3620             htmp->Rebin(rbX);
3621             htmp->Draw("same HE");
3622           }
3623         }
3624         //Y
3625         cxe->cd(3) ; 
3626         gPad->SetLogy();
3627         gPad->SetGridy();
3628         htmp = fhYE->ProjectionX("hye_cluster_nocut",0,-1);
3629         if(htmp){
3630           htmp->SetMinimum(1);
3631           htmp->Rebin(rbY);
3632           htmp->SetTitle("y of clusters for energy in cluster > threshold");
3633           htmp->SetAxisRange(ymin,ymax,"X");
3634           htmp->Draw("HE");
3635           
3636           for (Int_t i = 0; i < ncuts; i++) {
3637             binmin =  hE->FindBin(ecut[i]);
3638             //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
3639             htmp = fhYE->ProjectionX(Form("hye_cluster_cut%d",i),binmin,-1);
3640             htmp->SetLineColor(ecutcolor[i]);
3641             htmp->Rebin(rbY);
3642             htmp->Draw("same HE");
3643           }
3644         }
3645         //Z
3646         cxe->cd(4) ; 
3647         gPad->SetLogy();
3648         gPad->SetGridy();
3649         
3650         htmp = fhZE->ProjectionX("hze_cluster_nocut",0,-1);
3651         if(htmp){
3652           htmp->SetMinimum(1);
3653           htmp->Rebin(rbZ);
3654           htmp->SetTitle("z of clusters for energy in cluster > threshold");
3655           htmp->SetAxisRange(zmin,zmax,"X");
3656           htmp->Draw("HE");
3657           
3658           for (Int_t i = 0; i < ncuts; i++) {
3659             binmin =  hE->FindBin(ecut[i]);
3660             //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
3661             htmp = fhZE->ProjectionX(Form("hze_cluster_cut%d",i),binmin,-1);
3662             htmp->SetLineColor(ecutcolor[i]);
3663             htmp->Rebin(rbZ);
3664             htmp->Draw("same HE"); 
3665           }
3666         }
3667         
3668         sprintf(name,"QA_%s_ClusterX_Y_Z_R_ECut.eps",fCalorimeter.Data());
3669         cxe->Print(name); printf("Create plot %s\n",name);
3670         
3671         
3672         //----------------------------------------------------------
3673         // Cluster X, Y, Z, R, NCells in cluster dependence
3674         //---------------------------------------------------------     
3675         Int_t ncellcut[]={2, 3, 4};
3676         Int_t ncellcuts = 3;
3677         sprintf(cname,"%s_QA_ClusterX_Y_Z_R_NCellsCut",fCalorimeter.Data());
3678         TCanvas  * cxn = new TCanvas(cname, "Cluster X Y Z R, NCells cut", 800, 800) ;
3679         cxn->Divide(2, 2);              
3680         //R
3681         cxn->cd(1) ; 
3682         gPad->SetLogy();
3683         gPad->SetGridy();
3684         
3685         TLegend pLegendXClN(0.83,0.6,0.95,0.93);
3686         pLegendXClN.SetTextSize(0.03);
3687         pLegendXClN.SetFillColor(10);
3688         pLegendXClN.SetBorderSize(1);
3689         
3690         htmp = fhRNCells->ProjectionX("hrn_cluster_nocut",0,-1);
3691         if(htmp){
3692           htmp->SetMinimum(1);
3693           htmp->Rebin(rbR);
3694           htmp->SetTitle("r of clusters for energy in cluster > threshold");
3695           htmp->SetAxisRange(rmin,rmax,"X");
3696           htmp->Draw("HE");
3697           pLegendXClN.AddEntry(htmp,"No cut","L");
3698           
3699           for (Int_t i = 0; i < ncellcuts; i++) {
3700             if(i < ncellcuts-1) htmp = fhRNCells->ProjectionX(Form("hrn_cluster_cut%d",i),ncellcut[i],ncellcut[i]);
3701             else htmp = fhRNCells->ProjectionX(Form("hrn_cluster_cut%d",i),ncellcut[i],-1);
3702             htmp->SetLineColor(ecutcolor[i]);
3703             htmp->Rebin(rbR);
3704             htmp->Draw("same HE");
3705             if(i < ncellcuts-1) pLegendXClN.AddEntry(htmp,Form("n = %1.1d",ncellcut[i]-1),"L");
3706             else pLegendXClN.AddEntry(htmp,Form("n >= %1.1d",ncellcut[i]-1),"L");
3707             
3708           }
3709         }
3710         pLegendXClN.Draw();
3711         
3712         //X
3713         cxn->cd(2) ; 
3714         gPad->SetLogy();
3715         gPad->SetGridy();
3716         htmp = fhXNCells->ProjectionX("hxn_cluster_nocut",0,-1);
3717         if(htmp){
3718           htmp->SetMinimum(1);
3719           htmp->Rebin(rbX);
3720           htmp->SetTitle("x of clusters for energy in cluster > threshold");
3721           htmp->SetAxisRange(xmin,xmax,"X");
3722           htmp->Draw("HE");
3723           
3724           for (Int_t i = 0; i < ncellcuts; i++) {
3725             if(i < ncellcuts-1)htmp = fhXNCells->ProjectionX(Form("hxn_cluster_cut%d",i),ncellcut[i],ncellcut[i]);
3726             else htmp = fhXNCells->ProjectionX(Form("hxn_cluster_cut%d",i),ncellcut[i],-1);
3727             htmp->SetLineColor(ecutcolor[i]);
3728             htmp->Rebin(rbX);
3729             htmp->Draw("same HE");   
3730           }
3731         }
3732         //Y
3733         cxn->cd(3) ; 
3734         gPad->SetLogy();
3735         gPad->SetGridy();
3736         htmp = fhYNCells->ProjectionX("hyn_cluster_nocut",0,-1);
3737         if(htmp){
3738           htmp->SetMinimum(1);
3739           htmp->Rebin(rbY);
3740           htmp->SetTitle("y of clusters for energy in cluster > threshold");
3741           htmp->SetAxisRange(ymin,ymax,"X");
3742           htmp->Draw("HE");
3743           
3744           for (Int_t i = 0; i < ncellcuts; i++) {
3745             if(i < ncellcuts-1) htmp = fhYNCells->ProjectionX(Form("hyn_cluster_cut%d",i),ncellcut[i],ncellcut[i]);
3746             else htmp = fhYNCells->ProjectionX(Form("hyn_cluster_cut%d",i),ncellcut[i],-1);
3747             htmp->SetLineColor(ecutcolor[i]);
3748             htmp->Rebin(rbY);
3749             htmp->Draw("same HE");  
3750           }
3751         }
3752         //Z
3753         cxn->cd(4) ; 
3754         gPad->SetLogy();
3755         gPad->SetGridy();
3756         
3757         htmp = fhZNCells->ProjectionX("hzn_cluster_nocut",0,-1);
3758         if(htmp){
3759           htmp->SetMinimum(1);
3760           htmp->Rebin(rbZ);
3761           htmp->SetTitle("z of clusters for energy in cluster > threshold");
3762           htmp->SetAxisRange(zmin,zmax,"X");
3763           htmp->Draw("HE");
3764           
3765           for (Int_t i = 0; i < ncellcuts; i++) {
3766             if(i < ncellcuts-1)htmp = fhZNCells->ProjectionX(Form("hzn_cluster_cut%d",i),ncellcut[i],ncellcut[i]);
3767             else htmp = fhZNCells->ProjectionX(Form("hzn_cluster_cut%d",i),ncellcut[i],-1);
3768             htmp->SetLineColor(ecutcolor[i]);
3769             htmp->Rebin(rbZ);
3770             htmp->Draw("same HE");    
3771           }
3772         }
3773         
3774         sprintf(name,"QA_%s_ClusterX_Y_Z_R_NCellsCut.eps",fCalorimeter.Data());
3775         cxn->Print(name); printf("Create plot %s\n",name);
3776         
3777         
3778         //----------------------------------------------------------
3779         // Cell X, Y, Z, R, energy cut dependence
3780         //---------------------------------------------------------     
3781         
3782         sprintf(cname,"%s_QA_CellX_Y_Z_R_ECut",fCalorimeter.Data());
3783         TCanvas  * cxecell = new TCanvas(cname, "Cell X Y Z R, E cut", 800, 800) ;
3784         cxecell->Divide(2, 2);          
3785         //R
3786         cxecell->cd(1) ; 
3787         gPad->SetLogy();
3788         gPad->SetGridy();
3789         
3790         TLegend pLegendXCell(0.83,0.6,0.95,0.93);
3791         pLegendXCell.SetTextSize(0.03);
3792         pLegendXCell.SetFillColor(10);
3793         pLegendXCell.SetBorderSize(1);
3794         
3795         htmp = fhRCellE->ProjectionX("hre_cell_nocut",0,-1);
3796         if(htmp){
3797           htmp->SetMinimum(1);
3798           htmp->Rebin(rbR);
3799           htmp->SetTitle("r of cells for energy in cluster > threshold");
3800           htmp->SetAxisRange(rmin,rmax,"X");
3801           htmp->Draw("HE");
3802           pLegendXCell.AddEntry(htmp,"No cut","L");
3803           
3804           for (Int_t i = 0; i < ncuts; i++) {
3805             binmin =  hE->FindBin(ecut[i]);
3806             //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
3807             htmp = fhRCellE->ProjectionX(Form("hre_celr_cut%d",i),binmin,-1);
3808             htmp->SetLineColor(ecutcolor[i]);
3809             htmp->Rebin(rbR);
3810             htmp->Draw("same HE");
3811             pLegendXCell.AddEntry(htmp,Form("E>%1.1f",ecut[i]),"L"); 
3812           }
3813         }
3814         pLegendXCell.Draw();
3815         
3816         //X
3817         cxecell->cd(2) ; 
3818         gPad->SetLogy();
3819         gPad->SetGridy();
3820         
3821         htmp = fhXCellE->ProjectionX("hxe_cells_nocut",0,-1);
3822         if(htmp){
3823           htmp->SetMinimum(1);
3824           htmp->Rebin(rbX);
3825           htmp->SetTitle("x of cells for energy in cluster > threshold");
3826           htmp->SetAxisRange(xmin,xmax,"X");
3827           htmp->Draw("HE");
3828           
3829           for (Int_t i = 0; i < ncuts; i++) {
3830             binmin =  hE->FindBin(ecut[i]);
3831             //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
3832             htmp = fhXCellE->ProjectionX(Form("hxe_cells_cut%d",i),binmin,-1);
3833             htmp->SetLineColor(ecutcolor[i]);
3834             htmp->Rebin(rbX);
3835             htmp->Draw("same HE");
3836           }
3837         }
3838         //Y
3839         cxecell->cd(3) ; 
3840         gPad->SetLogy();
3841         gPad->SetGridy();
3842         htmp = fhYCellE->ProjectionX("hye_cells_nocut",0,-1);
3843         if(htmp){
3844           htmp->SetMinimum(1);
3845           htmp->Rebin(rbY);
3846           htmp->SetTitle("y of cells for energy in cluster > threshold");
3847           htmp->SetAxisRange(ymin,ymax,"X");
3848           htmp->Draw("HE");
3849           
3850           for (Int_t i = 0; i < ncuts; i++) {
3851             binmin =  hE->FindBin(ecut[i]);
3852             //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
3853             htmp = fhYCellE->ProjectionX(Form("hye_cells_cut%d",i),binmin,-1);
3854             htmp->SetLineColor(ecutcolor[i]);
3855             htmp->Rebin(rbY);
3856             htmp->Draw("same HE");
3857           }
3858         }
3859         //Z
3860         cxecell->cd(4) ; 
3861         gPad->SetLogy();
3862         gPad->SetGridy();
3863         htmp = fhZCellE->ProjectionX("hze_cells_nocut",0,-1);
3864         if(htmp){
3865           htmp->SetMinimum(1);
3866           htmp->Rebin(rbZ);
3867           htmp->SetTitle("z of cells for energy in cluster > threshold");
3868           htmp->SetAxisRange(zmin,zmax,"X");
3869           htmp->Draw("HE");
3870           
3871           for (Int_t i = 0; i < ncuts; i++) {
3872             binmin =  hE->FindBin(ecut[i]);
3873             //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
3874             htmp = fhZCellE->ProjectionX(Form("hze_cells_cut%d",i),binmin,-1);
3875             htmp->SetLineColor(ecutcolor[i]);
3876             htmp->Rebin(rbZ);
3877             htmp->Draw("same HE"); 
3878           }
3879         }
3880         sprintf(name,"QA_%s_CellX_Y_Z_R_ECut.eps",fCalorimeter.Data());
3881         cxecell->Print(name); printf("Create plot %s\n",name);
3882         
3883         
3884         //----------------------------------------------------------
3885         // Cluster-Cell X, Y, Z, R, cluster energy cut dependence
3886         //---------------------------------------------------------     
3887         Int_t rbDR= 1;//rbR;
3888         Int_t rbDX= 1;//rbX;
3889         Int_t rbDY= 1;//rbY;
3890         Int_t rbDZ= 1;//rbZ;
3891
3892         sprintf(cname,"%s_QA_DeltaClusterCellX_Y_Z_R_ECut",fCalorimeter.Data());
3893         TCanvas  * cxde = new TCanvas(cname, "Cluster-Cell X, Y, Z, R, E cut", 800, 800) ;
3894         cxde->Divide(2, 2);             
3895         //R
3896         cxde->cd(1) ; 
3897         gPad->SetLogy();
3898         gPad->SetGridy();
3899         
3900         TLegend pLegendXClD(0.83,0.6,0.95,0.93);
3901         pLegendXClD.SetTextSize(0.03);
3902         pLegendXClD.SetFillColor(10);
3903         pLegendXClD.SetBorderSize(1);
3904         
3905         htmp = fhDeltaCellClusterRE->ProjectionX("hrde_nocut",0,-1);
3906         if(htmp){
3907                 htmp->SetMinimum(1);
3908                 htmp->Rebin(rbDR);
3909                 htmp->SetTitle("r clusters - r cells for energy in cluster > threshold");
3910                 htmp->SetAxisRange(-50,50,"X");
3911                 htmp->Draw("HE");
3912                 pLegendXCl.AddEntry(htmp,"No cut","L");
3913                 
3914                 for (Int_t i = 0; i < ncuts; i++) {
3915                         binmin =  hE->FindBin(ecut[i]);
3916                         //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
3917                         htmp = fhDeltaCellClusterRE->ProjectionX(Form("hrde_cut%d",i),binmin,-1);
3918                         htmp->SetLineColor(ecutcolor[i]);
3919                         htmp->Rebin(rbDR);
3920                         htmp->Draw("same HE");
3921                         pLegendXClD.AddEntry(htmp,Form("E>%1.1f",ecut[i]),"L");
3922                 }
3923         }
3924         pLegendXClD.Draw();
3925         
3926         //X
3927         cxde->cd(2) ; 
3928         gPad->SetLogy();
3929         gPad->SetGridy();
3930         htmp = fhDeltaCellClusterXE->ProjectionX("hxde_nocut",0,-1);
3931         if(htmp){
3932                 htmp->SetMinimum(1);
3933                 htmp->Rebin(rbDX);
3934                 htmp->SetTitle("x clusters -x cells for energy in cluster > threshold");
3935                 htmp->SetAxisRange(-50,50,"X");
3936                 htmp->Draw("HE");
3937                 
3938                 for (Int_t i = 0; i < ncuts; i++) {
3939                         binmin =  hE->FindBin(ecut[i]);
3940                         //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
3941                         htmp = fhDeltaCellClusterXE->ProjectionX(Form("hxde_cut%d",i),binmin,-1);
3942                         htmp->SetLineColor(ecutcolor[i]);
3943                         htmp->Rebin(rbDX);
3944                         htmp->Draw("same HE");
3945                         
3946                 }
3947         }
3948         //Y
3949         cxde->cd(3) ; 
3950         gPad->SetLogy();
3951         gPad->SetGridy();
3952         htmp = fhDeltaCellClusterYE->ProjectionX("hyde_nocut",0,-1);
3953         if(htmp){
3954                 htmp->SetMinimum(1);
3955                 htmp->Rebin(rbDY);
3956                 htmp->SetTitle("y clusters - ycells for energy in cluster > threshold");
3957                 htmp->SetAxisRange(-50,50,"X");
3958                 htmp->Draw("HE");
3959                 
3960                 for (Int_t i = 0; i < ncuts; i++) {
3961                         binmin =  hE->FindBin(ecut[i]);
3962                         //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
3963                         htmp = fhDeltaCellClusterYE->ProjectionX(Form("hyde_cut%d",i),binmin,-1);
3964                         htmp->SetLineColor(ecutcolor[i]);
3965                         htmp->Rebin(rbDY);
3966                         htmp->Draw("same HE");
3967                         
3968                 }
3969         }
3970         //Z
3971         cxde->cd(4) ; 
3972         gPad->SetLogy();
3973         gPad->SetGridy();
3974         
3975         htmp = fhDeltaCellClusterZE->ProjectionX("hzde_nocut",0,-1);
3976         if(htmp){
3977                 htmp->SetMinimum(1);
3978                 htmp->Rebin(rbZ);
3979                 htmp->SetTitle("z clusters - z cells for energy in cluster > threshold");
3980                 htmp->SetAxisRange(-50,50,"X");
3981                 htmp->Draw("HE");
3982                 
3983                 for (Int_t i = 0; i < ncuts; i++) {
3984                         binmin =  hE->FindBin(ecut[i]);
3985                         //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
3986                         htmp = fhDeltaCellClusterZE->ProjectionX(Form("hzde_cut%d",i),binmin,-1);
3987                         htmp->SetLineColor(ecutcolor[i]);
3988                         htmp->Rebin(rbZ);
3989                         htmp->Draw("same HE");
3990                         
3991                 }
3992         }
3993         
3994         sprintf(name,"QA_%s_DeltaClusterCellX_Y_Z_R_ECut.eps",fCalorimeter.Data());
3995         cxde->Print(name); printf("Create plot %s\n",name);
3996         
3997         
3998         //----------------------------------------------------------
3999         // Cluster-Cell X, Y, Z, R, NCells in cluster dependence
4000         //---------------------------------------------------------     
4001         sprintf(cname,"%s_QA_DeltaClusterCellX_Y_Z_R_NCellsCut",fCalorimeter.Data());
4002         TCanvas  * cxdn = new TCanvas(cname, "Cluster-Cell X Y Z R, NCells cut", 800, 800) ;
4003         cxdn->Divide(2, 2);             
4004         //R
4005         cxdn->cd(1) ; 
4006         gPad->SetLogy();
4007         gPad->SetGridy();
4008         
4009         TLegend pLegendXClDN(0.83,0.6,0.95,0.93);
4010         pLegendXClDN.SetTextSize(0.03);
4011         pLegendXClDN.SetFillColor(10);
4012         pLegendXClDN.SetBorderSize(1);
4013         
4014         htmp = fhDeltaCellClusterRNCells->ProjectionX("hrdn_nocut",0,-1);
4015         if(htmp){
4016                 htmp->SetMinimum(1);
4017                 htmp->Rebin(rbDR);
4018                 htmp->SetTitle("r clusters - r cells for n cells in cluster > threshold");
4019                 htmp->SetAxisRange(-50,50,"X");
4020                 htmp->Draw("HE");
4021                 pLegendXClDN.AddEntry(htmp,"No cut","L");
4022                 
4023                 for (Int_t i = 0; i < ncellcuts; i++) {
4024                         if(i < ncellcuts-1) htmp = fhDeltaCellClusterRNCells->ProjectionX(Form("hrdn_cut%d",i),ncellcut[i],ncellcut[i]);
4025                         else htmp = fhDeltaCellClusterRNCells->ProjectionX(Form("hrdn_cut%d",i),ncellcut[i],-1);
4026                         htmp->SetLineColor(ecutcolor[i]);
4027                         htmp->Rebin(rbDR);
4028                         htmp->Draw("same HE");
4029                         if(i < ncellcuts-1) pLegendXClDN.AddEntry(htmp,Form("n = %1.1d",ncellcut[i]-1),"L");
4030                         else pLegendXClDN.AddEntry(htmp,Form("n >= %1.1d",ncellcut[i]-1),"L");
4031                         
4032                 }
4033         }
4034         pLegendXClDN.Draw();
4035         
4036         //X
4037         cxdn->cd(2) ; 
4038         gPad->SetLogy();
4039         gPad->SetGridy();
4040         htmp = fhDeltaCellClusterXNCells->ProjectionX("hxdn_nocut",0,-1);
4041         if(htmp){
4042                 htmp->SetMinimum(1);
4043                 htmp->Rebin(rbDX);
4044                 htmp->SetTitle("x clusters - x cells for n cells in cluster > threshold");
4045                 htmp->SetAxisRange(-50,50,"X");
4046                 htmp->Draw("HE");
4047                 
4048                 for (Int_t i = 0; i < ncellcuts; i++) {
4049                         if(i < ncellcuts-1)htmp = fhDeltaCellClusterXNCells->ProjectionX(Form("hxdn_cut%d",i),ncellcut[i],ncellcut[i]);
4050                         else htmp = fhDeltaCellClusterXNCells->ProjectionX(Form("hxdn_cut%d",i),ncellcut[i],-1);
4051                         htmp->SetLineColor(ecutcolor[i]);
4052                         htmp->Rebin(rbDX);
4053                         htmp->Draw("same HE");
4054                         
4055                 }
4056         }
4057         //Y
4058         cxdn->cd(3) ; 
4059         gPad->SetLogy();
4060         gPad->SetGridy();
4061         htmp = fhDeltaCellClusterYNCells->ProjectionX("hydn_nocut",0,-1);
4062         if(htmp){
4063                 htmp->SetMinimum(1);
4064                 htmp->Rebin(rbDY);
4065                 htmp->SetTitle("y clusters - y cells for n cells in cluster > threshold");
4066                 htmp->SetAxisRange(-50,50,"X");
4067                 htmp->Draw("HE");
4068                 
4069                 for (Int_t i = 0; i < ncellcuts; i++) {
4070                         if(i < ncellcuts-1) htmp = fhDeltaCellClusterYNCells->ProjectionX(Form("hydn_cut%d",i),ncellcut[i],ncellcut[i]);
4071                         else htmp = fhDeltaCellClusterYNCells->ProjectionX(Form("hydn_cut%d",i),ncellcut[i],-1);
4072                         htmp->SetLineColor(ecutcolor[i]);
4073                         htmp->Rebin(rbDY);
4074                         htmp->Draw("same HE");
4075                         
4076                 }
4077         }
4078         //Z
4079         cxdn->cd(4) ; 
4080         gPad->SetLogy();
4081         gPad->SetGridy();
4082         
4083         htmp = fhDeltaCellClusterZNCells->ProjectionX("hzdn_nocut",0,-1);
4084         if(htmp){
4085                 htmp->SetMinimum(1);
4086                 htmp->Rebin(rbDZ);
4087                 htmp->SetTitle("z clusters - z cells for ncells in cluster > threshold");
4088                 htmp->SetAxisRange(-50,50,"X");
4089                 htmp->Draw("HE");
4090                 
4091                 for (Int_t i = 0; i < ncellcuts; i++) {
4092                         if(i < ncellcuts-1)htmp = fhDeltaCellClusterZNCells->ProjectionX(Form("hzdn_cut%d",i),ncellcut[i],ncellcut[i]);
4093                         else htmp = fhDeltaCellClusterZNCells->ProjectionX(Form("hzdn_cut%d",i),ncellcut[i],-1);
4094                         htmp->SetLineColor(ecutcolor[i]);
4095                         htmp->Rebin(rbDZ);
4096                         htmp->Draw("same HE");
4097                         
4098                 }
4099         }
4100         
4101         sprintf(name,"QA_%s_DeltaClusterCellX_Y_Z_R_NCellsCut.eps",fCalorimeter.Data());
4102         cxdn->Print(name); printf("Create plot %s\n",name);
4103
4104         
4105         //----------------------------------------------------------
4106         //Reconstructed clusters energy-eta-phi distributions, matched with tracks
4107         //----------------------------------------------------------
4108         
4109         TH1F *  hEChargedClone   = (TH1F*)   fhECharged->Clone(Form("%sClone",fhECharged->GetName()));
4110         TH1F *  hPtChargedClone  = (TH1F*)   fhPtCharged->Clone(Form("%sClone",fhPtCharged->GetName()));
4111         TH1F *  hEtaChargedClone = (TH1F*)   fhEtaCharged->Clone(Form("%sClone",fhEtaCharged->GetName()));
4112         TH1F *  hPhiChargedClone = (TH1F*)   fhPhiCharged->Clone(Form("%sClone",fhPhiCharged->GetName()));
4113
4114         
4115         sprintf(cname,"QA_%s_rectrackmatch",fCalorimeter.Data());
4116         TCanvas  * ccltm = new TCanvas(cname, "Reconstructed clusters E-Phi-Eta, matched with tracks", 1200, 400) ;
4117         ccltm->Divide(3, 1);
4118         
4119         ccltm->cd(1) ; 
4120         if(fhECharged->GetEntries() > 0) gPad->SetLogy();
4121         fhECharged->Rebin(rbE);
4122         fhECharged->SetAxisRange(ptmin,ptmax,"X");
4123         fhECharged->SetMinimum(1);
4124         fhECharged->Draw();
4125                 
4126         ccltm->cd(2) ; 
4127         if(fhPhiCharged->GetEntries() > 0) gPad->SetLogy();
4128         fhPhiCharged->Rebin(rbPhi);
4129         fhPhiCharged->SetAxisRange(phimin,phimax,"X");
4130         fhPhiCharged->Draw();
4131         fhPhiCharged->Draw();
4132         
4133         ccltm->cd(3) ;
4134         if(fhEtaCharged->GetEntries() > 0) gPad->SetLogy();
4135         fhEtaCharged->Rebin(rbEta);
4136         fhEtaCharged->SetAxisRange(etamin,etamax,"X");  
4137         fhEtaCharged->Draw();
4138         fhEtaCharged->Draw();
4139         
4140         sprintf(name,"QA_%s_ClusterEnergyPhiEta_TrackMatched.eps",fCalorimeter.Data());
4141         ccltm->Print(name); printf("Plot: %s\n",name);
4142         
4143         //----------------------------------------------------------
4144         // Ratio  of reconstructed clusters energy-eta-phi distributions, matched with tracks over all
4145         //----------------------------------------------------------
4146         
4147         sprintf(cname,"%s_QA_ChargedRatio",fCalorimeter.Data());
4148         TCanvas  * ccharge = new TCanvas(cname, "Charged clusters over all clusters", 1200, 400) ;
4149         ccharge->Divide(3, 1);
4150         
4151         ccharge->cd(1) ; 
4152         fhECharged->Sumw2();
4153         fhE->Sumw2();
4154         fhECharged->Divide(fhE);
4155         fhECharged->SetAxisRange(ptmin,ptmax,"X");
4156         fhECharged->SetMaximum(0.5);
4157         fhECharged->SetYTitle("track-matched clusters / all clusters");
4158         fhECharged->Draw("HE");
4159                 
4160         ccharge->cd(2) ; 
4161         fhPhiCharged->Sumw2();
4162         fhPhi->Rebin(rbPhi);
4163         fhPhi->Sumw2();
4164         fhPhiCharged->Divide(fhPhi);
4165         fhPhiCharged->SetAxisRange(phimin,phimax,"X");
4166         fhPhiCharged->SetMaximum(0.5);
4167         fhPhiCharged->SetYTitle("track-matched clusters / all clusters");
4168         fhPhiCharged->Draw("HE");
4169         
4170         ccharge->cd(3) ; 
4171         fhEtaCharged->Sumw2();
4172         fhEta->Rebin(rbEta);
4173         fhEta->Sumw2();
4174         fhEtaCharged->Divide(fhEta);
4175         fhEtaCharged->SetAxisRange(etamin,etamax,"X");
4176         fhEtaCharged->SetMaximum(0.5);
4177         fhEtaCharged->SetYTitle("track-matched clusters / all clusters");
4178         fhEtaCharged->Draw("HE");
4179         
4180         sprintf(name,"QA_%s_ClustersMatchedToAllRatios.eps",fCalorimeter.Data());
4181         ccharge->Print(name); printf("Create plot %s\n",name);
4182         
4183         //-------------------------------------------   
4184         // N Cells - N Clusters - N Cells per cluster
4185         //-------------------------------------------
4186         sprintf(cname,"QA_%s_nclustercells",fCalorimeter.Data());
4187         TCanvas  * cN = new TCanvas(cname, " Number of CaloClusters and CaloCells", 800, 1200) ;
4188         cN->Divide(2, 3);
4189         
4190         cN->cd(1) ; 
4191         
4192         TLegend pLegendN(0.7,0.6,0.9,0.8);
4193         pLegendN.SetTextSize(0.03);
4194         pLegendN.AddEntry(fhNClusters,"all modules","L");
4195         pLegendN.SetFillColor(10);
4196         pLegendN.SetBorderSize(1);
4197         
4198         if(fhNClusters->GetEntries() > 0) gPad->SetLogy();
4199         gPad->SetLogx();
4200         fhNClusters->SetLineColor(1);
4201         
4202         Int_t rbN = 1;
4203         if(fhNClusters->GetNbinsX()> nbins) rbN = fhNClusters->GetNbinsX()/nbins;
4204         
4205         fhNClusters->SetAxisRange(nmin,nmax,"X");
4206         fhNClusters->Draw("HE");
4207         for(Int_t imod = 0; imod < fNModules; imod++){
4208                 fhNClustersMod[imod]->SetAxisRange(nmin,nmax,"X");
4209                 fhNClustersMod[imod]->SetLineColor(modColorIndex[imod]);
4210                 fhNClustersMod[imod]->Draw("same");
4211                 pLegendN.AddEntry(fhNClustersMod[imod],Form("module %d",imod),"L");
4212         }
4213         pLegendN.Draw();
4214         
4215         cN->cd(2) ; 
4216         gPad->SetLogx();
4217         for(Int_t imod = 1; imod < fNModules; imod++){
4218                 htmp = (TH1D*)fhNClustersMod[imod]->Clone(Form("hNClustersRat%d",imod));
4219                 htmp->Divide(fhNClustersMod[0]);
4220                 htmp->SetLineColor(modColorIndex[imod]);
4221                 if(imod==1){
4222                         htmp->SetTitle("Ratio # clusters in  module X / module 0");
4223                         htmp->SetMaximum(5);
4224                         htmp->SetMinimum(0);
4225                         htmp->Draw("HE");
4226                 }
4227                 else 
4228                         htmp->Draw("same HE");
4229                 
4230         }
4231         
4232         cN->cd(3) ; 
4233         if(fhNCells->GetEntries() > 0) gPad->SetLogy();
4234         gPad->SetLogx();
4235         fhNCells->SetLineColor(1);
4236         fhNCells->SetAxisRange(nmin,nmax,"X");
4237         fhNCells->Draw("HE");
4238         for(Int_t imod = 0; imod < fNModules; imod++){
4239                 fhNCellsMod[imod]->SetAxisRange(nmin,nmax,"X");
4240                 fhNCellsMod[imod]->SetLineColor(modColorIndex[imod]);
4241                 fhNCellsMod[imod]->Draw("same HE");
4242         }
4243         
4244         
4245         cN->cd(4) ; 
4246         gPad->SetLogx();
4247         for(Int_t imod = 1; imod < fNModules; imod++){
4248                 htmp = (TH1D*)fhNCellsMod[imod]->Clone(Form("hNCellsRat%d",imod));
4249                 htmp->Divide(fhNCellsMod[0]);
4250                 htmp->SetLineColor(modColorIndex[imod]);
4251                 if(imod==1){
4252                         htmp->SetTitle("Ratio # cells in  module X / module 0");
4253                         htmp->SetMaximum(5);
4254                         htmp->SetMinimum(0);
4255                         htmp->Draw("HE");
4256                 }
4257                 else 
4258                         htmp->Draw("same HE");
4259                 
4260         }
4261         
4262         cN->cd(5) ; 
4263         if(fhNCellsPerCluster->GetEntries() > 0) gPad->SetLogy();
4264         gPad->SetLogx();
4265         TH1D *cpc = fhNCellsPerCluster->ProjectionY("cpc",-1,-1,-1,-1);
4266         cpc->SetLineColor(1);
4267         cpc->SetTitle("# cells per cluster");
4268         cpc->Draw("HE"); 
4269         TH1D ** hNCellsCluster1D = new TH1D*[fNModules];
4270         
4271         for(Int_t imod = 0; imod < fNModules; imod++){
4272                 hNCellsCluster1D[imod] = fhNCellsPerClusterMod[imod]->ProjectionY(Form("cpc_%d",imod),-1,-1);
4273                 hNCellsCluster1D[imod]->SetLineColor(modColorIndex[imod]);
4274                 hNCellsCluster1D[imod]->Draw("same HE");
4275         }
4276         
4277         
4278         cN->cd(6) ; 
4279         gPad->SetLogx();
4280         for(Int_t imod = 1; imod < fNModules; imod++){
4281                 htmp = (TH1D*)hNCellsCluster1D[imod]->Clone(Form("hNClustersCells1DRat%d",imod));
4282                 htmp->Divide(hNCellsCluster1D[0]);
4283                 htmp->SetLineColor(modColorIndex[imod]);
4284                 if(imod==1){
4285                         htmp->SetTitle("Ratio # cells per cluster in  module X / module 0");
4286                         //htmp->SetAxisRange(ptmin,ptmax,"X");
4287                         htmp->SetMaximum(3.5);
4288                         htmp->SetMinimum(0);
4289                         htmp->Draw("HE");
4290                 }
4291                 else 
4292                         htmp->Draw("same HE");
4293                 
4294         }
4295         sprintf(name,"QA_%s_NumberCaloClustersAndCaloCells.eps",fCalorimeter.Data());
4296         cN->Print(name); printf("Print plot %s\n",name);
4297         
4298         //----------------------------------------------------  
4299         // Cell Time histograms, time only available in ESDs
4300         //----------------------------------------------------
4301         if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
4302         
4303                 sprintf(cname,"QA_%s_cellstime",fCalorimeter.Data());
4304                 TCanvas  * ctime = new TCanvas(cname, " Cells time", 1200, 400) ;
4305                 ctime->Divide(3, 1);
4306                 
4307                 Int_t rbTime = 1;
4308                 if(fhTime->GetNbinsX()> ntimebins) rbTime = fhTime->GetNbinsX()/ntimebins;
4309                 
4310                 ctime->cd(1) ; 
4311                 if(fhTime->GetEntries() > 0) gPad->SetLogy();
4312                 fhTime->Rebin(rbTime);
4313                 fhTime->SetAxisRange(timemin,timemax,"X");
4314                 fhTime->Draw();
4315         
4316                 ctime->cd(2) ; 
4317                 fhTimeId->SetTitleOffset(1.8,"Y");
4318                 fhTimeId->SetAxisRange(timemin,timemax,"X");
4319                 fhTimeId->Draw("colz");
4320         
4321                 ctime->cd(3) ; 
4322                 fhTimeAmp->SetTitle("Cell Energy vs Cell Time");
4323                 fhTimeAmp->SetTitleOffset(1.8,"Y");
4324                 fhTimeAmp->SetAxisRange(timemin,timemax,"Y");
4325                 fhTimeAmp->SetAxisRange(ptmin,ptmax,"X");               
4326                 fhTimeAmp->Draw("colz");
4327         
4328                 sprintf(name,"QA_%s_CellsTime.eps",fCalorimeter.Data());
4329                 ctime->Print(name); printf("Plot: %s\n",name);
4330         }
4331         
4332         
4333         //---------------------------------
4334         //Grid of cell per module plots 
4335         //---------------------------------
4336         {
4337         //Number of entries per cell
4338         gStyle->SetPadRightMargin(0.15);
4339         sprintf(cname,"%s_QA_GridCellEntries",fCalorimeter.Data());
4340         TCanvas *cgrid   = new TCanvas("cgrid","Number of entries per cell", 12,12,800,400);
4341         if(fNModules%2 == 0)
4342                 cgrid->Divide(fNModules/2,2); 
4343         else
4344                 cgrid->Divide(fNModules/2+1,2); 
4345                 
4346         for(Int_t imod = 0; imod < fNModules ; imod++){
4347                 cgrid->cd(imod+1);
4348                 gPad->SetLogz();
4349                 gPad->SetGridy();
4350                 gPad->SetGridx();
4351                 //fhGridCellsMod[imod]->GetYAxis()->SetTitleColor(1);
4352                 fhGridCellsMod[imod]->SetZTitle("Counts    ");
4353                 fhGridCellsMod[imod]->SetYTitle("row (phi direction)    ");
4354                 //fhGridCellsMod[imod]->SetLabelSize(0.025,"z");
4355                 fhGridCellsMod[imod]->Draw("colz");
4356         }
4357         sprintf(name,"QA_%s_GridCellsEntries.eps",fCalorimeter.Data());
4358         cgrid->Print(name); printf("Create plot %s\n",name);
4359                         
4360         sprintf(cname,"%s_QA_GridCellAccumEnergy",fCalorimeter.Data());
4361         TCanvas *cgridE   = new TCanvas("cgridE","Summed energy per cell", 12,12,800,400);
4362         if(fNModules%2 == 0)
4363                 cgridE->Divide(fNModules/2,2); 
4364         else
4365                 cgridE->Divide(fNModules/2+1,2); 
4366         for(Int_t imod = 0; imod < fNModules ; imod++){
4367                 cgridE->cd(imod+1);
4368                 gPad->SetLogz();
4369                 gPad->SetGridy();
4370                 gPad->SetGridx();
4371                 //fhGridCellsEMod[imod]->SetLabelSize(0.025,"z");
4372                 fhGridCellsEMod[imod]->SetZTitle("Accumulated Energy (GeV)    ");
4373                 fhGridCellsEMod[imod]->SetYTitle("row (phi direction)    ");
4374                 fhGridCellsEMod[imod]->Draw("colz");
4375         }
4376         sprintf(name,"QA_%s_GridCellsAccumEnergy.eps",fCalorimeter.Data());
4377         cgridE->Print(name); printf("Create plot %s\n",name);
4378
4379         //Accumulated energy per cell
4380         sprintf(cname,"%s_QA_GridCellAverageEnergy",fCalorimeter.Data());
4381         TCanvas *cgridEA   = new TCanvas("cgridEA","Average energy per cell", 12,12,800,400);
4382         if(fNModules%2 == 0)      
4383                 cgridEA->Divide(fNModules/2,2);
4384         else
4385                 cgridEA->Divide(fNModules/2+1,2);  
4386         for(Int_t imod = 0; imod < fNModules ; imod++){
4387                 cgridEA->cd(imod+1);
4388                 gPad->SetLogz();
4389                 gPad->SetGridy();
4390                 gPad->SetGridx();
4391                 //fhGridCellsEMod[imod]->SetLabelSize(0.025,"z");
4392                 fhGridCellsEMod[imod]->SetZTitle("Average Energy (GeV)    ");
4393                 fhGridCellsEMod[imod]->Divide(fhGridCellsMod[imod]);
4394                 fhGridCellsEMod[imod]->Draw("colz");
4395         }
4396         sprintf(name,"QA_%s_GridCellsAverageEnergy.eps",fCalorimeter.Data());
4397         cgridEA->Print(name); printf("Create plot %s\n",name);
4398                 
4399         //Accumulated Time per cell, E > 0.5 GeV
4400                 
4401         sprintf(cname,"%s_QA_GridCellAccumTime",fCalorimeter.Data());
4402         TCanvas *cgridT   = new TCanvas("cgridT","Summed time per cell", 12,12,800,400);
4403         if(fNModules%2 == 0)
4404                 cgridT->Divide(fNModules/2,2); 
4405         else
4406                 cgridE->Divide(fNModules/2+1,2); 
4407         for(Int_t imod = 0; imod < fNModules ; imod++){
4408                 cgridT->cd(imod+1);
4409                 gPad->SetLogz();
4410                 gPad->SetGridy();
4411                 gPad->SetGridx();
4412                 //fhGridCellsTimeMod[imod]->SetLabelSize(0.025,"z");
4413                 fhGridCellsTimeMod[imod]->SetZTitle("Accumulated Time (ns)    ");
4414                 fhGridCellsTimeMod[imod]->SetYTitle("row (phi direction)    ");
4415                 fhGridCellsTimeMod[imod]->Draw("colz");
4416         }
4417         sprintf(name,"QA_%s_GridCellsAccumTime.eps",fCalorimeter.Data());
4418         cgridT->Print(name); printf("Create plot %s\n",name);
4419                 
4420         }
4421         
4422         //---------------------------------------------
4423         //Calorimeter Correlation, PHOS vs EMCAL
4424         //---------------------------------------------
4425         if(fCorrelateCalos){
4426                 
4427                 sprintf(cname,"QA_%s_CaloCorr_EMCALvsPHOS",fCalorimeter.Data());
4428                 TCanvas  * ccorr = new TCanvas(cname, " EMCAL vs PHOS", 400, 400) ;
4429                 ccorr->Divide(2, 2);
4430         
4431                 ccorr->cd(1) ; 
4432                 //gPad->SetLogy();
4433                 //gPad->SetLogx();
4434                 fhCaloCorrNClusters->SetAxisRange(nmin,nmax,"X");
4435                 fhCaloCorrNClusters->SetAxisRange(nmin,nmax,"Y");               
4436                 fhCaloCorrNClusters ->Draw();
4437         
4438                 ccorr->cd(2) ; 
4439                 //gPad->SetLogy();
4440                 //gPad->SetLogx();
4441                 fhCaloCorrNCells->SetAxisRange(nmin,nmax,"X");
4442                 fhCaloCorrNCells->SetAxisRange(nmin,nmax,"Y");          
4443                 fhCaloCorrNCells->Draw();
4444         
4445                 //gPad->SetLogy();
4446                 //gPad->SetLogx();
4447                 fhCaloCorrEClusters->SetAxisRange(ptmin,ptmax,"X");
4448                 fhCaloCorrEClusters->SetAxisRange(ptmin,ptmax,"Y");             
4449                 fhCaloCorrEClusters->Draw();
4450         
4451                 ccorr->cd(4) ; 
4452                 //gPad->SetLogy();
4453                 //gPad->SetLogx();
4454                 fhCaloCorrECells->SetAxisRange(ptmin,ptmax,"X");
4455                 fhCaloCorrECells->SetAxisRange(ptmin,ptmax,"Y");                
4456                 fhCaloCorrECells->Draw();
4457         
4458                 sprintf(name,"QA_%s_CaloCorr_EMCALvsPHOS.eps",fCalorimeter.Data());
4459                 ccorr->Print(name); printf("Plot: %s\n",name);
4460         }
4461                 
4462         //----------------------------
4463         //Invariant mass
4464         //-----------------------------
4465         
4466         Int_t imbinmin = -1;
4467         Int_t imbinmax = -1;
4468         
4469         if(fhIM->GetEntries() > 1){
4470                 Int_t nebins  = fhIM->GetNbinsX();
4471                 Int_t emax = (Int_t) fhIM->GetXaxis()->GetXmax();
4472                 Int_t emin = (Int_t) fhIM->GetXaxis()->GetXmin();
4473                 if (emin != 0 ) printf("emin != 0 \n");
4474                 //printf("IM: nBinsX %d, emin %2.2f, emax %2.2f\n",nebins,emin,emax);
4475                 
4476                 sprintf(cname,"QA_%s_IM",fCalorimeter.Data());
4477                 //      printf("c5\n");
4478                 TCanvas  * c5 = new TCanvas(cname, "Invariant mass", 600, 400) ;
4479                 c5->Divide(2, 3);
4480                 
4481                 c5->cd(1) ; 
4482                 //fhIM->SetLineColor(4);
4483                 //fhIM->Draw();
4484                 imbinmin = 0;
4485                 imbinmax =  (Int_t) (1-emin)*nebins/emax;
4486                 TH1D *pyim1 = fhIM->ProjectionY(Form("%s_py1",fhIM->GetName()),imbinmin,imbinmax);
4487                 pyim1->SetTitle("E_{pair} < 1 GeV");
4488                 pyim1->SetLineColor(1);
4489                 pyim1->Draw();
4490                 TLegend pLegendIM(0.7,0.6,0.9,0.8);
4491                 pLegendIM.SetTextSize(0.03);
4492                 pLegendIM.AddEntry(pyim1,"all modules","L");
4493                 pLegendIM.SetFillColor(10);
4494                 pLegendIM.SetBorderSize(1);
4495                 //FIXME
4496                 for(Int_t imod = 0; imod < fNModules; imod++){
4497                         pyim1 = fhIMMod[imod]->ProjectionY(Form("%s_py1",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
4498                         pLegendIM.AddEntry(pyim1,Form("module %d",imod),"L");
4499                         pyim1->SetLineColor(imod+1);
4500                         pyim1->Draw("same");
4501                 }
4502                 pLegendIM.Draw();
4503                 
4504                 c5->cd(2) ; 
4505                 imbinmin =  (Int_t) (1-emin)*nebins/emax;
4506                 imbinmax =  (Int_t) (2-emin)*nebins/emax;
4507                 TH1D *pyim2 = fhIM->ProjectionY(Form("%s_py2",fhIM->GetName()),imbinmin,imbinmax);
4508                 pyim2->SetTitle("1 < E_{pair} < 2 GeV");
4509                 pyim2->SetLineColor(1);
4510                 pyim2->Draw();
4511                 for(Int_t imod = 0; imod < fNModules; imod++){
4512                         pyim2 = fhIMMod[imod]->ProjectionY(Form("%s_py2",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
4513                         pyim2->SetLineColor(imod+1);
4514                         pyim2->Draw("same");
4515                 }
4516                 
4517                 c5->cd(3) ; 
4518                 imbinmin =  (Int_t) (2-emin)*nebins/emax;
4519                 imbinmax =  (Int_t) (3-emin)*nebins/emax;
4520                 TH1D *pyim3 = fhIM->ProjectionY(Form("%s_py3",fhIM->GetName()),imbinmin,imbinmax);
4521                 pyim3->SetTitle("2 < E_{pair} < 3 GeV");
4522                 pyim3->SetLineColor(1);
4523                 pyim3->Draw();
4524                 for(Int_t imod = 0; imod < fNModules; imod++){
4525                         pyim3 = fhIMMod[imod]->ProjectionY(Form("%s_py3",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
4526                         pyim3->SetLineColor(imod+1);
4527                         pyim3->Draw("same");
4528                 }
4529                 
4530                 c5->cd(4) ;
4531                 imbinmin =  (Int_t) (3-emin)*nebins/emax;
4532                 imbinmax =  (Int_t) (4-emin)*nebins/emax;
4533                 TH1D *pyim4 = fhIM->ProjectionY(Form("%s_py4",fhIM->GetName()),imbinmin,imbinmax);
4534                 pyim4->SetTitle("3 < E_{pair} < 4 GeV");
4535                 pyim4->SetLineColor(1);
4536                 pyim4->Draw();
4537                 for(Int_t imod = 0; imod < fNModules; imod++){
4538                         pyim4 = fhIMMod[imod]->ProjectionY(Form("%s_py4",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
4539                         pyim4->SetLineColor(imod+1);
4540                         pyim4->Draw("same");
4541                 }
4542                 
4543                 c5->cd(5) ;
4544                 imbinmin =  (Int_t) (4-emin)*nebins/emax;
4545                 imbinmax =  (Int_t) (5-emin)*nebins/emax;
4546                 TH1D *pyim5 = fhIM->ProjectionY(Form("%s_py5",fhIM->GetName()),imbinmin,imbinmax);
4547                 pyim5->SetTitle("4< E_{pair} < 5 GeV");
4548                 pyim5->SetLineColor(1);
4549                 pyim5->Draw();
4550                 for(Int_t imod = 0; imod < fNModules; imod++){
4551                         pyim5 = fhIMMod[imod]->ProjectionY(Form("%s_py5",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
4552                         pyim5->SetLineColor(imod+1);
4553                         pyim5->Draw("same");
4554                 }
4555                 
4556                 c5->cd(6) ;
4557                 imbinmin =  (Int_t) (5-emin)*nebins/emax;
4558                 imbinmax =  -1;
4559                 TH1D *pyim10 = fhIM->ProjectionY(Form("%s_py6",fhIM->GetName()),imbinmin,imbinmax);
4560                 pyim10->SetTitle("E_{pair} > 5 GeV");
4561                 pyim10->SetLineColor(1);
4562                 pyim10->Draw();
4563                 for(Int_t imod = 0; imod < fNModules; imod++){
4564                         pyim10 = fhIMMod[imod]->ProjectionY(Form("%s_py6",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
4565                         pyim10->SetLineColor(imod+1);
4566                         pyim10->Draw("same");
4567                 }
4568                 
4569                 sprintf(name,"QA_%s_InvariantMass.eps",fCalorimeter.Data());
4570                 c5->Print(name); printf("Plot: %s\n",name);
4571         }
4572         
4573         //--------------------------------------------------
4574         //Invariant mass, clusters with more than one cell
4575         //-------------------------------------------------
4576         if(fhIMCellCut->GetEntries() > 1){
4577                 Int_t nebins  = fhIMCellCut->GetNbinsX();
4578                 Int_t emax = (Int_t) fhIMCellCut->GetXaxis()->GetXmax();
4579                 Int_t emin = (Int_t) fhIMCellCut->GetXaxis()->GetXmin();
4580                 if (emin != 0 ) printf("emin != 0 \n");
4581                 //printf("IMCellCut: nBinsX %d, emin %2.2f, emax %2.2f\n",nebins,emin,emax);
4582                 
4583                 sprintf(cname,"QA_%s_IMCellCut",fCalorimeter.Data());
4584                 //      printf("c5cc\n");
4585                 TCanvas  * c5cc = new TCanvas(cname, "Invariant mass, Cell Cut", 600, 400) ;
4586                 c5cc->Divide(2, 3);
4587                 
4588                 c5cc->cd(1) ; 
4589                 //fhIMCellCut->SetLineColor(4);
4590                 //fhIMCellCut->Draw();
4591                 imbinmin = 0;
4592                 imbinmax =  (Int_t) (1-emin)*nebins/emax;
4593                 TH1D *pyimcc1 = fhIMCellCut->ProjectionY(Form("%s_py1",fhIMCellCut->GetName()),imbinmin,imbinmax);
4594                 pyimcc1->SetTitle("E_{pair} < 1 GeV");
4595                 pyimcc1->SetLineColor(1);
4596                 pyimcc1->Draw();
4597                 TLegend pLegendIMCellCut(0.7,0.6,0.9,0.8);
4598                 pLegendIMCellCut.SetTextSize(0.03);
4599                 pLegendIMCellCut.AddEntry(pyimcc1,"all modules","L");
4600                 pLegendIMCellCut.SetFillColor(10);
4601                 pLegendIMCellCut.SetBorderSize(1);
4602                 
4603                 for(Int_t imod = 0; imod < fNModules; imod++){
4604                         pyimcc1 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
4605                         pLegendIMCellCut.AddEntry(pyimcc1,Form("module %d",imod),"L");
4606                         pyimcc1->SetLineColor(imod+1);
4607                         pyimcc1->Draw("same");
4608                 }
4609                 pLegendIMCellCut.Draw();
4610                 
4611                 c5cc->cd(2) ; 
4612                 imbinmin =  (Int_t) (1-emin)*nebins/emax;
4613                 imbinmax =  (Int_t) (2-emin)*nebins/emax;
4614                 TH1D *pyimcc2 = fhIMCellCut->ProjectionY(Form("%s_py2",fhIMCellCut->GetName()),imbinmin,imbinmax);
4615                 pyimcc2->SetTitle("1 < E_{pair} < 2 GeV");
4616                 pyimcc2->SetLineColor(1);
4617                 pyimcc2->Draw();
4618                 for(Int_t imod = 0; imod < fNModules; imod++){
4619                         pyimcc2 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
4620                         pyimcc2->SetLineColor(imod+1);
4621                         pyimcc2->Draw("same");
4622                 }
4623                 
4624                 c5cc->cd(3) ; 
4625                 imbinmin =  (Int_t) (2-emin)*nebins/emax;
4626                 imbinmax =  (Int_t) (3-emin)*nebins/emax;
4627                 TH1D *pyimcc3 = fhIMCellCut->ProjectionY(Form("%s_py3",fhIMCellCut->GetName()),imbinmin,imbinmax);
4628                 pyimcc3->SetTitle("2 < E_{pair} < 3 GeV");
4629                 pyimcc3->SetLineColor(1);
4630                 pyimcc3->Draw();
4631                 for(Int_t imod = 0; imod < fNModules; imod++){
4632                         pyimcc3 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
4633                         pyimcc3->SetLineColor(imod+1);
4634                         pyimcc3->Draw("same");
4635                 }
4636                 
4637                 c5cc->cd(4) ;
4638                 imbinmin =  (Int_t) (3-emin)*nebins/emax;
4639                 imbinmax =  (Int_t) (4-emin)*nebins/emax;
4640                 TH1D *pyimcc4 = fhIMCellCut->ProjectionY(Form("%s_py4",fhIMCellCut->GetName()),imbinmin,imbinmax);
4641                 pyimcc4->SetTitle("3 < E_{pair} < 4 GeV");
4642                 pyimcc4->SetLineColor(1);
4643                 pyimcc4->Draw();
4644                 for(Int_t imod = 0; imod < fNModules; imod++){
4645                         pyimcc4 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py5",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
4646                         pyimcc4->SetLineColor(imod+1);
4647                         pyimcc4->Draw("same");
4648                 }
4649                 
4650                 c5cc->cd(5) ;
4651                 imbinmin =  (Int_t) (4-emin)*nebins/emax;
4652                 imbinmax =  (Int_t) (5-emin)*nebins/emax;
4653                 TH1D *pyimcc5cc = fhIMCellCut->ProjectionY(Form("%s_py5",fhIMCellCut->GetName()),imbinmin,imbinmax);
4654                 pyimcc5cc->SetTitle("4< E_{pair} < 5 GeV");
4655                 pyimcc5cc->SetLineColor(1);
4656                 pyimcc5cc->Draw();
4657                 for(Int_t imod = 0; imod < fNModules; imod++){
4658                         pyimcc5cc = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py5",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
4659                         pyimcc5cc->SetLineColor(imod+1);
4660                         pyimcc5cc->Draw("same");
4661                 }
4662                 
4663                 c5cc->cd(6) ;
4664                 imbinmin =  (Int_t) (5-emin)*nebins/emax;
4665                 imbinmax =  -1;
4666                 TH1D *pyimcc10 = fhIMCellCut->ProjectionY(Form("%s_py6",fhIMCellCut->GetName()),imbinmin,imbinmax);
4667                 pyimcc10->SetTitle("E_{pair} > 5 GeV");
4668                 pyimcc10->SetLineColor(1);
4669                 pyimcc10->Draw();
4670                 for(Int_t imod = 0; imod < fNModules; imod++){
4671                         pyimcc10 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
4672                         pyimcc10->SetLineColor(imod+1);
4673                         pyimcc10->Draw("same");
4674                 }
4675                 
4676                 sprintf(name,"QA_%s_InvariantMass_CellCut.eps",fCalorimeter.Data());
4677                 c5cc->Print(name); printf("Plot: %s\n",name);
4678         }
4679         
4680         
4681         //Asymmetry
4682         if(fhAsym->GetEntries() > 1){
4683                 Int_t nebins  = fhAsym->GetNbinsX();
4684                 Int_t emax = (Int_t) fhAsym->GetXaxis()->GetXmax();
4685                 Int_t emin = (Int_t) fhAsym->GetXaxis()->GetXmin();
4686                 if (emin != 0 ) printf("emin != 0 \n");
4687                 //printf("Asym: nBinsX %d, emin %2.2f, emax %2.2f\n",nebins,emin,emax);
4688                 
4689                 sprintf(cname,"QA_%s_Asym",fCalorimeter.Data());
4690                 //      printf("c5\n");
4691                 TCanvas  * c5b = new TCanvas(cname, "Asymmetry", 400, 400) ;
4692                 c5b->Divide(2, 2);
4693                 
4694                 c5b->cd(1) ; 
4695                 fhAsym->SetTitleOffset(1.6,"Y");
4696                 fhAsym->SetLineColor(4);
4697                 fhAsym->Draw();
4698                 
4699                 c5b->cd(2) ; 
4700                 imbinmin = 0;
4701                 imbinmax = (Int_t) (5-emin)*nebins/emax;
4702                 TH1D *pyAsym5 = fhAsym->ProjectionY(Form("%s_py5",fhAsym->GetName()),imbinmin,imbinmax);
4703                 pyAsym5->SetTitle("E_{pair} < 5 GeV");
4704                 pyAsym5->SetLineColor(4);
4705                 pyAsym5->Draw();
4706                 
4707                 c5b->cd(3) ; 
4708                 imbinmin = (Int_t) (5-emin)*nebins/emax;
4709                 imbinmax = (Int_t) (10-emin)*nebins/emax;
4710                 TH1D *pyAsym510 = fhAsym->ProjectionY(Form("%s_py510",fhAsym->GetName()),imbinmin,imbinmax);
4711                 pyAsym510->SetTitle("5 < E_{pair} < 10 GeV");
4712                 pyAsym510->SetLineColor(4);
4713                 pyAsym510->Draw();
4714                 
4715                 c5b->cd(4) ;
4716                 imbinmin = (Int_t) (10-emin)*nebins/emax;
4717                 imbinmax = -1;
4718                 TH1D *pyAsym10 = fhAsym->ProjectionY(Form("%s_py10",fhAsym->GetName()),imbinmin,imbinmax);
4719                 pyAsym10->SetTitle("E_{pair} > 10 GeV");
4720                 pyAsym10->SetLineColor(4);
4721                 pyAsym10->Draw();
4722                 
4723                 sprintf(name,"QA_%s_Asymmetry.eps",fCalorimeter.Data());
4724                 c5b->Print(name); printf("Plot: %s\n",name);
4725         }
4726         
4727         
4728         if(IsDataMC()){
4729         //Reconstructed vs MC distributions
4730         //printf("c6\n");
4731         sprintf(cname,"QA_%s_recvsmc",fCalorimeter.Data());
4732         TCanvas  * c6 = new TCanvas(cname, "Reconstructed vs MC distributions", 400, 400) ;
4733         c6->Divide(2, 2);
4734         
4735         c6->cd(1) ; 
4736         fh2E->SetTitleOffset(1.6,"Y");
4737         fh2E->SetLineColor(4);
4738         fh2E->Draw();
4739         
4740         c6->cd(2) ; 
4741         fh2Pt->SetTitleOffset(1.6,"Y");
4742         fh2Pt->SetLineColor(4);
4743         fh2Pt->Draw();
4744         
4745         c6->cd(3) ; 
4746         fh2Phi->SetTitleOffset(1.6,"Y");
4747         fh2Phi->SetLineColor(4);
4748         fh2Phi->Draw();
4749         
4750         c6->cd(4) ; 
4751         fh2Eta->SetTitleOffset(1.6,"Y");
4752         fh2Eta->SetLineColor(4);
4753         fh2Eta->Draw();
4754         
4755         sprintf(name,"QA_%s_ReconstructedVSMCDistributions.eps",fCalorimeter.Data());
4756         c6->Print(name); printf("Plot: %s\n",name);     
4757         
4758         //Reconstructed vs MC distributions
4759         //printf("c6\n");
4760         sprintf(cname,"QA_%s_gamrecvsmc",fCalorimeter.Data());
4761         TCanvas  * c6Gam = new TCanvas(cname, "Reconstructed vs MC distributions", 400, 400) ;
4762         c6Gam->Divide(2, 2);
4763         
4764         c6Gam->cd(1) ; 
4765         fhGamE->Draw();
4766         
4767         c6Gam->cd(2) ; 
4768         fhGamPt->Draw();
4769         
4770         c6Gam->cd(3) ; 
4771         fhGamPhi->Draw();
4772         
4773         c6Gam->cd(4) ; 
4774         fhGamEta->Draw();
4775         
4776         sprintf(name,"QA_%s_GammaReconstructedVSMCDistributions.eps",fCalorimeter.Data());
4777         c6->Print(name); printf("Plot: %s\n",name);     
4778         
4779         //Generated - reconstructed  
4780         //printf("c7\n");
4781         sprintf(cname,"QA_%s_diffgenrec",fCalorimeter.Data());
4782         TCanvas  * c7 = new TCanvas(cname, "generated - reconstructed", 400, 400) ;
4783         c7->Divide(2, 2);
4784         
4785         c7->cd(1) ; 
4786         if(fhDeltaE->GetEntries() > 0) gPad->SetLogy();
4787         fhGamDeltaE->SetLineColor(4);
4788         fhDeltaE->Draw();
4789         fhGamDeltaE->Draw("same");
4790         
4791         TLegend pLegendd(0.65,0.55,0.9,0.8);
4792         pLegendd.SetTextSize(0.06);
4793         pLegendd.AddEntry(fhDeltaE,"all","L");
4794         pLegendd.AddEntry(fhGamDeltaE,"from  #gamma","L");
4795         pLegendd.SetFillColor(10);
4796         pLegendd.SetBorderSize(1);
4797         pLegendd.Draw();
4798         
4799         c7->cd(2) ; 
4800         if(fhDeltaPt->GetEntries() > 0) gPad->SetLogy();
4801         fhGamDeltaPt->SetLineColor(4);
4802         fhDeltaPt->Draw();
4803         fhGamDeltaPt->Draw("same");
4804         
4805         c7->cd(3) ; 
4806         fhGamDeltaPhi->SetLineColor(4);
4807         fhDeltaPhi->Draw();
4808         fhGamDeltaPhi->Draw("same");
4809         
4810         c7->cd(4) ; 
4811         fhGamDeltaEta->SetLineColor(4);
4812         fhDeltaEta->Draw();
4813         fhGamDeltaEta->Draw("same");
4814         
4815         sprintf(name,"QA_%s_DiffGeneratedReconstructed.eps",fCalorimeter.Data());
4816         c7->Print(name); printf("Plot: %s\n",name);
4817         
4818         // Reconstructed / Generated 
4819         //printf("c8\n");
4820         sprintf(cname,"QA_%s_ratiorecgen",fCalorimeter.Data());
4821         TCanvas  * c8 = new TCanvas(cname, " reconstructed / generated", 400, 400) ;
4822         c8->Divide(2, 2);
4823         
4824         c8->cd(1) ; 
4825         if(fhRatioE->GetEntries() > 0) gPad->SetLogy();
4826         fhGamRatioE->SetLineColor(4);
4827         fhRatioE->Draw();
4828         fhGamRatioE->Draw("same");
4829         
4830         TLegend pLegendr(0.65,0.55,0.9,0.8);
4831         pLegendr.SetTextSize(0.06);
4832         pLegendr.AddEntry(fhRatioE,"all","L");
4833         pLegendr.AddEntry(fhGamRatioE,"from  #gamma","L");
4834         pLegendr.SetFillColor(10);
4835         pLegendr.SetBorderSize(1);
4836         pLegendr.Draw();
4837         
4838         c8->cd(2) ; 
4839         if(fhRatioPt->GetEntries() > 0) gPad->SetLogy();
4840         fhGamRatioPt->SetLineColor(4);
4841         fhRatioPt->Draw();
4842         fhGamRatioPt->Draw("same");
4843         
4844         c8->cd(3) ; 
4845         fhGamRatioPhi->SetLineColor(4);
4846         fhRatioPhi->Draw();
4847         fhGamRatioPhi->Draw("same");
4848         
4849         c8->cd(4) ; 
4850         fhGamRatioEta->SetLineColor(4);
4851         fhRatioEta->Draw();
4852         fhGamRatioEta->Draw("same");
4853         
4854         sprintf(name,"QA_%s_ReconstructedDivGenerated.eps",fCalorimeter.Data());
4855         c8->Print(name); printf("Plot: %s\n",name);
4856         
4857         //MC
4858         
4859         //Generated distributions
4860         //printf("c1\n");
4861         sprintf(cname,"QA_%s_gen",fCalorimeter.Data());
4862         TCanvas  * c10 = new TCanvas(cname, "Generated distributions", 600, 200) ;
4863         c10->Divide(3, 1);
4864         
4865         c10->cd(1) ; 
4866         gPad->SetLogy();
4867         TH1F * haxispt  = (TH1F*) fhGenPi0Pt->Clone(Form("%s_axispt",fhGenPi0Pt->GetName()));  
4868         haxispt->SetTitle("Generated Particles p_{T}, |#eta| < 1");
4869         fhGenPi0Pt->SetLineColor(1);
4870         fhGenGamPt->SetLineColor(4);
4871         fhGenEtaPt->SetLineColor(2);
4872         fhGenOmegaPt->SetLineColor(7);
4873         fhGenElePt->SetLineColor(6);
4874         
4875         //Select the maximum of the histogram to show all lines.
4876         if(fhGenPi0Pt->GetMaximum() >= fhGenGamPt->GetMaximum() && fhGenPi0Pt->GetMaximum() >= fhGenEtaPt->GetMaximum() && 
4877            fhGenPi0Pt->GetMaximum() >= fhGenOmegaPt->GetMaximum() && fhGenPi0Pt->GetMaximum() >= fhGenElePt->GetMaximum())
4878                 haxispt->SetMaximum(fhGenPi0Pt->GetMaximum());
4879         else if(fhGenGamPt->GetMaximum() >= fhGenPi0Pt->GetMaximum() && fhGenGamPt->GetMaximum() >= fhGenEtaPt->GetMaximum() && 
4880                         fhGenGamPt->GetMaximum() >= fhGenOmegaPt->GetMaximum() && fhGenGamPt->GetMaximum() >= fhGenElePt->GetMaximum())
4881                 haxispt->SetMaximum(fhGenGamPt->GetMaximum());
4882         else if(fhGenEtaPt->GetMaximum() >= fhGenPi0Pt->GetMaximum() && fhGenEtaPt->GetMaximum() >= fhGenGamPt->GetMaximum() && 
4883                         fhGenEtaPt->GetMaximum() >= fhGenOmegaPt->GetMaximum() && fhGenEtaPt->GetMaximum() >= fhGenElePt->GetMaximum())
4884                 haxispt->SetMaximum(fhGenEtaPt->GetMaximum());  
4885         else if(fhGenOmegaPt->GetMaximum() >= fhGenPi0Pt->GetMaximum() && fhGenOmegaPt->GetMaximum() >= fhGenEtaPt->GetMaximum() && 
4886                         fhGenOmegaPt->GetMaximum() >= fhGenGamPt->GetMaximum() && fhGenOmegaPt->GetMaximum() >= fhGenElePt->GetMaximum())
4887                 haxispt->SetMaximum(fhGenOmegaPt->GetMaximum());
4888         else if(fhGenElePt->GetMaximum() >= fhGenPi0Pt->GetMaximum() && fhGenElePt->GetMaximum() >= fhGenEtaPt->GetMaximum() && 
4889                         fhGenElePt->GetMaximum() >= fhGenOmegaPt->GetMaximum() && fhGenElePt->GetMaximum() >= fhGenGamPt->GetMaximum())
4890                 haxispt->SetMaximum(fhGenElePt->GetMaximum());
4891         haxispt->SetMinimum(1);
4892         haxispt->Draw("axis");
4893         fhGenPi0Pt->Draw("same");
4894         fhGenGamPt->Draw("same");
4895         fhGenEtaPt->Draw("same");
4896         fhGenOmegaPt->Draw("same");
4897         fhGenElePt->Draw("same");
4898         
4899         TLegend pLegend(0.85,0.65,0.95,0.93);
4900         pLegend.SetTextSize(0.06);
4901         pLegend.AddEntry(fhGenPi0Pt,"  #pi^{0}","L");
4902         pLegend.AddEntry(fhGenGamPt,"  #gamma","L");
4903         pLegend.AddEntry(fhGenEtaPt,"  #eta","L");
4904         pLegend.AddEntry(fhGenOmegaPt,"  #omega","L");
4905         pLegend.AddEntry(fhGenElePt,"  e^{#pm}","L");
4906         pLegend.SetFillColor(10);
4907         pLegend.SetBorderSize(1);
4908         pLegend.Draw();
4909         
4910         c10->cd(2) ;
4911         gPad->SetLogy();
4912         TH1F * haxiseta  = (TH1F*) fhGenPi0Eta->Clone(Form("%s_axiseta",fhGenPi0Eta->GetName()));  
4913         haxiseta->SetTitle("Generated Particles #eta, |#eta| < 1");
4914         fhGenPi0Eta->SetLineColor(1);
4915         fhGenGamEta->SetLineColor(4);
4916         fhGenEtaEta->SetLineColor(2);
4917         fhGenOmegaEta->SetLineColor(7);
4918         fhGenEleEta->SetLineColor(6);
4919         //Select the maximum of the histogram to show all lines.
4920         if(fhGenPi0Eta->GetMaximum() >= fhGenGamEta->GetMaximum() && fhGenPi0Eta->GetMaximum() >= fhGenEtaEta->GetMaximum() && 
4921            fhGenPi0Eta->GetMaximum() >= fhGenOmegaEta->GetMaximum() && fhGenPi0Eta->GetMaximum() >= fhGenEleEta->GetMaximum())
4922                 haxiseta->SetMaximum(fhGenPi0Eta->GetMaximum());
4923         else if(fhGenGamEta->GetMaximum() >= fhGenPi0Eta->GetMaximum() && fhGenGamEta->GetMaximum() >= fhGenEtaEta->GetMaximum() && 
4924                         fhGenGamEta->GetMaximum() >= fhGenOmegaEta->GetMaximum() && fhGenGamEta->GetMaximum() >= fhGenEleEta->GetMaximum())
4925                 haxiseta->SetMaximum(fhGenGamEta->GetMaximum());
4926         else if(fhGenEtaEta->GetMaximum() >= fhGenPi0Eta->GetMaximum() && fhGenEtaEta->GetMaximum() >= fhGenGamEta->GetMaximum() && 
4927                         fhGenEtaEta->GetMaximum() >= fhGenOmegaEta->GetMaximum() && fhGenEtaEta->GetMaximum() >= fhGenEleEta->GetMaximum())
4928                 haxiseta->SetMaximum(fhGenEtaEta->GetMaximum());        
4929         else if(fhGenOmegaEta->GetMaximum() >= fhGenPi0Eta->GetMaximum() && fhGenOmegaEta->GetMaximum() >= fhGenEtaEta->GetMaximum() && 
4930                         fhGenOmegaEta->GetMaximum() >= fhGenGamEta->GetMaximum() && fhGenOmegaEta->GetMaximum() >= fhGenEleEta->GetMaximum())
4931                 haxiseta->SetMaximum(fhGenOmegaEta->GetMaximum());
4932         else if(fhGenEleEta->GetMaximum() >= fhGenPi0Eta->GetMaximum() && fhGenEleEta->GetMaximum() >= fhGenEtaEta->GetMaximum() && 
4933                         fhGenEleEta->GetMaximum() >= fhGenOmegaEta->GetMaximum() && fhGenEleEta->GetMaximum() >= fhGenGamEta->GetMaximum())
4934                 haxiseta->SetMaximum(fhGenEleEta->GetMaximum());
4935         haxiseta->SetMinimum(100);
4936         haxiseta->Draw("axis");
4937         fhGenPi0Eta->Draw("same");
4938         fhGenGamEta->Draw("same");
4939         fhGenEtaEta->Draw("same");
4940         fhGenOmegaEta->Draw("same");
4941         fhGenEleEta->Draw("same");
4942         
4943         
4944         c10->cd(3) ; 
4945         gPad->SetLogy();
4946         TH1F * haxisphi  = (TH1F*) fhGenPi0Phi->Clone(Form("%s_axisphi",fhGenPi0Phi->GetName()));  
4947         haxisphi->SetTitle("Generated Particles #phi, |#eta| < 1");
4948         fhGenPi0Phi->SetLineColor(1);
4949         fhGenGamPhi->SetLineColor(4);
4950         fhGenEtaPhi->SetLineColor(2);
4951         fhGenOmegaPhi->SetLineColor(7);
4952         fhGenElePhi->SetLineColor(6);
4953         //Select the maximum of the histogram to show all lines.
4954         if(fhGenPi0Phi->GetMaximum() >= fhGenGamPhi->GetMaximum() && fhGenPi0Phi->GetMaximum() >= fhGenEtaPhi->GetMaximum() && 
4955            fhGenPi0Phi->GetMaximum() >= fhGenOmegaPhi->GetMaximum() && fhGenPi0Phi->GetMaximum() >= fhGenElePhi->GetMaximum())
4956                 haxisphi->SetMaximum(fhGenPi0Phi->GetMaximum());
4957         else if(fhGenGamPhi->GetMaximum() >= fhGenPi0Phi->GetMaximum() && fhGenGamPhi->GetMaximum() >= fhGenEtaPhi->GetMaximum() && 
4958                         fhGenGamPhi->GetMaximum() >= fhGenOmegaPhi->GetMaximum() && fhGenGamPhi->GetMaximum() >= fhGenElePhi->GetMaximum())
4959                 haxisphi->SetMaximum(fhGenGamPhi->GetMaximum());
4960         else if(fhGenEtaPhi->GetMaximum() >= fhGenPi0Phi->GetMaximum() && fhGenEtaPhi->GetMaximum() >= fhGenGamPhi->GetMaximum() && 
4961                         fhGenEtaPhi->GetMaximum() >= fhGenOmegaPhi->GetMaximum() && fhGenEtaPhi->GetMaximum() >= fhGenElePhi->GetMaximum())
4962                 haxisphi->SetMaximum(fhGenEtaPhi->GetMaximum());        
4963         else if(fhGenOmegaPhi->GetMaximum() >= fhGenPi0Phi->GetMaximum() && fhGenOmegaPhi->GetMaximum() >= fhGenEtaPhi->GetMaximum() && 
4964                         fhGenOmegaPhi->GetMaximum() >= fhGenGamPhi->GetMaximum() && fhGenOmegaPhi->GetMaximum() >= fhGenElePhi->GetMaximum())
4965                 haxisphi->SetMaximum(fhGenOmegaPhi->GetMaximum());
4966         else if(fhGenElePhi->GetMaximum() >= fhGenPi0Phi->GetMaximum() && fhGenElePhi->GetMaximum() >= fhGenEtaPhi->GetMaximum() && 
4967                         fhGenElePhi->GetMaximum() >= fhGenOmegaPhi->GetMaximum() && fhGenElePhi->GetMaximum() >= fhGenGamPhi->GetMaximum())
4968                 haxisphi->SetMaximum(fhGenElePhi->GetMaximum());
4969         haxisphi->SetMinimum(100);
4970         haxisphi->Draw("axis");
4971         fhGenPi0Phi->Draw("same");
4972         fhGenGamPhi->Draw("same");
4973         fhGenEtaPhi->Draw("same");
4974         fhGenOmegaPhi->Draw("same");
4975         fhGenElePhi->Draw("same");
4976         
4977         sprintf(name,"QA_%s_GeneratedDistributions.eps",fCalorimeter.Data());
4978         c10->Print(name); printf("Plot: %s\n",name);
4979         
4980         
4981         //Reconstructed clusters depending on its original particle.
4982         //printf("c1\n");
4983         sprintf(cname,"QA_%s_recgenid",fCalorimeter.Data());
4984         TCanvas  * c11 = new TCanvas(cname, "Reconstructed particles, function of their original particle ID", 400, 400) ;
4985         c11->Divide(2, 2);
4986         
4987         
4988         c11->cd(1) ; 
4989         gPad->SetLogy();
4990         TH1F * hGamE   = (TH1F*) fhGamE->ProjectionX(Form("%s_px",fhGamE->GetName()),-1,-1);
4991         TH1F * hPi0E   = (TH1F*) fhPi0E->ProjectionX(Form("%s_px",fhPi0E->GetName()),-1,-1);
4992         TH1F * hEleE   = (TH1F*) fhEleE->ProjectionX(Form("%s_px",fhEleE->GetName()),-1,-1);
4993         TH1F * hNeHadE = (TH1F*) fhNeHadE->ProjectionX(Form("%s_px",fhNeHadE->GetName()),-1,-1);
4994         TH1F * hChHadE = (TH1F*) fhChHadE->ProjectionX(Form("%s_px",fhChHadE->GetName()),-1,-1);
4995         TH1F * haxisE  = (TH1F*) hPi0E->Clone(Form("%s_axisE",fhPi0E->GetName()));  
4996         haxisE->SetTitle("Reconstructed particles E, function of their original particle ID");
4997         hPi0E->SetLineColor(1);
4998         hGamE->SetLineColor(4);
4999         hNeHadE->SetLineColor(2);
5000         hChHadE->SetLineColor(7);
5001         hEleE->SetLineColor(6);
5002         
5003         //Select the maximum of the histogram to show all lines.
5004         if(hPi0E->GetMaximum() >= hGamE->GetMaximum() && hPi0E->GetMaximum() >= hNeHadE->GetMaximum() && 
5005            hPi0E->GetMaximum() >= hChHadE->GetMaximum() && hPi0E->GetMaximum() >= hEleE->GetMaximum())
5006                 haxisE->SetMaximum(hPi0E->GetMaximum());
5007         else if(hGamE->GetMaximum() >= hPi0E->GetMaximum() && hGamE->GetMaximum() >= hNeHadE->GetMaximum() && 
5008                         hGamE->GetMaximum() >= hChHadE->GetMaximum() && hGamE->GetMaximum() >= hEleE->GetMaximum())
5009                 haxisE->SetMaximum(hGamE->GetMaximum());
5010         else if(hNeHadE->GetMaximum() >= hPi0E->GetMaximum() && hNeHadE->GetMaximum() >= hGamE->GetMaximum() && 
5011                         hNeHadE->GetMaximum() >= hChHadE->GetMaximum() && hNeHadE->GetMaximum() >= hEleE->GetMaximum())
5012                 haxisE->SetMaximum(hNeHadE->GetMaximum());      
5013         else if(hChHadE->GetMaximum() >= hPi0E->GetMaximum() && hChHadE->GetMaximum() >= hNeHadE->GetMaximum() && 
5014                         hChHadE->GetMaximum() >= hGamE->GetMaximum() && hChHadE->GetMaximum() >= hEleE->GetMaximum())
5015                 haxisE->SetMaximum(hChHadE->GetMaximum());
5016         else if(hEleE->GetMaximum() >= hPi0E->GetMaximum() && hEleE->GetMaximum() >= hNeHadE->GetMaximum() && 
5017                         hEleE->GetMaximum() >= hChHadE->GetMaximum() && hEleE->GetMaximum() >= hGamE->GetMaximum())
5018                 haxisE->SetMaximum(hEleE->GetMaximum());
5019         haxisE->SetXTitle("E (GeV)");
5020         haxisE->SetMinimum(1);
5021         haxisE->Draw("axis");
5022         hPi0E->Draw("same");
5023         hGamE->Draw("same");
5024         hNeHadE->Draw("same");
5025         hChHadE->Draw("same");
5026         hEleE->Draw("same");
5027         
5028         TLegend pLegend2(0.8,0.65,0.95,0.93);
5029         pLegend2.SetTextSize(0.06);
5030         pLegend2.AddEntry(hPi0E,"  #pi^{0}","L");
5031         pLegend2.AddEntry(hGamE,"  #gamma","L");
5032         pLegend2.AddEntry(hEleE,"  e^{#pm}","L");
5033         pLegend2.AddEntry(hChHadE,"  h^{#pm}","L");
5034         pLegend2.AddEntry(hNeHadE,"  h^{0}","L");
5035         pLegend2.SetFillColor(10);
5036         pLegend2.SetBorderSize(1);
5037         pLegend2.Draw();
5038         
5039         
5040         c11->cd(2) ; 
5041         gPad->SetLogy();
5042         //printf("%s, %s, %s, %s, %s\n",fhGamPt->GetName(),fhPi0Pt->GetName(),fhElePt->GetName(),fhNeHadPt->GetName(), fhChHadPt->GetName());
5043         TH1F * hGamPt   = (TH1F*) fhGamPt->ProjectionX(Form("%s_px",fhGamPt->GetName()),-1,-1);
5044         TH1F * hPi0Pt   = (TH1F*) fhPi0Pt->ProjectionX(Form("%s_px",fhPi0Pt->GetName()),-1,-1);
5045         TH1F * hElePt   = (TH1F*) fhElePt->ProjectionX(Form("%s_px",fhElePt->GetName()),-1,-1);
5046         TH1F * hNeHadPt = (TH1F*) fhNeHadPt->ProjectionX(Form("%s_px",fhNeHadPt->GetName()),-1,-1);
5047         TH1F * hChHadPt = (TH1F*) fhChHadPt->ProjectionX(Form("%s_px",fhChHadPt->GetName()),-1,-1);
5048         haxispt  = (TH1F*) hPi0Pt->Clone(Form("%s_axisPt",fhPi0Pt->GetName()));  
5049         haxispt->SetTitle("Reconstructed particles p_{T}, function of their original particle ID");
5050         hPi0Pt->SetLineColor(1);
5051         hGamPt->SetLineColor(4);
5052         hNeHadPt->SetLineColor(2);
5053         hChHadPt->SetLineColor(7);
5054         hElePt->SetLineColor(6);
5055         
5056         //Select the maximum of the histogram to show all lines.
5057         if(hPi0Pt->GetMaximum() >= hGamPt->GetMaximum() && hPi0Pt->GetMaximum() >= hNeHadPt->GetMaximum() && 
5058            hPi0Pt->GetMaximum() >= hChHadPt->GetMaximum() && hPi0Pt->GetMaximum() >= hElePt->GetMaximum())
5059                 haxispt->SetMaximum(hPi0Pt->GetMaximum());
5060         else if(hGamPt->GetMaximum() >= hPi0Pt->GetMaximum() && hGamPt->GetMaximum() >= hNeHadPt->GetMaximum() && 
5061                         hGamPt->GetMaximum() >= hChHadPt->GetMaximum() && hGamPt->GetMaximum() >= hElePt->GetMaximum())
5062                 haxispt->SetMaximum(hGamPt->GetMaximum());
5063         else if(hNeHadPt->GetMaximum() >= hPi0Pt->GetMaximum() && hNeHadPt->GetMaximum() >= hGamPt->GetMaximum() && 
5064                         hNeHadPt->GetMaximum() >= hChHadPt->GetMaximum() && hNeHadPt->GetMaximum() >= hElePt->GetMaximum())
5065                 haxispt->SetMaximum(hNeHadPt->GetMaximum());    
5066         else if(hChHadPt->GetMaximum() >= hPi0Pt->GetMaximum() && hChHadPt->GetMaximum() >= hNeHadPt->GetMaximum() && 
5067                         hChHadPt->GetMaximum() >= hGamPt->GetMaximum() && hChHadPt->GetMaximum() >= hElePt->GetMaximum())
5068                 haxispt->SetMaximum(hChHadPt->GetMaximum());
5069         else if(hElePt->GetMaximum() >= hPi0Pt->GetMaximum() && hElePt->GetMaximum() >= hNeHadPt->GetMaximum() && 
5070                         hElePt->GetMaximum() >= hChHadPt->GetMaximum() && hElePt->GetMaximum() >= hGamPt->GetMaximum())
5071                 haxispt->SetMaximum(hElePt->GetMaximum());
5072         haxispt->SetXTitle("p_{T} (GeV/c)");
5073         haxispt->SetMinimum(1);
5074         haxispt->Draw("axis");
5075         hPi0Pt->Draw("same");
5076         hGamPt->Draw("same");
5077         hNeHadPt->Draw("same");
5078         hChHadPt->Draw("same");
5079         hElePt->Draw("same");
5080         
5081         c11->cd(3) ;
5082         gPad->SetLogy();
5083         
5084         TH1F * hGamEta   = (TH1F*) fhGamEta->ProjectionX(Form("%s_px",fhGamEta->GetName()),-1,-1);
5085         TH1F * hPi0Eta   = (TH1F*) fhPi0Eta->ProjectionX(Form("%s_px",fhPi0Eta->GetName()),-1,-1);
5086         TH1F * hEleEta   = (TH1F*) fhEleEta->ProjectionX(Form("%s_px",fhEleEta->GetName()),-1,-1);
5087         TH1F * hNeHadEta = (TH1F*) fhNeHadEta->ProjectionX(Form("%s_px",fhNeHadEta->GetName()),-1,-1);
5088         TH1F * hChHadEta = (TH1F*) fhChHadEta->ProjectionX(Form("%s_px",fhChHadEta->GetName()),-1,-1);
5089         haxiseta  = (TH1F*) hPi0Eta->Clone(Form("%s_axisEta",fhPi0Eta->GetName()));  
5090         haxiseta->SetTitle("Reconstructed particles #eta, function of their original particle ID");
5091         hPi0Eta->SetLineColor(1);
5092         hGamEta->SetLineColor(4);
5093         hNeHadEta->SetLineColor(2);
5094         hChHadEta->SetLineColor(7);
5095         hEleEta->SetLineColor(6);
5096         //Select the maximum of the histogram to show all lines.
5097         if(hPi0Eta->GetMaximum() >= hGamEta->GetMaximum() && hPi0Eta->GetMaximum() >= hNeHadEta->GetMaximum() && 
5098            hPi0Eta->GetMaximum() >= hChHadEta->GetMaximum() && hPi0Eta->GetMaximum() >= hEleEta->GetMaximum())
5099                 haxiseta->SetMaximum(hPi0Eta->GetMaximum());
5100         else if(hGamEta->GetMaximum() >= hPi0Eta->GetMaximum() && hGamEta->GetMaximum() >= hNeHadEta->GetMaximum() && 
5101                         hGamEta->GetMaximum() >= hChHadEta->GetMaximum() && hGamEta->GetMaximum() >= hEleEta->GetMaximum())
5102                 haxiseta->SetMaximum(hGamEta->GetMaximum());
5103         else if(hNeHadEta->GetMaximum() >= hPi0Eta->GetMaximum() && hNeHadEta->GetMaximum() >= hGamEta->GetMaximum() && 
5104                         hNeHadEta->GetMaximum() >= hChHadEta->GetMaximum() && hNeHadEta->GetMaximum() >= hEleEta->GetMaximum())
5105                 haxiseta->SetMaximum(hNeHadEta->GetMaximum());  
5106         else if(hChHadEta->GetMaximum() >= hPi0Eta->GetMaximum() && hChHadEta->GetMaximum() >= hNeHadEta->GetMaximum() && 
5107                         hChHadEta->GetMaximum() >= hGamEta->GetMaximum() && hChHadEta->GetMaximum() >= hEleEta->GetMaximum())
5108                 haxiseta->SetMaximum(hChHadEta->GetMaximum());
5109         else if(hEleEta->GetMaximum() >= hPi0Eta->GetMaximum() && hEleEta->GetMaximum() >= hNeHadEta->GetMaximum() && 
5110                         hEleEta->GetMaximum() >= hChHadEta->GetMaximum() && hEleEta->GetMaximum() >= hGamEta->GetMaximum())
5111                 haxiseta->SetMaximum(hEleEta->GetMaximum());
5112         
5113         haxiseta->SetXTitle("#eta");
5114         haxiseta->Draw("axis");
5115         hPi0Eta->Draw("same");
5116         hGamEta->Draw("same");
5117         hNeHadEta->Draw("same");
5118         hChHadEta->Draw("same");
5119         hEleEta->Draw("same");
5120         
5121         
5122         c11->cd(4) ; 
5123         gPad->SetLogy();
5124         TH1F * hGamPhi   = (TH1F*) fhGamPhi->ProjectionX(Form("%s_px",fhGamPhi->GetName()),-1,-1);
5125         TH1F * hPi0Phi   = (TH1F*) fhPi0Phi->ProjectionX(Form("%s_px",fhPi0Phi->GetName()),-1,-1);
5126         TH1F * hElePhi   = (TH1F*) fhElePhi->ProjectionX(Form("%s_px",fhElePhi->GetName()),-1,-1);
5127         TH1F * hNeHadPhi = (TH1F*) fhNeHadPhi->ProjectionX(Form("%s_px",fhNeHadPhi->GetName()),-1,-1);
5128         TH1F * hChHadPhi = (TH1F*) fhChHadPhi->ProjectionX(Form("%s_px",fhChHadPhi->GetName()),-1,-1);
5129         haxisphi  = (TH1F*) hPi0Phi->Clone(Form("%s_axisPhi",fhPi0Phi->GetName()));  
5130         haxisphi->SetTitle("Reconstructed particles #phi, function of their original particle ID");
5131         
5132         hPi0Phi->SetLineColor(1);
5133         hGamPhi->SetLineColor(4);
5134         hNeHadPhi->SetLineColor(2);
5135         hChHadPhi->SetLineColor(7);
5136         hElePhi->SetLineColor(6);
5137         //Select the maximum of the histogram to show all lines.
5138         if(hPi0Phi->GetMaximum() >= hGamPhi->GetMaximum() && hPi0Phi->GetMaximum() >= hNeHadPhi->GetMaximum() && 
5139            hPi0Phi->GetMaximum() >= hChHadPhi->GetMaximum() && hPi0Phi->GetMaximum() >= hElePhi->GetMaximum())
5140                 haxisphi->SetMaximum(hPi0Phi->GetMaximum());
5141         else if(hGamPhi->GetMaximum() >= hPi0Phi->GetMaximum() && hGamPhi->GetMaximum() >= hNeHadPhi->GetMaximum() && 
5142                         hGamPhi->GetMaximum() >= hChHadPhi->GetMaximum() && hGamPhi->GetMaximum() >= hElePhi->GetMaximum())
5143                 haxisphi->SetMaximum(hGamPhi->GetMaximum());
5144         else if(hNeHadPhi->GetMaximum() >= hPi0Phi->GetMaximum() && hNeHadPhi->GetMaximum() >= hGamPhi->GetMaximum() && 
5145                         hNeHadPhi->GetMaximum() >= hChHadPhi->GetMaximum() && hNeHadPhi->GetMaximum() >= hElePhi->GetMaximum())
5146                 haxisphi->SetMaximum(hNeHadPhi->GetMaximum());  
5147         else if(hChHadPhi->GetMaximum() >= hPi0Phi->GetMaximum() && hChHadPhi->GetMaximum() >= hNeHadPhi->GetMaximum() && 
5148                         hChHadPhi->GetMaximum() >= hGamPhi->GetMaximum() && hChHadPhi->GetMaximum() >= hElePhi->GetMaximum())
5149                 haxisphi->SetMaximum(hChHadPhi->GetMaximum());
5150         else if(hElePhi->GetMaximum() >= hPi0Phi->GetMaximum() && hElePhi->GetMaximum() >= hNeHadPhi->GetMaximum() && 
5151                         hElePhi->GetMaximum() >= hChHadPhi->GetMaximum() && hElePhi->GetMaximum() >= hGamPhi->GetMaximum())
5152         haxisphi->SetMaximum(hElePhi->GetMaximum());
5153         haxisphi->SetXTitle("#phi (rad)");
5154         haxisphi->Draw("axis");
5155         hPi0Phi->Draw("same");
5156         hGamPhi->Draw("same");
5157         hNeHadPhi->Draw("same");
5158         hChHadPhi->Draw("same");
5159         hElePhi->Draw("same");
5160         
5161         sprintf(name,"QA_%s_RecDistributionsGenID.eps",fCalorimeter.Data());
5162         c11->Print(name); printf("Plot: %s\n",name);
5163         
5164         
5165         //Ratio reconstructed clusters / generated particles in acceptance, for different particle ID
5166         //printf("c1\n");
5167         
5168         TH1F *  hPi0EClone   = (TH1F*)   hPi0E  ->Clone(Form("%s_Clone",fhPi0E->GetName()));
5169         TH1F *  hGamEClone   = (TH1F*)   hGamE  ->Clone(Form("%s_Clone",fhGamE->GetName()));
5170         TH1F *  hPi0PtClone  = (TH1F*)   hPi0Pt ->Clone(Form("%s_Clone",fhPi0Pt->GetName()));
5171         TH1F *  hGamPtClone  = (TH1F*)   hGamPt ->Clone(Form("%s_Clone",fhGamPt->GetName()));   
5172         TH1F *  hPi0EtaClone = (TH1F*)   hPi0Eta->Clone(Form("%s_Clone",fhPi0Eta->GetName()));
5173         TH1F *  hGamEtaClone = (TH1F*)   hGamEta->Clone(Form("%s_Clone",fhGamEta->GetName()));  
5174         TH1F *  hPi0PhiClone = (TH1F*)   hPi0Phi->Clone(Form("%s_Clone",fhPi0Phi->GetName()));
5175         TH1F *  hGamPhiClone = (TH1F*)   hGamPhi->Clone(Form("%s_Clone",fhGamPhi->GetName()));  
5176         
5177         sprintf(cname,"QA_%s_recgenidratio",fCalorimeter.Data());
5178         TCanvas  * c12 = new TCanvas(cname, "Ratio reconstructed clusters / generated particles in acceptance, for different particle ID", 400, 400) ;
5179         c12->Divide(2, 2);
5180         
5181         c12->cd(1) ; 
5182         gPad->SetLogy();
5183         haxisE->SetTitle("Ratio reconstructed clusters / generated particles in acceptance, for different particle ID");
5184         hPi0EClone->Divide(fhGenPi0AccE);
5185         hGamEClone->Divide(fhGenGamAccE);
5186         haxisE->SetMaximum(5);
5187         haxisE->SetMinimum(1e-2);
5188         haxisE->SetXTitle("E (GeV)");
5189         haxisE->SetYTitle("ratio = rec/gen");
5190         haxisE->Draw("axis");
5191         hPi0E->Draw("same");
5192         hGamE->Draw("same");
5193         
5194         TLegend pLegend3(0.75,0.2,0.9,0.4);
5195         pLegend3.SetTextSize(0.06);
5196         pLegend3.AddEntry(hPi0EClone,"  #pi^{0}","L");
5197         pLegend3.AddEntry(hGamEClone,"  #gamma","L");
5198         pLegend3.SetFillColor(10);
5199         pLegend3.SetBorderSize(1);
5200         pLegend3.Draw();
5201         
5202         c12->cd(2) ; 
5203         gPad->SetLogy();
5204         haxispt->SetTitle("Ratio reconstructed clusters / generated particles in acceptance, for different particle ID");
5205         hPi0PtClone->Divide(fhGenPi0AccPt);
5206         hGamPtClone->Divide(fhGenGamAccPt);
5207         haxispt->SetMaximum(5);
5208         haxispt->SetMinimum(1e-2);
5209         haxispt->SetXTitle("p_{T} (GeV/c)");
5210         haxispt->SetYTitle("ratio = rec/gen");
5211         haxispt->Draw("axis");
5212         hPi0PtClone->Draw("same");
5213         hGamPtClone->Draw("same");
5214         
5215         c12->cd(3) ;
5216         gPad->SetLogy();
5217         
5218         haxiseta->SetTitle("Ratio reconstructed clusters / generated particles in acceptance, for different particle ID");
5219         hPi0EtaClone->Divide(fhGenPi0AccEta);
5220         hGamEtaClone->Divide(fhGenGamAccEta);
5221         haxiseta->SetMaximum(1.2);
5222         haxiseta->SetMinimum(1e-2);
5223         haxiseta->SetYTitle("ratio = rec/gen");
5224         haxiseta->SetXTitle("#eta");
5225         haxiseta->Draw("axis");
5226         hPi0EtaClone->Draw("same");
5227         hGamEtaClone->Draw("same");
5228         
5229         
5230         c12->cd(4) ; 
5231         gPad->SetLogy();
5232         haxisphi->SetTitle("Ratio reconstructed clusters / generated particles in acceptance, for different particle ID");
5233         hPi0PhiClone->Divide(fhGenPi0AccPhi);
5234         hGamPhiClone->Divide(fhGenGamAccPhi);
5235         haxisphi->SetYTitle("ratio = rec/gen");
5236         haxisphi->SetXTitle("#phi (rad)");
5237         haxisphi->SetMaximum(1.2);
5238         haxisphi->SetMinimum(1e-2);
5239         haxisphi->Draw("axis");
5240         hPi0PhiClone->Draw("same");
5241         hGamPhiClone->Draw("same");
5242         
5243         sprintf(name,"QA_%s_EfficiencyGenID.eps",fCalorimeter.Data());
5244         c12->Print(name); printf("Plot: %s\n",name);
5245         
5246         
5247         
5248         //Reconstructed distributions
5249         //printf("c1\n");
5250         sprintf(cname,"QA_%s_vertex",fCalorimeter.Data());
5251         TCanvas  * c13 = new TCanvas(cname, "Particle vertex", 400, 400) ;
5252         c13->Divide(2, 2);
5253         
5254         c13->cd(1) ; 
5255         //gPad->SetLogy();
5256         fhEMVxyz->SetTitleOffset(1.6,"Y");
5257         fhEMVxyz->Draw();
5258         
5259         c13->cd(2) ; 
5260         //gPad->SetLogy();
5261         fhHaVxyz->SetTitleOffset(1.6,"Y");
5262         fhHaVxyz->Draw();
5263         
5264         c13->cd(3) ;
5265         gPad->SetLogy();
5266         TH1F * hEMR = (TH1F*) fhEMR->ProjectionY(Form("%s_py",fhEMR->GetName()),-1,-1); 
5267         hEMR->SetLineColor(4);
5268         hEMR->Draw();
5269         
5270         c13->cd(4) ; 
5271         gPad->SetLogy();
5272         TH1F * hHaR = (TH1F*) fhHaR->ProjectionY(Form("%s_py",fhHaR->GetName()),-1,-1); 
5273         hHaR->SetLineColor(4);
5274         hHaR->Draw();
5275         
5276         
5277         sprintf(name,"QA_%s_ParticleVertex.eps",fCalorimeter.Data());
5278         c13->Print(name); printf("Plot: %s\n",name);
5279         
5280         
5281         //Track-matching distributions
5282
5283         //Reconstructed distributions, matched with tracks, generated particle dependence
5284         //printf("c2\n");
5285         sprintf(cname,"QA_%s_rectrackmatchGenID",fCalorimeter.Data());
5286         TCanvas  * c22ch = new TCanvas(cname, "Reconstructed distributions, matched with tracks, for different particle ID", 400, 400) ;
5287         c22ch->Divide(2, 2);
5288         
5289         c22ch->cd(1) ; 
5290         
5291         TH1F * hGamECharged   = (TH1F*) fhGamECharged->ProjectionX(Form("%s_px",fhGamECharged->GetName()),-1,-1);
5292         TH1F * hPi0ECharged   = (TH1F*) fhPi0ECharged->ProjectionX(Form("%s_px",fhPi0ECharged->GetName()),-1,-1);
5293         TH1F * hEleECharged   = (TH1F*) fhEleECharged->ProjectionX(Form("%s_px",fhEleECharged->GetName()),-1,-1);
5294         TH1F * hNeHadECharged = (TH1F*) fhNeHadECharged->ProjectionX(Form("%s_px",fhNeHadECharged->GetName()),-1,-1);
5295         TH1F * hChHadECharged = (TH1F*) fhChHadECharged->ProjectionX(Form("%s_px",fhChHadECharged->GetName()),-1,-1);
5296         hPi0ECharged->SetLineColor(1);
5297         hGamECharged->SetLineColor(4);
5298         hNeHadECharged->SetLineColor(2);
5299         hChHadECharged->SetLineColor(7);
5300         hEleECharged->SetLineColor(6);  
5301         gPad->SetLogy();
5302         fhECharged->SetLineColor(3);
5303         fhECharged->SetMinimum(0.5);
5304         fhECharged->Draw();
5305         hPi0ECharged->Draw("same");
5306         hGamECharged->Draw("same");
5307         hNeHadECharged->Draw("same");
5308         hChHadECharged->Draw("same");
5309         hEleECharged->Draw("same");
5310         TLegend pLegend22(0.75,0.45,0.9,0.8);
5311         pLegend22.SetTextSize(0.06);
5312         pLegend22.AddEntry(fhECharged,"all","L");
5313         pLegend22.AddEntry(hPi0ECharged,"#pi^{0}","L");
5314         pLegend22.AddEntry(hGamECharged,"#gamma","L");
5315         pLegend22.AddEntry(hEleECharged,"e^{#pm}","L");
5316         pLegend22.AddEntry(hChHadECharged,"h^{#pm}","L");
5317         pLegend22.AddEntry(hNeHadECharged,"h^{0}","L");
5318         pLegend22.SetFillColor(10);
5319         pLegend22.SetBorderSize(1);
5320         pLegend22.Draw();
5321         
5322         c22ch->cd(2) ; 
5323         
5324         TH1F * hGamPtCharged   = (TH1F*) fhGamPtCharged->ProjectionX(Form("%s_px",fhGamPtCharged->GetName()),-1,-1);
5325         TH1F * hPi0PtCharged   = (TH1F*) fhPi0PtCharged->ProjectionX(Form("%s_px",fhPi0PtCharged->GetName()),-1,-1);
5326         TH1F * hElePtCharged   = (TH1F*) fhElePtCharged->ProjectionX(Form("%s_px",fhElePtCharged->GetName()),-1,-1);
5327         TH1F * hNeHadPtCharged = (TH1F*) fhNeHadPtCharged->ProjectionX(Form("%s_px",fhNeHadPtCharged->GetName()),-1,-1);
5328         TH1F * hChHadPtCharged = (TH1F*) fhChHadPtCharged->ProjectionX(Form("%s_px",fhChHadPtCharged->GetName()),-1,-1);
5329         hPi0PtCharged->SetLineColor(1);
5330         hGamPtCharged->SetLineColor(4);
5331         hNeHadPtCharged->SetLineColor(2);
5332         hChHadPtCharged->SetLineColor(7);
5333         hElePtCharged->SetLineColor(6); 
5334         gPad->SetLogy();
5335         fhPtCharged->SetLineColor(3);
5336         fhPtCharged->SetMinimum(0.5);
5337         fhPtCharged->Draw();
5338         hPi0PtCharged->Draw("same");
5339         hGamPtCharged->Draw("same");
5340         hNeHadPtCharged->Draw("same");
5341         hChHadPtCharged->Draw("same");
5342         hElePtCharged->Draw("same");    
5343         
5344         c22ch->cd(4) ; 
5345         
5346         TH1F * hGamEtaCharged   = (TH1F*) fhGamEtaCharged->ProjectionX(Form("%s_px",fhGamEtaCharged->GetName()),-1,-1);
5347         TH1F * hPi0EtaCharged   = (TH1F*) fhPi0EtaCharged->ProjectionX(Form("%s_px",fhPi0EtaCharged->GetName()),-1,-1);
5348         TH1F * hEleEtaCharged   = (TH1F*) fhEleEtaCharged->ProjectionX(Form("%s_px",fhEleEtaCharged->GetName()),-1,-1);
5349         TH1F * hNeHadEtaCharged = (TH1F*) fhNeHadEtaCharged->ProjectionX(Form("%s_px",fhNeHadEtaCharged->GetName()),-1,-1);
5350         TH1F * hChHadEtaCharged = (TH1F*) fhChHadEtaCharged->ProjectionX(Form("%s_px",fhChHadEtaCharged->GetName()),-1,-1);
5351         hPi0EtaCharged->SetLineColor(1);
5352         hGamEtaCharged->SetLineColor(4);
5353         hNeHadEtaCharged->SetLineColor(2);
5354         hChHadEtaCharged->SetLineColor(7);
5355         hEleEtaCharged->SetLineColor(6);        
5356         gPad->SetLogy();
5357         fhEtaCharged->SetLineColor(3);
5358         fhEtaCharged->SetMinimum(0.5);
5359         fhEtaCharged->Draw();
5360         hPi0EtaCharged->Draw("same");
5361         hGamEtaCharged->Draw("same");
5362         hNeHadEtaCharged->Draw("same");
5363         hChHadEtaCharged->Draw("same");
5364         hEleEtaCharged->Draw("same");
5365         
5366         c22ch->cd(3) ; 
5367         
5368         TH1F * hGamPhiCharged   = (TH1F*) fhGamPhiCharged->ProjectionX(Form("%s_px",fhGamPhiCharged->GetName()),-1,-1);
5369         TH1F * hPi0PhiCharged   = (TH1F*) fhPi0PhiCharged->ProjectionX(Form("%s_px",fhPi0PhiCharged->GetName()),-1,-1);
5370         TH1F * hElePhiCharged   = (TH1F*) fhElePhiCharged->ProjectionX(Form("%s_px",fhElePhiCharged->GetName()),-1,-1);
5371         TH1F * hNeHadPhiCharged = (TH1F*) fhNeHadPhiCharged->ProjectionX(Form("%s_px",fhNeHadPhiCharged->GetName()),-1,-1);
5372         TH1F * hChHadPhiCharged = (TH1F*) fhChHadPhiCharged->ProjectionX(Form("%s_px",fhChHadPhiCharged->GetName()),-1,-1);
5373         hPi0PhiCharged->SetLineColor(1);
5374         hGamPhiCharged->SetLineColor(4);
5375         hNeHadPhiCharged->SetLineColor(2);
5376         hChHadPhiCharged->SetLineColor(7);
5377         hElePhiCharged->SetLineColor(6);        
5378         gPad->SetLogy();
5379         fhPhiCharged->SetLineColor(3);
5380         fhPhiCharged->SetMinimum(0.5);
5381         fhPhiCharged->Draw();
5382         hPi0PhiCharged->Draw("same");
5383         hGamPhiCharged->Draw("same");
5384         hNeHadPhiCharged->Draw("same");
5385         hChHadPhiCharged->Draw("same");
5386         hElePhiCharged->Draw("same");
5387         
5388         
5389         sprintf(name,"QA_%s_ReconstructedDistributions_TrackMatchedGenID.eps",fCalorimeter.Data());
5390         c22ch->Print(name); printf("Plot: %s\n",name);
5391         
5392         TH1F *  hGamEChargedClone   = (TH1F*)   hGamECharged->Clone(Form("%s_Clone",fhGamECharged->GetName()));
5393         TH1F *  hGamPtChargedClone  = (TH1F*)   hGamPtCharged->Clone(Form("%s_Clone",fhGamPtCharged->GetName()));
5394         TH1F *  hGamEtaChargedClone = (TH1F*)   hGamEtaCharged->Clone(Form("%s_Clone",fhGamEtaCharged->GetName()));
5395         TH1F *  hGamPhiChargedClone = (TH1F*)   hGamPhiCharged->Clone(Form("%s_Clone",fhGamPhiCharged->GetName()));
5396         
5397         TH1F *  hPi0EChargedClone   = (TH1F*)   hPi0ECharged->Clone(Form("%s_Clone",fhPi0ECharged->GetName()));
5398         TH1F *  hPi0PtChargedClone  = (TH1F*)   hPi0PtCharged->Clone(Form("%s_Clone",fhPi0PtCharged->GetName()));
5399         TH1F *  hPi0EtaChargedClone = (TH1F*)   hPi0EtaCharged->Clone(Form("%s_Clone",fhPi0EtaCharged->GetName()));
5400         TH1F *  hPi0PhiChargedClone = (TH1F*)   hPi0PhiCharged->Clone(Form("%s_Clone",fhPi0PhiCharged->GetName()));
5401         
5402         TH1F *  hEleEChargedClone   = (TH1F*)   hEleECharged->Clone(Form("%s_Clone",fhEleECharged->GetName()));
5403         TH1F *  hElePtChargedClone  = (TH1F*)   hElePtCharged->Clone(Form("%s_Clone",fhElePtCharged->GetName()));
5404         TH1F *  hEleEtaChargedClone = (TH1F*)   hEleEtaCharged->Clone(Form("%s_Clone",fhEleEtaCharged->GetName()));
5405         TH1F *  hElePhiChargedClone = (TH1F*)   hElePhiCharged->Clone(Form("%s_Clone",fhElePhiCharged->GetName()));     
5406         
5407         TH1F *  hNeHadEChargedClone   = (TH1F*)   hNeHadECharged->Clone(Form("%s_Clone",fhNeHadECharged->GetName()));
5408         TH1F *  hNeHadPtChargedClone  = (TH1F*)   hNeHadPtCharged->Clone(Form("%s_Clone",fhNeHadPtCharged->GetName()));
5409         TH1F *  hNeHadEtaChargedClone = (TH1F*)   hNeHadEtaCharged->Clone(Form("%s_Clone",fhNeHadEtaCharged->GetName()));
5410         TH1F *  hNeHadPhiChargedClone = (TH1F*)   hNeHadPhiCharged->Clone(Form("%s_Clone",fhNeHadPhiCharged->GetName()));
5411         
5412         TH1F *  hChHadEChargedClone   = (TH1F*)   hChHadECharged->Clone(Form("%s_Clone",fhChHadECharged->GetName()));
5413         TH1F *  hChHadPtChargedClone  = (TH1F*)   hChHadPtCharged->Clone(Form("%s_Clone",fhChHadPtCharged->GetName()));
5414         TH1F *  hChHadEtaChargedClone = (TH1F*)   hChHadEtaCharged->Clone(Form("%s_Clone",fhChHadEtaCharged->GetName()));
5415         TH1F *  hChHadPhiChargedClone = (TH1F*)   hChHadPhiCharged->Clone(Form("%s_Clone",fhChHadPhiCharged->GetName()));       
5416         
5417         //Ratio: reconstructed track matched/ all reconstructed
5418         //printf("c3\n");
5419         sprintf(cname,"QA_%s_rectrackmatchratGenID",fCalorimeter.Data());
5420         TCanvas  * c3ch = new TCanvas(cname, "Ratio: reconstructed track matched/ all reconstructed, for different particle ID", 400, 400) ;
5421         c3ch->Divide(2, 2);
5422         
5423         c3ch->cd(1) ;
5424         hEChargedClone->SetMaximum(1.2);
5425         hEChargedClone->SetMinimum(0.001);      
5426         hEChargedClone->SetLineColor(3);
5427         hEChargedClone->SetYTitle("track matched / all");
5428         hPi0EChargedClone->Divide(hPi0E);
5429         hGamEChargedClone->Divide(hGamE);
5430         hEleEChargedClone->Divide(hEleE);
5431         hNeHadEChargedClone->Divide(hNeHadE);
5432         hChHadEChargedClone->Divide(hChHadE);
5433         hEChargedClone->Draw();
5434         hPi0EChargedClone->Draw("same");
5435         hGamEChargedClone->Draw("same");
5436         hEleEChargedClone->Draw("same");
5437         hNeHadEChargedClone->Draw("same");
5438         hChHadEChargedClone->Draw("same");
5439         
5440         TLegend pLegend3ch(0.75,0.45,0.9,0.8);
5441         pLegend3ch.SetTextSize(0.06);
5442         pLegend3ch.AddEntry(hEChargedClone,"all","L");
5443         pLegend3ch.AddEntry(hPi0EChargedClone,"#pi^{0}","L");
5444         pLegend3ch.AddEntry(hGamEChargedClone,"#gamma","L");
5445         pLegend3ch.AddEntry(hEleEChargedClone,"e^{#pm}","L");
5446         pLegend3ch.AddEntry(hChHadEChargedClone,"h^{#pm}","L");
5447         pLegend3ch.AddEntry(hNeHadEChargedClone,"h^{0}","L");
5448         pLegend3ch.SetFillColor(10);
5449         pLegend3ch.SetBorderSize(1);
5450         pLegend3ch.Draw();
5451         
5452         c3ch->cd(2) ;
5453         hPtChargedClone->SetMaximum(1.2);
5454         hPtChargedClone->SetMinimum(0.001);     
5455         hPtChargedClone->SetLineColor(3);
5456         hPtChargedClone->SetYTitle("track matched / all");
5457         hPi0PtChargedClone->Divide(hPi0Pt);
5458         hGamPtChargedClone->Divide(hGamPt);
5459         hElePtChargedClone->Divide(hElePt);
5460         hNeHadPtChargedClone->Divide(hNeHadPt);
5461         hChHadPtChargedClone->Divide(hChHadPt);
5462         hPtChargedClone->Draw();
5463         hPi0PtChargedClone->Draw("same");
5464         hGamPtChargedClone->Draw("same");
5465         hElePtChargedClone->Draw("same");
5466         hNeHadPtChargedClone->Draw("same");
5467         hChHadPtChargedClone->Draw("same");
5468         
5469         c3ch->cd(4) ;
5470         hEtaChargedClone->SetMaximum(1.2);
5471         hEtaChargedClone->SetMinimum(0.001);    
5472         hEtaChargedClone->SetLineColor(3);
5473         hEtaChargedClone->SetYTitle("track matched / all");
5474         hPi0EtaChargedClone->Divide(hPi0Eta);
5475         hGamEtaChargedClone->Divide(hGamEta);
5476         hEleEtaChargedClone->Divide(hEleEta);
5477         hNeHadEtaChargedClone->Divide(hNeHadEta);
5478         hChHadEtaChargedClone->Divide(hChHadEta);
5479         hEtaChargedClone->Draw();
5480         hPi0EtaChargedClone->Draw("same");
5481         hGamEtaChargedClone->Draw("same");
5482         hEleEtaChargedClone->Draw("same");
5483         hNeHadEtaChargedClone->Draw("same");
5484         hChHadEtaChargedClone->Draw("same");
5485         
5486         c3ch->cd(3) ;
5487         hPhiChargedClone->SetMaximum(1.2);
5488         hPhiChargedClone->SetMinimum(0.001);
5489         hPhiChargedClone->SetLineColor(3);
5490         hPhiChargedClone->SetYTitle("track matched / all");
5491         hPi0PhiChargedClone->Divide(hPi0Phi);
5492         hGamPhiChargedClone->Divide(hGamPhi);
5493         hElePhiChargedClone->Divide(hElePhi);
5494         hNeHadPhiChargedClone->Divide(hNeHadPhi);
5495         hChHadPhiChargedClone->Divide(hChHadPhi);
5496         hPhiChargedClone->Draw();
5497         hPi0PhiChargedClone->Draw("same");
5498         hGamPhiChargedClone->Draw("same");
5499         hElePhiChargedClone->Draw("same");
5500         hNeHadPhiChargedClone->Draw("same");
5501         hChHadPhiChargedClone->Draw("same");
5502         
5503         sprintf(name,"QA_%s_RatioReconstructedMatchedDistributionsGenID.eps",fCalorimeter.Data());
5504         c3ch->Print(name); printf("Plot: %s\n",name);
5505         
5506         }       
5507         //Track-matching distributions
5508                 
5509         sprintf(cname,"QA_%s_trkmatch",fCalorimeter.Data());
5510         TCanvas *cme = new TCanvas(cname,"Track-matching distributions", 400, 400);
5511         cme->Divide(2,2);
5512                 
5513         TLegend pLegendpE0(0.6,0.55,0.9,0.8);
5514         pLegendpE0.SetTextSize(0.04);
5515         pLegendpE0.AddEntry(fh1pOverE,"all","L");
5516         pLegendpE0.AddEntry(fh1pOverER02,"dR < 0.02","L");              
5517         pLegendpE0.SetFillColor(10);
5518         pLegendpE0.SetBorderSize(1);
5519         //pLegendpE0.Draw();
5520                 
5521         cme->cd(1);
5522         if(fh1pOverE->GetEntries() > 0) gPad->SetLogy();
5523         fh1pOverE->SetTitle("Track matches p/E");
5524         fh1pOverE->Draw();
5525         fh1pOverER02->SetLineColor(4);
5526         fh1pOverER02->Draw("same");
5527         pLegendpE0.Draw();
5528                 
5529         cme->cd(2);
5530         if(fh1dR->GetEntries() > 0) gPad->SetLogy();
5531         fh1dR->Draw();
5532         
5533         cme->cd(3);
5534         fh2MatchdEdx->Draw();
5535         
5536         cme->cd(4);
5537         fh2EledEdx->Draw();
5538         
5539         sprintf(name,"QA_%s_TrackMatchingEleDist.eps",fCalorimeter.Data());
5540         cme->Print(name); printf("Plot: %s\n",name);       
5541         
5542         if(IsDataMC()){
5543         sprintf(cname,"QA_%s_trkmatchMCEle",fCalorimeter.Data());
5544         TCanvas *cmemc = new TCanvas(cname,"Track-matching distributions from MC electrons", 600, 200);
5545         cmemc->Divide(3,1);
5546         
5547         cmemc->cd(1);
5548         gPad->SetLogy();
5549         fhMCEle1pOverE->Draw();
5550         fhMCEle1pOverER02->SetLineColor(4);
5551         fhMCEle1pOverE->SetLineColor(1);
5552         fhMCEle1pOverER02->Draw("same");
5553         pLegendpE0.Draw();
5554                 
5555         cmemc->cd(2);
5556         gPad->SetLogy();
5557         fhMCEle1dR->Draw();
5558                 
5559         cmemc->cd(3);
5560         fhMCEle2MatchdEdx->Draw();
5561                 
5562         sprintf(name,"QA_%s_TrackMatchingDistMCEle.eps",fCalorimeter.Data());
5563         cmemc->Print(name); printf("Plot: %s\n",name);  
5564         
5565                 
5566         sprintf(cname,"QA_%s_trkmatchMCChHad",fCalorimeter.Data());
5567         TCanvas *cmemchad = new TCanvas(cname,"Track-matching distributions from MC charged hadrons", 600, 200);
5568         cmemchad->Divide(3,1);
5569                 
5570         cmemchad->cd(1);
5571         gPad->SetLogy();
5572         fhMCChHad1pOverE->Draw();
5573         fhMCChHad1pOverER02->SetLineColor(4);
5574         fhMCChHad1pOverE->SetLineColor(1);
5575         fhMCChHad1pOverER02->Draw("same");
5576         pLegendpE0.Draw();
5577                 
5578         cmemchad->cd(2);
5579         gPad->SetLogy();
5580         fhMCChHad1dR->Draw();
5581
5582         cmemchad->cd(3);
5583         fhMCChHad2MatchdEdx->Draw();
5584                 
5585         sprintf(name,"QA_%s_TrackMatchingDistMCChHad.eps",fCalorimeter.Data());
5586         cmemchad->Print(name); printf("Plot: %s\n",name);       
5587         
5588         sprintf(cname,"QA_%s_trkmatchMCNeutral",fCalorimeter.Data());
5589         TCanvas *cmemcn = new TCanvas(cname,"Track-matching distributions from MC neutrals", 600, 200);
5590         cmemcn->Divide(3,1);
5591                 
5592         cmemcn->cd(1);
5593         gPad->SetLogy();
5594         fhMCNeutral1pOverE->Draw();
5595         fhMCNeutral1pOverE->SetLineColor(1);
5596         fhMCNeutral1pOverER02->SetLineColor(4);
5597         fhMCNeutral1pOverER02->Draw("same");
5598         pLegendpE0.Draw();
5599                 
5600         cmemcn->cd(2);
5601         gPad->SetLogy();
5602         fhMCNeutral1dR->Draw();
5603                 
5604         cmemcn->cd(3);
5605         fhMCNeutral2MatchdEdx->Draw();
5606                 
5607         sprintf(name,"QA_%s_TrackMatchingDistMCNeutral.eps",fCalorimeter.Data());
5608         cmemcn->Print(name); printf("Plot: %s\n",name);       
5609         
5610         sprintf(cname,"QA_%s_trkmatchpE",fCalorimeter.Data());
5611         TCanvas *cmpoe = new TCanvas(cname,"Track-matching distributions, p/E", 400, 200);
5612         cmpoe->Divide(2,1);
5613                 
5614         cmpoe->cd(1);
5615         gPad->SetLogy();
5616         fh1pOverE->SetLineColor(1);
5617         fhMCEle1pOverE->SetLineColor(4);
5618         fhMCChHad1pOverE->SetLineColor(2);
5619         fhMCNeutral1pOverE->SetLineColor(7);
5620         fh1pOverER02->SetMinimum(0.5);
5621         fh1pOverE->Draw();
5622         fhMCEle1pOverE->Draw("same");
5623         fhMCChHad1pOverE->Draw("same");
5624         fhMCNeutral1pOverE->Draw("same");
5625         TLegend pLegendpE(0.65,0.55,0.9,0.8);
5626         pLegendpE.SetTextSize(0.06);
5627         pLegendpE.AddEntry(fh1pOverE,"all","L");
5628         pLegendpE.AddEntry(fhMCEle1pOverE,"e^{#pm}","L");
5629         pLegendpE.AddEntry(fhMCChHad1pOverE,"h^{#pm}","L");
5630         pLegendpE.AddEntry(fhMCNeutral1pOverE,"neutrals","L");
5631         pLegendpE.SetFillColor(10);
5632         pLegendpE.SetBorderSize(1);
5633         pLegendpE.Draw();
5634         
5635         cmpoe->cd(2);
5636         gPad->SetLogy();
5637         fh1pOverER02->SetTitle("Track matches p/E, dR<0.2");
5638         fh1pOverER02->SetLineColor(1);
5639         fhMCEle1pOverER02->SetLineColor(4);
5640         fhMCChHad1pOverER02->SetLineColor(2);
5641         fhMCNeutral1pOverER02->SetLineColor(7);
5642         fh1pOverER02->SetMaximum(fh1pOverE->GetMaximum());
5643         fh1pOverER02->SetMinimum(0.5);
5644         fh1pOverER02->Draw();
5645         fhMCEle1pOverER02->Draw("same");
5646         fhMCChHad1pOverER02->Draw("same");
5647         fhMCNeutral1pOverER02->Draw("same");
5648         
5649         //              TLegend pLegendpE2(0.65,0.55,0.9,0.8);
5650         //              pLegendpE2.SetTextSize(0.06);
5651         //              pLegendpE2.SetHeader("dR < 0.02");
5652         //              pLegendpE2.SetFillColor(10);
5653         //              pLegendpE2.SetBorderSize(1);
5654         //              pLegendpE2.Draw();
5655         
5656         sprintf(name,"QA_%s_TrackMatchingPOverE.eps",fCalorimeter.Data());
5657         cmpoe->Print(name); printf("Plot: %s\n",name);                          
5658         }
5659         
5660         char line[1024] ; 
5661         sprintf(line, ".!tar -zcf QA_%s_%s.tar.gz *%s*.eps", fCalorimeter.Data(), GetName(),fCalorimeter.Data()) ; 
5662         gROOT->ProcessLine(line);
5663         sprintf(line, ".!rm -fR *.eps"); 
5664         gROOT->ProcessLine(line);
5665         
5666         printf("AliAnaCalorimeterQA::Terminate() - !! All the eps files are in QA_%s_%s.tar.gz !!!\n",  fCalorimeter.Data(), GetName());
5667         
5668 }