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