efa58f2e55e07eb60a330c36237cfbf235f7cae7
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / AliDalitzElectronCuts.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
24 #include "AliDalitzElectronCuts.h"
25 #include "AliAODConversionPhoton.h"
26 #include "AliKFVertex.h"
27 #include "AliAODTrack.h"
28 #include "AliESDtrack.h"
29 #include "AliAnalysisManager.h"
30 #include "AliInputEventHandler.h"
31 #include "AliMCEventHandler.h"
32 #include "AliAODHandler.h"
33 #include "AliPIDResponse.h"
34 #include "TH1.h"
35 #include "TH2.h"
36 #include "AliStack.h"
37 #include "TObjString.h"
38 #include "AliAODEvent.h"
39 #include "AliESDEvent.h"
40 #include "TList.h"
41 class iostream;
42
43 using namespace std;
44
45 ClassImp(AliDalitzElectronCuts)
46
47
48 const char* AliDalitzElectronCuts::fgkCutNames[AliDalitzElectronCuts::kNCuts] = {
49 "GoodId",
50 "ededxSigmaITSCut",
51 "ededxSigmaTPCCut",
52 "pidedxSigmaTPCCut",
53 "piMinMomdedxSigmaTPCCut",
54 "piMaxMomdedxSigmaTPCCut",
55 "LowPRejectionSigmaCut",
56 "kTOFelectronPID",
57 "clsTPCCut",
58 "EtaCut",
59 "PsiPair",
60 "RejectSharedElecGamma",
61 "BackgroundScheme",
62 };
63
64 //________________________________________________________________________
65 AliDalitzElectronCuts::AliDalitzElectronCuts(const char *name,const char *title) : AliAnalysisCuts(name,title),
66     fHistograms(NULL),
67     fPIDResponse(NULL),
68     fesdTrackCuts(0),
69     fEtaCut(0.9),
70     fRadiusCut(1000.0),
71     fPsiPairCut(0.45),
72     fDeltaPhiCutMin(0.),
73     fDeltaPhiCutMax(0.12),
74     fMinClsTPC(0), // minimum clusters in the TPC
75     fMinClsTPCToF(0), // minimum clusters to findable clusters
76     fDodEdxSigmaITSCut(kFALSE),
77     fDodEdxSigmaTPCCut(kTRUE),
78     fDoTOFsigmaCut(kFALSE), // RRnewTOF
79     fDoRejectSharedElecGamma(kFALSE),
80     fDoPsiPairCut(kFALSE),
81     fPIDnSigmaAboveElectronLineITS(100),
82     fPIDnSigmaBelowElectronLineITS(-100),
83     fPIDnSigmaAboveElectronLineTPC(100),
84     fPIDnSigmaBelowElectronLineTPC(-100),
85     fPIDnSigmaAbovePionLineTPC(0),
86     fPIDnSigmaAbovePionLineTPCHighPt(-100),
87     fTofPIDnSigmaAboveElectronLine(100), // RRnewTOF
88     fTofPIDnSigmaBelowElectronLine(-100), // RRnewTOF
89     fPIDMinPnSigmaAbovePionLineTPC(0),
90     fPIDMaxPnSigmaAbovePionLineTPC(0),
91     fDoKaonRejectionLowP(kFALSE),
92     fDoProtonRejectionLowP(kFALSE),
93     fDoPionRejectionLowP(kFALSE),
94     fPIDnSigmaAtLowPAroundKaonLine(0),
95     fPIDnSigmaAtLowPAroundProtonLine(0),
96     fPIDnSigmaAtLowPAroundPionLine(0),
97     fPIDMinPKaonRejectionLowP(1.5),
98     fPIDMinPProtonRejectionLowP(2.0),
99     fPIDMinPPionRejectionLowP(0.5),
100     fUseCorrectedTPCClsInfo(kFALSE),
101     fUseTOFpid(kFALSE),
102     fUseTrackMultiplicityForBG(kFALSE),
103     fBKGMethod(0),
104     fCutString(NULL),
105     hCutIndex(NULL),
106     hdEdxCuts(NULL),
107     hITSdEdxbefore(NULL),
108     hITSdEdxafter(NULL),
109     hTPCdEdxbefore(NULL),
110     hTPCdEdxafter(NULL),
111     hTOFbefore(NULL),
112     hTOFafter(NULL)
113    {
114     InitPIDResponse();
115     for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=0;}
116     fCutString=new TObjString((GetCutNumber()).Data());
117
118
119     fesdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts");
120
121    // Using standard function for setting Cuts
122     Bool_t selectPrimaries=kTRUE;
123     fesdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(selectPrimaries);
124 }
125
126 //________________________________________________________________________
127 AliDalitzElectronCuts::~AliDalitzElectronCuts() {
128     // Destructor
129   //Deleting fHistograms leads to seg fault it it's added to output collection of a task
130   // if(fHistograms)
131   //    delete fHistograms;
132   // fHistograms = NULL;
133
134    if(fCutString != NULL){
135       delete fCutString;
136       fCutString = NULL;
137    }
138
139
140 }
141
142 //________________________________________________________________________
143 void AliDalitzElectronCuts::InitCutHistograms(TString name, Bool_t preCut){
144
145     // Initialize Cut Histograms for QA (only initialized and filled if function is called)
146
147
148     if(fHistograms != NULL){
149         delete fHistograms;
150         fHistograms=NULL;
151     }
152     if(fHistograms==NULL){
153         fHistograms=new TList();
154         if(name=="")fHistograms->SetName(Form("ElectronCuts_%s",GetCutNumber().Data()));
155         else fHistograms->SetName(Form("%s_%s",name.Data(),GetCutNumber().Data()));
156     }
157
158
159     hCutIndex=new TH1F(Form("IsElectronSelected %s",GetCutNumber().Data()),"IsElectronSelected",10,-0.5,9.5);
160     hCutIndex->GetXaxis()->SetBinLabel(kElectronIn+1,"in");
161     hCutIndex->GetXaxis()->SetBinLabel(kNoTracks+1,"no tracks");
162     hCutIndex->GetXaxis()->SetBinLabel(kTrackCuts+1,"Track cuts");
163     hCutIndex->GetXaxis()->SetBinLabel(kdEdxCuts+1,"dEdx");
164     hCutIndex->GetXaxis()->SetBinLabel(kElectronOut+1,"out");
165     fHistograms->Add(hCutIndex);
166
167
168
169     // dEdx Cuts
170     hdEdxCuts=new TH1F(Form("dEdxCuts %s",GetCutNumber().Data()),"dEdxCuts",10,-0.5,9.5);
171     hdEdxCuts->GetXaxis()->SetBinLabel(1,"in");
172     hdEdxCuts->GetXaxis()->SetBinLabel(2,"ITSelectron");
173     hdEdxCuts->GetXaxis()->SetBinLabel(3,"TPCelectron");
174     hdEdxCuts->GetXaxis()->SetBinLabel(4,"TPCpion");
175     hdEdxCuts->GetXaxis()->SetBinLabel(5,"TPCpionhighp");
176     hdEdxCuts->GetXaxis()->SetBinLabel(6,"TPCkaonlowprej");
177     hdEdxCuts->GetXaxis()->SetBinLabel(7,"TPCprotonlowprej");
178     hdEdxCuts->GetXaxis()->SetBinLabel(8,"TPCpionlowprej");
179     hdEdxCuts->GetXaxis()->SetBinLabel(9,"TOFelectron");
180     hdEdxCuts->GetXaxis()->SetBinLabel(10,"out");
181     fHistograms->Add(hdEdxCuts);
182     
183
184
185     TAxis *AxisBeforeITS = NULL;
186     TAxis *AxisBeforedEdx = NULL;
187     TAxis *AxisBeforeTOF = NULL;
188
189     if(preCut){
190
191
192        hITSdEdxbefore=new TH2F(Form("Electron_ITS_before %s",GetCutNumber().Data()),"ITS dEdx electron before" ,150,0.05,20,400,-10,10);
193        fHistograms->Add(hITSdEdxbefore);
194        AxisBeforeITS = hITSdEdxbefore->GetXaxis();
195
196        hTPCdEdxbefore=new TH2F(Form("Electron_dEdx_before %s",GetCutNumber().Data()),"dEdx electron before" ,150,0.05,20,400,-10,10);
197        fHistograms->Add(hTPCdEdxbefore);
198        AxisBeforedEdx = hTPCdEdxbefore->GetXaxis();
199
200        hTOFbefore=new TH2F(Form("Electron_TOF_before %s",GetCutNumber().Data()),"TOF electron before" ,150,0.05,20,400,-6,10);
201        fHistograms->Add(hTOFbefore);
202        AxisBeforeTOF = hTOFbefore->GetXaxis();
203
204     }
205
206
207     hITSdEdxafter=new TH2F(Form("Electron_ITS_after %s",GetCutNumber().Data()),"ITS dEdx electron after" ,150,0.05,20,400, -10,10);
208     fHistograms->Add(hITSdEdxafter);
209
210     hTPCdEdxafter=new TH2F(Form("Electron_dEdx_after %s",GetCutNumber().Data()),"dEdx electron after" ,150,0.05,20,400, -10,10);
211     fHistograms->Add(hTPCdEdxafter);
212
213     hTOFafter=new TH2F(Form("Electron_TOF_after %s",GetCutNumber().Data()),"TOF electron after" ,150,0.05,20,400,-6,10);
214     fHistograms->Add(hTOFafter);
215
216     TAxis *AxisAfter = hTPCdEdxafter->GetXaxis(); 
217     Int_t bins = AxisAfter->GetNbins();
218     Double_t from = AxisAfter->GetXmin();
219     Double_t to = AxisAfter->GetXmax();
220     Double_t *newBins = new Double_t[bins+1];
221     newBins[0] = from;
222     Double_t factor = TMath::Power(to/from, 1./bins);
223     for(Int_t i=1; i<=bins; ++i) newBins[i] = factor * newBins[i-1];
224     AxisAfter->Set(bins, newBins);
225     AxisAfter = hTOFafter->GetXaxis(); 
226     AxisAfter->Set(bins, newBins);
227          AxisAfter = hITSdEdxafter->GetXaxis(); 
228     AxisAfter->Set(bins, newBins);
229
230     if(preCut){
231        AxisBeforeITS->Set(bins, newBins);
232        AxisBeforedEdx->Set(bins, newBins);
233        AxisBeforeTOF->Set(bins, newBins);
234     }
235     delete [] newBins;
236
237         
238     // Event Cuts and Info
239 }
240
241
242 //________________________________________________________________________
243 Bool_t AliDalitzElectronCuts::InitPIDResponse(){
244
245 // Set Pointer to AliPIDResponse
246
247   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
248
249   if(man) {
250
251     AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
252     fPIDResponse = (AliPIDResponse*)inputHandler->GetPIDResponse();
253     if(fPIDResponse)return kTRUE;
254
255   }
256
257   return kFALSE;
258 }
259
260 ///________________________________________________________________________
261 Bool_t AliDalitzElectronCuts::ElectronIsSelected(AliESDtrack* lTrack)
262 {
263     //Selection of Reconstructed electrons
264
265     if(hCutIndex)hCutIndex->Fill(kElectronIn);
266
267
268     if ( ! lTrack->GetConstrainedParam() ){
269         
270        
271
272         return kFALSE;
273
274     }
275
276
277
278     if( ! lTrack ) {
279          if(hCutIndex)hCutIndex->Fill(kNoTracks);
280          return kFALSE;
281     }
282
283     AliVTrack * track = dynamic_cast<AliVTrack*>(lTrack);
284
285
286     // Track Cuts
287     if( !TrackIsSelected(lTrack) ){
288          if(hCutIndex)hCutIndex->Fill(kTrackCuts);
289          return kFALSE;
290     }
291
292
293     // dEdx Cuts
294     if( ! dEdxCuts( track ) ) {
295          if(hCutIndex)hCutIndex->Fill(kdEdxCuts);
296          return kFALSE;
297
298     }
299
300     //Electron passed the cuts
301     if(hCutIndex)hCutIndex->Fill(kElectronOut);
302
303
304     return kTRUE;
305 }
306
307 ///________________________________________________________________________
308 Bool_t AliDalitzElectronCuts::TrackIsSelected(AliESDtrack* lTrack) {
309     // Track Selection for Photon Reconstruction
310
311
312
313     if( ! fesdTrackCuts->AcceptTrack(lTrack) ){
314
315         return kFALSE;
316     }
317
318    if(  TMath::Abs( lTrack->Eta()) > fEtaCut ) {
319
320         return kFALSE;
321     }
322
323     if( lTrack->GetNcls(1) < fMinClsTPC ) {
324
325         return kFALSE;
326     }
327
328     //Findable clusters
329
330     Double_t clsToF=0;
331
332
333     if (!fUseCorrectedTPCClsInfo ){
334         if(lTrack->GetTPCNclsF()!=0){
335
336               clsToF = (Double_t)lTrack->GetNcls(1)/(Double_t)lTrack->GetTPCNclsF();
337         }// Ncluster/Nfindablecluster
338     }
339     else {
340
341               //clsToF = lTrack->GetTPCClusterInfo(2,0,GetFirstTPCRow(photon->GetConversionRadius()));
342               clsToF = lTrack->GetTPCClusterInfo(2,1); //NOTE ask friederike
343                 
344     }
345
346
347     if( clsToF < fMinClsTPCToF){
348     return kFALSE;
349     }
350
351
352
353    return kTRUE;
354 }
355 ///________________________________________________________________________
356 Bool_t AliDalitzElectronCuts::dEdxCuts(AliVTrack *fCurrentTrack){
357
358     // Electron Identification Cuts for Photon reconstruction
359
360     if(!fPIDResponse){  InitPIDResponse();  }// Try to reinitialize PID Response
361     if(!fPIDResponse){  AliError("No PID Response"); return kFALSE;}// if still missing fatal error
362
363
364
365     //cout<<"dEdxCuts: //////////////////////////////////////////////////////////////////////////"<<endl;
366
367
368
369     Int_t cutIndex=0;
370
371     if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
372     if(hITSdEdxbefore)hITSdEdxbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasITS(fCurrentTrack, AliPID::kElectron));
373     if(hTPCdEdxbefore)hTPCdEdxbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTPC(fCurrentTrack, AliPID::kElectron));
374
375
376     cutIndex++;
377
378
379   if( fDodEdxSigmaITSCut == kTRUE ){
380
381
382         if( fPIDResponse->NumberOfSigmasITS(fCurrentTrack,AliPID::kElectron)<fPIDnSigmaBelowElectronLineITS ||
383                 fPIDResponse->NumberOfSigmasITS(fCurrentTrack,AliPID::kElectron)> fPIDnSigmaAboveElectronLineITS ){
384
385           if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
386           return kFALSE;
387       }
388      
389   }
390
391  if(hITSdEdxafter)hITSdEdxafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasITS(fCurrentTrack, AliPID::kElectron));
392
393
394   cutIndex++;
395
396
397   if(fDodEdxSigmaTPCCut == kTRUE){
398
399
400       // TPC Electron Line
401       if( fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)<fPIDnSigmaBelowElectronLineTPC ||
402                 fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)>fPIDnSigmaAboveElectronLineTPC){
403
404           if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
405           return kFALSE;
406       }
407       cutIndex++;
408
409       // TPC Pion Line
410         if( fCurrentTrack->P()>fPIDMinPnSigmaAbovePionLineTPC && fCurrentTrack->P()<fPIDMaxPnSigmaAbovePionLineTPC ){
411           if(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLineTPC     &&
412                  fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)<fPIDnSigmaAboveElectronLineTPC &&
413                  fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)<fPIDnSigmaAbovePionLineTPC){
414
415               if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
416               return kFALSE;
417           }
418         }
419         cutIndex++;
420    
421         // High Pt Pion rej
422         if( fCurrentTrack->P()>fPIDMaxPnSigmaAbovePionLineTPC ){
423           if(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLineTPC &&
424                  fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)<fPIDnSigmaAboveElectronLineTPC&&
425                  fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)<fPIDnSigmaAbovePionLineTPCHighPt){
426
427                 if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
428                 return kFALSE;
429           }
430         }
431
432         cutIndex++;
433   }
434
435   else{ cutIndex+=3; }
436
437
438   if(   fDoKaonRejectionLowP == kTRUE   ){
439
440         if( fCurrentTrack->P() < fPIDMinPKaonRejectionLowP ){
441
442           if( TMath::Abs(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kKaon))<fPIDnSigmaAtLowPAroundKaonLine){
443
444               if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
445
446               return kFALSE;
447           }
448         }
449   }
450   cutIndex++;
451    
452   if(   fDoProtonRejectionLowP == kTRUE    ){
453
454         if( fCurrentTrack->P()  < fPIDMinPProtonRejectionLowP ){
455           if( TMath::Abs(   fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kProton))<fPIDnSigmaAtLowPAroundProtonLine){
456
457               if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
458               return kFALSE;
459           }
460         }
461   }
462    cutIndex++;
463    
464   if(fDoPionRejectionLowP == kTRUE){
465         if( fCurrentTrack->P() < fPIDMinPPionRejectionLowP ){
466           if( TMath::Abs( fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)) < fPIDnSigmaAtLowPAroundPionLine ){
467
468               if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
469                 return kFALSE;
470           }
471         }
472   }
473   cutIndex++;
474
475    
476   if((fCurrentTrack->GetStatus() & AliESDtrack::kTOFpid) && !(fCurrentTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
477      if(hTOFbefore) hTOFbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron));
478      if(fUseTOFpid){
479         if(fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron)>fTofPIDnSigmaAboveElectronLine ||
480            fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron)<fTofPIDnSigmaBelowElectronLine ){
481            if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
482            return kFALSE;
483         }
484      }
485      if(hTOFafter)hTOFafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron));
486   }
487      cutIndex++;
488
489   if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
490   if(hTPCdEdxafter)hTPCdEdxafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTPC(fCurrentTrack, AliPID::kElectron));
491
492   return kTRUE;
493 }
494 ///________________________________________________________________________
495
496
497 AliVTrack *AliDalitzElectronCuts::GetTrack(AliVEvent * event, Int_t label){
498     //Returns pointer to the track with given ESD label
499     //(Important for AOD implementation, since Track array in AOD data is different
500     //from ESD array, but ESD tracklabels are stored in AOD Tracks)
501
502   AliESDEvent * esdEvent = dynamic_cast<AliESDEvent*>(event);
503   if(esdEvent) {
504         if(label > event->GetNumberOfTracks() ) return NULL;
505         AliESDtrack * track = esdEvent->GetTrack(label);
506         return track;
507         
508   } else { 
509         for(Int_t ii=0; ii<event->GetNumberOfTracks(); ii++) {
510           AliVTrack * track = dynamic_cast<AliVTrack*>(event->GetTrack(ii));
511           
512           if(track) { 
513                 if(track->GetID() == label) {
514                   return track;
515                 }
516           }
517         }
518     }
519   
520   cout << "track not found " << label << " " << event->GetNumberOfTracks() << endl;
521   return NULL;
522 }
523 ///________________________________________________________________________
524 Bool_t AliDalitzElectronCuts::RejectSharedElecGamma(TList *photons, Int_t indexEle){
525
526
527      for(Int_t i = 0;i<photons->GetEntries();i++){
528
529       AliAODConversionPhoton *photonComp = (AliAODConversionPhoton*) photons->At(i);
530
531       Int_t posLabel = photonComp->GetTrackLabelPositive();
532       Int_t negLabel = photonComp->GetTrackLabelNegative();
533
534       if( (photonComp->GetConversionRadius() < fRadiusCut) && (posLabel == indexEle || negLabel == indexEle) ){
535         return kFALSE;
536       }
537      }
538
539    return kTRUE;
540 }
541
542 Double_t AliDalitzElectronCuts::GetPsiPair( const AliESDtrack* trackPos, const AliESDtrack* trackNeg ) const
543 {
544 //
545 // This angle is a measure for the contribution of the opening in polar
546 // direction Δ0 to the opening angle ξ Pair
547 //
548 // Ref. Measurement of photons via conversion pairs with the PHENIX experiment at RHIC
549 //      Master Thesis. Thorsten Dahms. 2005
550 // https://twiki.cern.ch/twiki/pub/ALICE/GammaPhysicsPublications/tdahms_thesis.pdf
551 //
552         Double_t momPos[3];
553         Double_t momNeg[3];
554         if( trackPos->GetConstrainedPxPyPz(momPos) == 0 ) trackPos->GetPxPyPz( momPos );
555         if( trackNeg->GetConstrainedPxPyPz(momNeg) == 0 ) trackNeg->GetPxPyPz( momNeg );
556
557         TVector3 posDaughter;
558         TVector3 negDaughter;
559
560         posDaughter.SetXYZ( momPos[0], momPos[1], momPos[2] );
561         negDaughter.SetXYZ( momNeg[0], momNeg[1], momNeg[2] );
562
563         Double_t deltaTheta = negDaughter.Theta() - posDaughter.Theta();
564         Double_t openingAngle =  posDaughter.Angle( negDaughter );  //TMath::ACos( posDaughter.Dot(negDaughter)/(negDaughter.Mag()*posDaughter.Mag()) );
565         if( openingAngle < 1e-20 ) return 0.;
566         Double_t psiAngle = TMath::ASin( deltaTheta/openingAngle );
567
568         return psiAngle;
569 }
570
571 Bool_t AliDalitzElectronCuts::IsFromGammaConversion( Double_t psiPair, Double_t deltaPhi ) const
572 {
573 //
574 // Returns true if it is a gamma conversion according to psi pair value
575 //
576         return ( (deltaPhi > fDeltaPhiCutMin  &&  deltaPhi < fDeltaPhiCutMax) &&
577         TMath::Abs(psiPair) < ( fPsiPairCut - fPsiPairCut/fDeltaPhiCutMax * deltaPhi ) );
578 }
579
580 ///________________________________________________________________________
581 Bool_t AliDalitzElectronCuts::UpdateCutString(cutIds cutID, Int_t value) {
582 ///Update the cut string (if it has been created yet)
583
584   if(fCutString && fCutString->GetString().Length() == kNCuts) {
585         cout << "Updating cut id in spot number " << cutID << " to " << value << endl;
586         fCutString->SetString(GetCutNumber());
587   } else {
588         cout << "fCutString not yet initialized, will not be updated" << endl;
589         return kFALSE;
590   }
591  // cout << fCutString->GetString().Data() << endl;
592   return kTRUE;
593 }
594
595 ///________________________________________________________________________
596 Bool_t AliDalitzElectronCuts::InitializeCutsFromCutString(const TString analysisCutSelection ) {
597    // Initialize Cuts from a given Cut string
598
599   cout<<"Set Cut Number: "<<analysisCutSelection.Data()<<endl;
600   if(analysisCutSelection.Length()!=kNCuts) {
601         AliError(Form("Cut selection has the wrong length! size is %d, number of cuts is %d", analysisCutSelection.Length(), kNCuts));
602         return kFALSE;
603   }
604   if(!analysisCutSelection.IsDigit()){
605         AliError("Cut selection contains characters");
606         return kFALSE;
607   }
608   
609   const char *cutSelection = analysisCutSelection.Data();
610   #define ASSIGNARRAY(i)        fCuts[i] = cutSelection[i] - '0'
611   for(Int_t ii=0;ii<kNCuts;ii++){
612       ASSIGNARRAY(ii);
613   }
614
615   // TestFlag
616   if(fCuts[0] !=9){
617     AliError("Analysis Cut Selection does not start with 9");
618         PrintCuts();
619     return kFALSE;
620   }
621
622   // Set Individual Cuts
623   for(Int_t ii=0;ii<kNCuts;ii++){
624       if(!SetCut(cutIds(ii),fCuts[ii]))return kFALSE;
625   }
626
627   //PrintCuts();
628
629     return kTRUE;
630 }
631 ///________________________________________________________________________
632 Bool_t AliDalitzElectronCuts::SetCut(cutIds cutID, const Int_t value) {
633   ///Set individual cut ID
634
635   //cout << "Updating cut  " << fgkCutNames[cutID] << " (" << cutID << ") to " << value << endl;
636
637   switch (cutID) {
638   case kgoodId:
639         fCuts[kgoodId] = value;
640         if(value != 9) {
641           cout << "Error:: First value of cut string is wrong, aborting!!" << endl;
642           return kFALSE;
643         } else {
644           return kTRUE;
645         }
646
647   case kededxSigmaITSCut:
648         if( SetITSdEdxCutElectronLine(value)) { //NOTE SetITSdEdxCutElectronLine: To be implemented 
649           fCuts[kededxSigmaITSCut] = value;
650           UpdateCutString(cutID, value);
651           return kTRUE;
652         } else return kFALSE;
653
654  case kededxSigmaTPCCut:
655         if( SetTPCdEdxCutElectronLine(value)) { //NOTE SetITSdEdxCutElectronLine: To be implemented 
656           fCuts[kededxSigmaTPCCut] = value;
657           UpdateCutString(cutID, value);
658           return kTRUE;
659         } else return kFALSE;
660
661   case kpidedxSigmaTPCCut:
662         if( SetTPCdEdxCutPionLine(value)) { //NOTE SetITSdEdxCutPionLine: To be implemented
663           fCuts[kpidedxSigmaTPCCut] = value;
664           UpdateCutString(cutID, value);
665           return kTRUE;
666         } else return kFALSE;
667
668   case kpiMinMomdedxSigmaTPCCut:
669         if( SetMinMomPiondEdxTPCCut(value)) {
670           fCuts[kpiMinMomdedxSigmaTPCCut] = value;
671           UpdateCutString(cutID, value);
672           return kTRUE;
673         } else return kFALSE;
674
675   case kpiMaxMomdedxSigmaTPCCut:
676         if( SetMaxMomPiondEdxTPCCut(value)) {
677           fCuts[kpiMaxMomdedxSigmaTPCCut] = value;
678           UpdateCutString(cutID, value);
679           return kTRUE;
680         } else return kFALSE;
681
682   case kLowPRejectionSigmaCut:
683         if( SetLowPRejectionCuts(value) ) {
684           fCuts[kLowPRejectionSigmaCut] = value;
685           UpdateCutString(cutID, value);
686           return kTRUE;
687         } else return kFALSE;
688
689
690   case kTOFelectronPID:
691         if( SetTOFElectronPIDCut(value)) {
692           fCuts[kTOFelectronPID] = value;
693           UpdateCutString(cutID, value);
694           return kTRUE;
695         } else return kFALSE;
696
697   case kclsTPCCut:
698         if( SetTPCClusterCut(value)) {
699           fCuts[kclsTPCCut] = value;
700           UpdateCutString(cutID, value);
701           return kTRUE;
702         } else return kFALSE;
703
704   case ketaCut:
705         if( SetEtaCut(value)) {
706           fCuts[ketaCut] = value;
707           UpdateCutString(cutID, value);
708           return kTRUE;
709         } else return kFALSE;
710    case kPsiPair:
711         if( SetPsiPairCut(value)) {
712           fCuts[kPsiPair] = value;
713           UpdateCutString(cutID, value);
714           return kTRUE;
715         } else return kFALSE;
716
717   case kRejectSharedElecGamma:
718         if( SetRejectSharedElecGamma(value)) {
719           fCuts[kRejectSharedElecGamma] = value;
720           UpdateCutString(cutID, value);
721           return kTRUE;
722         } else return kFALSE;
723
724   case kBackgroundScheme:
725         if( SetBackgroundScheme(value)) {
726           fCuts[kBackgroundScheme] = value;
727           UpdateCutString(cutID, value);
728           return kTRUE;
729         } else return kFALSE;
730
731   case kNCuts:
732         cout << "Error:: Cut id out of range"<< endl;
733         return kFALSE;
734   }
735
736   cout << "Error:: Cut id " << cutID << " not recognized "<< endl;
737   return kFALSE;
738
739   //PrintCuts();
740   
741 }
742
743 ///________________________________________________________________________
744
745 void AliDalitzElectronCuts::PrintCuts() {
746     // Print out current Cut Selection
747   for(Int_t ic = 0; ic < kNCuts; ic++) {
748         printf("%-30s : %d \n", fgkCutNames[ic], fCuts[ic]);
749   }
750
751 }
752
753 ///________________________________________________________________________
754 Bool_t AliDalitzElectronCuts::SetITSdEdxCutElectronLine(Int_t ededxSigmaCut)
755 {   // Set Cut
756
757         switch(ededxSigmaCut){
758
759                 case 0: 
760                         fDodEdxSigmaITSCut = kFALSE;
761                         fPIDnSigmaBelowElectronLineITS=-100;
762                         fPIDnSigmaAboveElectronLineITS= 100;
763                         break;
764                 case 1: // -10,10
765                         fDodEdxSigmaITSCut = kTRUE;
766                         fPIDnSigmaBelowElectronLineITS=-10;
767                         fPIDnSigmaAboveElectronLineITS=10;
768                         break;
769                 case 2: // -6,7
770                         fDodEdxSigmaITSCut = kTRUE;
771                         fPIDnSigmaBelowElectronLineITS=-6;
772                         fPIDnSigmaAboveElectronLineITS=7;
773                         break;
774                 case 3: // -5,5
775                         fDodEdxSigmaITSCut = kTRUE;
776                         fPIDnSigmaBelowElectronLineITS=-5;
777                         fPIDnSigmaAboveElectronLineITS=5;
778                         break;
779                 case 4: // -4,5
780                         fDodEdxSigmaITSCut = kTRUE;
781                         fPIDnSigmaBelowElectronLineITS=-4;
782                         fPIDnSigmaAboveElectronLineITS=5;
783                         break;
784                 case 5: // -3,5
785                         fDodEdxSigmaITSCut = kTRUE;
786                         fPIDnSigmaBelowElectronLineITS=-3;
787                         fPIDnSigmaAboveElectronLineITS=5;
788                         break;
789                 case 6: // -4,4
790                         fDodEdxSigmaITSCut = kTRUE;
791                         fPIDnSigmaBelowElectronLineITS=-4;
792                         fPIDnSigmaAboveElectronLineITS=4;
793                         break;
794                 case 7: // -2.5,4
795                         fDodEdxSigmaITSCut = kTRUE;
796                         fPIDnSigmaBelowElectronLineITS=-2.5;
797                         fPIDnSigmaAboveElectronLineITS=4;
798                         break;
799                 case 8: // -2,3.5
800                         fDodEdxSigmaITSCut = kTRUE;
801                         fPIDnSigmaBelowElectronLineITS=-2;
802                         fPIDnSigmaAboveElectronLineITS=3.5;
803                         break;
804                 default:
805                         cout<<"Warning: ITSdEdxCutElectronLine not defined"<<ededxSigmaCut<<endl;
806                         return kFALSE;
807         
808     }
809     return kTRUE;
810 }
811
812 ///________________________________________________________________________
813 Bool_t AliDalitzElectronCuts::SetTPCdEdxCutElectronLine(Int_t ededxSigmaCut)
814 {   // Set Cut
815                 switch(ededxSigmaCut){
816
817                 case 0: fDodEdxSigmaTPCCut = kFALSE;
818                         fPIDnSigmaBelowElectronLineTPC=-10;
819                         fPIDnSigmaAboveElectronLineTPC=10;
820                         break;
821                 case 1: // -10,10
822                         fDodEdxSigmaTPCCut = kTRUE;
823                         fPIDnSigmaBelowElectronLineTPC=-10;
824                         fPIDnSigmaAboveElectronLineTPC=10;
825                         break;
826                 case 2: // -6,7
827                         fDodEdxSigmaTPCCut = kTRUE;
828                         fPIDnSigmaBelowElectronLineTPC=-6;
829                         fPIDnSigmaAboveElectronLineTPC=7;
830                         break;
831                 case 3: // -5,5
832                         fDodEdxSigmaTPCCut = kTRUE;
833                         fPIDnSigmaBelowElectronLineTPC=-5;
834                         fPIDnSigmaAboveElectronLineTPC=5;
835                         break;
836                 case 4: // -4,5
837                         fDodEdxSigmaTPCCut = kTRUE;
838                         fPIDnSigmaBelowElectronLineTPC=-4;
839                         fPIDnSigmaAboveElectronLineTPC=5;
840                         break;  
841                 case 5: // -3,5
842                         fDodEdxSigmaTPCCut = kTRUE;
843                         fPIDnSigmaBelowElectronLineTPC=-3;
844                         fPIDnSigmaAboveElectronLineTPC=5;
845                         break;
846                 case 6: // -4,4
847                         fDodEdxSigmaTPCCut = kTRUE;
848                         fPIDnSigmaBelowElectronLineTPC=-4;
849                         fPIDnSigmaAboveElectronLineTPC=4;
850                         break;
851                 case 7: // -2.5,4
852                         fDodEdxSigmaTPCCut = kTRUE;
853                         fPIDnSigmaBelowElectronLineTPC=-2.5;
854                         fPIDnSigmaAboveElectronLineTPC=4;
855                         break;
856                 case 8: // -2,3.5
857                         fDodEdxSigmaTPCCut = kTRUE;
858                         fPIDnSigmaBelowElectronLineTPC=-2;
859                         fPIDnSigmaAboveElectronLineTPC=3.5;
860                         break;
861                 default:
862                         cout<<"Warning: TPCdEdxCutElectronLine not defined"<<ededxSigmaCut<<endl;
863                         return kFALSE;
864         
865     }
866     return kTRUE;
867 }
868
869 ///________________________________________________________________________
870 Bool_t AliDalitzElectronCuts::SetTPCdEdxCutPionLine(Int_t pidedxSigmaCut)
871 {   // Set Cut
872
873         switch(pidedxSigmaCut){
874                 
875                 case 0: fPIDnSigmaAbovePionLineTPC= 0;
876                         fPIDnSigmaAbovePionLineTPCHighPt=-100;
877                         break;
878                 case 1:  // -10
879                         fPIDnSigmaAbovePionLineTPC=-10;
880                         fPIDnSigmaAbovePionLineTPCHighPt=-10;
881                         break;
882                 case 2:  // 1
883                         fPIDnSigmaAbovePionLineTPC=-1;
884                         fPIDnSigmaAbovePionLineTPCHighPt=-10;
885                         break;
886                 case 3:   // 0
887                         fPIDnSigmaAbovePionLineTPC=0;
888                         fPIDnSigmaAbovePionLineTPCHighPt=-10;
889                         break;
890                 case 4:  // 1
891                         fPIDnSigmaAbovePionLineTPC=1;
892                         fPIDnSigmaAbovePionLineTPCHighPt=-10;
893                         break;
894                 case 5:  // 1
895                         fPIDnSigmaAbovePionLineTPC=2.;
896                         fPIDnSigmaAbovePionLineTPCHighPt=-10;
897                         break;
898                 case 6:  // 1
899                         fPIDnSigmaAbovePionLineTPC=2.5;
900                         fPIDnSigmaAbovePionLineTPCHighPt=-10;
901                         break;
902                 case 7:
903                         fPIDnSigmaAbovePionLineTPC=3.0; // We need a bit less tight cut on dE/dx
904                         fPIDnSigmaAbovePionLineTPCHighPt=-10;
905                         break;
906                 case 8:  // 1
907                         fPIDnSigmaAbovePionLineTPC=3.5;
908                         fPIDnSigmaAbovePionLineTPCHighPt=-10;
909                         break;
910                 case 9:  // 1
911                         fPIDnSigmaAbovePionLineTPC=1.5;
912                         fPIDnSigmaAbovePionLineTPCHighPt=-1.0;
913                         break;
914                 default:
915                         cout<<"Warning: pidedxSigmaCut not defined "<<pidedxSigmaCut<<endl;
916                         return kFALSE;
917         }
918         return kTRUE;
919 }
920
921 ///________________________________________________________________________
922 Bool_t AliDalitzElectronCuts::SetMinMomPiondEdxTPCCut(Int_t piMomdedxSigmaCut)
923 {   // Set Cut
924         switch(piMomdedxSigmaCut){
925                 
926                 case 0: fPIDMinPnSigmaAbovePionLineTPC=0.;
927                         break;
928                 case 1:  // 50.0 GeV
929                         fPIDMinPnSigmaAbovePionLineTPC=50.;
930                         break;
931                 case 2:  // 20.0 GeV
932                         fPIDMinPnSigmaAbovePionLineTPC=20.;
933                         break;
934                 case 3:  // 1.5 GeV
935                         fPIDMinPnSigmaAbovePionLineTPC=1.5;
936                         break;
937                 case 4:  // 1. GeV
938                         fPIDMinPnSigmaAbovePionLineTPC=1.;
939                         break;  
940                 case 5:  // 0.5 GeV
941                         fPIDMinPnSigmaAbovePionLineTPC=0.5;
942                         break;
943                 case 6:  // 0.4 GeV
944                         fPIDMinPnSigmaAbovePionLineTPC=0.4;
945                         break;    
946                 case 7:  // 0.3 GeV
947                         fPIDMinPnSigmaAbovePionLineTPC=0.3;
948                         break;
949                 case 8:  // 0.25 GeV
950                         fPIDMinPnSigmaAbovePionLineTPC=0.25;
951                         break;
952                 default:
953                         cout<<"Warning: piMomdedxSigmaCut not defined "<<piMomdedxSigmaCut<<endl;
954                         return kFALSE;
955     }
956     return kTRUE;
957 }
958
959 ///________________________________________________________________________
960 Bool_t AliDalitzElectronCuts::SetTPCClusterCut(Int_t clsTPCCut)
961 {   // Set Cut
962     switch(clsTPCCut){
963     case 0: // 0
964         fMinClsTPC= 0.;
965         break;
966     case 1:  // 70
967         fMinClsTPC= 70.;
968         break;
969     case 2:  // 80
970         fMinClsTPC= 80.;
971         break;
972     case 3:  // 100
973         fMinClsTPC= 100.;
974         break;
975     case 4:  // 0% of findable clusters
976         fMinClsTPCToF= 0.0;
977         fUseCorrectedTPCClsInfo=0;
978         break;
979     case 5:  // 35% of findable clusters
980         fMinClsTPCToF= 0.35;
981         fUseCorrectedTPCClsInfo=0;
982         break;
983     case 6:  // 60% of findable clusters
984         fMinClsTPCToF= 0.6;
985         fUseCorrectedTPCClsInfo=0;
986         break;
987     case 7:  // 70% of findable clusters
988         fMinClsTPCToF= 0.7;
989         fUseCorrectedTPCClsInfo=0;
990         break;
991     default:
992         cout<<"Warning: clsTPCCut not defined "<<clsTPCCut<<endl;
993         return kFALSE;
994     }
995     return kTRUE;
996 }
997
998 ///________________________________________________________________________
999 Bool_t AliDalitzElectronCuts::SetEtaCut(Int_t etaCut)
1000
1001   // Set eta Cut
1002         switch(etaCut){
1003                 case 0: fEtaCut         = 100.;
1004                         break;
1005                 case 1: // 1.4
1006                         fEtaCut         = 1.4;
1007                         break;
1008                 case 2: // 1.2
1009                         fEtaCut         = 1.2;
1010                         break;
1011                 case 3: // 0.9
1012                         fEtaCut         = 0.9;
1013                         break;
1014                 case 4: // 0.8
1015                         fEtaCut         = 0.8;
1016                         break;
1017                 case 5: // 0.75
1018                         fEtaCut         = 0.75;
1019                         break;
1020                 default:
1021                         cout<<"Warning: EtaCut not defined "<<etaCut<<endl;
1022                         return kFALSE;
1023     }
1024     return kTRUE;
1025 }
1026
1027 ///________________________________________________________________________
1028 Bool_t AliDalitzElectronCuts::SetMaxMomPiondEdxTPCCut(Int_t piMaxMomdedxSigmaCut)
1029 {   // Set Cut
1030    switch(piMaxMomdedxSigmaCut){
1031
1032                 case 0: fPIDMinPnSigmaAbovePionLineTPC=0.;
1033                         break;
1034                 case 1:  // 100. GeV
1035                         fPIDMaxPnSigmaAbovePionLineTPC=100.;
1036                         break;
1037                 case 2:  // 5. GeV
1038                         fPIDMaxPnSigmaAbovePionLineTPC=5.;
1039                         break;
1040                 case 3:  // 4. GeV
1041                         fPIDMaxPnSigmaAbovePionLineTPC=4.;
1042                         break;
1043                 case 4:  // 3.5 GeV
1044                         fPIDMaxPnSigmaAbovePionLineTPC=3.5;
1045                         break;
1046                 case 5:  // 3. GeV
1047                         fPIDMaxPnSigmaAbovePionLineTPC=3.;
1048                         break;
1049                 default:
1050                         cout<<"Warning: piMaxMomdedxSigmaCut not defined "<<piMaxMomdedxSigmaCut<<endl;
1051                         return kFALSE;
1052     }
1053     return kTRUE;
1054 }
1055
1056 ///________________________________________________________________________
1057 Bool_t AliDalitzElectronCuts::SetLowPRejectionCuts(Int_t LowPRejectionSigmaCut)
1058 {   // Set Cut
1059     switch(LowPRejectionSigmaCut){
1060         case 0:  //
1061         fDoKaonRejectionLowP=kFALSE;
1062         fDoProtonRejectionLowP=kFALSE;
1063         fDoPionRejectionLowP=kFALSE;
1064         fPIDnSigmaAtLowPAroundKaonLine=0;
1065         fPIDnSigmaAtLowPAroundProtonLine=0;
1066         fPIDnSigmaAtLowPAroundPionLine=0;
1067         break;
1068     case 1:  //
1069         fDoKaonRejectionLowP=kTRUE;
1070         fDoProtonRejectionLowP=kTRUE;
1071         fDoPionRejectionLowP=kTRUE;
1072         fPIDnSigmaAtLowPAroundKaonLine=0.5;
1073         fPIDnSigmaAtLowPAroundProtonLine=0.5;
1074         fPIDnSigmaAtLowPAroundPionLine=0.5;
1075         break;
1076     case 2:  //
1077         fDoKaonRejectionLowP=kTRUE;
1078         fDoProtonRejectionLowP=kTRUE;
1079         fDoPionRejectionLowP=kTRUE;
1080         fPIDnSigmaAtLowPAroundKaonLine=1;
1081         fPIDnSigmaAtLowPAroundProtonLine=1;
1082         fPIDnSigmaAtLowPAroundPionLine=1;
1083         break;
1084     case 3:  //
1085         fDoKaonRejectionLowP=kTRUE;
1086         fDoProtonRejectionLowP=kTRUE;
1087         fDoPionRejectionLowP=kTRUE;
1088         fPIDnSigmaAtLowPAroundKaonLine=1.5;
1089         fPIDnSigmaAtLowPAroundProtonLine=1.5;
1090         fPIDnSigmaAtLowPAroundPionLine=1.5;
1091         break;
1092     case 4:  //
1093         fDoKaonRejectionLowP=kTRUE;
1094         fDoProtonRejectionLowP=kTRUE;
1095         fDoPionRejectionLowP=kTRUE;
1096         fPIDnSigmaAtLowPAroundKaonLine=0.;
1097         fPIDnSigmaAtLowPAroundProtonLine=0.;
1098         fPIDnSigmaAtLowPAroundPionLine=1;
1099         break;
1100     case 5:  //
1101         fDoKaonRejectionLowP=kTRUE;
1102         fDoProtonRejectionLowP=kTRUE;
1103         fDoPionRejectionLowP=kTRUE;
1104         fPIDnSigmaAtLowPAroundKaonLine=0.;
1105         fPIDnSigmaAtLowPAroundProtonLine=0.;
1106         fPIDnSigmaAtLowPAroundPionLine=1.5;
1107         break;
1108     case 6:  //
1109         fDoKaonRejectionLowP=kTRUE;
1110         fDoProtonRejectionLowP=kTRUE;
1111         fDoPionRejectionLowP=kTRUE;
1112         fPIDnSigmaAtLowPAroundKaonLine=0.;
1113         fPIDnSigmaAtLowPAroundProtonLine=0.;
1114         fPIDnSigmaAtLowPAroundPionLine=2.;
1115         break;
1116     default:
1117         cout<<"Warning: LowPRejectionSigmaCut not defined "<<LowPRejectionSigmaCut<<endl;
1118         return kFALSE;
1119     }
1120     return kTRUE;
1121 }
1122
1123 ///________________________________________________________________________
1124 Bool_t AliDalitzElectronCuts::SetTOFElectronPIDCut(Int_t TOFelectronPID){
1125     // Set Cut
1126     switch(TOFelectronPID){ // RRnewTOF start //////////////////////////////////////////////////////////////////////////
1127     case 0: // no cut
1128         fUseTOFpid = kFALSE;
1129         fTofPIDnSigmaBelowElectronLine=-100;
1130         fTofPIDnSigmaAboveElectronLine=100;
1131         break;
1132     case 1: // -7,7
1133         fUseTOFpid = kTRUE;
1134         fTofPIDnSigmaBelowElectronLine=-7;
1135         fTofPIDnSigmaAboveElectronLine=7;
1136         break;
1137     case 2: // -5,5
1138         fUseTOFpid = kTRUE;
1139         fTofPIDnSigmaBelowElectronLine=-5;
1140         fTofPIDnSigmaAboveElectronLine=5;
1141         break;
1142     case 3: // -3,5
1143         fUseTOFpid = kTRUE;
1144         fTofPIDnSigmaBelowElectronLine=-3;
1145         fTofPIDnSigmaAboveElectronLine=5;
1146         break;
1147     case 4: // -2,3
1148         fUseTOFpid = kTRUE;
1149         fTofPIDnSigmaBelowElectronLine=-2;
1150         fTofPIDnSigmaAboveElectronLine=3;
1151         break;
1152     default:
1153         cout<<"Warning: TOFElectronCut not defined "<<TOFelectronPID<<endl;
1154         return kFALSE;
1155     } //////////////////////// RRnewTOF end //////////////////////////////////////////////////////////////////////////
1156     return kTRUE;
1157 }
1158 ///_______________________________________________________________________________
1159
1160 Bool_t AliDalitzElectronCuts::SetPsiPairCut(Int_t psiCut) {
1161   
1162
1163   switch(psiCut) {
1164   case 0:
1165         fDoPsiPairCut = kFALSE;
1166         fPsiPairCut = 10000; //
1167         fDeltaPhiCutMin = -1000.;
1168         fDeltaPhiCutMax =  1000.;
1169         
1170         break;
1171   case 1:
1172         fDoPsiPairCut = kTRUE;
1173         fPsiPairCut = 0.45; // Standard
1174         fDeltaPhiCutMin = 0.;
1175         fDeltaPhiCutMax = 0.12;
1176         break;
1177   default:
1178       cout<<"Warning: PsiPairCut not defined "<<fPsiPairCut<<endl;
1179       return kFALSE;
1180   }
1181
1182   return kTRUE;
1183 }
1184
1185 ///_______________________________________________________________________________
1186 Bool_t AliDalitzElectronCuts::SetRejectSharedElecGamma(Int_t RCut) {
1187   
1188
1189   switch(RCut) {
1190   case 0:
1191         fDoRejectSharedElecGamma = kFALSE;
1192         fRadiusCut = 10000; // 
1193         break;
1194   case 1:
1195         fDoRejectSharedElecGamma = kTRUE;
1196         fRadiusCut = 2.0; // cm 
1197         break;
1198   case 2:
1199         fDoRejectSharedElecGamma = kTRUE;
1200         fRadiusCut = 3.0; // Standard
1201         break;
1202   case 3:
1203         fDoRejectSharedElecGamma = kTRUE;
1204         fRadiusCut = 4.0; // 
1205         break;
1206   case 4:
1207         fDoRejectSharedElecGamma = kTRUE;
1208         fRadiusCut = 5.0; // 
1209         break;
1210   case 5:
1211         fDoRejectSharedElecGamma = kTRUE;
1212         fRadiusCut = 10.0; // 
1213         break;
1214   case 6:
1215         fDoRejectSharedElecGamma = kTRUE;
1216         fRadiusCut = 15.0; // 
1217         break;
1218   default:
1219       cout<<"Warning: PsiPairCut not defined "<<fDoRejectSharedElecGamma<<endl;
1220       return kFALSE;
1221   }
1222
1223   return kTRUE;
1224 }
1225 ///__________________________________________________________________________
1226 Bool_t AliDalitzElectronCuts::SetBackgroundScheme(Int_t BackgroundScheme){
1227
1228     // Set Cut
1229     switch(BackgroundScheme){
1230
1231     case 0: //Rotation
1232             fBKGMethod = 0;
1233             fUseTrackMultiplicityForBG = kFALSE;
1234         break;
1235     case 1: // mixed event with V0 multiplicity
1236             fBKGMethod  = 1;
1237             fUseTrackMultiplicityForBG = kFALSE;
1238         break;
1239     case 2: // mixed event with track multiplicity
1240             fUseTrackMultiplicityForBG = kTRUE;
1241             fBKGMethod  = 1;
1242         break;
1243     case 3: //Rotation
1244            fUseTrackMultiplicityForBG = kFALSE;
1245             fBKGMethod  = 2;
1246         break;
1247     case 4: //Rotation
1248             fUseTrackMultiplicityForBG = kTRUE;
1249             fBKGMethod  = 2;
1250         break;
1251
1252     default:
1253         cout<<"Warning: BackgroundScheme not defined "<<BackgroundScheme<<endl;
1254         return kFALSE;
1255     }
1256     return kTRUE;
1257 }
1258 ///________________________________________________________________________
1259 TString AliDalitzElectronCuts::GetCutNumber(){
1260     // returns TString with current cut number
1261   TString a(kNCuts);
1262   for(Int_t ii=0;ii<kNCuts;ii++){
1263         a.Append(Form("%d",fCuts[ii]));
1264   }
1265   return a;
1266 }
1267
1268
1269 ///________________________________________________________________________
1270 AliDalitzElectronCuts* AliDalitzElectronCuts::GetStandardCuts2010PbPb(){
1271     //Create and return standard 2010 PbPb cuts
1272     AliDalitzElectronCuts *cuts=new AliDalitzElectronCuts("StandardCuts2010PbPb","StandardCuts2010PbPb");
1273     if(!cuts->InitializeCutsFromCutString("9069640364102")){
1274         cout<<"Warning: Initialization of Standardcuts2010PbPb failed"<<endl;}
1275     return cuts;
1276 }
1277
1278 ///________________________________________________________________________
1279 AliDalitzElectronCuts* AliDalitzElectronCuts::GetStandardCuts2010pp(){
1280     //Create and return standard 2010 PbPb cuts
1281     AliDalitzElectronCuts *cuts=new AliDalitzElectronCuts("StandardCuts2010pp","StandardCuts2010pp");
1282                                           
1283     if(!cuts->InitializeCutsFromCutString("9069640364102")){
1284         cout<<"Warning: Initialization of Standardcuts2010pp failed"<<endl;}
1285      return cuts;
1286 }
1287