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