Replace GetMass for M(), smearing for virtual photons added, histogramas for eta...
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / AliDalitzElectronCuts.cxx
1
2 /**************************************************************************
3  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  *                                                                        *
5  * Authors: Svein Lindal, Daniel Lohner                                   *
6  * Version 1.0                                                            *
7  *                                                                        *
8  * Permission to use, copy, modify and distribute this software and its   *
9  * documentation strictly for non-commercial purposes is hereby granted   *
10  * without fee, provided that the above copyright notice appears in all   *
11  * copies and that both the copyright notice and this permission notice   *
12  * appear in the supporting documentation. The authors make no claims     *
13  * about the suitability of this software for any purpose. It is          *
14  * provided "as is" without express or implied warranty.                  *
15  **************************************************************************/
16
17 ////////////////////////////////////////////////
18 //--------------------------------------------- 
19 // Class handling all kinds of selection cuts for
20 // Gamma Conversion analysis
21 //---------------------------------------------
22 ////////////////////////////////////////////////
23
24
25 #include "AliDalitzElectronCuts.h"
26 #include "AliAODConversionPhoton.h"
27 #include "AliKFVertex.h"
28 #include "AliAODTrack.h"
29 #include "AliESDtrack.h"
30 #include "AliAnalysisManager.h"
31 #include "AliInputEventHandler.h"
32 #include "AliMCEventHandler.h"
33 #include "AliAODHandler.h"
34 #include "AliPIDResponse.h"
35 #include "TH1.h"
36 #include "TH2.h"
37 #include "AliStack.h"
38 #include "TObjString.h"
39 #include "AliAODEvent.h"
40 #include "AliESDEvent.h"
41 #include "TList.h"
42 class iostream;
43
44 using namespace std;
45
46 ClassImp(AliDalitzElectronCuts)
47
48
49 const char* AliDalitzElectronCuts::fgkCutNames[AliDalitzElectronCuts::kNCuts] = {
50 "GoodId",
51 "ededxSigmaITSCut",
52 "ededxSigmaTPCCut",
53 "pidedxSigmaTPCCut",
54 "piMinMomdedxSigmaTPCCut",
55 "piMaxMomdedxSigmaTPCCut",
56 "LowPRejectionSigmaCut",
57 "kTOFelectronPID",
58 "clsITSCut",
59 "clsTPCCut",
60 "EtaCut",
61 "PsiPair",
62 "RejectSharedElecGamma",
63 "BackgroundScheme",
64 "NumberOfRotations",
65 "PtCut",
66 "DCAcut",
67 "MassCut",
68 "kWeights"
69 };
70
71 //________________________________________________________________________
72 AliDalitzElectronCuts::AliDalitzElectronCuts(const char *name,const char *title) : AliAnalysisCuts(name,title),
73     fHistograms(NULL),
74     fPIDResponse(NULL),
75     fesdTrackCuts(NULL),
76     fEtaCut(0.9),
77     fEtaShift(0.0),
78     fDoEtaCut(kFALSE),
79     fPtMinCut(0.0),
80     fPtMaxCut(9999),
81     fRadiusCut(1000.0),
82     fPsiPairCut(0.45),
83     fDeltaPhiCutMin(0.),
84     fDeltaPhiCutMax(0.12),
85     fMinClsTPC(0), // minimum clusters in the TPC
86     fMinClsTPCToF(0), // minimum clusters to findable clusters
87     fDodEdxSigmaITSCut(kFALSE),
88     fDodEdxSigmaTPCCut(kTRUE),
89     fDoTOFsigmaCut(kFALSE), // RRnewTOF
90     fDoRejectSharedElecGamma(kFALSE),
91     fDoPsiPairCut(kFALSE),
92     fPIDnSigmaAboveElectronLineITS(100),
93     fPIDnSigmaBelowElectronLineITS(-100),
94     fPIDnSigmaAboveElectronLineTPC(100),
95     fPIDnSigmaBelowElectronLineTPC(-100),
96     fPIDnSigmaAbovePionLineTPC(0),
97     fPIDnSigmaAbovePionLineTPCHighPt(-100),
98     fTofPIDnSigmaAboveElectronLine(100), // RRnewTOF
99     fTofPIDnSigmaBelowElectronLine(-100), // RRnewTOF
100     fPIDMinPnSigmaAbovePionLineTPC(0),
101     fPIDMaxPnSigmaAbovePionLineTPC(0),
102     fDoKaonRejectionLowP(kFALSE),
103     fDoProtonRejectionLowP(kFALSE),
104     fDoPionRejectionLowP(kFALSE),
105     fPIDnSigmaAtLowPAroundKaonLine(0),
106     fPIDnSigmaAtLowPAroundProtonLine(0),
107     fPIDnSigmaAtLowPAroundPionLine(0),
108     fPIDMinPKaonRejectionLowP(1.5),
109     fPIDMinPProtonRejectionLowP(2.0),
110     fPIDMinPPionRejectionLowP(0.5),
111     fUseCorrectedTPCClsInfo(kFALSE),
112     fUseCrossedRows(kFALSE),
113     fUseTOFpid(kFALSE),
114     fRequireTOF(kFALSE),
115     fUseTrackMultiplicityForBG(kFALSE),
116     fBKGMethod(0),
117     fnumberOfRotationEventsForBG(0),
118     fDoMassCut(kFALSE),
119     fDoMassMinCut(kFALSE),
120     fMassCutLowPt(999.),
121     fMassCutHighPt(999.),
122     fMassCutPtMin(-100.0),
123     fMassMinCut(-999.),
124     fDoWeights(kFALSE),
125     fUseVPhotonMCPSmearing(kFALSE),
126     fCutString(NULL),
127     hCutIndex(NULL),
128     hdEdxCuts(NULL),
129     hITSdEdxbefore(NULL),
130     hITSdEdxafter(NULL),
131     hTPCdEdxbefore(NULL),
132     hTPCdEdxafter(NULL),
133     hTPCdEdxSignalbefore(NULL),
134     hTPCdEdxSignalafter(NULL),
135     hTOFbefore(NULL),
136     hTOFafter(NULL),
137     hTrackDCAxyPtbefore(NULL),
138     hTrackDCAxyPtafter(NULL),
139     hTrackDCAzPtbefore(NULL),
140     hTrackDCAzPtafter(NULL),
141     hTrackNFindClsPtTPCbefore(NULL),
142     hTrackNFindClsPtTPCafter(NULL),
143     hTrackPosEtabeforeDedx(NULL),
144     hTrackNegEtabeforeDedx(NULL),
145     hTrackPosEtaafterDedx(NULL),
146     hTrackNegEtaafterDedx(NULL)
147    {
148     InitPIDResponse();
149     for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=0;}
150     fCutString=new TObjString((GetCutNumber()).Data());
151
152    //fesdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts");
153    // Using standard function for setting Cuts
154     Bool_t selectPrimaries=kFALSE;
155     fesdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(selectPrimaries);
156 }
157
158 //________________________________________________________________________
159 AliDalitzElectronCuts::~AliDalitzElectronCuts() {
160     // Destructor
161   //Deleting fHistograms leads to seg fault it it's added to output collection of a task
162   // if(fHistograms)
163   //    delete fHistograms;
164   // fHistograms = NULL;
165
166    if(fCutString != NULL){
167       delete fCutString;
168       fCutString = NULL;
169    }
170
171
172 }
173
174 //________________________________________________________________________
175 void AliDalitzElectronCuts::InitCutHistograms(TString name, Bool_t preCut,TString cutNumber){
176
177     // Initialize Cut Histograms for QA (only initialized and filled if function is called)
178
179      TH1::AddDirectory(kFALSE);
180
181      TString cutName = "";
182     
183      if( cutNumber==""){
184          cutName = GetCutNumber().Data();
185      }
186      else {
187             cutName = cutNumber.Data();
188      } 
189
190     if(fHistograms != NULL){
191         delete fHistograms;
192         fHistograms=NULL;
193     }
194     if(fHistograms==NULL){
195         fHistograms=new TList();
196         if(name=="")fHistograms->SetName(Form("ElectronCuts_%s",cutName.Data()));
197         else fHistograms->SetName(Form("%s_%s",name.Data(),cutName.Data()));
198     }
199     
200     
201     Int_t kDedxSignalbins = 200;
202     
203      const Int_t kDCABins=62;
204     
205      Double_t binsDCADummy[63]={-3.0,-2.7,-2.4,-2.1,-1.8,-1.5,-1.2,-0.9,-0.6,-0.3,-0.25,-0.2,-0.19,-0.18,-0.17,-0.16,-0.15,-0.14,-0.13,-0.12,-0.11,-0.10,-0.09,-0.08,-0.07,-0.06,-0.05,-0.04,-0.03,-0.02,-0.01,0.0,0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.1,0.11,0.12,0.13,0.14,0.15,0.16,0.17,0.18,0.19,0.2,0.25,0.3,0.6,0.9,1.2,1.5,1.8,2.1,2.4,2.7,3.0};
206
207      const Int_t kPtBins=110;
208      Double_t binsPtDummy[kPtBins+1];
209      const Int_t kPBins = 109;
210      Double_t binsPDummy[kPBins+1];
211      binsPtDummy[0]=0.0;
212      binsPDummy[0]=0.05;
213      
214         for(Int_t i=1;i<kPtBins+1;i++)
215         {
216                 if(binsPtDummy[i-1]+0.05<1.01)
217                         binsPtDummy[i]=binsPtDummy[i-1]+0.05;
218                 else
219                         binsPtDummy[i]=binsPtDummy[i-1]+0.1;
220                 
221         }
222         for(Int_t i=1; i <kPBins+1;i++){
223                   
224                   if( binsPDummy[i-1]+0.05<1.01)
225                         binsPDummy[i] = binsPDummy[i-1]+0.05;
226                   else
227                         binsPDummy[i] = binsPDummy[i-1]+0.1;
228                 
229         }
230        
231
232
233     hCutIndex=new TH1F(Form("IsElectronSelected %s",cutName.Data()),"IsElectronSelected",10,-0.5,9.5);
234     hCutIndex->GetXaxis()->SetBinLabel(kElectronIn+1,"in");
235     hCutIndex->GetXaxis()->SetBinLabel(kNoTracks+1,"no tracks");
236     hCutIndex->GetXaxis()->SetBinLabel(kTrackCuts+1,"Track cuts");
237     hCutIndex->GetXaxis()->SetBinLabel(kdEdxCuts+1,"dEdx");
238     hCutIndex->GetXaxis()->SetBinLabel(kElectronOut+1,"out");
239     fHistograms->Add(hCutIndex);
240
241
242
243     // dEdx Cuts
244     hdEdxCuts=new TH1F(Form("dEdxCuts %s",cutName.Data()),"dEdxCuts",10,-0.5,9.5);
245     hdEdxCuts->GetXaxis()->SetBinLabel(1,"in");
246     hdEdxCuts->GetXaxis()->SetBinLabel(2,"ITSelectron");
247     hdEdxCuts->GetXaxis()->SetBinLabel(3,"TPCelectron");
248     hdEdxCuts->GetXaxis()->SetBinLabel(4,"TPCpion");
249     hdEdxCuts->GetXaxis()->SetBinLabel(5,"TPCpionhighp");
250     hdEdxCuts->GetXaxis()->SetBinLabel(6,"TPCkaonlowprej");
251     hdEdxCuts->GetXaxis()->SetBinLabel(7,"TPCprotonlowprej");
252     hdEdxCuts->GetXaxis()->SetBinLabel(8,"TPCpionlowprej");
253     hdEdxCuts->GetXaxis()->SetBinLabel(9,"TOFelectron");
254     hdEdxCuts->GetXaxis()->SetBinLabel(10,"out");
255     fHistograms->Add(hdEdxCuts);
256     
257
258
259     TAxis *AxisBeforeITS  = NULL;
260     TAxis *AxisBeforedEdx = NULL;
261     TAxis *AxisBeforeTOF  = NULL;
262     TAxis *AxisBeforedEdxSignal = NULL;
263
264     if(preCut){
265
266
267        hITSdEdxbefore=new TH2F(Form("Electron_ITS_before %s",cutName.Data()),"ITS dEdx electron before" ,kPBins,binsPDummy,200,-10,10);
268        fHistograms->Add(hITSdEdxbefore);
269        AxisBeforeITS = hITSdEdxbefore->GetXaxis();
270
271        hTPCdEdxbefore=new TH2F(Form("Electron_dEdx_before %s",cutName.Data()),"dEdx electron before" ,kPBins,binsPDummy,200,-10,10);
272        fHistograms->Add(hTPCdEdxbefore);
273        AxisBeforedEdx = hTPCdEdxbefore->GetXaxis();
274
275        hTPCdEdxSignalbefore=new TH2F(Form("Electron_dEdxSignal_before %s",cutName.Data()),"dEdx electron signal before" ,kPBins,binsPDummy,kDedxSignalbins,0.0,200);
276        fHistograms->Add(hTPCdEdxSignalbefore);
277        AxisBeforedEdxSignal = hTPCdEdxSignalbefore->GetXaxis();
278
279        hTOFbefore=new TH2F(Form("Electron_TOF_before %s",cutName.Data()),"TOF electron before" ,kPBins,binsPDummy,200,-10,10);
280        fHistograms->Add(hTOFbefore);
281        AxisBeforeTOF = hTOFbefore->GetXaxis();
282        
283        hTrackDCAxyPtbefore = new TH2F(Form("hTrack_DCAxy_Pt_before %s",cutName.Data()),"DCAxy Vs Pt of tracks before",kDCABins,binsDCADummy,kPtBins,binsPtDummy);
284        fHistograms->Add(hTrackDCAxyPtbefore);   
285        
286        hTrackDCAzPtbefore  = new TH2F(Form("hTrack_DCAz_Pt_before %s",cutName.Data()), "DCAz  Vs Pt of tracks before",kDCABins,binsDCADummy,kPtBins,binsPtDummy);
287        fHistograms->Add(hTrackDCAzPtbefore); 
288        
289        hTrackNFindClsPtTPCbefore = new TH2F(Form("hTrack_NFindCls_Pt_TPC_before %s",cutName.Data()),"Track: N Findable Cls TPC Vs Pt before",60,0,1.5,kPtBins,binsPtDummy);
290        fHistograms->Add(hTrackNFindClsPtTPCbefore); 
291         
292        
293
294     }
295
296
297     hITSdEdxafter=new TH2F(Form("Electron_ITS_after %s",cutName.Data()),"ITS dEdx electron after" ,kPBins,binsPDummy,200, -10,10);
298     fHistograms->Add(hITSdEdxafter);
299
300     hTPCdEdxafter=new TH2F(Form("Electron_dEdx_after %s",cutName.Data()),"dEdx electron after" ,kPBins,binsPDummy,200, -10,10);
301     fHistograms->Add(hTPCdEdxafter);
302
303     hTPCdEdxSignalafter=new TH2F(Form("Electron_dEdxSignal_after %s",cutName.Data()),"dEdx electron signal after" ,kPBins,binsPDummy,kDedxSignalbins,0.0,200);
304     fHistograms->Add(hTPCdEdxSignalafter);
305
306     hTOFafter=new TH2F(Form("Electron_TOF_after %s",cutName.Data()),"TOF electron after" ,kPBins,binsPDummy,200,-6,10);
307     fHistograms->Add(hTOFafter);
308       
309     hTrackDCAxyPtafter  = new TH2F(Form("hTrack_DCAxy_Pt_after %s",cutName.Data()),"DCAxy Vs Pt of tracks after",kDCABins,binsDCADummy,kPtBins,binsPtDummy);
310     fHistograms->Add(hTrackDCAxyPtafter); 
311     
312     hTrackDCAzPtafter  = new TH2F(Form("hTrack_DCAz_Pt_after %s",cutName.Data()), "DCAz Vs Pt of tracks  after",kDCABins,binsDCADummy,kPtBins,binsPtDummy);
313     fHistograms->Add(hTrackDCAzPtafter); 
314     
315     hTrackNFindClsPtTPCafter = new TH2F(Form("hTrack_NFindCls_Pt_TPC_after %s",cutName.Data()),"Track: N Findable Cls TPC Vs Pt after",60,0,1.5,kPtBins,binsPtDummy);
316     fHistograms->Add(hTrackNFindClsPtTPCafter); 
317     
318     hTrackPosEtabeforeDedx = new TH1F("hTrack_Pos_Eta_before_Dedx","hTrack_Pos_Eta_before_Dedx",600,-1.5,1.5);
319     fHistograms->Add(hTrackPosEtabeforeDedx);
320     
321     hTrackNegEtabeforeDedx = new TH1F("hTrack_Neg_Eta_before_Dedx","hTrack_Neg_Eta_before_Dedx",600,-1.5,1.5);
322     fHistograms->Add(hTrackNegEtabeforeDedx);
323     
324     hTrackPosEtaafterDedx  = new TH1F("hTrack_Pos_Eta_after_Dedx","hTrack_Pos_Eta_after_Dedx",600,-1.5,1.5);
325     fHistograms->Add(hTrackPosEtaafterDedx);
326     
327     hTrackNegEtaafterDedx  = new TH1F("hTrack_Neg_Eta_afterDedx","hTrack_Neg_Eta_after_Dedx",600,-1.5,1.5);
328     fHistograms->Add(hTrackNegEtaafterDedx);
329     
330     
331
332     TAxis *AxisAfter = hTPCdEdxafter->GetXaxis(); 
333     Int_t bins = AxisAfter->GetNbins();
334     Double_t from = AxisAfter->GetXmin();
335     Double_t to = AxisAfter->GetXmax();
336     Double_t *newBins = new Double_t[bins+1];
337     newBins[0] = from;
338     Double_t factor = TMath::Power(to/from, 1./bins);
339     for(Int_t i=1; i<=bins; ++i) newBins[i] = factor * newBins[i-1];
340     AxisAfter->Set(bins, newBins);
341     AxisAfter = hTOFafter->GetXaxis(); 
342     AxisAfter->Set(bins, newBins);
343     AxisAfter = hITSdEdxafter->GetXaxis();
344     AxisAfter->Set(bins,newBins); 
345     AxisAfter = hTPCdEdxSignalafter->GetXaxis();
346     AxisAfter->Set(bins,newBins);
347     
348     if(preCut){
349        AxisBeforeITS->Set(bins, newBins);
350        AxisBeforedEdx->Set(bins, newBins);
351        AxisBeforedEdxSignal->Set(bins,newBins);
352        AxisBeforeTOF->Set(bins, newBins);
353        
354     }
355     delete [] newBins;
356
357     TH1::AddDirectory(kTRUE);        
358
359     // Event Cuts and Info
360 }
361
362
363 //________________________________________________________________________
364 Bool_t AliDalitzElectronCuts::InitPIDResponse(){
365
366 // Set Pointer to AliPIDResponse
367
368   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
369
370   if(man) {
371
372     AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
373     fPIDResponse = (AliPIDResponse*)inputHandler->GetPIDResponse();
374     if(fPIDResponse)return kTRUE;
375
376   }
377
378   return kFALSE;
379 }
380 ///________________________________________________________________________
381 Bool_t AliDalitzElectronCuts::ElectronIsSelectedMC(Int_t labelParticle,AliStack *fMCStack)
382 {   
383         if( labelParticle < 0 || labelParticle >= fMCStack->GetNtrack() ) return kFALSE;
384         if( fMCStack->IsPhysicalPrimary(labelParticle) == kFALSE ) return kFALSE; //Ask Ana
385
386         TParticle* particle = fMCStack->Particle(labelParticle);
387
388         if( TMath::Abs( particle->GetPdgCode() ) != 11 )  return kFALSE;
389         
390         if( fDoEtaCut ){
391           if( particle->Eta() > (fEtaCut + fEtaShift) || particle->Eta() < (-fEtaCut + fEtaShift) )
392           return kFALSE;
393         }
394         
395
396 return kTRUE;
397 }
398
399
400 ///________________________________________________________________________
401 Bool_t AliDalitzElectronCuts::ElectronIsSelected(AliESDtrack* lTrack)
402 {
403     //Selection of Reconstructed electrons
404     
405     
406     Float_t b[2];
407     Float_t bCov[3];
408     lTrack->GetImpactParameters(b,bCov);
409    
410     if (bCov[0]<=0 || bCov[2]<=0) {
411         AliDebug(1, "Estimated b resolution lower or equal zero!");
412         bCov[0]=0; bCov[2]=0;
413     }
414     
415     
416
417     Float_t dcaToVertexXY = b[0];
418     Float_t dcaToVertexZ  = b[1];
419     Double_t clsToF = GetNFindableClustersTPC(lTrack);
420    
421    if( hTrackDCAxyPtbefore) hTrackDCAxyPtbefore->Fill(dcaToVertexXY,lTrack->Pt());
422    if( hTrackDCAzPtbefore ) hTrackDCAzPtbefore->Fill( dcaToVertexZ, lTrack->Pt());
423    if( hTrackNFindClsPtTPCbefore ) hTrackNFindClsPtTPCbefore->Fill( clsToF, lTrack->Pt());
424    
425    
426
427     if(hCutIndex)hCutIndex->Fill(kElectronIn);
428
429     if (lTrack == NULL){
430       if(hCutIndex)hCutIndex->Fill(kNoTracks);
431          return kFALSE;  
432     }   
433        
434     if ( ! lTrack->GetConstrainedParam() ){
435         return kFALSE;
436     }
437     AliVTrack * track = dynamic_cast<AliVTrack*>(lTrack);
438
439
440     // Track Cuts
441     if( !TrackIsSelected(lTrack) ){
442          if(hCutIndex)hCutIndex->Fill(kTrackCuts);
443          return kFALSE;
444     }
445
446     if( lTrack->GetSign() > 0.0 ){
447        
448      if (hTrackPosEtabeforeDedx) hTrackPosEtabeforeDedx->Fill(lTrack->Eta());
449       
450     } else{
451       
452       if(hTrackNegEtabeforeDedx) hTrackNegEtabeforeDedx->Fill(lTrack->Eta());
453       
454     }
455     
456     
457     // dEdx Cuts
458     if( ! dEdxCuts( track ) ) {
459          if(hCutIndex)hCutIndex->Fill(kdEdxCuts);
460          return kFALSE;
461
462     }
463     
464     if( lTrack->GetSign() > 0.0 ){
465        
466       if( hTrackPosEtaafterDedx) hTrackPosEtaafterDedx->Fill(lTrack->Eta());
467       
468     } else{
469       
470       if( hTrackNegEtaafterDedx) hTrackNegEtaafterDedx->Fill(lTrack->Eta());
471       
472     }
473     
474     
475
476     //Electron passed the cuts
477     if(hCutIndex)hCutIndex->Fill(kElectronOut);
478     
479     if( hTrackDCAxyPtafter)        hTrackDCAxyPtafter->Fill(dcaToVertexXY,lTrack->Pt());
480     if( hTrackDCAzPtafter )        hTrackDCAzPtafter->Fill(dcaToVertexZ,lTrack->Pt());
481     if( hTrackNFindClsPtTPCafter ) hTrackNFindClsPtTPCafter->Fill( clsToF, lTrack->Pt());
482
483
484     return kTRUE;
485 }
486
487 ///________________________________________________________________________
488 Bool_t AliDalitzElectronCuts::TrackIsSelected(AliESDtrack* lTrack) {
489     // Track Selection for Photon Reconstruction
490     
491          
492     Double_t clsToF = GetNFindableClustersTPC(lTrack);
493     
494
495     if( ! fesdTrackCuts->AcceptTrack(lTrack) ){
496
497         return kFALSE;
498     }
499     
500     if( fDoEtaCut ) {
501       if(  lTrack->Eta() > (fEtaCut + fEtaShift) || lTrack->Eta() < (-fEtaCut + fEtaShift) ) {
502         return kFALSE;
503       }
504    }
505    
506    
507    if( lTrack->Pt() < fPtMinCut || lTrack->Pt() > fPtMaxCut ) {
508      
509         return kFALSE;
510         
511    }
512
513    
514
515     if( clsToF < fMinClsTPCToF){
516     return kFALSE;
517     }
518
519     
520
521    return kTRUE;
522 }
523 ///________________________________________________________________________
524 Bool_t AliDalitzElectronCuts::dEdxCuts(AliVTrack *fCurrentTrack){
525
526     // Electron Identification Cuts for Photon reconstruction
527
528     if(!fPIDResponse){  InitPIDResponse();  }// Try to reinitialize PID Response
529     if(!fPIDResponse){  AliError("No PID Response"); return kFALSE;}// if still missing fatal error
530
531
532
533     //cout<<"dEdxCuts: //////////////////////////////////////////////////////////////////////////"<<endl;
534
535
536
537     Int_t cutIndex=0;
538
539     if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
540     if(hITSdEdxbefore)hITSdEdxbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasITS(fCurrentTrack, AliPID::kElectron));
541     if(hTPCdEdxbefore)hTPCdEdxbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTPC(fCurrentTrack, AliPID::kElectron));
542     if(hTPCdEdxSignalbefore)hTPCdEdxSignalbefore->Fill(fCurrentTrack->P(),TMath::Abs(fCurrentTrack->GetTPCsignal()));
543
544
545     cutIndex++;
546
547
548                 if( fDodEdxSigmaITSCut == kTRUE ){
549
550
551                         if( fPIDResponse->NumberOfSigmasITS(fCurrentTrack,AliPID::kElectron)<fPIDnSigmaBelowElectronLineITS ||
552                                         fPIDResponse->NumberOfSigmasITS(fCurrentTrack,AliPID::kElectron)> fPIDnSigmaAboveElectronLineITS ){
553                                 
554                                 if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
555                                 return kFALSE;
556       }
557                         
558                 }
559                 
560                 if(hITSdEdxafter)hITSdEdxafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasITS(fCurrentTrack, AliPID::kElectron));
561                 
562                 
563                 cutIndex++;
564                 
565                 
566                 if(fDodEdxSigmaTPCCut == kTRUE){
567                         
568                         
569       // TPC Electron Line
570       if( fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)<fPIDnSigmaBelowElectronLineTPC ||
571                                         fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)>fPIDnSigmaAboveElectronLineTPC){
572                                 
573                                 if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
574                                 return kFALSE;
575       }
576       cutIndex++;
577                         
578       // TPC Pion Line
579                         if( fCurrentTrack->P()>fPIDMinPnSigmaAbovePionLineTPC && fCurrentTrack->P()<fPIDMaxPnSigmaAbovePionLineTPC ){
580                                 if(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLineTPC     &&
581                                          fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)<fPIDnSigmaAboveElectronLineTPC &&
582                                          fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)<fPIDnSigmaAbovePionLineTPC){
583                                         
584                                         if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
585                                         return kFALSE;
586                                 }
587                         }
588                         cutIndex++;
589                         
590                         // High Pt Pion rej
591                         if( fCurrentTrack->P()>fPIDMaxPnSigmaAbovePionLineTPC ){
592                                 if(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLineTPC &&
593                                          fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)<fPIDnSigmaAboveElectronLineTPC&&
594                                          fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)<fPIDnSigmaAbovePionLineTPCHighPt){
595                                         
596                                         if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
597                                         return kFALSE;
598                                 }
599                         }
600                         
601                         cutIndex++;
602                 }
603
604                 else{ cutIndex+=3; }
605
606
607                 if(   fDoKaonRejectionLowP == kTRUE   ){
608
609                         if( fCurrentTrack->P() < fPIDMinPKaonRejectionLowP ){
610                                 
611                                 if( TMath::Abs(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kKaon))<fPIDnSigmaAtLowPAroundKaonLine){
612                                         
613                                         if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
614                                         
615                                         return kFALSE;
616                                 }
617                         }
618                 }
619                 cutIndex++;
620                 
621                 if(   fDoProtonRejectionLowP == kTRUE    ){
622                         
623                         if( fCurrentTrack->P()  < fPIDMinPProtonRejectionLowP ){
624                                 if( TMath::Abs(   fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kProton))<fPIDnSigmaAtLowPAroundProtonLine){
625                                         
626                                         if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
627                                         return kFALSE;
628                                 }
629                         }
630                 }
631                 cutIndex++;
632                 
633                 if(fDoPionRejectionLowP == kTRUE){
634                         if( fCurrentTrack->P() < fPIDMinPPionRejectionLowP ){
635                                 if( TMath::Abs( fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)) < fPIDnSigmaAtLowPAroundPionLine ){
636                                         
637                                         if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
638                                         return kFALSE;
639                                 }
640                         }
641                 }
642                 cutIndex++;
643                 
644                 
645                 if( ( fCurrentTrack->GetStatus() & AliESDtrack::kTOFpid ) && ( !( fCurrentTrack->GetStatus() & AliESDtrack::kTOFmismatch) ) ){
646                         if(hTOFbefore) hTOFbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron));
647                         if(fUseTOFpid){
648         if(fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron)>fTofPIDnSigmaAboveElectronLine ||
649            fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron)<fTofPIDnSigmaBelowElectronLine ){
650                                         if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
651                                         return kFALSE;
652         }
653                         }
654                         if(hTOFafter)hTOFafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron));
655                 }
656                 else if ( fRequireTOF == kTRUE ) {
657                         
658                         if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
659                         return kFALSE;
660                 }
661                 cutIndex++;
662                 
663                 if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
664                 if(hTPCdEdxafter)hTPCdEdxafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTPC(fCurrentTrack, AliPID::kElectron));
665                 if(hTPCdEdxSignalafter)hTPCdEdxSignalafter->Fill(fCurrentTrack->P(),TMath::Abs(fCurrentTrack->GetTPCsignal()));
666                 
667                 return kTRUE;
668 }
669 ///________________________________________________________________________
670
671
672 AliVTrack *AliDalitzElectronCuts::GetTrack(AliVEvent * event, Int_t label){
673     //Returns pointer to the track with given ESD label
674     //(Important for AOD implementation, since Track array in AOD data is different
675     //from ESD array, but ESD tracklabels are stored in AOD Tracks)
676
677   AliESDEvent * esdEvent = dynamic_cast<AliESDEvent*>(event);
678   if(esdEvent) {
679         if(label > event->GetNumberOfTracks() ) return NULL;
680         AliESDtrack * track = esdEvent->GetTrack(label);
681         return track;
682         
683   } else { 
684         for(Int_t ii=0; ii<event->GetNumberOfTracks(); ii++) {
685           AliVTrack * track = dynamic_cast<AliVTrack*>(event->GetTrack(ii));
686           
687           if(track) { 
688                 if(track->GetID() == label) {
689                   return track;
690                 }
691           }
692         }
693     }
694   
695   cout << "track not found " << label << " " << event->GetNumberOfTracks() << endl;
696   return NULL;
697 }
698 ///________________________________________________________________________
699 Bool_t AliDalitzElectronCuts::RejectSharedElecGamma(TList *photons, Int_t indexEle){
700
701
702      for(Int_t i = 0;i<photons->GetEntries();i++){
703
704       AliAODConversionPhoton *photonComp = (AliAODConversionPhoton*) photons->At(i);
705
706       Int_t posLabel = photonComp->GetTrackLabelPositive();
707       Int_t negLabel = photonComp->GetTrackLabelNegative();
708
709       if( (photonComp->GetConversionRadius() < fRadiusCut) && (posLabel == indexEle || negLabel == indexEle) ){
710         return kFALSE;
711       }
712      }
713
714    return kTRUE;
715 }
716 Bool_t AliDalitzElectronCuts::MassCut(Double_t pi0CandidatePt , Double_t vphotonCandidateMass){
717   
718         if( pi0CandidatePt < fMassCutPtMin ){
719           
720               if( vphotonCandidateMass < fMassCutLowPt ){
721                     return kTRUE;
722               }
723                 
724         }
725         else{
726           
727                if( vphotonCandidateMass < fMassCutHighPt ){
728                     return kTRUE;
729                }
730               
731         }
732         
733         return kFALSE;
734           
735 }
736
737 Double_t AliDalitzElectronCuts::GetNFindableClustersTPC(AliESDtrack* lTrack){
738   
739   
740   Double_t clsToF=0;
741   
742   if( fUseCrossedRows == kFALSE ) {
743
744     if ( !fUseCorrectedTPCClsInfo ){
745         if(lTrack->GetTPCNclsF()!=0){
746
747               clsToF = (Double_t)lTrack->GetNcls(1)/(Double_t)lTrack->GetTPCNclsF();
748         }// Ncluster/Nfindablecluster
749     }
750     else {
751
752               //clsToF = lTrack->GetTPCClusterInfo(2,0,GetFirstTPCRow(photon->GetConversionRadius()));
753               clsToF = lTrack->GetTPCClusterInfo(2,0); //NOTE ask friederike
754                 
755     }
756   } else  {
757    
758          Float_t nCrossedRowsTPC = lTrack->GetTPCCrossedRows();
759          clsToF = 1.0;
760           if ( lTrack->GetTPCNclsF()>0 ) {
761               clsToF = nCrossedRowsTPC / lTrack->GetTPCNclsF();
762           }     
763     }
764   
765   return clsToF;
766    
767 }
768
769 /*
770 Double_t AliDalitzElectronCuts::GetPsiPair( const AliESDtrack *trackPos, const AliESDtrack *trackNeg )
771 {
772 //
773 // This angle is a measure for the contribution of the opening in polar
774 // direction ??0 to the opening angle ?? Pair
775 //
776 // Ref. Measurement of photons via conversion pairs with the PHENIX experiment at RHIC
777 //      Master Thesis. Thorsten Dahms. 2005
778 // https://twiki.cern.ch/twiki/pub/ALICE/GammaPhysicsPublications/tdahms_thesis.pdf
779 //
780         Double_t momPos[3];
781         Double_t momNeg[3];
782         if( trackPos->GetConstrainedPxPyPz(momPos) == 0 ) trackPos->GetPxPyPz( momPos );
783         if( trackNeg->GetConstrainedPxPyPz(momNeg) == 0 ) trackNeg->GetPxPyPz( momNeg );
784
785         TVector3 posDaughter;
786         TVector3 negDaughter;
787
788         posDaughter.SetXYZ( momPos[0], momPos[1], momPos[2] );
789         negDaughter.SetXYZ( momNeg[0], momNeg[1], momNeg[2] );
790
791         Double_t deltaTheta = negDaughter.Theta() - posDaughter.Theta();
792         Double_t openingAngle =  posDaughter.Angle( negDaughter );  //TMath::ACos( posDaughter.Dot(negDaughter)/(negDaughter.Mag()*posDaughter.Mag()) );
793
794         if( openingAngle < 1e-20 ) return 0.;
795
796         Double_t psiAngle = TMath::ASin( deltaTheta/openingAngle );
797
798         return psiAngle;
799 }*/
800
801 Bool_t AliDalitzElectronCuts::IsFromGammaConversion( Double_t psiPair, Double_t deltaPhi )
802 {
803 //
804 // Returns true if it is a gamma conversion according to psi pair value
805 //
806         return ( (deltaPhi > fDeltaPhiCutMin  &&  deltaPhi < fDeltaPhiCutMax) &&
807         TMath::Abs(psiPair) < ( fPsiPairCut - fPsiPairCut/fDeltaPhiCutMax * deltaPhi ) );
808 }
809
810 ///________________________________________________________________________
811 Bool_t AliDalitzElectronCuts::UpdateCutString(cutIds cutID, Int_t value) {
812 ///Update the cut string (if it has been created yet)
813
814   if(fCutString && fCutString->GetString().Length() == kNCuts) {
815          cout << "Updating cut id in spot number " << cutID << " to " << value << endl;
816         fCutString->SetString(GetCutNumber());
817   } else {
818          cout << "fCutString not yet initialized, will not be updated" << endl;
819         return kFALSE;
820   }
821  // cout << fCutString->GetString().Data() << endl;
822   return kTRUE;
823 }
824
825 ///________________________________________________________________________
826 Bool_t AliDalitzElectronCuts::InitializeCutsFromCutString(const TString analysisCutSelection ) {
827    // Initialize Cuts from a given Cut string
828
829 //   out<<"Set Cut Number: "<<analysisCutSelection.Data()<<endl;
830   AliInfo(Form("Set ElectronCuts Number: %s",analysisCutSelection.Data()));
831   
832   if(analysisCutSelection.Length()!=kNCuts) {
833         AliError(Form("Cut selection has the wrong length! size is %d, number of cuts is %d", analysisCutSelection.Length(), kNCuts));
834         return kFALSE;
835   }
836   if(!analysisCutSelection.IsDigit()){
837         AliError("Cut selection contains characters");
838         return kFALSE;
839   }
840   
841   const char *cutSelection = analysisCutSelection.Data();
842   #define ASSIGNARRAY(i)        fCuts[i] = cutSelection[i] - '0'
843   for(Int_t ii=0;ii<kNCuts;ii++){
844       ASSIGNARRAY(ii);
845   }
846
847   // TestFlag
848   if(fCuts[0] !=9){
849     AliError("Analysis Cut Selection does not start with 9");
850         PrintCuts();
851     return kFALSE;
852   }
853
854   // Set Individual Cuts
855   for(Int_t ii=0;ii<kNCuts;ii++){
856       if(!SetCut(cutIds(ii),fCuts[ii]))return kFALSE;
857   }
858
859   //PrintCuts();
860
861     return kTRUE;
862 }
863 ///________________________________________________________________________
864 Bool_t AliDalitzElectronCuts::SetCut(cutIds cutID, const Int_t value) {
865   ///Set individual cut ID
866
867   //cout << "Updating cut  " << fgkCutNames[cutID] << " (" << cutID << ") to " << value << endl;
868
869   switch (cutID) {
870   case kgoodId:
871         fCuts[kgoodId] = value;
872         if(value != 9) {
873           cout << "Error:: First value of cut string is wrong, aborting!!" << endl;
874           return kFALSE;
875         } else {
876           return kTRUE;
877         }
878
879   case kededxSigmaITSCut:
880         if( SetITSdEdxCutElectronLine(value)) { //NOTE SetITSdEdxCutElectronLine: To be implemented 
881           fCuts[kededxSigmaITSCut] = value;
882           UpdateCutString(cutID, value);
883           return kTRUE;
884         } else return kFALSE;
885
886         case kededxSigmaTPCCut:
887                 if( SetTPCdEdxCutElectronLine(value)) { //NOTE SetITSdEdxCutElectronLine: To be implemented 
888                         fCuts[kededxSigmaTPCCut] = value;
889                         UpdateCutString(cutID, value);
890                         return kTRUE;
891                 } else return kFALSE;
892                 
893   case kpidedxSigmaTPCCut:
894                 if( SetTPCdEdxCutPionLine(value)) { //NOTE SetITSdEdxCutPionLine: To be implemented
895                         fCuts[kpidedxSigmaTPCCut] = value;
896                         UpdateCutString(cutID, value);
897                         return kTRUE;
898                 } else return kFALSE;
899                 
900   case kpiMinMomdedxSigmaTPCCut:
901                 if( SetMinMomPiondEdxTPCCut(value)) {
902                         fCuts[kpiMinMomdedxSigmaTPCCut] = value;
903                         UpdateCutString(cutID, value);
904                         return kTRUE;
905                 } else return kFALSE;
906                 
907   case kpiMaxMomdedxSigmaTPCCut:
908                 if( SetMaxMomPiondEdxTPCCut(value)) {
909                         fCuts[kpiMaxMomdedxSigmaTPCCut] = value;
910                         UpdateCutString(cutID, value);
911                         return kTRUE;
912                 } else return kFALSE;
913                 
914   case kLowPRejectionSigmaCut:
915                 if( SetLowPRejectionCuts(value) ) {
916                         fCuts[kLowPRejectionSigmaCut] = value;
917                         UpdateCutString(cutID, value);
918                         return kTRUE;
919                 } else return kFALSE;
920                 
921                 
922   case kTOFelectronPID:
923                 if( SetTOFElectronPIDCut(value)) {
924                         fCuts[kTOFelectronPID] = value;
925                         UpdateCutString(cutID, value);
926                         return kTRUE;
927                 } else return kFALSE;
928   case kclsITSCut:
929                 if( SetITSClusterCut(value) ) {
930                         fCuts[kclsITSCut] = value;
931                         UpdateCutString(cutID, value);
932                         return kTRUE;                   
933                 } else return kFALSE;
934   case kclsTPCCut:
935                 if( SetTPCClusterCut(value)) {
936                         fCuts[kclsTPCCut] = value;
937                         UpdateCutString(cutID, value);
938                         return kTRUE;
939                 } else return kFALSE;
940                 
941   case ketaCut:
942                 if( SetEtaCut(value)) {
943                         fCuts[ketaCut] = value;
944                         UpdateCutString(cutID, value);
945                         return kTRUE;
946                 } else return kFALSE;
947   case kptCut:  
948                 if( SetPtCut(value)) {
949                         fCuts[kptCut] = value;
950                         UpdateCutString(cutID, value);
951                         return kTRUE;
952                 } else return kFALSE;
953     
954   case kDCACut:
955                 if( SetDCACut(value)) {
956                         fCuts[kDCACut] = value;
957                         UpdateCutString(cutID, value);
958                         return kTRUE;
959                 } else return kFALSE;
960               
961               
962         case kPsiPair:
963                 if( SetPsiPairCut(value)) {
964                         fCuts[kPsiPair] = value;
965                         UpdateCutString(cutID, value);
966                         return kTRUE;
967                 } else return kFALSE;
968                 
969   case kRejectSharedElecGamma:
970                 if( SetRejectSharedElecGamma(value)) {
971                         fCuts[kRejectSharedElecGamma] = value;
972                         UpdateCutString(cutID, value);
973           return kTRUE;
974                 } else return kFALSE;
975                 
976   case kBackgroundScheme:
977                 if( SetBackgroundScheme(value)) {
978                         fCuts[kBackgroundScheme] = value;
979                         UpdateCutString(cutID, value);
980                         return kTRUE;
981                 } else return kFALSE;
982
983   case kNumberOfRotations:
984                 if( SetNumberOfRotations(value)) {
985                         fCuts[kNumberOfRotations] = value;
986                         UpdateCutString(cutID, value);
987                         return kTRUE;
988                 } else return kFALSE;
989                 
990   case kmassCut:
991                 if( SetMassCut(value)) {
992                         fCuts[kmassCut] = value;
993                         UpdateCutString(cutID, value);
994                         return kTRUE;
995                 } else return kFALSE;
996   case kWeights:
997                 if( SetDoWeights(value)) {
998                         fCuts[kWeights] = value;
999                         UpdateCutString(cutID, value);
1000                         return kTRUE;
1001                 } else return kFALSE;
1002                
1003   case kuseVPhotonMCPSmearing:
1004     
1005                   if( SetUseVPhotonMCPmearing(value)) {
1006                         fCuts[kuseVPhotonMCPSmearing] = value;
1007                         UpdateCutString(cutID, value);
1008                         return kTRUE;
1009                   } else return kFALSE;
1010                   
1011   case kNCuts:
1012                 cout << "Error:: Cut id out of range"<< endl;
1013                 return kFALSE;
1014   }
1015         
1016   cout << "Error:: Cut id " << cutID << " not recognized "<< endl;
1017   return kFALSE;
1018
1019   //PrintCuts();
1020   
1021 }
1022
1023 ///________________________________________________________________________
1024
1025 void AliDalitzElectronCuts::PrintCuts() {
1026     // Print out current Cut Selection
1027   for(Int_t ic = 0; ic < kNCuts; ic++) {
1028         printf("%-30s : %d \n", fgkCutNames[ic], fCuts[ic]);
1029   }
1030
1031 }
1032
1033 ///________________________________________________________________________
1034 Bool_t AliDalitzElectronCuts::SetITSdEdxCutElectronLine(Int_t ededxSigmaCut)
1035 {   // Set Cut
1036
1037         switch(ededxSigmaCut){
1038
1039         case 0: 
1040                 fDodEdxSigmaITSCut = kFALSE;
1041                 fPIDnSigmaBelowElectronLineITS=-100;
1042                 fPIDnSigmaAboveElectronLineITS= 100;
1043                 break;
1044         case 1: // -10,10
1045                 fDodEdxSigmaITSCut = kTRUE;
1046                 fPIDnSigmaBelowElectronLineITS=-10;
1047                 fPIDnSigmaAboveElectronLineITS=10;
1048                 break;
1049         case 2: // -6,7
1050                 fDodEdxSigmaITSCut = kTRUE;
1051                 fPIDnSigmaBelowElectronLineITS=-6;
1052                 fPIDnSigmaAboveElectronLineITS=7;
1053                 break;
1054         case 3: // -5,5
1055                 fDodEdxSigmaITSCut = kTRUE;
1056                 fPIDnSigmaBelowElectronLineITS=-5;
1057                 fPIDnSigmaAboveElectronLineITS=5;
1058                 break;
1059         case 4: // -4,5
1060                 fDodEdxSigmaITSCut = kTRUE;
1061                 fPIDnSigmaBelowElectronLineITS=-4;
1062                 fPIDnSigmaAboveElectronLineITS=5;
1063                 break;
1064         case 5: // -3,5
1065                 fDodEdxSigmaITSCut = kTRUE;
1066                 fPIDnSigmaBelowElectronLineITS=-3;
1067                 fPIDnSigmaAboveElectronLineITS=5;
1068                 break;
1069         case 6: // -4,4
1070                 fDodEdxSigmaITSCut = kTRUE;
1071                 fPIDnSigmaBelowElectronLineITS=-4;
1072                 fPIDnSigmaAboveElectronLineITS=4;
1073                 break;
1074         case 7: // -2.5,4
1075                 fDodEdxSigmaITSCut = kTRUE;
1076                 fPIDnSigmaBelowElectronLineITS=-2.5;
1077                 fPIDnSigmaAboveElectronLineITS=4;
1078                 break;
1079         case 8: // -2,3.5
1080                 fDodEdxSigmaITSCut = kTRUE;
1081                 fPIDnSigmaBelowElectronLineITS=-2;
1082                 fPIDnSigmaAboveElectronLineITS=3.5;
1083                 break;
1084         default:
1085                 cout<<"Warning: ITSdEdxCutElectronLine not defined"<<ededxSigmaCut<<endl;
1086                 return kFALSE;
1087     
1088         }
1089         return kTRUE;
1090 }
1091
1092 ///________________________________________________________________________
1093 Bool_t AliDalitzElectronCuts::SetTPCdEdxCutElectronLine(Int_t ededxSigmaCut)
1094 {   // Set Cut
1095         switch(ededxSigmaCut){
1096
1097         case 0: fDodEdxSigmaTPCCut = kFALSE;
1098                 fPIDnSigmaBelowElectronLineTPC=-10;
1099                 fPIDnSigmaAboveElectronLineTPC=10;
1100                 break;
1101         case 1: // -10,10
1102                 fDodEdxSigmaTPCCut = kTRUE;
1103                 fPIDnSigmaBelowElectronLineTPC=-10;
1104                 fPIDnSigmaAboveElectronLineTPC=10;
1105                 break;
1106         case 2: // -6,7
1107                 fDodEdxSigmaTPCCut = kTRUE;
1108                 fPIDnSigmaBelowElectronLineTPC=-6;
1109                 fPIDnSigmaAboveElectronLineTPC=7;
1110                 break;
1111         case 3: // -5,5
1112                 fDodEdxSigmaTPCCut = kTRUE;
1113                 fPIDnSigmaBelowElectronLineTPC=-5;
1114                 fPIDnSigmaAboveElectronLineTPC=5;
1115                 break;
1116         case 4: // -4,5
1117                 fDodEdxSigmaTPCCut = kTRUE;
1118                 fPIDnSigmaBelowElectronLineTPC=-4;
1119                 fPIDnSigmaAboveElectronLineTPC=5;
1120                 break;  
1121         case 5: // -3,5
1122                 fDodEdxSigmaTPCCut = kTRUE;
1123                 fPIDnSigmaBelowElectronLineTPC=-3;
1124                 fPIDnSigmaAboveElectronLineTPC=5;
1125                 break;
1126         case 6: // -4,4
1127                 fDodEdxSigmaTPCCut = kTRUE;
1128                 fPIDnSigmaBelowElectronLineTPC=-4;
1129                 fPIDnSigmaAboveElectronLineTPC=4;
1130                 break;
1131         case 7: // -2.5,4
1132                 fDodEdxSigmaTPCCut = kTRUE;
1133                 fPIDnSigmaBelowElectronLineTPC=-2.5;
1134                 fPIDnSigmaAboveElectronLineTPC=4;
1135                 break;
1136         case 8: // -2,3.5
1137                 fDodEdxSigmaTPCCut = kTRUE;
1138                 fPIDnSigmaBelowElectronLineTPC=-2;
1139                 fPIDnSigmaAboveElectronLineTPC=3.5;
1140                 break;
1141         default:
1142                 cout<<"Warning: TPCdEdxCutElectronLine not defined"<<ededxSigmaCut<<endl;
1143                 return kFALSE;
1144     
1145         }
1146         return kTRUE;
1147 }
1148
1149 ///________________________________________________________________________
1150 Bool_t AliDalitzElectronCuts::SetTPCdEdxCutPionLine(Int_t pidedxSigmaCut)
1151 {   // Set Cut
1152
1153         switch(pidedxSigmaCut){
1154                 
1155         case 0: fPIDnSigmaAbovePionLineTPC= 0;
1156                 fPIDnSigmaAbovePionLineTPCHighPt=-100;
1157                 break;
1158         case 1:  // -10
1159                 fPIDnSigmaAbovePionLineTPC=3.0;            //Update Sep-05-2013 from -10 to 3
1160                 fPIDnSigmaAbovePionLineTPCHighPt=-10;
1161                 break;
1162         case 2:  // 1
1163                 fPIDnSigmaAbovePionLineTPC=2;              //Update Sep-09-2013 from -1  to  2
1164                 fPIDnSigmaAbovePionLineTPCHighPt=-1;       //Update Sep-09-2013 from -10 to -1
1165                 break;
1166         case 3:   // 0
1167                 fPIDnSigmaAbovePionLineTPC=2;              //Update Sep-09-2013 from   0 to   2
1168                 fPIDnSigmaAbovePionLineTPCHighPt=0;        //Update Sep-09-2013 from -10 to   0
1169                 break;
1170         case 4:  // 1
1171                 fPIDnSigmaAbovePionLineTPC=1;
1172                 fPIDnSigmaAbovePionLineTPCHighPt=-10;
1173                 break;
1174         case 5:  // 1
1175                 fPIDnSigmaAbovePionLineTPC=2.;
1176                 fPIDnSigmaAbovePionLineTPCHighPt=-10;
1177                 break;
1178         case 6:  // 1
1179                 fPIDnSigmaAbovePionLineTPC=2.5;
1180                 fPIDnSigmaAbovePionLineTPCHighPt=-10;
1181                 break;
1182         case 7:
1183                 fPIDnSigmaAbovePionLineTPC = 2.0; // We need a bit less tight cut on dE/dx //Updated from 3.0 and -10 to +2.0 , +2.0 
1184                 fPIDnSigmaAbovePionLineTPCHighPt = 2.0;
1185                 break;
1186         case 8:  // 1
1187                 fPIDnSigmaAbovePionLineTPC = 1.5;   // Updated May-16-2013 from 3.5 and -10 to +1.5, +1
1188                 fPIDnSigmaAbovePionLineTPCHighPt = 1.0;
1189                 break;
1190         case 9:  // 1
1191                 fPIDnSigmaAbovePionLineTPC=1.5;
1192                 fPIDnSigmaAbovePionLineTPCHighPt=-1.0;
1193                 break;
1194         default:
1195                 cout<<"Warning: pidedxSigmaCut not defined "<<pidedxSigmaCut<<endl;
1196                 return kFALSE;
1197         }
1198         return kTRUE;
1199 }
1200
1201 ///________________________________________________________________________
1202 Bool_t AliDalitzElectronCuts::SetMinMomPiondEdxTPCCut(Int_t piMomdedxSigmaCut)
1203 {   // Set Cut
1204         switch(piMomdedxSigmaCut){
1205                 
1206         case 0: fPIDMinPnSigmaAbovePionLineTPC=0.;
1207                 break;
1208         case 1:  // 50.0 GeV
1209                 fPIDMinPnSigmaAbovePionLineTPC=50.;
1210                 break;
1211         case 2:  // 20.0 GeV
1212                 fPIDMinPnSigmaAbovePionLineTPC=20.;
1213                 break;
1214         case 3:  // 1.5 GeV
1215                 fPIDMinPnSigmaAbovePionLineTPC=1.5;
1216                 break;
1217         case 4:  // 1. GeV
1218                 fPIDMinPnSigmaAbovePionLineTPC=1.;
1219                 break;  
1220         case 5:  // 0.5 GeV
1221                 fPIDMinPnSigmaAbovePionLineTPC=0.5;
1222                 break;
1223         case 6:  // 0.4 GeV
1224                 fPIDMinPnSigmaAbovePionLineTPC=0.4;
1225                 break;    
1226         case 7:  // 0.3 GeV
1227                 fPIDMinPnSigmaAbovePionLineTPC=0.3;
1228                 break;
1229         case 8:  // 0.25 GeV
1230                 fPIDMinPnSigmaAbovePionLineTPC=0.25;
1231                 break;
1232         default:
1233                 cout<<"Warning: piMomdedxSigmaCut not defined "<<piMomdedxSigmaCut<<endl;
1234                 return kFALSE;
1235         }
1236         return kTRUE;
1237 }
1238 ///________________________________________________________________________
1239 Bool_t AliDalitzElectronCuts::SetITSClusterCut(Int_t clsITSCut){
1240
1241     
1242         if( !fesdTrackCuts ) {
1243
1244                 cout<<"Warning: AliESDtrackCut is not initialized "<<endl;
1245                 return kFALSE;
1246         }
1247
1248         switch(clsITSCut){
1249
1250         case 0: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kOff);
1251                 break;
1252         case 1: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kFirst);
1253                 break;  //1 hit first layer of SPD
1254         case 2: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
1255                 break; //1 hit in any layer of SPD
1256         case 3: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kFirst);
1257                 fesdTrackCuts->SetMinNClustersITS(4);
1258                 // 4 hits in total in the ITS. At least 1 hit in the first layer of SPD  
1259                 break;
1260         case 4: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
1261                 fesdTrackCuts->SetMinNClustersITS(3);
1262                 // 3 hits in total in the ITS. At least 1 hit in any layer of SPD
1263                 break;
1264         case 5: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
1265                 fesdTrackCuts->SetMinNClustersITS(4);
1266                 // 4 hits in total in the ITS. At least 1 hit in any layer of SPD
1267                 break;
1268         case 6: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
1269                 fesdTrackCuts->SetMinNClustersITS(5);
1270                 // 5 hits in total in the ITS. At least 1 hit in any layer of SPD
1271                 break;
1272         case 7: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kOff);
1273                 fesdTrackCuts->SetMinNClustersITS(4);
1274                 break;
1275         case 8: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kBoth);
1276                 break;
1277         case 9: fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kBoth);
1278                 fesdTrackCuts->SetMinNClustersITS(4);
1279                 break;
1280                 
1281         default:
1282                 cout<<"Warning: clsITSCut not defined "<<clsITSCut<<endl;
1283                 return kFALSE;
1284         }
1285         
1286 return kTRUE;
1287 }
1288
1289 ///________________________________________________________________________
1290 Bool_t AliDalitzElectronCuts::SetTPCClusterCut(Int_t clsTPCCut)
1291 {   // Set Cut
1292         switch(clsTPCCut){
1293         case 0: // 0
1294                 fMinClsTPC= 0.;
1295                 fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
1296                 break;
1297         case 1:  // 70
1298                 fMinClsTPC= 70.;
1299                 fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
1300                 break;
1301         case 2:  // 80
1302                 fMinClsTPC= 80.;
1303                 fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
1304                 break;
1305         case 3:  // Changed 2014-02-04  before fMinClsTPC = 50.;
1306                 fMinClsTPCToF = 0.8;
1307                 fesdTrackCuts->SetMinNCrossedRowsTPC(70);
1308                 fesdTrackCuts->SetMinNClustersTPC(0);
1309                 fUseCrossedRows = kTRUE;
1310                 break;
1311         case 4:  // 0% of findable clusters
1312                 fMinClsTPC= 70.;  
1313                 fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
1314                 fMinClsTPCToF= 0.0;
1315                 fUseCorrectedTPCClsInfo=0;
1316                 break;
1317         case 5:  // 35% of findable clusters
1318                 fMinClsTPC = 70.;  
1319                 fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
1320                 fMinClsTPCToF= 0.35;
1321                 fUseCorrectedTPCClsInfo=0;
1322                 break;
1323         case 6:  // 60% of findable clusters
1324                 fMinClsTPC= 70.;  
1325                 fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
1326                 fMinClsTPCToF= 0.6;
1327                 fUseCorrectedTPCClsInfo=0;
1328                 break;
1329         case 7:  // 60% Changed 2014-02-04 before fMinClsTPC = 0.7 fUseCorrectedTPCClsInfo = 0
1330                  // Changed 2014-02-04  before fMinClsTPC = 50.;
1331                 fMinClsTPCToF = 0.6;
1332                 fesdTrackCuts->SetMinNCrossedRowsTPC(70);
1333                 fesdTrackCuts->SetMinNClustersTPC(0);
1334                 fUseCrossedRows = kTRUE;
1335                 break;
1336         case 8: fMinClsTPC = 0.;  
1337                 fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
1338                 fMinClsTPCToF= 0.35;
1339                 fUseCorrectedTPCClsInfo=0;
1340                 break;
1341         case 9:  // 35% of findable clusters
1342                 fMinClsTPC = 70.;  
1343                 fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
1344                 fMinClsTPCToF= 0.35;
1345                 fUseCorrectedTPCClsInfo=1;
1346                 break;
1347           
1348         default:
1349                 cout<<"Warning: clsTPCCut not defined "<<clsTPCCut<<endl;
1350                 return kFALSE;
1351         }
1352         return kTRUE;
1353 }
1354
1355 ///________________________________________________________________________
1356 Bool_t AliDalitzElectronCuts::SetEtaCut(Int_t etaCut)
1357
1358   // Set eta Cut
1359         switch(etaCut){
1360         case 0: 
1361                 fEtaCut = 100.;
1362                 fDoEtaCut = kFALSE;
1363                 break;
1364         case 1: // 1.4
1365                 fEtaCut = 1.4;
1366                 fDoEtaCut = kTRUE;
1367                 break;
1368         case 2: // 1.2
1369                 fEtaCut = 1.2;
1370                 fDoEtaCut = kTRUE;
1371                 break;
1372         case 3: // 0.9
1373                 fEtaCut = 0.9;
1374                 fDoEtaCut = kTRUE;
1375                 break;
1376         case 4: // 0.8
1377                 fEtaCut = 0.8;
1378                 fDoEtaCut = kTRUE;
1379                 break;
1380         case 5: // 0.75
1381                 fEtaCut = 0.75;
1382                 fDoEtaCut = kTRUE;
1383                 break;
1384         case 6: //0.6
1385                 fEtaCut = 0.6; //changed from 0.4 to 0.6 2013.06.10
1386                 fDoEtaCut = kTRUE;
1387                 break;
1388         case 7: //0.5
1389                 fEtaCut = 0.5; //changed from 0.3 to 0.5 2013.06.10
1390                 fDoEtaCut = kTRUE;
1391                 break;
1392         case 8: fEtaCut = 0.4;
1393                 fDoEtaCut = kTRUE;
1394                 break;
1395         case 9: fEtaCut = 0.65;
1396                 fDoEtaCut = kTRUE; 
1397                 break;
1398         default:
1399                 cout<<"Warning: EtaCut not defined "<<etaCut<<endl;
1400                 return kFALSE;
1401         }
1402         return kTRUE;
1403 }
1404
1405 ///________________________________________________________________________
1406 Bool_t AliDalitzElectronCuts::SetPtCut(Int_t ptCut)
1407
1408         // Set Pt Cut
1409          //0.1GeV, 0.125 GeV, 0.15 GeV
1410   
1411         switch(ptCut){
1412           
1413         case 0: fPtMinCut = 0.075;
1414                 fPtMaxCut = 9999;
1415                 break;
1416         case 1:  // 0.1
1417                 fPtMinCut  = 0.1;       
1418                 fPtMaxCut  = 9999;
1419                 break;
1420         case 2:  // 0.125 GeV
1421                 fPtMinCut = 0.125;              
1422                 fPtMaxCut = 9999;
1423                 break;
1424         case 3: // 0.15 GeV
1425                 fPtMinCut = 0.15;
1426                 fPtMaxCut = 9999;
1427                 break;
1428                 // 0.5 - 0.7 
1429         case 4: fPtMinCut = 0.5;
1430                 fPtMaxCut = 0.7;
1431                 break;
1432         case 5: // 0.175 GeV
1433                 fPtMinCut = 0.175;
1434                 fPtMaxCut = 9999;
1435                 break;
1436         default:
1437                 cout<<"Warning: PtCut not defined "<<ptCut<<endl;
1438                 return kFALSE;
1439         }
1440         return kTRUE;
1441 }
1442
1443
1444 ///________________________________________________________________________
1445 Bool_t AliDalitzElectronCuts::SetDCACut(Int_t dcaCut)
1446
1447   // Set DCA Cut
1448   
1449         if( !fesdTrackCuts ) {
1450
1451                 cout<<"Warning: AliESDtrackCut is not initialized "<<endl;
1452                 return kFALSE;
1453         }
1454   
1455         switch(dcaCut){
1456           
1457         case 0: 
1458                 //Open cuts//
1459                 fesdTrackCuts->SetMaxDCAToVertexZ(1000);
1460                 fesdTrackCuts->SetMaxDCAToVertexXY(1000);
1461                 fesdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36);
1462                 break;
1463                
1464         case 1: 
1465                 fesdTrackCuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");
1466                 fesdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36);
1467                 
1468                 break;
1469         case 2: fesdTrackCuts->SetMaxDCAToVertexZ(2);
1470                 fesdTrackCuts->SetMaxDCAToVertexXY(1);
1471                 fesdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36);
1472                 break; 
1473                 
1474         case 3: fesdTrackCuts->SetMaxDCAToVertexXYPtDep("0.0105+0.0350/pt^1.1");
1475                 fesdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36);
1476                 break;
1477                 
1478         default:
1479                 cout<<"Warning: dcaCut not defined "<<dcaCut<<endl;
1480                 return kFALSE;
1481         }
1482         return kTRUE;
1483 }
1484
1485
1486
1487
1488 ///________________________________________________________________________
1489 Bool_t AliDalitzElectronCuts::SetMaxMomPiondEdxTPCCut(Int_t piMaxMomdedxSigmaCut)
1490 {   // Set Cut
1491    switch(piMaxMomdedxSigmaCut){
1492
1493          case 0: 
1494                  fPIDMaxPnSigmaAbovePionLineTPC=0.;
1495                  break;
1496          case 1:  // 100. GeV
1497                  fPIDMaxPnSigmaAbovePionLineTPC=100.;
1498                  break;
1499          case 2:  // 5. GeV
1500                  fPIDMaxPnSigmaAbovePionLineTPC=5.;
1501                         break;
1502          case 3:  // 4. GeV
1503                  fPIDMaxPnSigmaAbovePionLineTPC=4.;
1504                  break;
1505          case 4:  // 3.5 GeV
1506                  fPIDMaxPnSigmaAbovePionLineTPC=3.5;
1507                  break;
1508          case 5:  // 3. GeV
1509                  fPIDMaxPnSigmaAbovePionLineTPC=3.;
1510                  break;
1511          default:
1512                  cout<<"Warning: piMaxMomdedxSigmaCut not defined "<<piMaxMomdedxSigmaCut<<endl;
1513                  return kFALSE;
1514          }
1515          return kTRUE;
1516 }
1517
1518 ///________________________________________________________________________
1519 Bool_t AliDalitzElectronCuts::SetLowPRejectionCuts(Int_t LowPRejectionSigmaCut)
1520 {   // Set Cut
1521         switch(LowPRejectionSigmaCut){
1522         case 0:  //
1523                 fDoKaonRejectionLowP=kFALSE;
1524                 fDoProtonRejectionLowP=kFALSE;
1525                 fDoPionRejectionLowP=kFALSE;
1526                 fPIDnSigmaAtLowPAroundKaonLine=0;
1527                 fPIDnSigmaAtLowPAroundProtonLine=0;
1528                 fPIDnSigmaAtLowPAroundPionLine=0;
1529                 fPIDMinPPionRejectionLowP = fPIDMinPnSigmaAbovePionLineTPC;
1530                 break;
1531         case 1:  //
1532                 fDoKaonRejectionLowP=kTRUE;
1533                 fDoProtonRejectionLowP=kTRUE;
1534                 fDoPionRejectionLowP=kTRUE;
1535                 fPIDnSigmaAtLowPAroundKaonLine=0.5;
1536                 fPIDnSigmaAtLowPAroundProtonLine=0.5;
1537                 fPIDnSigmaAtLowPAroundPionLine=0.5;
1538                 fPIDMinPPionRejectionLowP = fPIDMinPnSigmaAbovePionLineTPC;
1539                 break;
1540         case 2:  //
1541                 fDoKaonRejectionLowP=kTRUE;
1542                 fDoProtonRejectionLowP=kTRUE;
1543                 fDoPionRejectionLowP=kTRUE;
1544                 fPIDnSigmaAtLowPAroundKaonLine=1.0;
1545                 fPIDnSigmaAtLowPAroundProtonLine=1.0;
1546                 fPIDnSigmaAtLowPAroundPionLine=1.0;
1547                 fPIDMinPPionRejectionLowP = fPIDMinPnSigmaAbovePionLineTPC;
1548                 break;
1549         case 3:  //
1550                 fDoKaonRejectionLowP=kTRUE;
1551                 fDoProtonRejectionLowP=kTRUE;
1552                 fDoPionRejectionLowP=kTRUE;
1553                 fPIDnSigmaAtLowPAroundKaonLine=1.5;
1554                 fPIDnSigmaAtLowPAroundProtonLine=1.5;
1555                 fPIDnSigmaAtLowPAroundPionLine=1.5;
1556                 fPIDMinPPionRejectionLowP = fPIDMinPnSigmaAbovePionLineTPC;
1557                 break;
1558         case 4:  //
1559                 fDoKaonRejectionLowP=kTRUE;
1560                 fDoProtonRejectionLowP=kTRUE;
1561                 fDoPionRejectionLowP=kTRUE;
1562                 fPIDnSigmaAtLowPAroundKaonLine=2.0;
1563                 fPIDnSigmaAtLowPAroundProtonLine=2.0;
1564                 fPIDnSigmaAtLowPAroundPionLine=2.0;
1565                 fPIDMinPPionRejectionLowP = fPIDMinPnSigmaAbovePionLineTPC;
1566                 break;
1567         case 5:  //
1568                 fDoKaonRejectionLowP=kTRUE;
1569                 fDoProtonRejectionLowP=kTRUE;
1570                 fDoPionRejectionLowP=kTRUE;
1571                 fPIDnSigmaAtLowPAroundKaonLine=2.0;
1572                 fPIDnSigmaAtLowPAroundProtonLine=2.0;
1573                 fPIDnSigmaAtLowPAroundPionLine=2.5;
1574                 fPIDMinPPionRejectionLowP = fPIDMinPnSigmaAbovePionLineTPC;
1575                 break;
1576         case 6:  //
1577                 fDoKaonRejectionLowP=kTRUE;
1578                 fDoProtonRejectionLowP=kTRUE;
1579                 fDoPionRejectionLowP=kTRUE;
1580                 fPIDnSigmaAtLowPAroundKaonLine=0.;
1581                 fPIDnSigmaAtLowPAroundProtonLine=0.;
1582                 fPIDnSigmaAtLowPAroundPionLine=2.;
1583                 fPIDMinPPionRejectionLowP = fPIDMinPnSigmaAbovePionLineTPC;
1584                 break;
1585         case 7: //
1586                 fDoKaonRejectionLowP=kFALSE;
1587                 fDoProtonRejectionLowP=kFALSE;
1588                 fDoPionRejectionLowP=kTRUE;
1589                 fPIDnSigmaAtLowPAroundKaonLine=0.0;
1590                 fPIDnSigmaAtLowPAroundProtonLine=0.0;
1591                 fPIDnSigmaAtLowPAroundPionLine=1.0;
1592                 fPIDMinPPionRejectionLowP = fPIDMinPnSigmaAbovePionLineTPC;
1593                 break;
1594         case 8:
1595                 fDoKaonRejectionLowP=kFALSE;
1596                 fDoProtonRejectionLowP=kFALSE;
1597                 fDoPionRejectionLowP=kTRUE;
1598                 fPIDnSigmaAtLowPAroundKaonLine=0.;
1599                 fPIDnSigmaAtLowPAroundProtonLine=0.;
1600                 fPIDnSigmaAtLowPAroundPionLine=0.5; 
1601                 fPIDMinPPionRejectionLowP = fPIDMinPnSigmaAbovePionLineTPC;
1602                 break;  
1603         default:
1604                 cout<<"Warning: LowPRejectionSigmaCut not defined "<<LowPRejectionSigmaCut<<endl;
1605                 return kFALSE;
1606         }
1607         return kTRUE;
1608 }
1609
1610 ///________________________________________________________________________
1611 Bool_t AliDalitzElectronCuts::SetTOFElectronPIDCut(Int_t TOFelectronPID){
1612     // Set Cut
1613         switch(TOFelectronPID){ // RRnewTOF start //////////////////////////////////////////////////////////////////////////
1614         case 0: // no cut
1615                 fRequireTOF = kFALSE;
1616                 fUseTOFpid = kFALSE;
1617                 fTofPIDnSigmaBelowElectronLine=-100;
1618                 fTofPIDnSigmaAboveElectronLine=100;
1619                 break;
1620         case 1: // -7,7
1621                 fRequireTOF = kFALSE;
1622                 fUseTOFpid = kTRUE;
1623                 fTofPIDnSigmaBelowElectronLine=-7;
1624                 fTofPIDnSigmaAboveElectronLine=7;
1625                 break;
1626         case 2: // -5,5
1627                 fRequireTOF = kFALSE;
1628                 fUseTOFpid = kTRUE;
1629                 fTofPIDnSigmaBelowElectronLine=-5;
1630                 fTofPIDnSigmaAboveElectronLine=5;
1631                 break;
1632         case 3: // -3,5
1633                 fRequireTOF = kFALSE;
1634                 fUseTOFpid = kTRUE;
1635                 fTofPIDnSigmaBelowElectronLine=-3;
1636                 fTofPIDnSigmaAboveElectronLine=5;
1637                 break;
1638         case 4: // -2,3
1639                 fRequireTOF = kFALSE;
1640                 fUseTOFpid = kTRUE;
1641                 fTofPIDnSigmaBelowElectronLine=-2;
1642                 fTofPIDnSigmaAboveElectronLine=3;
1643                 break;
1644         case 5: // -3, 3 TOF mandatory
1645                 fRequireTOF = kTRUE;
1646                 fUseTOFpid  = kTRUE;
1647                 fTofPIDnSigmaBelowElectronLine= -3;
1648                 fTofPIDnSigmaAboveElectronLine=  3;
1649                 break;
1650         default:
1651         cout<<"Warning: TOFElectronCut not defined "<<TOFelectronPID<<endl;
1652         return kFALSE;
1653     } //////////////////////// RRnewTOF end //////////////////////////////////////////////////////////////////////////
1654     return kTRUE;
1655 }
1656 ///_______________________________________________________________________________
1657
1658 Bool_t AliDalitzElectronCuts::SetPsiPairCut(Int_t psiCut) {
1659   
1660
1661   switch(psiCut) {
1662   case 0:
1663         fDoPsiPairCut = kFALSE;
1664         fPsiPairCut = 10000.; //
1665         fDeltaPhiCutMin = -1000.;
1666         fDeltaPhiCutMax =  1000.;
1667         
1668         break;
1669   case 1:
1670         fDoPsiPairCut = kTRUE;
1671         fPsiPairCut = 0.45; // Standard
1672         fDeltaPhiCutMin = 0.0;
1673         fDeltaPhiCutMax = 0.12;
1674         break;
1675   case 2:
1676         fDoPsiPairCut = kTRUE;
1677         fPsiPairCut = 0.60; 
1678         fDeltaPhiCutMin = 0.0;
1679         fDeltaPhiCutMax = 0.12;
1680         break;
1681   case 3:
1682         fDoPsiPairCut = kTRUE;
1683         fPsiPairCut = 0.52;
1684         fDeltaPhiCutMin = 0.0;
1685         fDeltaPhiCutMax = 0.12;
1686         break;
1687   case 4:
1688         fDoPsiPairCut = kTRUE;
1689         fPsiPairCut = 0.30;
1690         fDeltaPhiCutMin = 0.0;
1691         fDeltaPhiCutMax = 0.12;
1692         break;
1693     
1694   default:
1695       cout<<"Warning: PsiPairCut not defined "<<fPsiPairCut<<endl;
1696       return kFALSE;
1697   }
1698
1699   return kTRUE;
1700 }
1701
1702 ///_______________________________________________________________________________
1703 Bool_t AliDalitzElectronCuts::SetRejectSharedElecGamma(Int_t RCut) {
1704   
1705
1706   switch(RCut) {
1707   case 0:
1708         fDoRejectSharedElecGamma = kFALSE;
1709         fRadiusCut = 10000; // 
1710         break;
1711   case 1:
1712         fDoRejectSharedElecGamma = kTRUE;
1713         fRadiusCut = 2.0; // cm 
1714         break;
1715   case 2:
1716         fDoRejectSharedElecGamma = kTRUE;
1717         fRadiusCut = 3.0; // Standard
1718         break;
1719   case 3:
1720         fDoRejectSharedElecGamma = kTRUE;
1721         fRadiusCut = 4.0; // 
1722         break;
1723   case 4:
1724         fDoRejectSharedElecGamma = kTRUE;
1725         fRadiusCut = 5.0; // 
1726         break;
1727   case 5:
1728         fDoRejectSharedElecGamma = kTRUE;
1729         fRadiusCut = 10.0; // 
1730         break;
1731   case 6:
1732         fDoRejectSharedElecGamma = kTRUE;
1733         fRadiusCut = 15.0; // 
1734         break;
1735   default:
1736       cout<<"Warning: PsiPairCut not defined "<<fDoRejectSharedElecGamma<<endl;
1737       return kFALSE;
1738   }
1739
1740   return kTRUE;
1741 }
1742 ///__________________________________________________________________________
1743 Bool_t AliDalitzElectronCuts::SetBackgroundScheme(Int_t BackgroundScheme){
1744
1745     // Set Cut
1746     switch(BackgroundScheme){
1747
1748     case 0: //Rotation
1749             fBKGMethod = 0;
1750             fUseTrackMultiplicityForBG = kFALSE;
1751         break;
1752     case 1: // mixed event with V0 multiplicity
1753             fBKGMethod  = 1;
1754             fUseTrackMultiplicityForBG = kFALSE;
1755         break;
1756     case 2: // mixed event with track multiplicity
1757             fUseTrackMultiplicityForBG = kTRUE;
1758             fBKGMethod  = 1;
1759         break;
1760     case 3: //Rotation
1761            fUseTrackMultiplicityForBG = kFALSE;
1762             fBKGMethod  = 2;
1763         break;
1764     case 4: //Rotation
1765             fUseTrackMultiplicityForBG = kTRUE;
1766             fBKGMethod  = 2;
1767         break;
1768     case 5: fUseTrackMultiplicityForBG = kTRUE;
1769             fBKGMethod  = 3;
1770         break;
1771
1772     default:
1773         cout<<"Warning: BackgroundScheme not defined "<<BackgroundScheme<<endl;
1774         return kFALSE;
1775     }
1776     return kTRUE;
1777 }
1778
1779 ///________________________________________________________________________
1780 Bool_t AliDalitzElectronCuts::SetNumberOfRotations(Int_t NumberOfRotations)
1781 {   // Set Cut
1782     switch(NumberOfRotations){
1783     case 0:
1784         fnumberOfRotationEventsForBG = 5;
1785         break;
1786     case 1:
1787         fnumberOfRotationEventsForBG = 10;
1788         break;
1789     case 2:
1790         fnumberOfRotationEventsForBG = 15;
1791         break;
1792     case 3:
1793         fnumberOfRotationEventsForBG = 20;
1794         break;
1795     case 4:
1796         fnumberOfRotationEventsForBG = 2;
1797         break;
1798     case 5:
1799         fnumberOfRotationEventsForBG = 50;
1800         break;
1801     case 6:
1802         fnumberOfRotationEventsForBG = 80;
1803         break;
1804     case 7:
1805         fnumberOfRotationEventsForBG = 100;
1806         break;
1807     default:
1808         cout<<"Warning: NumberOfRotations not defined "<<NumberOfRotations<<endl;
1809         return kFALSE;
1810     }
1811     return kTRUE;
1812 }
1813
1814
1815
1816 ///________________________________________________________________________
1817 Bool_t AliDalitzElectronCuts::SetDoWeights(Int_t opc)
1818 {   // Set Cut
1819     switch(opc){
1820       
1821     case 0:             fDoWeights = kFALSE;
1822                         break;
1823     case 1:             fDoWeights = kTRUE;
1824                         break; 
1825     default:
1826                         cout<<"Warning: Weights option not defined "<<opc<<endl;
1827                         return kFALSE;
1828     }
1829     return kTRUE;
1830 }
1831 ///________________________________________________________________________
1832 Bool_t AliDalitzElectronCuts::SetMassCut(Int_t massCut)
1833 {   // Set Cut
1834     switch(massCut){
1835       
1836     case 0:
1837                         
1838                         fMassCutPtMin  = -999.; //GeV
1839                         fMassCutLowPt  =  999.; //GeV/c^2
1840                         fMassCutHighPt =  999.; //GeV/c^2
1841                         fMassMinCut = -999;
1842                         fDoMassCut = kFALSE;   
1843                         fDoMassMinCut = kFALSE;
1844                         break;
1845     case 1:
1846                         //fMassCut = 0.135;             //GeV/c^2
1847                         fMassCutPtMin  = -999.; //GeV
1848                         fMassCutLowPt  = 0.135; //GeV/c^2
1849                         fMassCutHighPt = 0.135; //GeV/c^2
1850                         fMassMinCut = -999;
1851                         fDoMassCut = kTRUE;
1852                         fDoMassMinCut = kFALSE;
1853                         break; 
1854     case 2:
1855                         //fMassCut = 0.100;     //GeV/c^2
1856                         fMassCutPtMin  = -999.; //GeV
1857                         fMassCutLowPt  = 0.100; //GeV/c^2
1858                         fMassCutHighPt = 0.100; //GeV/c^2
1859                         fMassMinCut = -999;
1860                         fDoMassCut = kTRUE;
1861                         fDoMassMinCut = kFALSE;
1862                         break;
1863     case 3:
1864                         /*fMassCut = 0.075;     //GeV/c^2 Changed from Feb 25
1865                         fMassCutPtMin  = -999.; //GeV
1866                         fMassCutLowPt  = 0.075; //GeV/c^2
1867                         fMassCutHighPt = 0.075; //GeV/c^2
1868                         fDoMassCut = kTRUE;
1869                         fDoMassMinCut = kFALSE;*/
1870                         fMassCutPtMin  = 1.0;   //GeV
1871                         fMassCutLowPt  = 0.015; //GeV/c^2
1872                         fMassCutHighPt = 0.035; //GeV/c^2
1873                         fMassMinCut    = 0.002;
1874                         fDoMassCut = kTRUE;
1875                         fDoMassMinCut = kTRUE;
1876                         break;
1877     case 4:
1878                         //fMassCut = 0.050;     //GeV/c^2
1879                         fMassCutPtMin  = -999.; //GeV
1880                         fMassCutLowPt  = 0.050; //GeV/c^2
1881                         fMassCutHighPt = 0.050; //GeV/c^2
1882                         fMassMinCut = -999;
1883                         fDoMassCut = kTRUE;
1884                         fDoMassMinCut = kFALSE;
1885                         break;
1886     case 5:
1887                         
1888                         fMassCutPtMin  = -999.; //GeV
1889                         fMassCutLowPt  = 0.035; //GeV/c^2
1890                         fMassCutHighPt = 0.035; //GeV/c^2
1891                         fMassMinCut = -999;
1892                         fDoMassCut = kTRUE;
1893                         fDoMassMinCut = kFALSE;
1894                         break;
1895     case 6:
1896                         fMassCutPtMin  = -999.; //GeV
1897                         fMassCutLowPt  = 0.015; //GeV/c^2
1898                         fMassCutHighPt = 0.015; //GeV/c^2
1899                         fMassMinCut = -999;
1900                         fDoMassCut = kTRUE;
1901                         fDoMassMinCut = kFALSE;
1902                         break;
1903     case 7:             fMassCutPtMin  = 1.0;   //GeV
1904                         fMassCutLowPt  = 0.015; //GeV/c^2
1905                         fMassCutHighPt = 0.035; //GeV/c^2
1906                         fMassMinCut = -999;
1907                         fDoMassCut = kTRUE;
1908                         fDoMassMinCut = kFALSE;
1909                         break;
1910     case 8:             fMassCutPtMin  = 1.0;   //GeV
1911                         fMassCutLowPt  = 0.015; //GeV/c^2
1912                         fMassCutHighPt = 0.050; //GeV/c^2
1913                         fMassMinCut = -999;
1914                         fDoMassCut = kTRUE;
1915                         fDoMassMinCut = kFALSE;
1916                         break;
1917     case 9:             fMassCutPtMin  = 1.0;   //GeV
1918                         fMassCutLowPt  = 0.025; //GeV/c^2
1919                         fMassCutHighPt = 0.035; //GeV/c^2
1920                         fMassMinCut = -999;
1921                         fDoMassCut = kTRUE;
1922                         fDoMassMinCut = kFALSE;
1923                         break;
1924     default:
1925                         cout<<"Warning: MassCut not defined "<<massCut<<endl;
1926                         return kFALSE;
1927     }
1928     return kTRUE;
1929 }
1930 Bool_t AliDalitzElectronCuts::SetUseVPhotonMCPmearing(Int_t useMCPSmearing)
1931 {// Set Cut
1932    switch(useMCPSmearing){
1933      
1934    case 0:
1935       fUseVPhotonMCPSmearing=kFALSE;
1936       break;
1937    case 1:
1938       fUseVPhotonMCPSmearing=kTRUE;
1939       break;
1940       
1941    default: cout<<"Warning: MassCut not defined "<<useMCPSmearing<<endl;
1942             return kFALSE;
1943       
1944    }
1945    
1946    return kTRUE;
1947 }
1948
1949
1950 ///________________________________________________________________________
1951 TString AliDalitzElectronCuts::GetCutNumber(){
1952     // returns TString with current cut number
1953   TString a(kNCuts);
1954   for(Int_t ii=0;ii<kNCuts;ii++){
1955         a.Append(Form("%d",fCuts[ii]));
1956   }
1957   return a;
1958 }
1959
1960
1961 ///________________________________________________________________________
1962 AliDalitzElectronCuts* AliDalitzElectronCuts::GetStandardCuts2010PbPb(){
1963     //Create and return standard 2010 PbPb cuts
1964     AliDalitzElectronCuts *cuts=new AliDalitzElectronCuts("StandardCuts2010PbPb","StandardCuts2010PbPb");
1965     if(!cuts->InitializeCutsFromCutString("9069640364102")){
1966         cout<<"Warning: Initialization of Standardcuts2010PbPb failed"<<endl;}
1967     return cuts;
1968 }
1969
1970 ///________________________________________________________________________
1971 AliDalitzElectronCuts* AliDalitzElectronCuts::GetStandardCuts2010pp(){
1972     //Create and return standard 2010 PbPb cuts
1973     AliDalitzElectronCuts *cuts=new AliDalitzElectronCuts("StandardCuts2010pp","StandardCuts2010pp");
1974                                           
1975     if(!cuts->InitializeCutsFromCutString("9069640364102")){
1976         cout<<"Warning: Initialization of Standardcuts2010pp failed"<<endl;}
1977      return cuts;
1978 }
1979