updated task to make it possible to run on the grid
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / AliConversionCuts.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Authors: Svein Lindal, Daniel Lohner                                   *
5  * Version 1.0                                                            *
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 handling all kinds of selection cuts for
19 // Gamma Conversion analysis
20 //---------------------------------------------
21 ////////////////////////////////////////////////
22
23 #include "AliConversionCuts.h"
24
25 #include "AliKFVertex.h"
26 #include "AliAODTrack.h"
27 #include "AliESDtrack.h"
28 #include "AliAnalysisManager.h"
29 #include "AliInputEventHandler.h"
30 #include "AliMCEventHandler.h"
31 #include "AliAODHandler.h"
32 #include "AliPIDResponse.h"
33 #include "TH1.h"
34 #include "TH2.h"
35 #include "AliStack.h"
36 #include "AliAODConversionMother.h"
37 #include "TObjString.h"
38 #include "AliAODEvent.h"
39 #include "AliESDEvent.h"
40 #include "AliCentrality.h"
41 #include "TList.h"
42 #include "AliLog.h"
43 #include "AliGenCocktailEventHeader.h"
44 #include "AliGenDPMjetEventHeader.h"
45 #include "AliGenPythiaEventHeader.h"
46 #include "AliGenHijingEventHeader.h"
47 #include "AliTriggerAnalysis.h"
48 #include "AliV0ReaderV1.h"
49
50 class iostream;
51
52 using namespace std;
53
54 ClassImp(AliConversionCuts)
55
56
57 const char* AliConversionCuts::fgkCutNames[AliConversionCuts::kNCuts] = {
58    "HeavyIon",
59    "CentralityMin",
60    "CentralityMax",
61    "SelectV0AND",
62    "MultiplicityMethod",
63    "RemovePileUp",
64    "RejectExtraSignals",
65    "V0FinderType",
66    "EtaCut",
67    "MinRCut",
68    "SinglePtCut",
69    "ClsTPCCut",
70    "ededxSigmaCut",
71    "pidedxSigmaCut",
72    "piMomdedxSigmaCut",
73    "piMaxMomdedxSigmaCut",
74    "LowPRejectionSigmaCut",
75    "TOFelectronPID",
76    "QtMaxCut",
77    "Chi2GammaCut",
78    "PsiPair",
79    "DoPhotonAsymmetryCut",
80    "CosinePointingAngle",
81    "SharedElectronCuts",
82    "RejectToCloseV0s"
83 };
84
85
86 //________________________________________________________________________
87 AliConversionCuts::AliConversionCuts(const char *name,const char *title) :
88    AliAnalysisCuts(name,title),
89    fHistograms(NULL),
90    fHeaderList(NULL),
91    fPIDResponse(NULL),
92    fEventQuality(-1),
93    fMaxR(200),
94    fMinR(0),
95    fEtaCut(0.9),
96    fEtaCutMin(-0.1),
97    fPtCut(0.02),
98    fSinglePtCut(0),
99    fMaxZ(1000),
100    fMinClsTPC(0.),
101    fMinClsTPCToF(0.),
102    fLineCutZRSlope(0.),
103    fLineCutZValue(0),
104    fLineCutZRSlopeMin(0.),
105    fLineCutZValueMin(0),
106    fChi2CutConversion(1000),
107    fPIDProbabilityCutNegativeParticle(0),
108    fPIDProbabilityCutPositiveParticle(0),
109    fDodEdxSigmaCut(kTRUE),
110    fDoTOFsigmaCut(kFALSE),
111    fPIDTRDEfficiency(1),
112    fDoTRDPID(kFALSE),
113    fPIDnSigmaAboveElectronLine(100),
114    fPIDnSigmaBelowElectronLine(-100),
115    fTofPIDnSigmaAboveElectronLine(100),
116    fTofPIDnSigmaBelowElectronLine(-100),
117    fPIDnSigmaAbovePionLine(0),
118    fPIDnSigmaAbovePionLineHighPt(-100),
119    fPIDMinPnSigmaAbovePionLine(0),
120    fPIDMaxPnSigmaAbovePionLine(0),
121    fDoKaonRejectionLowP(kFALSE),
122    fDoProtonRejectionLowP(kFALSE),
123    fDoPionRejectionLowP(kFALSE),
124    fPIDnSigmaAtLowPAroundKaonLine(0),
125    fPIDnSigmaAtLowPAroundProtonLine(0),
126    fPIDnSigmaAtLowPAroundPionLine(0),
127    fPIDMinPKaonRejectionLowP(1.5),
128    fPIDMinPProtonRejectionLowP(2),
129    fPIDMinPPionRejectionLowP(0),
130    fDoQtGammaSelection(kTRUE),
131    fDoHighPtQtGammaSelection(kFALSE),
132    fQtMax(100),
133    fHighPtQtMax(0.),
134    fPtBorderForQt(0),
135    fXVertexCut(0.),
136    fYVertexCut(0.),
137    fZVertexCut(0.),
138    fNSigmaMass(0.),
139    fUseEtaMinCut(kFALSE),
140    fUseOnFlyV0Finder(kTRUE),
141    fDoPhotonAsymmetryCut(kTRUE),
142    fMinPPhotonAsymmetryCut(100.),
143    fMinPhotonAsymmetry(0.),
144    fIsHeavyIon(kFALSE),
145    fDetectorCentrality(0),
146    fModCentralityClass(0),
147    fMaxVertexZ(10),
148    fCentralityMin(0),
149    fCentralityMax(0),
150    fUseCorrectedTPCClsInfo(kFALSE),
151    fUseTOFpid(kFALSE),
152    fMultiplicityMethod(0),
153    fSpecialTrigger(0),
154    fRemovePileUp(kFALSE),
155    fOpeningAngle(0.005),
156    fPsiPairCut(10000),
157    fCosPAngleCut(10000),
158    fDoToCloseV0sCut(kFALSE),
159    fRejectExtraSignals(0),
160    fminV0Dist(200.),
161    fDoSharedElecCut(kFALSE),
162    fOfflineTriggerMask(0),
163    fHasV0AND(kTRUE),
164    fIsSDDFired(kTRUE),
165    fRandom(0),
166    fElectronArraySize(500),
167    fElectronLabelArray(NULL),
168    fConversionPointXArray(0.0),
169    fConversionPointYArray(0.0),
170    fConversionPointZArray(0.0),
171    fnHeaders(0),
172    fNotRejectedStart(NULL),
173    fNotRejectedEnd(NULL),
174    fGeneratorNames(NULL),
175    fCutString(NULL),
176    hdEdxCuts(NULL),
177    hTPCdEdxbefore(NULL),
178    hTPCdEdxafter(NULL),
179    hTPCdEdxSigbefore(NULL),
180    hTPCdEdxSigafter(NULL),
181    hTOFbefore(NULL),
182    hTOFSigbefore(NULL),
183    hTOFSigafter(NULL),
184    hTrackCuts(NULL),
185    hPhotonCuts(NULL),
186    hInvMassbefore(NULL),
187    hArmenterosbefore(NULL),
188    hInvMassafter(NULL),
189    hArmenterosafter(NULL),
190    hAcceptanceCuts(NULL),
191    hCutIndex(NULL),
192    hV0EventCuts(NULL),
193    hCentrality(NULL),
194    hVertexZ(NULL),
195    hTriggerClass(NULL),
196    hTriggerClassSelected(NULL)
197 {
198    InitPIDResponse();
199    for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=0;}
200    fCutString=new TObjString((GetCutNumber()).Data());
201
202    fElectronLabelArray = new Int_t[fElectronArraySize];
203
204 }
205
206 //________________________________________________________________________
207 AliConversionCuts::AliConversionCuts(const AliConversionCuts &ref) :
208    AliAnalysisCuts(ref),
209    fHistograms(NULL),
210    fHeaderList(ref.fHeaderList),
211    fPIDResponse(NULL),
212    fEventQuality(ref.fEventQuality),
213    fMaxR(ref.fMaxR),
214    fMinR(ref.fMinR),
215    fEtaCut(ref.fEtaCut),
216    fEtaCutMin(ref.fEtaCutMin),
217    fPtCut(ref.fPtCut),
218    fSinglePtCut(ref.fSinglePtCut),
219    fMaxZ(ref.fMaxZ),
220    fMinClsTPC(ref.fMinClsTPC),
221    fMinClsTPCToF(ref.fMinClsTPCToF),
222    fLineCutZRSlope(ref.fLineCutZRSlope),
223    fLineCutZValue(ref.fLineCutZValue),
224    fLineCutZRSlopeMin(ref.fLineCutZRSlopeMin),
225    fLineCutZValueMin(ref.fLineCutZValueMin),
226    fChi2CutConversion(ref.fChi2CutConversion),
227    fPIDProbabilityCutNegativeParticle(ref.fPIDProbabilityCutNegativeParticle),
228    fPIDProbabilityCutPositiveParticle(ref.fPIDProbabilityCutPositiveParticle),
229    fDodEdxSigmaCut(ref. fDodEdxSigmaCut),
230    fDoTOFsigmaCut(ref.fDoTOFsigmaCut),
231    fPIDTRDEfficiency(ref.fPIDTRDEfficiency),
232    fDoTRDPID(ref.fDoTRDPID),
233    fPIDnSigmaAboveElectronLine(ref.fPIDnSigmaAboveElectronLine),
234    fPIDnSigmaBelowElectronLine(ref.fPIDnSigmaBelowElectronLine),
235    fTofPIDnSigmaAboveElectronLine(ref.fTofPIDnSigmaAboveElectronLine),
236    fTofPIDnSigmaBelowElectronLine(ref.fTofPIDnSigmaBelowElectronLine),
237    fPIDnSigmaAbovePionLine(ref.fPIDnSigmaAbovePionLine),
238    fPIDnSigmaAbovePionLineHighPt(ref.fPIDnSigmaAbovePionLineHighPt),
239    fPIDMinPnSigmaAbovePionLine(ref.fPIDMinPnSigmaAbovePionLine),
240    fPIDMaxPnSigmaAbovePionLine(ref.fPIDMaxPnSigmaAbovePionLine),
241    fDoKaonRejectionLowP(ref.fDoKaonRejectionLowP),
242    fDoProtonRejectionLowP(ref.fDoProtonRejectionLowP),
243    fDoPionRejectionLowP(ref.fDoPionRejectionLowP),
244    fPIDnSigmaAtLowPAroundKaonLine(ref.fPIDnSigmaAtLowPAroundKaonLine),
245    fPIDnSigmaAtLowPAroundProtonLine(ref.fPIDnSigmaAtLowPAroundProtonLine),
246    fPIDnSigmaAtLowPAroundPionLine(ref.fPIDnSigmaAtLowPAroundPionLine),
247    fPIDMinPKaonRejectionLowP(ref.fPIDMinPKaonRejectionLowP),
248    fPIDMinPProtonRejectionLowP(ref.fPIDMinPProtonRejectionLowP),
249    fPIDMinPPionRejectionLowP(ref.fPIDMinPPionRejectionLowP),
250    fDoQtGammaSelection(ref.fDoQtGammaSelection),
251    fDoHighPtQtGammaSelection(ref.fDoHighPtQtGammaSelection),
252    fQtMax(ref.fQtMax),
253    fHighPtQtMax(ref.fHighPtQtMax),
254    fPtBorderForQt(ref.fPtBorderForQt),
255    fXVertexCut(ref.fXVertexCut),
256    fYVertexCut(ref.fYVertexCut),
257    fZVertexCut(ref.fZVertexCut),
258    fNSigmaMass(ref.fNSigmaMass),
259    fUseEtaMinCut(ref.fUseEtaMinCut),
260    fUseOnFlyV0Finder(ref.fUseOnFlyV0Finder),
261    fDoPhotonAsymmetryCut(fDoPhotonAsymmetryCut),
262    fMinPPhotonAsymmetryCut(ref.fMinPPhotonAsymmetryCut),
263    fMinPhotonAsymmetry(ref.fMinPhotonAsymmetry),
264    fIsHeavyIon(ref.fIsHeavyIon),
265    fDetectorCentrality(ref.fDetectorCentrality),
266    fModCentralityClass(ref.fModCentralityClass),
267    fMaxVertexZ(ref.fMaxVertexZ),
268    fCentralityMin(ref.fCentralityMin),
269    fCentralityMax(ref.fCentralityMax),
270    fUseCorrectedTPCClsInfo(ref.fUseCorrectedTPCClsInfo),
271    fUseTOFpid(ref.fUseTOFpid),
272    fMultiplicityMethod(ref.fMultiplicityMethod),
273    fSpecialTrigger(ref.fSpecialTrigger),
274    fRemovePileUp(ref.fRemovePileUp),
275    fOpeningAngle(ref.fOpeningAngle),
276    fPsiPairCut(ref.fPsiPairCut),
277    fCosPAngleCut(ref.fCosPAngleCut),
278    fDoToCloseV0sCut(ref.fDoToCloseV0sCut),
279    fRejectExtraSignals(ref.fRejectExtraSignals),
280    fminV0Dist(ref.fminV0Dist),
281    fDoSharedElecCut(ref.fDoSharedElecCut),
282    fOfflineTriggerMask(ref.fOfflineTriggerMask),
283    fHasV0AND(ref.fHasV0AND),
284    fIsSDDFired(ref.fIsSDDFired),
285    fRandom(ref.fRandom),
286    fElectronArraySize(ref.fElectronArraySize),
287    fElectronLabelArray(NULL),
288    fConversionPointXArray(ref.fConversionPointXArray),
289    fConversionPointYArray(ref.fConversionPointYArray),
290    fConversionPointZArray(ref.fConversionPointZArray),
291    fnHeaders(ref.fnHeaders),
292    fNotRejectedStart(NULL),
293    fNotRejectedEnd(NULL),
294    fGeneratorNames(ref.fGeneratorNames),
295    fCutString(NULL),
296    hdEdxCuts(NULL),
297    hTPCdEdxbefore(NULL),
298    hTPCdEdxafter(NULL),
299    hTPCdEdxSigbefore(NULL),
300    hTPCdEdxSigafter(NULL),
301    hTOFbefore(NULL),
302    hTOFSigbefore(NULL),
303    hTOFSigafter(NULL),
304    hTrackCuts(NULL),
305    hPhotonCuts(NULL),
306    hInvMassbefore(NULL),
307    hArmenterosbefore(NULL),
308    hInvMassafter(NULL),
309    hArmenterosafter(NULL),
310    hAcceptanceCuts(NULL),
311    hCutIndex(NULL),
312    hV0EventCuts(NULL),
313    hCentrality(NULL),
314    hVertexZ(NULL),
315    hTriggerClass(NULL),
316    hTriggerClassSelected(NULL)
317 {
318    // Copy Constructor
319    for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=ref.fCuts[jj];}
320    fCutString=new TObjString((GetCutNumber()).Data());
321    fElectronLabelArray = new Int_t[fElectronArraySize];
322    // dont copy histograms (if you like histograms, call InitCutHistograms())
323 }
324
325
326 //________________________________________________________________________
327 AliConversionCuts::~AliConversionCuts() {
328    // Destructor
329    //Deleting fHistograms leads to seg fault it it's added to output collection of a task
330    // if(fHistograms)
331    //   delete fHistograms;
332    // fHistograms = NULL;
333    if(fCutString != NULL){
334       delete fCutString;
335       fCutString = NULL;
336    }
337    if(fElectronLabelArray){
338       delete fElectronLabelArray;
339       fElectronLabelArray = NULL;
340    }
341    if(fNotRejectedStart){
342       delete[] fNotRejectedStart;
343       fNotRejectedStart = NULL;
344    }
345    if(fNotRejectedEnd){
346       delete[] fNotRejectedEnd;
347       fNotRejectedEnd = NULL;
348    }
349    if(fGeneratorNames){
350       delete[] fGeneratorNames;
351       fGeneratorNames = NULL;
352    }
353 }
354
355 //________________________________________________________________________
356 void AliConversionCuts::InitCutHistograms(TString name, Bool_t preCut){
357
358    // Initialize Cut Histograms for QA (only initialized and filled if function is called)
359
360    if(fHistograms != NULL){
361       delete fHistograms;
362       fHistograms=NULL;
363    }
364    if(fHistograms==NULL){
365       fHistograms=new TList();
366       if(name=="")fHistograms->SetName(Form("ConvCuts_%s",GetCutNumber().Data()));
367       else fHistograms->SetName(Form("%s_%s",name.Data(),GetCutNumber().Data()));
368    }
369
370    // IsPhotonSelected
371    hCutIndex=new TH1F(Form("IsPhotonSelected %s",GetCutNumber().Data()),"IsPhotonSelected",10,-0.5,9.5);
372    hCutIndex->GetXaxis()->SetBinLabel(kPhotonIn+1,"in");
373    hCutIndex->GetXaxis()->SetBinLabel(kOnFly+1,"onfly");
374    hCutIndex->GetXaxis()->SetBinLabel(kNoTracks+1,"no tracks");
375    hCutIndex->GetXaxis()->SetBinLabel(kdEdxCuts+1,"dEdx");
376    hCutIndex->GetXaxis()->SetBinLabel(kTrackCuts+1,"Track cuts");
377    hCutIndex->GetXaxis()->SetBinLabel(kConvPointFail+1,"ConvPoint fail");
378    hCutIndex->GetXaxis()->SetBinLabel(kPhotonCuts+1,"PhotonCuts");
379    hCutIndex->GetXaxis()->SetBinLabel(kPhotonOut+1,"out");
380    fHistograms->Add(hCutIndex);
381
382    // Track Cuts
383    hTrackCuts=new TH1F(Form("TrackCuts %s",GetCutNumber().Data()),"TrackCuts",9,-0.5,8.5);
384    hTrackCuts->GetXaxis()->SetBinLabel(1,"in");
385    hTrackCuts->GetXaxis()->SetBinLabel(2,"likesign");
386    hTrackCuts->GetXaxis()->SetBinLabel(3,"ntpccl");
387    hTrackCuts->GetXaxis()->SetBinLabel(4,"acceptance");
388    hTrackCuts->GetXaxis()->SetBinLabel(5,"singlept");
389    hTrackCuts->GetXaxis()->SetBinLabel(6,"TPCrefit");
390    hTrackCuts->GetXaxis()->SetBinLabel(7,"kink");
391    hTrackCuts->GetXaxis()->SetBinLabel(8,"out");
392    fHistograms->Add(hTrackCuts);
393
394    // Photon Cuts
395    hPhotonCuts=new TH1F(Form("PhotonCuts %s",GetCutNumber().Data()),"PhotonCuts",12,-0.5,11.5);
396    hPhotonCuts->GetXaxis()->SetBinLabel(1,"in");
397    hPhotonCuts->GetXaxis()->SetBinLabel(2,"qtcut");
398    hPhotonCuts->GetXaxis()->SetBinLabel(3,"chi2");
399    hPhotonCuts->GetXaxis()->SetBinLabel(4,"acceptance");
400    hPhotonCuts->GetXaxis()->SetBinLabel(5,"asymmetry");
401    hPhotonCuts->GetXaxis()->SetBinLabel(6,"pidprob");
402    hPhotonCuts->GetXaxis()->SetBinLabel(7,"cortpcclinfo");
403    hPhotonCuts->GetXaxis()->SetBinLabel(8,"PsiPair");
404    hPhotonCuts->GetXaxis()->SetBinLabel(9,"CosPAngle");
405    hPhotonCuts->GetXaxis()->SetBinLabel(10,"out");
406    fHistograms->Add(hPhotonCuts);
407
408    if(preCut){
409       hInvMassbefore=new TH1F(Form("InvMass_before %s",GetCutNumber().Data()),"InvMass_before",1000,0,0.3);
410       fHistograms->Add(hInvMassbefore);
411       hArmenterosbefore=new TH2F(Form("Armenteros_before %s",GetCutNumber().Data()),"Armenteros_before",200,-1,1,1000,0,1.);
412       fHistograms->Add(hArmenterosbefore);
413    }
414    hInvMassafter=new TH1F(Form("InvMass_after %s",GetCutNumber().Data()),"InvMass_after",1000,0,0.3);
415    fHistograms->Add(hInvMassafter);
416    hArmenterosafter=new TH2F(Form("Armenteros_after %s",GetCutNumber().Data()),"Armenteros_after",200,-1,1,250,0,0.25);
417    fHistograms->Add(hArmenterosafter);
418
419    hAcceptanceCuts=new TH1F(Form("PhotonAcceptanceCuts %s",GetCutNumber().Data()),"PhotonAcceptanceCuts",10,-0.5,9.5);
420    hAcceptanceCuts->GetXaxis()->SetBinLabel(1,"in");
421    hAcceptanceCuts->GetXaxis()->SetBinLabel(2,"maxR");
422    hAcceptanceCuts->GetXaxis()->SetBinLabel(3,"minR");
423    hAcceptanceCuts->GetXaxis()->SetBinLabel(4,"line");
424    hAcceptanceCuts->GetXaxis()->SetBinLabel(5,"maxZ");
425    hAcceptanceCuts->GetXaxis()->SetBinLabel(6,"eta");
426    hAcceptanceCuts->GetXaxis()->SetBinLabel(7,"minpt");
427    hAcceptanceCuts->GetXaxis()->SetBinLabel(8,"out");
428    fHistograms->Add(hAcceptanceCuts);
429
430    // dEdx Cuts
431    hdEdxCuts=new TH1F(Form("dEdxCuts %s",GetCutNumber().Data()),"dEdxCuts",10,-0.5,9.5);
432    hdEdxCuts->GetXaxis()->SetBinLabel(1,"in");
433    hdEdxCuts->GetXaxis()->SetBinLabel(2,"TPCelectron");
434    hdEdxCuts->GetXaxis()->SetBinLabel(3,"TPCpion");
435    hdEdxCuts->GetXaxis()->SetBinLabel(4,"TPCpionhighp");
436    hdEdxCuts->GetXaxis()->SetBinLabel(5,"TPCkaonlowprej");
437    hdEdxCuts->GetXaxis()->SetBinLabel(6,"TPCprotonlowprej");
438    hdEdxCuts->GetXaxis()->SetBinLabel(7,"TPCpionlowprej");
439    hdEdxCuts->GetXaxis()->SetBinLabel(8,"TOFelectron");
440    hdEdxCuts->GetXaxis()->SetBinLabel(9,"TRDelectron");
441    hdEdxCuts->GetXaxis()->SetBinLabel(10,"out");
442    fHistograms->Add(hdEdxCuts);
443
444    TAxis *AxisBeforedEdx = NULL;
445    TAxis *AxisBeforedEdxSig = NULL;
446    TAxis *AxisBeforeTOF = NULL;
447    TAxis *AxisBeforeTOFSig = NULL;
448    if(preCut){
449       hTPCdEdxbefore=new TH2F(Form("Gamma_dEdx_before %s",GetCutNumber().Data()),"dEdx Gamma before" ,150,0.03,20,800,0,200);
450       fHistograms->Add(hTPCdEdxbefore);
451       AxisBeforedEdx = hTPCdEdxbefore->GetXaxis();
452       hTPCdEdxSigbefore=new TH2F(Form("Gamma_dEdxSig_before %s",GetCutNumber().Data()),"dEdx Sigma Gamma before" ,150,0.03,20,400,-10,10);
453       fHistograms->Add(hTPCdEdxSigbefore);
454       AxisBeforedEdxSig = hTPCdEdxSigbefore->GetXaxis();
455
456       hTOFbefore=new TH2F(Form("Gamma_TOF_before %s",GetCutNumber().Data()),"TOF Gamma before" ,150,0.03,20,11000,-1000,10000);
457       fHistograms->Add(hTOFbefore);
458       AxisBeforeTOF = hTOFbefore->GetXaxis();
459       hTOFSigbefore=new TH2F(Form("Gamma_TOFSig_before %s",GetCutNumber().Data()),"TOF Sigma Gamma before" ,150,0.03,20,400,-6,10);
460       fHistograms->Add(hTOFSigbefore);
461       AxisBeforeTOFSig = hTOFSigbefore->GetXaxis();
462
463    }
464    hTPCdEdxSigafter=new TH2F(Form("Gamma_dEdxSig_after %s",GetCutNumber().Data()),"dEdx Sigma Gamma after" ,150,0.03,20,400, -10,10);
465    fHistograms->Add(hTPCdEdxSigafter);
466
467    hTPCdEdxafter=new TH2F(Form("Gamma_dEdx_after %s",GetCutNumber().Data()),"dEdx Gamma after" ,150,0.03,20,800,0,200);
468    fHistograms->Add(hTPCdEdxafter);
469
470    hTOFSigafter=new TH2F(Form("Gamma_TOFSig_after %s",GetCutNumber().Data()),"TOF Sigma Gamma after" ,150,0.03,20,400,-6,10);
471    fHistograms->Add(hTOFSigafter);
472
473    TAxis *AxisAfter = hTPCdEdxSigafter->GetXaxis();
474    Int_t bins = AxisAfter->GetNbins();
475    Double_t from = AxisAfter->GetXmin();
476    Double_t to = AxisAfter->GetXmax();
477    Double_t *newBins = new Double_t[bins+1];
478    newBins[0] = from;
479    Double_t factor = TMath::Power(to/from, 1./bins);
480    for(Int_t i=1; i<=bins; ++i) newBins[i] = factor * newBins[i-1];
481    AxisAfter->Set(bins, newBins);
482    AxisAfter = hTOFSigafter->GetXaxis();
483    AxisAfter->Set(bins, newBins);
484    AxisAfter = hTPCdEdxafter->GetXaxis();
485    AxisAfter->Set(bins, newBins);
486    if(preCut){
487       AxisBeforedEdx->Set(bins, newBins);
488       AxisBeforeTOF->Set(bins, newBins);
489       AxisBeforedEdxSig->Set(bins, newBins);
490       AxisBeforeTOFSig->Set(bins, newBins);
491    }
492    delete [] newBins;
493
494    // Event Cuts and Info
495    if(preCut){
496       hV0EventCuts=new TH1F(Form("ESD_EventCuts %s",GetCutNumber().Data()),"Event Cuts",7,-0.5,6.5);
497       hV0EventCuts->GetXaxis()->SetBinLabel(1,"in");
498       hV0EventCuts->GetXaxis()->SetBinLabel(2,"OfflineTrigger");
499       hV0EventCuts->GetXaxis()->SetBinLabel(3,"nvtxcontr");
500       hV0EventCuts->GetXaxis()->SetBinLabel(4,"VertexZ");
501       hV0EventCuts->GetXaxis()->SetBinLabel(5,"pileup");
502       hV0EventCuts->GetXaxis()->SetBinLabel(6,"centrsel");
503       hV0EventCuts->GetXaxis()->SetBinLabel(7,"out");
504       fHistograms->Add(hV0EventCuts);
505
506       hCentrality=new TH1F(Form("Centrality %s",GetCutNumber().Data()),"Centrality",100,0,100);
507       fHistograms->Add(hCentrality);
508       hVertexZ=new TH1F(Form("VertexZ %s",GetCutNumber().Data()),"VertexZ",1000,-50,50);
509       fHistograms->Add(hVertexZ);
510
511       hTriggerClass= new TH1F(Form("OfflineTrigger %s",GetCutNumber().Data()),"OfflineTrigger",34,-0.5,33.5);
512       hTriggerClass->GetXaxis()->SetBinLabel( 1,"kMB");
513       hTriggerClass->GetXaxis()->SetBinLabel( 2,"kINT7");
514       hTriggerClass->GetXaxis()->SetBinLabel( 3,"kMUON");
515       hTriggerClass->GetXaxis()->SetBinLabel( 4,"kHighMult");
516       hTriggerClass->GetXaxis()->SetBinLabel( 5,"kKEMC1");
517       hTriggerClass->GetXaxis()->SetBinLabel( 6,"kCINT5");
518       hTriggerClass->GetXaxis()->SetBinLabel( 7,"kCMUS5/kMUSPB");
519       hTriggerClass->GetXaxis()->SetBinLabel( 8,"kMUSH7/kMUSHPB");
520       hTriggerClass->GetXaxis()->SetBinLabel( 9,"kMUL7/kMuonLikePB");
521       hTriggerClass->GetXaxis()->SetBinLabel(10,"kMUU7/kMuonUnlikePB");
522       hTriggerClass->GetXaxis()->SetBinLabel(11,"kEMC7/kEMC8");
523       hTriggerClass->GetXaxis()->SetBinLabel(12,"kMUS7");
524       hTriggerClass->GetXaxis()->SetBinLabel(13,"kPHI1");
525       hTriggerClass->GetXaxis()->SetBinLabel(14,"kPHI7/kPHI8/kPHOSPb");
526       hTriggerClass->GetXaxis()->SetBinLabel(15,"kEMCEJE");
527       hTriggerClass->GetXaxis()->SetBinLabel(16,"kEMCEGA");
528       hTriggerClass->GetXaxis()->SetBinLabel(17,"kCentral");
529       hTriggerClass->GetXaxis()->SetBinLabel(18,"kSemiCentral");
530       hTriggerClass->GetXaxis()->SetBinLabel(19,"kDG5");
531       hTriggerClass->GetXaxis()->SetBinLabel(20,"kZED");
532       hTriggerClass->GetXaxis()->SetBinLabel(21,"kSPI7/kSPI");
533       hTriggerClass->GetXaxis()->SetBinLabel(22,"kINT8");
534       hTriggerClass->GetXaxis()->SetBinLabel(23,"kMuonSingleLowPt8");
535       hTriggerClass->GetXaxis()->SetBinLabel(24,"kMuonSingleHighPt8");
536       hTriggerClass->GetXaxis()->SetBinLabel(25,"kMuonLikeLowPt8");
537       hTriggerClass->GetXaxis()->SetBinLabel(26,"kMuonUnlikeLowPt8");
538       hTriggerClass->GetXaxis()->SetBinLabel(27,"kMuonUnlikeLowPt0");
539       hTriggerClass->GetXaxis()->SetBinLabel(28,"kUserDefined");
540       hTriggerClass->GetXaxis()->SetBinLabel(29,"kFastOnly");
541       hTriggerClass->GetXaxis()->SetBinLabel(30,"kAnyINT");
542       hTriggerClass->GetXaxis()->SetBinLabel(31,"kAny");
543       hTriggerClass->GetXaxis()->SetBinLabel(32,"V0AND");
544       hTriggerClass->GetXaxis()->SetBinLabel(33,"NOT kFastOnly");
545       hTriggerClass->GetXaxis()->SetBinLabel(34,"failed Physics Selection");
546       fHistograms->Add(hTriggerClass);
547
548       hTriggerClassSelected= new TH1F(Form("OfflineTriggerSelected %s",GetCutNumber().Data()),"OfflineTriggerSelected",33,-0.5,32.5);
549       hTriggerClassSelected->GetXaxis()->SetBinLabel( 1,"kMB");
550       hTriggerClassSelected->GetXaxis()->SetBinLabel( 2,"kINT7");
551       hTriggerClassSelected->GetXaxis()->SetBinLabel( 3,"kMUON");
552       hTriggerClassSelected->GetXaxis()->SetBinLabel( 4,"kHighMult");
553       hTriggerClassSelected->GetXaxis()->SetBinLabel( 5,"kKEMC1");
554       hTriggerClassSelected->GetXaxis()->SetBinLabel( 6,"kCINT5");
555       hTriggerClassSelected->GetXaxis()->SetBinLabel( 7,"kCMUS5/kMUSPB");
556       hTriggerClassSelected->GetXaxis()->SetBinLabel( 8,"kMUSH7/kMUSHPB");
557       hTriggerClassSelected->GetXaxis()->SetBinLabel( 9,"kMUL7/kMuonLikePB");
558       hTriggerClassSelected->GetXaxis()->SetBinLabel(10,"kMUU7/kMuonUnlikePB");
559       hTriggerClassSelected->GetXaxis()->SetBinLabel(11,"kEMC7/kEMC8");
560       hTriggerClassSelected->GetXaxis()->SetBinLabel(12,"kMUS7");
561       hTriggerClassSelected->GetXaxis()->SetBinLabel(13,"kPHI1");
562       hTriggerClassSelected->GetXaxis()->SetBinLabel(14,"kPHI7/kPHI8/kPHOSPb");
563       hTriggerClassSelected->GetXaxis()->SetBinLabel(15,"kEMCEJE");
564       hTriggerClassSelected->GetXaxis()->SetBinLabel(16,"kEMCEGA");
565       hTriggerClassSelected->GetXaxis()->SetBinLabel(17,"kCentral");
566       hTriggerClassSelected->GetXaxis()->SetBinLabel(18,"kSemiCentral");
567       hTriggerClassSelected->GetXaxis()->SetBinLabel(19,"kDG5");
568       hTriggerClassSelected->GetXaxis()->SetBinLabel(20,"kZED");
569       hTriggerClassSelected->GetXaxis()->SetBinLabel(21,"kSPI7/kSPI");
570       hTriggerClassSelected->GetXaxis()->SetBinLabel(22,"kINT8");
571       hTriggerClassSelected->GetXaxis()->SetBinLabel(23,"kMuonSingleLowPt8");
572       hTriggerClassSelected->GetXaxis()->SetBinLabel(24,"kMuonSingleHighPt8");
573       hTriggerClassSelected->GetXaxis()->SetBinLabel(25,"kMuonLikeLowPt8");
574       hTriggerClassSelected->GetXaxis()->SetBinLabel(26,"kMuonUnlikeLowPt8");
575       hTriggerClassSelected->GetXaxis()->SetBinLabel(27,"kMuonUnlikeLowPt0");
576       hTriggerClassSelected->GetXaxis()->SetBinLabel(28,"kUserDefined");
577       hTriggerClassSelected->GetXaxis()->SetBinLabel(29,"kFastOnly");
578       hTriggerClassSelected->GetXaxis()->SetBinLabel(30,"kAnyINT");
579       hTriggerClassSelected->GetXaxis()->SetBinLabel(31,"kAny");
580       hTriggerClassSelected->GetXaxis()->SetBinLabel(32,"V0AND");
581       hTriggerClassSelected->GetXaxis()->SetBinLabel(33,"NOT kFastOnly");
582       fHistograms->Add(hTriggerClassSelected);
583    }
584 }
585
586 //________________________________________________________________________
587 Bool_t AliConversionCuts::InitPIDResponse(){
588    // Set Pointer to AliPIDResponse
589
590    AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
591    if(man) {
592       AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
593       fPIDResponse = (AliPIDResponse*)inputHandler->GetPIDResponse();
594       if(fPIDResponse)return kTRUE;
595
596    }
597
598
599    return kFALSE;
600 }
601 ///________________________________________________________________________
602 Bool_t AliConversionCuts::EventIsSelected(AliVEvent *fInputEvent, AliVEvent *fMCEvent){
603    // Process Event Selection
604
605    Int_t cutindex=0;
606    if(hV0EventCuts)hV0EventCuts->Fill(cutindex);
607    cutindex++;
608
609    // Check for MC event
610    if(fMCEvent){
611       // Check if MC event is correctly loaded
612       AliMCEventHandler* mcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
613       if (!mcHandler){
614          fEventQuality = 2;
615          return kFALSE;
616       }
617       if (!mcHandler->InitOk() ){
618          fEventQuality = 2;
619          return kFALSE;
620       }
621       if (!mcHandler->TreeK() ){
622          fEventQuality = 2;
623          return kFALSE;
624       }
625       if (!mcHandler->TreeTR() ) {
626          fEventQuality = 2;
627          return kFALSE;
628       }
629    }
630
631    // Event Trigger
632    if(!IsTriggerSelected()){
633       if(hV0EventCuts)hV0EventCuts->Fill(cutindex);
634       fEventQuality = 3;
635       return kFALSE;
636    }
637    cutindex++;
638
639    if(fInputEvent->IsA()==AliESDEvent::Class()){
640       AliTriggerAnalysis fTriggerAnalysis;// = new AliTriggerAnalysis;
641       fHasV0AND = fTriggerAnalysis.IsOfflineTriggerFired((AliESDEvent*)fInputEvent, AliTriggerAnalysis::kV0AND);
642       if(fHasV0AND&&hTriggerClass)hTriggerClass->Fill(31);
643    }
644
645    // Number of Contributors Cut
646    if(GetNumberOfContributorsVtx(fInputEvent)<=0) {
647       if(hV0EventCuts)hV0EventCuts->Fill(cutindex);
648       fEventQuality = 5;
649       return kFALSE;
650    }
651    cutindex++;
652
653    // Z Vertex Position Cut
654    if(!VertexZCut(fInputEvent)){
655       if(hV0EventCuts)hV0EventCuts->Fill(cutindex);
656       fEventQuality = 4;
657       return kFALSE;
658    }
659    cutindex++;
660
661    // Pile Up Rejection
662
663    if(fRemovePileUp){
664       if(fInputEvent->IsPileupFromSPD(3,0.8,3.,2.,5.)){
665          if(hV0EventCuts)hV0EventCuts->Fill(cutindex);
666          fEventQuality = 6;
667          return kFALSE;
668       }
669    }
670    cutindex++;
671
672    // Centrality Selection
673    if(!IsCentralitySelected(fInputEvent,fMCEvent)){
674       if(hV0EventCuts)hV0EventCuts->Fill(cutindex);
675       fEventQuality = 1;
676       return kFALSE;
677    }
678    cutindex++;
679
680    // Fill Event Histograms
681    if(hV0EventCuts)hV0EventCuts->Fill(cutindex);
682    if(hVertexZ)hVertexZ->Fill(fInputEvent->GetPrimaryVertex()->GetZ());
683    if(hCentrality)hCentrality->Fill(GetCentrality(fInputEvent));
684
685    fEventQuality = 0;
686    return kTRUE;
687 }
688
689 ///________________________________________________________________________
690 Bool_t AliConversionCuts::PhotonIsSelectedMC(TParticle *particle,AliStack *fMCStack,Bool_t checkForConvertedGamma){
691    // MonteCarlo Photon Selection
692
693    if(!fMCStack)return kFALSE;
694
695    if (particle->GetPdgCode() == 22){
696
697       if(particle->R() > fMaxR) return kFALSE;
698       if(abs(particle->Eta())> fEtaCut || abs(particle->Eta())< fEtaCutMin) return kFALSE;
699
700       if(particle->GetMother(0) >-1 && fMCStack->Particle(particle->GetMother(0))->GetPdgCode() == 22){
701          return kFALSE; // no photon as mothers!
702       }
703
704       if(particle->GetMother(0) >= fMCStack->GetNprimary()){
705          return kFALSE; // the gamma has a mother, and it is not a primary particle
706       }
707
708       if(!checkForConvertedGamma) return kTRUE; // return in case of accepted gamma
709
710       // looking for conversion gammas (electron + positron from pairbuilding (= 5) )
711       TParticle* ePos = NULL;
712       TParticle* eNeg = NULL;
713
714       if(particle->GetNDaughters() >= 2){
715          for(Int_t daughterIndex=particle->GetFirstDaughter();daughterIndex<=particle->GetLastDaughter();daughterIndex++){
716             TParticle *tmpDaughter = fMCStack->Particle(daughterIndex);
717             if(tmpDaughter->GetUniqueID() == 5){
718                if(tmpDaughter->GetPdgCode() == 11){
719                   eNeg = tmpDaughter;
720                } else if(tmpDaughter->GetPdgCode() == -11){
721                   ePos = tmpDaughter;
722                }
723             }
724          }
725       }
726
727       if(ePos == NULL || eNeg == NULL){ // means we do not have two daughters from pair production
728          return kFALSE;
729       }
730
731       if(ePos->Pt()<fSinglePtCut || eNeg->Pt()<fSinglePtCut){
732          return kFALSE; // no reconstruction below the Pt cut
733       }
734
735       if( abs(ePos->Eta())> fEtaCut || abs(ePos->Eta())< fEtaCutMin ||
736           abs(eNeg->Eta())> fEtaCut || abs(eNeg->Eta())< fEtaCutMin ) {
737          return kFALSE;
738       }
739
740       if(ePos->R()>fMaxR){
741          return kFALSE; // cuts on distance from collision point
742       }
743
744       if(abs(ePos->Vz()) > fMaxZ){
745          return kFALSE;  // outside material
746       }
747       if(abs(eNeg->Vz()) > fMaxZ){
748          return kFALSE;  // outside material
749       }
750
751       if( ePos->R() <= ((abs(ePos->Vz()) * fLineCutZRSlope) - fLineCutZValue)){
752          return kFALSE;  // line cut to exclude regions where we do not reconstruct
753       } else if ( fEtaCutMin != -0.1 &&   ePos->R() >= ((abs(ePos->Vz()) * fLineCutZRSlopeMin) - fLineCutZValueMin)){
754          return kFALSE;
755       }
756
757       if( eNeg->R() <= ((abs(eNeg->Vz()) * fLineCutZRSlope) - fLineCutZValue)){
758          return kFALSE; // line cut to exclude regions where we do not reconstruct
759       } else if ( fEtaCutMin != -0.1 &&   eNeg->R() >= ((abs(eNeg->Vz()) * fLineCutZRSlopeMin) - fLineCutZValueMin)){
760          return kFALSE;
761       }
762
763       return kTRUE;
764       //if(AcceptanceCut(particle,ePos,eNeg))return kTRUE;
765    }
766    return kFALSE;
767 }
768
769
770 ///________________________________________________________________________
771 Bool_t AliConversionCuts::PhotonCuts(AliConversionPhotonBase *photon,AliVEvent *event)
772 {   // Specific Photon Cuts
773
774    Int_t cutIndex = 0;
775    if(hPhotonCuts)hPhotonCuts->Fill(cutIndex);
776    cutIndex++;
777
778    // Fill Histos before Cuts
779    if(hInvMassbefore)hInvMassbefore->Fill(photon->GetMass());
780
781    if(hArmenterosbefore)hArmenterosbefore->Fill(photon->GetArmenterosAlpha(),photon->GetArmenterosQt());
782
783    // Gamma selection based on QT from Armenteros
784    if(fDoQtGammaSelection == kTRUE){
785       if(!ArmenterosQtCut(photon)){
786          if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //1
787          return kFALSE;
788       }
789    }
790    cutIndex++; //2
791
792    // Chi Cut
793    if(photon->GetChi2perNDF() > fChi2CutConversion || photon->GetChi2perNDF() <=0){
794       {
795          if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //2
796          return kFALSE;
797       }
798    }
799    cutIndex++;//3
800
801    // Reconstruction Acceptance Cuts
802    if(!AcceptanceCuts(photon)){
803       if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //3
804       return kFALSE;
805    }
806
807    cutIndex++; //4
808    // Asymmetry Cut
809    if(fDoPhotonAsymmetryCut == kTRUE){
810       if(!AsymmetryCut(photon,event)){
811          if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //4
812          return kFALSE;
813       }
814    }
815
816    //Check the pid probability
817    cutIndex++; //5
818    if(!PIDProbabilityCut(photon, event)) {
819       if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //5
820       return kFALSE;
821    }
822
823    cutIndex++; //6
824    if(!CorrectedTPCClusterCut(photon, event)) {
825       if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //6
826       return kFALSE;
827    }
828
829
830    cutIndex++; //7
831    if(!PsiPairCut(photon)) {
832       if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //7
833       return kFALSE;
834    }
835
836    cutIndex++; //8
837    if(!CosinePAngleCut(photon, event)) {
838       if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //8
839       return kFALSE;
840    }
841
842    cutIndex++; //9
843    if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //9
844
845    // Histos after Cuts
846    if(hInvMassafter)hInvMassafter->Fill(photon->GetMass());
847    if(hArmenterosafter)hArmenterosafter->Fill(photon->GetArmenterosAlpha(),photon->GetArmenterosQt());
848
849
850    return kTRUE;
851
852 }
853
854 ///________________________________________________________________________
855 Bool_t AliConversionCuts::CorrectedTPCClusterCut(AliConversionPhotonBase *photon, AliVEvent * event)
856 {   //Cut on corrected TPC Cluster Info
857
858    AliVTrack * negTrack = GetTrack(event, photon->GetTrackLabelNegative());
859    AliVTrack * posTrack = GetTrack(event, photon->GetTrackLabelPositive());
860
861    if(!negTrack||!posTrack)return kFALSE;
862
863    Double_t negclsToF=0;
864
865    if (!fUseCorrectedTPCClsInfo ){
866       if(negTrack->GetTPCNclsF()!=0){
867          negclsToF = (Double_t)negTrack->GetNcls(1)/(Double_t)negTrack->GetTPCNclsF();}// Ncluster/Nfindablecluster
868    }
869    else {
870       negclsToF = negTrack->GetTPCClusterInfo(2,0,GetFirstTPCRow(photon->GetConversionRadius()));
871    }
872
873    Double_t posclsToF = 0.;
874    if (!fUseCorrectedTPCClsInfo ){
875       if(posTrack->GetTPCNclsF()!=0){
876          posclsToF = (Double_t)posTrack->GetNcls(1)/(Double_t)posTrack->GetTPCNclsF();
877       }
878    }else{
879       posclsToF = posTrack->GetTPCClusterInfo(2,0,GetFirstTPCRow(photon->GetConversionRadius()));
880    }
881
882    if( negclsToF < fMinClsTPCToF || posclsToF < fMinClsTPCToF ){
883       return kFALSE;
884    }
885
886    return kTRUE;
887 }
888
889 ///________________________________________________________________________
890 Bool_t AliConversionCuts::PhotonIsSelected(AliConversionPhotonBase *photon, AliVEvent * event)
891 {
892    //Selection of Reconstructed Photons
893
894    FillPhotonCutIndex(kPhotonIn);
895
896    // Get Tracks
897    AliVTrack * negTrack = GetTrack(event, photon->GetTrackLabelNegative());
898    AliVTrack * posTrack = GetTrack(event, photon->GetTrackLabelPositive());
899
900    if(!negTrack || !posTrack) {
901       FillPhotonCutIndex(kNoTracks);
902       return kFALSE;
903    }
904
905    // dEdx Cuts
906    if(!dEdxCuts(negTrack) || !dEdxCuts(posTrack)) {
907       FillPhotonCutIndex(kdEdxCuts);
908       return kFALSE;
909    }
910
911    // Track Cuts
912    if(!TracksAreSelected(negTrack, posTrack)){
913       FillPhotonCutIndex(kTrackCuts);
914       return kFALSE;
915    }
916
917    // Photon Cuts
918    if(!PhotonCuts(photon,event)){
919       FillPhotonCutIndex(kPhotonCuts);
920       return kFALSE;
921    }
922
923    // Photon passed cuts
924    FillPhotonCutIndex(kPhotonOut);
925    return kTRUE;
926 }
927
928 ///________________________________________________________________________
929 Bool_t AliConversionCuts::ArmenterosQtCut(AliConversionPhotonBase *photon)
930 {   // Armenteros Qt Cut
931
932    if(fDoHighPtQtGammaSelection){
933       if(photon->GetPhotonPt() < fPtBorderForQt){
934          if(photon->GetArmenterosQt()>fQtMax){
935             return kFALSE;
936          }
937       } else {
938          if(photon->GetArmenterosQt()>fHighPtQtMax){
939             return kFALSE;
940          }
941       }
942    } else {
943
944       if(photon->GetArmenterosQt()>fQtMax){
945          return kFALSE;
946       }
947    }
948    return kTRUE;
949 }
950
951
952 ///________________________________________________________________________
953 Bool_t AliConversionCuts::AcceptanceCuts(AliConversionPhotonBase *photon) {
954    // Exclude certain areas for photon reconstruction
955
956    Int_t cutIndex=0;
957    if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
958    cutIndex++;
959
960    if(photon->GetConversionRadius()>fMaxR){ // cuts on distance from collision point
961       if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
962       return kFALSE;
963    }
964    cutIndex++;
965
966    if(photon->GetConversionRadius()<fMinR){ // cuts on distance from collision point
967       if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
968       return kFALSE;
969    }
970    cutIndex++;
971
972    if(photon->GetConversionRadius() <= ((abs(photon->GetConversionZ())*fLineCutZRSlope)-fLineCutZValue)){
973       if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
974       return kFALSE;
975    }
976    else if (fUseEtaMinCut &&  photon->GetConversionRadius() >= ((abs(photon->GetConversionZ())*fLineCutZRSlopeMin)-fLineCutZValueMin )){
977       if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
978       return kFALSE;
979    }
980    cutIndex++;
981
982    if(abs(photon->GetConversionZ()) > fMaxZ ){ // cuts out regions where we do not reconstruct
983       if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
984       return kFALSE;
985    }
986    cutIndex++;
987
988
989    if(abs(photon->GetPhotonEta())> fEtaCut || abs(photon->GetPhotonEta())< fEtaCutMin){
990       if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
991       return kFALSE;
992    }
993    cutIndex++;
994
995
996    if(photon->GetPhotonPt()<fPtCut){
997       if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
998       return kFALSE;
999    }
1000    cutIndex++;
1001
1002    if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
1003
1004    return kTRUE;
1005 }
1006
1007
1008 ///________________________________________________________________________
1009 Bool_t AliConversionCuts::SpecificTrackCuts(AliAODTrack * negTrack, AliAODTrack * posTrack,Int_t &cutIndex) {
1010    // Track Cuts which require AOD/ESD specific implementation
1011
1012    if( !negTrack->IsOn(AliESDtrack::kTPCrefit)  || !posTrack->IsOn(AliESDtrack::kTPCrefit)   )  {
1013       if(hTrackCuts)hTrackCuts->Fill(cutIndex);
1014       return kFALSE;
1015    }
1016    cutIndex++;
1017
1018    AliAODVertex * NegVtxType=negTrack->GetProdVertex();
1019    AliAODVertex * PosVtxType=posTrack->GetProdVertex();
1020    if((NegVtxType->GetType())==AliAODVertex::kKink  || (PosVtxType->GetType())==AliAODVertex::kKink) {
1021       if(hTrackCuts)hTrackCuts->Fill(cutIndex);
1022       return kFALSE;
1023    }
1024    return kTRUE;
1025
1026 }
1027
1028
1029 ///________________________________________________________________________
1030 Bool_t AliConversionCuts::SpecificTrackCuts(AliESDtrack * negTrack, AliESDtrack * posTrack,Int_t &cutIndex) {
1031    // Track Cuts which require AOD/ESD specific implementation
1032
1033    if( !negTrack->IsOn(AliESDtrack::kTPCrefit)  || !posTrack->IsOn(AliESDtrack::kTPCrefit)   )  {
1034       if(hTrackCuts)hTrackCuts->Fill(cutIndex);
1035       return kFALSE;
1036    }
1037    cutIndex++;
1038
1039    if(negTrack->GetKinkIndex(0) > 0  || posTrack->GetKinkIndex(0) > 0 ) {
1040       if(hTrackCuts)hTrackCuts->Fill(cutIndex);
1041       return kFALSE;
1042    }
1043    return kTRUE;
1044 }
1045
1046
1047
1048 ///________________________________________________________________________
1049 Bool_t AliConversionCuts::TracksAreSelected(AliVTrack * negTrack, AliVTrack * posTrack) {
1050    // Track Selection for Photon Reconstruction
1051
1052    Int_t cutIndex=0;
1053    if(hTrackCuts)hTrackCuts->Fill(cutIndex);
1054    cutIndex++;
1055
1056    // avoid like sign
1057    if(negTrack->Charge() == posTrack->Charge()) {
1058       if(hTrackCuts)hTrackCuts->Fill(cutIndex);
1059       return kFALSE;
1060    }
1061    cutIndex++;
1062
1063    // Number of TPC Clusters
1064    if( negTrack->GetNcls(1) < fMinClsTPC || posTrack->GetNcls(1) < fMinClsTPC ) {
1065       if(hTrackCuts)hTrackCuts->Fill(cutIndex);
1066       return kFALSE;
1067    }
1068    cutIndex++;
1069
1070    // Acceptance
1071
1072    if(abs(negTrack->Eta()) > fEtaCut || abs(negTrack->Eta()) < fEtaCutMin ||
1073       abs(posTrack->Eta())> fEtaCut || abs(posTrack->Eta())< fEtaCutMin) {
1074       if(hTrackCuts)hTrackCuts->Fill(cutIndex);
1075       return kFALSE;
1076    }
1077    cutIndex++;
1078
1079    // Single Pt Cut
1080    if( negTrack->Pt()< fSinglePtCut ||  posTrack->Pt()< fSinglePtCut){
1081       if(hTrackCuts)hTrackCuts->Fill(cutIndex);
1082       return kFALSE;
1083    }
1084    cutIndex++;
1085
1086    // AOD ESD specific cuts
1087    Bool_t passCuts = kTRUE;
1088
1089    if(negTrack->IsA()==AliAODTrack::Class()) {
1090       passCuts = passCuts * SpecificTrackCuts(static_cast<AliAODTrack*>(negTrack), static_cast<AliAODTrack*>(posTrack),cutIndex);
1091    } else {
1092       passCuts = passCuts * SpecificTrackCuts(static_cast<AliESDtrack*>(negTrack), static_cast<AliESDtrack*>(posTrack),cutIndex);
1093    }
1094
1095    if(!passCuts){
1096       if(hTrackCuts)hTrackCuts->Fill(cutIndex);
1097       return kFALSE;
1098    }
1099    cutIndex++;
1100
1101    if(hTrackCuts)hTrackCuts->Fill(cutIndex);
1102
1103    return kTRUE;
1104
1105 }
1106
1107 ///________________________________________________________________________
1108 Bool_t AliConversionCuts::dEdxCuts(AliVTrack *fCurrentTrack){
1109    // Electron Identification Cuts for Photon reconstruction
1110
1111    if(!fPIDResponse){InitPIDResponse();}// Try to reinitialize PID Response
1112    if(!fPIDResponse){AliError("No PID Response"); return kTRUE;}// if still missing fatal error
1113
1114    Int_t cutIndex=0;
1115    if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
1116    if(hTPCdEdxSigbefore)hTPCdEdxSigbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTPC(fCurrentTrack, AliPID::kElectron));
1117    if(hTPCdEdxbefore)hTPCdEdxbefore->Fill(fCurrentTrack->P(),fCurrentTrack->GetTPCsignal());
1118    cutIndex++;
1119
1120
1121    if(fDodEdxSigmaCut == kTRUE){
1122       // TPC Electron Line
1123       if( fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)<fPIDnSigmaBelowElectronLine ||
1124           fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)>fPIDnSigmaAboveElectronLine){
1125
1126          if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
1127          return kFALSE;
1128       }
1129       cutIndex++;
1130
1131       // TPC Pion Line
1132       if( fCurrentTrack->P()>fPIDMinPnSigmaAbovePionLine && fCurrentTrack->P()<fPIDMaxPnSigmaAbovePionLine ){
1133          if(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLine &&
1134             fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)<fPIDnSigmaAboveElectronLine&&
1135             fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)<fPIDnSigmaAbovePionLine){
1136
1137             if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
1138             return kFALSE;
1139          }
1140       }
1141       cutIndex++;
1142
1143       // High Pt Pion rej
1144       if( fCurrentTrack->P()>fPIDMaxPnSigmaAbovePionLine ){
1145          if(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLine &&
1146             fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)<fPIDnSigmaAboveElectronLine &&
1147             fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)<fPIDnSigmaAbovePionLineHighPt){
1148
1149             if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
1150             return kFALSE;
1151          }
1152       }
1153       cutIndex++;
1154    }
1155    else{cutIndex+=3;}
1156
1157    if(fDoKaonRejectionLowP == kTRUE){
1158       if(fCurrentTrack->P()<fPIDMinPKaonRejectionLowP ){
1159          if( abs(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kKaon))<fPIDnSigmaAtLowPAroundKaonLine){
1160
1161             if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
1162             return kFALSE;
1163          }
1164       }
1165    }
1166    cutIndex++;
1167
1168    if(fDoProtonRejectionLowP == kTRUE){
1169       if( fCurrentTrack->P()<fPIDMinPProtonRejectionLowP ){
1170          if( abs(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kProton))<fPIDnSigmaAtLowPAroundProtonLine){
1171
1172             if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
1173             return kFALSE;
1174          }
1175       }
1176    }
1177    cutIndex++;
1178
1179    if(fDoPionRejectionLowP == kTRUE){
1180       if( fCurrentTrack->P()<fPIDMinPPionRejectionLowP ){
1181          if( abs(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion))<fPIDnSigmaAtLowPAroundPionLine){
1182
1183             if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
1184             return kFALSE;
1185          }
1186       }
1187    }
1188    cutIndex++;
1189
1190
1191    // cout<<"Start"<<endl;
1192    // AliPIDResponse::EDetPidStatus status=fPIDResponse->CheckPIDStatus(AliPIDResponse::kTOF,fCurrentTrack);
1193
1194    // if( ( (status & AliVTrack::kTOFout) == AliVTrack::kTOFout ) && ( (status & AliVTrack::kTIME) == AliVTrack::kTIME ))
1195    //    {cout<<"TOF DA"<<endl;}
1196    // if(status == AliPIDResponse::kDetPidOk){
1197    //    Float_t probMis = fPIDResponse->GetTOFMismatchProbability(fCurrentTrack);
1198    //    cout<<"--> "<<probMis<<endl;
1199    //    if(probMis > 0.01){
1200
1201    //    }
1202    // }
1203
1204    if((fCurrentTrack->GetStatus() & AliESDtrack::kTOFpid) && !(fCurrentTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
1205       if(hTOFbefore){
1206          Double_t t0 = fPIDResponse->GetTOFResponse().GetStartTime(fCurrentTrack->P());
1207          Double_t times[5];
1208          fCurrentTrack->GetIntegratedTimes(times);
1209          Double_t TOFsignal =   fCurrentTrack->GetTOFsignal();
1210          Double_t dT = TOFsignal - t0 - times[0];
1211          hTOFbefore->Fill(fCurrentTrack->P(),dT);
1212       }
1213       if(hTOFSigbefore) hTOFSigbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron));
1214       if(fUseTOFpid){
1215          if(fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron)>fTofPIDnSigmaAboveElectronLine ||
1216             fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron)<fTofPIDnSigmaBelowElectronLine ){
1217             if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
1218             return kFALSE;
1219          }
1220       }
1221       if(hTOFSigafter)hTOFSigafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron));
1222    }
1223    cutIndex++;
1224
1225    // Apply TRD PID
1226    if(fDoTRDPID){
1227       if(!fPIDResponse->IdentifiedAsElectronTRD(fCurrentTrack,fPIDTRDEfficiency)){
1228          if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
1229          return kFALSE;
1230       }
1231    }
1232    cutIndex++;
1233
1234    if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
1235    if(hTPCdEdxSigafter)hTPCdEdxSigafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTPC(fCurrentTrack, AliPID::kElectron));
1236    if(hTPCdEdxafter)hTPCdEdxafter->Fill(fCurrentTrack->P(),fCurrentTrack->GetTPCsignal());
1237    return kTRUE;
1238 }
1239
1240 ///________________________________________________________________________
1241 Bool_t AliConversionCuts::AsymmetryCut(AliConversionPhotonBase * photon,AliVEvent *event) {
1242    // Cut on Energy Assymetry
1243
1244    for(Int_t ii=0;ii<2;ii++){
1245
1246       AliVTrack *track=GetTrack(event,photon->GetTrackLabel(ii));
1247
1248       if( track->P() > fMinPPhotonAsymmetryCut ){
1249          Double_t trackNegAsy=0;
1250          if (photon->GetPhotonP()!=0.){
1251             trackNegAsy= track->P()/photon->GetPhotonP();
1252          }
1253
1254          if( trackNegAsy<fMinPhotonAsymmetry ||trackNegAsy>(1.- fMinPhotonAsymmetry)){
1255             return kFALSE;
1256          }
1257       }
1258
1259    }
1260    return kTRUE;
1261 }
1262
1263 ///________________________________________________________________________
1264 AliVTrack *AliConversionCuts::GetTrack(AliVEvent * event, Int_t label){
1265    //Returns pointer to the track with given ESD label
1266    //(Important for AOD implementation, since Track array in AOD data is different
1267    //from ESD array, but ESD tracklabels are stored in AOD Tracks)
1268
1269    AliESDEvent * esdEvent = dynamic_cast<AliESDEvent*>(event);
1270    if(esdEvent) {
1271       if(label > event->GetNumberOfTracks() ) return NULL;
1272       AliESDtrack * track = esdEvent->GetTrack(label);
1273       return track;
1274
1275    } else {
1276       for(Int_t ii=0; ii<event->GetNumberOfTracks(); ii++) {
1277          AliVTrack * track = dynamic_cast<AliVTrack*>(event->GetTrack(ii));
1278
1279          if(track) {
1280             if(track->GetID() == label) {
1281                return track;
1282             }
1283          }
1284       }
1285    }
1286
1287    //AliDebug(5,(Form("track not found %d %d",label,event->GetNumberOfTracks()));
1288    return NULL;
1289 }
1290
1291 ///________________________________________________________________________
1292 AliESDtrack *AliConversionCuts::GetESDTrack(AliESDEvent * event, Int_t label){
1293    //Returns pointer to the track with given ESD label
1294    //(Important for AOD implementation, since Track array in AOD data is different
1295    //from ESD array, but ESD tracklabels are stored in AOD Tracks)
1296
1297    if(event) {
1298       if(label > event->GetNumberOfTracks() ) return NULL;
1299       AliESDtrack * track = event->GetTrack(label);
1300       return track;
1301    }
1302    //AliDebug(5,(Form("track not found %d %d",label,event->GetNumberOfTracks()));
1303    return NULL;
1304 }
1305
1306
1307
1308 ///________________________________________________________________________
1309 Bool_t AliConversionCuts::PIDProbabilityCut(AliConversionPhotonBase *photon, AliVEvent * event){
1310    // Cut on Electron Probability for Photon Reconstruction
1311
1312    AliESDEvent * esdEvent = dynamic_cast<AliESDEvent*>(event);
1313
1314    if(esdEvent){
1315
1316       Bool_t iResult=kFALSE;
1317
1318       Double_t *posProbArray = new Double_t[AliPID::kSPECIES];
1319       Double_t *negProbArray = new Double_t[AliPID::kSPECIES];
1320
1321       AliESDtrack* negTrack     = esdEvent->GetTrack(photon->GetTrackLabelNegative());
1322       AliESDtrack* posTrack     = esdEvent->GetTrack(photon->GetTrackLabelPositive());
1323
1324       if(negProbArray && posProbArray){
1325
1326          negTrack->GetTPCpid(negProbArray);
1327          posTrack->GetTPCpid(posProbArray);
1328
1329          if(negProbArray[AliPID::kElectron]>=fPIDProbabilityCutNegativeParticle && posProbArray[AliPID::kElectron]>=fPIDProbabilityCutPositiveParticle){
1330             iResult=kTRUE;
1331          }
1332       }
1333
1334       delete [] posProbArray;
1335       delete [] negProbArray;
1336       return iResult;
1337
1338    } else {
1339       ///Not possible for AODs
1340       return kTRUE;
1341    }
1342
1343
1344
1345
1346 }
1347
1348
1349 ///________________________________________________________________________
1350 Bool_t AliConversionCuts::AcceptanceCut(TParticle *particle, TParticle * ePos,TParticle* eNeg){
1351    // MC Acceptance Cuts
1352    //(Certain areas were excluded for photon reconstruction)
1353
1354    if(particle->R()>fMaxR){
1355       return kFALSE;}
1356
1357    if(ePos->R()>fMaxR){
1358       return kFALSE;
1359    }
1360
1361    if(ePos->R()<fMinR){
1362       return kFALSE;
1363    }
1364
1365    if( ePos->R() <= ((abs(ePos->Vz())*fLineCutZRSlope)-fLineCutZValue)){
1366       return kFALSE;
1367    }
1368    else if (fUseEtaMinCut &&  ePos->R() >= ((abs(ePos->Vz())*fLineCutZRSlopeMin)-fLineCutZValueMin )){
1369       return kFALSE;
1370    }
1371
1372    if(abs(eNeg->Vz()) > fMaxZ ){ // cuts out regions where we do not reconstruct
1373       return kFALSE;
1374    }
1375
1376    if(eNeg->Vz()!=ePos->Vz()||eNeg->R()!=ePos->R()){
1377       return kFALSE;
1378    }
1379
1380    if(abs(ePos->Vz()) > fMaxZ ){ // cuts out regions where we do not reconstruct
1381       return kFALSE;
1382    }
1383
1384    if(abs(particle->Eta())> fEtaCut || abs(particle->Eta())< fEtaCutMin){
1385       return kFALSE;
1386    }
1387
1388    if(abs(ePos->Eta())> fEtaCut || abs(ePos->Eta())< fEtaCutMin){
1389       return kFALSE;
1390    }
1391
1392    if(abs(eNeg->Eta())> fEtaCut || abs(eNeg->Eta())< fEtaCutMin){
1393       return kFALSE;
1394    }
1395
1396    if( ePos->Pt()< fSinglePtCut ||  eNeg->Pt()< fSinglePtCut){
1397       return kFALSE;
1398    }
1399
1400    if(particle->Pt()<fPtCut){
1401       return kFALSE;
1402    }
1403
1404    return kTRUE;
1405 }
1406 ///________________________________________________________________________
1407 Bool_t AliConversionCuts::UpdateCutString() {
1408    ///Update the cut string (if it has been created yet)
1409
1410    if(fCutString && fCutString->GetString().Length() == kNCuts) {
1411       fCutString->SetString(GetCutNumber());
1412    } else {
1413       return kFALSE;
1414    }
1415    return kTRUE;
1416 }
1417
1418 ///________________________________________________________________________
1419 Bool_t AliConversionCuts::InitializeCutsFromCutString(const TString analysisCutSelection ) {
1420    // Initialize Cuts from a given Cut string
1421
1422    AliInfo(Form("Set Photoncut Number: %s",analysisCutSelection.Data()));
1423    if(analysisCutSelection.Length()!=kNCuts) {
1424       AliError(Form("Cut selection has the wrong length! size is %d, number of cuts is %d", analysisCutSelection.Length(), kNCuts));
1425       return kFALSE;
1426    }
1427    if(!analysisCutSelection.IsDigit()){
1428       AliError("Cut selection contains characters");
1429       return kFALSE;
1430    }
1431
1432    const char *cutSelection = analysisCutSelection.Data();
1433 #define ASSIGNARRAY(i)  fCuts[i] = cutSelection[i] - '0'
1434    for(Int_t ii=0;ii<kNCuts;ii++){
1435       ASSIGNARRAY(ii);
1436    }
1437
1438    // Set Individual Cuts
1439    for(Int_t ii=0;ii<kNCuts;ii++){
1440       if(!SetCut(cutIds(ii),fCuts[ii]))return kFALSE;
1441    }
1442
1443    //PrintCuts();
1444
1445    // Set StandardTriggers
1446
1447    if(fIsHeavyIon)SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral);
1448    else SelectCollisionCandidates(AliVEvent::kMB);
1449
1450    return kTRUE;
1451 }
1452 ///________________________________________________________________________
1453 Bool_t AliConversionCuts::SetCut(cutIds cutID, const Int_t value) {
1454    ///Set individual cut ID
1455
1456    switch (cutID) {
1457
1458    case kv0FinderType:
1459       if( SetV0Finder(value)) {
1460          fCuts[kv0FinderType] = value;
1461          UpdateCutString();
1462          return kTRUE;
1463       } else return kFALSE;
1464
1465    case kededxSigmaCut:
1466       if( SetTPCdEdxCutElectronLine(value)) {
1467          fCuts[kededxSigmaCut] = value;
1468          UpdateCutString();
1469          return kTRUE;
1470       } else return kFALSE;
1471
1472    case kpidedxSigmaCut:
1473       if( SetTPCdEdxCutPionLine(value)) {
1474          fCuts[kpidedxSigmaCut] = value;
1475          UpdateCutString();
1476          return kTRUE;
1477       } else return kFALSE;
1478
1479    case kpiMomdedxSigmaCut:
1480       if( SetMinMomPiondEdxCut(value)) {
1481          fCuts[kpiMomdedxSigmaCut] = value;
1482          UpdateCutString();
1483          return kTRUE;
1484       } else return kFALSE;
1485
1486    case kchi2GammaCut:
1487       if( SetChi2GammaCut(value)) {
1488          fCuts[kchi2GammaCut] = value;
1489          UpdateCutString();
1490          return kTRUE;
1491       } else return kFALSE;
1492
1493    case ksinglePtCut:
1494       if( SetSinglePtCut(value)) {
1495          fCuts[ksinglePtCut] = value;
1496          UpdateCutString();
1497          return kTRUE;
1498       } else return kFALSE;
1499
1500    case kclsTPCCut:
1501       if( SetTPCClusterCut(value)) {
1502          fCuts[kclsTPCCut] = value;
1503          UpdateCutString();
1504          return kTRUE;
1505       } else return kFALSE;
1506
1507    case ketaCut:
1508       if( SetEtaCut(value)) {
1509          fCuts[ketaCut] = value;
1510          UpdateCutString();
1511          return kTRUE;
1512       } else return kFALSE;
1513
1514    case kLowPRejectionSigmaCut:
1515       if( SetLowPRejectionCuts(value)) {
1516          fCuts[kLowPRejectionSigmaCut] = value;
1517          UpdateCutString();
1518          return kTRUE;
1519       } else return kFALSE;
1520
1521    case kQtMaxCut:
1522       if( SetQtMaxCut(value)) {
1523          fCuts[kQtMaxCut] = value;
1524          UpdateCutString();
1525          return kTRUE;
1526       } else return kFALSE;
1527
1528    case kpiMaxMomdedxSigmaCut:
1529       if( SetMaxMomPiondEdxCut(value)) {
1530          fCuts[kpiMaxMomdedxSigmaCut] = value;
1531          UpdateCutString();
1532          return kTRUE;
1533       } else return kFALSE;
1534
1535    case kRCut:
1536       if( SetRCut(value)) {
1537          fCuts[kRCut] = value;
1538          UpdateCutString();
1539          return kTRUE;
1540       } else return kFALSE;
1541
1542    case kremovePileUp:
1543       if( SetRemovePileUp(value)) {
1544          fCuts[kremovePileUp] = value;
1545          UpdateCutString();
1546          return kTRUE;
1547       } else return kFALSE;
1548
1549    case kselectV0AND:
1550       if( SetSelectSpecialTrigger(value)) {
1551          fCuts[kselectV0AND] = value;
1552          UpdateCutString();
1553          return kTRUE;
1554       } else return kFALSE;
1555
1556    case kmultiplicityMethod:
1557       if( SetMultiplicityMethod(value)) {
1558          fCuts[kmultiplicityMethod] = value;
1559          UpdateCutString();
1560          return kTRUE;
1561       } else return kFALSE;
1562
1563    case kisHeavyIon:
1564       if( SetIsHeavyIon(value)) {
1565          fCuts[kisHeavyIon] = value;
1566          UpdateCutString();
1567          return kTRUE;
1568       } else return kFALSE;
1569
1570    case kCentralityMin:
1571       if( SetCentralityMin(value)) {
1572          fCuts[kCentralityMin] = value;
1573          UpdateCutString();
1574          return kTRUE;
1575       } else return kFALSE;
1576
1577    case kCentralityMax:
1578       if( SetCentralityMax(value)) {
1579          fCuts[kCentralityMax] = value;
1580          UpdateCutString();
1581          return kTRUE;
1582       } else return kFALSE;
1583
1584    case kTOFelectronPID:
1585       if( SetTOFElectronPIDCut(value)) {
1586          fCuts[kTOFelectronPID] = value;
1587          UpdateCutString();
1588          return kTRUE;
1589       } else return kFALSE;
1590
1591    case kdoPhotonAsymmetryCut:
1592       if( SetPhotonAsymmetryCut(value)) {
1593          fCuts[kdoPhotonAsymmetryCut] = value;
1594          UpdateCutString();
1595          return kTRUE;
1596       } else return kFALSE;
1597
1598    case kPsiPair:
1599       if( SetPsiPairCut(value)) {
1600          fCuts[kPsiPair] = value;
1601          UpdateCutString();
1602          return kTRUE;
1603       } else return kFALSE;
1604
1605    case kCosPAngle:
1606       if( SetCosPAngleCut(value)) {
1607          fCuts[kCosPAngle] = value;
1608          UpdateCutString();
1609          return kTRUE;
1610       } else return kFALSE;
1611
1612
1613    case kElecShare:
1614       if( SetSharedElectronCut(value)) {
1615          fCuts[kElecShare] = value;
1616          UpdateCutString();
1617          return kTRUE;
1618       } else return kFALSE;
1619
1620    case kToCloseV0s:
1621       if( SetToCloseV0sCut(value)) {
1622          fCuts[kToCloseV0s] = value;
1623          UpdateCutString();
1624          return kTRUE;
1625       } else return kFALSE;
1626
1627    case kExtraSignals:
1628       if( SetRejectExtraSignalsCut(value)) {
1629          fCuts[kExtraSignals] = value;
1630          UpdateCutString();
1631          return kTRUE;
1632       } else return kFALSE;
1633
1634    case kNCuts:
1635       AliError("Cut id out of range");
1636       return kFALSE;
1637    }
1638
1639    AliError("Cut id %d not recognized");
1640    return kFALSE;
1641
1642
1643 }
1644 ///________________________________________________________________________
1645 void AliConversionCuts::PrintCuts() {
1646    // Print out current Cut Selection
1647    for(Int_t ic = 0; ic < kNCuts; ic++) {
1648       printf("%-30s : %d \n", fgkCutNames[ic], fCuts[ic]);
1649    }
1650 }
1651 ///________________________________________________________________________
1652 Bool_t AliConversionCuts::SetIsHeavyIon(Int_t isHeavyIon)
1653 {   // Set Cut
1654    switch(isHeavyIon){
1655    case 0:
1656       fIsHeavyIon=0;
1657       break;
1658    case 1:
1659       fIsHeavyIon=1;
1660       fDetectorCentrality=0;
1661       break;
1662    case 2:
1663       fIsHeavyIon=1;
1664       fDetectorCentrality=1;
1665       break;
1666    case 3: //allows to select centrality 0-45% in steps of 5% for V0 Multiplicity
1667       fIsHeavyIon=1;
1668       fDetectorCentrality=0;
1669       fModCentralityClass=1;
1670       break;
1671    case 4: //allows to select centrality 45-90% in steps of 5% for V0 Multiplicity
1672       fIsHeavyIon=1;
1673       fDetectorCentrality=0;
1674       fModCentralityClass=2;
1675       break;
1676    case 5: //strict cut on v0 tracks for MC
1677       fIsHeavyIon=1;
1678       fDetectorCentrality=0;
1679       fModCentralityClass=3;
1680       break;
1681    case 6: //allows to select centrality 0-45% in steps of 5% for V0 Multiplicity
1682       //strict cut on v0 tracks for MC
1683       fIsHeavyIon=1;
1684       fDetectorCentrality=0;
1685       fModCentralityClass=4;
1686       break;
1687    case 7: //allows to select centrality 45-90% in steps of 5% for V0 Multiplicity
1688       //strict cut on v0 tracks for MC
1689       fIsHeavyIon=1;
1690       fDetectorCentrality=0;
1691       fModCentralityClass=5;
1692       break;
1693    default:
1694       AliError(Form("SetHeavyIon not defined %d",isHeavyIon));
1695       return kFALSE;
1696    }
1697    return kTRUE;
1698 }
1699 //___________________________________________________________________
1700 Bool_t AliConversionCuts::SetCentralityMin(Int_t minCentrality)
1701 {
1702    // Set Cut
1703    if(minCentrality<0||minCentrality>9){
1704       AliError(Form("minCentrality not defined %d",minCentrality));
1705       return kFALSE;
1706    }
1707
1708    fCentralityMin=minCentrality;
1709    return kTRUE;
1710 }
1711 //___________________________________________________________________
1712 Bool_t AliConversionCuts::SetCentralityMax(Int_t maxCentrality)
1713 {
1714    // Set Cut
1715    if(maxCentrality<0||maxCentrality>9){
1716       AliError(Form("maxCentrality not defined %d",maxCentrality));
1717       return kFALSE;
1718    }
1719    fCentralityMax=maxCentrality;
1720    return kTRUE;
1721 }
1722 ///________________________________________________________________________
1723 Int_t AliConversionCuts::SetSelectSpecialTrigger(Int_t selectSpecialTrigger)
1724 {// Set Cut
1725
1726    switch(selectSpecialTrigger){
1727    case 0:
1728       fSpecialTrigger=0; // dont care
1729       break;
1730    case 1:
1731       fSpecialTrigger=1; // V0AND
1732       break;
1733    case 2:
1734       fSpecialTrigger=2; // with SDD requested
1735       break;
1736    case 3:
1737       fSpecialTrigger=3; // V0AND plus with SDD requested
1738       break;
1739
1740    default:
1741       AliError("Warning: Special Trigger Not known");
1742       return kFALSE;
1743    }
1744    return kTRUE;
1745 }
1746 ///________________________________________________________________________
1747 Bool_t AliConversionCuts::SetMultiplicityMethod(Int_t multiplicityMethod)
1748 {
1749    // Set Cut
1750    fMultiplicityMethod=multiplicityMethod;
1751
1752    // 0 Photon Multiplicity
1753    // 1 TPC Track multiplicity
1754    // 2 V0 Mult
1755    // 3 SPD Mult
1756
1757    return kTRUE;
1758 }
1759 ///________________________________________________________________________
1760 Bool_t AliConversionCuts::SetRemovePileUp(Int_t removePileUp)
1761 {// Set Cut
1762    switch(removePileUp){
1763    case 0:
1764       fRemovePileUp=kFALSE;
1765       break;
1766    case 1:
1767       fRemovePileUp=kTRUE;
1768       break;
1769    default:
1770       AliError("RemovePileUpCut not defined");
1771       return kFALSE;
1772    }
1773    return kTRUE;
1774 }
1775 ///________________________________________________________________________
1776 Bool_t AliConversionCuts::SetRejectExtraSignalsCut(Int_t extraSignal) {
1777
1778    switch(extraSignal){
1779    case 0:
1780       fRejectExtraSignals = 0;
1781       break; // No Rejection
1782    case 1:
1783       fRejectExtraSignals = 1;
1784       break; // MinBias Header
1785    case 2:
1786       fRejectExtraSignals = 2;
1787       break; // User String Array
1788    case 3:
1789       fRejectExtraSignals = 3;
1790       break; // Rejection for Gamma Correction only
1791    default:
1792       AliError(Form("Extra Signal Rejection not defined %d",extraSignal));
1793       return kFALSE;
1794    }
1795    return kTRUE;
1796 }
1797 ///________________________________________________________________________
1798 Bool_t AliConversionCuts::SetV0Finder(Int_t v0FinderType)
1799 {   // Set Cut
1800    switch (v0FinderType){
1801    case 0:  // on fly V0 finder
1802       fUseOnFlyV0Finder=kTRUE;
1803       break;
1804    case 1:  // offline V0 finder
1805       fUseOnFlyV0Finder=kFALSE;
1806       break;
1807    default:
1808       AliError(Form(" v0FinderType not defined %d",v0FinderType));
1809       return kFALSE;
1810    }
1811    return kTRUE;
1812 }
1813 ///________________________________________________________________________
1814 Bool_t AliConversionCuts::SetEtaCut(Int_t etaCut)
1815 {   // Set Cut
1816
1817    //Set Standard LineCutZValues
1818    fLineCutZValueMin = -2;
1819    fLineCutZValue = 7.;
1820
1821    switch(etaCut){
1822    case 0: // 0.9
1823       fEtaCut           = 0.9;
1824       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
1825       fEtaCutMin                = -0.1;
1826       fLineCutZRSlopeMin = 0.;
1827       break;
1828    case 1:      // 1.2
1829       fEtaCut           = 1.2;
1830       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
1831       fEtaCutMin                = -0.1;
1832       fLineCutZRSlopeMin = 0.;
1833       break;
1834    case 2:      // 1.4
1835       fEtaCut           = 1.4;
1836       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
1837       fEtaCutMin                = -0.1;
1838       fLineCutZRSlopeMin = 0.;
1839       break;
1840    case 3: // 0.8
1841       fEtaCut           = 0.8;
1842       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
1843       fEtaCutMin                = -0.1;
1844       fLineCutZRSlopeMin = 0.;
1845       break;
1846    case 4: // 0.75
1847       fEtaCut           = 0.75;
1848       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
1849       fEtaCutMin                = -0.1;
1850       fLineCutZRSlopeMin = 0.;
1851       break;
1852    case 5: // 0.9 - 1.4
1853       fEtaCut           = 1.4;
1854       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
1855       fEtaCutMin                = 0.9;
1856       fLineCutZRSlopeMin = tan(2*atan(exp(-fEtaCutMin)));
1857       break;
1858    case 6: // 5.
1859       fEtaCut           = 5.;
1860       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
1861       fEtaCutMin                = -0.1;
1862       fLineCutZRSlopeMin = 0.;
1863       break;
1864    case 7: // 0.1 - 0.8
1865       fEtaCut           = 0.8;
1866       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
1867       fEtaCutMin                = 0.1;
1868       fLineCutZRSlopeMin = tan(2*atan(exp(-fEtaCutMin)));
1869       break;
1870    case 8: // 0.1 - 0.8
1871       fEtaCut           = 0.9;
1872       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
1873       fEtaCutMin                = 0.1;
1874       fLineCutZRSlopeMin = tan(2*atan(exp(-fEtaCutMin)));
1875       break;
1876    case 9: // 10
1877       fEtaCut           = 10;
1878       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
1879       fEtaCutMin                = -0.1;
1880       fLineCutZRSlopeMin = 0.;
1881       break;
1882    default:
1883       AliError(Form(" EtaCut not defined %d",etaCut));
1884       return kFALSE;
1885    }
1886    return kTRUE;
1887 }
1888 ///________________________________________________________________________
1889 Bool_t AliConversionCuts::SetRCut(Int_t RCut){
1890    // Set Cut
1891    switch(RCut){
1892    case 0:
1893       fMinR=0;
1894       fMaxR = 180.;
1895       break;
1896    case 1:
1897       fMinR=2.8;
1898       fMaxR = 180.;
1899       break;
1900    case 2:
1901       fMinR=5.;
1902       fMaxR = 180.;
1903       break;
1904    case 3:
1905       fMaxR = 70.;
1906       fMinR = 10.;
1907       break;
1908    case 4:
1909       fMaxR = 70.;
1910       fMinR = 5.;
1911       break;
1912       // High purity cuts for PbPb (remove first layers of material)
1913    case 5:
1914       fMaxR = 180.;
1915       fMinR = 10.;
1916       break;
1917    case 6:
1918       fMaxR = 180.;
1919       fMinR = 20.;
1920       break;
1921    case 7:
1922       fMaxR = 180.;
1923       fMinR = 26.;
1924       break;
1925    case 8:
1926       fMaxR = 180.;
1927       fMinR = 35.;
1928       break;
1929    case 9:
1930       fMaxR = 35.;
1931       fMinR = 5.;
1932       break;
1933
1934    default:
1935       AliError("RCut not defined");
1936       return kFALSE;
1937    }
1938    return kTRUE;
1939 }
1940 ///________________________________________________________________________
1941 Bool_t AliConversionCuts::SetSinglePtCut(Int_t singlePtCut)
1942 {   // Set Cut
1943    switch(singlePtCut){
1944    case 0: // 0.050 GeV
1945       fSinglePtCut = 0.050;
1946       break;
1947    case 1:  // 0.100 GeV
1948       fSinglePtCut = 0.100;
1949       break;
1950    case 2:  // 0.150 GeV
1951       fSinglePtCut = 0.150;
1952       break;
1953    case 3:  // 0.200 GeV
1954       fSinglePtCut = 0.200;
1955       break;
1956    case 4:  // 0.075 GeV
1957       fSinglePtCut = 0.075;
1958       break;
1959    case 5:  // 0.125 GeV
1960       fSinglePtCut = 0.125;
1961       break;
1962    case 6:  // 0.04 GeV
1963       fSinglePtCut = 0.040;
1964       break;
1965    case 7:  // 0.0 GeV
1966       fSinglePtCut = 0.0;
1967       break;
1968    default:
1969       AliError(Form("singlePtCut not defined %d",singlePtCut));
1970       return kFALSE;
1971    }
1972    return kTRUE;
1973 }
1974 ///________________________________________________________________________
1975 Bool_t AliConversionCuts::SetTPCClusterCut(Int_t clsTPCCut)
1976 {   // Set Cut
1977    switch(clsTPCCut){
1978    case 0: // 0
1979       fMinClsTPC= 0.;
1980       break;
1981    case 1:  // 70
1982       fMinClsTPC= 70.;
1983       break;
1984    case 2:  // 80
1985       fMinClsTPC= 80.;
1986       break;
1987    case 3:  // 100
1988       fMinClsTPC= 100.;
1989       break;
1990    case 4:  // 60% of findable clusters
1991       fMinClsTPCToF= 0.6;
1992       fUseCorrectedTPCClsInfo=0;
1993       break;
1994    case 5:  // 0% of findable clusters
1995       fMinClsTPCToF= 0.0;
1996       fUseCorrectedTPCClsInfo=1;
1997       break;
1998    case 6:  // 70% of findable clusters
1999       fMinClsTPCToF= 0.7;
2000       fUseCorrectedTPCClsInfo=1;
2001       break;
2002    case 7:  // 0% of findable clusters
2003       fMinClsTPCToF= 0.35;
2004       fUseCorrectedTPCClsInfo=0;
2005       break;
2006    case 8:
2007       fMinClsTPCToF= 0.35;
2008       fUseCorrectedTPCClsInfo=1;
2009       break;
2010    case 9:
2011       fMinClsTPCToF= 0.6;
2012       fUseCorrectedTPCClsInfo=1;
2013       break;
2014    default:
2015       AliError(Form("Warning: clsTPCCut not defined %d",clsTPCCut));
2016       return kFALSE;
2017    }
2018    return kTRUE;
2019 }
2020 ///________________________________________________________________________
2021 Bool_t AliConversionCuts::SetTPCdEdxCutElectronLine(Int_t ededxSigmaCut)
2022 {   // Set Cut
2023    switch(ededxSigmaCut){
2024    case 0: // -10,10
2025       fPIDnSigmaBelowElectronLine=-10;
2026       fPIDnSigmaAboveElectronLine=10;
2027       break;
2028    case 1: // -5,5
2029       fPIDnSigmaBelowElectronLine=-5;
2030       fPIDnSigmaAboveElectronLine=5;
2031       break;
2032    case 2: // -3,5
2033       fPIDnSigmaBelowElectronLine=-3;
2034       fPIDnSigmaAboveElectronLine=5;
2035       break;
2036    case 3: // -4,5
2037       fPIDnSigmaBelowElectronLine=-4;
2038       fPIDnSigmaAboveElectronLine=5;
2039       break;
2040    case 4: // -6,7
2041       fPIDnSigmaBelowElectronLine=-6;
2042       fPIDnSigmaAboveElectronLine=7;
2043       break;
2044    case 5: // -4,4
2045       fPIDnSigmaBelowElectronLine=-4;
2046       fPIDnSigmaAboveElectronLine=4;
2047       break;
2048    case 6: // -2.5,4
2049       fPIDnSigmaBelowElectronLine=-2.5;
2050       fPIDnSigmaAboveElectronLine=4;
2051       break;
2052    case 7: // -2,3.5
2053       fPIDnSigmaBelowElectronLine=-2;
2054       fPIDnSigmaAboveElectronLine=3.5;
2055       break;
2056    default:
2057       AliError("TPCdEdxCutElectronLine not defined");
2058       return kFALSE;
2059
2060    }
2061    return kTRUE;
2062 }
2063 ///________________________________________________________________________
2064 Bool_t AliConversionCuts::SetTPCdEdxCutPionLine(Int_t pidedxSigmaCut)
2065 {   // Set Cut
2066
2067    switch(pidedxSigmaCut){
2068    case 0:  // -10
2069       fPIDnSigmaAbovePionLine=-10;
2070       fPIDnSigmaAbovePionLineHighPt=-10;
2071       break;
2072    case 1:   // 0
2073       fPIDnSigmaAbovePionLine=0;
2074       fPIDnSigmaAbovePionLineHighPt=-10;
2075       break;
2076    case 2:  // 1
2077       fPIDnSigmaAbovePionLine=1;
2078       fPIDnSigmaAbovePionLineHighPt=-10;
2079       break;
2080    case 3:  // 1
2081       fPIDnSigmaAbovePionLine=2.5;
2082       fPIDnSigmaAbovePionLineHighPt=-10;
2083       break;
2084    case 4:  // 1
2085       fPIDnSigmaAbovePionLine=0.5;
2086       fPIDnSigmaAbovePionLineHighPt=-10;
2087       break;
2088    case 5:  // 1
2089       fPIDnSigmaAbovePionLine=2.;
2090       fPIDnSigmaAbovePionLineHighPt=-10;
2091       break;
2092    case 6:  // 1
2093       fPIDnSigmaAbovePionLine=2.;
2094       fPIDnSigmaAbovePionLineHighPt=0.5;
2095       break;
2096    case 7:  // 1
2097       fPIDnSigmaAbovePionLine=3.5;
2098       fPIDnSigmaAbovePionLineHighPt=-10;
2099       break;
2100    case 8:  // 1
2101       fPIDnSigmaAbovePionLine=2.;
2102       fPIDnSigmaAbovePionLineHighPt=1.;
2103       break;
2104    case 9:
2105       fPIDnSigmaAbovePionLine=3.0; // We need a bit less tight cut on dE/dx
2106       fPIDnSigmaAbovePionLineHighPt=-10;
2107       break;
2108    default:
2109       AliError(Form("Warning: pidedxSigmaCut not defined %d",pidedxSigmaCut));
2110       return kFALSE;
2111    }
2112    return kTRUE;
2113 }
2114 ///________________________________________________________________________
2115 Bool_t AliConversionCuts::SetMinMomPiondEdxCut(Int_t piMomdedxSigmaCut)
2116 {   // Set Cut
2117    switch(piMomdedxSigmaCut){
2118    case 0:  // 0.5 GeV
2119       fPIDMinPnSigmaAbovePionLine=0.5;
2120       break;
2121    case 1:  // 1. GeV
2122       fPIDMinPnSigmaAbovePionLine=1.;
2123       break;
2124    case 2:  // 1.5 GeV
2125       fPIDMinPnSigmaAbovePionLine=1.5;
2126       break;
2127    case 3:  // 20.0 GeV
2128       fPIDMinPnSigmaAbovePionLine=20.;
2129       break;
2130    case 4:  // 50.0 GeV
2131       fPIDMinPnSigmaAbovePionLine=50.;
2132       break;
2133    case 5:  // 0.3 GeV
2134       fPIDMinPnSigmaAbovePionLine=0.3;
2135       break;
2136    case 6:  // 0.25 GeV
2137       fPIDMinPnSigmaAbovePionLine=0.25;
2138       break;
2139    case 7:  // 0.4 GeV
2140       fPIDMinPnSigmaAbovePionLine=0.4;
2141       break;
2142    case 8:  // 0.2 GeV
2143       fPIDMinPnSigmaAbovePionLine=0.2;
2144       break;
2145    default:
2146       AliError(Form("piMomdedxSigmaCut not defined %d",piMomdedxSigmaCut));
2147       return kFALSE;
2148    }
2149    return kTRUE;
2150 }
2151 ///________________________________________________________________________
2152 Bool_t AliConversionCuts::SetMaxMomPiondEdxCut(Int_t piMaxMomdedxSigmaCut)
2153 {   // Set Cut
2154    switch(piMaxMomdedxSigmaCut){
2155    case 0:  // 100. GeV
2156       fPIDMaxPnSigmaAbovePionLine=100.;
2157       break;
2158    case 1:  // 5. GeV
2159       fPIDMaxPnSigmaAbovePionLine=5.;
2160       break;
2161    case 2:  // 4. GeV
2162       fPIDMaxPnSigmaAbovePionLine=4.;
2163       break;
2164    case 3:  // 3.5 GeV
2165       fPIDMaxPnSigmaAbovePionLine=3.5;
2166       break;
2167    case 4:  // 3. GeV
2168       fPIDMaxPnSigmaAbovePionLine=3.;
2169       break;
2170    case 5:  // 7. GeV
2171       fPIDMaxPnSigmaAbovePionLine=7.;
2172       break;
2173    default:
2174       AliError(Form("piMaxMomdedxSigmaCut not defined %d",piMaxMomdedxSigmaCut));
2175       return kFALSE;
2176    }
2177    return kTRUE;
2178 }
2179 ///________________________________________________________________________
2180 Bool_t AliConversionCuts::SetLowPRejectionCuts(Int_t LowPRejectionSigmaCut)
2181 {   // Set Cut
2182    switch(LowPRejectionSigmaCut){
2183    case 0:  //
2184       fPIDnSigmaAtLowPAroundKaonLine=0;
2185       fPIDnSigmaAtLowPAroundProtonLine=0;
2186       fPIDnSigmaAtLowPAroundPionLine=0;
2187       fDoKaonRejectionLowP = kFALSE;
2188       fDoProtonRejectionLowP = kFALSE;
2189       fDoPionRejectionLowP = kFALSE;
2190       fPIDMinPPionRejectionLowP = fPIDMinPnSigmaAbovePionLine;
2191       break;
2192    case 1:  //
2193       fPIDnSigmaAtLowPAroundKaonLine=0.5;
2194       fPIDnSigmaAtLowPAroundProtonLine=0.5;
2195       fPIDnSigmaAtLowPAroundPionLine=0.5;
2196       fDoKaonRejectionLowP = kTRUE;
2197       fDoProtonRejectionLowP = kTRUE;
2198       fDoPionRejectionLowP = kTRUE;
2199       fPIDMinPPionRejectionLowP = fPIDMinPnSigmaAbovePionLine;
2200       break;
2201    case 2:  //
2202       fPIDnSigmaAtLowPAroundKaonLine=1;
2203       fPIDnSigmaAtLowPAroundProtonLine=1;
2204       fPIDnSigmaAtLowPAroundPionLine=1;
2205       fDoKaonRejectionLowP = kTRUE;
2206       fDoProtonRejectionLowP = kTRUE;
2207       fDoPionRejectionLowP = kTRUE;
2208       fPIDMinPPionRejectionLowP = fPIDMinPnSigmaAbovePionLine;
2209       break;
2210    case 3:  //
2211       fPIDnSigmaAtLowPAroundKaonLine=2.;
2212       fPIDnSigmaAtLowPAroundProtonLine=2.;
2213       fPIDnSigmaAtLowPAroundPionLine=2.;
2214       fDoKaonRejectionLowP = kTRUE;
2215       fDoProtonRejectionLowP = kTRUE;
2216       fDoPionRejectionLowP = kTRUE;
2217       fPIDMinPPionRejectionLowP = fPIDMinPnSigmaAbovePionLine;
2218       break;
2219    case 4:  //
2220       fPIDnSigmaAtLowPAroundKaonLine=0.;
2221       fPIDnSigmaAtLowPAroundProtonLine=0.;
2222       fPIDnSigmaAtLowPAroundPionLine=1;
2223       fDoKaonRejectionLowP = kFALSE;
2224       fDoProtonRejectionLowP = kFALSE;
2225       fDoPionRejectionLowP = kTRUE;
2226       fPIDMinPPionRejectionLowP = fPIDMinPnSigmaAbovePionLine;
2227       break;
2228    case 5:  //
2229       fPIDnSigmaAtLowPAroundKaonLine=0.;
2230       fPIDnSigmaAtLowPAroundProtonLine=0.;
2231       fPIDnSigmaAtLowPAroundPionLine=1.5;
2232       fDoKaonRejectionLowP = kFALSE;
2233       fDoProtonRejectionLowP = kFALSE;
2234       fDoPionRejectionLowP = kTRUE;
2235       fPIDMinPPionRejectionLowP = fPIDMinPnSigmaAbovePionLine;
2236       break;
2237    case 6:  //
2238       fPIDnSigmaAtLowPAroundKaonLine=0.;
2239       fPIDnSigmaAtLowPAroundProtonLine=0.;
2240       fPIDnSigmaAtLowPAroundPionLine=2.;
2241       fDoKaonRejectionLowP = kFALSE;
2242       fDoProtonRejectionLowP = kFALSE;
2243       fDoPionRejectionLowP = kTRUE;
2244       fPIDMinPPionRejectionLowP = fPIDMinPnSigmaAbovePionLine;
2245       break;
2246    case 7:  //
2247       fPIDnSigmaAtLowPAroundKaonLine=0.;
2248       fPIDnSigmaAtLowPAroundProtonLine=0.;
2249       fPIDnSigmaAtLowPAroundPionLine=0.5;
2250       fDoKaonRejectionLowP = kFALSE;
2251       fDoProtonRejectionLowP = kFALSE;
2252       fDoPionRejectionLowP = kTRUE;
2253       fPIDMinPPionRejectionLowP = fPIDMinPnSigmaAbovePionLine;
2254       break;
2255    default:
2256       AliError(Form("LowPRejectionSigmaCut not defined %d",LowPRejectionSigmaCut));
2257       return kFALSE;
2258    }
2259    return kTRUE;
2260 }
2261 ///________________________________________________________________________
2262 Bool_t AliConversionCuts::SetTOFElectronPIDCut(Int_t TOFelectronPID){
2263    // Set Cut
2264    switch(TOFelectronPID){
2265    case 0: // no cut
2266       fUseTOFpid = kFALSE;
2267       fTofPIDnSigmaBelowElectronLine=-100;
2268       fTofPIDnSigmaAboveElectronLine=100;
2269       break;
2270    case 1: // -7,7
2271       fUseTOFpid = kTRUE;
2272       fTofPIDnSigmaBelowElectronLine=-7;
2273       fTofPIDnSigmaAboveElectronLine=7;
2274       break;
2275    case 2: // -5,5
2276       fUseTOFpid = kTRUE;
2277       fTofPIDnSigmaBelowElectronLine=-5;
2278       fTofPIDnSigmaAboveElectronLine=5;
2279       break;
2280    case 3: // -3,5
2281       fUseTOFpid = kTRUE;
2282       fTofPIDnSigmaBelowElectronLine=-3;
2283       fTofPIDnSigmaAboveElectronLine=5;
2284       break;
2285    case 4: // -2,3
2286       fUseTOFpid = kTRUE;
2287       fTofPIDnSigmaBelowElectronLine=-2;
2288       fTofPIDnSigmaAboveElectronLine=3;
2289       break;
2290    case 5: // -3,3
2291       fUseTOFpid = kTRUE;
2292       fTofPIDnSigmaBelowElectronLine=-3;
2293       fTofPIDnSigmaAboveElectronLine=3;
2294       break;
2295    default:
2296       AliError(Form("TOFElectronCut not defined %d",TOFelectronPID));
2297       return kFALSE;
2298    }
2299    return kTRUE;
2300 }
2301 ///________________________________________________________________________
2302 Bool_t AliConversionCuts::SetQtMaxCut(Int_t QtMaxCut)
2303 {   // Set Cut
2304    switch(QtMaxCut){
2305    case 0: //
2306       fQtMax=1.;
2307       fDoQtGammaSelection=kFALSE;
2308       fDoHighPtQtGammaSelection=kFALSE;
2309       fHighPtQtMax=100.;
2310       fPtBorderForQt=100.;
2311       break;
2312    case 1:
2313       fQtMax=0.1;
2314       fDoHighPtQtGammaSelection=kFALSE;
2315       fHighPtQtMax=100.;
2316       fPtBorderForQt=100.;
2317       break;
2318    case 2:
2319       fQtMax=0.07;
2320       fDoHighPtQtGammaSelection=kFALSE;
2321       fHighPtQtMax=100.;
2322       fPtBorderForQt=100.;
2323       break;
2324    case 3:
2325       fQtMax=0.05;
2326       fDoHighPtQtGammaSelection=kFALSE;
2327       fHighPtQtMax=100.;
2328       fPtBorderForQt=100.;
2329       break;
2330    case 4:
2331       fQtMax=0.03;
2332       fDoHighPtQtGammaSelection=kFALSE;
2333       fHighPtQtMax=100.;
2334       fPtBorderForQt=100.;
2335       break;
2336    case 5:
2337       fQtMax=0.02;
2338       fDoHighPtQtGammaSelection=kFALSE;
2339       fHighPtQtMax=100.;
2340       fPtBorderForQt=100.;
2341       break;
2342    case 6:
2343       fQtMax=0.02;
2344       fDoHighPtQtGammaSelection=kTRUE;
2345       fHighPtQtMax=0.06;
2346       fPtBorderForQt=2.5;
2347       break;
2348    case 7:
2349       fQtMax=0.15;
2350       fDoHighPtQtGammaSelection=kFALSE;
2351       fHighPtQtMax=100.;
2352       fPtBorderForQt=100.;
2353       break;
2354    default:
2355       AliError(Form("Warning: QtMaxCut not defined %d",QtMaxCut));
2356       return kFALSE;
2357    }
2358    return kTRUE;
2359 }
2360 ///________________________________________________________________________
2361 Bool_t AliConversionCuts::SetChi2GammaCut(Int_t chi2GammaCut)
2362 {   // Set Cut
2363
2364    switch(chi2GammaCut){
2365    case 0: // 100
2366       fChi2CutConversion = 100.;
2367       break;
2368    case 1:  // 50
2369       fChi2CutConversion = 50.;
2370       break;
2371    case 2:  // 30
2372       fChi2CutConversion = 30.;
2373       break;
2374    case 3:
2375       fChi2CutConversion = 200.;
2376       break;
2377    case 4:
2378       fChi2CutConversion = 500.;
2379       break;
2380    case 5:
2381       fChi2CutConversion = 100000.;
2382       break;
2383    case 6:
2384       fChi2CutConversion = 5.;
2385       break;
2386    case 7:
2387       fChi2CutConversion = 10.;
2388       break;
2389    case 8:
2390       fChi2CutConversion = 20.;
2391       break;
2392    case 9:
2393       fChi2CutConversion = 15.;
2394       break;
2395    default:
2396       AliError(Form("Warning: Chi2GammaCut not defined %d",chi2GammaCut));
2397       return kFALSE;
2398    }
2399    return kTRUE;
2400 }
2401 ///________________________________________________________________________
2402 Bool_t AliConversionCuts::SetPsiPairCut(Int_t psiCut) {
2403
2404    switch(psiCut) {
2405    case 0:
2406       fPsiPairCut = 10000; //
2407       break;
2408    case 1:
2409       fPsiPairCut = 0.1; //
2410       break;
2411    case 2:
2412       fPsiPairCut = 0.05; // Standard
2413       break;
2414    case 3:
2415       fPsiPairCut = 0.035; //
2416       break;
2417    case 4:
2418       fPsiPairCut = 0.15; //
2419       break;
2420    case 5:
2421       fPsiPairCut = 0.2; //
2422       break;
2423    case 6:
2424       fPsiPairCut = 0.03; //
2425       break;
2426    case 7:
2427       fPsiPairCut = 0.025; //
2428       break;
2429    case 8:
2430       fPsiPairCut = 0.01; //
2431       break;
2432    case 9:
2433       fPsiPairCut = 0.5; //
2434       break;
2435    default:
2436       AliError(Form("PsiPairCut not defined %d",psiCut));
2437       return kFALSE;
2438    }
2439
2440    return kTRUE;
2441 }
2442 ///________________________________________________________________________
2443 Bool_t AliConversionCuts::SetPhotonAsymmetryCut(Int_t doPhotonAsymmetryCut){
2444    // Set Cut
2445    switch(doPhotonAsymmetryCut){
2446    case 0:
2447       fDoPhotonAsymmetryCut=0;
2448       fMinPPhotonAsymmetryCut=100.;
2449       fMinPhotonAsymmetry=0.;
2450       break;
2451    case 1:
2452       fDoPhotonAsymmetryCut=1;
2453       fMinPPhotonAsymmetryCut=3.5;
2454       fMinPhotonAsymmetry=0.04;
2455       break;
2456    case 2:
2457       fDoPhotonAsymmetryCut=1;
2458       fMinPPhotonAsymmetryCut=3.5;
2459       fMinPhotonAsymmetry=0.06;
2460       break;
2461    default:
2462       AliError(Form("PhotonAsymmetryCut not defined %d",doPhotonAsymmetryCut));
2463       return kFALSE;
2464    }
2465    fCuts[kdoPhotonAsymmetryCut]=doPhotonAsymmetryCut;
2466    return kTRUE;
2467 }
2468 ///________________________________________________________________________
2469 Bool_t AliConversionCuts::SetCosPAngleCut(Int_t cosCut) {
2470
2471    switch(cosCut){
2472    case 0:
2473       fCosPAngleCut = TMath::Pi(); // -1
2474       break;
2475    case 1:
2476       fCosPAngleCut = 0.1; // 0.99500
2477       break;
2478    case 2:
2479       fCosPAngleCut = 0.05; // 0.99875
2480       break;
2481    case 3:
2482       fCosPAngleCut = 0.025; // 0.99969
2483       break;
2484    case 4:
2485       fCosPAngleCut = 0.01; // 0.99995
2486       break;
2487    case 5:
2488       fCosPAngleCut = 0.2; // 0.98007
2489       break;
2490    case 6:
2491       fCosPAngleCut = 0.5; // 0.87758
2492       break;
2493    case 7:
2494       fCosPAngleCut = 0.075; // 0.73169
2495       break;
2496    default:
2497       AliError(Form("Cosine Pointing Angle cut not defined %d",cosCut));
2498       return kFALSE;
2499    }
2500
2501    return kTRUE;
2502 }
2503 ///________________________________________________________________________
2504 Bool_t AliConversionCuts::SetSharedElectronCut(Int_t sharedElec) {
2505
2506    switch(sharedElec){
2507    case 0:
2508       fDoSharedElecCut = kFALSE;
2509       break;
2510    case 1:
2511       fDoSharedElecCut = kTRUE;
2512       break;
2513    default:
2514       AliError(Form("Shared Electron Cut not defined %d",sharedElec));
2515       return kFALSE;
2516    }
2517
2518    return kTRUE;
2519 }
2520 ///________________________________________________________________________
2521 Bool_t AliConversionCuts::SetToCloseV0sCut(Int_t toClose) {
2522
2523    switch(toClose){
2524    case 0:
2525       fDoToCloseV0sCut = kFALSE;
2526       fminV0Dist = 250;
2527       break;
2528    case 1:
2529       fDoToCloseV0sCut = kTRUE;
2530       fminV0Dist = 1;
2531       break;
2532    case 2:
2533       fDoToCloseV0sCut = kTRUE;
2534       fminV0Dist = 2;
2535       break;
2536    case 3:
2537       fDoToCloseV0sCut = kTRUE;
2538       fminV0Dist = 3;
2539       break;
2540    default:
2541       AliError(Form("Shared Electron Cut not defined %d",toClose));
2542       return kFALSE;
2543    }
2544    return kTRUE;
2545 }
2546 ///________________________________________________________________________
2547 Bool_t AliConversionCuts::SetTRDElectronCut(Int_t TRDElectronCut)
2548 {   // Set Cut
2549    switch(TRDElectronCut){
2550    case 0:
2551       fDoTRDPID=kFALSE;
2552       break;
2553    case 1:
2554       fDoTRDPID=kTRUE;
2555       fPIDTRDEfficiency=0.1;
2556       break;
2557    case 8:
2558       fDoTRDPID=kTRUE;
2559       fPIDTRDEfficiency=0.8;
2560       break;
2561    case 9:
2562       fDoTRDPID=kTRUE;
2563       fPIDTRDEfficiency=0.9;
2564       break;
2565    default:
2566       AliError(Form("TRDElectronCut not defined %d",TRDElectronCut));
2567       return kFALSE;
2568    }
2569
2570    return kTRUE;
2571 }
2572 //-------------------------------------------------------------
2573 Double_t AliConversionCuts::GetCentrality(AliVEvent *event)
2574 {   // Get Event Centrality
2575
2576    AliESDEvent *esdEvent=dynamic_cast<AliESDEvent*>(event);
2577    if(esdEvent){
2578       AliCentrality *fESDCentrality=(AliCentrality*)esdEvent->GetCentrality();
2579
2580       if(fDetectorCentrality==0){
2581          return fESDCentrality->GetCentralityPercentile("V0M"); // default
2582       }
2583       if(fDetectorCentrality==1){
2584          return fESDCentrality->GetCentralityPercentile("CL1");
2585       }
2586    }
2587
2588    AliAODEvent *aodEvent=dynamic_cast<AliAODEvent*>(event);
2589    if(aodEvent){
2590       if(aodEvent->GetHeader()){return aodEvent->GetHeader()->GetCentrality();}
2591    }
2592
2593    return -1;
2594 }
2595 //-------------------------------------------------------------
2596 Bool_t AliConversionCuts::IsCentralitySelected(AliVEvent *event, AliVEvent *fMCEvent)
2597 {   // Centrality Selection
2598    if(!fIsHeavyIon)return kTRUE;
2599
2600    if(fCentralityMin == 0 && fCentralityMax == 0) return kTRUE;//0-100%
2601    if(fCentralityMin >= fCentralityMax) return kTRUE;//0-100%
2602
2603    Double_t centrality=GetCentrality(event);
2604    if(centrality<0)return kFALSE;
2605
2606    Int_t centralityC=0;
2607    if (fModCentralityClass == 0){
2608       centralityC= Int_t(centrality/10);
2609       if(centralityC >= fCentralityMin && centralityC < fCentralityMax)
2610          return kTRUE;
2611       else return kFALSE;
2612    }
2613    else if (fModCentralityClass ==1){
2614       centralityC= Int_t(centrality);
2615       if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2616          return kTRUE;
2617       } else return kFALSE;
2618    }
2619    else if (fModCentralityClass ==2){
2620       centralityC= Int_t(centrality);
2621       if(centralityC >= ((fCentralityMin*5)+45) && centralityC < ((fCentralityMax*5)+45))
2622          return kTRUE;
2623       else return kFALSE;
2624    }
2625
2626    // Use strict V0 amplitude cut for MC centrality
2627    Float_t nv0amplitude = event->GetVZEROData()->GetMTotV0A()+event->GetVZEROData()->GetMTotV0C();
2628    Float_t V0Amplitude10[10] = {9999999.0,13670,9345,6209,3944,2352,1272,611,255, 83};
2629    //                                    0    10   20   30   40   50   60  70  80  90%
2630    Float_t V0Amplitude5a[10] = {9999999.0,16612,13670,11290,9345,7650,6209,4984,3944,3074};
2631    //                                    0     5    10    15   20   25   30   35   40   45%
2632    Float_t V0Amplitude5b[10] = {3074,2352,1725,1272,899,611,402,255,152,83};
2633    //                             45   50   55   60  65  70  75  80  85 90%
2634
2635    if (fModCentralityClass == 3){
2636       if(fMCEvent){
2637          if(nv0amplitude > V0Amplitude10[fCentralityMax] && nv0amplitude <= V0Amplitude10[fCentralityMin])
2638             return kTRUE;
2639          else return kFALSE;
2640       }
2641       else{
2642          centralityC= Int_t(centrality/10);
2643          if(centralityC >= fCentralityMin && centralityC < fCentralityMax)
2644             return kTRUE;
2645          else return kFALSE;
2646       }
2647    }
2648    else if (fModCentralityClass ==4){
2649       if(fMCEvent){
2650          if(nv0amplitude > V0Amplitude5a[fCentralityMax] && nv0amplitude <= V0Amplitude5a[fCentralityMin])
2651             return kTRUE;
2652          else return kFALSE;
2653       }
2654       else{
2655          centralityC= Int_t(centrality);
2656          if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2657             return kTRUE;
2658          } else return kFALSE;
2659       }
2660    }
2661    else if (fModCentralityClass ==5){
2662       if(fMCEvent){
2663          if(nv0amplitude > V0Amplitude5b[fCentralityMax] && nv0amplitude <= V0Amplitude5b[fCentralityMin])
2664             return kTRUE;
2665          else return kFALSE;
2666       }
2667       else{
2668          centralityC= Int_t(centrality);
2669          if(centralityC >= ((fCentralityMin*5)+45) && centralityC < ((fCentralityMax*5)+45))
2670             return kTRUE;
2671          else return kFALSE;
2672       }
2673    }
2674
2675    return kFALSE;
2676 }
2677 ///________________________________________________________________________
2678 Bool_t AliConversionCuts::VertexZCut(AliVEvent *event){
2679    // Cut on z position of primary vertex
2680    Double_t fVertexZ=event->GetPrimaryVertex()->GetZ();
2681
2682    if(abs(fVertexZ)>fMaxVertexZ)return kFALSE;
2683    return kTRUE;
2684 }
2685 ///________________________________________________________________________
2686
2687 Int_t AliConversionCuts::GetNumberOfContributorsVtx(AliVEvent *event){
2688    // returns number of contributors to the vertex
2689
2690    AliESDEvent *fESDEvent=dynamic_cast<AliESDEvent*>(event);
2691    if(fESDEvent){
2692       if (fESDEvent->GetPrimaryVertex() != NULL){
2693          if(fESDEvent->GetPrimaryVertex()->GetNContributors()>0) {
2694             return fESDEvent->GetPrimaryVertex()->GetNContributors();
2695          }
2696       }
2697
2698       if(fESDEvent->GetPrimaryVertexSPD() !=NULL){
2699          if(fESDEvent->GetPrimaryVertexSPD()->GetNContributors()>0) {
2700             return fESDEvent->GetPrimaryVertexSPD()->GetNContributors();
2701          }  else {
2702             AliWarning(Form("Number of contributors from bad vertex type:: %s",fESDEvent->GetPrimaryVertex()->GetName()));
2703             return 0;
2704          }
2705       }
2706    }
2707
2708    AliAODEvent *fAODEvent=dynamic_cast<AliAODEvent*>(event);
2709    if(fAODEvent){
2710       if (fAODEvent->GetPrimaryVertex() != NULL){
2711          if(fAODEvent->GetPrimaryVertex()->GetNContributors()>0) {
2712             return fAODEvent->GetPrimaryVertex()->GetNContributors();
2713          }
2714       }
2715       if(fAODEvent->GetPrimaryVertexSPD() !=NULL){
2716          if(fAODEvent->GetPrimaryVertexSPD()->GetNContributors()>0) {
2717             return fAODEvent->GetPrimaryVertexSPD()->GetNContributors();
2718          } else {
2719             AliWarning(Form("Number of contributors from bad vertex type:: %s",fAODEvent->GetPrimaryVertex()->GetName()));
2720             return 0;
2721          }
2722       }
2723    }
2724
2725    return 0;
2726 }
2727
2728 ///________________________________________________________________________
2729
2730 Bool_t AliConversionCuts::IsTriggerSelected()
2731 {
2732
2733    AliInputEventHandler *fInputHandler=(AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
2734
2735    UInt_t isSelected = AliVEvent::kAny;
2736    if( fInputHandler && fInputHandler->GetEventSelection()) {
2737       // Get the actual offline trigger mask for the event and AND it with the
2738       // requested mask. If no mask requested select by default the event.
2739       if (fOfflineTriggerMask)
2740          isSelected = fOfflineTriggerMask & fInputHandler->IsEventSelected();
2741    }
2742    fIsSDDFired = !(fInputHandler->IsEventSelected() & AliVEvent::kFastOnly);
2743
2744    // Fill Histogram
2745    if(hTriggerClass){
2746       if (fIsSDDFired) hTriggerClass->Fill(32);
2747       if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClass->Fill(0);
2748       if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClass->Fill(1);
2749       if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClass->Fill(2);
2750       if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClass->Fill(3);
2751       if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClass->Fill(4);
2752       if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClass->Fill(5);
2753       if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClass->Fill(6);
2754       if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClass->Fill(6);
2755       if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClass->Fill(7);
2756       if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClass->Fill(7);
2757       if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClass->Fill(8);
2758       if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClass->Fill(8);
2759       if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClass->Fill(9);
2760       if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClass->Fill(9);
2761       if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClass->Fill(10);
2762       if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClass->Fill(10);
2763       if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClass->Fill(11);
2764       if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClass->Fill(12);
2765       if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClass->Fill(13);
2766       if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClass->Fill(13);
2767       if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClass->Fill(13);
2768       if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClass->Fill(14);
2769       if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClass->Fill(15);
2770       if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClass->Fill(16);
2771       if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClass->Fill(17);
2772       if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClass->Fill(18);
2773       if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClass->Fill(19);
2774       if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClass->Fill(20);
2775       if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClass->Fill(20);
2776       if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClass->Fill(21);
2777       if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClass->Fill(22);
2778       if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClass->Fill(23);
2779       if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClass->Fill(24);
2780       if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClass->Fill(25);
2781       if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClass->Fill(26);
2782       if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClass->Fill(27);
2783       if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClass->Fill(28);
2784       if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClass->Fill(29);
2785       if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClass->Fill(30);
2786       if (!fInputHandler->IsEventSelected()) hTriggerClass->Fill(33);
2787    }
2788
2789    if(hTriggerClassSelected && isSelected){
2790       if (!fIsSDDFired) hTriggerClassSelected->Fill(32);
2791       if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClassSelected->Fill(0);
2792       if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClassSelected->Fill(1);
2793       if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClassSelected->Fill(2);
2794       if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClassSelected->Fill(3);
2795       if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClassSelected->Fill(4);
2796       if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClassSelected->Fill(5);
2797       if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClassSelected->Fill(6);
2798       if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClassSelected->Fill(6);
2799       if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClassSelected->Fill(7);
2800       if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClassSelected->Fill(7);
2801       if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClassSelected->Fill(8);
2802       if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClassSelected->Fill(8);
2803       if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClassSelected->Fill(9);
2804       if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClassSelected->Fill(9);
2805       if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClassSelected->Fill(10);
2806       if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClassSelected->Fill(10);
2807       if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClassSelected->Fill(11);
2808       if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClassSelected->Fill(12);
2809       if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClassSelected->Fill(13);
2810       if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClassSelected->Fill(13);
2811       if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClassSelected->Fill(13);
2812       if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClassSelected->Fill(14);
2813       if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClassSelected->Fill(15);
2814       if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClassSelected->Fill(16);
2815       if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClassSelected->Fill(17);
2816       if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClassSelected->Fill(18);
2817       if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClassSelected->Fill(19);
2818       if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClassSelected->Fill(20);
2819       if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClassSelected->Fill(20);
2820       if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClassSelected->Fill(21);
2821       if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClassSelected->Fill(22);
2822       if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClassSelected->Fill(23);
2823       if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClassSelected->Fill(24);
2824       if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClassSelected->Fill(25);
2825       if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClassSelected->Fill(26);
2826       if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClassSelected->Fill(27);
2827       if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClassSelected->Fill(28);
2828       if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClassSelected->Fill(29);
2829       if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClassSelected->Fill(30);
2830    }
2831
2832    if(!isSelected)return kFALSE;
2833
2834    return kTRUE;
2835
2836 }
2837
2838 ///________________________________________________________________________
2839 Int_t AliConversionCuts::GetFirstTPCRow(Double_t radius){
2840    // Get first TPC row
2841    Int_t firstTPCRow = 0;
2842    Double_t radiusI = 84.8;
2843    Double_t radiusO = 134.6;
2844    Double_t radiusOB = 198.;
2845    Double_t rSizeI = 0.75;
2846    Double_t rSizeO = 1.;
2847    Double_t rSizeOB = 1.5;
2848    Int_t nClsI = 63;
2849    Int_t nClsIO = 127;
2850
2851    if(radius <= radiusI){
2852       return firstTPCRow;
2853    }
2854    if(radius>radiusI && radius<=radiusO){
2855       firstTPCRow = (Int_t)((radius-radiusI)/rSizeI);
2856    }
2857    if(radius>radiusO && radius<=radiusOB){
2858       firstTPCRow = (Int_t)(nClsI+(radius-radiusO)/rSizeO);
2859    }
2860
2861    if(radius>radiusOB){
2862       firstTPCRow =(Int_t)(nClsIO+(radius-radiusOB)/rSizeOB);
2863    }
2864
2865    return firstTPCRow;
2866 }
2867
2868 Bool_t AliConversionCuts::CosinePAngleCut(const AliConversionPhotonBase * photon, AliVEvent * event) const {
2869    ///Check if passes cosine of pointing angle cut
2870    if(GetCosineOfPointingAngle(photon, event) < (TMath::Cos(fCosPAngleCut))){
2871       return kFALSE;
2872    }
2873    return kTRUE;
2874 }
2875
2876 Double_t AliConversionCuts::GetCosineOfPointingAngle( const AliConversionPhotonBase * photon, AliVEvent * event) const{
2877    // calculates the pointing angle of the recalculated V0
2878
2879    Double_t momV0[3] = {0,0,0};
2880    if(event->IsA()==AliESDEvent::Class()){
2881       AliESDEvent *esdEvent = dynamic_cast<AliESDEvent*>(event);
2882       if(!esdEvent) return -999;
2883       AliESDv0 *v0 = esdEvent->GetV0(photon->GetV0Index());
2884       if(!v0) return -999;
2885       v0->GetPxPyPz(momV0[0],momV0[1],momV0[2]);
2886    }
2887    if(event->IsA()==AliAODEvent::Class()){
2888       momV0[0] = photon->GetPx();
2889       momV0[1] = photon->GetPy();
2890       momV0[2] = photon->GetPz();
2891    }
2892
2893    //Double_t momV0[3] = { photon->GetPx(), photon->GetPy(), photon->GetPz() }; //momentum of the V0
2894    Double_t PosV0[3] = { photon->GetConversionX() - event->GetPrimaryVertex()->GetX(),
2895                          photon->GetConversionY() - event->GetPrimaryVertex()->GetY(),
2896                          photon->GetConversionZ() - event->GetPrimaryVertex()->GetZ() }; //Recalculated V0 Position vector
2897
2898    Double_t momV02 = momV0[0]*momV0[0] + momV0[1]*momV0[1] + momV0[2]*momV0[2];
2899    Double_t PosV02 = PosV0[0]*PosV0[0] + PosV0[1]*PosV0[1] + PosV0[2]*PosV0[2];
2900
2901
2902    Double_t cosinePointingAngle = -999;
2903    if(momV02*PosV02 > 0.0)
2904       cosinePointingAngle = (PosV0[0]*momV0[0] +  PosV0[1]*momV0[1] + PosV0[2]*momV0[2] ) / TMath::Sqrt(momV02 * PosV02);
2905
2906    return cosinePointingAngle;
2907 }
2908
2909 ///________________________________________________________________________
2910 Bool_t AliConversionCuts::PsiPairCut(const AliConversionPhotonBase * photon) const {
2911
2912    if(photon->GetPsiPair() > fPsiPairCut){
2913       return kFALSE;}
2914    else{return kTRUE;}
2915
2916 }
2917
2918 ///________________________________________________________________________
2919 TString AliConversionCuts::GetCutNumber(){
2920    // returns TString with current cut number
2921    TString a(kNCuts);
2922    for(Int_t ii=0;ii<kNCuts;ii++){
2923       a.Append(Form("%d",fCuts[ii]));
2924    }
2925    return a;
2926 }
2927
2928 ///________________________________________________________________________
2929 void AliConversionCuts::FillElectonLabelArray(AliAODConversionPhoton* photon, Int_t nV0){
2930
2931    Int_t posLabel = photon->GetTrackLabelPositive();
2932    Int_t negLabel = photon->GetTrackLabelNegative();
2933
2934    fElectronLabelArray[nV0*2] = posLabel;
2935    fElectronLabelArray[(nV0*2)+1] = negLabel;
2936 }
2937 ///________________________________________________________________________
2938 Bool_t AliConversionCuts::RejectSharedElectronV0s(AliAODConversionPhoton* photon, Int_t nV0, Int_t nV0s){
2939
2940    Int_t posLabel = photon->GetTrackLabelPositive();
2941    Int_t negLabel = photon->GetTrackLabelNegative();
2942
2943    for(Int_t i = 0; i<nV0s*2;i++){
2944       if(i==nV0*2)     continue;
2945       if(i==(nV0*2)+1) continue;
2946       if(fElectronLabelArray[i] == posLabel){
2947          return kFALSE;}
2948       if(fElectronLabelArray[i] == negLabel){
2949          return kFALSE;}
2950    }
2951
2952    return kTRUE;
2953 }
2954 ///________________________________________________________________________
2955 Bool_t AliConversionCuts::RejectToCloseV0s(AliAODConversionPhoton* photon, TList *photons, Int_t nV0){
2956
2957
2958    Double_t posX = photon->GetConversionX();
2959    Double_t posY = photon->GetConversionY();
2960    Double_t posZ = photon->GetConversionZ();
2961
2962    for(Int_t i = 0;i<photons->GetEntries();i++){
2963       if(nV0 == i) continue;
2964       AliAODConversionPhoton *photonComp = (AliAODConversionPhoton*) photons->At(i);
2965       Double_t posCompX = photonComp->GetConversionX();
2966       Double_t posCompY = photonComp->GetConversionY();
2967       Double_t posCompZ = photonComp->GetConversionZ();
2968
2969       Double_t dist = pow((posX - posCompX),2)+pow((posY - posCompY),2)+pow((posZ - posCompZ),2);
2970
2971       if(dist < fminV0Dist*fminV0Dist){
2972          if(photon->GetChi2perNDF() < photonComp->GetChi2perNDF()) return kTRUE;
2973          else {
2974             return kFALSE;}
2975       }
2976
2977    }
2978    return kTRUE;
2979 }
2980 ///________________________________________________________________________
2981 void AliConversionCuts::GetNotRejectedParticles(Int_t rejection, TList *HeaderList, AliMCEvent *MCEvent){
2982
2983    if(fNotRejectedStart){
2984       delete[] fNotRejectedStart;
2985       fNotRejectedStart = NULL;
2986    }
2987    if(fNotRejectedEnd){
2988       delete[] fNotRejectedEnd;
2989       fNotRejectedEnd = NULL;
2990    }
2991    if(fGeneratorNames){
2992       delete[] fGeneratorNames;
2993       fGeneratorNames = NULL;
2994    }
2995
2996    if(rejection == 0) return; // No Rejection
2997    AliGenCocktailEventHeader *cHeader = dynamic_cast<AliGenCocktailEventHeader*>(MCEvent->GenEventHeader());
2998    if(cHeader){
2999       TList *genHeaders = cHeader->GetHeaders();
3000       AliGenEventHeader* gh = 0;
3001       fnHeaders = 0;
3002       if(rejection == 1 || rejection == 3) fnHeaders = 1; // MinBiasHeader
3003       if(rejection == 2){ // TList of Headers Names
3004          for(Int_t i = 0; i<genHeaders->GetEntries();i++){
3005             gh = (AliGenEventHeader*)genHeaders->At(i);
3006             TString GeneratorName = gh->GetName();
3007             for(Int_t j = 0; j<HeaderList->GetEntries();j++){
3008                TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
3009                if(GeneratorName.CompareTo(GeneratorInList) == 0){
3010                   fnHeaders++;
3011                   continue;
3012                }
3013             }
3014          }
3015       }
3016
3017       fNotRejectedStart = new Int_t[fnHeaders];
3018       fNotRejectedEnd = new Int_t[fnHeaders];
3019       fGeneratorNames = new TString[fnHeaders];
3020
3021       if(rejection == 1 || rejection == 3){
3022          fNotRejectedStart[0] = 0;
3023          fNotRejectedEnd[0] = ((AliGenEventHeader*)genHeaders->At(0))->NProduced()-1;
3024          fGeneratorNames[0] = ((AliGenEventHeader*)genHeaders->At(0))->GetName();
3025          return;
3026       }
3027
3028       Int_t firstindex = 0;
3029       Int_t lastindex =  -1;
3030       Int_t nummer = 0;
3031       for(Int_t i = 0; i<genHeaders->GetEntries();i++){
3032          gh = (AliGenEventHeader*)genHeaders->At(i);
3033          TString GeneratorName = gh->GetName();
3034          lastindex = lastindex + gh->NProduced();
3035          for(Int_t j = 0; j<HeaderList->GetEntries();j++){
3036             TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
3037             if(GeneratorName.CompareTo(GeneratorInList) == 0){
3038                fNotRejectedStart[nummer] = firstindex;
3039                fNotRejectedEnd[nummer] = lastindex;
3040                fGeneratorNames[nummer] = GeneratorName;
3041 //                cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
3042                nummer++;
3043                continue;
3044             }
3045          }
3046          firstindex = firstindex + gh->NProduced();
3047       }
3048    } else { // No Cocktail Header Found
3049       fNotRejectedStart = new Int_t[1];
3050       fNotRejectedEnd = new Int_t[1];
3051
3052       fnHeaders = 1;
3053       fNotRejectedStart[0] = 0;
3054       fNotRejectedEnd[0] = MCEvent->Stack()->GetNprimary()-1;
3055 //       if(rejection == 2){
3056       fGeneratorNames = new TString[1];
3057       fGeneratorNames[0] = "NoCocktailGeneratorFound";
3058 //       }
3059             
3060       AliGenPythiaEventHeader *mcHeaderPythia = dynamic_cast<AliGenPythiaEventHeader*>(MCEvent->GenEventHeader());      
3061       if (mcHeaderPythia) fGeneratorNames[0] = "NoCocktailGeneratorFound_Pythia";
3062       AliGenDPMjetEventHeader *mcHeaderPhojet = dynamic_cast<AliGenDPMjetEventHeader*>(MCEvent->GenEventHeader());      
3063       if (mcHeaderPhojet) fGeneratorNames[0] = "NoCocktailGeneratorFound_Phojet";
3064       AliGenHijingEventHeader *mcHeaderHijing = dynamic_cast<AliGenHijingEventHeader*>(MCEvent->GenEventHeader());      
3065       if (mcHeaderHijing) fGeneratorNames[0] = "NoCocktailGeneratorFound_Hijing";
3066
3067       SetRejectExtraSignalsCut(0);
3068    }
3069
3070 }
3071 //_________________________________________________________________________
3072 Int_t AliConversionCuts::IsParticleFromBGEvent(Int_t index, AliStack *MCStack){
3073
3074    // Not Accepted == kFALSE == 0
3075    //     Accepted ==  kTRUE == 1
3076    //  FirstHeader ==  kTRUE == 3
3077
3078    if(index < 0) return 0; // No Particle
3079
3080    Int_t accepted = 0;
3081    if( index >= MCStack->GetNprimary()){ // Secondary Particle
3082       if( ((TParticle*)MCStack->Particle(index))->GetMother(0) < 0) return 1; // Secondary Particle without Mother??
3083       return IsParticleFromBGEvent(((TParticle*)MCStack->Particle(index))->GetMother(0),MCStack);
3084    }
3085    for(Int_t i = 0;i<fnHeaders;i++){
3086       if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
3087          accepted = 1;
3088          if(i == 0) accepted = 2; // MB Header
3089       }
3090    }
3091
3092    return accepted;
3093 }
3094 //_________________________________________________________________________
3095 Int_t AliConversionCuts::IsEventAcceptedByConversionCut(AliConversionCuts *ReaderCuts, AliVEvent *InputEvent, AliMCEvent *MCEvent, Bool_t isHeavyIon){
3096
3097    if(isHeavyIon && !(IsCentralitySelected(InputEvent,MCEvent)))
3098       return 1; // Check Centrality --> Not Accepted => eventQuality = 1
3099
3100    if(!isHeavyIon && GetIsFromPileup()){
3101       if(InputEvent->IsPileupFromSPD(3,0.8,3.,2.,5.)){
3102          return 6; // Check Pileup --> Not Accepted => eventQuality = 6
3103       }
3104    }
3105
3106    Bool_t hasV0And = ReaderCuts->HasV0AND();
3107    Bool_t isSDDFired = ReaderCuts->IsSDDFired();
3108    if( (IsSpecialTrigger() == 2 || IsSpecialTrigger() == 3) && !isSDDFired && !MCEvent)
3109       return 7; // With SDD requested but no fired
3110
3111    if( (IsSpecialTrigger() == 1 || IsSpecialTrigger() == 3) && !hasV0And)
3112       return 8; // V0AND requested but no fired
3113
3114
3115    return 0;
3116 }
3117
3118 Float_t AliConversionCuts::GetWeightForMeson(TString period, Int_t index, AliStack *MCStack){
3119    if (!(period.CompareTo("LHC12f1a") == 0 || period.CompareTo("LHC12f1b") == 0  || period.CompareTo("LHC12i3") == 0 )) return 1.;
3120    
3121    Int_t kCaseGen = 0;
3122    for (Int_t i = 0; i < fnHeaders; i++){
3123       if (index >= fNotRejectedStart[i] && index < fNotRejectedEnd[i]+1){
3124 //          cout << fGeneratorNames[i].Data() << endl;
3125          if (fGeneratorNames[i].CompareTo("Pythia") == 0){
3126             kCaseGen = 1;
3127          } else if (fGeneratorNames[i].CompareTo("DPMJET") == 0){
3128             kCaseGen = 2;
3129          } else if (fGeneratorNames[i].CompareTo("HIJING") == 0){
3130             kCaseGen = 3;
3131          } else if (fGeneratorNames[i].CompareTo("BOX") == 0){
3132             kCaseGen = 4;
3133          } else if (fGeneratorNames[i].CompareTo("PARAM") == 0){
3134             kCaseGen = 5;
3135          } else if (fGeneratorNames[i].CompareTo("NoCocktailGeneratorFound") == 0){
3136             kCaseGen = 6;
3137          } else if (fGeneratorNames[i].CompareTo("NoCocktailGeneratorFound_Pythia") == 0){
3138             kCaseGen = 1;
3139          } else if (fGeneratorNames[i].CompareTo("NoCocktailGeneratorFound_Phojet") == 0){
3140             kCaseGen = 2;
3141          } else if (fGeneratorNames[i].CompareTo("NoCocktailGeneratorFound_Hijing") == 0){
3142             kCaseGen = 3;
3143          } 
3144 //          cout << "resulting kCaseGen :" << kCaseGen << endl;
3145       }
3146    }
3147    
3148    Double_t mesonPt = ((TParticle*)MCStack->Particle(index))->Pt();
3149    
3150 //   Double_t mesonY = 10.;
3151 //   if(((TParticle*)MCStack->Particle(index))->Energy() - ((TParticle*)MCStack->Particle(index))->Pz() == 0 || ((TParticle*)MCStack->Particle(index))->Energy() + ((TParticle*)MCStack->Particle(index))->Pz() == 0){
3152 //      mesonY=10.;
3153 //   } else{
3154 //      mesonY = 0.5*(TMath::Log((((TParticle*)MCStack->Particle(index))->Energy()+((TParticle*)MCStack->Particle(index))->Pz()) / (((TParticle*)MCStack->Particle(index))->Energy()-((TParticle*)MCStack->Particle(index))->Pz())));
3155 //   }
3156    Double_t mesonMass = ((TParticle*)MCStack->Particle(index))->GetCalcMass();
3157    Float_t functionResult = 1.;
3158    if (kCaseGen == 1){
3159       Float_t dNdyMC = 2.1462;
3160       Float_t nMC = 7.06055;
3161       Float_t tMC = 0.12533;
3162       if ( ((TParticle*)MCStack->Particle(index))->GetPdgCode() ==  111){
3163          dNdyMC = 2.1462;
3164          nMC = 7.06055;
3165          tMC = 0.12533;
3166       } else if ( ((TParticle*)MCStack->Particle(index))->GetPdgCode() ==  221){
3167          dNdyMC = 0.2357;
3168          nMC = 5.9105;
3169          tMC = 0.1525;
3170       }
3171       functionResult = dNdyMC / ( 2 * TMath::Pi())*(nMC-1.)*(nMC-2.) / (nMC*tMC*(nMC*tMC+mesonMass*(nMC-2.)))  * pow(1.+(sqrt(mesonPt*mesonPt+mesonMass*mesonMass)-mesonMass)/(nMC*tMC), -nMC);
3172    } else if (kCaseGen == 2){
3173       Float_t dNdyMC = 2.35978;
3174       Float_t nMC = 6.81795;
3175       Float_t tMC = 0.11492;
3176       if ( ((TParticle*)MCStack->Particle(index))->GetPdgCode() ==  111){
3177          dNdyMC = 2.35978;
3178          nMC = 6.81795;
3179          tMC = 0.11492;
3180       } else if ( ((TParticle*)MCStack->Particle(index))->GetPdgCode() ==  221){
3181          dNdyMC = 0.3690;
3182          nMC = 5.55809;
3183          tMC = 0.13387;
3184       }
3185       functionResult = dNdyMC / ( 2 * TMath::Pi())*(nMC-1.)*(nMC-2.) / (nMC*tMC*(nMC*tMC+mesonMass*(nMC-2.)))  * pow(1.+(sqrt(mesonPt*mesonPt+mesonMass*mesonMass)-mesonMass)/(nMC*tMC), -nMC);
3186    } else if (kCaseGen == 4){
3187 //       functionResult = 1./sqrt(1.-mesonMass*mesonMass/((mesonMass*mesonMass+mesonPt*mesonPt)*cosh(mesonY)*cosh(mesonY)));
3188       Float_t a = 0.23437;
3189       Float_t b = 5.6661;
3190       Float_t c = -1430.5863;
3191       Float_t d = -0.6966624;
3192       Float_t e = 252.3742;
3193       if ( ((TParticle*)MCStack->Particle(index))->GetPdgCode() ==  111){
3194          a = 0.23437;
3195          b = 5.6661;
3196          c = -1430.5863;
3197          d = -0.6966624;
3198          e = 252.3742;
3199       } else if ( ((TParticle*)MCStack->Particle(index))->GetPdgCode() ==  221){
3200          a = 0.10399;
3201          b = 4.35311;
3202          c = -12.17723;
3203          d = -0.01172;
3204          e =1.85140;
3205       }
3206       functionResult = a*TMath::Power(mesonPt,-1.*(b+c/(TMath::Power(mesonPt,d)+e)))*1./mesonPt *1./1.6 *1./(2.* TMath::Pi());
3207    }
3208    
3209    Float_t dNdyData = 2.2328;
3210    Float_t nData = 7.1473;
3211    Float_t tData = 0.1346;
3212    if ( ((TParticle*)MCStack->Particle(index))->GetPdgCode() ==  111){
3213          dNdyData = 2.2328;
3214          nData = 7.1473;
3215          tData = 0.1346;
3216       } else if ( ((TParticle*)MCStack->Particle(index))->GetPdgCode() ==  221){
3217          dNdyData = 0.38992; //be careful this fit is not optimal, eta in data still has problems
3218          nData = 5.72778;
3219          tData = 0.13835;
3220       }
3221    Float_t tsallisData = dNdyData / ( 2 * TMath::Pi())*(nData-1.)*(nData-2.) / (nData*tData*(nData*tData+mesonMass*(nData-2.)))  * pow(1.+(sqrt(mesonPt*mesonPt+mesonMass*mesonMass)-mesonMass)/(nData*tData), -nData);
3222 //    cout << "tsallisData/functionResult: " << tsallisData/functionResult << endl;
3223    return tsallisData/functionResult;
3224 //       return 
3225 }
3226
3227 ///________________________________________________________________________
3228 AliConversionCuts* AliConversionCuts::GetStandardCuts2010PbPb(){
3229     //Create and return standard 2010 PbPb cuts
3230     AliConversionCuts *cuts=new AliConversionCuts("StandardCuts2010PbPb","StandardCuts2010PbPb");
3231     if(!cuts->InitializeCutsFromCutString("1000002042092970023220000")){
3232         cout<<"Warning: Initialization of Standardcuts2010PbPb failed"<<endl;}
3233     return cuts;
3234 }
3235
3236 ///________________________________________________________________________
3237 AliConversionCuts* AliConversionCuts::GetStandardCuts2010pp(){
3238     //Create and return standard 2010 PbPb cuts
3239     AliConversionCuts *cuts=new AliConversionCuts("StandardCuts2010pp","StandardCuts2010pp");
3240     if(!cuts->InitializeCutsFromCutString("0000011002093663003800000")){
3241         cout<<"Warning: Initialization of Standardcuts2010pp failed"<<endl;}
3242     return cuts;
3243 }
3244