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