Added a new class for the AOD information
[u/mrichter/AliRoot.git] / PWG4 / GammaConv / AliGammaConversionHistograms.cxx
CommitLineData
d7d7e825 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt *
5 * Version 1.1 *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16////////////////////////////////////////////////
17//---------------------------------------------
18// Class used to do analysis on conversion pairs
19//---------------------------------------------
20////////////////////////////////////////////////
21
22#include "AliGammaConversionHistograms.h"
23#include "TMath.h"
24#include "TObjString.h"
25#include "TMap.h"
26#include "TList.h"
27#include "TH1F.h"
28#include "TH2F.h"
29
30
31using namespace std;
32
33ClassImp(AliGammaConversionHistograms)
34
35
36AliGammaConversionHistograms::AliGammaConversionHistograms() :
37 fHistogramMap(new TMap()),
38 fNPhiIndex(0),
39 fNRIndex(0),
40 fMinRadius(0.),
41 fMaxRadius(0.),
42 fDeltaR(0.),
43 fMinPhi(0.),
44 fMaxPhi(0.),
45 fDeltaPhi(0.),
46 fMappingContainer(NULL),
47 fBackgroundContainer(NULL),
48 fDebugContainer(NULL),
49 fResolutionContainer(NULL),
50 fMatchContainer(NULL),
51 fESDContainer(NULL),
52 fMCContainer(NULL),
53 fTableContainer(NULL),
54 fOtherContainer(NULL)
55{
56 // see header file for documenation
57}
58
59
60AliGammaConversionHistograms::AliGammaConversionHistograms(const AliGammaConversionHistograms & original) :
61 fHistogramMap(original.fHistogramMap),
62 fNPhiIndex(original.fNPhiIndex),
63 fNRIndex(original.fNRIndex),
64 fMinRadius(original.fMinRadius),
65 fMaxRadius(original.fMaxRadius),
66 fDeltaR(original.fDeltaR),
67 fMinPhi(original.fMinPhi),
68 fMaxPhi(original.fMaxPhi),
69 fDeltaPhi(original.fDeltaPhi),
70 fMappingContainer(original.fMappingContainer),
71 fBackgroundContainer(original.fBackgroundContainer),
72 fDebugContainer(original.fDebugContainer),
73 fResolutionContainer(original.fResolutionContainer),
74 fMatchContainer(original.fMatchContainer),
75 fESDContainer(original.fESDContainer),
76 fMCContainer(original.fMCContainer),
77 fTableContainer(original.fTableContainer),
78 fOtherContainer(original.fOtherContainer)
79{
80 //see header file for documentation
81}
82
83
84AliGammaConversionHistograms & AliGammaConversionHistograms::operator = (const AliGammaConversionHistograms & /*original*/)
85{
86 // assignment operator
87 return *this;
88}
89
90
91AliGammaConversionHistograms::~AliGammaConversionHistograms() {
92 //destructor
93
94
95}
96
97void AliGammaConversionHistograms::AddHistogram(TString histogramName, TString histogramTitle, Int_t nXBins, Double_t firstX,Double_t lastX,TString xAxisTitle, TString yAxisTitle){
98 // see header file for documentation
99 TH1F *tmp = new TH1F(histogramName, histogramTitle,nXBins,firstX,lastX);
100 tmp->GetXaxis()->SetTitle(xAxisTitle);
101 tmp->GetYaxis()->SetTitle(yAxisTitle);
102 TObjString* tobjstring = new TObjString(histogramName.Data());
103 fHistogramMap->Add((TObject*)tobjstring,(TObject*)tmp);
104}
105
106void AliGammaConversionHistograms::AddHistogram(TString histogramName, TString histogramTitle, Int_t nXBins, Double_t firstX, Double_t lastX, Int_t nYBins, Double_t firstY, Double_t lastY, TString xAxisTitle, TString yAxisTitle){
107 // see header file for documentation
108 TH2F *tmp = new TH2F(histogramName, histogramTitle,nXBins,firstX,lastX,nYBins,firstY,lastY);
109 tmp->GetXaxis()->SetTitle(xAxisTitle);
110 tmp->GetYaxis()->SetTitle(yAxisTitle);
111 TObjString *tobjstring = new TObjString(histogramName.Data());
112 fHistogramMap->Add((TObject*)tobjstring,(TObject*)tmp);
113}
114
115void AliGammaConversionHistograms::AddTable(TString tableName,TString tableTitle,Int_t nXBins,const char * axesLabel[]){
116
117
118 TH1F *tmp = new TH1F(tableName,tableTitle,nXBins,0,nXBins);
119 for(Int_t xbin=1; xbin<=nXBins; xbin++){
120 tmp->GetXaxis()->SetBinLabel(xbin,axesLabel[xbin-1]);
121 }
122 tmp->SetStats(0);
123
124 TObjString *tobjstring = new TObjString(tableName.Data());
125 fHistogramMap->Add((TObject*)tobjstring,(TObject*)tmp);
126}
127
128void AliGammaConversionHistograms::FillTable(TString tableName,Double_t xValue) const {
129 TH1 *tmp = (TH1*)fHistogramMap->GetValue(tableName.Data());
130 if(tmp){
131 tmp->Fill(xValue);
132 }
133}
134
135void AliGammaConversionHistograms::FillHistogram(TString histogramName, Double_t xValue) const{
136 //see header file for documentation
137 TH1 *tmp = (TH1*)fHistogramMap->GetValue(histogramName.Data());
138 if(tmp){
139 tmp->Fill(xValue);
140 }
141}
142
143void AliGammaConversionHistograms::FillHistogram(TString histogramName, Double_t xValue, Double_t yValue) const{
144 //see header file for documentation
145 TH1 *tmp = (TH1*)fHistogramMap->GetValue(histogramName.Data());
146 if(tmp){
147 tmp->Fill(xValue, yValue);
148 }
149}
150
151void AliGammaConversionHistograms::GetOutputContainer(TList *fOutputContainer){
152 //checking if the container is alrerady created
153
154 if(fOutputContainer == NULL){
155 cout<<"WARNING: GetOutputContainer: output container object is NULL"<<endl;
156 return;
157 }
158
159 if(fHistogramMap != NULL){
160 TIter iter(fHistogramMap);
161 TObjString *histogramName;
162 while ((histogramName = (TObjString*) iter.Next())) {
163 TString histogramString = histogramName->GetString();
164 if(histogramString.Contains("Mapping")){// means it should be put in the mapping folder
165 if(fMappingContainer == NULL){
166 fMappingContainer = new TList();
167 fMappingContainer->SetName("Mapping histograms");
168 }
169 if(fMappingContainer != NULL){
170 fMappingContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
171 }
172 }
173 else if(histogramString.Contains("Background")){// means it should be put in the background folder
174 if(fBackgroundContainer == NULL){
175 fBackgroundContainer = new TList();
176 fBackgroundContainer->SetName("Background histograms");
177 }
178 if(fBackgroundContainer != NULL){
179 fBackgroundContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
180 }
181 }
182 else if(histogramString.Contains("Debug")){// means it should be put in the debug folder
183 if(fDebugContainer == NULL){
184 fDebugContainer = new TList();
185 fDebugContainer->SetName("Debug histograms");
186 }
187 if(fDebugContainer != NULL){
188 fDebugContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
189 }
190 }
191 else if(histogramString.Contains("Resolution")){// means it should be put in the resolution folder
192 if(fResolutionContainer == NULL){
193 fResolutionContainer = new TList();
194 fResolutionContainer->SetName("Resolution histograms");
195 }
196 if(fResolutionContainer != NULL){
197 fResolutionContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
198 }
199 }
200 else if(histogramString.Contains("TrueConv")){// means it should be put in the true conv folder
201 if(fMatchContainer == NULL){
202 fMatchContainer = new TList();
203 fMatchContainer->SetName("True conversion histograms");
204 }
205 if(fMatchContainer != NULL){
206 fMatchContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
207 }
208 }
209 else if(histogramString.Contains("ESD")){// means it should be put in the ESD folder
210 if(fESDContainer == NULL){
211 fESDContainer = new TList();
212 fESDContainer->SetName("ESD histograms");
213 }
214 if(fESDContainer != NULL){
215 fESDContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
216 }
217 }
218 else if(histogramString.Contains("MC")){// means it should be put in the MC folder
219 if(fMCContainer == NULL){
220 fMCContainer = new TList();
221 fMCContainer->SetName("MC histograms");
222 }
223 if(fMCContainer != NULL){
224 fMCContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
225 }
226 }
227 else if(histogramString.Contains("Table")){// means it should be put in the Table Folder
228 if(fTableContainer == NULL){
229 fTableContainer = new TList();
230 fTableContainer->SetName("Tables");
231 }
232 if(fTableContainer != NULL){
233 fTableContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
234 }
235 }
236 else{
237 if(fOtherContainer == NULL){
238 fOtherContainer = new TList();
239 fOtherContainer->SetName("Other histograms");
240 }
241 if(fOtherContainer != NULL){
242 fOtherContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
243 }
244 }
245 histogramName = NULL;
246 } // end while
247 if(fMappingContainer != NULL){
248 fOutputContainer->Add(fMappingContainer);
249 }
250 if(fBackgroundContainer != NULL){
251 fOutputContainer->Add(fBackgroundContainer);
252 }
253 if(fDebugContainer != NULL){
254 fOutputContainer->Add(fDebugContainer);
255 }
256 if(fResolutionContainer != NULL){
257 fOutputContainer->Add(fResolutionContainer);
258 }
259 if(fMatchContainer != NULL){
260 fOutputContainer->Add(fMatchContainer);
261 }
262 if(fESDContainer != NULL){
263 fOutputContainer->Add(fESDContainer);
264 }
265 if(fMCContainer != NULL){
266 fOutputContainer->Add(fMCContainer);
267 }
268 if(fTableContainer != NULL){
269 fOutputContainer->Add(fTableContainer);
270 }
271 if(fOtherContainer != NULL){
272 fOutputContainer->Add(fMCContainer);
273 }
274 }
275}
276
277Int_t AliGammaConversionHistograms::GetRBin(Double_t radius) const{
278 // see header file for documentation
279 Int_t iResult=0;
280 if(fDeltaR>0){
281 iResult = (Int_t)((radius - fMinRadius)/fDeltaR);
282 }
283 return iResult;
284}
285
286Int_t AliGammaConversionHistograms::GetPhiBin(Double_t phi) const{
287 // see header file for documentation
288 Int_t iResult=0;
289 if(fDeltaPhi>0){
290 if(phi>TMath::Pi()){
291 phi-=2*TMath::Pi();
292 }
293 iResult = (Int_t)((phi - fMinPhi)/fDeltaPhi);
294 }
295 return iResult;
296}
297
298
299
300void AliGammaConversionHistograms::InitializeMappingValues(Int_t nPhiIndex, Int_t nRIndex, Int_t nBinsR, Double_t minRadius, Double_t maxRadius,Int_t nBinsPhi, Double_t minPhi, Double_t maxPhi){
301 // Initializing the valuse for the mapping
302
303 fNPhiIndex = nPhiIndex;
304 fNRIndex = nRIndex;
305 fMinRadius = minRadius;
306 fMaxRadius = maxRadius;
307 if(nBinsR>0 && nRIndex!=0){
308 fDeltaR = (fMaxRadius - fMinRadius)/nRIndex;
309 }
310 fMinPhi = minPhi;
311 fMaxPhi = maxPhi;
312 if(nBinsPhi>0 && nPhiIndex!=0){
313 fDeltaPhi = (fMaxPhi-fMinPhi)/nPhiIndex;
314 }
315}
316
317
318//mapping
319void AliGammaConversionHistograms::AddMappingHistograms(Int_t nPhiIndex, Int_t nRIndex,Int_t nXBins, Double_t firstX, Double_t lastX, Int_t nYBins, Double_t firstY, Double_t lastY, TString xAxisTitle, TString yAxisTitle){
320 // see header file for documentation
321
322 for(Int_t phi =0; phi<=fNPhiIndex;phi++){
323
324 for(Int_t r =0; r<fNRIndex;r++){
325
326 // setting axis to "" changes below
327 xAxisTitle="";
328 yAxisTitle="";
329 //Creating the axis titles
330 if(xAxisTitle.Length() == 0){
331 xAxisTitle.Form("Phi %02d",phi);
332 }
333
334 if(yAxisTitle.Length() == 0){
335 yAxisTitle.Form("R %02d",phi);
336 }
337
338 //MC
339 TString nameMC="";
340 nameMC.Form("MC_Conversion_Mapping-Phi%02d-R%02d",phi,r);
341 TString titleMC="";
342 titleMC.Form("Electron-Positron MC Mapping-Phi%02d-R%02d",phi,r);
343
344 AddHistogram(nameMC, titleMC, nXBins, firstX, lastX, nYBins, firstY, lastY, xAxisTitle, yAxisTitle);
345
346 //ESD
347 TString nameESD="";
348 nameESD.Form("ESD_Conversion_Mapping-Phi%02d-R%02d",phi,r);
349 TString titleESD="";
350 titleESD.Form("Electron-Positron ESD Mapping-Phi%02d-R%02d",phi,r);
351
352 AddHistogram(nameESD, titleESD, nXBins, firstX, lastX, nYBins, firstY, lastY, xAxisTitle, yAxisTitle);
353 }
354 }
355
356
357 for(Int_t phi =0; phi<=nPhiIndex;phi++){
358
359 // setting axis to "" changes below
360 xAxisTitle="";
361 yAxisTitle="";
362 //Creating the axis titles
363 if(xAxisTitle.Length() == 0){
364 xAxisTitle.Form("Phi %02d",phi);
365 }
366 if(yAxisTitle.Length() == 0){
367 yAxisTitle = "Counts";
368 }
369
370 //MC
371 TString nameMC="";
372 nameMC.Form("MC_Conversion_Mapping-Phi%02d",phi);
373 TString titleMC="";
374 titleMC.Form("Electron-Positron MC Mapping-Phi%02d",phi);
375
376 AddHistogram(nameMC, titleMC, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
377
378 //MC
379 TString nameESD="";
380 nameESD.Form("ESD_Conversion_Mapping-Phi%02d",phi);
381 TString titleESD="";
382 titleESD.Form("Electron-Positron ESD Mapping-Phi%02d",phi);
383
384 AddHistogram(nameESD, titleESD, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
385 }
386
387
388 for(Int_t r =0; r<=nRIndex;r++){
389
390 // setting axis to "" changes below
391 xAxisTitle="";
392 yAxisTitle="";
393 //Creating the axis titles
394 if(xAxisTitle.Length() == 0){
395 xAxisTitle.Form("R %02d",r);
396 }
397 if(yAxisTitle.Length() == 0){
398 yAxisTitle = "Counts";
399 }
400
401 //MC
402 TString nameMC="";
403 nameMC.Form("MC_Conversion_Mapping-R%02d",r);
404 TString titleMC="";
405 titleMC.Form("Electron-Positron MC Mapping-R%02d",r);
406
407 AddHistogram(nameMC, titleMC, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
408
409 //ESD
410 TString nameESD="";
411 nameESD.Form("ESD_Conversion_Mapping-R%02d",r);
412 TString titleESD="";
413 titleESD.Form("Electron-Positron ESD Mapping-R%02d",r);
414
415 AddHistogram(nameESD, titleESD, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
416
417 //Mapping Phi in R
418 TString nameMCPhiInR="";
419 nameMCPhiInR.Form("MC_Conversion_Mapping_Phi_R-%02d",r);
420 TString titleMCPhiInR="";
421 titleMCPhiInR.Form("MC Mapping of Phi in R%02d",r);
422 AddHistogram(nameMCPhiInR, titleMCPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
423
424 //Mapping Phi in R
425 TString nameESDPhiInR="";
426 nameESDPhiInR.Form("ESD_Conversion_Mapping_Phi_R-%02d",r);
427 TString titleESDPhiInR="";
428 titleESDPhiInR.Form("ESD Mapping of Phi in R%02d",r);
429 AddHistogram(nameESDPhiInR, titleESDPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
430 }
431}