]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/FEMTOSCOPY/AliFemtoUser/AliFemtoKKTrackCut.cxx
updates for Kaon Analysis
[u/mrichter/AliRoot.git] / PWGCF / FEMTOSCOPY / AliFemtoUser / AliFemtoKKTrackCut.cxx
1 /*
2 ***************************************************************************
3 *
4 * $Id: AliFemtoKKTrackCut.cxx 60781 2013-02-08 16:24:10Z akisiel $ 
5 *
6
7 ***************************************************************************
8 *
9
10 *              
11 *
12 ***************************************************************************
13 *
14 * $Log$
15 * Revision 1.3  2007/05/22 09:01:42  akisiel
16 * Add the possibiloity to save cut settings in the ROOT file
17 *
18 * Revision 1.2  2007/05/21 10:38:25  akisiel
19 * More coding rule conformance
20 *
21 * Revision 1.1  2007/05/16 10:25:06  akisiel
22 * Making the directory structure of AliFemtoUser flat. All files go into one common directory
23 *
24 * Revision 1.4  2007/05/03 09:46:10  akisiel
25 * Fixing Effective C++ warnings
26 *
27 * Revision 1.3  2007/04/27 07:25:59  akisiel
28 * Make revisions needed for compilation from the main AliRoot tree
29 *
30 * Revision 1.1.1.1  2007/04/25 15:38:41  panos
31 * Importing the HBT code dir
32 *
33 * Revision 1.4  2007-04-03 16:00:08  mchojnacki
34 * Changes to iprove memory managing
35 *
36 * Revision 1.3  2007/03/13 15:30:03  mchojnacki
37 * adding reader for simulated data
38 *
39 * Revision 1.2  2007/03/08 14:58:03  mchojnacki
40 * adding some alice stuff
41 *
42 * Revision 1.1.1.1  2007/03/07 10:14:49  mchojnacki
43 * First version on CVS
44 *
45 **************************************************************************/
46
47 #include "AliFemtoKKTrackCut.h"
48 #include <cstdio>
49
50 #ifdef __ROOT__ 
51 ClassImp(AliFemtoKKTrackCut)
52 #endif
53
54
55 // electron
56 // 0.13 - 1.8
57 // 0       7.594129e-02    8.256141e-03
58 // 1       -5.535827e-01   8.170825e-02
59 // 2       1.728591e+00    3.104210e-01
60 // 3       -2.827893e+00   5.827802e-01
61 // 4       2.503553e+00    5.736207e-01
62 // 5       -1.125965e+00   2.821170e-01
63 // 6       2.009036e-01    5.438876e-02
64
65 // pion
66 // 0.13 - 2.0
67 // 0       1.063457e+00    8.872043e-03
68 // 1       -4.222208e-01   2.534402e-02
69 // 2       1.042004e-01    1.503945e-02
70
71 // kaon
72 // 0.18 - 2.0
73 // 0       -7.289406e-02   1.686074e-03
74 // 1       4.415666e-01    1.143939e-02
75 // 2       -2.996790e-01   1.840964e-02
76 // 3       6.704652e-02    7.783990e-03
77
78 // proton
79 // 0.26 - 2.0
80 // 0       -3.730200e-02   2.347311e-03
81 // 1       1.163684e-01    1.319316e-02
82 // 2       8.354116e-02    1.997948e-02
83 // 3       -4.608098e-02   8.336400e-03
84
85
86   AliFemtoKKTrackCut::AliFemtoKKTrackCut() :
87     fCharge(0),
88     fLabel(0),
89     fStatus(0),
90     fPIDMethod(knSigma),
91 //ml
92   fNsigmaTPCle250(3.),
93   fNsigmaTPC250_400(3.),
94   fNsigmaTPC400_450(3.),
95   fNsigmaTPC450_500(3.),
96   fNsigmaTPCge500(3.),
97   fNsigmaTOF500_800(3.),
98   fNsigmaTOF800_1000(3.),
99   fNsigmaTOFge1000(3.),
100     fminTPCclsF(0),
101     fminTPCncls(0),
102     fminITScls(0),
103     fMaxITSchiNdof(1000.0),
104     fMaxTPCchiNdof(1000.0),
105     fMaxSigmaToVertex(1000.0),
106     fNTracksPassed(0),
107     fNTracksFailed(0),
108     fRemoveKinks(kFALSE),
109     fRemoveITSFake(kFALSE),
110     fMostProbable(0), 
111     fMaxImpactXY(1000.0),
112     fMaxImpactZ(1000.0),
113     fMaxImpactXYPtOff(1000.0),
114     fMaxImpactXYPtNrm(1000.0),
115     fMaxImpactXYPtPow(1000.0),
116     fMinPforTOFpid(0.0),
117     fMaxPforTOFpid(10000.0),
118     fMinPforTPCpid(0.0),
119     fMaxPforTPCpid(10000.0),
120     fMinPforITSpid(0.0),
121     fMaxPforITSpid(10000.0)
122 {
123   // Default constructor
124   fNTracksPassed = fNTracksFailed = 0;
125   fCharge = 0;  // takes both charges 0
126   fPt[0]=0.0;              fPt[1] = 100.0;//100
127   fRapidity[0]=-2;       fRapidity[1]=2;//-2 2
128   fEta[0]=-2;       fEta[1]=2;//-2 2
129   fPidProbElectron[0]=-1;fPidProbElectron[1]=2;
130   fPidProbPion[0]=-1;    fPidProbPion[1]=2;
131   fPidProbKaon[0]=-1;fPidProbKaon[1]=2;
132   fPidProbProton[0]=-1;fPidProbProton[1]=2;
133   fPidProbMuon[0]=-1;fPidProbMuon[1]=2;
134   for (Int_t i = 0; i < 3; i++)
135     fCutClusterRequirementITS[i] = AliESDtrackCuts::kOff;
136   fLabel=false;
137   fStatus=0;
138   fminTPCclsF=0;
139   fminITScls=0;
140   fPIDMethod=knSigma;
141
142   fNsigmaTPCle250=3.0;
143   fNsigmaTPC250_400=3.0;
144   fNsigmaTPC400_450=3.0;
145   fNsigmaTPC450_500=3.0;
146   fNsigmaTPCge500=3.0;
147
148   fNsigmaTOF500_800=3.0;
149   fNsigmaTOF800_1000=3.0;
150   fNsigmaTOFge1000=3.0;
151
152
153
154 }
155 //------------------------------
156 AliFemtoKKTrackCut::~AliFemtoKKTrackCut(){
157   /* noop */
158 }
159 //------------------------------
160 bool AliFemtoKKTrackCut::Pass(const AliFemtoTrack* track)
161 {
162   //cout<<"AliFemtoKKTrackCut::Pass"<<endl;
163
164   // test the particle and return 
165   // true if it meets all the criteria
166   // false if it doesn't meet at least one of the criteria
167   float tMost[5];
168   
169   //cout<<"AliKK  cut"<<endl;
170   //cout<<fPidProbPion[0]<<" < pi ="<<track->PidProbPion()<<" <"<<fPidProbPion[1]<<endl;
171   if (fStatus!=0)
172     {
173       //cout<<" status "<<track->Label()<<" "<<track->Flags()<<" "<<track->TPCnclsF()<<" "<<track->ITSncls()<<endl;
174       if ((track->Flags()&fStatus)!=fStatus)
175         {
176           //      cout<<track->Flags()<<" "<<fStatus<<" no go through status"<<endl;
177           return false;
178         }
179         
180     }
181   if (fRemoveKinks) {
182     if ((track->KinkIndex(0)) || (track->KinkIndex(1)) || (track->KinkIndex(2)))
183       return false;
184   }
185   if (fRemoveITSFake) {
186     if (track->ITSncls() < 0)
187       return false;
188   }
189   if (fminTPCclsF>track->TPCnclsF())
190     {
191       //cout<<" No go because TPC Number of ClsF"<<fminTPCclsF<< " "<<track->TPCnclsF()<<endl;
192       return false;
193     }
194   if (fminTPCncls>track->TPCncls())
195     {
196       //cout<<" No go because TPC Number of ClsF"<<fminTPCclsF<< " "<<track->TPCnclsF()<<endl;
197       return false;
198     }
199   if (fminITScls>track->ITSncls())
200     {
201       //cout<<" No go because ITS Number of Cls"<<fminITScls<< " "<<track->ITSncls()<<endl;
202       return false;
203     }
204
205   if (fMaxImpactXY < TMath::Abs(track->ImpactD()))
206     return false;
207
208   if (fMaxImpactZ < TMath::Abs(track->ImpactZ()))
209     return false;
210   
211   if (fMaxSigmaToVertex < track->SigmaToVertex()) {
212     return false;
213   }
214   
215   if (track->ITSncls() > 0) 
216     if ((track->ITSchi2()/track->ITSncls()) > fMaxITSchiNdof) {
217       return false;
218     }
219
220   if (track->TPCncls() > 0)
221     if ((track->TPCchi2()/track->TPCncls()) > fMaxTPCchiNdof) {
222       return false;
223     }
224   //ITS cluster requirenments
225   for (Int_t i = 0; i < 3; i++)
226     if(!CheckITSClusterRequirement(fCutClusterRequirementITS[i], track->HasPointOnITSLayer(i*2), track->HasPointOnITSLayer(i*2+1)))
227       return false;
228
229   if (fLabel)
230     {
231       //cout<<"labels"<<endl;
232       if(track->Label()<0)
233         {
234           fNTracksFailed++;
235           //   cout<<"No Go Through the cut"<<endl;
236           //  cout<<fLabel<<" Label="<<track->Label()<<endl;
237           return false;
238         }    
239     }
240   if (fCharge!=0)
241     {              
242       //cout<<"AliKK  cut ch "<<endl;
243       //cout<<fCharge<<" Charge="<<track->Charge()<<endl;
244       if (track->Charge()!= fCharge)    
245         {
246           fNTracksFailed++;
247           //  cout<<"No Go Through the cut"<<endl;
248           // cout<<fCharge<<" Charge="<<track->Charge()<<endl;
249           return false;
250         }
251     }
252
253
254   
255
256   Bool_t tTPCPidIn = (track->Flags()&AliFemtoTrack::kTPCpid)>0;
257   Bool_t tITSPidIn = (track->Flags()&AliFemtoTrack::kITSpid)>0;
258   Bool_t tTOFPidIn = (track->Flags()&AliFemtoTrack::kTOFpid)>0;
259   
260   if(fMinPforTOFpid > 0 && track->P().Mag() > fMinPforTOFpid &&
261      track->P().Mag() < fMaxPforTOFpid && !tTOFPidIn)
262     {
263       fNTracksFailed++;
264       return false;
265     }
266   
267   if(fMinPforTPCpid > 0 && track->P().Mag() > fMinPforTPCpid &&
268      track->P().Mag() < fMaxPforTPCpid && !tTPCPidIn)
269     {
270       fNTracksFailed++;
271       return false;
272     }
273   
274   if(fMinPforITSpid > 0 && track->P().Mag() > fMinPforITSpid &&
275      track->P().Mag() < fMaxPforITSpid && !tITSPidIn)
276     {
277       fNTracksFailed++;
278       return false;
279     }
280   
281
282   float tEnergy = ::sqrt(track->P().Mag2()+fMass*fMass);
283   float tRapidity = 0.5*::log((tEnergy+track->P().z())/(tEnergy-track->P().z()));
284   float tPt = ::sqrt((track->P().x())*(track->P().x())+(track->P().y())*(track->P().y()));
285   float tEta = track->P().PseudoRapidity();
286   
287   if (fMaxImpactXYPtOff < 999.0) {
288     if ((fMaxImpactXYPtOff + fMaxImpactXYPtNrm*TMath::Power(tPt, fMaxImpactXYPtPow)) < TMath::Abs(track->ImpactD())) {
289       fNTracksFailed++;
290       return false;
291     }
292   }
293
294   if ((tRapidity<fRapidity[0])||(tRapidity>fRapidity[1]))
295     {
296       fNTracksFailed++;
297       //cout<<"No Go Through the cut"<<endl;   
298       //cout<<fRapidity[0]<<" < Rapidity ="<<tRapidity<<" <"<<fRapidity[1]<<endl;
299       return false;
300     }
301   if ((tEta<fEta[0])||(tEta>fEta[1]))
302     {
303       fNTracksFailed++;
304       //cout<<"No Go Through the cut"<<endl;   
305       //cout<<fEta[0]<<" < Eta ="<<tEta<<" <"<<fEta[1]<<endl;
306       return false;
307     }
308   if ((tPt<fPt[0])||(tPt>fPt[1]))
309     {
310       fNTracksFailed++;
311       //cout<<"No Go Through the cut"<<endl;
312       //cout<<fPt[0]<<" < Pt ="<<Pt<<" <"<<fPt[1]<<endl;
313       return false;
314     }
315
316
317
318
319   //   cout << "Track has pids: " 
320   //        << track->PidProbElectron() << " " 
321   //        << track->PidProbMuon() << " " 
322   //        << track->PidProbPion() << " " 
323   //        << track->PidProbKaon() << " " 
324   //        << track->PidProbProton() << " " 
325   //        << track->PidProbElectron()+track->PidProbMuon()+track->PidProbPion()+track->PidProbKaon()+track->PidProbProton() << endl;
326
327     
328   if ((track->PidProbElectron()<fPidProbElectron[0])||(track->PidProbElectron()>fPidProbElectron[1]))
329     {
330       fNTracksFailed++;
331       //cout<<"No Go Through the cut"<<endl;
332       //cout<<fPidProbElectron[0]<<" < e ="<<track->PidProbElectron()<<" <"<<fPidProbElectron[1]<<endl;
333       return false;
334     }
335   if ((track->PidProbPion()<fPidProbPion[0])||(track->PidProbPion()>fPidProbPion[1]))
336     {
337       fNTracksFailed++;
338       //cout<<"No Go Through the cut"<<endl;
339       //cout<<fPidProbPion[0]<<" < pi ="<<track->PidProbPion()<<" <"<<fPidProbPion[1]<<endl;
340       return false;
341     }
342   if ((track->PidProbKaon()<fPidProbKaon[0])||(track->PidProbKaon()>fPidProbKaon[1]))
343     {
344       fNTracksFailed++;
345       //cout<<"No Go Through the cut"<<endl;
346       //cout<<fPidProbKaon[0]<<" < k ="<<track->PidProbKaon()<<" <"<<fPidProbKaon[1]<<endl;
347       return false;
348     }
349   if ((track->PidProbProton()<fPidProbProton[0])||(track->PidProbProton()>fPidProbProton[1]))
350     {
351       fNTracksFailed++;
352       //cout<<"No Go Through the cut"<<endl;
353       //cout<<fPidProbProton[0]<<" < p  ="<<track->PidProbProton()<<" <"<<fPidProbProton[1]<<endl;
354       return false;
355     }
356   if ((track->PidProbMuon()<fPidProbMuon[0])||(track->PidProbMuon()>fPidProbMuon[1]))
357     {
358       fNTracksFailed++;
359       //cout<<"No Go Through the cut"<<endl;
360       //cout<<fPidProbMuon[0]<<" <  mi="<<track->PidProbMuon()<<" <"<<fPidProbMuon[1]<<endl;
361       return false;
362     }
363
364   if (fMostProbable) {
365   
366     int imost=0;
367     tMost[0] = track->PidProbElectron()*PidFractionElectron(track->P().Mag());
368     tMost[1] = 0.0;
369     tMost[2] = track->PidProbPion()*PidFractionPion(track->P().Mag());
370     tMost[3] = track->PidProbKaon()*PidFractionKaon(track->P().Mag());
371     tMost[4] = track->PidProbProton()*PidFractionProton(track->P().Mag());
372     float ipidmax = 0.0;
373
374
375     //****N Sigma Method****
376         if(fPIDMethod==0){
377           // Looking for pions
378           if (fMostProbable == 2) {
379             if (IsPionNSigma(track->P().Mag(), track->NSigmaTPCPi(), track->NSigmaTOFPi()))
380               imost = 2;
381
382           }
383           else if (fMostProbable == 3) { 
384
385     
386           if (IsKaonNSigma(track->P().Mag(), track->NSigmaTPCK(), track->NSigmaTOFK())){
387                     
388               imost = 3;
389             }
390   
391           }
392           else if (fMostProbable == 4) { // proton nsigma-PID required contour adjusting
393             if (IsProtonNSigma(track->P().Mag(), track->NSigmaTPCP(), track->NSigmaTOFP()) // && IsProtonTPCdEdx(track->P().Mag(), track->TPCsignal())
394             )
395               imost = 4;
396           }
397
398         }
399         
400         
401
402     //****Contour Method****
403         if(fPIDMethod==1){
404           for (int ip=0; ip<5; ip++)
405             if (tMost[ip] > ipidmax) { ipidmax = tMost[ip]; imost = ip; };
406
407           // Looking for pions
408           if (fMostProbable == 2) {
409             if (imost == 2) {
410               // Using the TPC to reject non-pions
411               if (!(IsPionTPCdEdx(track->P().Mag(), track->TPCsignal())))
412                 imost = 0;
413               if (0) {
414                 // Using the TOF to reject non-pions
415                 if (track->P().Mag() < 0.6) {
416                   if (tTOFPidIn)
417                     if (!IsPionTOFTime(track->P().Mag(), track->TOFpionTime()))
418                       imost = 0;
419                 }
420                 else {
421                   if (tTOFPidIn) {
422                     if (!IsPionTOFTime(track->P().Mag(), track->TOFpionTime()))
423                       imost = 0;
424                   }
425                   else {
426                     imost = 0;
427                   }
428                 }
429               }
430             }
431           }
432
433           // Looking for kaons
434           else if (fMostProbable == 3) {
435             //       if (imost == 3) {
436             // Using the TPC to reject non-kaons
437             if (track->P().Mag() < 0.6) {
438               if (!(IsKaonTPCdEdx(track->P().Mag(), track->TPCsignal())))
439                 imost = 0;
440               else imost = 3;
441               if (1) {
442                 // Using the TOF to reject non-kaons
443                 if (tTOFPidIn)
444                   if (!IsKaonTOFTime(track->P().Mag(), track->TOFkaonTime()))
445                     imost = 0;
446               }
447             }
448             else {
449               if (1) {
450                 if (tTOFPidIn) {
451                   if (!IsKaonTOFTime(track->P().Mag(), track->TOFkaonTime()))
452                     imost = 0;
453                   else
454                     imost = 3;
455                 }
456                 else {
457                   if (!(IsKaonTPCdEdx(track->P().Mag(), track->TPCsignal())))
458                     imost = 0;
459                   else 
460                     imost = 3;
461                 }
462               }
463             }
464             //       }
465           }
466     
467           // Looking for protons
468           else if (fMostProbable == 4) {
469             //       if (imost == 3) {
470             // Using the TPC to reject non-kaons
471             if (track->P().Mag() < 0.8) {
472               if (!(IsProtonTPCdEdx(track->P().Mag(), track->TPCsignal())))
473                 imost = 0;
474               else imost = 4;
475               if (0) {
476                 // Using the TOF to reject non-kaons
477                 if (tTOFPidIn)
478                   if (!IsKaonTOFTime(track->P().Mag(), track->TOFkaonTime()))
479                     imost = 0;
480               }
481             }
482             else {
483               if (0) {
484                 if (tTOFPidIn) {
485                   if (!IsKaonTOFTime(track->P().Mag(), track->TOFkaonTime()))
486                     imost = 0;
487                   else
488                     imost = 3;
489                 }
490                 else {
491                   if (!(IsKaonTPCdEdx(track->P().Mag(), track->TPCsignal())))
492                     imost = 0;
493                   else 
494                     imost = 3;
495                 }
496               }
497             }
498             //       }
499           }
500         }
501     if (imost != fMostProbable) return false;
502   }
503   
504   //fan
505   //cout<<"****** Go Through the cut ******"<<endl;
506   // cout<<fLabel<<" Label="<<track->Label()<<endl;
507   // cout<<fCharge<<" Charge="<<track->Charge()<<endl;
508   // cout<<fPt[0]<<" < Pt ="<<Pt<<" <"<<fPt[1]<<endl;
509   //cout<<fRapidity[0]<<" < Rapidity ="<<tRapidity<<" <"<<fRapidity[1]<<endl;
510   //cout<<fPidProbElectron[0]<<" <  e="<<track->PidProbElectron()<<" <"<<fPidProbElectron[1]<<endl;
511   //cout<<fPidProbPion[0]<<" <  pi="<<track->PidProbPion()<<" <"<<fPidProbPion[1]<<endl;
512   //cout<<fPidProbKaon[0]<<" <  k="<<track->PidProbKaon()<<" <"<<fPidProbKaon[1]<<endl;
513   //cout<<fPidProbProton[0]<<" <  p="<<track->PidProbProton()<<" <"<<fPidProbProton[1]<<endl;
514   //cout<<fPidProbMuon[0]<<" <  mi="<<track->PidProbMuon()<<" <"<<fPidProbMuon[1]<<endl;
515   fNTracksPassed++ ;
516   return true;
517     
518     
519 }
520 //------------------------------
521 AliFemtoString AliFemtoKKTrackCut::Report()
522 {
523   // Prepare report from the execution
524   string tStemp;
525   char tCtemp[100];
526   snprintf(tCtemp , 100, "Particle mass:\t%E\n",this->Mass());
527   tStemp=tCtemp;
528   snprintf(tCtemp , 100, "Particle charge:\t%d\n",fCharge);
529   tStemp+=tCtemp;
530   snprintf(tCtemp , 100, "Particle pT:\t%E - %E\n",fPt[0],fPt[1]);
531   tStemp+=tCtemp;
532   snprintf(tCtemp , 100, "Particle rapidity:\t%E - %E\n",fRapidity[0],fRapidity[1]);
533   tStemp+=tCtemp; 
534   snprintf(tCtemp , 100, "Particle eta:\t%E - %E\n",fEta[0],fEta[1]);
535   tStemp+=tCtemp;
536   snprintf(tCtemp , 100, "Number of tracks which passed:\t%ld  Number which failed:\t%ld\n",fNTracksPassed,fNTracksFailed);
537   tStemp += tCtemp;
538   AliFemtoString returnThis = tStemp;
539   return returnThis;
540 }
541 TList *AliFemtoKKTrackCut::ListSettings()
542 {
543   // return a list of settings in a writable form
544   TList *tListSetttings = new TList();
545   char buf[200];
546   snprintf(buf, 200, "AliFemtoKKTrackCut.mass=%f", this->Mass());
547   tListSetttings->AddLast(new TObjString(buf));
548
549   snprintf(buf, 200, "AliFemtoKKTrackCut.charge=%i", fCharge);
550   tListSetttings->AddLast(new TObjString(buf));
551   snprintf(buf, 200, "AliFemtoKKTrackCut.pidprobpion.minimum=%f", fPidProbPion[0]);
552   tListSetttings->AddLast(new TObjString(buf));
553   snprintf(buf, 200, "AliFemtoKKTrackCut.pidprobpion.maximum=%f", fPidProbPion[1]);
554   tListSetttings->AddLast(new TObjString(buf));
555   snprintf(buf, 200, "AliFemtoKKTrackCut.pidprobkaon.minimum=%f", fPidProbKaon[0]);
556   tListSetttings->AddLast(new TObjString(buf));
557   snprintf(buf, 200, "AliFemtoKKTrackCut.pidprobkaon.maximum=%f", fPidProbKaon[1]);
558   tListSetttings->AddLast(new TObjString(buf));
559   snprintf(buf, 200, "AliFemtoKKTrackCut.pidprobproton.minimum=%f", fPidProbProton[0]);
560   tListSetttings->AddLast(new TObjString(buf));
561   snprintf(buf, 200, "AliFemtoKKTrackCut.pidprobproton.maximum=%f", fPidProbProton[1]);
562   tListSetttings->AddLast(new TObjString(buf));
563   snprintf(buf, 200, "AliFemtoKKTrackCut.pidprobelectron.minimum=%f", fPidProbElectron[0]);
564   tListSetttings->AddLast(new TObjString(buf));
565   snprintf(buf, 200, "AliFemtoKKTrackCut.pidprobelectron.maximum=%f", fPidProbElectron[1]);
566   tListSetttings->AddLast(new TObjString(buf));
567   snprintf(buf, 200, "AliFemtoKKTrackCut.pidprobMuon.minimum=%f", fPidProbMuon[0]);
568   tListSetttings->AddLast(new TObjString(buf));
569   snprintf(buf, 200, "AliFemtoKKTrackCut.pidprobMuon.maximum=%f", fPidProbMuon[1]);
570   tListSetttings->AddLast(new TObjString(buf));
571   snprintf(buf, 200, "AliFemtoKKTrackCut.minimumtpcclusters=%i", fminTPCclsF);
572   tListSetttings->AddLast(new TObjString(buf));
573   snprintf(buf, 200, "AliFemtoKKTrackCut.minimumitsclusters=%i", fminTPCclsF);
574   tListSetttings->AddLast(new TObjString(buf));
575   snprintf(buf, 200, "AliFemtoKKTrackCut.pt.minimum=%f", fPt[0]);
576   tListSetttings->AddLast(new TObjString(buf));
577   snprintf(buf, 200, "AliFemtoKKTrackCut.pt.maximum=%f", fPt[1]);
578   tListSetttings->AddLast(new TObjString(buf));
579   snprintf(buf, 200, "AliFemtoKKTrackCut.rapidity.minimum=%f", fRapidity[0]);
580   tListSetttings->AddLast(new TObjString(buf));
581   snprintf(buf, 200, "AliFemtoKKTrackCut.rapidity.maximum=%f", fRapidity[1]);
582   tListSetttings->AddLast(new TObjString(buf));
583   snprintf(buf, 200, "AliFemtoKKTrackCut.removekinks=%i", fRemoveKinks);
584   tListSetttings->AddLast(new TObjString(buf));
585   snprintf(buf, 200, "AliFemtoKKTrackCut.maxitschindof=%f", fMaxITSchiNdof);
586   tListSetttings->AddLast(new TObjString(buf));
587   snprintf(buf, 200, "AliFemtoKKTrackCut.maxtpcchindof=%f", fMaxTPCchiNdof);
588   tListSetttings->AddLast(new TObjString(buf));
589   snprintf(buf, 200, "AliFemtoKKTrackCut.maxsigmatovertex=%f", fMaxSigmaToVertex);
590   tListSetttings->AddLast(new TObjString(buf));
591   snprintf(buf, 200, "AliFemtoKKTrackCut.maximpactxy=%f", fMaxImpactXY);
592   tListSetttings->AddLast(new TObjString(buf));
593   snprintf(buf, 200, "AliFemtoKKTrackCut.maximpactz=%f", fMaxImpactZ);
594   tListSetttings->AddLast(new TObjString(buf));
595   if (fMostProbable) {
596     if (fMostProbable == 2)
597       snprintf(buf, 200, "AliFemtoKKTrackCut.mostprobable=%s", "Pion");
598     if (fMostProbable == 3)
599       snprintf(buf, 200, "AliFemtoKKTrackCut.mostprobable=%s", "Kaon");
600     if (fMostProbable == 4)
601       snprintf(buf, 200, "AliFemtoKKTrackCut.mostprobable=%s", "Proton");
602     tListSetttings->AddLast(new TObjString(buf));
603   }
604   return tListSetttings;
605 }
606 void AliFemtoKKTrackCut::SetRemoveKinks(const bool& flag)
607 {
608   fRemoveKinks = flag;
609 }
610                             
611 void AliFemtoKKTrackCut::SetRemoveITSFake(const bool& flag)
612 {
613   fRemoveITSFake = flag;
614 }
615                             
616 // electron
617 // 0.13 - 1.8
618 // 0       7.594129e-02    8.256141e-03
619 // 1       -5.535827e-01   8.170825e-02
620 // 2       1.728591e+00    3.104210e-01
621 // 3       -2.827893e+00   5.827802e-01
622 // 4       2.503553e+00    5.736207e-01
623 // 5       -1.125965e+00   2.821170e-01
624 // 6       2.009036e-01    5.438876e-02
625 float AliFemtoKKTrackCut::PidFractionElectron(float mom) const
626 {
627   // Provide a parameterized fraction of electrons dependent on momentum
628   if (mom<0.13) 
629     return (7.594129e-02 
630             -5.535827e-01*0.13     
631             +1.728591e+00*0.13*0.13    
632             -2.827893e+00*0.13*0.13*0.13 
633             +2.503553e+00*0.13*0.13*0.13*0.13      
634             -1.125965e+00*0.13*0.13*0.13*0.13*0.13      
635             +2.009036e-01*0.13*0.13*0.13*0.13*0.13*0.13);   
636
637   if (mom>1.8)
638     return (7.594129e-02 
639             -5.535827e-01*1.8      
640             +1.728591e+00*1.8*1.8    
641             -2.827893e+00*1.8*1.8*1.8 
642             +2.503553e+00*1.8*1.8*1.8*1.8          
643             -1.125965e+00*1.8*1.8*1.8*1.8*1.8      
644             +2.009036e-01*1.8*1.8*1.8*1.8*1.8*1.8);   
645   return (7.594129e-02 
646           -5.535827e-01*mom        
647           +1.728591e+00*mom*mom    
648           -2.827893e+00*mom*mom*mom 
649           +2.503553e+00*mom*mom*mom*mom    
650           -1.125965e+00*mom*mom*mom*mom*mom      
651           +2.009036e-01*mom*mom*mom*mom*mom*mom);   
652 }
653
654 // pion
655 // 0.13 - 2.0
656 // 0       1.063457e+00    8.872043e-03
657 // 1       -4.222208e-01   2.534402e-02
658 // 2       1.042004e-01    1.503945e-02
659 float AliFemtoKKTrackCut::PidFractionPion(float mom) const
660 {
661   // Provide a parameterized fraction of pions dependent on momentum
662   if (mom<0.13) 
663     return ( 1.063457e+00
664              -4.222208e-01*0.13
665              +1.042004e-01*0.0169);
666   if (mom>2.0) 
667     return ( 1.063457e+00
668              -4.222208e-01*2.0
669              +1.042004e-01*4.0);
670   return ( 1.063457e+00
671            -4.222208e-01*mom
672            +1.042004e-01*mom*mom);
673 }
674
675 // kaon
676 // 0.18 - 2.0
677 // 0       -7.289406e-02   1.686074e-03
678 // 1       4.415666e-01    1.143939e-02
679 // 2       -2.996790e-01   1.840964e-02
680 // 3       6.704652e-02    7.783990e-03
681 float AliFemtoKKTrackCut::PidFractionKaon(float mom) const
682 {
683   // Provide a parameterized fraction of kaons dependent on momentum
684   if (mom<0.18) 
685     return (-7.289406e-02
686             +4.415666e-01*0.18     
687             -2.996790e-01*0.18*0.18    
688             +6.704652e-02*0.18*0.18*0.18);
689   if (mom>2.0) 
690     return (-7.289406e-02
691             +4.415666e-01*2.0      
692             -2.996790e-01*2.0*2.0    
693             +6.704652e-02*2.0*2.0*2.0);
694   return (-7.289406e-02
695           +4.415666e-01*mom        
696           -2.996790e-01*mom*mom    
697           +6.704652e-02*mom*mom*mom);
698 }
699
700 // proton
701 // 0.26 - 2.0
702 // 0       -3.730200e-02   2.347311e-03
703 // 1       1.163684e-01    1.319316e-02
704 // 2       8.354116e-02    1.997948e-02
705 // 3       -4.608098e-02   8.336400e-03
706 float AliFemtoKKTrackCut::PidFractionProton(float mom) const
707 {
708   // Provide a parameterized fraction of protons dependent on momentum
709   if (mom<0.26) return  0.0;
710   if (mom>2.0) 
711     return (-3.730200e-02  
712             +1.163684e-01*2.0         
713             +8.354116e-02*2.0*2.0       
714             -4.608098e-02*2.0*2.0*2.0);
715   return (-3.730200e-02  
716           +1.163684e-01*mom           
717           +8.354116e-02*mom*mom       
718           -4.608098e-02*mom*mom*mom);  
719 }
720
721 void AliFemtoKKTrackCut::SetMomRangeTOFpidIs(const float& minp, const float& maxp)
722 {
723   fMinPforTOFpid = minp;
724   fMaxPforTOFpid = maxp;
725 }
726
727 void AliFemtoKKTrackCut::SetMomRangeTPCpidIs(const float& minp, const float& maxp)
728 {
729   fMinPforTPCpid = minp;
730   fMaxPforTPCpid = maxp;
731 }
732
733 void AliFemtoKKTrackCut::SetMomRangeITSpidIs(const float& minp, const float& maxp)
734 {
735   fMinPforITSpid = minp;
736   fMaxPforITSpid = maxp;
737 }
738
739 bool AliFemtoKKTrackCut::IsPionTPCdEdx(float mom, float dEdx)
740 {
741   //   double a1 = -95.4545, b1 = 86.5455;
742   //   double a2 = 0.0,      b2 = 56.0;
743   double a1 = -343.75,  b1 = 168.125;
744   double a2 = 0.0,      b2 = 65.0;
745
746   if (mom < 0.32) {
747     if (dEdx < a1*mom+b1) return true;
748   }
749   if (dEdx < a2*mom+b2) return true;
750
751   return false;
752 }
753
754 bool AliFemtoKKTrackCut::IsKaonTPCdEdx(float mom, float dEdx)
755 {
756
757 //   double a1 = -547.0; double b1 =  297.0;
758 //   double a2 = -125.0; double b2 =  145.0;
759 //   double a3 = -420.0; double b3 =  357.0;
760 //   double a4 = -110.0; double b4 =  171.0;
761 //   double b5 =   72.0;
762
763 //   if (mom<0.2) return false;
764
765 //   if (mom<0.36) {
766 //     if (dEdx < a1*mom+b1) return false;
767 //     if (dEdx > a3*mom+b3) return false;
768 //   }
769 //   else if (mom<0.6) {
770 //     if (dEdx < a2*mom+b2) return false;
771 //     if (dEdx > a3*mom+b3) return false;
772 //   }
773 //   else if (mom<0.9) {
774 //     if (dEdx > a4*mom+b4) return false;
775 //     if (dEdx <        b5) return false;
776 //   }
777 //   else 
778 //     return false;
779 //   //   else {
780 //   //     if (dEdx > b5) return false;
781 //   //   }
782    
783 //   return true;
784
785   double a1 = -268.896; double b1 =  198.669;
786   double a2 = -49.0012;  double b2 =  88.7214;
787
788   if (mom<0.2) return false;
789
790   if (mom>0.3 && mom<0.5) {
791     if (dEdx < a1*mom+b1) return false;
792   }
793   else  if (mom<1.2) {
794     if (dEdx < a2*mom+b2) return false;
795   }
796
797   return true;
798
799 }
800
801 bool AliFemtoKKTrackCut::IsProtonTPCdEdx(float mom, float dEdx)
802 {
803   double a1 = -1800.0; double b1 =  940.0;
804   double a2 = -500.0;  double b2 =  420.0;
805   double a3 = -216.7;  double b3 =  250.0;
806
807   if (mom<0.2) return false;
808
809   if (mom>0.3 && mom<0.4) {
810     if (dEdx < a1*mom+b1) return false;
811   }
812   else  if (mom<0.6) {
813     if (dEdx < a2*mom+b2) return false;
814   }
815   else  if (mom<0.9) {
816     if (dEdx < a3*mom+b3) return false;
817   }
818
819   return true;
820    
821 }
822
823 bool AliFemtoKKTrackCut::IsPionTOFTime(float mom, float ttof)
824 {
825   double a1 = -427.0; double b1 =  916.0;
826   double a2 =  327.0; double b2 = -888.0;
827   if (mom<0.3) return kFALSE;
828   if (mom>2.0) return kFALSE;
829   if (ttof > a1*mom+b1) return kFALSE;
830   if (ttof < a2*mom+b2) return kFALSE;
831
832   return kTRUE;
833 }
834
835 bool AliFemtoKKTrackCut::IsKaonTOFTime(float mom, float ttof)
836 {
837   double a1 =   000.0; double b1 =  -500.0;
838   double a2 =   000.0; double b2 =   500.0;
839   double a3 =   850.0; double b3 = -1503.0;
840   double a4 = -1637.0; double b4 =  3621.0;
841
842   if (mom<0.3) return kFALSE;
843   if (mom>2.06) return kFALSE;
844   if (mom<1.2) {
845     if (ttof > a2*mom+b2) return kFALSE;
846     if (ttof < a1*mom+b1) return kFALSE;
847   }
848   if (mom<1.9) {
849     if (ttof > a2*mom+b2) return kFALSE;
850     if (ttof < a3*mom+b3) return kFALSE;
851   }
852   if (mom<2.06) {
853     if (ttof > a4*mom+b4) return kFALSE;
854     if (ttof < a3*mom+b3) return kFALSE;
855   }
856   return kTRUE;
857 }
858
859 bool AliFemtoKKTrackCut::IsProtonTOFTime(float mom, float ttof)
860 {
861   double a1 =   000.0; double b1 =  -915.0;
862   double a2 =   000.0; double b2 =   600.0;
863   double a3 =   572.0; double b3 = -1715.0;
864
865   if (mom<0.3) return kFALSE;
866   if (mom>3.0) return kFALSE;
867   if (mom<1.4) {
868     if (ttof > a2*mom+b2) return kFALSE;
869     if (ttof < a1*mom+b1) return kFALSE;
870   }
871   if (mom<3.0) {
872     if (ttof > a2*mom+b2) return kFALSE;
873     if (ttof < a3*mom+b3) return kFALSE;
874   }
875   return kTRUE;
876 }
877
878
879
880
881 bool AliFemtoKKTrackCut::IsKaonTPCdEdxNSigma(float mom, float nsigmaK)
882 {
883 //  cout<<" AliFemtoKKTrackCut::IsKaonTPCdEdxNSigma "<<mom<<" "<<nsigmaK<<endl;
884
885
886   if(mom<0.35 && TMath::Abs(nsigmaK)<5.0)return true;
887   if(mom>=0.35 && mom<0.5 && TMath::Abs(nsigmaK)<3.0)return true; 
888   if(mom>=0.5 && mom<0.7 && TMath::Abs(nsigmaK)<2.0)return true;
889
890   return false;
891 }
892
893 bool AliFemtoKKTrackCut::IsKaonTOFNSigma(float mom, float nsigmaK)
894 {
895 //  cout<<" AliFemtoKKTrackCut::IsKaonTPCdEdxNSigma "<<mom<<" "<<nsigmaK<<endl;
896   //fan
897   //  if(mom<1.5 && TMath::Abs(nsigmaK)<3.0)return true;
898   if(mom>=1.5 && TMath::Abs(nsigmaK)<2.0)return true; 
899   return false;
900 }
901
902
903 bool AliFemtoKKTrackCut::IsKaonNSigma(float mom, float nsigmaTPCK, float nsigmaTOFK)
904 {
905
906   if(mom<0.25)
907     {
908       if(TMath::Abs(nsigmaTPCK)<fNsigmaTPCle250)
909         { 
910           return true;
911         } 
912       else 
913         {
914           return false;
915         }
916     }
917
918   if(mom>=0.25 && mom<0.4)
919     {
920       if(TMath::Abs(nsigmaTPCK)<fNsigmaTPC250_400)
921         { 
922           return true;
923         } 
924       else 
925         {
926           return false;
927         }
928     }
929
930   if(mom>=0.4 && mom<0.45)
931     {
932       if(TMath::Abs(nsigmaTPCK)<fNsigmaTPC400_450)
933         { 
934           return true;
935         } 
936       else 
937         {
938           return false;
939         }
940     }
941
942  if(mom>=0.45 && mom<0.5)
943     {
944       if(TMath::Abs(nsigmaTPCK)<fNsigmaTPC450_500)
945         { 
946           return true;
947         } 
948       else 
949         {
950           return false;
951         }
952     }
953
954 /////////////  
955   
956   
957   
958   if(mom>=0.5 && mom<0.8)
959     {
960       if(TMath::Abs(nsigmaTOFK)<fNsigmaTOF500_800 && TMath::Abs(nsigmaTPCK)<fNsigmaTPCge500) 
961         {
962           //     cout<<"500-800 "<<fNsigmaTOF500_800<<" "<<nsigmaTOFK<<endl;
963           return true;
964         }
965       else
966         {
967           return false;
968         }
969     }
970
971   if(mom>=0.8 && mom<1.0)
972     {
973       if(TMath::Abs(nsigmaTOFK)<fNsigmaTOF800_1000 && TMath::Abs(nsigmaTPCK)<fNsigmaTPCge500) 
974         {
975           //          cout<<"800-1000 "<<fNsigmaTOF800_1000<<" "<<nsigmaTOFK<<endl;
976           return true;
977         }
978       else
979         {
980           return false;
981         }
982     }
983
984  if(mom>=1.0)
985     {
986       if(TMath::Abs(nsigmaTOFK)<fNsigmaTOFge1000 && TMath::Abs(nsigmaTPCK)<fNsigmaTPCge500) 
987         {
988           //      cout<<">1000 "<<fNsigmaTOFge1000<<" "<<nsigmaTOFK<<endl;
989           return true;
990         }
991       else
992         {
993           return false;
994         }
995     }
996     
997     
998     
999 //   if(mom>1.5 || mom<0.15)return false;
1000   return false;
1001
1002 }
1003
1004
1005
1006 /* old
1007 bool AliFemtoKKTrackCut::IsKaonNSigma(float mom, float nsigmaTPCK, float nsigmaTOFK)
1008 {
1009
1010   if(mom<0.4)
1011     {
1012       if(nsigmaTOFK<-999.)
1013         {
1014           if(TMath::Abs(nsigmaTPCK)<2.0) return true;
1015         }
1016       else if(TMath::Abs(nsigmaTOFK)<3.0 && TMath::Abs(nsigmaTPCK)<3.0) return true;
1017     }
1018   else if(mom>=0.4 && mom<=0.6)
1019     {
1020       if(nsigmaTOFK<-999.)
1021         {
1022           if(TMath::Abs(nsigmaTPCK)<2.0) return true;
1023         }
1024       else if(TMath::Abs(nsigmaTOFK)<3.0 && TMath::Abs(nsigmaTPCK)<3.0) return true;
1025     }
1026   else if(nsigmaTOFK<-999.)
1027     {
1028       return false;
1029     }
1030   else if(TMath::Abs(nsigmaTOFK)<3.0 && TMath::Abs(nsigmaTPCK)<3.0) return true;
1031
1032   return false;
1033 }
1034 */
1035
1036
1037 bool AliFemtoKKTrackCut::IsPionNSigma(float mom, float nsigmaTPCPi, float nsigmaTOFPi)
1038 {
1039   if(mom<0.65)
1040     {
1041       if(nsigmaTOFPi<-999.)
1042         {
1043           if(mom<0.35 && TMath::Abs(nsigmaTPCPi)<3.0) return true;
1044           else if(mom<0.5 && mom>=0.35 && TMath::Abs(nsigmaTPCPi)<3.0) return true;
1045           else if(mom>=0.5 && TMath::Abs(nsigmaTPCPi)<2.0) return true;
1046           else return false;      
1047         }
1048       else if(TMath::Abs(nsigmaTOFPi)<3.0 && TMath::Abs(nsigmaTPCPi)<3.0) return true;
1049     }
1050   else if(nsigmaTOFPi<-999.)
1051     {
1052       return false;
1053     }
1054   else if(mom<1.5 && TMath::Abs(nsigmaTOFPi)<3.0 && TMath::Abs(nsigmaTPCPi)<5.0) return true;
1055   else if(mom>=1.5 && TMath::Abs(nsigmaTOFPi)<2.0 && TMath::Abs(nsigmaTPCPi)<5.0) return true;
1056
1057   return false;
1058 }
1059
1060
1061 bool AliFemtoKKTrackCut::IsProtonNSigma(float mom, float nsigmaTPCP, float nsigmaTOFP)
1062 {
1063     if (mom > 0.8) {
1064         if (TMath::Hypot( nsigmaTOFP, nsigmaTPCP )/TMath::Sqrt(2) < 3.0)
1065             return true;
1066         }
1067     else {
1068         if (TMath::Abs(nsigmaTPCP) < 3.0)
1069             return true;
1070     }
1071
1072   return false;
1073 }
1074
1075
1076 void AliFemtoKKTrackCut::SetPIDMethod(ReadPIDMethodType newMethod)
1077 {
1078   fPIDMethod = newMethod;
1079 }
1080
1081
1082 void AliFemtoKKTrackCut::SetClusterRequirementITS(AliESDtrackCuts::Detector det, AliESDtrackCuts::ITSClusterRequirement req) 
1083
1084   fCutClusterRequirementITS[det] = req; 
1085 }
1086
1087 Bool_t AliFemtoKKTrackCut::CheckITSClusterRequirement(AliESDtrackCuts::ITSClusterRequirement req, Bool_t clusterL1, Bool_t clusterL2)
1088 {
1089   // checks if the cluster requirement is fullfilled (in this case: return kTRUE)
1090   
1091   switch (req)
1092     {
1093     case AliESDtrackCuts::kOff:        return kTRUE;
1094     case AliESDtrackCuts::kNone:       return !clusterL1 && !clusterL2;
1095     case AliESDtrackCuts::kAny:        return clusterL1 || clusterL2;
1096     case AliESDtrackCuts::kFirst:      return clusterL1;
1097     case AliESDtrackCuts::kOnlyFirst:  return clusterL1 && !clusterL2;
1098     case AliESDtrackCuts::kSecond:     return clusterL2;
1099     case AliESDtrackCuts::kOnlySecond: return clusterL2 && !clusterL1;
1100     case AliESDtrackCuts::kBoth:       return clusterL1 && clusterL2;
1101   }
1102   
1103   return kFALSE;
1104 }
1105
1106
1107 void AliFemtoKKTrackCut::SetNsigmaTPCle250(Double_t nsigma)
1108 {
1109   fNsigmaTPCle250 = nsigma;
1110 }
1111
1112 void AliFemtoKKTrackCut::SetNsigmaTPC250_400(Double_t nsigma)
1113 {
1114   fNsigmaTPC250_400 = nsigma;
1115 }
1116
1117 void AliFemtoKKTrackCut::SetNsigmaTPC400_450(Double_t nsigma)
1118 {
1119   fNsigmaTPC400_450 = nsigma;
1120 }
1121
1122 void AliFemtoKKTrackCut::SetNsigmaTPC450_500(Double_t nsigma)
1123 {
1124   fNsigmaTPC450_500 = nsigma;
1125 }
1126
1127 void AliFemtoKKTrackCut::SetNsigmaTPCge500(Double_t nsigma)
1128 {
1129   fNsigmaTPCge500 = nsigma;
1130 }
1131
1132
1133
1134 void AliFemtoKKTrackCut::SetNsigmaTOF500_800(Double_t nsigma)
1135 {
1136   fNsigmaTOF500_800 = nsigma;
1137 }
1138
1139
1140 void AliFemtoKKTrackCut::SetNsigmaTOF800_1000(Double_t nsigma)
1141 {
1142   fNsigmaTOF800_1000 = nsigma;
1143 }
1144
1145 void AliFemtoKKTrackCut::SetNsigmaTOFge1000(Double_t nsigma)
1146 {
1147   fNsigmaTOFge1000 = nsigma;
1148 }