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