]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/FEMTOSCOPY/AliFemtoUser/AliFemtoESDTrackCut.cxx
Migration of PWG2/FEMTOSCOPY to PWGCF/FEMTOSCOPY
[u/mrichter/AliRoot.git] / PWGCF / FEMTOSCOPY / AliFemtoUser / AliFemtoESDTrackCut.cxx
1 /*
2 ***************************************************************************
3 *
4 * $Id$ 
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 "AliFemtoESDTrackCut.h"
48 #include <cstdio>
49
50 #ifdef __ROOT__ 
51 ClassImp(AliFemtoESDTrackCut)
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   AliFemtoESDTrackCut::AliFemtoESDTrackCut() :
87     fCharge(0),
88     fLabel(0),
89     fStatus(0),
90     fPIDMethod(knSigma),
91     fminTPCclsF(0),
92     fminTPCncls(0),
93     fminITScls(0),
94     fMaxITSchiNdof(1000.0),
95     fMaxTPCchiNdof(1000.0),
96     fMaxSigmaToVertex(1000.0),
97     fNTracksPassed(0),
98     fNTracksFailed(0),
99     fRemoveKinks(kFALSE),
100     fRemoveITSFake(kFALSE),
101     fMostProbable(0), 
102     fMaxImpactXY(1000.0),
103     fMaxImpactZ(1000.0),
104     fMaxImpactXYPtOff(1000.0),
105     fMaxImpactXYPtNrm(1000.0),
106     fMaxImpactXYPtPow(1000.0),
107     fMinPforTOFpid(0.0),
108     fMaxPforTOFpid(10000.0),
109     fMinPforTPCpid(0.0),
110     fMaxPforTPCpid(10000.0),
111     fMinPforITSpid(0.0),
112     fMaxPforITSpid(10000.0)
113 {
114   // Default constructor
115   fNTracksPassed = fNTracksFailed = 0;
116   fCharge = 0;  // takes both charges 0
117   fPt[0]=0.0;              fPt[1] = 100.0;//100
118   fRapidity[0]=-2;       fRapidity[1]=2;//-2 2
119   fEta[0]=-2;       fEta[1]=2;//-2 2
120   fPidProbElectron[0]=-1;fPidProbElectron[1]=2;
121   fPidProbPion[0]=-1;    fPidProbPion[1]=2;
122   fPidProbKaon[0]=-1;fPidProbKaon[1]=2;
123   fPidProbProton[0]=-1;fPidProbProton[1]=2;
124   fPidProbMuon[0]=-1;fPidProbMuon[1]=2;
125   fLabel=false;
126   fStatus=0;
127   fminTPCclsF=0;
128   fminITScls=0;
129   fPIDMethod=knSigma;
130 }
131 //------------------------------
132 AliFemtoESDTrackCut::~AliFemtoESDTrackCut(){
133   /* noop */
134 }
135 //------------------------------
136 bool AliFemtoESDTrackCut::Pass(const AliFemtoTrack* track)
137 {
138   // test the particle and return 
139   // true if it meets all the criteria
140   // false if it doesn't meet at least one of the criteria
141   float tMost[5];
142   
143   //cout<<"AliFemtoESD  cut"<<endl;
144   //cout<<fPidProbPion[0]<<" < pi ="<<track->PidProbPion()<<" <"<<fPidProbPion[1]<<endl;
145   if (fStatus!=0)
146     {
147       //cout<<" status "<<track->Label()<<" "<<track->Flags()<<" "<<track->TPCnclsF()<<" "<<track->ITSncls()<<endl;
148       if ((track->Flags()&fStatus)!=fStatus)
149         {
150           //      cout<<track->Flags()<<" "<<fStatus<<" no go through status"<<endl;
151           return false;
152         }
153         
154     }
155   if (fRemoveKinks) {
156     if ((track->KinkIndex(0)) || (track->KinkIndex(1)) || (track->KinkIndex(2)))
157       return false;
158   }
159   if (fRemoveITSFake) {
160     if (track->ITSncls() < 0)
161       return false;
162   }
163   if (fminTPCclsF>track->TPCnclsF())
164     {
165       //cout<<" No go because TPC Number of ClsF"<<fminTPCclsF<< " "<<track->TPCnclsF()<<endl;
166       return false;
167     }
168   if (fminTPCncls>track->TPCncls())
169     {
170       //cout<<" No go because TPC Number of ClsF"<<fminTPCclsF<< " "<<track->TPCnclsF()<<endl;
171       return false;
172     }
173   if (fminITScls>track->ITSncls())
174     {
175       //cout<<" No go because ITS Number of Cls"<<fminITScls<< " "<<track->ITSncls()<<endl;
176       return false;
177     }
178
179   if (fMaxImpactXY < TMath::Abs(track->ImpactD()))
180     return false;
181
182   if (fMaxImpactZ < TMath::Abs(track->ImpactZ()))
183     return false;
184   
185   if (fMaxSigmaToVertex < track->SigmaToVertex()) {
186     return false;
187   }
188   
189   if (track->ITSncls() > 0) 
190     if ((track->ITSchi2()/track->ITSncls()) > fMaxITSchiNdof) {
191       return false;
192     }
193
194   if (track->TPCncls() > 0)
195     if ((track->TPCchi2()/track->TPCncls()) > fMaxTPCchiNdof) {
196       return false;
197     }
198
199   if (fLabel)
200     {
201       //cout<<"labels"<<endl;
202       if(track->Label()<0)
203         {
204           fNTracksFailed++;
205           //   cout<<"No Go Through the cut"<<endl;
206           //  cout<<fLabel<<" Label="<<track->Label()<<endl;
207           return false;
208         }    
209     }
210   if (fCharge!=0)
211     {              
212       //cout<<"AliFemtoESD  cut ch "<<endl;
213       //cout<<fCharge<<" Charge="<<track->Charge()<<endl;
214       if (track->Charge()!= fCharge)    
215         {
216           fNTracksFailed++;
217           //  cout<<"No Go Through the cut"<<endl;
218           // cout<<fCharge<<" Charge="<<track->Charge()<<endl;
219           return false;
220         }
221     }
222   Bool_t tTPCPidIn = (track->Flags()&AliFemtoTrack::kTPCpid)>0;
223   Bool_t tITSPidIn = (track->Flags()&AliFemtoTrack::kITSpid)>0;
224   Bool_t tTOFPidIn = (track->Flags()&AliFemtoTrack::kTOFpid)>0;
225   
226   if(fMinPforTOFpid > 0 && track->P().Mag() > fMinPforTOFpid &&
227      track->P().Mag() < fMaxPforTOFpid && !tTOFPidIn)
228     {
229       fNTracksFailed++;
230       return false;
231     }
232   
233   if(fMinPforTPCpid > 0 && track->P().Mag() > fMinPforTPCpid &&
234      track->P().Mag() < fMaxPforTPCpid && !tTPCPidIn)
235     {
236       fNTracksFailed++;
237       return false;
238     }
239   
240   if(fMinPforITSpid > 0 && track->P().Mag() > fMinPforITSpid &&
241      track->P().Mag() < fMaxPforITSpid && !tITSPidIn)
242     {
243       fNTracksFailed++;
244       return false;
245     }
246   
247
248   float tEnergy = ::sqrt(track->P().Mag2()+fMass*fMass);
249   float tRapidity = 0.5*::log((tEnergy+track->P().z())/(tEnergy-track->P().z()));
250   float tPt = ::sqrt((track->P().x())*(track->P().x())+(track->P().y())*(track->P().y()));
251   float tEta = track->P().PseudoRapidity();
252   
253   if (fMaxImpactXYPtOff < 999.0) {
254     if ((fMaxImpactXYPtOff + fMaxImpactXYPtNrm*TMath::Power(tPt, fMaxImpactXYPtPow)) < TMath::Abs(track->ImpactD())) {
255       fNTracksFailed++;
256       return false;
257     }
258   }
259
260   if ((tRapidity<fRapidity[0])||(tRapidity>fRapidity[1]))
261     {
262       fNTracksFailed++;
263       //cout<<"No Go Through the cut"<<endl;   
264       //cout<<fRapidity[0]<<" < Rapidity ="<<tRapidity<<" <"<<fRapidity[1]<<endl;
265       return false;
266     }
267   if ((tEta<fEta[0])||(tEta>fEta[1]))
268     {
269       fNTracksFailed++;
270       //cout<<"No Go Through the cut"<<endl;   
271       //cout<<fEta[0]<<" < Eta ="<<tEta<<" <"<<fEta[1]<<endl;
272       return false;
273     }
274   if ((tPt<fPt[0])||(tPt>fPt[1]))
275     {
276       fNTracksFailed++;
277       //cout<<"No Go Through the cut"<<endl;
278       //cout<<fPt[0]<<" < Pt ="<<Pt<<" <"<<fPt[1]<<endl;
279       return false;
280     }
281   //   cout << "Track has pids: " 
282   //        << track->PidProbElectron() << " " 
283   //        << track->PidProbMuon() << " " 
284   //        << track->PidProbPion() << " " 
285   //        << track->PidProbKaon() << " " 
286   //        << track->PidProbProton() << " " 
287   //        << track->PidProbElectron()+track->PidProbMuon()+track->PidProbPion()+track->PidProbKaon()+track->PidProbProton() << endl;
288
289     
290   if ((track->PidProbElectron()<fPidProbElectron[0])||(track->PidProbElectron()>fPidProbElectron[1]))
291     {
292       fNTracksFailed++;
293       //cout<<"No Go Through the cut"<<endl;
294       //cout<<fPidProbElectron[0]<<" < e ="<<track->PidProbElectron()<<" <"<<fPidProbElectron[1]<<endl;
295       return false;
296     }
297   if ((track->PidProbPion()<fPidProbPion[0])||(track->PidProbPion()>fPidProbPion[1]))
298     {
299       fNTracksFailed++;
300       //cout<<"No Go Through the cut"<<endl;
301       //cout<<fPidProbPion[0]<<" < pi ="<<track->PidProbPion()<<" <"<<fPidProbPion[1]<<endl;
302       return false;
303     }
304   if ((track->PidProbKaon()<fPidProbKaon[0])||(track->PidProbKaon()>fPidProbKaon[1]))
305     {
306       fNTracksFailed++;
307       //cout<<"No Go Through the cut"<<endl;
308       //cout<<fPidProbKaon[0]<<" < k ="<<track->PidProbKaon()<<" <"<<fPidProbKaon[1]<<endl;
309       return false;
310     }
311   if ((track->PidProbProton()<fPidProbProton[0])||(track->PidProbProton()>fPidProbProton[1]))
312     {
313       fNTracksFailed++;
314       //cout<<"No Go Through the cut"<<endl;
315       //cout<<fPidProbProton[0]<<" < p  ="<<track->PidProbProton()<<" <"<<fPidProbProton[1]<<endl;
316       return false;
317     }
318   if ((track->PidProbMuon()<fPidProbMuon[0])||(track->PidProbMuon()>fPidProbMuon[1]))
319     {
320       fNTracksFailed++;
321       //cout<<"No Go Through the cut"<<endl;
322       //cout<<fPidProbMuon[0]<<" <  mi="<<track->PidProbMuon()<<" <"<<fPidProbMuon[1]<<endl;
323       return false;
324     }
325
326   if (fMostProbable) {
327     int imost=0;
328     tMost[0] = track->PidProbElectron()*PidFractionElectron(track->P().Mag());
329     tMost[1] = 0.0;
330     tMost[2] = track->PidProbPion()*PidFractionPion(track->P().Mag());
331     tMost[3] = track->PidProbKaon()*PidFractionKaon(track->P().Mag());
332     tMost[4] = track->PidProbProton()*PidFractionProton(track->P().Mag());
333     float ipidmax = 0.0;
334
335
336     //****N Sigma Method****
337         if(fPIDMethod==0){
338           // Looking for pions
339           if (fMostProbable == 2) {
340             if (IsPionNSigma(track->P().Mag(), track->NSigmaTPCPi(), track->NSigmaTOFPi()))
341               imost = 2;
342
343           }
344           else if (fMostProbable == 3) { 
345             if (IsKaonNSigma(track->P().Mag(), track->NSigmaTPCK(), track->NSigmaTOFK())){
346               imost = 3;
347             }
348   
349           }
350           else if (fMostProbable == 4) { // proton nsigma-PID required contour adjusting
351             if (IsProtonNSigma(track->P().Mag(), track->NSigmaTPCP(), track->NSigmaTOFP()) && IsProtonTPCdEdx(track->P().Mag(), track->TPCsignal()))
352               imost = 4;
353           }
354
355         }
356
357     //****Contour Method****
358         if(fPIDMethod==1){
359           for (int ip=0; ip<5; ip++)
360             if (tMost[ip] > ipidmax) { ipidmax = tMost[ip]; imost = ip; };
361
362           // Looking for pions
363           if (fMostProbable == 2) {
364             if (imost == 2) {
365               // Using the TPC to reject non-pions
366               if (!(IsPionTPCdEdx(track->P().Mag(), track->TPCsignal())))
367                 imost = 0;
368               if (0) {
369                 // Using the TOF to reject non-pions
370                 if (track->P().Mag() < 0.6) {
371                   if (tTOFPidIn)
372                     if (!IsPionTOFTime(track->P().Mag(), track->TOFpionTime()))
373                       imost = 0;
374                 }
375                 else {
376                   if (tTOFPidIn) {
377                     if (!IsPionTOFTime(track->P().Mag(), track->TOFpionTime()))
378                       imost = 0;
379                   }
380                   else {
381                     imost = 0;
382                   }
383                 }
384               }
385             }
386           }
387
388           // Looking for kaons
389           else if (fMostProbable == 3) {
390             //       if (imost == 3) {
391             // Using the TPC to reject non-kaons
392             if (track->P().Mag() < 0.6) {
393               if (!(IsKaonTPCdEdx(track->P().Mag(), track->TPCsignal())))
394                 imost = 0;
395               else imost = 3;
396               if (1) {
397                 // Using the TOF to reject non-kaons
398                 if (tTOFPidIn)
399                   if (!IsKaonTOFTime(track->P().Mag(), track->TOFkaonTime()))
400                     imost = 0;
401               }
402             }
403             else {
404               if (1) {
405                 if (tTOFPidIn) {
406                   if (!IsKaonTOFTime(track->P().Mag(), track->TOFkaonTime()))
407                     imost = 0;
408                   else
409                     imost = 3;
410                 }
411                 else {
412                   if (!(IsKaonTPCdEdx(track->P().Mag(), track->TPCsignal())))
413                     imost = 0;
414                   else 
415                     imost = 3;
416                 }
417               }
418             }
419             //       }
420           }
421     
422           // Looking for protons
423           else if (fMostProbable == 4) {
424             //       if (imost == 3) {
425             // Using the TPC to reject non-kaons
426             if (track->P().Mag() < 0.8) {
427               if (!(IsProtonTPCdEdx(track->P().Mag(), track->TPCsignal())))
428                 imost = 0;
429               else imost = 4;
430               if (0) {
431                 // Using the TOF to reject non-kaons
432                 if (tTOFPidIn)
433                   if (!IsKaonTOFTime(track->P().Mag(), track->TOFkaonTime()))
434                     imost = 0;
435               }
436             }
437             else {
438               if (0) {
439                 if (tTOFPidIn) {
440                   if (!IsKaonTOFTime(track->P().Mag(), track->TOFkaonTime()))
441                     imost = 0;
442                   else
443                     imost = 3;
444                 }
445                 else {
446                   if (!(IsKaonTPCdEdx(track->P().Mag(), track->TPCsignal())))
447                     imost = 0;
448                   else 
449                     imost = 3;
450                 }
451               }
452             }
453             //       }
454           }
455         }
456     if (imost != fMostProbable) return false;
457   }
458   
459   //fan
460   //cout<<"****** Go Through the cut ******"<<endl;
461   // cout<<fLabel<<" Label="<<track->Label()<<endl;
462   // cout<<fCharge<<" Charge="<<track->Charge()<<endl;
463   // cout<<fPt[0]<<" < Pt ="<<Pt<<" <"<<fPt[1]<<endl;
464   //cout<<fRapidity[0]<<" < Rapidity ="<<tRapidity<<" <"<<fRapidity[1]<<endl;
465   //cout<<fPidProbElectron[0]<<" <  e="<<track->PidProbElectron()<<" <"<<fPidProbElectron[1]<<endl;
466   //cout<<fPidProbPion[0]<<" <  pi="<<track->PidProbPion()<<" <"<<fPidProbPion[1]<<endl;
467   //cout<<fPidProbKaon[0]<<" <  k="<<track->PidProbKaon()<<" <"<<fPidProbKaon[1]<<endl;
468   //cout<<fPidProbProton[0]<<" <  p="<<track->PidProbProton()<<" <"<<fPidProbProton[1]<<endl;
469   //cout<<fPidProbMuon[0]<<" <  mi="<<track->PidProbMuon()<<" <"<<fPidProbMuon[1]<<endl;
470   fNTracksPassed++ ;
471   return true;
472     
473     
474 }
475 //------------------------------
476 AliFemtoString AliFemtoESDTrackCut::Report()
477 {
478   // Prepare report from the execution
479   string tStemp;
480   char tCtemp[100];
481   snprintf(tCtemp , 100, "Particle mass:\t%E\n",this->Mass());
482   tStemp=tCtemp;
483   snprintf(tCtemp , 100, "Particle charge:\t%d\n",fCharge);
484   tStemp+=tCtemp;
485   snprintf(tCtemp , 100, "Particle pT:\t%E - %E\n",fPt[0],fPt[1]);
486   tStemp+=tCtemp;
487   snprintf(tCtemp , 100, "Particle rapidity:\t%E - %E\n",fRapidity[0],fRapidity[1]);
488   tStemp+=tCtemp; 
489   snprintf(tCtemp , 100, "Particle eta:\t%E - %E\n",fEta[0],fEta[1]);
490   tStemp+=tCtemp;
491   snprintf(tCtemp , 100, "Number of tracks which passed:\t%ld  Number which failed:\t%ld\n",fNTracksPassed,fNTracksFailed);
492   tStemp += tCtemp;
493   AliFemtoString returnThis = tStemp;
494   return returnThis;
495 }
496 TList *AliFemtoESDTrackCut::ListSettings()
497 {
498   // return a list of settings in a writable form
499   TList *tListSetttings = new TList();
500   char buf[200];
501   snprintf(buf, 200, "AliFemtoESDTrackCut.mass=%f", this->Mass());
502   tListSetttings->AddLast(new TObjString(buf));
503
504   snprintf(buf, 200, "AliFemtoESDTrackCut.charge=%i", fCharge);
505   tListSetttings->AddLast(new TObjString(buf));
506   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobpion.minimum=%f", fPidProbPion[0]);
507   tListSetttings->AddLast(new TObjString(buf));
508   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobpion.maximum=%f", fPidProbPion[1]);
509   tListSetttings->AddLast(new TObjString(buf));
510   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobkaon.minimum=%f", fPidProbKaon[0]);
511   tListSetttings->AddLast(new TObjString(buf));
512   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobkaon.maximum=%f", fPidProbKaon[1]);
513   tListSetttings->AddLast(new TObjString(buf));
514   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobproton.minimum=%f", fPidProbProton[0]);
515   tListSetttings->AddLast(new TObjString(buf));
516   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobproton.maximum=%f", fPidProbProton[1]);
517   tListSetttings->AddLast(new TObjString(buf));
518   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobelectron.minimum=%f", fPidProbElectron[0]);
519   tListSetttings->AddLast(new TObjString(buf));
520   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobelectron.maximum=%f", fPidProbElectron[1]);
521   tListSetttings->AddLast(new TObjString(buf));
522   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobMuon.minimum=%f", fPidProbMuon[0]);
523   tListSetttings->AddLast(new TObjString(buf));
524   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobMuon.maximum=%f", fPidProbMuon[1]);
525   tListSetttings->AddLast(new TObjString(buf));
526   snprintf(buf, 200, "AliFemtoESDTrackCut.minimumtpcclusters=%i", fminTPCclsF);
527   tListSetttings->AddLast(new TObjString(buf));
528   snprintf(buf, 200, "AliFemtoESDTrackCut.minimumitsclusters=%i", fminTPCclsF);
529   tListSetttings->AddLast(new TObjString(buf));
530   snprintf(buf, 200, "AliFemtoESDTrackCut.pt.minimum=%f", fPt[0]);
531   tListSetttings->AddLast(new TObjString(buf));
532   snprintf(buf, 200, "AliFemtoESDTrackCut.pt.maximum=%f", fPt[1]);
533   tListSetttings->AddLast(new TObjString(buf));
534   snprintf(buf, 200, "AliFemtoESDTrackCut.rapidity.minimum=%f", fRapidity[0]);
535   tListSetttings->AddLast(new TObjString(buf));
536   snprintf(buf, 200, "AliFemtoESDTrackCut.rapidity.maximum=%f", fRapidity[1]);
537   tListSetttings->AddLast(new TObjString(buf));
538   snprintf(buf, 200, "AliFemtoESDTrackCut.removekinks=%i", fRemoveKinks);
539   tListSetttings->AddLast(new TObjString(buf));
540   snprintf(buf, 200, "AliFemtoESDTrackCut.maxitschindof=%f", fMaxITSchiNdof);
541   tListSetttings->AddLast(new TObjString(buf));
542   snprintf(buf, 200, "AliFemtoESDTrackCut.maxtpcchindof=%f", fMaxTPCchiNdof);
543   tListSetttings->AddLast(new TObjString(buf));
544   snprintf(buf, 200, "AliFemtoESDTrackCut.maxsigmatovertex=%f", fMaxSigmaToVertex);
545   tListSetttings->AddLast(new TObjString(buf));
546   snprintf(buf, 200, "AliFemtoESDTrackCut.maximpactxy=%f", fMaxImpactXY);
547   tListSetttings->AddLast(new TObjString(buf));
548   snprintf(buf, 200, "AliFemtoESDTrackCut.maximpactz=%f", fMaxImpactZ);
549   tListSetttings->AddLast(new TObjString(buf));
550   if (fMostProbable) {
551     if (fMostProbable == 2)
552       snprintf(buf, 200, "AliFemtoESDTrackCut.mostprobable=%s", "Pion");
553     if (fMostProbable == 3)
554       snprintf(buf, 200, "AliFemtoESDTrackCut.mostprobable=%s", "Kaon");
555     if (fMostProbable == 4)
556       snprintf(buf, 200, "AliFemtoESDTrackCut.mostprobable=%s", "Proton");
557     tListSetttings->AddLast(new TObjString(buf));
558   }
559   return tListSetttings;
560 }
561 void AliFemtoESDTrackCut::SetRemoveKinks(const bool& flag)
562 {
563   fRemoveKinks = flag;
564 }
565                             
566 void AliFemtoESDTrackCut::SetRemoveITSFake(const bool& flag)
567 {
568   fRemoveITSFake = flag;
569 }
570                             
571 // electron
572 // 0.13 - 1.8
573 // 0       7.594129e-02    8.256141e-03
574 // 1       -5.535827e-01   8.170825e-02
575 // 2       1.728591e+00    3.104210e-01
576 // 3       -2.827893e+00   5.827802e-01
577 // 4       2.503553e+00    5.736207e-01
578 // 5       -1.125965e+00   2.821170e-01
579 // 6       2.009036e-01    5.438876e-02
580 float AliFemtoESDTrackCut::PidFractionElectron(float mom) const
581 {
582   // Provide a parameterized fraction of electrons dependent on momentum
583   if (mom<0.13) 
584     return (7.594129e-02 
585             -5.535827e-01*0.13     
586             +1.728591e+00*0.13*0.13    
587             -2.827893e+00*0.13*0.13*0.13 
588             +2.503553e+00*0.13*0.13*0.13*0.13      
589             -1.125965e+00*0.13*0.13*0.13*0.13*0.13      
590             +2.009036e-01*0.13*0.13*0.13*0.13*0.13*0.13);   
591
592   if (mom>1.8)
593     return (7.594129e-02 
594             -5.535827e-01*1.8      
595             +1.728591e+00*1.8*1.8    
596             -2.827893e+00*1.8*1.8*1.8 
597             +2.503553e+00*1.8*1.8*1.8*1.8          
598             -1.125965e+00*1.8*1.8*1.8*1.8*1.8      
599             +2.009036e-01*1.8*1.8*1.8*1.8*1.8*1.8);   
600   return (7.594129e-02 
601           -5.535827e-01*mom        
602           +1.728591e+00*mom*mom    
603           -2.827893e+00*mom*mom*mom 
604           +2.503553e+00*mom*mom*mom*mom    
605           -1.125965e+00*mom*mom*mom*mom*mom      
606           +2.009036e-01*mom*mom*mom*mom*mom*mom);   
607 }
608
609 // pion
610 // 0.13 - 2.0
611 // 0       1.063457e+00    8.872043e-03
612 // 1       -4.222208e-01   2.534402e-02
613 // 2       1.042004e-01    1.503945e-02
614 float AliFemtoESDTrackCut::PidFractionPion(float mom) const
615 {
616   // Provide a parameterized fraction of pions dependent on momentum
617   if (mom<0.13) 
618     return ( 1.063457e+00
619              -4.222208e-01*0.13
620              +1.042004e-01*0.0169);
621   if (mom>2.0) 
622     return ( 1.063457e+00
623              -4.222208e-01*2.0
624              +1.042004e-01*4.0);
625   return ( 1.063457e+00
626            -4.222208e-01*mom
627            +1.042004e-01*mom*mom);
628 }
629
630 // kaon
631 // 0.18 - 2.0
632 // 0       -7.289406e-02   1.686074e-03
633 // 1       4.415666e-01    1.143939e-02
634 // 2       -2.996790e-01   1.840964e-02
635 // 3       6.704652e-02    7.783990e-03
636 float AliFemtoESDTrackCut::PidFractionKaon(float mom) const
637 {
638   // Provide a parameterized fraction of kaons dependent on momentum
639   if (mom<0.18) 
640     return (-7.289406e-02
641             +4.415666e-01*0.18     
642             -2.996790e-01*0.18*0.18    
643             +6.704652e-02*0.18*0.18*0.18);
644   if (mom>2.0) 
645     return (-7.289406e-02
646             +4.415666e-01*2.0      
647             -2.996790e-01*2.0*2.0    
648             +6.704652e-02*2.0*2.0*2.0);
649   return (-7.289406e-02
650           +4.415666e-01*mom        
651           -2.996790e-01*mom*mom    
652           +6.704652e-02*mom*mom*mom);
653 }
654
655 // proton
656 // 0.26 - 2.0
657 // 0       -3.730200e-02   2.347311e-03
658 // 1       1.163684e-01    1.319316e-02
659 // 2       8.354116e-02    1.997948e-02
660 // 3       -4.608098e-02   8.336400e-03
661 float AliFemtoESDTrackCut::PidFractionProton(float mom) const
662 {
663   // Provide a parameterized fraction of protons dependent on momentum
664   if (mom<0.26) return  0.0;
665   if (mom>2.0) 
666     return (-3.730200e-02  
667             +1.163684e-01*2.0         
668             +8.354116e-02*2.0*2.0       
669             -4.608098e-02*2.0*2.0*2.0);
670   return (-3.730200e-02  
671           +1.163684e-01*mom           
672           +8.354116e-02*mom*mom       
673           -4.608098e-02*mom*mom*mom);  
674 }
675
676 void AliFemtoESDTrackCut::SetMomRangeTOFpidIs(const float& minp, const float& maxp)
677 {
678   fMinPforTOFpid = minp;
679   fMaxPforTOFpid = maxp;
680 }
681
682 void AliFemtoESDTrackCut::SetMomRangeTPCpidIs(const float& minp, const float& maxp)
683 {
684   fMinPforTPCpid = minp;
685   fMaxPforTPCpid = maxp;
686 }
687
688 void AliFemtoESDTrackCut::SetMomRangeITSpidIs(const float& minp, const float& maxp)
689 {
690   fMinPforITSpid = minp;
691   fMaxPforITSpid = maxp;
692 }
693
694 bool AliFemtoESDTrackCut::IsPionTPCdEdx(float mom, float dEdx)
695 {
696   //   double a1 = -95.4545, b1 = 86.5455;
697   //   double a2 = 0.0,      b2 = 56.0;
698   double a1 = -343.75,  b1 = 168.125;
699   double a2 = 0.0,      b2 = 65.0;
700
701   if (mom < 0.32) {
702     if (dEdx < a1*mom+b1) return true;
703   }
704   if (dEdx < a2*mom+b2) return true;
705
706   return false;
707 }
708
709 bool AliFemtoESDTrackCut::IsKaonTPCdEdx(float mom, float dEdx)
710 {
711
712 //   double a1 = -547.0; double b1 =  297.0;
713 //   double a2 = -125.0; double b2 =  145.0;
714 //   double a3 = -420.0; double b3 =  357.0;
715 //   double a4 = -110.0; double b4 =  171.0;
716 //   double b5 =   72.0;
717
718 //   if (mom<0.2) return false;
719
720 //   if (mom<0.36) {
721 //     if (dEdx < a1*mom+b1) return false;
722 //     if (dEdx > a3*mom+b3) return false;
723 //   }
724 //   else if (mom<0.6) {
725 //     if (dEdx < a2*mom+b2) return false;
726 //     if (dEdx > a3*mom+b3) return false;
727 //   }
728 //   else if (mom<0.9) {
729 //     if (dEdx > a4*mom+b4) return false;
730 //     if (dEdx <        b5) return false;
731 //   }
732 //   else 
733 //     return false;
734 //   //   else {
735 //   //     if (dEdx > b5) return false;
736 //   //   }
737    
738 //   return true;
739
740   double a1 = -268.896; double b1 =  198.669;
741   double a2 = -49.0012;  double b2 =  88.7214;
742
743   if (mom<0.2) return false;
744
745   if (mom>0.3 && mom<0.5) {
746     if (dEdx < a1*mom+b1) return false;
747   }
748   else  if (mom<1.2) {
749     if (dEdx < a2*mom+b2) return false;
750   }
751
752   return true;
753
754 }
755
756 bool AliFemtoESDTrackCut::IsProtonTPCdEdx(float mom, float dEdx)
757 {
758   double a1 = -1800.0; double b1 =  940.0;
759   double a2 = -500.0;  double b2 =  420.0;
760   double a3 = -216.7;  double b3 =  250.0;
761
762   if (mom<0.2) return false;
763
764   if (mom>0.3 && mom<0.4) {
765     if (dEdx < a1*mom+b1) return false;
766   }
767   else  if (mom<0.6) {
768     if (dEdx < a2*mom+b2) return false;
769   }
770   else  if (mom<0.9) {
771     if (dEdx < a3*mom+b3) return false;
772   }
773
774   return true;
775    
776 }
777
778 bool AliFemtoESDTrackCut::IsPionTOFTime(float mom, float ttof)
779 {
780   double a1 = -427.0; double b1 =  916.0;
781   double a2 =  327.0; double b2 = -888.0;
782   if (mom<0.3) return kFALSE;
783   if (mom>2.0) return kFALSE;
784   if (ttof > a1*mom+b1) return kFALSE;
785   if (ttof < a2*mom+b2) return kFALSE;
786
787   return kTRUE;
788 }
789
790 bool AliFemtoESDTrackCut::IsKaonTOFTime(float mom, float ttof)
791 {
792   double a1 =   000.0; double b1 =  -500.0;
793   double a2 =   000.0; double b2 =   500.0;
794   double a3 =   850.0; double b3 = -1503.0;
795   double a4 = -1637.0; double b4 =  3621.0;
796
797   if (mom<0.3) return kFALSE;
798   if (mom>2.06) return kFALSE;
799   if (mom<1.2) {
800     if (ttof > a2*mom+b2) return kFALSE;
801     if (ttof < a1*mom+b1) return kFALSE;
802   }
803   if (mom<1.9) {
804     if (ttof > a2*mom+b2) return kFALSE;
805     if (ttof < a3*mom+b3) return kFALSE;
806   }
807   if (mom<2.06) {
808     if (ttof > a4*mom+b4) return kFALSE;
809     if (ttof < a3*mom+b3) return kFALSE;
810   }
811   return kTRUE;
812 }
813
814 bool AliFemtoESDTrackCut::IsProtonTOFTime(float mom, float ttof)
815 {
816   double a1 =   000.0; double b1 =  -915.0;
817   double a2 =   000.0; double b2 =   600.0;
818   double a3 =   572.0; double b3 = -1715.0;
819
820   if (mom<0.3) return kFALSE;
821   if (mom>3.0) return kFALSE;
822   if (mom<1.4) {
823     if (ttof > a2*mom+b2) return kFALSE;
824     if (ttof < a1*mom+b1) return kFALSE;
825   }
826   if (mom<3.0) {
827     if (ttof > a2*mom+b2) return kFALSE;
828     if (ttof < a3*mom+b3) return kFALSE;
829   }
830   return kTRUE;
831 }
832
833
834
835
836 bool AliFemtoESDTrackCut::IsKaonTPCdEdxNSigma(float mom, float nsigmaK)
837 {
838   cout<<" AliFemtoESDTrackCut::IsKaonTPCdEdxNSigma "<<mom<<" "<<nsigmaK<<endl;
839
840
841   if(mom<0.35 && TMath::Abs(nsigmaK)<5.0)return true;
842   if(mom>=0.35 && mom<0.5 && TMath::Abs(nsigmaK)<3.0)return true; 
843   if(mom>=0.5 && mom<0.7 && TMath::Abs(nsigmaK)<2.0)return true;
844
845   return false;
846 }
847
848
849 bool AliFemtoESDTrackCut::IsKaonTOFNSigma(float mom, float nsigmaK)
850 {
851   cout<<" AliFemtoESDTrackCut::IsKaonTPCdEdxNSigma "<<mom<<" "<<nsigmaK<<endl;
852   //fan
853   //  if(mom<1.5 && TMath::Abs(nsigmaK)<3.0)return true;
854   if(mom>=1.5 && TMath::Abs(nsigmaK)<2.0)return true; 
855   return false;
856 }
857
858 //ML according with Roberto Preghenella talk
859
860 bool AliFemtoESDTrackCut::IsKaonNSigma(float mom, float nsigmaTPCK, float nsigmaTOFK)
861 {
862   //cout<<"//////// AliFemtoESDTrackCut::IsKaonNSigma "<<mom<<" tpc "<<nsigmaTPCK<<" tof "<<nsigmaTOFK<<endl;
863
864
865   if(TMath::Abs(nsigmaTOFK)<3.0 && mom<1.5 && TMath::Abs(nsigmaTPCK)<3.0)return true;
866   if(TMath::Abs(nsigmaTOFK)<2.0 && mom>1.5 && TMath::Abs(nsigmaTPCK)<3.0)return true;
867
868   //no TOF signal
869  
870
871   if(nsigmaTOFK<=-1000.){
872     //cout<<"//////// AliFemtoESDTrackCut::IsKaonNSigma P= "<<mom<<" tpc "<<nsigmaTPCK<<" tof "<<nsigmaTOFK<<endl;
873     //cout <<"/////////////// AliFemtoESDTrackCut::IsKaonNSigma  NO TOF SIGNAL ////////////" <<endl;
874     if(mom<0.4 && TMath::Abs(nsigmaTPCK)<1.0)return true;
875     if(mom>=0.4 && mom<0.5 && TMath::Abs(nsigmaTPCK)<2.0)return true;
876     if(mom>=0.5 && mom<0.6 && TMath::Abs(nsigmaTPCK)<2.0)return true;
877   }
878
879   return false;
880 }
881
882
883
884 bool AliFemtoESDTrackCut::IsPionNSigma(float mom, float nsigmaTPCPi, float nsigmaTOFPi)
885 {
886   // cout<<" AliFemtoESDTrackCut::IsKaonNSigma "<<mom<<" tpc "<<nsigmaTPCK<<" tof "<<nsigmaTOFK<<endl;
887   //TOF signal
888   if(TMath::Abs(nsigmaTOFPi)<3.0 && mom<1.5 && TMath::Abs(nsigmaTPCPi)<5.0)return true;
889   if(TMath::Abs(nsigmaTOFPi)<2.0 && mom>1.5 && TMath::Abs(nsigmaTPCPi)<5.0)return true;
890
891
892   //no TOF signal
893   if(nsigmaTOFPi<-999.){
894     if(mom<0.35 && TMath::Abs(nsigmaTPCPi)<5.0)return true;
895     if(mom>=0.35 && mom<0.5 && TMath::Abs(nsigmaTPCPi)<3.0)return true;
896     if(mom>=0.5 && TMath::Abs(nsigmaTPCPi)<2.0)return true;
897   }
898   return false;
899 }
900
901
902 bool AliFemtoESDTrackCut::IsProtonNSigma(float mom, float nsigmaTPCP, float nsigmaTOFP)
903 {
904   // cout<<" AliFemtoESDTrackCut::IsKaonNSigma "<<mom<<" tpc "<<nsigmaTPCK<<" tof "<<nsigmaTOFK<<endl;
905
906   //TOF signal
907   if(TMath::Abs(nsigmaTOFP)<3.0 && mom<1.5 && TMath::Abs(nsigmaTPCP)<3.0)return true;
908   if(TMath::Abs(nsigmaTOFP)<2.0 && mom>1.5 && TMath::Abs(nsigmaTPCP)<3.0)return true;
909
910   //no TOF signal
911   if(nsigmaTOFP<-999.){
912     if(mom<0.5 && TMath::Abs(nsigmaTPCP)<3.0)return true;
913     if(mom>=0.5 && mom<0.8 && TMath::Abs(nsigmaTPCP)<2.0)return true;
914   }
915
916   return false;
917 }
918
919
920 void AliFemtoESDTrackCut::SetPIDMethod(ReadPIDMethodType newMethod)
921 {
922   fPIDMethod = newMethod;
923 }