changes from gsi. Using mult if no centrality. testfilterbit 128
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / AliGammaConversionHistograms.cxx
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 #include "TH3F.h"
30 #include "AliLog.h"
31
32 using namespace std;
33
34 ClassImp(AliGammaConversionHistograms)
35
36
37 AliGammaConversionHistograms::AliGammaConversionHistograms() :
38         fHistogramMap(new TMap()),
39         fNPhiIndex(0),
40         fNRIndex(0),
41         fNZIndex(0),
42         //  fRBinLimits(0),
43         //  fZBinLimits(0),
44         fMinRadius(0.),
45         fMaxRadius(0.),
46         fDeltaR(0.),
47         fMinPhi(0.),
48         fMaxPhi(0.),
49         fDeltaPhi(0.),
50         fMappingContainer(NULL),
51         fBackgroundContainer(NULL),
52         fDebugContainer(NULL),
53         fResolutionContainer(NULL),
54         fMatchContainer(NULL),
55         fESDContainer(NULL),
56         fMCContainer(NULL),
57         fTableContainer(NULL),  
58         fOtherContainer(NULL),
59         f3DContainer(NULL),
60         fHadContainer(NULL)
61 {
62   // see header file for documenation
63   for(Int_t i=0;i<14;i++){
64     fRBinLimits[i]=0.;
65   }
66   for(Int_t i=0;i<12;i++){
67     fZBinLimits[i]=0.;
68   }
69 }
70
71
72 AliGammaConversionHistograms::AliGammaConversionHistograms(const AliGammaConversionHistograms & original) :
73         fHistogramMap(original.fHistogramMap),
74         fNPhiIndex(original.fNPhiIndex),
75         fNRIndex(original.fNRIndex),
76         fNZIndex(original.fNZIndex),
77         //  fRBinLimits(original.fRBinLimits),
78         //  fZBinLimits(original.fZBinLimits),
79         fMinRadius(original.fMinRadius),
80         fMaxRadius(original.fMaxRadius),
81         fDeltaR(original.fDeltaR),
82         fMinPhi(original.fMinPhi),
83         fMaxPhi(original.fMaxPhi),
84         fDeltaPhi(original.fDeltaPhi),
85         fMappingContainer(original.fMappingContainer),
86         fBackgroundContainer(original.fBackgroundContainer),
87         fDebugContainer(original.fDebugContainer),
88         fResolutionContainer(original.fResolutionContainer),
89         fMatchContainer(original.fMatchContainer),
90         fESDContainer(original.fESDContainer),
91         fMCContainer(original.fMCContainer),
92         fTableContainer(original.fTableContainer), 
93         fOtherContainer(original.fOtherContainer),
94         f3DContainer(original.f3DContainer),
95         fHadContainer(original.fHadContainer)
96         {    
97         //see header file for documentation
98         for(Int_t i=0;i<14;i++){
99                 fRBinLimits[i]= original.fRBinLimits[i];
100         }
101         for(Int_t i=0;i<12;i++){
102                 fZBinLimits[i]=original.fZBinLimits[i];
103         }
104 }
105
106
107 AliGammaConversionHistograms & AliGammaConversionHistograms::operator = (const AliGammaConversionHistograms & /*original*/)
108 {
109   // assignment operator
110   return *this;
111 }
112
113
114 AliGammaConversionHistograms::~AliGammaConversionHistograms() {
115   //destructor
116         
117         
118 }
119
120 void AliGammaConversionHistograms::AddHistogram(TString histogramName, TString histogramTitle, Int_t nXBins, Double_t firstX,Double_t lastX,TString xAxisTitle, TString yAxisTitle){
121   // see header file for documentation
122   if( fHistogramMap->Contains(histogramName.Data()) ==  kFALSE ){
123     TH1F *tmp = new TH1F(histogramName, histogramTitle,nXBins,firstX,lastX);
124     tmp->GetXaxis()->SetTitle(xAxisTitle);
125     tmp->GetYaxis()->SetTitle(yAxisTitle);
126     TObjString* tobjstring = new TObjString(histogramName.Data());
127     fHistogramMap->Add((TObject*)tobjstring,(TObject*)tmp);
128   }
129   else{
130     cout << "Warning: Histogram ( "<<histogramName.Data()<<" ) already exists " << endl;
131   }
132 }
133
134 void 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, Int_t logAxis){
135   // see header file for documentation
136   if( fHistogramMap->Contains(histogramName.Data()) ==  kFALSE ){
137     TH2F *tmp = new TH2F(histogramName, histogramTitle,nXBins,firstX,lastX,nYBins,firstY,lastY);
138     tmp->GetXaxis()->SetTitle(xAxisTitle);
139     tmp->GetYaxis()->SetTitle(yAxisTitle);
140     TObjString *tobjstring = new TObjString(histogramName.Data());
141     fHistogramMap->Add((TObject*)tobjstring,(TObject*)tmp);
142
143     if(logAxis >= 0){
144       BinLogAxis(histogramName.Data(), logAxis);
145     }
146   }
147   else{
148     cout << "Warning: Histogram ( "<<histogramName.Data()<<" ) already exists " << endl;
149   }
150 }
151
152 void AliGammaConversionHistograms::AddHistogram(TString histogramName, TString histogramTitle, Int_t nXBins, Double_t firstX, Double_t lastX, Int_t nYBins, Double_t firstY, Double_t lastY, Int_t nZBins, Double_t firstZ, Double_t lastZ, TString xAxisTitle, TString yAxisTitle, TString zAxisTitle, Int_t logAxis ){
153   // see header file for documentation
154   if( fHistogramMap->Contains(histogramName.Data()) ==  kFALSE ){
155     TH3F *tmp = new TH3F(histogramName, histogramTitle,nXBins,firstX,lastX,nYBins,firstY,lastY,nZBins,firstZ,lastZ);
156     tmp->GetXaxis()->SetTitle(xAxisTitle);
157     tmp->GetYaxis()->SetTitle(yAxisTitle);
158     tmp->GetZaxis()->SetTitle(zAxisTitle);
159     TObjString *tobjstring = new TObjString(histogramName.Data());
160     fHistogramMap->Add((TObject*)tobjstring,(TObject*)tmp);
161     if(logAxis >= 0){
162       BinLogAxis(histogramName.Data(), logAxis);
163     }
164   }
165   else{
166     cout << "Warning: Histogram ( "<<histogramName.Data()<<" ) already exists " << endl;
167   }
168 }
169
170
171 Bool_t AliGammaConversionHistograms::BinLogAxis(const char* name, Int_t dim){
172
173   //
174   // converts the axis (defined by the dimension) of THx or THnSparse
175   // object to Log scale. Number of bins and bin min and bin max are preserved
176   
177  
178   TObject *o =  fHistogramMap->GetValue(name);
179   TAxis *axis = 0x0;
180   if(o->InheritsFrom("TH1")){
181     axis = (dynamic_cast<TH1F*>(o))->GetXaxis();
182   }
183   if(o->InheritsFrom("TH2")){
184     if(0 == dim){
185       axis = (dynamic_cast<TH2F*>(o))->GetXaxis();
186     }
187     else if(1 == dim){
188       axis = (dynamic_cast<TH2F*>(o))->GetYaxis();
189     }
190      else{
191        //  AliError("Only dim = 0 or 1 possible for TH2F");
192      }
193   }
194   //  if(o->InheritsFrom("THnSparse")){
195   //  axis = (dynamic_cast<THnSparse*>(o))->GetAxis(dim);
196   //}
197
198   if(!axis){
199     //AliError(Form("Axis '%d' could not be identified in the object '%s'\n", dim, name));
200     return kFALSE;
201   }
202
203   Int_t bins = axis->GetNbins();
204
205   Double_t from = axis->GetXmin();
206   if(from <= 0){
207     // AliError(Form(" Log binning not possible for object '%s'because the '%d' axis starts from '%f\n'", name, dim, from));
208     return kFALSE;
209   }
210   Double_t to = axis->GetXmax();
211   Double_t *newBins = new Double_t[bins+1];
212   newBins[0] = from;
213   Double_t factor = TMath::Power(to/from, 1./bins);
214   for(Int_t i=1; i<=bins; ++i){
215     newBins[i] = factor * newBins[i-1];
216   }
217   axis->Set(bins, newBins);
218   delete [] newBins;
219
220   return kTRUE;
221
222
223 }
224
225 void AliGammaConversionHistograms::AddTable(TString tableName,TString tableTitle,Int_t nXBins,const char * axesLabel[]){
226   //see header file for documentation
227
228   if( fHistogramMap->Contains(tableName.Data()) ==  kFALSE ){
229     TH1F *tmp = new TH1F(tableName,tableTitle,nXBins,0,nXBins);
230     for(Int_t xbin=1; xbin<=nXBins; xbin++){
231       tmp->GetXaxis()->SetBinLabel(xbin,axesLabel[xbin-1]);
232     }
233     tmp->SetStats(0);
234     
235     TObjString *tobjstring = new TObjString(tableName.Data());
236     fHistogramMap->Add((TObject*)tobjstring,(TObject*)tmp);
237   }
238   else{
239     cout << "Warning: Table ( "<<tableName.Data()<<" ) already exists " << endl;
240   }
241 }
242 void AliGammaConversionHistograms::AddTable(TString tableName,TString tableTitle,Int_t nXBins,const char * axesXLabel[],Int_t nYBins,const char * axesYLabel[]){
243   //see header file for documentation
244
245   if( fHistogramMap->Contains(tableName.Data()) ==  kFALSE ){
246     TH2F *tmp = new TH2F(tableName,tableTitle,nXBins,0,nXBins,nYBins,0,nYBins);
247     for(Int_t xbin=1; xbin<=nXBins; xbin++){
248       tmp->GetXaxis()->SetBinLabel(xbin,axesXLabel[xbin-1]);
249     }
250     for(Int_t ybin=1; ybin<=nYBins; ybin++){
251       tmp->GetYaxis()->SetBinLabel(ybin,axesYLabel[ybin-1]);
252     }
253     tmp->SetStats(0);
254     
255     TObjString *tobjstring = new TObjString(tableName.Data());
256     fHistogramMap->Add((TObject*)tobjstring,(TObject*)tmp);
257   }
258   else{
259     cout << "Warning: Table ( "<<tableName.Data()<<" ) already exists " << endl;
260   }
261 }
262
263 void AliGammaConversionHistograms::AddTable(TString tableName,TString tableTitle,Int_t nXBins,const char * axesXLabel[],Int_t nYBins,const char * axesYLabel[], Int_t nZBins,const char * axesZLabel[]){
264   //see header file for documentation
265
266   if( fHistogramMap->Contains(tableName.Data()) ==  kFALSE ){
267     TH3F *tmp = new TH3F(tableName,tableTitle,nXBins,0,nXBins,nYBins,0,nYBins,nZBins,0,nZBins);
268     for(Int_t xbin=1; xbin<=nXBins; xbin++){
269       tmp->GetXaxis()->SetBinLabel(xbin,axesXLabel[xbin-1]);
270     }
271     for(Int_t ybin=1; ybin<=nYBins; ybin++){
272       tmp->GetYaxis()->SetBinLabel(ybin,axesYLabel[ybin-1]);
273     }
274     for(Int_t zbin=1; zbin<=nZBins; zbin++){
275       tmp->GetZaxis()->SetBinLabel(zbin,axesZLabel[zbin-1]);
276     }
277     
278     tmp->SetStats(0);
279     
280     TObjString *tobjstring = new TObjString(tableName.Data());
281     fHistogramMap->Add((TObject*)tobjstring,(TObject*)tmp);
282   }
283   else{
284     cout << "Warning: Table ( "<<tableName.Data()<<" ) already exists " << endl;
285   }
286 }
287
288 void AliGammaConversionHistograms::FillTable(TString tableName,Double_t xValue) const {
289   //see header file for documentation
290   TH1 *tmp = (TH1*)fHistogramMap->GetValue(tableName.Data());
291   if(tmp){
292     tmp->Fill(xValue);
293   }
294 }
295 void AliGammaConversionHistograms::FillTable(TString tableName,Double_t xValue,Double_t yValue) const {
296   //see header file for documentation
297   TH2 *tmp = (TH2*)fHistogramMap->GetValue(tableName.Data());
298   if(tmp){
299     tmp->Fill(xValue,yValue);
300   }
301 }
302 void AliGammaConversionHistograms::FillTable(TString tableName,Double_t xValue,Double_t yValue, Double_t zValue) const {
303   //see header file for documentation
304   TH3 *tmp = (TH3*)fHistogramMap->GetValue(tableName.Data());
305   if(tmp){
306     tmp->Fill(xValue,yValue,zValue);
307   }
308 }
309
310 void AliGammaConversionHistograms::FillHistogram(TString histogramName, Double_t xValue) const{
311   //see header file for documentation
312   TH1 *tmp = (TH1*)fHistogramMap->GetValue(histogramName.Data());
313   if(tmp){
314     tmp->Fill(xValue);
315   }
316 }
317
318 void AliGammaConversionHistograms::FillHistogram(TString histogramName, Float_t* xValue, Int_t nPoints) const{
319         //see header file for documentation
320         TH1 *tmp = (TH1*)fHistogramMap->GetValue(histogramName.Data());
321         if(tmp){
322                 for( Int_t ii = 1; ii < nPoints+1; ii++){                 
323                         tmp->SetBinContent(ii,xValue[ii]);
324                 }
325         }
326 }
327
328 void AliGammaConversionHistograms::FillHistogram(TString histogramName, Double_t xValue, Double_t yValue) const{
329   //see header file for documentation
330   TH1 *tmp = (TH1*)fHistogramMap->GetValue(histogramName.Data());
331   if(tmp){
332     tmp->Fill(xValue, yValue);
333   }
334 }
335
336 void AliGammaConversionHistograms::FillHistogram(TString histogramName, Double_t xValue, Double_t yValue, Double_t zValue) const{
337   //see header file for documentation
338   TH3 *tmp = (TH3*)fHistogramMap->GetValue(histogramName.Data());
339   if(tmp){
340     tmp->Fill(xValue, yValue, zValue);
341   }
342 }
343
344
345 TObject* AliGammaConversionHistograms::GetValue(const TString& name)
346
347   //Get pointer to histogram with name
348   return fHistogramMap->GetValue(name.Data());
349 }
350
351 void AliGammaConversionHistograms::GetOutputContainer(TList *fOutputContainer){
352   //checking if the container is alrerady created
353         
354         if(fOutputContainer == NULL){
355                 cout<<"WARNING: GetOutputContainer: output container object is NULL"<<endl;
356                 return;
357         }
358
359         if(fHistogramMap != NULL){
360                 TIter iter(fHistogramMap);
361                 TObjString *histogramName;
362                 while ((histogramName = (TObjString*) iter.Next())) {
363                         TString histogramString = histogramName->GetString();
364                         if(histogramString.Contains("Mapping")){// means it should be put in the mapping folder
365                                 if(fMappingContainer == NULL){
366                                         fMappingContainer = new TList();
367                                         fMappingContainer->SetOwner(kTRUE);
368                                         fMappingContainer->SetName("Mapping histograms");
369                                 }
370                                 fMappingContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
371                         } else if(histogramString.Contains("HadInt")){// means it should be put in the Table Folder
372                                 if(fHadContainer == NULL){
373                                         fHadContainer = new TList();
374                                         fHadContainer->SetOwner(kTRUE);
375                                         fHadContainer->SetName("Hadronic Interactions histograms");
376                                 }
377                                 fHadContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));      
378                         } else if(histogramString.Contains("Background")){// means it should be put in the background folder
379                                 if(fBackgroundContainer == NULL){
380                                         fBackgroundContainer = new TList();
381                                         fBackgroundContainer->SetOwner(kTRUE);
382                                         fBackgroundContainer->SetName("Background histograms");
383                                 }
384                                 fBackgroundContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
385                         } else if(histogramString.Contains("Debug")){// means it should be put in the debug folder
386                                 if(fDebugContainer == NULL){
387                                         fDebugContainer = new TList();
388                                         fDebugContainer->SetOwner(kTRUE);
389                                         fDebugContainer->SetName("Debug histograms");
390                                 }
391                                 fDebugContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
392                         } else if(histogramString.Contains("Resolution")){// means it should be put in the resolution folder
393                                 if(fResolutionContainer == NULL){
394                                         fResolutionContainer = new TList();
395                                         fResolutionContainer->SetOwner(kTRUE);
396                                         fResolutionContainer->SetName("Resolution histograms");
397                                 }
398                                 fResolutionContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
399                         } else if(histogramString.Contains("TrueConv")){// means it should be put in the true conv folder
400                                 if(fMatchContainer == NULL){
401                                         fMatchContainer = new TList();
402                                         fMatchContainer->SetOwner(kTRUE);
403                                         fMatchContainer->SetName("True conversion histograms");
404                                 }
405                                 fMatchContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
406                         } else if(histogramString.Contains("ESD")){// means it should be put in the ESD folder
407                                 if(fESDContainer == NULL){
408                                         fESDContainer = new TList();
409                                         fESDContainer->SetOwner(kTRUE);
410                                         fESDContainer->SetName("ESD histograms");
411                                 }
412                                 fESDContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
413                         } else if(histogramString.Contains("MC")){// means it should be put in the MC folder
414                                 if(fMCContainer == NULL){
415                                         fMCContainer = new TList();
416                                         fMCContainer->SetOwner(kTRUE);
417                                         fMCContainer->SetName("MC histograms");
418                                 }
419                                 fMCContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
420                         } else if(histogramString.Contains("Table")){// means it should be put in the Table Folder
421                                 if(fTableContainer == NULL){
422                                         fTableContainer = new TList();
423                                         fTableContainer->SetOwner(kTRUE);
424                                         fTableContainer->SetName("Tables");
425                                 }
426                                 fTableContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
427                         } else if(histogramString.Contains("3DPlots")){// means it should be put in the Table Folder
428                                 if(f3DContainer == NULL){
429                                         f3DContainer = new TList();
430                                         f3DContainer->SetOwner(kTRUE);
431                                         f3DContainer->SetName("3D histograms");
432                                 }
433                                 f3DContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
434                         } else if(histogramString.Contains("HadInt")){// means it should be put in the Table Folder
435                                 if(fHadContainer == NULL){
436                                         fHadContainer = new TList();
437                                         fHadContainer->SetOwner(kTRUE);
438                                         fHadContainer->SetName("Hadronic Interactions histograms");
439                                 }
440                                 fHadContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
441                         } else{
442                                 if(fOtherContainer == NULL){
443                                         fOtherContainer = new TList();
444                                         fOtherContainer->SetOwner(kTRUE);
445                                         fOtherContainer->SetName("Other histograms");
446                                 }
447                                 fOtherContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
448                         }
449                         histogramName = NULL;
450                 } // end while
451
452                 if(fMappingContainer != NULL){
453                         fOutputContainer->Add(fMappingContainer);
454                 }
455                 if(fBackgroundContainer != NULL){
456                         fOutputContainer->Add(fBackgroundContainer);
457                 }
458                 if(fDebugContainer != NULL){
459                         fOutputContainer->Add(fDebugContainer);
460                 }
461                 if(fResolutionContainer != NULL){
462                         fOutputContainer->Add(fResolutionContainer);
463                 }
464                 if(fMatchContainer != NULL){
465                         fOutputContainer->Add(fMatchContainer);
466                 }
467                 if(fESDContainer != NULL){
468                         fOutputContainer->Add(fESDContainer);
469                 }
470                 if(fMCContainer != NULL){
471                         fOutputContainer->Add(fMCContainer);
472                 }
473                 if(fTableContainer !=  NULL){
474                         fOutputContainer->Add(fTableContainer); 
475                 }
476                 if(f3DContainer !=  NULL){
477                         fOutputContainer->Add(f3DContainer);    
478                 }
479                 if(fHadContainer !=  NULL){
480                         fOutputContainer->Add(fHadContainer);   
481                 }
482                 if(fOtherContainer != NULL){
483                         fOutputContainer->Add(fOtherContainer);
484                 }
485         }
486 }
487
488 Int_t AliGammaConversionHistograms::GetRBin(Double_t radius) const{
489   // see header file for documentation
490   Int_t iResult=0;
491 //   if(fDeltaR>0){
492 //     iResult = (Int_t)((radius - fMinRadius)/fDeltaR);
493 //   }
494   for(Int_t i=0;i<fNRIndex;i++){
495     //    cout<<"Test-limits::"<< fRBinLimits[i]<<endl;
496     if( radius>=fRBinLimits[i] && radius<fRBinLimits[i+1] ){
497       iResult=i;
498     }
499   }
500   return iResult;
501 }
502
503 Int_t AliGammaConversionHistograms::GetZBin(Double_t zPos) const{
504   // see header file for documentation
505   Int_t iResult=0;
506
507   for(Int_t i=0;i<fNZIndex;i++){
508     //    cout<<"Test-limits::"<< fZBinLimits[i]<<endl;
509     if( zPos>=fZBinLimits[i] && zPos<fZBinLimits[i+1] ){
510       iResult=i;
511     }
512   }
513   return iResult;
514 }
515
516
517
518 Int_t AliGammaConversionHistograms::GetPhiBin(Double_t phi) const{
519   // see header file for documentation
520   Int_t iResult=0;
521   if(fDeltaPhi>0){
522     if(phi>TMath::Pi()){
523       phi-=2*TMath::Pi();
524     }
525     iResult = (Int_t)((phi - fMinPhi)/fDeltaPhi);
526   }
527   return iResult;
528 }
529
530
531
532 void 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){
533   // Initializing the valuse for the mapping
534         
535   fNPhiIndex = nPhiIndex;
536   if(nRIndex<=14){
537     fNRIndex   = nRIndex;
538   }else{
539     fNRIndex=14;
540   }
541
542   fNZIndex = 13;
543
544   //  fRBinLimits= new Double_t[8];   Kenneth: moved from pointer to fixed array
545   /*
546   fRBinLimits[0]=0.;
547   fRBinLimits[1]=13.;   //changed from 12 to 13: A. Marin 01.03.10
548   fRBinLimits[2]=21.;   //changed from 22 to 21: A. Marin 01.03.10 
549   fRBinLimits[3]=35.;
550   fRBinLimits[4]=55.;
551   fRBinLimits[5]=72.;
552   fRBinLimits[6]=90.;
553   fRBinLimits[7]=500.;
554   */
555
556   fRBinLimits[0]=0.;
557   fRBinLimits[1]=3.5;
558   fRBinLimits[2]=5.75;
559   fRBinLimits[3]=9.5;
560   fRBinLimits[4]=13.;
561   fRBinLimits[5]=21.;
562   fRBinLimits[6]=27.5;
563   fRBinLimits[7]=35.;
564   fRBinLimits[8]=42.;
565   fRBinLimits[9]=55.;
566   fRBinLimits[10]=72.;
567   fRBinLimits[11]=79.5; // change from 81.5 to 79.5 to have CE in 1 r bin 81.05
568   fRBinLimits[12]=90.;
569   fRBinLimits[13]=500.;
570
571
572
573   //  fZBinLimits= new Double_t[7]; Kenneth: moved from pointer to fixed array
574   fZBinLimits[0]=-500.;
575   fZBinLimits[1]=-200.;
576   fZBinLimits[2]=-100.;
577   fZBinLimits[3]=-50.;
578   fZBinLimits[4]=-30.;
579   fZBinLimits[5]=-15.;
580   fZBinLimits[6]= 0.;
581   fZBinLimits[7]= 15.;
582   fZBinLimits[8]= 30.;
583   fZBinLimits[9]= 50.;
584   fZBinLimits[10]=100.;
585   fZBinLimits[11]=200.;
586   fZBinLimits[12]=500.;
587
588
589   fMinRadius      = minRadius;
590   fMaxRadius      = maxRadius;
591   if(nBinsR>0 && nRIndex!=0){
592     fDeltaR       = (fMaxRadius - fMinRadius)/nRIndex;
593   }
594   fMinPhi         = minPhi;
595   fMaxPhi         = maxPhi;
596   if(nBinsPhi>0 && nPhiIndex!=0){
597     fDeltaPhi     = (fMaxPhi-fMinPhi)/nPhiIndex;
598   }
599 }
600
601
602 //mapping
603 void 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){
604   // see header file for documentation
605
606   Double_t tmptogetridofwarning = firstX + lastX + nYBins + firstY + lastY;
607   if(tmptogetridofwarning < 0){
608     cout<<"Less than zero"<<endl;
609   }
610         
611   for(Int_t phi =0; phi<fNPhiIndex;phi++){
612                 
613     for(Int_t r =0; r<fNRIndex;r++){
614                         
615       // setting axis to "" changes below
616       xAxisTitle="z [cm]";
617       yAxisTitle="#eta";
618           
619       //Creating the axis titles
620       //if(xAxisTitle.Length() == 0){
621         //xAxisTitle.Form("Phi %02d",phi);
622          //      }
623                         
624       //if(yAxisTitle.Length() == 0){
625         //yAxisTitle.Form("R %02d",phi);
626                 // }
627                         
628       //MC
629       TString nameMC="";
630       nameMC.Form("MC_Conversion_Mapping_Phi%02d_R%02d",phi,r);
631       TString titleMC="";
632       titleMC.Form("Electron-Positron MC Mapping-Phi%02d-R%02d",phi,r);
633                         
634       //AddHistogram(nameMC, titleMC, nXBins, firstX, lastX, nYBins, firstY, lastY, xAxisTitle, yAxisTitle);
635                         
636       //ESD
637       TString nameESD="";
638       nameESD.Form("ESD_Conversion_Mapping_Phi%02d_R%02d",phi,r);
639       TString titleESD="";
640       titleESD.Form("Electron-Positron ESD Mapping-Phi%02d-R%02d",phi,r);
641                         
642       //AddHistogram(nameESD, titleESD, nXBins, firstX, lastX, nYBins, firstY, lastY, xAxisTitle, yAxisTitle);
643     }
644   }
645         
646         
647   for(Int_t phi =0; phi<=nPhiIndex;phi++){ 
648                 
649     // setting axis to "" changes below
650      xAxisTitle="z [cm]";
651       yAxisTitle="#eta";
652    //Creating the axis titles
653     //if(xAxisTitle.Length() == 0){
654     //  xAxisTitle.Form("Phi %02d",phi);
655     //}
656     //if(yAxisTitle.Length() == 0){
657     //  yAxisTitle = "Counts";
658     //}
659                 
660     //MC
661     TString nameMC="";
662     nameMC.Form("MC_Conversion_Mapping_Phi%02d",phi);
663     TString titleMC="";
664     titleMC.Form("Electron-Positron MC Mapping-Phi%02d",phi);
665                 
666     //AddHistogram(nameMC, titleMC, nXBins, firstX, lastX, nYBins, firstY, lastY, xAxisTitle, yAxisTitle);
667                 
668     //MC
669     TString nameESD="";
670     nameESD.Form("ESD_Conversion_Mapping_Phi%02d",phi);
671     TString titleESD="";
672     titleESD.Form("Electron-Positron ESD Mapping-Phi%02d",phi);
673                 
674     // AddHistogram(nameESD, titleESD, nXBins, firstX, lastX,nYBins, firstY, lastY, xAxisTitle, yAxisTitle);
675   }
676         
677         
678   for(Int_t r =0; r<nRIndex;r++){
679                 
680     // setting axis to "" changes below
681     xAxisTitle="#phi";
682     yAxisTitle="counts";
683     //Creating the axis titles
684     //if(xAxisTitle.Length() == 0){
685     //  xAxisTitle.Form("R %02d",r);
686     //}
687     //if(yAxisTitle.Length() == 0){
688     //  yAxisTitle = "Counts";
689     //}
690                 
691     //MC
692     TString nameMC="";
693     nameMC.Form("MC_Conversion_Mapping_R%02d",r);
694     TString titleMC="";
695     titleMC.Form("Electron-Positron MC Mapping-R%02d",r);
696                 
697     // AddHistogram(nameMC, titleMC, nXBins, firstX, lastX, nYBins, firstY, lastY, xAxisTitle, yAxisTitle);
698                 
699     //ESD
700     TString nameESD="";
701     nameESD.Form("ESD_Conversion_Mapping_R%02d",r);
702     TString titleESD="";
703     titleESD.Form("Electron-Positron ESD Mapping-R%02d",r);
704                 
705     //AddHistogram(nameESD, titleESD, nXBins, firstX, lastX,nYBins, firstY, lastY, xAxisTitle, yAxisTitle);
706                 
707     //Mapping Phi in R
708     TString nameMCPhiInR="";
709     nameMCPhiInR.Form("MC_Conversion_Mapping_Phi_in_R_%02d",r);
710     TString titleMCPhiInR="";
711     titleMCPhiInR.Form("MC Mapping of Phi in R%02d",r);
712     //    AddHistogram(nameMCPhiInR, titleMCPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
713     AddHistogram(nameMCPhiInR, titleMCPhiInR, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);
714                 
715
716     //Mapping Z in R
717     TString nameMCZInR="";
718     nameMCZInR.Form("MC_Conversion_Mapping_Z_in_R_%02d",r);
719     TString titleMCZInR="";
720     titleMCZInR.Form("MC Mapping of Z in R%02d",r);
721     //    AddHistogram(nameMCPhiInR, titleMCPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
722     AddHistogram(nameMCZInR, titleMCZInR, nXBins, -300, 300, xAxisTitle, yAxisTitle);
723
724
725    //Mapping Phi in R Middle Pt
726     TString nameMCMidPtPhiInR="";
727     nameMCMidPtPhiInR.Form("MC_Conversion_Mapping_MidPt_Phi_in_R_%02d",r);
728     TString titleMCMidPtPhiInR="";
729     titleMCMidPtPhiInR.Form("MC Mapping Middle Pt of Phi in R%02d",r);
730     //    AddHistogram(nameMCPhiInR, titleMCPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
731     AddHistogram(nameMCMidPtPhiInR, titleMCMidPtPhiInR, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);
732                 
733
734     //Mapping Z in R Middle Pt
735     TString nameMCMidPtZInR="";
736     nameMCMidPtZInR.Form("MC_Conversion_Mapping_MidPt_Z_in_R_%02d",r);
737     TString titleMCMidPtZInR="";
738     titleMCMidPtZInR.Form("MC Mapping Middle Pt of Z in R%02d",r);
739     //    AddHistogram(nameMCPhiInR, titleMCPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
740     AddHistogram(nameMCMidPtZInR, titleMCMidPtZInR, nXBins, -300, 300, xAxisTitle, yAxisTitle);
741
742
743
744
745     //Mapping Phi in R
746     TString nameESDPhiInR="";
747     nameESDPhiInR.Form("ESD_Conversion_Mapping_Phi_in_R_%02d",r);
748     TString titleESDPhiInR="";
749     titleESDPhiInR.Form("ESD Mapping of Phi in R%02d",r);
750     //    AddHistogram(nameESDPhiInR, titleESDPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);    
751     AddHistogram(nameESDPhiInR, titleESDPhiInR, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);    
752
753    //Mapping Z in R
754     TString nameESDZInR="";
755     nameESDZInR.Form("ESD_Conversion_Mapping_Z_in_R_%02d",r);
756     TString titleESDZInR="";
757     titleESDZInR.Form("ESD Mapping of Z in R%02d",r);
758     //    AddHistogram(nameESDPhiInR, titleESDPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);    
759     AddHistogram(nameESDZInR, titleESDZInR, nXBins, -300, 300, xAxisTitle, yAxisTitle);    
760
761     //Mapping Phi in R Middle Pt 
762     TString nameESDMidPtPhiInR="";
763     nameESDMidPtPhiInR.Form("ESD_Conversion_Mapping_MidPt_Phi_in_R_%02d",r);
764     TString titleESDMidPtPhiInR="";
765     titleESDMidPtPhiInR.Form("ESD Mapping Middle Pt of Phi in R%02d",r);
766     //    AddHistogram(nameESDPhiInR, titleESDPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);    
767     AddHistogram(nameESDMidPtPhiInR, titleESDMidPtPhiInR, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);    
768
769    //Mapping Z in R Middle Pt
770     TString nameESDMidPtZInR="";
771     nameESDMidPtZInR.Form("ESD_Conversion_Mapping_MidPt_Z_in_R_%02d",r);
772     TString titleESDMidPtZInR="";
773     titleESDMidPtZInR.Form("ESD Mapping Middle Pt of Z in R%02d",r);
774     //    AddHistogram(nameESDPhiInR, titleESDPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);    
775     AddHistogram(nameESDMidPtZInR, titleESDMidPtZInR, nXBins, -300, 300, xAxisTitle, yAxisTitle);    
776
777
778  
779   }
780
781
782
783   for(Int_t z =0; z<fNZIndex;z++){
784     //Mapping Phi in Z
785     TString nameMCPhiInZ="";
786     nameMCPhiInZ.Form("MC_Conversion_Mapping_Phi_in_Z_%02d",z);
787     TString titleMCPhiInZ="";
788     titleMCPhiInZ.Form("MC Mapping of Phi in Z%02d",z);
789     //    AddHistogram(nameMCPhiInR, titleMCPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
790     AddHistogram(nameMCPhiInZ, titleMCPhiInZ, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);
791  
792     //Mapping Phi in Z for FMD
793     TString nameMCFMDPhiInZ="";
794     nameMCFMDPhiInZ.Form("MC_Conversion_Mapping_FMD_Phi_in_Z_%02d",z);
795     TString titleMCFMDPhiInZ="";
796     titleMCFMDPhiInZ.Form("MC Mapping FMD of Phi in Z%02d",z);
797     //    AddHistogram(nameMCPhiInR, titleMCPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
798     AddHistogram(nameMCFMDPhiInZ, titleMCFMDPhiInZ, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);
799                 
800     //Mapping Phi in Z for ITSTPC
801     TString nameMCITSTPCPhiInZ="";
802     nameMCITSTPCPhiInZ.Form("MC_Conversion_Mapping_ITSTPC_Phi_in_Z_%02d",z);
803     TString titleMCITSTPCPhiInZ="";
804     titleMCITSTPCPhiInZ.Form("MC Mapping ITSTPC of Phi in Z%02d",z);
805     //    AddHistogram(nameMCPhiInR, titleMCPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
806     AddHistogram(nameMCITSTPCPhiInZ, titleMCITSTPCPhiInZ, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);
807
808     //Mapping Phi in Z for ITSTPC2 
809     TString nameMCITSTPC2PhiInZ="";
810     nameMCITSTPC2PhiInZ.Form("MC_Conversion_Mapping_ITSTPC2_Phi_in_Z_%02d",z);
811     TString titleMCITSTPC2PhiInZ="";
812     titleMCITSTPC2PhiInZ.Form("MC Mapping ITSTPC2 of Phi in Z%02d",z);
813     //    AddHistogram(nameMCPhiInR, titleMCPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
814     AddHistogram(nameMCITSTPC2PhiInZ, titleMCITSTPC2PhiInZ, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);
815
816
817     //Mapping R in Z
818     TString nameMCRInZ="";
819     nameMCRInZ.Form("MC_Conversion_Mapping_R_in_Z_%02d",z);
820     TString titleMCRInZ="";
821     titleMCRInZ.Form("MC Mapping of R in Z%02d",z);
822     //    AddHistogram(nameMCPhiInR, titleMCPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
823     AddHistogram(nameMCRInZ, titleMCRInZ, nXBins, fMinRadius, fMaxRadius, xAxisTitle, yAxisTitle);
824
825    //Mapping Phi in Z Middle Pt
826     TString nameMCMidPtPhiInZ="";
827     nameMCMidPtPhiInZ.Form("MC_Conversion_Mapping_MidPt_Phi_in_Z_%02d",z);
828     TString titleMCMidPtPhiInZ="";
829     titleMCMidPtPhiInZ.Form("MC Mapping Middle Pt of Phi in Z%02d",z);
830     //    AddHistogram(nameMCPhiInR, titleMCPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
831     AddHistogram(nameMCMidPtPhiInZ, titleMCMidPtPhiInZ, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);
832                 
833    //Mapping Phi in Z Middle Pt for FMD
834     TString nameMCMidPtFMDPhiInZ="";
835     nameMCMidPtFMDPhiInZ.Form("MC_Conversion_Mapping_MidPt_FMD_Phi_in_Z_%02d",z);
836     TString titleMCMidPtFMDPhiInZ="";
837     titleMCMidPtFMDPhiInZ.Form("MC Mapping Middle Pt of Phi in Z%02d",z);
838     //    AddHistogram(nameMCPhiInR, titleMCPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
839     AddHistogram(nameMCMidPtFMDPhiInZ, titleMCMidPtFMDPhiInZ, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);
840                 
841
842
843     //Mapping R in Z Middle Pt
844     TString nameMCMidPtRInZ="";
845     nameMCMidPtRInZ.Form("MC_Conversion_Mapping_MidPt_R_in_Z_%02d",z);
846     TString titleMCMidPtRInZ="";
847     titleMCMidPtRInZ.Form("MC Mapping Middle Pt of R in Z%02d",z);
848     //    AddHistogram(nameMCPhiInR, titleMCPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
849     AddHistogram(nameMCMidPtRInZ, titleMCMidPtRInZ, nXBins, fMinRadius, fMaxRadius, xAxisTitle, yAxisTitle);
850
851
852
853
854     //Mapping Phi in Z
855     TString nameESDPhiInZ="";
856     nameESDPhiInZ.Form("ESD_Conversion_Mapping_Phi_in_Z_%02d",z);
857     TString titleESDPhiInZ="";
858     titleESDPhiInZ.Form("ESD Mapping of Phi in Z%02d",z);
859     //    AddHistogram(nameESDPhiInR, titleESDPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);    
860     AddHistogram(nameESDPhiInZ, titleESDPhiInZ, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);    
861
862
863     //Mapping Phi in Z for FMD
864     TString nameESDFMDPhiInZ="";
865     nameESDFMDPhiInZ.Form("ESD_Conversion_Mapping_FMD_Phi_in_Z_%02d",z);
866     TString titleESDFMDPhiInZ="";
867     titleESDFMDPhiInZ.Form("ESD Mapping FMD of Phi in Z%02d",z);
868     //    AddHistogram(nameESDPhiInR, titleESDPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);    
869     AddHistogram(nameESDFMDPhiInZ, titleESDFMDPhiInZ, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);    
870
871     //Mapping Phi in Z for ITSTPC
872     TString nameESDITSTPCPhiInZ="";
873     nameESDITSTPCPhiInZ.Form("ESD_Conversion_Mapping_ITSTPC_Phi_in_Z_%02d",z);
874     TString titleESDITSTPCPhiInZ="";
875     titleESDITSTPCPhiInZ.Form("ESD Mapping ITSTPC of Phi in Z%02d",z);
876     //    AddHistogram(nameESDPhiInR, titleESDPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);    
877     AddHistogram(nameESDITSTPCPhiInZ, titleESDITSTPCPhiInZ, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);    
878
879    //Mapping Phi in Z for ITSTPC2
880     TString nameESDITSTPC2PhiInZ="";
881     nameESDITSTPC2PhiInZ.Form("ESD_Conversion_Mapping_ITSTPC2_Phi_in_Z_%02d",z);
882     TString titleESDITSTPC2PhiInZ="";
883     titleESDITSTPC2PhiInZ.Form("ESD Mapping ITSTPC2 of Phi in Z%02d",z);
884     //    AddHistogram(nameESDPhiInR, titleESDPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);    
885     AddHistogram(nameESDITSTPC2PhiInZ, titleESDITSTPC2PhiInZ, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);    
886
887
888    //Mapping R in Z
889     TString nameESDRInZ="";
890     nameESDRInZ.Form("ESD_Conversion_Mapping_R_in_Z_%02d",z);
891     TString titleESDRInZ="";
892     titleESDRInZ.Form("ESD Mapping of R in Z%02d",z);
893     //    AddHistogram(nameESDPhiInR, titleESDPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);    
894     AddHistogram(nameESDRInZ, titleESDRInZ, nXBins, fMinRadius, fMaxRadius, xAxisTitle, yAxisTitle);    
895
896
897    //Mapping Phi in Z Middle Pt
898     TString nameESDMidPtPhiInZ="";
899     nameESDMidPtPhiInZ.Form("ESD_Conversion_Mapping_MidPt_Phi_in_Z_%02d",z);
900     TString titleESDMidPtPhiInZ="";
901     titleESDMidPtPhiInZ.Form("ESD Mapping Middle Ptof Phi in R%02d",z);
902     //    AddHistogram(nameESDPhiInR, titleESDPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);    
903     AddHistogram(nameESDMidPtPhiInZ, titleESDMidPtPhiInZ, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);    
904
905    //Mapping Phi in Z Middle Pt for FMD
906     TString nameESDMidPtFMDPhiInZ="";
907     nameESDMidPtFMDPhiInZ.Form("ESD_Conversion_Mapping_MidPt_FMD_Phi_in_Z_%02d",z);
908     TString titleESDMidPtFMDPhiInZ="";
909     titleESDMidPtFMDPhiInZ.Form("ESD Mapping Middle Pt FMD of Phi in Z%02d",z);
910     //    AddHistogram(nameESDPhiInR, titleESDPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);    
911     AddHistogram(nameESDMidPtFMDPhiInZ, titleESDMidPtFMDPhiInZ, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);    
912
913
914    //Mapping R in Z Middle Pt
915     TString nameESDMidPtRInZ="";
916     nameESDMidPtRInZ.Form("ESD_Conversion_Mapping_MidPt_R_in_Z_%02d",z);
917     TString titleESDMidPtRInZ="";
918     titleESDMidPtRInZ.Form("ESD Mapping Middle Pt of R in Z%02d",z);
919     //    AddHistogram(nameESDPhiInR, titleESDPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);    
920     AddHistogram(nameESDMidPtRInZ, titleESDMidPtRInZ, nXBins, fMinRadius, fMaxRadius, xAxisTitle, yAxisTitle);    
921
922
923
924   }
925
926
927
928 }