]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/macros/ConfigGammaConversion.C
Changed to new naming scheme for histograms, added functionality to the analysis...
[u/mrichter/AliRoot.git] / PWG4 / macros / ConfigGammaConversion.C
1 /** VERSION NUMBER 0 */
2 /** new Version Kenneth */
3
4 Bool_t usePWG4PartCorr = kTRUE;
5
6
7 /** ------------------------------ Monte Carlo flag -----------------------------------------*/
8 Bool_t doMCTruth = kTRUE;
9 /** ---------------------------- end Monte Carlo flag ---------------------------------------*/
10
11 /** ------------------------- Choose KFParticle OR ESDTrack  --------------------------------*/
12 Bool_t useKFParticle = kTRUE;
13 Bool_t useESDTrack   = kFALSE;
14 /** ----------------------- end Choose KFParticle OR ESDTrack  -----------------------------*/
15
16
17 Bool_t calculateBackground = kTRUE;
18
19 Int_t numberOfFilesToAnalyze=0;
20
21 /** ---------------------------------- define cuts here ------------------------------------*/
22
23 Int_t pidOfNegativeTrack=11;
24 Int_t pidOfPositiveTrack=-11;
25
26 Double_t LineCutZRSlope = 0.662487;
27 Double_t LineCutZValue = 7.;
28
29 Double_t maxRCut   = 160.;
30 Double_t etaCut    = 1.2;
31 Double_t ptCut     = 0.02;
32 Double_t chi2CutConversion   = 20.;
33 Double_t chi2CutMeson   = 20.;
34
35 Double_t xVertexCut = 0.;
36 Double_t yVertexCut = 0.;
37 Double_t zVertexCut = 0.;
38
39 Double_t sigmaCutGammaMass=0.0001;
40
41 Bool_t useImprovedVertex = kTRUE;
42
43 // define masses of different particles, this will be used by the KF particle
44 // together with the width to set mass constraints. Units in GeV.
45 Double_t electronMass = 0.00051099892;
46 Double_t gammaMass    = 0.;
47 Double_t pi0Mass      = 0.1349766;
48 Double_t etaMass      = 0.54751;
49
50 // define the width constraint used by KF particle.
51 Double_t gammaWidth = 0.01;
52 Double_t pi0Width   = 0.01;
53 Double_t etaWidth   = 0.01;
54
55 // define the probability of track being an electron
56 Double_t probElectron = 0.002;
57
58 Double_t minOpeningAngleGhostCut = 0.01;
59
60 /** ----------------------------------end define cuts here----------------------------------*/
61
62 /** -------------------------------- Phi/R Mapping ---------------------------------------*/
63 Int_t nPhiIndex = 18;
64 Int_t nRIndex   = 40;
65
66 Double_t minRadius   = 0.;
67 Double_t maxRadius   = 200.;
68 Double_t minPhi      = -TMath::Pi();
69 Double_t maxPhi      = TMath::Pi();
70 /** ------------------------------- end Phi/R Mapping ------------------------------------*/
71
72
73
74 /** ------------------- define which histograms to plot here --------------------------------*/
75 /**   NB: to change the bin numbers, see below the histogram flags                           */
76 Bool_t plotMCConversionR             = kTRUE;
77 Bool_t plotMCConversionZR            = kTRUE;
78 Bool_t plotMCConversionXY            = kTRUE;
79 Bool_t plotMCConversionOpeningAngle  = kTRUE;
80
81 Bool_t plotMCEEnergy  = kTRUE;
82 Bool_t plotMCEPt      = kTRUE;
83 Bool_t plotMCEEta     = kTRUE;
84 Bool_t plotMCEPhi     = kTRUE;
85
86 Bool_t plotMCPEnergy  = kTRUE;
87 Bool_t plotMCPPt      = kTRUE;
88 Bool_t plotMCPEta     = kTRUE;
89 Bool_t plotMCPPhi     = kTRUE;
90
91 Bool_t plotMCallGammaEnergy = kTRUE;
92 Bool_t plotMCallGammaPt     = kTRUE;
93 Bool_t plotMCallGammaEta    = kTRUE;
94 Bool_t plotMCallGammaPhi    = kTRUE;
95 Bool_t plotMCallGammaRapid  = kTRUE;
96
97
98 Bool_t plotMCConvGammaEnergy  = kTRUE;
99 Bool_t plotMCConvGammaPt      = kTRUE;
100 Bool_t plotMCConvGammaEta     = kTRUE;
101 Bool_t plotMCConvGammaPhi     = kTRUE;
102 Bool_t plotMCConvGammaRapid   = kTRUE;
103 Bool_t plotMCConvGammaPtvsEta = kTRUE;
104
105 Bool_t plotMCallDirectGammaEnergy  = kTRUE;
106 Bool_t plotMCallDirectGammaPt      = kTRUE;
107 Bool_t plotMCallDirectGammaEta     = kTRUE;
108 Bool_t plotMCallDirectGammaPhi     = kTRUE;
109 Bool_t plotMCallDirectGammaRapid   = kTRUE;
110
111
112 Bool_t plotMCConvDirectGammaEnergy  = kTRUE;
113 Bool_t plotMCConvDirectGammaPt      = kTRUE;
114 Bool_t plotMCConvDirectGammaEta     = kTRUE;
115 Bool_t plotMCConvDirectGammaPhi     = kTRUE;
116 Bool_t plotMCConvDirectGammaRapid   = kTRUE;
117
118 Bool_t plotMCMotherEta                                  = kTRUE;
119 Bool_t plotMCMotherRapid                                = kTRUE;
120 Bool_t plotMCMotherPhi                                  = kTRUE;
121 Bool_t plotMCMotherPt                                   = kTRUE;
122 Bool_t plotMCMotherEnergy                               = kTRUE;
123 Bool_t plotMCMotherMass                                 = kTRUE;
124 Bool_t plotMCMotherOpeningAngle                         = kTRUE;
125 Bool_t plotMCMotherR                                    = kTRUE;
126 Bool_t plotMCMotherZR                                   = kTRUE;
127 Bool_t plotMCMotherXY                                   = kTRUE;
128 Bool_t plotMCMotherPtvsEtaWithinAcceptance              = kTRUE;
129 Bool_t plotMCMotherPtvsRapidWithinAcceptance            = kTRUE;
130 Bool_t plotMCMotherPtvsEtaConvGammaWithinAcceptance     = kTRUE;
131 Bool_t plotMCMotherPtvsRapidConvGammaWithinAcceptance   = kTRUE;
132 Bool_t plotMCMotherSpectra                              = kTRUE;
133
134 Bool_t plotMCPi0Eta                                = kTRUE;
135 Bool_t plotMCPi0Rapid                              = kTRUE;
136 Bool_t plotMCPi0Phi                                = kTRUE;
137 Bool_t plotMCPi0Pt                                 = kTRUE;
138 Bool_t plotMCPi0Energy                             = kTRUE;
139 Bool_t plotMCPi0Mass                               = kTRUE;
140 Bool_t plotMCPi0OpeningAngle                       = kTRUE;
141 Bool_t plotMCPi0R                                  = kTRUE;
142 Bool_t plotMCPi0ZR                                 = kTRUE;
143 Bool_t plotMCPi0XY                                 = kTRUE;
144 Bool_t plotMCPi0PtvsEtaWithinAcceptance            = kTRUE;
145 Bool_t plotMCPi0PtvsRapidWithinAcceptance          = kTRUE;
146 Bool_t plotMCPi0PtvsEtaConvGammaWithinAcceptance   = kTRUE;
147 Bool_t plotMCPi0PtvsRapidConvGammaWithinAcceptance = kTRUE;
148
149
150 Bool_t plotMCPi0SecondaryEta                                = kTRUE;
151 Bool_t plotMCPi0SecondaryRapid                              = kTRUE;
152 Bool_t plotMCPi0SecondaryPhi                                = kTRUE;
153 Bool_t plotMCPi0SecondaryPt                                 = kTRUE;
154 Bool_t plotMCPi0SecondaryEnergy                             = kTRUE;
155 Bool_t plotMCPi0SecondaryMass                               = kTRUE;
156 Bool_t plotMCPi0SecondaryOpeningAngle                       = kTRUE;
157 Bool_t plotMCPi0SecondaryR                                  = kTRUE;
158 Bool_t plotMCPi0SecondaryZR                                 = kTRUE;
159 Bool_t plotMCPi0SecondaryXY                                 = kTRUE;
160 Bool_t plotMCPi0SecondaryPtvsEtaWithinAcceptance            = kTRUE;
161 Bool_t plotMCPi0SecondaryPtvsRapidWithinAcceptance          = kTRUE;
162 Bool_t plotMCPi0SecondaryPtvsEtaConvGammaWithinAcceptance   = kTRUE;
163 Bool_t plotMCPi0SecondaryPtvsRapidConvGammaWithinAcceptance = kTRUE;
164
165
166 Bool_t plotMCEtaEta                                = kTRUE;
167 Bool_t plotMCEtaRapid                              = kTRUE;
168 Bool_t plotMCEtaPhi                                = kTRUE;
169 Bool_t plotMCEtaPt                                 = kTRUE;
170 Bool_t plotMCEtaEnergy                             = kTRUE;
171 Bool_t plotMCEtaMass                               = kTRUE;
172 Bool_t plotMCEtaOpeningAngleGamma                  = kTRUE;
173 Bool_t plotMCEtaR                                  = kTRUE;
174 Bool_t plotMCEtaZR                                 = kTRUE;
175 Bool_t plotMCEtaXY                                 = kTRUE;
176 Bool_t plotMCEtaPtvsEtaWithinAcceptance            = kTRUE;
177 Bool_t plotMCEtaPtvsRapidWithinAcceptance          = kTRUE;
178 Bool_t plotMCEtaPtvsEtaConvGammaWithinAcceptance   = kTRUE;
179 Bool_t plotMCEtaPtvsRapidConvGammaWithinAcceptance = kTRUE;
180
181
182 // Histograms from esd tracks
183 Bool_t plotESDConversionR            = kTRUE;
184 Bool_t plotESDConversionZR           = kTRUE;
185 Bool_t plotESDConversionXY           = kTRUE;
186 Bool_t plotESDConversionOpeningAngle = kTRUE;
187
188 Bool_t plotESDEEnergy = kTRUE;
189 Bool_t plotESDEPt     = kTRUE;
190 Bool_t plotESDEEta    = kTRUE;
191 Bool_t plotESDEPhi    = kTRUE;
192
193 Bool_t plotESDPEnergy = kTRUE;
194 Bool_t plotESDPPt     = kTRUE;
195 Bool_t plotESDPEta    = kTRUE;
196 Bool_t plotESDPPhi    = kTRUE;
197
198 Bool_t plotESDConvGammaEnergy = kTRUE;
199 Bool_t plotESDConvGammaPt     = kTRUE;
200 Bool_t plotESDConvGammaEta    = kTRUE;
201 Bool_t plotESDConvGammaPhi    = kTRUE;
202 Bool_t plotESDConvGammaMass   = kTRUE;
203 Bool_t plotESDConvGammaWidth  = kTRUE;
204 Bool_t plotESDConvGammaChi2   = kTRUE;
205 Bool_t plotESDConvGammaNDF    = kTRUE;
206 Bool_t plotESDConvGammaRapid  = kTRUE;
207 Bool_t plotESDConvGammaPtvsEta = kTRUE;
208
209 Bool_t plotESDTrueConvGammaEnergy         = kTRUE;
210 Bool_t plotESDTrueConvGammaPt             = kTRUE;
211 Bool_t plotESDTrueConvGammaEta            = kTRUE;
212 Bool_t plotESDTrueConvGammaPhi            = kTRUE;
213 Bool_t plotESDTrueConvGammaMass           = kTRUE;
214 Bool_t plotESDTrueConvGammaWidth          = kTRUE;
215 Bool_t plotESDTrueConvGammaChi2           = kTRUE;
216 Bool_t plotESDTrueConvGammaNDF            = kTRUE;
217 Bool_t plotESDTrueConvGammaRapid          = kTRUE;
218 Bool_t plotESDTrueConvGammaPtvsEta        = kTRUE;
219 Bool_t plotESDTrueConversionR             = kTRUE;
220 Bool_t plotESDTrueConversionZR            = kTRUE;
221 Bool_t plotESDTrueConversionXY            = kTRUE;
222 Bool_t plotESDTrueConversionOpeningAngle  = kTRUE;
223
224 Bool_t plotESDNoCutConvGammaEnergy         = kTRUE;
225 Bool_t plotESDNoCutConvGammaPt             = kTRUE;
226 Bool_t plotESDNoCutConvGammaEta            = kTRUE;
227 Bool_t plotESDNoCutConvGammaPhi            = kTRUE;
228 Bool_t plotESDNoCutConvGammaMass           = kTRUE;
229 Bool_t plotESDNoCutConvGammaWidth          = kTRUE;
230 Bool_t plotESDNoCutConvGammaChi2           = kTRUE;
231 Bool_t plotESDNoCutConvGammaNDF            = kTRUE;
232 Bool_t plotESDNoCutConvGammaRapid          = kTRUE;
233 Bool_t plotESDNoCutConvGammaPtvsEta        = kTRUE;
234 Bool_t plotESDNoCutConversionR             = kTRUE;
235 Bool_t plotESDNoCutConversionZR            = kTRUE;
236 Bool_t plotESDNoCutConversionXY            = kTRUE;
237 Bool_t plotESDNoCutConversionOpeningAngle  = kTRUE;
238
239 Bool_t plotESDMotherOpeningAngleGamma = kTRUE;
240 Bool_t plotESDMotherEnergy            = kTRUE;
241 Bool_t plotESDMotherPt                = kTRUE;
242 Bool_t plotESDMotherEta               = kTRUE;
243 Bool_t plotESDMotherPhi               = kTRUE;
244 Bool_t plotESDMotherMass              = kTRUE;
245 Bool_t plotESDMotherR                 = kTRUE;
246 Bool_t plotESDMotherZR                = kTRUE;
247 Bool_t plotESDMotherXY                = kTRUE;
248 Bool_t plotESDMotherRapid             = kTRUE;
249
250
251 Bool_t plotESDBackgroundOpeningAngleGamma = kTRUE;
252 Bool_t plotESDBackgroundEnergy            = kTRUE;
253 Bool_t plotESDBackgroundPt                = kTRUE;
254 Bool_t plotESDBackgroundEta               = kTRUE;
255 Bool_t plotESDBackgroundPhi               = kTRUE;
256 Bool_t plotESDBackgroundMass              = kTRUE;
257 Bool_t plotESDBackgroundR                 = kTRUE;
258 Bool_t plotESDBackgroundZR                = kTRUE;
259 Bool_t plotESDBackgroundXY                = kTRUE;
260 Bool_t plotESDBackgroundRapid             = kTRUE;
261
262
263
264 Bool_t plotMapping = kFALSE;       
265
266 Bool_t plotResolutiondPt = kTRUE;
267 Bool_t plotResolutiondR  = kTRUE;
268 Bool_t plotResolutiondZ  = kTRUE;
269
270 Bool_t plotResolutiondRdPt = kTRUE;
271
272 Bool_t plotResolutionMCPt = kTRUE;
273 Bool_t plotResolutionMCR  = kTRUE;
274 Bool_t plotResolutionMCZ  = kTRUE;
275
276 Bool_t plotResolutionESDPt = kTRUE;
277 Bool_t plotResolutionESDR  = kTRUE;
278 Bool_t plotResolutionESDZ  = kTRUE;
279
280 Bool_t plotESDNumberOfV0s          = kTRUE;
281 Bool_t plotESDNumberOfSurvivingV0s = kTRUE;
282
283 //  debug histograms
284 Bool_t plotESDCutGetOnFly      = kTRUE;
285 Bool_t plotESDCutNContributors = kTRUE;
286 Bool_t plotESDCutLikeSign      = kTRUE;
287 Bool_t plotESDCutRefit         = kTRUE;
288 Bool_t plotESDCutKink          = kTRUE;
289 Bool_t plotESDCutPIDProb       = kTRUE;
290 Bool_t plotESDCutR             = kTRUE;
291 Bool_t plotESDCutLine          = kTRUE;
292 Bool_t plotESDCutNDF           = kTRUE;
293 Bool_t plotESDCutChi2          = kTRUE;
294 Bool_t plotESDCutEta           = kTRUE;
295 Bool_t plotESDCutPt            = kTRUE;
296 Bool_t plotESDTrueConvGammaTrackLength =kTRUE;
297 Bool_t plotESDTrueConvGammaTrackLengthVSInvMass =kTRUE;
298
299
300 Bool_t plotPi0Spectra = kTRUE;
301 Bool_t plotEtaSpectra = kTRUE;
302
303
304 /** ----------------- end define which histograms to plot here -------------------------------*/
305
306
307
308 /** ----------- Define the binning for the different plot types here -------------------------*/
309 //R-plots
310 Int_t nXBinsR = 500;
311 Double_t firstXBinR = 0.;
312 Double_t lastXBinR = 250.;
313
314 //ZR-plots
315 Int_t nXBinsZR = 1200;
316 Double_t firstXBinZR = -300.;
317 Double_t lastXBinZR = 300.;
318 Int_t nYBinsZR = 500;
319 Double_t firstYBinZR = 0.;
320 Double_t lastYBinZR = 250.;
321
322 //XY-plots
323 Int_t nXBinsXY = 1000;
324 Double_t firstXBinXY = -250.;
325 Double_t lastXBinXY = 250.;
326 Int_t nYBinsXY = 1000;
327 Double_t firstYBinXY = -250.;
328 Double_t lastYBinXY = 250.;
329
330 //OpenAngle-plots
331 Int_t nXBinsOpeningAngle = 400;
332 Double_t firstXBinOpeningAngle = 0.;
333 Double_t lastXBinOpeningAngle = TMath::Pi();
334
335 //Energy-plots
336 Int_t nXBinsEnergy = 200;
337 Double_t firstXBinEnergy = 0.;
338 Double_t lastXBinEnergy = 50.;
339
340 //Pt-plots
341 Int_t nXBinsPt = 200;
342 Double_t firstXBinPt = 0.;
343 Double_t lastXBinPt = 50.;
344
345 //Eta-plots
346 Int_t nXBinsEta = 40;
347 Double_t firstXBinEta = -2.;
348 Double_t lastXBinEta = 2.;
349
350 //Rapidity
351 Int_t nXBinsRapid = 200;
352 Double_t firstXBinRapid = -10.;
353 Double_t lastXBinRapid = 10.;
354
355 //Phi-plots
356 Int_t nXBinsPhi = 72;
357 Double_t firstXBinPhi = -TMath::Pi();
358 Double_t lastXBinPhi = TMath::Pi();
359
360 //Mapping-plots
361 Int_t nXBinsMapping = 400;
362 Double_t firstXBinMapping = -100.;
363 Double_t lastXBinMapping = 100.;
364 Int_t nYBinsMapping = 40;
365 Double_t firstYBinMapping = -2;
366 Double_t lastYBinMapping = 2;
367
368 //ResolutionPlots
369 //RESdPt
370 Int_t nXBinsResdPt=500;
371 Int_t firstXBinResdPt= 0;
372 Int_t lastXBinResdPt=5;
373 Int_t nYBinsResdPt=1000;
374 Int_t firstYBinResdPt= -5;
375 Int_t lastYBinResdPt=5;
376
377 //RESdR
378 Int_t nXBinsResdR=500;
379 Int_t firstXBinResdR= 0;
380 Int_t lastXBinResdR=250;
381 Int_t nYBinsResdR=100;
382 Int_t firstYBinResdR= -25;
383 Int_t lastYBinResdR=25;
384
385 //RESdZ
386 Int_t nXBinsResdZ=80;
387 Int_t firstXBinResdZ= -20;
388 Int_t lastXBinResdZ=20;
389 Int_t nYBinsResdZ=80;
390 Int_t firstYBinResdZ= -20;
391 Int_t lastYBinResdZ=20;
392
393 //RESdRdPt
394 Int_t nXBinsResdRdPt=440;
395 Int_t firstXBinResdRdPt= -22;
396 Int_t lastXBinResdRdPt=22;
397 Int_t nYBinsResdRdPt=100;
398 Int_t firstYBinResdRdPt= -5;
399 Int_t lastYBinResdRdPt=5;
400
401 //RESMCPt
402 Int_t nXBinsResPt=100;
403 Int_t firstXBinResPt= 0;
404 Int_t lastXBinResPt=5;
405
406 //RESMCR
407 Int_t nXBinsResR=500;
408 Int_t firstXBinResR= 0;
409 Int_t lastXBinResR=250;
410
411 //RESMCZ
412 Int_t nXBinsResZ=500;
413 Int_t firstXBinResZ= 0;
414 Int_t lastXBinResZ=250;
415
416 //GammaMass-plots
417 Int_t nXBinsGammaMass = 4000;
418 Double_t firstXBinGammaMass = 0.;
419 Double_t lastXBinGammaMass = 1.;
420
421 //Pi0Mass-plots
422 Int_t nXBinsPi0Mass = 100;
423 Double_t firstXBinPi0Mass = 0.;
424 Double_t lastXBinPi0Mass = 1.;
425
426 //EtaMass-plots
427 Int_t nXBinsEtaMass = 100;
428 Double_t firstXBinEtaMass = 0.;
429 Double_t lastXBinEtaMass = 1.;
430
431 //GammaWidth-plots
432 Int_t nXBinsGammaWidth = 100;
433 Double_t firstXBinGammaWidth = 0.;
434 Double_t lastXBinGammaWidth = 1.;
435
436 //GammaChi2-plots
437 Int_t nXBinsGammaChi2 = 100;
438 Double_t firstXBinGammaChi2 = 0;
439 Double_t lastXBinGammaChi2 = 100.;
440
441 //GammaNDF-plots
442 Int_t nXBinsGammaNDF = 10;
443 Double_t firstXBinGammaNDF = 0.;
444 Double_t lastXBinGammaNDF = 10.;
445
446 //Spectra-plots
447 Int_t nXBinsSpectra = 500;
448 Double_t firstXBinSpectra = 0.;
449 Double_t lastXBinSpectra = 1.;
450 Int_t nYBinsSpectra = 100;
451 Double_t firstYBinSpectra = 0.;
452 Double_t lastYBinSpectra = 50.;
453
454 //track length plots
455 Int_t nXBinsTrackLength = 1000;
456 Double_t firstXBinTrackLength = 0;
457 Double_t lastXBinTrackLength = 500;
458
459 /** ---------- end Define the binning for the different plot types here ----------------------*/
460
461
462 /************************************************************************************************
463  *                                                                                              *
464  *                                                                                              *
465  *                     EVERYTHING BELOW IS FOR DEVELOPERS ONLY                                  *
466  *                                                                                              *
467  *                                                                                              *
468  ************************************************************************************************/
469 TString outputFileName = "histogramsGammaConversion";
470 TString outputFileAppendix = "";
471 TString dataList = "";
472 Bool_t writeNtuple = kFALSE;
473
474 Bool_t scanArguments(TString arguments){
475   Bool_t iResult = kTRUE;
476         
477   //  cout<<"All arguments: "<<arguments<<endl;
478         
479   TString allArgs=arguments;
480   TString argument;
481   int bMissingParam=0;
482         
483   TObjArray* pTokens=allArgs.Tokenize(" ");
484   if (pTokens) {
485                 
486     for(int i=0; i<pTokens->GetEntries() && iResult==kTRUE; i++) {
487       argument=((TObjString*)pTokens->At(i))->GetString();
488                         
489       if(argument.IsNull()) continue;
490       // -- deconvolute-time option
491       if(argument.CompareTo("-data-list") == 0){
492         if((bMissingParam=(++i>=pTokens->GetEntries()))) break;
493         dataList = ((TObjString*)pTokens->At(i))->GetString();
494         if(dataList.IsNull()){
495           cout<<"-data-list is NULL"<<endl;
496           iResult=kFALSE;
497         }
498         else{
499           cout<<"Data list is set to: "<<dataList<<endl;
500         }
501       }
502       else if(argument.CompareTo("-output-file-name") == 0){
503         if((bMissingParam=(++i>=pTokens->GetEntries()))) break;
504         outputFileName = ((TObjString*)pTokens->At(i))->GetString();
505         if(outputFileName.IsNull()){
506           cout<<"-output-file-name is NULL"<<endl;
507           iResult=kFALSE;
508         }
509         else{
510           cout<<"Setting output file name to: "<<outputFileName<<endl;
511         }
512       }
513       else if (argument.CompareTo("-write-ntuple") == 0){
514         cout<<"Writing ntuple to file."<<endl;
515         writeNtuple = kTRUE;
516       }
517       else if(argument.CompareTo("-append-to-output-file") == 0){
518         if((bMissingParam=(++i>=pTokens->GetEntries()))) break;
519         outputFileAppendix = "_"+((TObjString*)pTokens->At(i))->GetString();
520         if(outputFileAppendix.IsNull()){
521           cout<<"-appending-to-output-file is NULL"<<endl;
522           iResult=kFALSE;
523         }
524         else{
525           cout<<"Appending to the output file: "<<outputFileAppendix<<endl;
526         }
527       }
528     }
529                 
530     delete pTokens;
531   }
532   if (bMissingParam) {
533     cout<<"Missing parameter for argument "<< argument.Data()<<endl;
534     iResult=kFALSE;
535   }
536   return iResult;
537 }
538
539 void ConfigGammaConversion(TString arguments){
540         
541   if(!scanArguments(arguments)){
542     break;
543   }
544         
545   if(numberOfFilesToAnalyze==0){
546     ifstream dataInStream;
547     dataInStream.open(dataList.Data());
548     if ( !dataInStream ){
549       cout<<"Data list file does not exist: "<<dataList.Data()<<endl;
550       return 0;
551     }
552     string line;
553     while ( !dataInStream.eof() )
554       {
555         getline(dataInStream, line);
556         if(line.compare("") != 0){//checks if there is an empty line in the data list
557           numberOfFilesToAnalyze++;
558         }
559       }
560   }
561   cout<<"Number Of files to analyze: "<<numberOfFilesToAnalyze<<endl;
562         
563   build();//build (if necessary) and load the libraries needed
564         
565   gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C"); // load the CreateChain macro
566         
567   AliLog::SetGlobalLogLevel(AliLog::kError);
568         
569   //-------------------------------- Creating the histograms -------------------------------
570   AliGammaConversionHistograms * histograms = new AliGammaConversionHistograms();
571         
572   if(plotMCConversionR == kTRUE){ histograms->AddHistogram("MC_Conversion_R","Radius of gamma conversion points",nXBinsR, firstXBinR, lastXBinR,"counts","cm");}
573   if(plotMCConversionZR == kTRUE){ histograms->AddHistogram("MC_Conversion_ZR","Radius of gamma conversion points vs Z",nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "cm", "cm");}
574   if(plotMCConversionXY == kTRUE){ histograms->AddHistogram("MC_Conversion_XY","Gamma XY converison point.",nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "cm", "cm");}
575   if(plotMCConversionOpeningAngle == kTRUE){ histograms->AddHistogram("MC_Conversion_OpeningAngle","Opening angle of e+e- pairs from gamma conversion",nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "counts", "cm");}
576         
577   if(plotMCEEnergy == kTRUE){ histograms->AddHistogram("MC_E_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
578   if(plotMCEPt == kTRUE){ histograms->AddHistogram("MC_E_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
579   if(plotMCEEta == kTRUE){ histograms->AddHistogram("MC_E_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
580   if(plotMCEPhi == kTRUE){ histograms->AddHistogram("MC_E_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
581         
582   if(plotMCPEnergy == kTRUE){ histograms->AddHistogram("MC_P_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
583   if(plotMCPPt == kTRUE){ histograms->AddHistogram("MC_P_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
584   if(plotMCPEta == kTRUE){ histograms->AddHistogram("MC_P_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
585   if(plotMCPPhi == kTRUE){ histograms->AddHistogram("MC_P_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
586         
587   if(plotMCallGammaEnergy == kTRUE){ histograms->AddHistogram("MC_allGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
588   if(plotMCallGammaPt == kTRUE){ histograms->AddHistogram("MC_allGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
589   if(plotMCallGammaEta == kTRUE){ histograms->AddHistogram("MC_allGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
590   if(plotMCallGammaPhi == kTRUE){ histograms->AddHistogram("MC_allGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
591   if(plotMCallGammaRapid == kTRUE){ histograms->AddHistogram("MC_allGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
592         
593   if(plotMCConvGammaEnergy == kTRUE){ histograms->AddHistogram("MC_ConvGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
594   if(plotMCConvGammaPt == kTRUE){ histograms->AddHistogram("MC_ConvGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
595   if(plotMCConvGammaEta == kTRUE){ histograms->AddHistogram("MC_ConvGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
596   if(plotMCConvGammaPhi == kTRUE){ histograms->AddHistogram("MC_ConvGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
597   if(plotMCConvGammaRapid == kTRUE){ histograms->AddHistogram("MC_ConvGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
598   if(plotMCConvGammaPtvsEta == kTRUE){ histograms->AddHistogram("MC_ConvGamma_Pt_Eta","", nXBinsPt, firstXBinPt, lastXBinPt,nXBinsEta, firstXBinEta, lastXBinEta,"","");}
599         
600   if(plotMCallDirectGammaEnergy == kTRUE){ histograms->AddHistogram("MC_allDirectGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
601   if(plotMCallDirectGammaPt == kTRUE){ histograms->AddHistogram("MC_allDirectGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
602   if(plotMCallDirectGammaEta == kTRUE){ histograms->AddHistogram("MC_allDirectGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
603   if(plotMCallDirectGammaPhi == kTRUE){ histograms->AddHistogram("MC_allDirectGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
604   if(plotMCallDirectGammaRapid == kTRUE){ histograms->AddHistogram("MC_allDirectGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
605         
606   if(plotMCConvDirectGammaEnergy == kTRUE){ histograms->AddHistogram("MC_ConvDirectGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
607   if(plotMCConvDirectGammaPt == kTRUE){ histograms->AddHistogram("MC_ConvDirectGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
608   if(plotMCConvDirectGammaEta == kTRUE){ histograms->AddHistogram("MC_ConvDirectGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
609   if(plotMCConvDirectGammaPhi == kTRUE){ histograms->AddHistogram("MC_ConvDirectGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
610   if(plotMCConvDirectGammaRapid == kTRUE){ histograms->AddHistogram("MC_ConvDirectGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
611         
612   if(plotMCMotherEta == kTRUE){ histograms->AddHistogram("MC_Mother_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
613   if(plotMCMotherPhi == kTRUE){ histograms->AddHistogram("MC_Mother_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
614   if(plotMCMotherRapid == kTRUE){ histograms->AddHistogram("MC_Mother_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
615   if(plotMCMotherPt == kTRUE){ histograms->AddHistogram("MC_Mother_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
616   if(plotMCMotherEnergy == kTRUE){ histograms->AddHistogram("MC_Mother_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
617   if(plotMCMotherMass == kTRUE){ histograms->AddHistogram("MC_Mother_Mass" ,"" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass, "", "");}
618   if(plotMCMotherOpeningAngle == kTRUE){ histograms->AddHistogram("MC_Mother_GammaDaughter_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
619   if(plotMCMotherR == kTRUE){ histograms->AddHistogram("MC_Mother_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
620   if(plotMCMotherZR == kTRUE){ histograms->AddHistogram("MC_Mother_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
621   if(plotMCMotherXY == kTRUE){ histograms->AddHistogram("MC_Mother_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
622   if(plotMCMotherPtvsEtaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Mother_Pt_Eta_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
623   if(plotMCMotherPtvsRapidWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Mother_Pt_Rapid_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
624   if(plotMCMotherPtvsEtaConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Mother_Pt_Eta_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
625   if(plotMCMotherPtvsRapidConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Mother_Pt_Rapid_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
626
627   if(plotMCMotherSpectra == kTRUE){ 
628     histograms->AddHistogram("MC_Mother_InvMass_vs_Pt" ,"" ,nXBinsSpectra, firstXBinSpectra, lastXBinSpectra, nYBinsSpectra, firstYBinSpectra, lastYBinSpectra, "", "");
629     histograms->AddHistogram("MC_Mother_InvMass_vs_Pt_withinAcceptance" ,"" ,nXBinsSpectra, firstXBinSpectra, lastXBinSpectra, nYBinsSpectra, firstYBinSpectra, lastYBinSpectra, "", "");
630     histograms->AddHistogram("MC_Mother_InvMass_vs_Pt_ConvGamma_withinAcceptance" ,"" ,nXBinsSpectra, firstXBinSpectra, lastXBinSpectra, nYBinsSpectra, firstYBinSpectra, lastYBinSpectra, "", "");
631   }
632         
633         
634   if(plotMCPi0Eta == kTRUE){ histograms->AddHistogram("MC_Pi0_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}        
635   if(plotMCPi0Rapid == kTRUE){ histograms->AddHistogram("MC_Pi0_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}      
636   if(plotMCPi0Phi == kTRUE){ histograms->AddHistogram("MC_Pi0_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
637   if(plotMCPi0Pt == kTRUE){ histograms->AddHistogram("MC_Pi0_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
638   if(plotMCPi0Energy == kTRUE){ histograms->AddHistogram("MC_Pi0_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
639   if(plotMCPi0Mass == kTRUE){ histograms->AddHistogram("MC_Pi0_Mass" ,"" , nXBinsPi0Mass, firstXBinPi0Mass, lastXBinPi0Mass, "", "");}
640   if(plotMCPi0OpeningAngle == kTRUE){ histograms->AddHistogram("MC_Pi0_GammaDaughter_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
641   if(plotMCPi0R == kTRUE){ histograms->AddHistogram("MC_Pi0_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
642   if(plotMCPi0ZR == kTRUE){ histograms->AddHistogram("MC_Pi0_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
643   if(plotMCPi0XY == kTRUE){ histograms->AddHistogram("MC_Pi0_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
644   if(plotMCPi0PtvsEtaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Pt_Eta_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
645   if(plotMCPi0PtvsRapidWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Pt_Rapid_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
646   if(plotMCPi0PtvsEtaConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Pt_Eta_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
647   if(plotMCPi0PtvsRapidConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Pt_Rapid_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
648         
649         
650   if(plotMCPi0SecondaryEta == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
651   if(plotMCPi0SecondaryRapid == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
652   if(plotMCPi0SecondaryPhi == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
653   if(plotMCPi0SecondaryPt == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
654   if(plotMCPi0SecondaryEnergy == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
655   if(plotMCPi0SecondaryMass == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Mass" ,"" , nXBinsPi0Mass, firstXBinPi0Mass, lastXBinPi0Mass, "", "");}
656   if(plotMCPi0SecondaryOpeningAngle == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_GammaDaughter_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
657   if(plotMCPi0SecondaryR == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
658   if(plotMCPi0SecondaryZR == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
659   if(plotMCPi0SecondaryXY == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
660   if(plotMCPi0SecondaryPtvsEtaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Pt_Eta_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
661   if(plotMCPi0SecondaryPtvsRapidWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Pt_Rapid_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
662   if(plotMCPi0SecondaryPtvsEtaConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Pt_Eta_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
663   if(plotMCPi0SecondaryPtvsRapidConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Pt_Rapid_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
664         
665         
666         
667   if(plotMCEtaEta == kTRUE){ histograms->AddHistogram("MC_Eta_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
668   if(plotMCEtaRapid == kTRUE){ histograms->AddHistogram("MC_Eta_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
669   if(plotMCEtaPhi == kTRUE){ histograms->AddHistogram("MC_Eta_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
670   if(plotMCEtaPt == kTRUE){ histograms->AddHistogram("MC_Eta_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
671   if(plotMCEtaEnergy == kTRUE){ histograms->AddHistogram("MC_Eta_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
672   if(plotMCEtaMass == kTRUE){ histograms->AddHistogram("MC_Eta_Mass" ,"" , nXBinsEtaMass, firstXBinEtaMass, lastXBinEtaMass, "", "");}
673   if(plotMCEtaOpeningAngleGamma == kTRUE){ histograms->AddHistogram("MC_Eta_GammaDaughter_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
674   if(plotMCEtaR == kTRUE){ histograms->AddHistogram("MC_Eta_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
675   if(plotMCEtaZR == kTRUE){ histograms->AddHistogram("MC_Eta_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
676   if(plotMCEtaXY == kTRUE){ histograms->AddHistogram("MC_Eta_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
677   if(plotMCEtaPtvsEtaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Eta_Pt_Eta_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
678   if(plotMCEtaPtvsRapidWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Eta_Pt_Rapid_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
679   if(plotMCEtaPtvsEtaConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Eta_Pt_Eta_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
680   if(plotMCEtaPtvsRapidConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Eta_Pt_Rapid_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
681         
682         
683   // Histograms from esd tracks 
684   if(plotESDEEnergy == kTRUE){ histograms->AddHistogram("ESD_E_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
685   if(plotESDEPt == kTRUE){ histograms->AddHistogram("ESD_E_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
686   if(plotESDEEta == kTRUE){ histograms->AddHistogram("ESD_E_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
687   if(plotESDEPhi == kTRUE){ histograms->AddHistogram("ESD_E_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
688         
689   if(plotESDPEnergy == kTRUE){ histograms->AddHistogram("ESD_P_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
690   if(plotESDPPt == kTRUE){ histograms->AddHistogram("ESD_P_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
691   if(plotESDPEta == kTRUE){ histograms->AddHistogram("ESD_P_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
692   if(plotESDPPhi == kTRUE){ histograms->AddHistogram("ESD_P_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
693         
694   if(plotESDConvGammaEnergy == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
695   if(plotESDConvGammaPt == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
696   if(plotESDConvGammaEta == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
697   if(plotESDConvGammaPhi == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
698   if(plotESDConvGammaMass == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Mass" ,"" ,  nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass, "", "");}
699   if(plotESDConvGammaWidth == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Width" ,"" , nXBinsGammaWidth, firstXBinGammaWidth, lastXBinGammaWidth, "", "");}
700   if(plotESDConvGammaChi2 == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Chi2" ,"" , nXBinsGammaChi2, firstXBinGammaChi2, lastXBinGammaChi2, "", "");}
701   if(plotESDConvGammaNDF == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_NDF" ,"" , nXBinsGammaNDF, firstXBinGammaNDF, lastXBinGammaNDF, "", "");}
702   if(plotESDConvGammaRapid == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
703   if(plotESDConvGammaPtvsEta == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Pt_Eta","", nXBinsPt, firstXBinPt, lastXBinPt,nXBinsEta, firstXBinEta, lastXBinEta,"","" );}
704
705   if(plotESDConversionR == kTRUE){ histograms->AddHistogram("ESD_Conversion_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
706   if(plotESDConversionZR == kTRUE){ histograms->AddHistogram("ESD_Conversion_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
707   if(plotESDConversionXY == kTRUE){ histograms->AddHistogram("ESD_Conversion_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
708   if(plotESDConversionOpeningAngle == kTRUE){ histograms->AddHistogram("ESD_Conversion_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
709
710
711   if(plotESDTrueConvGammaEnergy == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
712   if(plotESDTrueConvGammaPt == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
713   if(plotESDTrueConvGammaEta == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
714   if(plotESDTrueConvGammaPhi == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
715   if(plotESDTrueConvGammaMass == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Mass" ,"" ,  nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass, "", "");}
716   if(plotESDTrueConvGammaWidth == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Width" ,"" , nXBinsGammaWidth, firstXBinGammaWidth, lastXBinGammaWidth, "", "");}
717   if(plotESDTrueConvGammaChi2 == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Chi2" ,"" , nXBinsGammaChi2, firstXBinGammaChi2, lastXBinGammaChi2, "", "");}
718   if(plotESDTrueConvGammaNDF == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_NDF" ,"" , nXBinsGammaNDF, firstXBinGammaNDF, lastXBinGammaNDF, "", "");}
719   if(plotESDTrueConvGammaRapid == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
720   if(plotESDTrueConvGammaPtvsEta == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Pt_Eta" ,"" , nXBinsPt, firstXBinPt, lastXBinPt,nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
721
722   if(plotESDTrueConversionR == kTRUE){ histograms->AddHistogram("ESD_TrueConversion_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
723   if(plotESDTrueConversionZR == kTRUE){ histograms->AddHistogram("ESD_TrueConversion_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
724   if(plotESDTrueConversionXY == kTRUE){ histograms->AddHistogram("ESD_TrueConversion_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
725   if(plotESDTrueConversionOpeningAngle == kTRUE){ histograms->AddHistogram("ESD_TrueConversion_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
726
727
728
729   if(plotESDNoCutConvGammaEnergy == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
730   if(plotESDNoCutConvGammaPt == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
731   if(plotESDNoCutConvGammaEta == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
732   if(plotESDNoCutConvGammaPhi == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
733   if(plotESDNoCutConvGammaMass == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Mass" ,"" ,  nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass, "", "");}
734   if(plotESDNoCutConvGammaWidth == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Width" ,"" , nXBinsGammaWidth, firstXBinGammaWidth, lastXBinGammaWidth, "", "");}
735   if(plotESDNoCutConvGammaChi2 == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Chi2" ,"" , nXBinsGammaChi2, firstXBinGammaChi2, lastXBinGammaChi2, "", "");}
736   if(plotESDNoCutConvGammaNDF == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_NDF" ,"" , nXBinsGammaNDF, firstXBinGammaNDF, lastXBinGammaNDF, "", "");}
737   if(plotESDNoCutConvGammaRapid == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
738   if(plotESDNoCutConvGammaPtvsEta == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Pt_Eta" ,"" , nXBinsPt, firstXBinPt, lastXBinPt,nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
739
740   if(plotESDNoCutConversionR == kTRUE){ histograms->AddHistogram("ESD_NoCutConversion_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
741   if(plotESDNoCutConversionZR == kTRUE){ histograms->AddHistogram("ESD_NoCutConversion_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
742   if(plotESDNoCutConversionXY == kTRUE){ histograms->AddHistogram("ESD_NoCutConversion_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
743   if(plotESDNoCutConversionOpeningAngle == kTRUE){ histograms->AddHistogram("ESD_NoCutConversion_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
744
745
746
747
748   if(plotESDMotherOpeningAngleGamma == kTRUE){ histograms->AddHistogram("ESD_Mother_GammaDaughter_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
749   if(plotESDMotherEnergy == kTRUE){ histograms->AddHistogram("ESD_Mother_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
750   if(plotESDMotherPt == kTRUE){ histograms->AddHistogram("ESD_Mother_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
751   if(plotESDMotherEta == kTRUE){ histograms->AddHistogram("ESD_Mother_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
752   if(plotESDMotherPhi == kTRUE){ histograms->AddHistogram("ESD_Mother_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
753   if(plotESDMotherMass == kTRUE){ histograms->AddHistogram("ESD_Mother_Mass" ,"" , nXBinsPi0Mass, firstXBinPi0Mass, lastXBinPi0Mass, "", "");}
754   if(plotESDMotherR == kTRUE){ histograms->AddHistogram("ESD_Mother_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
755   if(plotESDMotherZR == kTRUE){ histograms->AddHistogram("ESD_Mother_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
756   if(plotESDMotherXY == kTRUE){ histograms->AddHistogram("ESD_Mother_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
757   if(plotESDMotherRapid == kTRUE){ histograms->AddHistogram("ESD_Mother_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
758
759         
760   if(plotESDBackgroundOpeningAngleGamma == kTRUE){ histograms->AddHistogram("ESD_Background_GammaDaughter_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
761   if(plotESDBackgroundEnergy == kTRUE){ histograms->AddHistogram("ESD_Background_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
762   if(plotESDBackgroundPt == kTRUE){ histograms->AddHistogram("ESD_Background_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
763   if(plotESDBackgroundEta == kTRUE){ histograms->AddHistogram("ESD_Background_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
764   if(plotESDBackgroundPhi == kTRUE){ histograms->AddHistogram("ESD_Background_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
765   if(plotESDBackgroundMass == kTRUE){ histograms->AddHistogram("ESD_Background_Mass" ,"" , nXBinsEtaMass, firstXBinEtaMass, lastXBinEtaMass, "", "");}
766   if(plotESDBackgroundR == kTRUE){ histograms->AddHistogram("ESD_Background_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
767   if(plotESDBackgroundZR == kTRUE){ histograms->AddHistogram("ESD_Background_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
768   if(plotESDBackgroundXY == kTRUE){ histograms->AddHistogram("ESD_Background_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
769   if(plotESDBackgroundRapid == kTRUE){ histograms->AddHistogram("ESD_Background_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
770
771         
772   if(plotMapping == kTRUE){
773     histograms->InitializeMappingValues(nPhiIndex,nRIndex,nXBinsMapping,minRadius,maxRadius,nYBinsMapping,minPhi,maxPhi);
774     histograms->AddMappingHistograms(nPhiIndex,nRIndex,nXBinsMapping,minRadius,maxRadius,nYBinsMapping,minPhi,maxPhi);
775   }
776         
777   if(plotResolutiondPt == kTRUE){histograms->AddHistogram("Resolution_dPt" ,"" , nXBinsResdPt, firstXBinResdPt, lastXBinResdPt, nYBinsResdPt, firstYBinResdPt, lastYBinResdPt, "", "");}
778   if(plotResolutiondR == kTRUE){histograms->AddHistogram("Resolution_dR" ,"" , nXBinsResdR, firstXBinResdR, lastXBinResdR, nYBinsResdR, firstYBinResdR, lastYBinResdR, "", "");}
779   if(plotResolutiondZ == kTRUE){histograms->AddHistogram("Resolution_dZ" ,"" , nXBinsResdZ, firstXBinResdZ, lastXBinResdZ, nYBinsResdZ, firstYBinResdZ, lastYBinResdZ, "", "");}
780         
781   if(plotResolutiondRdPt == kTRUE){histograms->AddHistogram("Resolution_dR_dPt" ,"" , nXBinsResdRdPt, firstXBinResdRdPt, lastXBinResdRdPt, nYBinsResdRdPt, firstYBinResdRdPt, lastYBinResdRdPt, "", "");}
782         
783   if(plotResolutionMCPt == kTRUE){histograms->AddHistogram("Resolution_MC_Pt" ,"" , nXBinsResPt, firstXBinResPt, lastXBinResPt,"","");}
784   if(plotResolutionMCR == kTRUE){histograms->AddHistogram("Resolution_MC_R" ,"" , nXBinsResR, firstXBinResR, lastXBinResR,"","");}
785   if(plotResolutionMCZ == kTRUE){histograms->AddHistogram("Resolution_MC_Z" ,"" , nXBinsResZ, firstXBinResZ, lastXBinResZ,"","");}
786         
787   if(plotResolutionESDPt == kTRUE){histograms->AddHistogram("Resolution_ESD_Pt" ,"" , nXBinsResPt, firstXBinResPt, lastXBinResPt,"","");}
788   if(plotResolutionESDR == kTRUE){histograms->AddHistogram("Resolution_ESD_R" ,"" , nXBinsResR, firstXBinResR, lastXBinResR,"","");}
789   if(plotResolutionESDZ == kTRUE){histograms->AddHistogram("Resolution_ESD_Z" ,"" , nXBinsResZ, firstXBinResZ, lastXBinResZ,"","");}
790         
791   if(plotESDNumberOfV0s == kTRUE){histograms->AddHistogram("ESD_NumberOfV0s","Number of v0s",100, 0, 100,"","");}
792   if(plotESDNumberOfSurvivingV0s == kTRUE){histograms->AddHistogram("ESD_NumberOfSurvivingV0s","Number of surviving v0s",100, 0, 100,"","");}
793         
794   //  debug histograms
795   if(plotESDCutGetOnFly == kTRUE){histograms->AddHistogram("ESD_CutGetOnFly_InvMass" ,"Not GetOnFly" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
796   if(plotESDCutNContributors == kTRUE){histograms->AddHistogram("ESD_CutNContributors_InvMass" ,"NContributors <= 0" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
797   if(plotESDCutLikeSign == kTRUE){histograms->AddHistogram("ESD_CutLikeSign_InvMass" ,"LikeSign" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
798   if(plotESDCutRefit == kTRUE){histograms->AddHistogram("ESD_CutRefit_InvMass" ,"No TPC refit" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
799   if(plotESDCutKink == kTRUE){histograms->AddHistogram("ESD_CutKink_InvMass" ,"Kinks" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
800   if(plotESDCutPIDProb == kTRUE){histograms->AddHistogram("ESD_CutPIDProb_InvMass" ,"wrong TPC PID" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
801   if(plotESDCutR == kTRUE){histograms->AddHistogram("ESD_CutR_InvMass" ,"Above RMax" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
802   if(plotESDCutNDF == kTRUE){histograms->AddHistogram("ESD_CutNDF_InvMass" ,"NDF <= 0" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
803   if(plotESDCutChi2 == kTRUE){histograms->AddHistogram("ESD_CutChi2_InvMass" ,"#chi^{2} > Max" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
804   if(plotESDCutEta == kTRUE){histograms->AddHistogram("ESD_CutEta_InvMass" ,"Above #eta max" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
805   if(plotESDCutPt == kTRUE){histograms->AddHistogram("ESD_CutPt_InvMass" ,"Below p_{t} min" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
806   if(plotESDCutLine == kTRUE){histograms->AddHistogram("ESD_CutLine_InvMass" ,"Out of reconstruction area" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
807   if(plotESDTrueConvGammaTrackLength == kTRUE){histograms->AddHistogram("ESD_TrueConvGamma_TrackLength","Track length of TrueConvGamma",nXBinsTrackLength,firstXBinTrackLength,lastXBinTrackLength,"","");}
808   if(plotESDTrueConvGammaTrackLengthVSInvMass == kTRUE){histograms->AddHistogram("ESD_TrueConvGamma_TrackLengthVSInvMass","Track length of TrueConvGamma vs Inv mass",nXBinsTrackLength,firstXBinTrackLength,lastXBinTrackLength,nXBinsPt, firstXBinPt, lastXBinPt,"","");}
809
810
811   if(plotPi0Spectra == kTRUE){
812 histograms->AddHistogram("ESD_Mother_InvMass_vs_Pt" ,"Invariant Mass vs Pt" , nXBinsSpectra, firstXBinSpectra, lastXBinSpectra,nYBinsSpectra, firstYBinSpectra, lastYBinSpectra,"InvMass [GeV]","Pt [GeV]");
813 }
814   if(plotPi0Spectra == kTRUE && calculateBackground == kTRUE){
815 histograms->AddHistogram("ESD_Background_InvMass_vs_Pt" ,"Background Invariant Mass vs Pt" , nXBinsSpectra, firstXBinSpectra, lastXBinSpectra,nYBinsSpectra, firstYBinSpectra, lastYBinSpectra,"InvMass [GeV]","Pt [GeV]");
816 }
817         
818         
819         
820   //------------------------------ end Creating the histograms -----------------------------
821         
822   // Create the Analysis manager
823   AliAnalysisManager *mgr  = new AliAnalysisManager("My Manager", "My Analysis");
824         
825   // Define Input Event Handler 
826   AliESDInputHandler* inpHandler = new AliESDInputHandler();
827         
828   // Define Output Event Handler
829   AliAODHandler* aodHandler = new AliAODHandler();
830   TString fileOutAOD = "AOD_"+ outputFileName + outputFileAppendix + ".root";
831   aodHandler->SetOutputFileName(fileOutAOD);
832   //  aodHandler->SetOutputFileName("aodAliGammaConversion.root");
833         
834   // Define MC Truth Event Handler
835   AliMCEventHandler* mcHandler = new AliMCEventHandler();
836         
837   // Add Handlers to the Task Manager
838   mgr->SetInputEventHandler  (inpHandler);
839   mgr->SetOutputEventHandler (aodHandler);
840   mgr->SetMCtruthEventHandler(mcHandler);
841         
842   // Be sure you are told what you are doing
843   //  mgr->SetDebugLevel(10);
844         
845   // Declare Common Input Tchain
846   AliAnalysisDataContainer *cinput1 = NULL;
847   if(usePWG4PartCorr){
848     cinput1 = mgr->CreateContainer("Chain",TChain::Class(),AliAnalysisManager::kInputContainer);
849   }
850   else{
851     cinput1 = mgr->GetCommonInputContainer();
852   }
853         
854   // Common Output Tree in common Ã¢\80\98defaultâ\80\99 output file
855   AliAnalysisDataContainer *coutput1 = NULL;
856   if(usePWG4PartCorr){
857     coutput1 = mgr->CreateContainer("tree",TTree::Class(),AliAnalysisManager::kOutputContainer, "default");
858   }
859   else{
860     coutput1 = mgr->GetCommonOutputContainer();
861   }
862         
863   // Private output objects
864   if(outputFileName.Contains(".root")){
865     outputFileName.ReplaceAll(".root","");
866   }
867   if(outputFileAppendix.Contains(".root")){
868     outputFileAppendix.ReplaceAll(".root","");
869   }
870   TString fileOut = outputFileName + outputFileAppendix + ".root";
871         
872   AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("histogramsAliGammaConversion", TList::Class(),AliAnalysisManager::kOutputContainer, fileOut);
873         
874         
875   //------------------------ END: Define input/output handlers ---------------------------------------------------
876         
877         
878   //check for errors in the specified data
879   if(useKFParticle == kTRUE && useESDTrack == kTRUE){
880     //Print warning, cannot use both
881   }
882   if(useKFParticle == kFALSE && useESDTrack == kFALSE){
883     //Print warning, one have to be specified
884   }
885         
886         
887   //Create the V0Reader
888   AliV0Reader * v0Reader = new AliV0Reader();
889   if(useKFParticle){
890     v0Reader->UseKFParticle();
891   }
892   else if(useESDTrack){
893     v0Reader->UseESDTrack();
894   }
895   v0Reader->SetNegativeTrackPID(pidOfNegativeTrack);
896   v0Reader->SetPositiveTrackPID(pidOfPositiveTrack);
897   v0Reader->SetMaxRCut(maxRCut);
898   v0Reader->SetEtaCut(etaCut);
899   v0Reader->SetPtCut(ptCut);
900   v0Reader->SetLineCutZRSlope(LineCutZRSlope);
901   v0Reader->SetLineCutZValue(LineCutZValue);    
902   v0Reader->SetChi2CutConversion(chi2CutConversion);
903   v0Reader->SetChi2CutMeson(chi2CutMeson);
904   v0Reader->SetPIDProbability(probElectron);
905   v0Reader->SetXVertexCut(xVertexCut);
906   v0Reader->SetYVertexCut(yVertexCut);
907   v0Reader->SetZVertexCut(zVertexCut);
908   v0Reader->SetSigmaMass(sigmaCutGammaMass);
909   v0Reader->SetUseImprovedVertex(useImprovedVertex);
910   v0Reader->SetDoMCTruth(doMCTruth);
911         
912   // Create the GammaConversionTask
913   AliAnalysisTaskGammaConversion *gammaconversion = new AliAnalysisTaskGammaConversion("GammaConversionTask");
914   gammaconversion->SetDebugLevel(10);
915         
916   gammaconversion->SetWriteNtuple(writeNtuple);
917         
918   gammaconversion->SetV0Reader(v0Reader);
919   gammaconversion->SetCalculateBackground(calculateBackground);
920   gammaconversion->Init();
921         
922   gammaconversion->SetElectronMass(electronMass);
923   gammaconversion->SetGammaMass(gammaMass);
924   gammaconversion->SetPi0Mass(pi0Mass);
925   gammaconversion->SetEtaMass(etaMass);
926         
927   gammaconversion->SetGammaWidth(gammaWidth);
928   gammaconversion->SetPi0Width(pi0Width);
929   gammaconversion->SetEtaWidth(etaWidth);
930
931   gammaconversion->SetMinOpeningAngleGhostCut(minOpeningAngleGhostCut);
932         
933   // define the width constraint used by KF particle.
934   Double_t gammaWidth = 0.01;
935   Double_t pi0Width   = 0.01;
936   Double_t etaWidth   = 0.01;
937         
938   gammaconversion->SetHistograms(histograms);
939   v0Reader->SetHistograms(histograms);// also give the pointer to the v0reader, for debugging cuts
940         
941   gammaconversion->SetDoMCTruth(doMCTruth);
942         
943         
944   // Add task to the manager 
945   mgr->AddTask(gammaconversion);
946         
947   // Connect I/O to the task
948   mgr->ConnectInput (gammaconversion, 0, cinput1);
949   mgr->ConnectOutput(gammaconversion, 0, coutput1);
950   mgr->ConnectOutput(gammaconversion, 1, coutput2);
951         
952   if(dataList.IsNull()){
953     cout<<"Data list is not set, aborting."<<endl;
954     return;
955   }
956         
957   TChain* chain= CreateESDChain(dataList,numberOfFilesToAnalyze);
958         
959   mgr->InitAnalysis();
960         
961   mgr->PrintStatus();
962         
963   mgr->StartAnalysis("local",chain);
964 }
965
966 void build() {
967   TStopwatch timer;
968   timer.Start();
969   gSystem->Load("libTree.so");
970   gSystem->Load("libGeom");
971   //  gSystem->Load("libANALYSISalice");
972         
973   ////
974   //Setting up ESD.par//
975   ////
976   cout<<"compiling ESD"<<endl;
977   setupPar("ESD");
978   gSystem->Load("libVMC.so");
979   gSystem->Load("libESD.so");
980         
981   ////
982   ////
983   //Setting up STEERBase.par//
984   ////
985   cout<<"compiling STEERBase"<<endl;
986   setupPar("STEERBase");
987   gSystem->Load("libSTEERBase.so");
988         
989   ////
990   //Setting up AOD.par//
991   ////
992   cout<<"compiling AOD"<<endl;
993   setupPar("AOD");
994   gSystem->Load("libAOD.so");
995         
996   ////
997   //Setting up ANALYSIS.par//
998   ////
999   cout<<"compiling ANALYSIS"<<endl;
1000   setupPar("ANALYSIS");
1001   gSystem->Load("libANALYSIS.so");
1002         
1003   ////
1004   //Setting up ANALYSISalice.par//
1005   ////
1006   cout<<"compiling ANALUSISalice"<<endl;
1007   setupPar("ANALYSISalice");
1008   gSystem->Load("libANALYSISalice.so");
1009         
1010   ////
1011   //Setting up PWG4Gamma.par//
1012   ////
1013   //  cout<<"compiling GammaConv"<<endl;
1014         
1015   if(usePWG4PartCorr == kTRUE){
1016     cout<<"Using PWG4PartCorr library"<<endl;
1017     setupPar("PWG4PartCorr");
1018     gSystem->Load("libPWG4PartCorr.so");  
1019   }
1020   else{
1021     setupPar("PWG4GammaConv");
1022     gSystem->Load("libPWG4GammaConv.so");
1023   }
1024   //if head:: use PWG4PartCorr
1025 }
1026
1027 Int_t setupPar(const char* pararchivename) {
1028   ///////////////////
1029   // Setup PAR File//
1030   ///////////////////
1031   if (pararchivename) {
1032     char processline[1024];
1033     sprintf(processline,".! tar xvzf %s.par",pararchivename);
1034     gROOT->ProcessLine(processline);
1035     const char* ocwd = gSystem->WorkingDirectory();
1036     gSystem->ChangeDirectory(pararchivename);
1037                 
1038     // check for BUILD.sh and execute
1039     if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
1040       printf("*******************************\n");
1041       printf("*** Building PAR archive    ***\n");
1042       printf("*******************************\n");
1043                         
1044       if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
1045         Error("runAnalysis","Cannot Build the PAR Archive! - Abort!");
1046         return -1;
1047       }
1048     }
1049     // check for SETUP.C and execute
1050     if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
1051       printf("*******************************\n");
1052       printf("*** Setup PAR archive       ***\n");
1053       printf("*******************************\n");
1054       gROOT->Macro("PROOF-INF/SETUP.C");
1055     }
1056                 
1057     gSystem->ChangeDirectory("../");
1058   }                                                                                                                                               
1059   return 1;
1060 }