]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/macros/QA/DrawCaloQA.C
Add in QA task histograms for each module of PHOS EMCAL
[u/mrichter/AliRoot.git] / PWG4 / macros / QA / DrawCaloQA.C
1 //Histograms
2 //CaloClusters 
3 TH1F * fhE  ; //! E distribution, Reco
4 TH1F * fhPt ; //! pT distribution, Reco
5 TH1F * fhPhi; //! phi distribution, Reco 
6 TH1F * fhEta; //! eta distribution, Reco 
7 TH2F * fhEtaPhi  ; //! eta vs phi, Reco 
8 TH3F * fhEtaPhiE  ; //! eta vs phi vs E, Reco
9 TH1F * fhECharged  ; //! E distribution, Reco, matched with track
10 TH1F * fhPtCharged ; //! pT distribution, Reco, matched with track
11 TH1F * fhPhiCharged; //! phi distribution, Reco, matched with track 
12 TH1F * fhEtaCharged; //! eta distribution, Reco, matched with track 
13 TH2F * fhEtaPhiCharged  ; //! eta vs phi, Reco, matched with track
14 TH1F * fhEChargedNoOut  ; //! E distribution, Reco, matched with track, no outer param
15 TH1F * fhPtChargedNoOut ; //! pT distribution, Reco, matched with track, no outer param
16 TH1F * fhPhiChargedNoOut; //! phi distribution, Reco, matched with track, no outer param
17 TH1F * fhEtaChargedNoOut; //! eta distribution, Reco, matched with track, no outer param
18 TH2F * fhEtaPhiChargedNoOut  ; //! eta vs phi, Reco, matched with track, no outer param
19 TH1F * fhDeltaE  ; //! MC-Reco E distribution   
20 TH1F * fhDeltaPt ; //! MC-Reco pT distribution
21 TH1F * fhDeltaPhi; //! MC-Reco phi distribution
22 TH1F * fhDeltaEta; //! MC-Reco eta distribution
23 TH1F * fhRatioE  ; //! Reco/MC E distribution   
24 TH1F * fhRatioPt ; //! Reco/MC pT distribution
25 TH1F * fhRatioPhi; //! Reco/MC phi distribution
26 TH1F * fhRatioEta; //! Reco/MC eta distribution
27 TH2F * fh2E  ; //! E distribution, Reco vs MC
28 TH2F * fh2Pt ; //! pT distribution, Reco vs MC
29 TH2F * fh2Phi; //! phi distribution, Reco vs MC
30 TH2F * fh2Eta; //! eta distribution, Reco vs MC
31 TH2F * fhIM; //! cluster pairs invariant mass
32 TH2F * fhIMCellCut; //! cluster pairs invariant mass, n cells > 1 per cluster
33 TH2F * fhAsym; //! cluster pairs invariant mass 
34 TH2F * fhNCellsPerCluster; //! N cells per cluster      
35 TH1F * fhNClusters; //! Number of clusters
36
37 //Calo Cells
38 TH1F * fhNCells; //! Number of towers/crystals with signal
39 TH1F * fhAmplitude; //! Amplitude measured in towers/crystals
40
41 //Calorimeters Correlation
42 TH2F * fhCaloCorrNClusters; // EMCAL vs PHOS, number of clusters        
43 TH2F * fhCaloCorrEClusters; // EMCAL vs PHOS, total measured cluster energy
44 TH2F * fhCaloCorrNCells; // EMCAL vs PHOS, number of cells
45 TH2F * fhCaloCorrECells; // EMCAL vs PHOS,  total measured cell energy
46
47 //Module histograms
48 TH1F ** fhEMod  ;               //! E distribution for different module, Reco
49 TH1F ** fhNClustersMod ;        //! Number of clusters for different module, Reco
50 TH2F ** fhNCellsPerClusterMod ; //! N cells per clusters different module, Reco
51 TH1F ** fhNCellsMod ;           //! Number of towers/crystals with signal different module, Reco
52 TH2F ** fhGridCellsMod ;        //! Cells ordered in column/row for different module, Reco
53 TH2F ** fhGridCellsEMod ;       //! Cells ordered in column/row for different module, weighted with energy, Reco
54 TH1F ** fhAmplitudeMod ;        //! Amplitude measured in towers/crystals different module, Reco
55 TH2F ** fhIMMod;                //! cluster pairs invariant mass, different module,
56 TH2F ** fhIMCellCutMod;         //! cluster pairs invariant mass, n cells > 1 per cluster, different module
57
58
59 //MC  
60 TH1F *fhGenGamPt  ; // pt of primary gamma
61 TH1F *fhGenGamEta ; // eta of primart gamma
62 TH1F *fhGenGamPhi ; // phi of primary gamma     
63 TH1F *fhGenPi0Pt  ; // pt of primary pi0
64 TH1F *fhGenPi0Eta ; // eta of primart pi0
65 TH1F *fhGenPi0Phi ; // phi of primary pi0       
66 TH1F *fhGenEtaPt  ; // pt of primary eta
67 TH1F *fhGenEtaEta ; // eta of primart eta
68 TH1F *fhGenEtaPhi ; // phi of primary eta
69 TH1F *fhGenOmegaPt  ; // pt of primary omega
70 TH1F *fhGenOmegaEta ; // eta of primart omega
71 TH1F *fhGenOmegaPhi ; // phi of primary omega
72 TH1F *fhGenElePt  ; // pt of primary electron
73 TH1F *fhGenEleEta ; // eta of primart electron
74 TH1F *fhGenElePhi ; // phi of primary electron
75
76 //TH3F * fhEMVxyz    ; // Electromagnetic particle production vertex
77 TH2F * fhEMVxyz    ; // Electromagnetic particle production vertex
78 TH2F * fhEMR       ; // Electromagnetic distance to vertex vs rec energy  
79 //TH3F * fhHaVxyz    ; // Hadron production vertex
80 TH2F * fhHaVxyz    ; // Hadron production vertex
81 TH2F * fhHaR       ; // Hadron distance to vertex vs rec energy  
82
83 TH2F * fhGamE  ; //! E distribution of generated photons, Reco
84 TH2F * fhGamPt ; //! pT distribution of generated photons, Reco
85 TH2F * fhGamPhi; //! phi distribution of generated photon, Reco 
86 TH2F * fhGamEta; //! eta distribution of generated photons, Reco        
87 TH1F * fhGamDeltaE  ; //! MC-Reco E distribution of generated photons   
88 TH1F * fhGamDeltaPt ; //! MC-Reco pT distribution of generated photons
89 TH1F * fhGamDeltaPhi; //! MC-Reco phi distribution of generated photons
90 TH1F * fhGamDeltaEta; //! MC-Reco eta distribution of generated photons
91 TH1F * fhGamRatioE  ; //! Reco/MC E distribution of generated photons   
92 TH1F * fhGamRatioPt ; //! Reco/MC pT distribution of generated photons
93 TH1F * fhGamRatioPhi; //! Reco/MC phi distribution of generated photons
94 TH1F * fhGamRatioEta; //! Reco/MC eta distribution of generated photons
95 TH2F * fhEleE  ; //! E distribution of generated electrons, Reco
96 TH2F * fhElePt ; //! pT distribution of generated electrons, Reco
97 TH2F * fhElePhi; //! phi distribution of generated electron, Reco 
98 TH2F * fhEleEta; //! eta distribution of generated electrons, Reco              
99 TH2F * fhPi0E  ; //! E distribution of generated pi0, Reco, gamma decay overlapped
100 TH2F * fhPi0Pt ; //! pT distribution of generated pi0, Reco, gamma decay overlapped
101 TH2F * fhPi0Phi; //! phi distribution of generated pi0, Reco, gamma decay overlapped
102 TH2F * fhPi0Eta; //! eta distribution of generated pi0, Reco, gamma decay overlapped
103 TH2F * fhNeHadE  ; //! E distribution of generated neutral hadron, Reco
104 TH2F * fhNeHadPt ; //! pT distribution of generated neutral hadron, Reco
105 TH2F * fhNeHadPhi; //! phi distribution of generated neutral hadron, Reco 
106 TH2F * fhNeHadEta; //! eta distribution of generated neutral hadron, Reco       
107 TH2F * fhChHadE  ; //! E distribution of generated charged hadron, Reco
108 TH2F * fhChHadPt ; //! pT distribution of generated charged hadron, Reco
109 TH2F * fhChHadPhi; //! phi distribution of generated charged hadron, Reco 
110 TH2F * fhChHadEta; //! eta distribution of generated charged hadron, Reco 
111
112 TH2F * fhGamECharged  ; //! E distribution of generated photons, Reco, track matched cluster
113 TH2F * fhGamPtCharged ; //! pT distribution of generated photons, Reco, track matched cluster
114 TH2F * fhGamPhiCharged; //! phi distribution of generated photon, Reco, track matched cluster 
115 TH2F * fhGamEtaCharged; //! eta distribution of generated photons, Reco, track matched cluster 
116 TH2F * fhEleECharged  ; //! E distribution of generated electrons, Reco, track matched cluster
117 TH2F * fhElePtCharged ; //! pT distribution of generated electrons, Reco, track matched cluster
118 TH2F * fhElePhiCharged; //! phi distribution of generated electron, Reco, track matched cluster 
119 TH2F * fhEleEtaCharged; //! eta distribution of generated electrons, Reco, track matched cluster                
120 TH2F * fhPi0ECharged  ; //! E distribution of generated pi0, Reco, gamma decay overlapped, track matched cluster
121 TH2F * fhPi0PtCharged ; //! pT distribution of generated pi0, Reco, gamma decay overlapped, track matched cluster
122 TH2F * fhPi0PhiCharged; //! phi distribution of generated pi0, Reco, gamma decay overlapped, track matched cluster
123 TH2F * fhPi0EtaCharged; //! eta distribution of generated pi0, Reco, gamma decay overlapped, track matched cluster
124 TH2F * fhNeHadECharged  ; //! E distribution of generated neutral hadron, Reco, track matched cluster
125 TH2F * fhNeHadPtCharged ; //! pT distribution of generated neutral hadron, Reco, track matched cluster
126 TH2F * fhNeHadPhiCharged; //! phi distribution of generated neutral hadron, Reco , track matched cluster
127 TH2F * fhNeHadEtaCharged; //! eta distribution of generated neutral hadron, Reco, track matched cluster         
128 TH2F * fhChHadECharged  ; //! E distribution of generated charged hadron, Reco, track matched cluster
129 TH2F * fhChHadPtCharged ; //! pT distribution of generated charged hadron, Reco, track matched cluster
130 TH2F * fhChHadPhiCharged; //! phi distribution of generated charged hadron, Reco, track matched cluster 
131 TH2F * fhChHadEtaCharged; //! eta distribution of generated charged hadron, Reco, track matched cluster         
132
133 TH1F *fhGenGamAccE   ; // E of primary gamma
134 TH1F *fhGenGamAccPt  ; // pt of primary gamma
135 TH1F *fhGenGamAccEta ; // eta of primart gamma
136 TH1F *fhGenGamAccPhi ; // phi of primary gamma  
137 TH1F *fhGenPi0AccE   ; // E of primary pi0
138 TH1F *fhGenPi0AccPt  ; // pt of primary pi0
139 TH1F *fhGenPi0AccEta ; // eta of primart pi0
140 TH1F *fhGenPi0AccPhi ; // phi of primary pi0            
141
142 //Histograms for track-matching
143 TH2F *fh1pOverE;     //! p/E for track-cluster matches
144 TH1F *fh1dR;         //! distance between projected track and cluster
145 TH2F *fh2EledEdx;    //! dE/dx vs. momentum for electron candidates
146 TH2F *fh2MatchdEdx;  //! dE/dx vs. momentum for all matches
147 TH2F *fhMCEle1pOverE;     //! p/E for track-cluster matches, MC electrons
148 TH1F *fhMCEle1dR;         //! distance between projected track and cluster, MC electrons
149 TH2F *fhMCEle2MatchdEdx;  //! dE/dx vs. momentum for all matches, MC electrons  
150
151 TH2F *fhMCChHad1pOverE;     //! p/E for track-cluster matches, MC charged hadrons
152 TH1F *fhMCChHad1dR;         //! distance between projected track and cluster, MC charged hadrons
153 TH2F *fhMCChHad2MatchdEdx;  //! dE/dx vs. momentum for all matches, MC charged
154
155 TH2F *fhMCNeutral1pOverE;     //! p/E for track-cluster matches, MC neutral
156 TH1F *fhMCNeutral1dR;         //! distance between projected track and cluster, MC neutral
157 TH2F *fhMCNeutral2MatchdEdx;  //! dE/dx vs. momentum for all matches, MC neutral        
158
159 TH2F *fh1pOverER02;           //! p/E for track-cluster matches, dR > 0.2       
160 TH2F *fhMCEle1pOverER02;      //! p/E for track-cluster matches, dR > 0.2, MC electrons
161 TH2F *fhMCChHad1pOverER02;    //! p/E for track-cluster matches, dR > 0.2, MC charged hadrons
162 TH2F *fhMCNeutral1pOverER02;  //! p/E for track-cluster matches, dR > 0.2, MC neutral
163
164 //________________________________________________________________________
165 void ReadHistograms(TString name, Bool_t isDataMC, Bool_t  fCorrelateCalos, Int_t fNModules)
166 {
167         TFile *f = new TFile("Calo.Performance.root","read");
168         TList* outputList = f->Get("Calo.Performance");
169         
170         //Module histograms
171         fhEMod                = new TH1F*[fNModules];
172         fhNClustersMod        = new TH1F*[fNModules];
173         fhNCellsPerClusterMod = new TH2F*[fNModules];
174         fhNCellsMod           = new TH1F*[fNModules];
175         fhGridCellsMod        = new TH2F*[fNModules];
176         fhGridCellsEMod       = new TH2F*[fNModules];
177         fhAmplitudeMod        = new TH1F*[fNModules];
178         fhIMMod               = new TH2F*[fNModules];
179         fhIMCellCutMod        = new TH2F*[fNModules];
180         
181         
182         // Histograms of this analsys are kept in the same list as other analysis, recover the position of
183         // the first one and then add the next 
184         Int_t index = outputList->IndexOf(outputList->FindObject(name+"hE"));
185         //printf("Calo: %s, index: %d\n",fCalorimeter.Data(),index);
186         //Read histograms, must be in the same order as in GetCreateOutputObject.
187         fhE      = (TH1F *) outputList->At(index++);    
188         fhPt     = (TH1F *) outputList->At(index++); 
189         fhPhi    = (TH1F *) outputList->At(index++); 
190         fhEta    = (TH1F *) outputList->At(index++);
191         fhEtaPhi = (TH2F *) outputList->At(index++);
192         fhEtaPhiE = (TH3F *) outputList->At(index++);
193
194         fhECharged      = (TH1F *) outputList->At(index++);     
195         fhPtCharged     = (TH1F *) outputList->At(index++); 
196         fhPhiCharged    = (TH1F *) outputList->At(index++); 
197         fhEtaCharged    = (TH1F *) outputList->At(index++);
198         fhEtaPhiCharged = (TH2F *) outputList->At(index++);
199         
200         fhEChargedNoOut      = (TH1F *) outputList->At(index++);        
201         fhPtChargedNoOut     = (TH1F *) outputList->At(index++); 
202         fhPhiChargedNoOut    = (TH1F *) outputList->At(index++); 
203         fhEtaChargedNoOut    = (TH1F *) outputList->At(index++);
204         fhEtaPhiChargedNoOut = (TH2F *) outputList->At(index++);
205         
206         fh1pOverE    = (TH2F *) outputList->At(index++);
207         fh1dR        = (TH1F *) outputList->At(index++);
208         fh2MatchdEdx = (TH2F *) outputList->At(index++);
209         fh2EledEdx   = (TH2F *) outputList->At(index++);
210         fh1pOverER02 = (TH2F *) outputList->At(index++); 
211
212         fhIM     = (TH2F *) outputList->At(index++);
213         fhIMCellCut = (TH2F *) outputList->At(index++);
214         fhAsym   = (TH2F *) outputList->At(index++);
215         
216         fhNCellsPerCluster = (TH2F *) outputList->At(index++);
217         fhNClusters  = (TH1F *) outputList->At(index++); 
218         fhNCells     = (TH1F *) outputList->At(index++); 
219         fhAmplitude  = (TH1F *) outputList->At(index++); 
220         
221         if(fCorrelateCalos){
222                 fhCaloCorrNClusters = (TH2F *) outputList->At(index++);
223                 fhCaloCorrEClusters = (TH2F *) outputList->At(index++); 
224                 fhCaloCorrNCells    = (TH2F *) outputList->At(index++); 
225                 fhCaloCorrECells    = (TH2F *) outputList->At(index++); 
226         }
227         
228         for(Int_t imod = 0 ; imod < fNModules; imod++){
229                 fhEMod[imod]                = (TH1F *) outputList->At(index++);
230                 fhNClustersMod[imod]        = (TH1F *) outputList->At(index++); 
231                 fhNCellsPerClusterMod[imod] = (TH2F *) outputList->At(index++); 
232                 fhNCellsMod[imod]           = (TH1F *) outputList->At(index++);         
233                 fhGridCellsMod[imod]        = (TH2F *) outputList->At(index++);
234                 fhGridCellsEMod[imod]       = (TH2F *) outputList->At(index++); 
235                 fhAmplitudeMod[imod]        = (TH1F *) outputList->At(index++); 
236                 fhIMMod[imod]               = (TH2F *) outputList->At(index++); 
237                 fhIMCellCutMod[imod]        = (TH2F *) outputList->At(index++);         
238                 
239         }
240         
241         if(isDataMC){
242                 fhDeltaE   = (TH1F *) outputList->At(index++); 
243                 fhDeltaPt  = (TH1F *) outputList->At(index++); 
244                 fhDeltaPhi = (TH1F *) outputList->At(index++); 
245                 fhDeltaEta = (TH1F *) outputList->At(index++); 
246                 
247                 fhRatioE   = (TH1F *) outputList->At(index++); 
248                 fhRatioPt  = (TH1F *) outputList->At(index++); 
249                 fhRatioPhi = (TH1F *) outputList->At(index++); 
250                 fhRatioEta = (TH1F *) outputList->At(index++); 
251                 
252                 fh2E       = (TH2F *) outputList->At(index++); 
253                 fh2Pt      = (TH2F *) outputList->At(index++); 
254                 fh2Phi     = (TH2F *) outputList->At(index++); 
255                 fh2Eta     = (TH2F *) outputList->At(index++); 
256                 
257                 fhGamE     = (TH2F *) outputList->At(index++); 
258                 fhGamPt    = (TH2F *) outputList->At(index++); 
259                 fhGamPhi   = (TH2F *) outputList->At(index++); 
260                 fhGamEta   = (TH2F *) outputList->At(index++); 
261                 
262                 fhGamDeltaE   = (TH1F *) outputList->At(index++); 
263                 fhGamDeltaPt  = (TH1F *) outputList->At(index++); 
264                 fhGamDeltaPhi = (TH1F *) outputList->At(index++); 
265                 fhGamDeltaEta = (TH1F *) outputList->At(index++); 
266                 
267                 fhGamRatioE   = (TH1F *) outputList->At(index++); 
268                 fhGamRatioPt  = (TH1F *) outputList->At(index++); 
269                 fhGamRatioPhi = (TH1F *) outputList->At(index++); 
270                 fhGamRatioEta = (TH1F *) outputList->At(index++); 
271                                 
272                 fhPi0E     = (TH2F *) outputList->At(index++); 
273                 fhPi0Pt    = (TH2F *) outputList->At(index++); 
274                 fhPi0Phi   = (TH2F *) outputList->At(index++); 
275                 fhPi0Eta   = (TH2F *) outputList->At(index++);          
276                 
277                 fhEleE     = (TH2F *) outputList->At(index++); 
278                 fhElePt    = (TH2F *) outputList->At(index++); 
279                 fhElePhi   = (TH2F *) outputList->At(index++); 
280                 fhEleEta   = (TH2F *) outputList->At(index++);          
281                 
282                 fhNeHadE     = (TH2F *) outputList->At(index++); 
283                 fhNeHadPt    = (TH2F *) outputList->At(index++); 
284                 fhNeHadPhi   = (TH2F *) outputList->At(index++); 
285                 fhNeHadEta   = (TH2F *) outputList->At(index++);                
286                 
287                 fhChHadE     = (TH2F *) outputList->At(index++); 
288                 fhChHadPt    = (TH2F *) outputList->At(index++); 
289                 fhChHadPhi   = (TH2F *) outputList->At(index++); 
290                 fhChHadEta   = (TH2F *) outputList->At(index++);                                        
291                 fhGamECharged     = (TH2F *) outputList->At(index++); 
292                 fhGamPtCharged    = (TH2F *) outputList->At(index++); 
293                 fhGamPhiCharged   = (TH2F *) outputList->At(index++); 
294                 fhGamEtaCharged   = (TH2F *) outputList->At(index++); 
295                 
296                 fhPi0ECharged     = (TH2F *) outputList->At(index++); 
297                 fhPi0PtCharged    = (TH2F *) outputList->At(index++); 
298                 fhPi0PhiCharged   = (TH2F *) outputList->At(index++); 
299                 fhPi0EtaCharged   = (TH2F *) outputList->At(index++);           
300                 
301                 fhEleECharged     = (TH2F *) outputList->At(index++); 
302                 fhElePtCharged    = (TH2F *) outputList->At(index++); 
303                 fhElePhiCharged   = (TH2F *) outputList->At(index++); 
304                 fhEleEtaCharged   = (TH2F *) outputList->At(index++);           
305                 
306                 fhNeHadECharged     = (TH2F *) outputList->At(index++); 
307                 fhNeHadPtCharged    = (TH2F *) outputList->At(index++); 
308                 fhNeHadPhiCharged   = (TH2F *) outputList->At(index++); 
309                 fhNeHadEtaCharged   = (TH2F *) outputList->At(index++);                 
310                 
311                 fhChHadECharged     = (TH2F *) outputList->At(index++); 
312                 fhChHadPtCharged    = (TH2F *) outputList->At(index++); 
313                 fhChHadPhiCharged   = (TH2F *) outputList->At(index++); 
314                 fhChHadEtaCharged   = (TH2F *) outputList->At(index++);                                 
315                 
316 //              fhEMVxyz     = (TH3F *) outputList->At(index++); 
317 //              fhHaVxyz     = (TH3F *) outputList->At(index++); 
318                 
319                 fhEMVxyz     = (TH2F *) outputList->At(index++); 
320                 fhHaVxyz     = (TH2F *) outputList->At(index++); 
321                 fhEMR        = (TH2F *) outputList->At(index++); 
322                 fhHaR        = (TH2F *) outputList->At(index++); 
323                 
324                 fhGenGamPt    = (TH1F *) outputList->At(index++); 
325                 fhGenGamEta   = (TH1F *) outputList->At(index++); 
326                 fhGenGamPhi   = (TH1F *) outputList->At(index++); 
327                 
328                 fhGenPi0Pt    = (TH1F *) outputList->At(index++); 
329                 fhGenPi0Eta   = (TH1F *) outputList->At(index++); 
330                 fhGenPi0Phi   = (TH1F *) outputList->At(index++); 
331                 
332                 fhGenEtaPt    = (TH1F *) outputList->At(index++); 
333                 fhGenEtaEta   = (TH1F *) outputList->At(index++); 
334                 fhGenEtaPhi   = (TH1F *) outputList->At(index++); 
335                 
336                 fhGenOmegaPt  = (TH1F *) outputList->At(index++); 
337                 fhGenOmegaEta = (TH1F *) outputList->At(index++); 
338                 fhGenOmegaPhi = (TH1F *) outputList->At(index++); 
339                 
340                 fhGenElePt    = (TH1F *) outputList->At(index++); 
341                 fhGenEleEta   = (TH1F *) outputList->At(index++); 
342                 fhGenElePhi   = (TH1F *) outputList->At(index++); 
343                 
344                 fhGenGamAccE   = (TH1F *) outputList->At(index++);              
345                 fhGenGamAccPt  = (TH1F *) outputList->At(index++); 
346                 fhGenGamAccEta = (TH1F *) outputList->At(index++); 
347                 fhGenGamAccPhi = (TH1F *) outputList->At(index++); 
348                 
349                 fhGenPi0AccE   = (TH1F *) outputList->At(index++);              
350                 fhGenPi0AccPt  = (TH1F *) outputList->At(index++); 
351                 fhGenPi0AccEta = (TH1F *) outputList->At(index++); 
352                 fhGenPi0AccPhi = (TH1F *) outputList->At(index++); 
353              
354                 //Track matching
355                 fhMCEle1pOverE =    (TH2F *) outputList->At(index++);
356                 fhMCEle1dR =        (TH1F *) outputList->At(index++);
357                 fhMCEle2MatchdEdx = (TH2F *) outputList->At(index++);
358         
359                 fhMCChHad1pOverE =    (TH2F *) outputList->At(index++);
360                 fhMCChHad1dR =        (TH1F *) outputList->At(index++);
361                 fhMCChHad2MatchdEdx = (TH2F *) outputList->At(index++);
362         
363                 fhMCNeutral1pOverE    = (TH2F *) outputList->At(index++);
364                 fhMCNeutral1dR        = (TH1F *) outputList->At(index++);
365                 fhMCNeutral2MatchdEdx = (TH2F *) outputList->At(index++);
366         
367                 fhMCEle1pOverER02     =    (TH2F *) outputList->At(index++);
368                 fhMCChHad1pOverER02   =    (TH2F *) outputList->At(index++);
369                 fhMCNeutral1pOverER02 =    (TH2F *) outputList->At(index++);
370         }//Is data MC
371 }
372
373
374 //__________________________________________________________________
375 void  DrawCaloQA(TString fCalorimeter = "EMCAL", Bool_t isDataMC = kFALSE) 
376 {
377         //Macro for replotting Calorimeter QA histograms
378         Bool_t fCorrelateCalos = kFALSE;
379         Int_t fNModules = 12;
380         //By default when PHOS QA is called correlation not done
381         if(fCalorimeter == "PHOS") {
382         fCorrelateCalos = kFALSE;
383         fNModules = 3;//5
384         }
385         else {
386                 fCorrelateCalos = kTRUE;
387         fNModules = 4;//12
388         }
389         cout<<"Calo? "<<fCalorimeter<<" Correlate plots? "<<fCorrelateCalos<<" MC plots?"<<isDataMC<<endl;
390         //Do some plots to end
391         gROOT->Macro("./style.C");//Set different root style parameters
392         //Recover histograms from output histograms list, needed for distributed analysis.      
393         ReadHistograms(fCalorimeter+"_", isDataMC, fCorrelateCalos,fNModules);
394         Float_t minx = 0;
395         Float_t maxx = 10;
396         
397         char name[128];
398         char cname[128];
399         
400         //Reconstructed distributions
401         //printf("c1\n");
402         sprintf(cname,"QA_%s_rec",fCalorimeter.Data());
403         TCanvas  * c = new TCanvas(cname, "Reconstructed distributions", 400, 400) ;
404         c->Divide(2, 2);
405         
406         fhE->SetAxisRange(minx,maxx,"X");
407         fhPt->SetAxisRange(minx,maxx,"X");
408         
409         c->cd(1) ; 
410         if(fhE->GetEntries() > 0) gPad->SetLogy();
411         TLegend pLegendE(0.7,0.6,0.9,0.8);
412         pLegendE.SetTextSize(0.03);
413         pLegendE.AddEntry(fhE,"all modules","L");
414         pLegendE.SetFillColor(10);
415         pLegendE.SetBorderSize(1);
416         
417         fhE->SetLineColor(1);
418         fhE->Draw();
419         for(Int_t imod = 0; imod < fNModules; imod++){
420                 fhEMod[imod]->SetLineColor(imod+1);
421                 fhEMod[imod]->Draw("same");
422                 pLegendE.AddEntry(fhEMod[imod],Form("module %d",imod),"L");
423         }
424         pLegendE.Draw();
425         
426         c->cd(2) ; 
427         gPad->SetLogy();
428         fhPt->SetLineColor(4);
429         fhPt->Draw();
430         
431         c->cd(3) ; 
432         fhPhi->SetLineColor(4);
433         fhPhi->Draw();
434         
435         c->cd(4) ; 
436         fhEta->SetLineColor(4);
437         fhEta->Draw();
438         
439         sprintf(name,"QA_%s_ReconstructedDistributions.eps",fCalorimeter.Data());
440         c->Print(name);
441         
442         //Reconstructed distributions, matched with tracks
443         //printf("c2\n");
444         sprintf(cname,"QA_%s_rectrackmatch",fCalorimeter.Data());
445         TCanvas  * c2 = new TCanvas(cname, "Reconstructed distributions, matched with tracks", 400, 400) ;
446         c2->Divide(2, 2);
447         
448         fhECharged->SetAxisRange(minx,maxx,"X");
449         fhPtCharged->SetAxisRange(minx,maxx,"X");
450
451         c2->cd(1) ; 
452         gPad->SetLogy();
453         fhECharged->SetLineColor(4);
454         fhECharged->Draw();
455         
456         c2->cd(2) ; 
457         gPad->SetLogy();
458         fhPtCharged->SetLineColor(4);
459         fhPtCharged->Draw();
460         
461         c2->cd(3) ; 
462         fhPhiCharged->SetLineColor(4);
463         fhPhiCharged->Draw();
464         
465         c2->cd(4) ; 
466         fhEtaCharged->SetLineColor(4);
467         fhEtaCharged->Draw();
468         
469         sprintf(name,"QA_%s_ReconstructedDistributions_TrackMatched.eps",fCalorimeter.Data());
470         c2->Print(name);
471         
472         TH1F *  hEChargedClone   = (TH1F*)   fhECharged->Clone("EChargedClone");
473         TH1F *  hPtChargedClone  = (TH1F*)   fhPtCharged->Clone("PtChargedClone");
474         TH1F *  hEtaChargedClone = (TH1F*)   fhEtaCharged->Clone("EtaChargedClone");
475         TH1F *  hPhiChargedClone = (TH1F*)   fhPhiCharged->Clone("PhiChargedClone");
476         
477         TH1F *  hEChargedClone2   = (TH1F*)   fhECharged->Clone("EChargedClone2");
478         TH1F *  hPtChargedClone2  = (TH1F*)   fhPtCharged->Clone("PtChargedClone2");
479         TH1F *  hEtaChargedClone2 = (TH1F*)   fhEtaCharged->Clone("EtaChargedClone2");
480         TH1F *  hPhiChargedClone2 = (TH1F*)   fhPhiCharged->Clone("PhiChargedClone2");
481         
482         //Ratio: reconstructed track matched/ all reconstructed
483         //printf("c3\n");
484         sprintf(cname,"QA_%s_rectrackmatchrat",fCalorimeter.Data());
485         TCanvas  * c3 = new TCanvas(cname, "Ratio: reconstructed track matched/ all reconstructed", 400, 400) ;
486         c3->Divide(2, 2);
487         
488         c3->cd(1) ;
489         gPad->SetLogy();
490         hEChargedClone->SetTitleOffset(1.6,"Y");
491         hEChargedClone->SetYTitle("track matched / all   ");
492         hEChargedClone->SetXTitle("E (GeV)");
493         hEChargedClone->Divide(fhE);
494         hEChargedClone->Draw();
495         
496         c3->cd(2) ; 
497         gPad->SetLogy();
498         hPtChargedClone->SetTitleOffset(1.6,"Y");
499         hPtChargedClone->SetYTitle("track matched / all   ");
500         hPtChargedClone->SetXTitle("p_{T} (GeV/c)");
501         hPtChargedClone->Divide(fhPt);
502         hPtChargedClone->Draw();
503         
504         c3->cd(3) ;
505         gPad->SetLogy();
506         hPhiChargedClone->SetTitleOffset(1.6,"Y");
507         hPhiChargedClone->SetYTitle("track matched / all   ");
508         hPhiChargedClone->SetXTitle("#phi (rad)");
509         hPhiChargedClone->Divide(fhPhi);
510         hPhiChargedClone->Draw();
511         
512         c3->cd(4) ; 
513         gPad->SetLogy();
514         hEtaChargedClone->SetTitleOffset(1.6,"Y");
515         hEtaChargedClone->SetYTitle("track matched / all   ");
516         hEtaChargedClone->SetXTitle("#eta");
517         hEtaChargedClone->Divide(fhEta);
518         hEtaChargedClone->Draw();
519         
520         sprintf(name,"QA_%s_RatioReconstructedMatchedDistributions.eps",fCalorimeter.Data());
521         c3->Print(name);
522         
523         //Ratio: reconstructed track matched (minus no track param) / all
524         //printf("c333\n");
525         sprintf(cname,"QA_%s_rectrackmatchratout",fCalorimeter.Data());
526         TCanvas  * c333 = new TCanvas(cname, "Ratio: reconstructed track matched (with outer track param)/ all", 400, 400) ;
527         c333->Divide(2, 2);
528         
529         c333->cd(1) ;
530         hEChargedClone2->Add(fhEChargedNoOut,-1);
531         hEChargedClone2->SetYTitle("track matched / all");
532         hEChargedClone2->SetXTitle("E (GeV)");
533         hEChargedClone2->Divide(fhE);
534         hEChargedClone2->Draw();
535         
536         c333->cd(2) ; 
537         hPtChargedClone2->Add(fhPtChargedNoOut,-1);
538         hPtChargedClone2->SetYTitle("track matched / all");
539         hPtChargedClone2->SetXTitle("p_{T} (GeV/c)");
540         hPtChargedClone2->Divide(fhPt);
541         hPtChargedClone2->Draw();
542         
543         c333->cd(3) ;
544         hPhiChargedClone2->Add(fhPhiChargedNoOut,-1);
545         hPhiChargedClone2->SetYTitle("track matched / all");
546         hPhiChargedClone2->SetXTitle("#phi (rad)");
547         hPhiChargedClone2->Divide(fhPhi);
548         hPhiChargedClone2->Draw();
549         
550         c333->cd(4) ; 
551         hEtaChargedClone2->Add(fhEtaChargedNoOut,-1);
552         hEtaChargedClone2->SetYTitle("track matched / all");
553         hEtaChargedClone2->SetXTitle("#eta");
554         hEtaChargedClone2->Divide(fhEta);
555         hEtaChargedClone2->Draw();
556         
557         sprintf(name,"QA_%s_RatioReconstructedMatchedDistributionsOuter.eps",fCalorimeter.Data());
558         c333->Print(name);
559         
560 //      //Reconstructed distributions, matched with tracks but no outer param
561 //      //printf("c2\n");
562 //      sprintf(cname,"QA_%s_rectrackmatch_noout",fCalorimeter.Data());
563 //      TCanvas  * c22 = new TCanvas(cname, "Reconstructed distributions, matched with tracks, no outer track param", 400, 400) ;
564 //      c22->Divide(2, 2);
565 //      
566 //      c22->cd(1) ; 
567 //      gPad->SetLogy();
568 //      fhEChargedNoOut->SetLineColor(4);
569 //      fhEChargedNoOut->Draw();
570 //      
571 //      c22->cd(2) ; 
572 //      gPad->SetLogy();
573 //      fhPtChargedNoOut->SetLineColor(4);
574 //      fhPtChargedNoOut->Draw();
575 //      
576 //      c22->cd(3) ; 
577 //      fhPhiChargedNoOut->SetLineColor(4);
578 //      fhPhiChargedNoOut->Draw();
579 //      
580 //      c22->cd(4) ; 
581 //      fhEtaChargedNoOut->SetLineColor(4);
582 //      fhEtaChargedNoOut->Draw();
583 //      
584 //      sprintf(name,"QA_%s_ReconstructedDistributions_TrackMatched_NoOutParam.eps",fCalorimeter.Data());
585 //      c22->Print(name);
586         
587         //Ratio: reconstructed track matched/ all reconstructed
588         //printf("c3\n");
589         
590 //      TH1F *  hEChargedNoOutClone   = (TH1F*)   fhEChargedNoOut->Clone("EChargedNoOutClone");
591 //      TH1F *  hPtChargedNoOutClone  = (TH1F*)   fhPtChargedNoOut->Clone("PtChargedNoOutClone");
592 //      TH1F *  hEtaChargedNoOutClone = (TH1F*)   fhEtaChargedNoOut->Clone("EtaChargedNoOutClone");
593 //      TH1F *  hPhiChargedNoOutClone = (TH1F*)   fhPhiChargedNoOut->Clone("PhiChargedNoOutClone");     
594 //      
595 //      sprintf(cname,"QA_%s_rectrackmatchratnoout",fCalorimeter.Data());
596 //      TCanvas  * c33 = new TCanvas(cname, "Ratio: reconstructed track matched/ all reconstructed", 400, 400) ;
597 //      c33->Divide(2, 2);
598 //      
599 //      c33->cd(1) ;
600 //      hEChargedNoOutClone->SetYTitle("track matched no out/ all matched");
601 //      hEChargedNoOutClone->SetXTitle("E (GeV)");
602 //      hEChargedNoOutClone->Divide(fhECharged);
603 //      hEChargedNoOutClone->Draw();
604 //      
605 //      c33->cd(2) ; 
606 //      hPtChargedNoOutClone->SetYTitle("track matched no out / all matched");
607 //      hPtChargedNoOutClone->SetXTitle("p_{T} (GeV/c)");
608 //      hPtChargedNoOutClone->Divide(fhPtCharged);
609 //      hPtChargedNoOutClone->Draw();
610 //      
611 //      c33->cd(3) ;
612 //      hPhiChargedNoOutClone->SetYTitle("track matched no out/ all matched");
613 //      hPhiChargedNoOutClone->SetXTitle("#phi (rad)");
614 //      hPhiChargedNoOutClone->Divide(fhPhiCharged);
615 //      hPhiChargedNoOutClone->Draw();
616 //      
617 //      c33->cd(4) ; 
618 //      hEtaChargedNoOutClone->SetYTitle("track matched no out/ all matched");
619 //      hEtaChargedNoOutClone->SetXTitle("#eta");
620 //      hEtaChargedNoOutClone->Divide(fhEtaCharged);
621 //      hEtaChargedNoOutClone->Draw();
622 //      
623 //      sprintf(name,"QA_%s_RatioMatchedDistributionsAllToNoOut.eps",fCalorimeter.Data());
624 //      c33->Print(name);
625         
626         
627
628         //TRACK MATCHING P/E distributions
629         //printf("cPoverE\n");
630         sprintf(cname,"QA_%s_trkmatch",fCalorimeter.Data());
631         TCanvas *cme = new TCanvas(cname,"Track-matching distributions", 400, 400);
632         cme->Divide(2,2);
633         
634         TLegend pLegendpE0(0.6,0.55,0.9,0.8);
635         pLegendpE0.SetTextSize(0.04);
636         pLegendpE0.AddEntry(fh1pOverE,"all","L");
637         pLegendpE0.AddEntry(fh1pOverER02,"dR < 0.02","L");
638         pLegendpE0.SetFillColor(10);
639         pLegendpE0.SetBorderSize(1);
640         //pLegendpE0.Draw();
641         
642         cme->cd(1);
643         gPad->SetLogy();
644         fh1pOverE->SetTitle("Track matches p/E");
645         fh1pOverE->Draw();
646         fh1pOverER02->SetLineColor(4);
647         fh1pOverER02->Draw("same");
648         pLegendpE0.Draw();
649         
650         cme->cd(2);
651         gPad->SetLogy();
652         fh1dR->Draw();
653         
654         cme->cd(3);
655         fh2MatchdEdx->Draw();
656         
657         cme->cd(4);
658         fh2EledEdx->Draw();
659         
660         sprintf(name,"QA_%s_TrackMatchingEleDist.eps",fCalorimeter.Data());
661         cme->Print(name);       
662
663         //eta vs phi
664         //printf("c4\n");
665         sprintf(cname,"QA_%s_etavsphi",fCalorimeter.Data());
666 //      TCanvas  * c4 = new TCanvas(cname, "reconstructed #eta vs #phi", 600, 200) ;
667 //      c4->Divide(3, 1);
668         
669         TCanvas  * c4 = new TCanvas(cname, "reconstructed #eta vs #phi", 400, 200) ;
670         c4->Divide(2, 1);
671         
672         c4->cd(1) ;
673         fhEtaPhi->Draw("cont");
674         
675         c4->cd(2) ; 
676         fhEtaPhiCharged->Draw("cont");
677         
678 //      c4->cd(3) ; 
679 //      fhEtaPhiChargedNoOut->Draw("cont");
680
681         sprintf(name,"QA_%s_ReconstructedEtaVsPhi.eps",fCalorimeter.Data());
682         c4->Print(name);
683         
684         sprintf(name,"QA_%s_ReconstructedEtaVsPhiVsE.eps",fCalorimeter.Data());
685         c4->Print(name); printf("Plot: %s\n",name);
686         
687         //Invariant mass
688         Int_t binmin = -1;
689         Int_t binmax = -1;
690         
691         if(fhIM->GetEntries() > 1){
692                 Int_t nebins  = fhIM->GetNbinsX();
693                 Int_t emax = (Int_t) fhIM->GetXaxis()->GetXmax();
694                 Int_t emin = (Int_t) fhIM->GetXaxis()->GetXmin();
695                 if (emin != 0 ) printf("emin != 0 \n");
696                 //printf("IM: nBinsX %d, emin %2.2f, emax %2.2f\n",nebins,emin,emax);
697                 
698                 sprintf(cname,"QA_%s_IM",fCalorimeter.Data());
699                 //      printf("c5\n");
700                 TCanvas  * c5 = new TCanvas(cname, "Invariant mass", 600, 400) ;
701                 c5->Divide(2, 3);
702                 
703                 c5->cd(1) ; 
704                 //fhIM->SetLineColor(4);
705                 //fhIM->Draw();
706                 binmin = 0;
707                 binmax =  (Int_t) (1-emin)*nebins/emax;
708                 TH1D *pyim1 = fhIM->ProjectionY("pyim1",binmin,binmax);
709                 pyim1->SetTitle("E_{pair} < 1 GeV");
710                 pyim1->SetLineColor(1);
711                 pyim1->Draw();
712                 TLegend pLegendIM(0.7,0.6,0.9,0.8);
713                 pLegendIM.SetTextSize(0.03);
714                 pLegendIM.AddEntry(pyim1,"all modules","L");
715                 pLegendIM.SetFillColor(10);
716                 pLegendIM.SetBorderSize(1);
717                 for(Int_t imod = 0; imod < fNModules; imod++){
718                         pyim1 = fhIMMod[imod]->ProjectionY(Form("pyim1_%d",imod),binmin,binmax);
719                         pLegendIM.AddEntry(pyim1,Form("module %d",imod),"L");
720                         pyim1->SetLineColor(imod+1);
721                         pyim1->Draw("same");
722                 }
723                 pLegendIM.Draw();
724                 
725                 c5->cd(2) ; 
726                 binmin =  (Int_t) (1-emin)*nebins/emax;
727                 binmax =  (Int_t) (2-emin)*nebins/emax;
728                 TH1D *pyim2 = fhIM->ProjectionY("pyim2",binmin,binmax);
729                 pyim2->SetTitle("1 < E_{pair} < 2 GeV");
730                 pyim2->SetLineColor(1);
731                 pyim2->Draw();
732                 for(Int_t imod = 0; imod < fNModules; imod++){
733                         pyim2 = fhIMMod[imod]->ProjectionY(Form("pyim2_%d",imod),binmin,binmax);
734                         pyim2->SetLineColor(imod+1);
735                         pyim2->Draw("same");
736                 }
737                 
738                 c5->cd(3) ; 
739                 binmin =  (Int_t) (2-emin)*nebins/emax;
740                 binmax =  (Int_t) (3-emin)*nebins/emax;
741                 TH1D *pyim3 = fhIM->ProjectionY("pyim3",binmin,binmax);
742                 pyim3->SetTitle("2 < E_{pair} < 3 GeV");
743                 pyim3->SetLineColor(1);
744                 pyim3->Draw();
745                 for(Int_t imod = 0; imod < fNModules; imod++){
746                         pyim3 = fhIMMod[imod]->ProjectionY(Form("pyim3_%d",imod),binmin,binmax);
747                         pyim3->SetLineColor(imod+1);
748                         pyim3->Draw("same");
749                 }
750                 
751                 c5->cd(4) ;
752                 binmin =  (Int_t) (3-emin)*nebins/emax;
753                 binmax =  (Int_t) (4-emin)*nebins/emax;
754                 TH1D *pyim4 = fhIM->ProjectionY("pyim4",binmin,binmax);
755                 pyim4->SetTitle("3 < E_{pair} < 4 GeV");
756                 pyim4->SetLineColor(1);
757                 pyim4->Draw();
758                 for(Int_t imod = 0; imod < fNModules; imod++){
759                         pyim4 = fhIMMod[imod]->ProjectionY(Form("pyim4_%d",imod),binmin,binmax);
760                         pyim4->SetLineColor(imod+1);
761                         pyim4->Draw("same");
762                 }
763                 
764                 c5->cd(5) ;
765                 binmin =  (Int_t) (4-emin)*nebins/emax;
766                 binmax =  (Int_t) (5-emin)*nebins/emax;
767                 TH1D *pyim5 = fhIM->ProjectionY("pyim5",binmin,binmax);
768                 pyim5->SetTitle("4< E_{pair} < 5 GeV");
769                 pyim5->SetLineColor(1);
770                 pyim5->Draw();
771                 for(Int_t imod = 0; imod < fNModules; imod++){
772                         pyim5 = fhIMMod[imod]->ProjectionY(Form("pyim5_%d",imod),binmin,binmax);
773                         pyim5->SetLineColor(imod+1);
774                         pyim5->Draw("same");
775                 }
776                 
777                 c5->cd(6) ;
778                 binmin =  (Int_t) (5-emin)*nebins/emax;
779                 binmax =  -1;
780                 TH1D *pyim10 = fhIM->ProjectionY("pyim10",binmin,binmax);
781                 pyim10->SetTitle("E_{pair} > 5 GeV");
782                 pyim10->SetLineColor(1);
783                 pyim10->Draw();
784                 for(Int_t imod = 0; imod < fNModules; imod++){
785                         pyim10 = fhIMMod[imod]->ProjectionY(Form("pyim10_%d",imod),binmin,binmax);
786                         pyim10->SetLineColor(imod+1);
787                         pyim10->Draw("same");
788                 }
789                 
790                 sprintf(name,"QA_%s_InvariantMass.eps",fCalorimeter.Data());
791                 c5->Print(name); printf("Plot: %s\n",name);
792         }
793         
794         
795         if(fhIMCellCut->GetEntries() > 1){
796                 Int_t nebins  = fhIMCellCut->GetNbinsX();
797                 Int_t emax = (Int_t) fhIMCellCut->GetXaxis()->GetXmax();
798                 Int_t emin = (Int_t) fhIMCellCut->GetXaxis()->GetXmin();
799                 if (emin != 0 ) printf("emin != 0 \n");
800                 //printf("IMCellCut: nBinsX %d, emin %2.2f, emax %2.2f\n",nebins,emin,emax);
801                 
802                 sprintf(cname,"QA_%s_IMCellCut",fCalorimeter.Data());
803                 //      printf("c5cc\n");
804                 TCanvas  * c5cc = new TCanvas(cname, "Invariant mass, Cell Cut", 600, 400) ;
805                 c5cc->Divide(2, 3);
806                 
807                 c5cc->cd(1) ; 
808                 //fhIMCellCut->SetLineColor(4);
809                 //fhIMCellCut->Draw();
810                 binmin = 0;
811                 binmax =  (Int_t) (1-emin)*nebins/emax;
812                 TH1D *pyimcc1 = fhIMCellCut->ProjectionY("pyimcc1",binmin,binmax);
813                 pyimcc1->SetTitle("E_{pair} < 1 GeV");
814                 pyimcc1->SetLineColor(1);
815                 pyimcc1->Draw();
816                 TLegend pLegendIMCellCut(0.7,0.6,0.9,0.8);
817                 pLegendIMCellCut.SetTextSize(0.03);
818                 pLegendIMCellCut.AddEntry(pyimcc1,"all modules","L");
819                 pLegendIMCellCut.SetFillColor(10);
820                 pLegendIMCellCut.SetBorderSize(1);
821                 for(Int_t imod = 0; imod < fNModules; imod++){
822                         pyimcc1 = fhIMCellCutMod[imod]->ProjectionY(Form("pyimcc1_%d",imod),binmin,binmax);
823                         pLegendIMCellCut.AddEntry(pyimcc1,Form("module %d",imod),"L");
824                         pyimcc1->SetLineColor(imod+1);
825                         pyimcc1->Draw("same");
826                 }
827                 pLegendIMCellCut.Draw();
828                 
829                 c5cc->cd(2) ; 
830                 binmin =  (Int_t) (1-emin)*nebins/emax;
831                 binmax =  (Int_t) (2-emin)*nebins/emax;
832                 TH1D *pyimcc2 = fhIMCellCut->ProjectionY("pyimcc2",binmin,binmax);
833                 pyimcc2->SetTitle("1 < E_{pair} < 2 GeV");
834                 pyimcc2->SetLineColor(1);
835                 pyimcc2->Draw();
836                 for(Int_t imod = 0; imod < fNModules; imod++){
837                         pyimcc2 = fhIMCellCutMod[imod]->ProjectionY(Form("pyimcc2_%d",imod),binmin,binmax);
838                         pyimcc2->SetLineColor(imod+1);
839                         pyimcc2->Draw("same");
840                 }
841                 
842                 c5cc->cd(3) ; 
843                 binmin =  (Int_t) (2-emin)*nebins/emax;
844                 binmax =  (Int_t) (3-emin)*nebins/emax;
845                 TH1D *pyimcc3 = fhIMCellCut->ProjectionY("pyimcc3",binmin,binmax);
846                 pyimcc3->SetTitle("2 < E_{pair} < 3 GeV");
847                 pyimcc3->SetLineColor(1);
848                 pyimcc3->Draw();
849                 for(Int_t imod = 0; imod < fNModules; imod++){
850                         pyimcc3 = fhIMCellCutMod[imod]->ProjectionY(Form("pyimcc3_%d",imod),binmin,binmax);
851                         pyimcc3->SetLineColor(imod+1);
852                         pyimcc3->Draw("same");
853                 }
854                 
855                 c5cc->cd(4) ;
856                 binmin =  (Int_t) (3-emin)*nebins/emax;
857                 binmax =  (Int_t) (4-emin)*nebins/emax;
858                 TH1D *pyimcc4 = fhIMCellCut->ProjectionY("pyimcc4",binmin,binmax);
859                 pyimcc4->SetTitle("3 < E_{pair} < 4 GeV");
860                 pyimcc4->SetLineColor(1);
861                 pyimcc4->Draw();
862                 for(Int_t imod = 0; imod < fNModules; imod++){
863                         pyimcc4 = fhIMCellCutMod[imod]->ProjectionY(Form("pyimcc4_%d",imod),binmin,binmax);
864                         pyimcc4->SetLineColor(imod+1);
865                         pyimcc4->Draw("same");
866                 }
867                 
868                 c5cc->cd(5) ;
869                 binmin =  (Int_t) (4-emin)*nebins/emax;
870                 binmax =  (Int_t) (5-emin)*nebins/emax;
871                 TH1D *pyimcc5cc = fhIMCellCut->ProjectionY("pyimcc5cc",binmin,binmax);
872                 pyimcc5cc->SetTitle("4< E_{pair} < 5 GeV");
873                 pyimcc5cc->SetLineColor(1);
874                 pyimcc5cc->Draw();
875                 for(Int_t imod = 0; imod < fNModules; imod++){
876                         pyimcc5cc = fhIMCellCutMod[imod]->ProjectionY(Form("pyimcc5cc_%d",imod),binmin,binmax);
877                         pyimcc5cc->SetLineColor(imod+1);
878                         pyimcc5cc->Draw("same");
879                 }
880                 
881                 c5cc->cd(6) ;
882                 binmin =  (Int_t) (5-emin)*nebins/emax;
883                 binmax =  -1;
884                 TH1D *pyimcc10 = fhIMCellCut->ProjectionY("pyimcc10",binmin,binmax);
885                 pyimcc10->SetTitle("E_{pair} > 5 GeV");
886                 pyimcc10->SetLineColor(1);
887                 pyimcc10->Draw();
888                 for(Int_t imod = 0; imod < fNModules; imod++){
889                         pyimcc10 = fhIMCellCutMod[imod]->ProjectionY(Form("pyimcc10_%d",imod),binmin,binmax);
890                         pyimcc10->SetLineColor(imod+1);
891                         pyimcc10->Draw("same");
892                 }
893                 
894                 sprintf(name,"QA_%s_InvariantMass_CellCut.eps",fCalorimeter.Data());
895                 c5cc->Print(name); printf("Plot: %s\n",name);
896         }
897         //Asymmetry
898         //printf("c5b\n");
899         if(fhAsym->GetEntries() > 1){
900                 Int_t nebins  = fhAsym->GetNbinsX();
901                 Int_t emax = (Int_t) fhAsym->GetXaxis()->GetXmax();
902                 Int_t emin = (Int_t) fhAsym->GetXaxis()->GetXmin();
903                 if (emin != 0 ) printf("emin != 0 \n");
904                 //printf("Asym: nBinsX %d, emin %2.2f, emax %2.2f\n",nebins,emin,emax);
905                 
906                 sprintf(cname,"QA_%s_Asym",fCalorimeter.Data());
907                 //      printf("c5\n");
908                 TCanvas  * c5b = new TCanvas(cname, "Asymmetry", 400, 400) ;
909                 c5b->Divide(2, 2);
910                 
911                 c5b->cd(1) ; 
912                 fhAsym->SetTitleOffset(1.6,"Y");
913                 fhAsym->SetLineColor(4);
914                 fhAsym->Draw();
915                 
916                 c5b->cd(2) ; 
917                 binmin = 0;
918                 binmax = (Int_t) (5-emin)*nebins/emax;
919                 TH1D *pyAsym5 = fhAsym->ProjectionY("pyAsym5",binmin,binmax);
920                 pyAsym5->SetTitle("E_{pair} < 5 GeV");
921                 pyAsym5->SetLineColor(4);
922                 pyAsym5->Draw();
923                 
924                 c5b->cd(3) ; 
925                 binmin = (Int_t) (5-emin)*nebins/emax;
926                 binmax = (Int_t) (10-emin)*nebins/emax;
927                 TH1D *pyAsym510 = fhAsym->ProjectionY("pyAsym5_10",binmin,binmax);
928                 pyAsym510->SetTitle("5 < E_{pair} < 10 GeV");
929                 pyAsym510->SetLineColor(4);
930                 pyAsym510->Draw();
931                 
932                 c5b->cd(4) ;
933                 binmin = (Int_t) (10-emin)*nebins/emax;
934                 binmax = -1;
935                 TH1D *pyAsym10 = fhAsym->ProjectionY("pyAsym10",binmin,binmax);
936                 pyAsym10->SetTitle("E_{pair} > 10 GeV");
937                 pyAsym10->SetLineColor(4);
938                 pyAsym10->Draw();
939                 
940                 sprintf(name,"QA_%s_Asymmetry.eps",fCalorimeter.Data());
941                 c5b->Print(name);
942         }
943                 
944         
945         //CaloCells
946         //printf("c9\n");
947         sprintf(cname,"QA_%s_nclustercellsamp",fCalorimeter.Data());
948         TCanvas  * c9 = new TCanvas(cname, " CaloClusters and CaloCells", 400, 400) ;
949         c9->Divide(2, 2);
950         
951         c9->cd(1) ; 
952         
953         TLegend pLegendN(0.7,0.6,0.9,0.8);
954         pLegendN.SetTextSize(0.03);
955         pLegendN.AddEntry(fhNClusters,"all modules","L");
956         pLegendN.SetFillColor(10);
957         pLegendN.SetBorderSize(1);
958         
959         if(fhNClusters->GetEntries() > 0) gPad->SetLogy();
960         gPad->SetLogx();
961         fhNClusters->SetLineColor(1);
962         fhNClusters->Draw();
963         for(Int_t imod = 0; imod < fNModules; imod++){
964                 fhNClustersMod[imod]->SetLineColor(imod+1);
965                 fhNClustersMod[imod]->Draw("same");
966                 pLegendN.AddEntry(fhNClustersMod[imod],Form("module %d",imod),"L");
967         }
968         pLegendN.Draw();
969         
970         c9->cd(2) ; 
971         if(fhNCells->GetEntries() > 0) gPad->SetLogy();
972         gPad->SetLogx();
973         fhNCells->SetLineColor(1);
974         fhNCells->Draw();
975         for(Int_t imod = 0; imod < fNModules; imod++){
976                 fhNCellsMod[imod]->SetLineColor(imod+1);
977                 fhNCellsMod[imod]->Draw("same");
978         }
979         c9->cd(3) ; 
980         if(fhNCellsPerCluster->GetEntries() > 0) gPad->SetLogy();
981         gPad->SetLogx();
982         TH1D *cpc = fhNCellsPerCluster->ProjectionY("cpc",-1,-1);
983         cpc->SetLineColor(1);
984         cpc->Draw();
985         for(Int_t imod = 0; imod < fNModules; imod++){
986                 cpc = fhNCellsPerClusterMod[imod]->ProjectionY(Form("cpc_%d",imod),-1,-1);
987                 cpc->SetLineColor(imod+1);
988                 cpc->Draw("same");
989         }
990         
991         c9->cd(4) ; 
992         if(fhAmplitude->GetEntries() > 0) gPad->SetLogy();
993         gPad->SetLogx();
994         fhAmplitude->SetLineColor(1);
995         fhAmplitude->Draw();
996         for(Int_t imod = 0; imod < fNModules; imod++){
997                 fhAmplitudeMod[imod]->SetLineColor(imod+1);
998                 fhAmplitudeMod[imod]->Draw("same");
999         }
1000         
1001         sprintf(name,"QA_%s_CaloClustersAndCaloCells.eps",fCalorimeter.Data());
1002         c9->Print(name); printf("Plot: %s\n",name);
1003
1004         if(fCorrelateCalos){
1005                 //Calorimeter Correlation, PHOS vs EMCAL
1006                 sprintf(cname,"QA_%s_CaloCorr_EMCALvsPHOS",fCalorimeter.Data());
1007                 TCanvas  * ccorr = new TCanvas(cname, " EMCAL vs PHOS", 400, 400) ;
1008                 ccorr->Divide(2, 2);
1009                 
1010                 ccorr->cd(1) ; 
1011                 //gPad->SetLogy();
1012                 //gPad->SetLogx();
1013                 fhCaloCorrNClusters ->Draw();
1014                 
1015                 ccorr->cd(2) ; 
1016                 //gPad->SetLogy();
1017                 //gPad->SetLogx();
1018                 fhCaloCorrNCells->Draw();
1019                 
1020                 ccorr->cd(3) ; 
1021                 //gPad->SetLogy();
1022                 //gPad->SetLogx();
1023                 fhCaloCorrEClusters->Draw();
1024                 
1025                 ccorr->cd(4) ; 
1026                 //gPad->SetLogy();
1027                 //gPad->SetLogx();
1028                 fhCaloCorrECells->Draw();
1029                 
1030                 sprintf(name,"QA_%s_CaloCorr_EMCALvsPHOS.eps",fCalorimeter.Data());
1031                 ccorr->Print(name); printf("Plot: %s\n",name);
1032         }
1033         
1034         //Grid of cell per module plots 
1035     {
1036                 gStyle->SetOptStat(0);
1037                 sprintf(cname,"QA_%s_GridCellEntries",fCalorimeter.Data());
1038                 //      printf("c5\n");
1039                 TCanvas *cgrid   = new TCanvas("cgrid","Number of entries per cell", 12,12,800,400);
1040                 if(fNModules%2 == 0)
1041                         cgrid->Divide(fNModules/2,2); 
1042                 else
1043                         cgrid->Divide(fNModules/2+1,2); 
1044                 
1045                 for(Int_t imod = 0; imod < fNModules ; imod++){
1046                         cgrid->cd(imod+1);
1047                         gPad->SetLogz();
1048                         gPad->SetGridy();
1049                         gPad->SetGridx();
1050                         fhGridCellsMod[imod]->SetLabelSize(0.025,"z");
1051                         fhGridCellsMod[imod]->Draw("colz");
1052                 }
1053                 sprintf(name,"QA_%s_GridCellsEntries.eps",fCalorimeter.Data());
1054                 cgrid->Print(name); printf("Plot: %s\n",name);
1055                 
1056                 sprintf(cname,"QA_%s_GridCellAccumEnergy",fCalorimeter.Data());
1057                 //      printf("c5\n");
1058                 TCanvas *cgridE   = new TCanvas("cgridE","Summed energy per cell", 12,12,800,400);
1059                 cgridE->Divide(fNModules/2,2); 
1060                 for(Int_t imod = 0; imod < fNModules ; imod++){
1061                         cgridE->cd(imod+1);
1062                         gPad->SetLogz();
1063                         gPad->SetGridy();
1064                         gPad->SetGridx();
1065                         fhGridCellsEMod[imod]->SetLabelSize(0.025,"z");
1066                         fhGridCellsEMod[imod]->Draw("colz");
1067                 }
1068                 sprintf(name,"QA_%s_GridCellsAccumEnergy.eps",fCalorimeter.Data());
1069                 cgridE->Print(name); printf("Plot: %s\n",name);
1070                 
1071                 sprintf(cname,"QA_%s_GridCellAverageEnergy",fCalorimeter.Data());
1072                 //      printf("c5\n");
1073                 TCanvas *cgridEA   = new TCanvas("cgridEA","Average energy per cell", 12,12,800,400);
1074                 cgridEA->Divide(fNModules/2,2); 
1075                 for(Int_t imod = 0; imod < fNModules ; imod++){
1076                         cgridEA->cd(imod+1);
1077                         gPad->SetLogz();
1078                         gPad->SetGridy();
1079                         gPad->SetGridx();
1080                         fhGridCellsEMod[imod]->SetLabelSize(0.025,"z");
1081                         fhGridCellsEMod[imod]->Divide(fhGridCellsMod[imod]);
1082                         fhGridCellsEMod[imod]->Draw("colz");
1083                 }
1084                 sprintf(name,"QA_%s_GridCellsAverageEnergy.eps",fCalorimeter.Data());
1085                 cgridEA->Print(name); printf("Plot: %s\n",name);
1086                 
1087         }       
1088         
1089         if(isDataMC){
1090           //Reconstructed vs MC distributions
1091           //printf("c6\n");
1092           sprintf(cname,"QA_%s_recvsmc",fCalorimeter.Data());
1093           TCanvas  * c6 = new TCanvas(cname, "Reconstructed vs MC distributions", 400, 400) ;
1094           c6->Divide(2, 2);
1095           
1096           fh2E->SetAxisRange(minx,maxx,"X");
1097           fh2Pt->SetAxisRange(minx,maxx,"X");
1098           fh2E->SetAxisRange(minx,maxx,"Y");
1099           fh2Pt->SetAxisRange(minx,maxx,"Y");
1100           
1101           c6->cd(1) ; 
1102           fh2E->SetTitleOffset(1.6,"Y");
1103           fh2E->SetLineColor(4);
1104           fh2E->Draw();
1105           
1106           c6->cd(2) ; 
1107           fh2Pt->SetTitleOffset(1.6,"Y");
1108           fh2Pt->SetLineColor(4);
1109           fh2Pt->Draw();
1110           
1111           c6->cd(3) ; 
1112           fh2Phi->SetTitleOffset(1.6,"Y");
1113           fh2Phi->SetLineColor(4);
1114           fh2Phi->Draw();
1115           
1116           c6->cd(4) ; 
1117           fh2Eta->SetTitleOffset(1.6,"Y");
1118           fh2Eta->SetLineColor(4);
1119           fh2Eta->Draw();
1120           
1121           sprintf(name,"QA_%s_ReconstructedVSMCDistributions.eps",fCalorimeter.Data());
1122           c6->Print(name);      
1123           
1124           //Reconstructed vs MC distributions
1125           //printf("c6\n");
1126           sprintf(cname,"QA_%s_gamrecvsmc",fCalorimeter.Data());
1127           TCanvas  * c6Gam = new TCanvas(cname, "Reconstructed vs MC distributions", 400, 400) ;
1128           c6Gam->Divide(2, 2);
1129           
1130           fhGamE->SetAxisRange(minx,maxx,"X");
1131           fhGamPt->SetAxisRange(minx,maxx,"X");
1132           
1133           c6Gam->cd(1) ; 
1134           fhGamE->Draw();
1135           
1136           c6Gam->cd(2) ; 
1137           fhGamPt->Draw();
1138           
1139           c6Gam->cd(3) ; 
1140           fhGamPhi->Draw();
1141           
1142           c6Gam->cd(4) ; 
1143           fhGamEta->Draw();
1144           
1145           sprintf(name,"QA_%s_GammaReconstructedVSMCDistributions.eps",fCalorimeter.Data());
1146           c6->Print(name);      
1147           
1148           //Generated - reconstructed  
1149           //printf("c7\n");
1150           sprintf(cname,"QA_%s_diffgenrec",fCalorimeter.Data());
1151           TCanvas  * c7 = new TCanvas(cname, "generated - reconstructed", 400, 400) ;
1152           c7->Divide(2, 2);
1153           
1154           c7->cd(1) ; 
1155           gPad->SetLogy();
1156           fhGamDeltaE->SetLineColor(4);
1157           fhDeltaE->Draw();
1158           fhGamDeltaE->Draw("same");
1159           
1160           TLegend pLegendd(0.65,0.55,0.9,0.8);
1161           pLegendd.SetTextSize(0.06);
1162           pLegendd.AddEntry(fhDeltaE,"all","L");
1163           pLegendd.AddEntry(fhGamDeltaE,"from  #gamma","L");
1164           pLegendd.SetFillColor(10);
1165           pLegendd.SetBorderSize(1);
1166           pLegendd.Draw();
1167           
1168           c7->cd(2) ; 
1169           gPad->SetLogy();
1170           fhGamDeltaPt->SetLineColor(4);
1171           fhDeltaPt->Draw();
1172           fhGamDeltaPt->Draw("same");
1173           
1174           c7->cd(3) ; 
1175           gPad->SetLogy();
1176           fhGamDeltaPhi->SetLineColor(4);
1177           fhDeltaPhi->Draw();
1178           fhGamDeltaPhi->Draw("same");
1179           
1180           c7->cd(4) ; 
1181           gPad->SetLogy();
1182           fhGamDeltaEta->SetLineColor(4);
1183           fhDeltaEta->Draw();
1184           fhGamDeltaEta->Draw("same");
1185           
1186           sprintf(name,"QA_%s_DiffGeneratedReconstructed.eps",fCalorimeter.Data());
1187           c7->Print(name);
1188           
1189           // Reconstructed / Generated 
1190           //printf("c8\n");
1191           sprintf(cname,"QA_%s_ratiorecgen",fCalorimeter.Data());
1192           TCanvas  * c8 = new TCanvas(cname, " reconstructed / generated", 400, 400) ;
1193           c8->Divide(2, 2);
1194           
1195           c8->cd(1) ; 
1196           gPad->SetLogy();
1197           fhGamRatioE->SetLineColor(4);
1198           fhRatioE->Draw();
1199           fhGamRatioE->Draw("same");
1200           
1201           TLegend pLegendr(0.65,0.55,0.9,0.8);
1202           pLegendr.SetTextSize(0.06);
1203           pLegendr.AddEntry(fhRatioE,"all","L");
1204           pLegendr.AddEntry(fhGamRatioE,"from  #gamma","L");
1205           pLegendr.SetFillColor(10);
1206           pLegendr.SetBorderSize(1);
1207           pLegendr.Draw();
1208           
1209           c8->cd(2) ; 
1210           gPad->SetLogy();
1211           fhGamRatioPt->SetLineColor(4);
1212           fhRatioPt->Draw();
1213           fhGamRatioPt->Draw("same");
1214           
1215           c8->cd(3) ; 
1216           fhGamRatioPhi->SetLineColor(4);
1217           fhRatioPhi->Draw();
1218           fhGamRatioPhi->Draw("same");
1219           
1220           c8->cd(4) ; 
1221           fhGamRatioEta->SetLineColor(4);
1222           fhRatioEta->Draw();
1223           fhGamRatioEta->Draw("same");
1224           
1225           sprintf(name,"QA_%s_ReconstructedDivGenerated.eps",fCalorimeter.Data());
1226           c8->Print(name);
1227           
1228           
1229           //Generated distributions
1230           //printf("c1\n");
1231           sprintf(cname,"QA_%s_gen",fCalorimeter.Data());
1232           TCanvas  * c10 = new TCanvas(cname, "Generated distributions", 600, 200) ;
1233           c10->Divide(3, 1);
1234           
1235           c10->cd(1) ; 
1236           gPad->SetLogy();
1237           TH1F * haxispt  = (TH1F*) fhGenPi0Pt->Clone("axispt");  
1238           haxispt->SetTitle("Generated Particles p_{T}, |#eta| < 1");
1239           fhGenPi0Pt->SetLineColor(1);
1240           fhGenGamPt->SetLineColor(4);
1241           fhGenEtaPt->SetLineColor(2);
1242           fhGenOmegaPt->SetLineColor(7);
1243           fhGenElePt->SetLineColor(6);
1244           
1245           //Select the maximum of the histogram to show all lines.
1246           if(fhGenPi0Pt->GetMaximum() >= fhGenGamPt->GetMaximum() && fhGenPi0Pt->GetMaximum() >= fhGenEtaPt->GetMaximum() && 
1247              fhGenPi0Pt->GetMaximum() >= fhGenOmegaPt->GetMaximum() && fhGenPi0Pt->GetMaximum() >= fhGenElePt->GetMaximum())
1248             haxispt->SetMaximum(fhGenPi0Pt->GetMaximum());
1249           else if(fhGenGamPt->GetMaximum() >= fhGenPi0Pt->GetMaximum() && fhGenGamPt->GetMaximum() >= fhGenEtaPt->GetMaximum() && 
1250                   fhGenGamPt->GetMaximum() >= fhGenOmegaPt->GetMaximum() && fhGenGamPt->GetMaximum() >= fhGenElePt->GetMaximum())
1251             haxispt->SetMaximum(fhGenGamPt->GetMaximum());
1252           else if(fhGenEtaPt->GetMaximum() >= fhGenPi0Pt->GetMaximum() && fhGenEtaPt->GetMaximum() >= fhGenGamPt->GetMaximum() && 
1253                   fhGenEtaPt->GetMaximum() >= fhGenOmegaPt->GetMaximum() && fhGenEtaPt->GetMaximum() >= fhGenElePt->GetMaximum())
1254             haxispt->SetMaximum(fhGenEtaPt->GetMaximum());      
1255           else if(fhGenOmegaPt->GetMaximum() >= fhGenPi0Pt->GetMaximum() && fhGenOmegaPt->GetMaximum() >= fhGenEtaPt->GetMaximum() && 
1256                   fhGenOmegaPt->GetMaximum() >= fhGenGamPt->GetMaximum() && fhGenOmegaPt->GetMaximum() >= fhGenElePt->GetMaximum())
1257             haxispt->SetMaximum(fhGenOmegaPt->GetMaximum());
1258           else if(fhGenElePt->GetMaximum() >= fhGenPi0Pt->GetMaximum() && fhGenElePt->GetMaximum() >= fhGenEtaPt->GetMaximum() && 
1259                   fhGenElePt->GetMaximum() >= fhGenOmegaPt->GetMaximum() && fhGenElePt->GetMaximum() >= fhGenGamPt->GetMaximum())
1260             haxispt->SetMaximum(fhGenElePt->GetMaximum());
1261           haxispt->SetMinimum(1);
1262           haxispt->SetAxisRange(minx,maxx,"X"); 
1263           haxispt->Draw("axis");
1264           fhGenPi0Pt->Draw("same");
1265           fhGenGamPt->Draw("same");
1266           fhGenEtaPt->Draw("same");
1267           fhGenOmegaPt->Draw("same");
1268           fhGenElePt->Draw("same");
1269           
1270           TLegend pLegend(0.85,0.65,0.95,0.93);
1271           pLegend.SetTextSize(0.06);
1272           pLegend.AddEntry(fhGenPi0Pt,"  #pi^{0}","L");
1273           pLegend.AddEntry(fhGenGamPt,"  #gamma","L");
1274           pLegend.AddEntry(fhGenEtaPt,"  #eta","L");
1275           pLegend.AddEntry(fhGenOmegaPt,"  #omega","L");
1276           pLegend.AddEntry(fhGenElePt,"  e^{#pm}","L");
1277           pLegend.SetFillColor(10);
1278           pLegend.SetBorderSize(1);
1279           pLegend.Draw();
1280           
1281           c10->cd(2) ;
1282           gPad->SetLogy();
1283           TH1F * haxiseta  = (TH1F*) fhGenPi0Eta->Clone("axiseta");  
1284           haxiseta->SetTitle("Generated Particles #eta, |#eta| < 1");
1285           fhGenPi0Eta->SetLineColor(1);
1286           fhGenGamEta->SetLineColor(4);
1287           fhGenEtaEta->SetLineColor(2);
1288           fhGenOmegaEta->SetLineColor(7);
1289           fhGenEleEta->SetLineColor(6);
1290           //Select the maximum of the histogram to show all lines.
1291           if(fhGenPi0Eta->GetMaximum() >= fhGenGamEta->GetMaximum() && fhGenPi0Eta->GetMaximum() >= fhGenEtaEta->GetMaximum() && 
1292              fhGenPi0Eta->GetMaximum() >= fhGenOmegaEta->GetMaximum() && fhGenPi0Eta->GetMaximum() >= fhGenEleEta->GetMaximum())
1293             haxiseta->SetMaximum(fhGenPi0Eta->GetMaximum());
1294           else if(fhGenGamEta->GetMaximum() >= fhGenPi0Eta->GetMaximum() && fhGenGamEta->GetMaximum() >= fhGenEtaEta->GetMaximum() && 
1295                   fhGenGamEta->GetMaximum() >= fhGenOmegaEta->GetMaximum() && fhGenGamEta->GetMaximum() >= fhGenEleEta->GetMaximum())
1296             haxiseta->SetMaximum(fhGenGamEta->GetMaximum());
1297           else if(fhGenEtaEta->GetMaximum() >= fhGenPi0Eta->GetMaximum() && fhGenEtaEta->GetMaximum() >= fhGenGamEta->GetMaximum() && 
1298                   fhGenEtaEta->GetMaximum() >= fhGenOmegaEta->GetMaximum() && fhGenEtaEta->GetMaximum() >= fhGenEleEta->GetMaximum())
1299             haxiseta->SetMaximum(fhGenEtaEta->GetMaximum());    
1300           else if(fhGenOmegaEta->GetMaximum() >= fhGenPi0Eta->GetMaximum() && fhGenOmegaEta->GetMaximum() >= fhGenEtaEta->GetMaximum() && 
1301                   fhGenOmegaEta->GetMaximum() >= fhGenGamEta->GetMaximum() && fhGenOmegaEta->GetMaximum() >= fhGenEleEta->GetMaximum())
1302             haxiseta->SetMaximum(fhGenOmegaEta->GetMaximum());
1303           else if(fhGenEleEta->GetMaximum() >= fhGenPi0Eta->GetMaximum() && fhGenEleEta->GetMaximum() >= fhGenEtaEta->GetMaximum() && 
1304                   fhGenEleEta->GetMaximum() >= fhGenOmegaEta->GetMaximum() && fhGenEleEta->GetMaximum() >= fhGenGamEta->GetMaximum())
1305             haxiseta->SetMaximum(fhGenEleEta->GetMaximum());
1306           haxiseta->SetMinimum(100);
1307           haxiseta->Draw("axis");
1308           fhGenPi0Eta->Draw("same");
1309           fhGenGamEta->Draw("same");
1310           fhGenEtaEta->Draw("same");
1311           fhGenOmegaEta->Draw("same");
1312           fhGenEleEta->Draw("same");
1313           
1314           
1315           c10->cd(3) ; 
1316           gPad->SetLogy();
1317           TH1F * haxisphi  = (TH1F*) fhGenPi0Phi->Clone("axisphi");  
1318           haxisphi->SetTitle("Generated Particles #phi, |#eta| < 1");
1319           fhGenPi0Phi->SetLineColor(1);
1320           fhGenGamPhi->SetLineColor(4);
1321           fhGenEtaPhi->SetLineColor(2);
1322           fhGenOmegaPhi->SetLineColor(7);
1323           fhGenElePhi->SetLineColor(6);
1324           //Select the maximum of the histogram to show all lines.
1325           if(fhGenPi0Phi->GetMaximum() >= fhGenGamPhi->GetMaximum() && fhGenPi0Phi->GetMaximum() >= fhGenEtaPhi->GetMaximum() && 
1326              fhGenPi0Phi->GetMaximum() >= fhGenOmegaPhi->GetMaximum() && fhGenPi0Phi->GetMaximum() >= fhGenElePhi->GetMaximum())
1327             haxisphi->SetMaximum(fhGenPi0Phi->GetMaximum());
1328           else if(fhGenGamPhi->GetMaximum() >= fhGenPi0Phi->GetMaximum() && fhGenGamPhi->GetMaximum() >= fhGenEtaPhi->GetMaximum() && 
1329                   fhGenGamPhi->GetMaximum() >= fhGenOmegaPhi->GetMaximum() && fhGenGamPhi->GetMaximum() >= fhGenElePhi->GetMaximum())
1330             haxisphi->SetMaximum(fhGenGamPhi->GetMaximum());
1331           else if(fhGenEtaPhi->GetMaximum() >= fhGenPi0Phi->GetMaximum() && fhGenEtaPhi->GetMaximum() >= fhGenGamPhi->GetMaximum() && 
1332                   fhGenEtaPhi->GetMaximum() >= fhGenOmegaPhi->GetMaximum() && fhGenEtaPhi->GetMaximum() >= fhGenElePhi->GetMaximum())
1333             haxisphi->SetMaximum(fhGenEtaPhi->GetMaximum());    
1334           else if(fhGenOmegaPhi->GetMaximum() >= fhGenPi0Phi->GetMaximum() && fhGenOmegaPhi->GetMaximum() >= fhGenEtaPhi->GetMaximum() && 
1335                   fhGenOmegaPhi->GetMaximum() >= fhGenGamPhi->GetMaximum() && fhGenOmegaPhi->GetMaximum() >= fhGenElePhi->GetMaximum())
1336             haxisphi->SetMaximum(fhGenOmegaPhi->GetMaximum());
1337           else if(fhGenElePhi->GetMaximum() >= fhGenPi0Phi->GetMaximum() && fhGenElePhi->GetMaximum() >= fhGenEtaPhi->GetMaximum() && 
1338                   fhGenElePhi->GetMaximum() >= fhGenOmegaPhi->GetMaximum() && fhGenElePhi->GetMaximum() >= fhGenGamPhi->GetMaximum())
1339             haxisphi->SetMaximum(fhGenElePhi->GetMaximum());
1340           haxisphi->SetMinimum(100);
1341           haxisphi->Draw("axis");
1342           fhGenPi0Phi->Draw("same");
1343           fhGenGamPhi->Draw("same");
1344           fhGenEtaPhi->Draw("same");
1345           fhGenOmegaPhi->Draw("same");
1346           fhGenElePhi->Draw("same");
1347           
1348           sprintf(name,"QA_%s_GeneratedDistributions.eps",fCalorimeter.Data());
1349           c10->Print(name);
1350           
1351           
1352           //Reconstructed clusters depending on its original particle.
1353           //printf("c1\n");
1354           sprintf(cname,"QA_%s_recgenid",fCalorimeter.Data());
1355           TCanvas  * c11 = new TCanvas(cname, "Reconstructed particles, function of their original particle ID", 400, 400) ;
1356           c11->Divide(2, 2);
1357           
1358           
1359           c11->cd(1) ; 
1360           gPad->SetLogy();
1361           TH1F * hGamE   = (TH1F*) fhGamE->ProjectionX("hGamE",-1,-1);
1362           TH1F * hPi0E   = (TH1F*) fhPi0E->ProjectionX("hPi0E",-1,-1);
1363           TH1F * hEleE   = (TH1F*) fhEleE->ProjectionX("hEleE",-1,-1);
1364           TH1F * hNeHadE = (TH1F*) fhNeHadE->ProjectionX("hNeHadE",-1,-1);
1365           TH1F * hChHadE = (TH1F*) fhChHadE->ProjectionX("hChHadE",-1,-1);
1366           TH1F * haxisE  = (TH1F*) hPi0E->Clone("axisE");  
1367           haxisE->SetTitle("Reconstructed particles E, function of their original particle ID");
1368           haxisE->SetAxisRange(minx,maxx,"X");  
1369           
1370           hPi0E->SetLineColor(1);
1371           hGamE->SetLineColor(4);
1372           hNeHadE->SetLineColor(2);
1373           hChHadE->SetLineColor(7);
1374           hEleE->SetLineColor(6);
1375           
1376           //Select the maximum of the histogram to show all lines.
1377           if(hPi0E->GetMaximum() >= hGamE->GetMaximum() && hPi0E->GetMaximum() >= hNeHadE->GetMaximum() && 
1378              hPi0E->GetMaximum() >= hChHadE->GetMaximum() && hPi0E->GetMaximum() >= hEleE->GetMaximum())
1379             haxisE->SetMaximum(hPi0E->GetMaximum());
1380           else if(hGamE->GetMaximum() >= hPi0E->GetMaximum() && hGamE->GetMaximum() >= hNeHadE->GetMaximum() && 
1381                   hGamE->GetMaximum() >= hChHadE->GetMaximum() && hGamE->GetMaximum() >= hEleE->GetMaximum())
1382             haxisE->SetMaximum(hGamE->GetMaximum());
1383           else if(hNeHadE->GetMaximum() >= hPi0E->GetMaximum() && hNeHadE->GetMaximum() >= hGamE->GetMaximum() && 
1384                   hNeHadE->GetMaximum() >= hChHadE->GetMaximum() && hNeHadE->GetMaximum() >= hEleE->GetMaximum())
1385             haxisE->SetMaximum(hNeHadE->GetMaximum());  
1386           else if(hChHadE->GetMaximum() >= hPi0E->GetMaximum() && hChHadE->GetMaximum() >= hNeHadE->GetMaximum() && 
1387                   hChHadE->GetMaximum() >= hGamE->GetMaximum() && hChHadE->GetMaximum() >= hEleE->GetMaximum())
1388             haxisE->SetMaximum(hChHadE->GetMaximum());
1389           else if(hEleE->GetMaximum() >= hPi0E->GetMaximum() && hEleE->GetMaximum() >= hNeHadE->GetMaximum() && 
1390                   hEleE->GetMaximum() >= hChHadE->GetMaximum() && hEleE->GetMaximum() >= hGamE->GetMaximum())
1391             haxisE->SetMaximum(hEleE->GetMaximum());
1392           haxisE->SetXTitle("E (GeV)");
1393           haxisE->SetMinimum(1);
1394           haxisE->Draw("axis");
1395           hPi0E->Draw("same");
1396           hGamE->Draw("same");
1397           hNeHadE->Draw("same");
1398           hChHadE->Draw("same");
1399           hEleE->Draw("same");
1400           
1401           TLegend pLegend2(0.8,0.65,0.95,0.93);
1402           pLegend2.SetTextSize(0.06);
1403           pLegend2.AddEntry(hPi0E,"  #pi^{0}","L");
1404           pLegend2.AddEntry(hGamE,"  #gamma","L");
1405           pLegend2.AddEntry(hEleE,"  e^{#pm}","L");
1406           pLegend2.AddEntry(hChHadE,"  h^{#pm}","L");
1407           pLegend2.AddEntry(hNeHadE,"  h^{0}","L");
1408           pLegend2.SetFillColor(10);
1409           pLegend2.SetBorderSize(1);
1410           pLegend2.Draw();
1411           
1412           
1413           c11->cd(2) ; 
1414           gPad->SetLogy();
1415           //printf("%s, %s, %s, %s, %s\n",fhGamPt->GetName(),fhPi0Pt->GetName(),fhElePt->GetName(),fhNeHadPt->GetName(), fhChHadPt->GetName());
1416           TH1F * hGamPt   = (TH1F*) fhGamPt->ProjectionX("hGamPt",-1,-1);
1417           TH1F * hPi0Pt   = (TH1F*) fhPi0Pt->ProjectionX("hPi0Pt",-1,-1);
1418           TH1F * hElePt   = (TH1F*) fhElePt->ProjectionX("hElePt",-1,-1);
1419           TH1F * hNeHadPt = (TH1F*) fhNeHadPt->ProjectionX("hNeHadPt",-1,-1);
1420           TH1F * hChHadPt = (TH1F*) fhChHadPt->ProjectionX("hChHadPt",-1,-1);
1421           haxispt  = (TH1F*) hPi0Pt->Clone("axispt");  
1422           haxispt->SetTitle("Reconstructed particles p_{T}, function of their original particle ID");
1423           hPi0Pt->SetLineColor(1);
1424           hGamPt->SetLineColor(4);
1425           hNeHadPt->SetLineColor(2);
1426           hChHadPt->SetLineColor(7);
1427           hElePt->SetLineColor(6);
1428           
1429           //Select the maximum of the histogram to show all lines.
1430           if(hPi0Pt->GetMaximum() >= hGamPt->GetMaximum() && hPi0Pt->GetMaximum() >= hNeHadPt->GetMaximum() && 
1431              hPi0Pt->GetMaximum() >= hChHadPt->GetMaximum() && hPi0Pt->GetMaximum() >= hElePt->GetMaximum())
1432             haxispt->SetMaximum(hPi0Pt->GetMaximum());
1433           else if(hGamPt->GetMaximum() >= hPi0Pt->GetMaximum() && hGamPt->GetMaximum() >= hNeHadPt->GetMaximum() && 
1434                   hGamPt->GetMaximum() >= hChHadPt->GetMaximum() && hGamPt->GetMaximum() >= hElePt->GetMaximum())
1435             haxispt->SetMaximum(hGamPt->GetMaximum());
1436           else if(hNeHadPt->GetMaximum() >= hPi0Pt->GetMaximum() && hNeHadPt->GetMaximum() >= hGamPt->GetMaximum() && 
1437                   hNeHadPt->GetMaximum() >= hChHadPt->GetMaximum() && hNeHadPt->GetMaximum() >= hElePt->GetMaximum())
1438             haxispt->SetMaximum(hNeHadPt->GetMaximum());        
1439           else if(hChHadPt->GetMaximum() >= hPi0Pt->GetMaximum() && hChHadPt->GetMaximum() >= hNeHadPt->GetMaximum() && 
1440                   hChHadPt->GetMaximum() >= hGamPt->GetMaximum() && hChHadPt->GetMaximum() >= hElePt->GetMaximum())
1441             haxispt->SetMaximum(hChHadPt->GetMaximum());
1442           else if(hElePt->GetMaximum() >= hPi0Pt->GetMaximum() && hElePt->GetMaximum() >= hNeHadPt->GetMaximum() && 
1443                   hElePt->GetMaximum() >= hChHadPt->GetMaximum() && hElePt->GetMaximum() >= hGamPt->GetMaximum())
1444             haxispt->SetMaximum(hElePt->GetMaximum());
1445           haxispt->SetXTitle("p_{T} (GeV/c)");
1446           haxispt->SetMinimum(1);
1447           haxispt->SetAxisRange(minx,maxx,"X");
1448           haxispt->Draw("axis");
1449           hPi0Pt->Draw("same");
1450           hGamPt->Draw("same");
1451           hNeHadPt->Draw("same");
1452           hChHadPt->Draw("same");
1453           hElePt->Draw("same");
1454           
1455           
1456           c11->cd(3) ;
1457           gPad->SetLogy();
1458           
1459           TH1F * hGamEta   = (TH1F*) fhGamEta->ProjectionX("hGamEta",-1,-1);
1460           TH1F * hPi0Eta   = (TH1F*) fhPi0Eta->ProjectionX("hPi0Eta",-1,-1);
1461           TH1F * hEleEta   = (TH1F*) fhEleEta->ProjectionX("hEleEta",-1,-1);
1462           TH1F * hNeHadEta = (TH1F*) fhNeHadEta->ProjectionX("hNeHadEta",-1,-1);
1463           TH1F * hChHadEta = (TH1F*) fhChHadEta->ProjectionX("hChHadEta",-1,-1);
1464           haxiseta  = (TH1F*) hPi0Eta->Clone("axiseta");  
1465           haxiseta->SetTitle("Reconstructed particles #eta, function of their original particle ID");
1466           hPi0Eta->SetLineColor(1);
1467           hGamEta->SetLineColor(4);
1468           hNeHadEta->SetLineColor(2);
1469           hChHadEta->SetLineColor(7);
1470           hEleEta->SetLineColor(6);
1471           //Select the maximum of the histogram to show all lines.
1472           if(hPi0Eta->GetMaximum() >= hGamEta->GetMaximum() && hPi0Eta->GetMaximum() >= hNeHadEta->GetMaximum() && 
1473              hPi0Eta->GetMaximum() >= hChHadEta->GetMaximum() && hPi0Eta->GetMaximum() >= hEleEta->GetMaximum())
1474             haxiseta->SetMaximum(hPi0Eta->GetMaximum());
1475           else if(hGamEta->GetMaximum() >= hPi0Eta->GetMaximum() && hGamEta->GetMaximum() >= hNeHadEta->GetMaximum() && 
1476                   hGamEta->GetMaximum() >= hChHadEta->GetMaximum() && hGamEta->GetMaximum() >= hEleEta->GetMaximum())
1477             haxiseta->SetMaximum(hGamEta->GetMaximum());
1478           else if(hNeHadEta->GetMaximum() >= hPi0Eta->GetMaximum() && hNeHadEta->GetMaximum() >= hGamEta->GetMaximum() && 
1479                   hNeHadEta->GetMaximum() >= hChHadEta->GetMaximum() && hNeHadEta->GetMaximum() >= hEleEta->GetMaximum())
1480             haxiseta->SetMaximum(hNeHadEta->GetMaximum());      
1481           else if(hChHadEta->GetMaximum() >= hPi0Eta->GetMaximum() && hChHadEta->GetMaximum() >= hNeHadEta->GetMaximum() && 
1482                   hChHadEta->GetMaximum() >= hGamEta->GetMaximum() && hChHadEta->GetMaximum() >= hEleEta->GetMaximum())
1483             haxiseta->SetMaximum(hChHadEta->GetMaximum());
1484           else if(hEleEta->GetMaximum() >= hPi0Eta->GetMaximum() && hEleEta->GetMaximum() >= hNeHadEta->GetMaximum() && 
1485                   hEleEta->GetMaximum() >= hChHadEta->GetMaximum() && hEleEta->GetMaximum() >= hGamEta->GetMaximum())
1486             haxiseta->SetMaximum(hEleEta->GetMaximum());
1487           
1488           haxiseta->SetXTitle("#eta");
1489           haxiseta->Draw("axis");
1490           hPi0Eta->Draw("same");
1491           hGamEta->Draw("same");
1492           hNeHadEta->Draw("same");
1493           hChHadEta->Draw("same");
1494           hEleEta->Draw("same");
1495           
1496           
1497           c11->cd(4) ; 
1498           gPad->SetLogy();
1499           TH1F * hGamPhi   = (TH1F*) fhGamPhi->ProjectionX("hGamPhi",-1,-1);
1500           TH1F * hPi0Phi   = (TH1F*) fhPi0Phi->ProjectionX("hPi0Phi",-1,-1);
1501           TH1F * hElePhi   = (TH1F*) fhElePhi->ProjectionX("hElePhi",-1,-1);
1502           TH1F * hNeHadPhi = (TH1F*) fhNeHadPhi->ProjectionX("hNeHadPhi",-1,-1);
1503           TH1F * hChHadPhi = (TH1F*) fhChHadPhi->ProjectionX("hChHadPhi",-1,-1);
1504           haxisphi  = (TH1F*) hPi0Phi->Clone("axisphi");  
1505           haxisphi->SetTitle("Reconstructed particles #phi, function of their original particle ID");
1506           
1507           hPi0Phi->SetLineColor(1);
1508           hGamPhi->SetLineColor(4);
1509           hNeHadPhi->SetLineColor(2);
1510           hChHadPhi->SetLineColor(7);
1511           hElePhi->SetLineColor(6);
1512           //Select the maximum of the histogram to show all lines.
1513           if(hPi0Phi->GetMaximum() >= hGamPhi->GetMaximum() && hPi0Phi->GetMaximum() >= hNeHadPhi->GetMaximum() && 
1514              hPi0Phi->GetMaximum() >= hChHadPhi->GetMaximum() && hPi0Phi->GetMaximum() >= hElePhi->GetMaximum())
1515             haxisphi->SetMaximum(hPi0Phi->GetMaximum());
1516           else if(hGamPhi->GetMaximum() >= hPi0Phi->GetMaximum() && hGamPhi->GetMaximum() >= hNeHadPhi->GetMaximum() && 
1517                   hGamPhi->GetMaximum() >= hChHadPhi->GetMaximum() && hGamPhi->GetMaximum() >= hElePhi->GetMaximum())
1518             haxisphi->SetMaximum(hGamPhi->GetMaximum());
1519           else if(hNeHadPhi->GetMaximum() >= hPi0Phi->GetMaximum() && hNeHadPhi->GetMaximum() >= hGamPhi->GetMaximum() && 
1520                   hNeHadPhi->GetMaximum() >= hChHadPhi->GetMaximum() && hNeHadPhi->GetMaximum() >= hElePhi->GetMaximum())
1521             haxisphi->SetMaximum(hNeHadPhi->GetMaximum());      
1522           else if(hChHadPhi->GetMaximum() >= hPi0Phi->GetMaximum() && hChHadPhi->GetMaximum() >= hNeHadPhi->GetMaximum() && 
1523                   hChHadPhi->GetMaximum() >= hGamPhi->GetMaximum() && hChHadPhi->GetMaximum() >= hElePhi->GetMaximum())
1524             haxisphi->SetMaximum(hChHadPhi->GetMaximum());
1525           else if(hElePhi->GetMaximum() >= hPi0Phi->GetMaximum() && hElePhi->GetMaximum() >= hNeHadPhi->GetMaximum() && 
1526                   hElePhi->GetMaximum() >= hChHadPhi->GetMaximum() && hElePhi->GetMaximum() >= hGamPhi->GetMaximum())
1527             haxisphi->SetMaximum(hElePhi->GetMaximum());
1528           haxisphi->SetXTitle("#phi (rad)");
1529           haxisphi->Draw("axis");
1530           hPi0Phi->Draw("same");
1531           hGamPhi->Draw("same");
1532           hNeHadPhi->Draw("same");
1533           hChHadPhi->Draw("same");
1534           hElePhi->Draw("same");
1535           
1536           sprintf(name,"QA_%s_RecDistributionsGenID.eps",fCalorimeter.Data());
1537           c11->Print(name);
1538           
1539           
1540           //Ratio reconstructed clusters / generated particles in acceptance, for different particle ID
1541           //printf("c1\n");
1542           
1543           TH1F *        hPi0EClone   = (TH1F*)   hPi0E  ->Clone("hPi0EClone");
1544           TH1F *        hGamEClone   = (TH1F*)   hGamE  ->Clone("hGamEClone");
1545           TH1F *        hPi0PtClone  = (TH1F*)   hPi0Pt ->Clone("hPi0PtClone");
1546           TH1F *        hGamPtClone  = (TH1F*)   hGamPt ->Clone("hGamPtClone"); 
1547           TH1F *        hPi0EtaClone = (TH1F*)   hPi0Eta->Clone("hPi0EtaClone");
1548           TH1F *        hGamEtaClone = (TH1F*)   hGamEta->Clone("hGamEtaClone");        
1549           TH1F *        hPi0PhiClone = (TH1F*)   hPi0Phi->Clone("hPi0PhiClone");
1550           TH1F *        hGamPhiClone = (TH1F*)   hGamPhi->Clone("hGamPhiClone");        
1551           
1552           sprintf(cname,"QA_%s_recgenidratio",fCalorimeter.Data());
1553           TCanvas  * c12 = new TCanvas(cname, "Ratio reconstructed clusters / generated particles in acceptance, for different particle ID", 400, 400) ;
1554           c12->Divide(2, 2);
1555           
1556           c12->cd(1) ; 
1557           gPad->SetLogy();
1558           haxisE->SetTitle("Ratio reconstructed clusters / generated particles in acceptance, for different particle ID");
1559           hPi0EClone->Divide(fhGenPi0AccE);
1560           hGamEClone->Divide(fhGenGamAccE);
1561           haxisE->SetMaximum(1000);
1562           haxisE->SetMinimum(1e-2);
1563           haxisE->SetXTitle("E (GeV)");
1564           haxisE->SetYTitle("ratio = rec/gen");
1565           haxisE->Draw("axis");
1566           hPi0E->Draw("same");
1567           hGamE->Draw("same");
1568         
1569           TLegend pLegend3(0.75,0.2,0.9,0.4);
1570           pLegend3.SetTextSize(0.06);
1571           pLegend3.AddEntry(hPi0EClone,"  #pi^{0}","L");
1572           pLegend3.AddEntry(hGamEClone,"  #gamma","L");
1573           pLegend3.SetFillColor(10);
1574           pLegend3.SetBorderSize(1);
1575           pLegend3.Draw();
1576           
1577           c12->cd(2) ; 
1578           gPad->SetLogy();
1579           haxispt->SetTitle("Ratio reconstructed clusters / generated particles in acceptance, for different particle ID");
1580           hPi0PtClone->Divide(fhGenPi0AccPt);
1581           hGamPtClone->Divide(fhGenGamAccPt);
1582           haxispt->SetMaximum(5);
1583           haxispt->SetMinimum(1e-2);
1584           haxispt->SetXTitle("p_{T} (GeV/c)");
1585           haxispt->SetYTitle("ratio = rec/gen");
1586           haxispt->Draw("axis");
1587           hPi0PtClone->Draw("same");
1588           hGamPtClone->Draw("same");
1589           
1590           c12->cd(3) ;
1591           gPad->SetLogy();
1592           
1593           haxiseta->SetTitle("Ratio reconstructed clusters / generated particles in acceptance, for different particle ID");
1594           hPi0EtaClone->Divide(fhGenPi0AccEta);
1595           hGamEtaClone->Divide(fhGenGamAccEta);
1596           haxiseta->SetMaximum(1.2);
1597           haxiseta->SetMinimum(1e-2);
1598           haxiseta->SetYTitle("ratio = rec/gen");
1599           haxiseta->SetXTitle("#eta");
1600           haxiseta->Draw("axis");
1601           hPi0EtaClone->Draw("same");
1602           hGamEtaClone->Draw("same");
1603           
1604           
1605           c12->cd(4) ; 
1606           gPad->SetLogy();
1607           haxisphi->SetTitle("Ratio reconstructed clusters / generated particles in acceptance, for different particle ID");
1608           hPi0PhiClone->Divide(fhGenPi0AccPhi);
1609           hGamPhiClone->Divide(fhGenGamAccPhi);
1610           haxisphi->SetYTitle("ratio = rec/gen");
1611           haxisphi->SetXTitle("#phi (rad)");
1612           haxisphi->SetMaximum(1.2);
1613           haxisphi->SetMinimum(1e-2);
1614           haxisphi->Draw("axis");
1615           hPi0PhiClone->Draw("same");
1616           hGamPhiClone->Draw("same");
1617           
1618           sprintf(name,"QA_%s_EfficiencyGenID.eps",fCalorimeter.Data());
1619           c12->Print(name);
1620           
1621           
1622           //Reconstructed distributions
1623           //printf("c1\n");
1624           sprintf(cname,"QA_%s_vertex",fCalorimeter.Data());
1625           TCanvas  * c13 = new TCanvas(cname, "Particle vertex", 400, 400) ;
1626           c13->Divide(2, 2);
1627           
1628           c13->cd(1) ; 
1629           //gPad->SetLogy();
1630           fhEMVxyz->SetTitleOffset(1.6,"Y");
1631           fhEMVxyz->Draw();
1632           
1633           c13->cd(2) ; 
1634           //gPad->SetLogy();
1635           fhHaVxyz->SetTitleOffset(1.6,"Y");
1636           fhHaVxyz->Draw();
1637           
1638           c13->cd(3) ;
1639           gPad->SetLogy();
1640           TH1F * hEMR = (TH1F*) fhEMR->ProjectionY("hEM",-1,-1); 
1641           hEMR->SetLineColor(4);
1642           hEMR->Draw();
1643           
1644           c13->cd(4) ; 
1645           gPad->SetLogy();
1646           TH1F * hHaR = (TH1F*) fhHaR->ProjectionY("hHa",-1,-1); 
1647           hHaR->SetLineColor(4);
1648           hHaR->Draw();
1649           
1650           
1651           sprintf(name,"QA_%s_ParticleVertex.eps",fCalorimeter.Data());
1652           c13->Print(name);
1653           
1654           
1655           //Track-matching distributions
1656           
1657           
1658           //Reconstructed distributions, matched with tracks, generated particle dependence
1659           //printf("c2\n");
1660           sprintf(cname,"QA_%s_rectrackmatchGenID",fCalorimeter.Data());
1661           TCanvas  * c22ch = new TCanvas(cname, "Reconstructed distributions, matched with tracks, for different particle ID", 400, 400) ;
1662           c22ch->Divide(2, 2);
1663           
1664           c22ch->cd(1) ; 
1665           
1666           TH1F * hGamECharged   = (TH1F*) fhGamECharged->ProjectionX("hGamECharged",-1,-1);
1667           TH1F * hPi0ECharged   = (TH1F*) fhPi0ECharged->ProjectionX("hPi0ECharged",-1,-1);
1668           TH1F * hEleECharged   = (TH1F*) fhEleECharged->ProjectionX("hEleECharged",-1,-1);
1669           TH1F * hNeHadECharged = (TH1F*) fhNeHadECharged->ProjectionX("hNeHadECharged",-1,-1);
1670           TH1F * hChHadECharged = (TH1F*) fhChHadECharged->ProjectionX("hChHadECharged",-1,-1);
1671           hPi0ECharged->SetLineColor(1);
1672           hGamECharged->SetLineColor(4);
1673           hNeHadECharged->SetLineColor(2);
1674           hChHadECharged->SetLineColor(7);
1675           hEleECharged->SetLineColor(6);        
1676           gPad->SetLogy();
1677           fhECharged->SetLineColor(3);
1678           fhECharged->SetMinimum(0.5);
1679           fhECharged->Draw();
1680           hPi0ECharged->Draw("same");
1681           hGamECharged->Draw("same");
1682           hNeHadECharged->Draw("same");
1683           hChHadECharged->Draw("same");
1684           hEleECharged->Draw("same");
1685           TLegend pLegend22(0.75,0.45,0.9,0.8);
1686           pLegend22.SetTextSize(0.06);
1687           pLegend22.AddEntry(fhECharged,"all","L");
1688           pLegend22.AddEntry(hPi0ECharged,"#pi^{0}","L");
1689           pLegend22.AddEntry(hGamECharged,"#gamma","L");
1690           pLegend22.AddEntry(hEleECharged,"e^{#pm}","L");
1691           pLegend22.AddEntry(hChHadECharged,"h^{#pm}","L");
1692           pLegend22.AddEntry(hNeHadECharged,"h^{0}","L");
1693           pLegend22.SetFillColor(10);
1694           pLegend22.SetBorderSize(1);
1695           pLegend22.Draw();
1696           
1697           c22ch->cd(2) ; 
1698           
1699           TH1F * hGamPtCharged   = (TH1F*) fhGamPtCharged->ProjectionX("hGamPtCharged",-1,-1);
1700           TH1F * hPi0PtCharged   = (TH1F*) fhPi0PtCharged->ProjectionX("hPi0PtCharged",-1,-1);
1701           TH1F * hElePtCharged   = (TH1F*) fhElePtCharged->ProjectionX("hElePtCharged",-1,-1);
1702           TH1F * hNeHadPtCharged = (TH1F*) fhNeHadPtCharged->ProjectionX("hNeHadPtCharged",-1,-1);
1703           TH1F * hChHadPtCharged = (TH1F*) fhChHadPtCharged->ProjectionX("hChHadPtCharged",-1,-1);
1704           hPi0PtCharged->SetLineColor(1);
1705           hGamPtCharged->SetLineColor(4);
1706           hNeHadPtCharged->SetLineColor(2);
1707           hChHadPtCharged->SetLineColor(7);
1708           hElePtCharged->SetLineColor(6);       
1709           gPad->SetLogy();
1710           fhPtCharged->SetLineColor(3);
1711           fhPtCharged->SetMinimum(0.5);
1712           fhPtCharged->Draw();
1713           hPi0PtCharged->Draw("same");
1714           hGamPtCharged->Draw("same");
1715           hNeHadPtCharged->Draw("same");
1716           hChHadPtCharged->Draw("same");
1717           hElePtCharged->Draw("same");  
1718           
1719           c22ch->cd(4) ; 
1720           
1721           TH1F * hGamEtaCharged   = (TH1F*) fhGamEtaCharged->ProjectionX("hGamEtaCharged",-1,-1);
1722           TH1F * hPi0EtaCharged   = (TH1F*) fhPi0EtaCharged->ProjectionX("hPi0EtaCharged",-1,-1);
1723           TH1F * hEleEtaCharged   = (TH1F*) fhEleEtaCharged->ProjectionX("hEleEtaCharged",-1,-1);
1724           TH1F * hNeHadEtaCharged = (TH1F*) fhNeHadEtaCharged->ProjectionX("hNeHadEtaCharged",-1,-1);
1725           TH1F * hChHadEtaCharged = (TH1F*) fhChHadEtaCharged->ProjectionX("hChHadEtaCharged",-1,-1);
1726           hPi0EtaCharged->SetLineColor(1);
1727           hGamEtaCharged->SetLineColor(4);
1728           hNeHadEtaCharged->SetLineColor(2);
1729           hChHadEtaCharged->SetLineColor(7);
1730           hEleEtaCharged->SetLineColor(6);      
1731           gPad->SetLogy();
1732           fhEtaCharged->SetLineColor(3);
1733           fhEtaCharged->SetMinimum(0.5);
1734           fhEtaCharged->Draw();
1735           hPi0EtaCharged->Draw("same");
1736           hGamEtaCharged->Draw("same");
1737           hNeHadEtaCharged->Draw("same");
1738           hChHadEtaCharged->Draw("same");
1739           hEleEtaCharged->Draw("same");
1740           
1741           c22ch->cd(3) ; 
1742           
1743           TH1F * hGamPhiCharged   = (TH1F*) fhGamPhiCharged->ProjectionX("hGamPhiCharged",-1,-1);
1744           TH1F * hPi0PhiCharged   = (TH1F*) fhPi0PhiCharged->ProjectionX("hPi0PhiCharged",-1,-1);
1745           TH1F * hElePhiCharged   = (TH1F*) fhElePhiCharged->ProjectionX("hElePhiCharged",-1,-1);
1746           TH1F * hNeHadPhiCharged = (TH1F*) fhNeHadPhiCharged->ProjectionX("hNeHadPhiCharged",-1,-1);
1747           TH1F * hChHadPhiCharged = (TH1F*) fhChHadPhiCharged->ProjectionX("hChHadPhiCharged",-1,-1);
1748           hPi0PhiCharged->SetLineColor(1);
1749           hGamPhiCharged->SetLineColor(4);
1750           hNeHadPhiCharged->SetLineColor(2);
1751           hChHadPhiCharged->SetLineColor(7);
1752           hElePhiCharged->SetLineColor(6);      
1753           gPad->SetLogy();
1754           fhPhiCharged->SetLineColor(3);
1755           fhPhiCharged->SetMinimum(0.5);
1756           fhPhiCharged->Draw();
1757           hPi0PhiCharged->Draw("same");
1758           hGamPhiCharged->Draw("same");
1759           hNeHadPhiCharged->Draw("same");
1760           hChHadPhiCharged->Draw("same");
1761           hElePhiCharged->Draw("same");
1762           
1763           
1764           sprintf(name,"QA_%s_ReconstructedDistributions_TrackMatchedGenID.eps",fCalorimeter.Data());
1765           c22ch->Print(name);
1766           
1767           TH1F *        hGamEChargedClone   = (TH1F*)   hGamECharged->Clone("GamEChargedClone");
1768           TH1F *        hGamPtChargedClone  = (TH1F*)   hGamPtCharged->Clone("GamPtChargedClone");
1769           TH1F *        hGamEtaChargedClone = (TH1F*)   hGamEtaCharged->Clone("GamEtaChargedClone");
1770           TH1F *        hGamPhiChargedClone = (TH1F*)   hGamPhiCharged->Clone("GamPhiChargedClone");
1771           
1772           TH1F *        hPi0EChargedClone   = (TH1F*)   hPi0ECharged->Clone("Pi0EChargedClone");
1773           TH1F *        hPi0PtChargedClone  = (TH1F*)   hPi0PtCharged->Clone("Pi0PtChargedClone");
1774           TH1F *        hPi0EtaChargedClone = (TH1F*)   hPi0EtaCharged->Clone("Pi0EtaChargedClone");
1775           TH1F *        hPi0PhiChargedClone = (TH1F*)   hPi0PhiCharged->Clone("Pi0PhiChargedClone");
1776         
1777           TH1F *        hEleEChargedClone   = (TH1F*)   hEleECharged->Clone("EleEChargedClone");
1778           TH1F *        hElePtChargedClone  = (TH1F*)   hElePtCharged->Clone("ElePtChargedClone");
1779           TH1F *        hEleEtaChargedClone = (TH1F*)   hEleEtaCharged->Clone("EleEtaChargedClone");
1780           TH1F *        hElePhiChargedClone = (TH1F*)   hElePhiCharged->Clone("ElePhiChargedClone");    
1781           
1782           TH1F *        hNeHadEChargedClone   = (TH1F*)   hNeHadECharged->Clone("NeHadEChargedClone");
1783           TH1F *        hNeHadPtChargedClone  = (TH1F*)   hNeHadPtCharged->Clone("NeHadPtChargedClone");
1784           TH1F *        hNeHadEtaChargedClone = (TH1F*)   hNeHadEtaCharged->Clone("NeHadEtaChargedClone");
1785           TH1F *        hNeHadPhiChargedClone = (TH1F*)   hNeHadPhiCharged->Clone("NeHadPhiChargedClone");
1786           
1787           TH1F *        hChHadEChargedClone   = (TH1F*)   hChHadECharged->Clone("ChHadEChargedClone");
1788           TH1F *        hChHadPtChargedClone  = (TH1F*)   hChHadPtCharged->Clone("ChHadPtChargedClone");
1789           TH1F *        hChHadEtaChargedClone = (TH1F*)   hChHadEtaCharged->Clone("ChHadEtaChargedClone");
1790           TH1F *        hChHadPhiChargedClone = (TH1F*)   hChHadPhiCharged->Clone("ChHadPhiChargedClone");      
1791           
1792           //Ratio: reconstructed track matched/ all reconstructed
1793           //printf("c3\n");
1794           sprintf(cname,"QA_%s_rectrackmatchratGenID",fCalorimeter.Data());
1795           TCanvas  * c3ch = new TCanvas(cname, "Ratio: reconstructed track matched/ all reconstructed, for different particle ID", 400, 400) ;
1796           c3ch->Divide(2, 2);
1797           
1798           c3ch->cd(1) ;
1799           hEChargedClone->SetMaximum(1.2);
1800           hEChargedClone->SetMinimum(0.001);    
1801           hEChargedClone->SetLineColor(3);
1802           hEChargedClone->SetYTitle("track matched / all");
1803           hPi0EChargedClone->Divide(hPi0E);
1804           hGamEChargedClone->Divide(hGamE);
1805           hEleEChargedClone->Divide(hEleE);
1806           hNeHadEChargedClone->Divide(hNeHadE);
1807           hChHadEChargedClone->Divide(hChHadE);
1808           hEChargedClone->Draw();
1809           hPi0EChargedClone->Draw("same");
1810           hGamEChargedClone->Draw("same");
1811           hEleEChargedClone->Draw("same");
1812           hNeHadEChargedClone->Draw("same");
1813           hChHadEChargedClone->Draw("same");
1814           
1815           TLegend pLegend3ch(0.75,0.45,0.9,0.8);
1816           pLegend3ch.SetTextSize(0.06);
1817           pLegend3ch.AddEntry(hEChargedClone,"all","L");
1818           pLegend3ch.AddEntry(hPi0EChargedClone,"#pi^{0}","L");
1819           pLegend3ch.AddEntry(hGamEChargedClone,"#gamma","L");
1820           pLegend3ch.AddEntry(hEleEChargedClone,"e^{#pm}","L");
1821           pLegend3ch.AddEntry(hChHadEChargedClone,"h^{#pm}","L");
1822           pLegend3ch.AddEntry(hNeHadEChargedClone,"h^{0}","L");
1823           pLegend3ch.SetFillColor(10);
1824           pLegend3ch.SetBorderSize(1);
1825           pLegend3ch.Draw();
1826           
1827           c3ch->cd(2) ;
1828           hPtChargedClone->SetMaximum(1.2);
1829           hPtChargedClone->SetMinimum(0.001);   
1830           hPtChargedClone->SetLineColor(3);
1831           hPtChargedClone->SetYTitle("track matched / all");
1832           hPi0PtChargedClone->Divide(hPi0Pt);
1833           hGamPtChargedClone->Divide(hGamPt);
1834           hElePtChargedClone->Divide(hElePt);
1835           hNeHadPtChargedClone->Divide(hNeHadPt);
1836           hChHadPtChargedClone->Divide(hChHadPt);
1837           hPtChargedClone->Draw();
1838           hPi0PtChargedClone->Draw("same");
1839           hGamPtChargedClone->Draw("same");
1840           hElePtChargedClone->Draw("same");
1841           hNeHadPtChargedClone->Draw("same");
1842           hChHadPtChargedClone->Draw("same");
1843           
1844           c3ch->cd(4) ;
1845           hEtaChargedClone->SetMaximum(1.2);
1846           hEtaChargedClone->SetMinimum(0.001);  
1847           hEtaChargedClone->SetLineColor(3);
1848           hEtaChargedClone->SetYTitle("track matched / all");
1849           hPi0EtaChargedClone->Divide(hPi0Eta);
1850           hGamEtaChargedClone->Divide(hGamEta);
1851           hEleEtaChargedClone->Divide(hEleEta);
1852           hNeHadEtaChargedClone->Divide(hNeHadEta);
1853           hChHadEtaChargedClone->Divide(hChHadEta);
1854           hEtaChargedClone->Draw();
1855           hPi0EtaChargedClone->Draw("same");
1856           hGamEtaChargedClone->Draw("same");
1857           hEleEtaChargedClone->Draw("same");
1858           hNeHadEtaChargedClone->Draw("same");
1859           hChHadEtaChargedClone->Draw("same");
1860           
1861           c3ch->cd(3) ;
1862           hPhiChargedClone->SetMaximum(1.2);
1863           hPhiChargedClone->SetMinimum(0.001);
1864           hPhiChargedClone->SetLineColor(3);
1865           hPhiChargedClone->SetYTitle("track matched / all");
1866           hPi0PhiChargedClone->Divide(hPi0Phi);
1867           hGamPhiChargedClone->Divide(hGamPhi);
1868           hElePhiChargedClone->Divide(hElePhi);
1869           hNeHadPhiChargedClone->Divide(hNeHadPhi);
1870           hChHadPhiChargedClone->Divide(hChHadPhi);
1871           hPhiChargedClone->Draw();
1872           hPi0PhiChargedClone->Draw("same");
1873           hGamPhiChargedClone->Draw("same");
1874           hElePhiChargedClone->Draw("same");
1875           hNeHadPhiChargedClone->Draw("same");
1876           hChHadPhiChargedClone->Draw("same");
1877           
1878           sprintf(name,"QA_%s_RatioReconstructedMatchedDistributionsGenID.eps",fCalorimeter.Data());
1879           c3ch->Print(name);      
1880           
1881           sprintf(cname,"QA_%s_trkmatchMCEle",fCalorimeter.Data());
1882           TCanvas *cmemc = new TCanvas(cname,"Track-matching distributions from MC electrons", 600, 200);
1883           cmemc->Divide(3,1);
1884           
1885           cmemc->cd(1);
1886           gPad->SetLogy();
1887           fhMCEle1pOverE->Draw();
1888           fhMCEle1pOverER02->SetLineColor(4);
1889           fhMCEle1pOverE->SetLineColor(1);
1890           fhMCEle1pOverER02->Draw("same");
1891           pLegendpE0.Draw();
1892           
1893           cmemc->cd(2);
1894           gPad->SetLogy();
1895           fhMCEle1dR->Draw();
1896           
1897           cmemc->cd(3);
1898           fhMCEle2MatchdEdx->Draw();
1899           
1900           sprintf(name,"QA_%s_TrackMatchingDistMCEle.eps",fCalorimeter.Data());
1901           cmemc->Print(name);  
1902           
1903           sprintf(cname,"QA_%s_trkmatchMCChHad",fCalorimeter.Data());
1904           TCanvas *cmemchad = new TCanvas(cname,"Track-matching distributions from MC charged hadrons", 600, 200);
1905           cmemchad->Divide(3,1);
1906           
1907           cmemchad->cd(1);
1908           gPad->SetLogy();
1909           fhMCChHad1pOverE->Draw();
1910           fhMCChHad1pOverE->SetLineColor(1);
1911           fhMCChHad1pOverER02->SetLineColor(4);
1912           fhMCChHad1pOverER02->Draw("same");
1913           pLegendpE0.Draw();
1914           
1915           cmemchad->cd(2);
1916           gPad->SetLogy();
1917           fhMCChHad1dR->Draw();
1918           
1919           cmemchad->cd(3);
1920           fhMCChHad2MatchdEdx->Draw();
1921           
1922           sprintf(name,"QA_%s_TrackMatchingDistMCChHad.eps",fCalorimeter.Data());
1923           cmemchad->Print(name);       
1924           
1925           sprintf(cname,"QA_%s_trkmatchMCNeutral",fCalorimeter.Data());
1926           TCanvas *cmemcn = new TCanvas(cname,"Track-matching distributions from MC neutrals", 600, 200);
1927           cmemcn->Divide(3,1);
1928           
1929           cmemcn->cd(1);
1930           gPad->SetLogy();
1931           fhMCNeutral1pOverE->Draw();
1932           fhMCNeutral1pOverE->SetLineColor(1);
1933           fhMCNeutral1pOverER02->SetLineColor(4);
1934           fhMCNeutral1pOverER02->Draw("same");
1935           pLegendpE0.Draw();
1936           
1937           cmemcn->cd(2);
1938           gPad->SetLogy();
1939           fhMCNeutral1dR->Draw();
1940           
1941           cmemcn->cd(3);
1942           fhMCNeutral2MatchdEdx->Draw();
1943           
1944           sprintf(name,"QA_%s_TrackMatchingDistMCNeutral.eps",fCalorimeter.Data());
1945           cmemcn->Print(name);       
1946           
1947           sprintf(cname,"QA_%s_trkmatchpE",fCalorimeter.Data());
1948           TCanvas *cmpoe = new TCanvas(cname,"Track-matching distributions, p/E", 400, 200);
1949           cmpoe->Divide(2,1);
1950           
1951           cmpoe->cd(1);
1952           gPad->SetLogy();
1953           fh1pOverE->SetLineColor(1);
1954           fhMCEle1pOverE->SetLineColor(4);
1955           fhMCChHad1pOverE->SetLineColor(2);
1956           fhMCNeutral1pOverE->SetLineColor(7);
1957           fh1pOverE->SetMinimum(0.5);
1958           fh1pOverE->Draw();
1959           fhMCEle1pOverE->Draw("same");
1960           fhMCChHad1pOverE->Draw("same");
1961           fhMCNeutral1pOverE->Draw("same");
1962           TLegend pLegendpE(0.65,0.55,0.9,0.8);
1963           pLegendpE.SetTextSize(0.06);
1964           pLegendpE.AddEntry(fh1pOverE,"all","L");
1965           pLegendpE.AddEntry(fhMCEle1pOverE,"e^{#pm}","L");
1966           pLegendpE.AddEntry(fhMCChHad1pOverE,"h^{#pm}","L");
1967           pLegendpE.AddEntry(fhMCNeutral1pOverE,"neutrals","L");
1968           pLegendpE.SetFillColor(10);
1969           pLegendpE.SetBorderSize(1);
1970           pLegendpE.Draw();
1971           
1972           cmpoe->cd(2);
1973           gPad->SetLogy();
1974           fh1pOverER02->SetTitle("Track matches p/E, dR<0.2");
1975           fh1pOverER02->SetLineColor(1);
1976           fhMCEle1pOverER02->SetLineColor(4);
1977           fhMCChHad1pOverER02->SetLineColor(2);
1978           fhMCNeutral1pOverER02->SetLineColor(7);
1979           fh1pOverER02->SetMaximum(fh1pOverE->GetMaximum());
1980           fh1pOverER02->SetMinimum(0.5);
1981           fh1pOverER02->Draw();
1982           fhMCEle1pOverER02->Draw("same");
1983           fhMCChHad1pOverER02->Draw("same");
1984           fhMCNeutral1pOverER02->Draw("same");
1985           
1986           //            TLegend pLegendpE2(0.65,0.55,0.9,0.8);
1987           //            pLegendpE2.SetTextSize(0.06);
1988           //            pLegendpE2.SetHeader("dR < 0.02");
1989           //            pLegendpE2.SetFillColor(10);
1990           //            pLegendpE2.SetBorderSize(1);
1991           //            pLegendpE2.Draw();
1992         //Track matching histograms
1993         sprintf(name,"QA_%s_TrackMatchingPOverE.eps",fCalorimeter.Data());
1994         cmpoe->Print(name);             
1995         }//MC related histograms
1996
1997         //      char line[1024] ; 
1998         //      sprintf(line, ".!tar -zcf QA_%s_%s.tar.gz *%s*.eps", fCalorimeter.Data(), GetName(),fCalorimeter.Data()) ; 
1999         //      gROOT->ProcessLine(line);
2000         //      sprintf(line, ".!rm -fR *.eps"); 
2001         //      gROOT->ProcessLine(line);
2002         //      
2003         //      printf("AliAnaCalorimeterQA::Terminate() - !! All the pdf files are in QA_%s_%s.tar.gz !!!\n",  fCalorimeter.Data(), GetName());
2004         
2005 }
2006