]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FEMTOSCOPY/AliFemtoUser/AliFemtoESDTrackCut.cxx
Fix Coverity report
[u/mrichter/AliRoot.git] / PWG2 / 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
337
338     //****N Sigma Method****
339     if(fPIDMethod==0){
340     // Looking for pions
341     if (fMostProbable == 2) {
342       if (IsPionNSigma(track->P().Mag(), track->NSigmaTPCPi(), track->NSigmaTOFPi()))
343         imost = 2;
344
345     }
346     else if (fMostProbable == 3) {
347       if (IsKaonNSigma(track->P().Mag(), track->NSigmaTPCK(), track->NSigmaTOFK())){
348         imost = 3;
349       }
350   
351     }
352     else if (fMostProbable == 4) {
353       if (IsProtonNSigma(track->P().Mag(), track->NSigmaTPCP(), track->NSigmaTOFP()))
354         imost = 4;
355     }
356
357     }
358
359     //****Contour Method****
360     if(fPIDMethod==1){
361     for (int ip=0; ip<5; ip++)
362       if (tMost[ip] > ipidmax) { ipidmax = tMost[ip]; imost = ip; };
363
364    // Looking for pions
365     if (fMostProbable == 2) {
366       if (imost == 2) {
367         // Using the TPC to reject non-pions
368         if (!(IsPionTPCdEdx(track->P().Mag(), track->TPCsignal())))
369           imost = 0;
370         if (0) {
371         // Using the TOF to reject non-pions
372         if (track->P().Mag() < 0.6) {
373           if (tTOFPidIn)
374             if (!IsPionTOFTime(track->P().Mag(), track->TOFpionTime()))
375               imost = 0;
376         }
377         else {
378           if (tTOFPidIn) {
379             if (!IsPionTOFTime(track->P().Mag(), track->TOFpionTime()))
380               imost = 0;
381           }
382           else {
383             imost = 0;
384           }
385         }
386         }
387       }
388     }
389
390     // Looking for kaons
391     else if (fMostProbable == 3) {
392 //       if (imost == 3) {
393         // Using the TPC to reject non-kaons
394       if (track->P().Mag() < 0.6) {
395         if (!(IsKaonTPCdEdx(track->P().Mag(), track->TPCsignal())))
396           imost = 0;
397         else imost = 3;
398         if (1) {
399           // Using the TOF to reject non-kaons
400           if (tTOFPidIn)
401             if (!IsKaonTOFTime(track->P().Mag(), track->TOFkaonTime()))
402               imost = 0;
403         }
404       }
405       else {
406         if (1) {
407           if (tTOFPidIn) {
408             if (!IsKaonTOFTime(track->P().Mag(), track->TOFkaonTime()))
409               imost = 0;
410             else
411               imost = 3;
412           }
413           else {
414             if (!(IsKaonTPCdEdx(track->P().Mag(), track->TPCsignal())))
415               imost = 0;
416             else 
417               imost = 3;
418           }
419         }
420       }
421       //       }
422     }
423     
424     // Looking for protons
425     else if (fMostProbable == 4) {
426 //       if (imost == 3) {
427         // Using the TPC to reject non-kaons
428       if (track->P().Mag() < 0.8) {
429         if (!(IsProtonTPCdEdx(track->P().Mag(), track->TPCsignal())))
430           imost = 0;
431         else imost = 4;
432         if (0) {
433           // Using the TOF to reject non-kaons
434           if (tTOFPidIn)
435             if (!IsKaonTOFTime(track->P().Mag(), track->TOFkaonTime()))
436               imost = 0;
437         }
438       }
439       else {
440         if (0) {
441           if (tTOFPidIn) {
442             if (!IsKaonTOFTime(track->P().Mag(), track->TOFkaonTime()))
443               imost = 0;
444             else
445               imost = 3;
446           }
447           else {
448             if (!(IsKaonTPCdEdx(track->P().Mag(), track->TPCsignal())))
449               imost = 0;
450             else 
451               imost = 3;
452           }
453         }
454       }
455       //       }
456     }
457     }
458     if (imost != fMostProbable) return false;
459   }
460   
461 //fan
462   //cout<<"****** Go Through the cut ******"<<endl;
463   // cout<<fLabel<<" Label="<<track->Label()<<endl;
464   // cout<<fCharge<<" Charge="<<track->Charge()<<endl;
465   // cout<<fPt[0]<<" < Pt ="<<Pt<<" <"<<fPt[1]<<endl;
466   //cout<<fRapidity[0]<<" < Rapidity ="<<tRapidity<<" <"<<fRapidity[1]<<endl;
467   //cout<<fPidProbElectron[0]<<" <  e="<<track->PidProbElectron()<<" <"<<fPidProbElectron[1]<<endl;
468   //cout<<fPidProbPion[0]<<" <  pi="<<track->PidProbPion()<<" <"<<fPidProbPion[1]<<endl;
469   //cout<<fPidProbKaon[0]<<" <  k="<<track->PidProbKaon()<<" <"<<fPidProbKaon[1]<<endl;
470   //cout<<fPidProbProton[0]<<" <  p="<<track->PidProbProton()<<" <"<<fPidProbProton[1]<<endl;
471   //cout<<fPidProbMuon[0]<<" <  mi="<<track->PidProbMuon()<<" <"<<fPidProbMuon[1]<<endl;
472   fNTracksPassed++ ;
473   return true;
474     
475     
476 }
477 //------------------------------
478 AliFemtoString AliFemtoESDTrackCut::Report()
479 {
480   // Prepare report from the execution
481   string tStemp;
482   char tCtemp[100];
483   snprintf(tCtemp , 100, "Particle mass:\t%E\n",this->Mass());
484   tStemp=tCtemp;
485   snprintf(tCtemp , 100, "Particle charge:\t%d\n",fCharge);
486   tStemp+=tCtemp;
487   snprintf(tCtemp , 100, "Particle pT:\t%E - %E\n",fPt[0],fPt[1]);
488   tStemp+=tCtemp;
489   snprintf(tCtemp , 100, "Particle rapidity:\t%E - %E\n",fRapidity[0],fRapidity[1]);
490   tStemp+=tCtemp; 
491   snprintf(tCtemp , 100, "Particle eta:\t%E - %E\n",fEta[0],fEta[1]);
492   tStemp+=tCtemp;
493   snprintf(tCtemp , 100, "Number of tracks which passed:\t%ld  Number which failed:\t%ld\n",fNTracksPassed,fNTracksFailed);
494   tStemp += tCtemp;
495   AliFemtoString returnThis = tStemp;
496   return returnThis;
497 }
498 TList *AliFemtoESDTrackCut::ListSettings()
499 {
500   // return a list of settings in a writable form
501   TList *tListSetttings = new TList();
502   char buf[200];
503   snprintf(buf, 200, "AliFemtoESDTrackCut.mass=%f", this->Mass());
504   tListSetttings->AddLast(new TObjString(buf));
505
506   snprintf(buf, 200, "AliFemtoESDTrackCut.charge=%i", fCharge);
507   tListSetttings->AddLast(new TObjString(buf));
508   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobpion.minimum=%f", fPidProbPion[0]);
509   tListSetttings->AddLast(new TObjString(buf));
510   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobpion.maximum=%f", fPidProbPion[1]);
511   tListSetttings->AddLast(new TObjString(buf));
512   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobkaon.minimum=%f", fPidProbKaon[0]);
513   tListSetttings->AddLast(new TObjString(buf));
514   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobkaon.maximum=%f", fPidProbKaon[1]);
515   tListSetttings->AddLast(new TObjString(buf));
516   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobproton.minimum=%f", fPidProbProton[0]);
517   tListSetttings->AddLast(new TObjString(buf));
518   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobproton.maximum=%f", fPidProbProton[1]);
519   tListSetttings->AddLast(new TObjString(buf));
520   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobelectron.minimum=%f", fPidProbElectron[0]);
521   tListSetttings->AddLast(new TObjString(buf));
522   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobelectron.maximum=%f", fPidProbElectron[1]);
523   tListSetttings->AddLast(new TObjString(buf));
524   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobMuon.minimum=%f", fPidProbMuon[0]);
525   tListSetttings->AddLast(new TObjString(buf));
526   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobMuon.maximum=%f", fPidProbMuon[1]);
527   tListSetttings->AddLast(new TObjString(buf));
528   snprintf(buf, 200, "AliFemtoESDTrackCut.minimumtpcclusters=%i", fminTPCclsF);
529   tListSetttings->AddLast(new TObjString(buf));
530   snprintf(buf, 200, "AliFemtoESDTrackCut.minimumitsclusters=%i", fminTPCclsF);
531   tListSetttings->AddLast(new TObjString(buf));
532   snprintf(buf, 200, "AliFemtoESDTrackCut.pt.minimum=%f", fPt[0]);
533   tListSetttings->AddLast(new TObjString(buf));
534   snprintf(buf, 200, "AliFemtoESDTrackCut.pt.maximum=%f", fPt[1]);
535   tListSetttings->AddLast(new TObjString(buf));
536   snprintf(buf, 200, "AliFemtoESDTrackCut.rapidity.minimum=%f", fRapidity[0]);
537   tListSetttings->AddLast(new TObjString(buf));
538   snprintf(buf, 200, "AliFemtoESDTrackCut.rapidity.maximum=%f", fRapidity[1]);
539   tListSetttings->AddLast(new TObjString(buf));
540   snprintf(buf, 200, "AliFemtoESDTrackCut.removekinks=%i", fRemoveKinks);
541   tListSetttings->AddLast(new TObjString(buf));
542   snprintf(buf, 200, "AliFemtoESDTrackCut.maxitschindof=%f", fMaxITSchiNdof);
543   tListSetttings->AddLast(new TObjString(buf));
544   snprintf(buf, 200, "AliFemtoESDTrackCut.maxtpcchindof=%f", fMaxTPCchiNdof);
545   tListSetttings->AddLast(new TObjString(buf));
546   snprintf(buf, 200, "AliFemtoESDTrackCut.maxsigmatovertex=%f", fMaxSigmaToVertex);
547   tListSetttings->AddLast(new TObjString(buf));
548   snprintf(buf, 200, "AliFemtoESDTrackCut.maximpactxy=%f", fMaxImpactXY);
549   tListSetttings->AddLast(new TObjString(buf));
550   snprintf(buf, 200, "AliFemtoESDTrackCut.maximpactz=%f", fMaxImpactZ);
551   tListSetttings->AddLast(new TObjString(buf));
552   if (fMostProbable) {
553     if (fMostProbable == 2)
554       snprintf(buf, 200, "AliFemtoESDTrackCut.mostprobable=%s", "Pion");
555     if (fMostProbable == 3)
556       snprintf(buf, 200, "AliFemtoESDTrackCut.mostprobable=%s", "Kaon");
557     if (fMostProbable == 4)
558       snprintf(buf, 200, "AliFemtoESDTrackCut.mostprobable=%s", "Proton");
559     tListSetttings->AddLast(new TObjString(buf));
560   }
561   return tListSetttings;
562 }
563 void AliFemtoESDTrackCut::SetRemoveKinks(const bool& flag)
564 {
565   fRemoveKinks = flag;
566 }
567                             
568 void AliFemtoESDTrackCut::SetRemoveITSFake(const bool& flag)
569 {
570   fRemoveITSFake = flag;
571 }
572                             
573                             // electron
574 // 0.13 - 1.8
575 // 0       7.594129e-02    8.256141e-03
576 // 1       -5.535827e-01   8.170825e-02
577 // 2       1.728591e+00    3.104210e-01
578 // 3       -2.827893e+00   5.827802e-01
579 // 4       2.503553e+00    5.736207e-01
580 // 5       -1.125965e+00   2.821170e-01
581 // 6       2.009036e-01    5.438876e-02
582 float AliFemtoESDTrackCut::PidFractionElectron(float mom) const
583 {
584   // Provide a parameterized fraction of electrons dependent on momentum
585   if (mom<0.13) 
586     return (7.594129e-02 
587             -5.535827e-01*0.13     
588             +1.728591e+00*0.13*0.13    
589             -2.827893e+00*0.13*0.13*0.13 
590             +2.503553e+00*0.13*0.13*0.13*0.13      
591             -1.125965e+00*0.13*0.13*0.13*0.13*0.13      
592             +2.009036e-01*0.13*0.13*0.13*0.13*0.13*0.13);   
593
594   if (mom>1.8)
595     return (7.594129e-02 
596             -5.535827e-01*1.8      
597             +1.728591e+00*1.8*1.8    
598             -2.827893e+00*1.8*1.8*1.8 
599             +2.503553e+00*1.8*1.8*1.8*1.8          
600             -1.125965e+00*1.8*1.8*1.8*1.8*1.8      
601             +2.009036e-01*1.8*1.8*1.8*1.8*1.8*1.8);   
602   return (7.594129e-02 
603           -5.535827e-01*mom        
604           +1.728591e+00*mom*mom    
605           -2.827893e+00*mom*mom*mom 
606           +2.503553e+00*mom*mom*mom*mom    
607           -1.125965e+00*mom*mom*mom*mom*mom      
608           +2.009036e-01*mom*mom*mom*mom*mom*mom);   
609 }
610
611 // pion
612 // 0.13 - 2.0
613 // 0       1.063457e+00    8.872043e-03
614 // 1       -4.222208e-01   2.534402e-02
615 // 2       1.042004e-01    1.503945e-02
616 float AliFemtoESDTrackCut::PidFractionPion(float mom) const
617 {
618   // Provide a parameterized fraction of pions dependent on momentum
619   if (mom<0.13) 
620     return ( 1.063457e+00
621              -4.222208e-01*0.13
622              +1.042004e-01*0.0169);
623   if (mom>2.0) 
624     return ( 1.063457e+00
625              -4.222208e-01*2.0
626              +1.042004e-01*4.0);
627   return ( 1.063457e+00
628            -4.222208e-01*mom
629            +1.042004e-01*mom*mom);
630 }
631
632 // kaon
633 // 0.18 - 2.0
634 // 0       -7.289406e-02   1.686074e-03
635 // 1       4.415666e-01    1.143939e-02
636 // 2       -2.996790e-01   1.840964e-02
637 // 3       6.704652e-02    7.783990e-03
638 float AliFemtoESDTrackCut::PidFractionKaon(float mom) const
639 {
640   // Provide a parameterized fraction of kaons dependent on momentum
641   if (mom<0.18) 
642     return (-7.289406e-02
643             +4.415666e-01*0.18     
644             -2.996790e-01*0.18*0.18    
645             +6.704652e-02*0.18*0.18*0.18);
646   if (mom>2.0) 
647     return (-7.289406e-02
648             +4.415666e-01*2.0      
649             -2.996790e-01*2.0*2.0    
650             +6.704652e-02*2.0*2.0*2.0);
651   return (-7.289406e-02
652           +4.415666e-01*mom        
653           -2.996790e-01*mom*mom    
654           +6.704652e-02*mom*mom*mom);
655 }
656
657 // proton
658 // 0.26 - 2.0
659 // 0       -3.730200e-02   2.347311e-03
660 // 1       1.163684e-01    1.319316e-02
661 // 2       8.354116e-02    1.997948e-02
662 // 3       -4.608098e-02   8.336400e-03
663 float AliFemtoESDTrackCut::PidFractionProton(float mom) const
664 {
665   // Provide a parameterized fraction of protons dependent on momentum
666   if (mom<0.26) return  0.0;
667   if (mom>2.0) 
668     return (-3.730200e-02  
669             +1.163684e-01*2.0         
670             +8.354116e-02*2.0*2.0       
671             -4.608098e-02*2.0*2.0*2.0);
672   return (-3.730200e-02  
673           +1.163684e-01*mom           
674           +8.354116e-02*mom*mom       
675           -4.608098e-02*mom*mom*mom);  
676 }
677
678 void AliFemtoESDTrackCut::SetMomRangeTOFpidIs(const float& minp, const float& maxp)
679 {
680   fMinPforTOFpid = minp;
681   fMaxPforTOFpid = maxp;
682 }
683
684 void AliFemtoESDTrackCut::SetMomRangeTPCpidIs(const float& minp, const float& maxp)
685 {
686   fMinPforTPCpid = minp;
687   fMaxPforTPCpid = maxp;
688 }
689
690 void AliFemtoESDTrackCut::SetMomRangeITSpidIs(const float& minp, const float& maxp)
691 {
692   fMinPforITSpid = minp;
693   fMaxPforITSpid = maxp;
694 }
695
696 bool AliFemtoESDTrackCut::IsPionTPCdEdx(float mom, float dEdx)
697 {
698 //   double a1 = -95.4545, b1 = 86.5455;
699 //   double a2 = 0.0,      b2 = 56.0;
700   double a1 = -343.75,  b1 = 168.125;
701   double a2 = 0.0,      b2 = 65.0;
702
703   if (mom < 0.32) {
704     if (dEdx < a1*mom+b1) return true;
705   }
706   if (dEdx < a2*mom+b2) return true;
707
708   return false;
709 }
710
711 bool AliFemtoESDTrackCut::IsKaonTPCdEdx(float mom, float dEdx)
712 {
713    // double a1 = -159.1, b1 = 145.9;
714    // double a2 = 0.0,    b2 = 60.0;
715    // double a3 = -138.235, b3 = 166.44;
716    // double a4 = -2015.79, b4 = 973.789;
717
718    // if (mom < 0.24) {
719    //   if (dEdx > a1*mom+b1) return true;
720    // }    
721    // else if (mom < 0.43) {
722    //   if ((dEdx > a1*mom+b1) && (dEdx < a4*mom+b4)) return true;
723    // }
724    // else if (mom < 0.54) {
725    //   if ((dEdx > a1*mom+b1) && (dEdx < a3*mom+b3)) return true;
726    // }
727    // else if (mom < 0.77) {
728    //   if ((dEdx > a2*mom+b2) && (dEdx < a3*mom+b3)) return true;
729    // }
730    
731    // return false;
732
733    double a1 = -547.0; double b1 =  297.0;
734    double a2 = -125.0; double b2 =  145.0;
735    double a3 = -420.0; double b3 =  357.0;
736    double a4 = -110.0; double b4 =  171.0;
737                        double b5 =   72.0;
738
739    if (mom<0.2) return false;
740
741    if (mom<0.36) {
742      if (dEdx < a1*mom+b1) return false;
743      if (dEdx > a3*mom+b3) return false;
744    }
745    else if (mom<0.6) {
746      if (dEdx < a2*mom+b2) return false;
747      if (dEdx > a3*mom+b3) return false;
748    }
749    else if (mom<0.9) {
750      if (dEdx > a4*mom+b4) return false;
751      if (dEdx <        b5) return false;
752    }
753    else 
754      return false;
755  //   else {
756  //     if (dEdx > b5) return false;
757  //   }
758    
759    return true;
760 }
761
762 bool AliFemtoESDTrackCut::IsProtonTPCdEdx(float mom, float dEdx)
763 {
764   double a1 = -3000.0; double b1 =  1280.0;
765   double a2 = -312.5;  double b2 =  312.5;
766   double a3 = -160.0;  double b3 =  221.0;
767 //   double a4 = -110.0;  double b4 =  171.0;
768 //                         double b5 =   72.0;
769
770    if (mom<0.2) return false;
771
772    if (mom<0.36) {
773      if (dEdx < a1*mom+b1) return false;
774    }
775    else if (mom<0.6) {
776      if (dEdx < a2*mom+b2) return false;
777    }
778    else if (mom<0.9) {
779      if (dEdx < a3*mom+b3) return false;
780    }
781    else 
782      return false;
783  //   else {
784  //     if (dEdx > b5) return false;
785  //   }
786    
787    return true;
788   
789 }
790
791 bool AliFemtoESDTrackCut::IsPionTOFTime(float mom, float ttof)
792 {
793   double a1 = -427.0; double b1 =  916.0;
794   double a2 =  327.0; double b2 = -888.0;
795   if (mom<0.3) return kFALSE;
796   if (mom>2.0) return kFALSE;
797   if (ttof > a1*mom+b1) return kFALSE;
798   if (ttof < a2*mom+b2) return kFALSE;
799
800   return kTRUE;
801 }
802
803 bool AliFemtoESDTrackCut::IsKaonTOFTime(float mom, float ttof)
804 {
805   double a1 =   000.0; double b1 =  -500.0;
806   double a2 =   000.0; double b2 =   500.0;
807   double a3 =   850.0; double b3 = -1503.0;
808   double a4 = -1637.0; double b4 =  3621.0;
809
810   if (mom<0.3) return kFALSE;
811   if (mom>2.06) return kFALSE;
812   if (mom<1.2) {
813     if (ttof > a2*mom+b2) return kFALSE;
814     if (ttof < a1*mom+b1) return kFALSE;
815   }
816   if (mom<1.9) {
817     if (ttof > a2*mom+b2) return kFALSE;
818     if (ttof < a3*mom+b3) return kFALSE;
819   }
820   if (mom<2.06) {
821     if (ttof > a4*mom+b4) return kFALSE;
822     if (ttof < a3*mom+b3) return kFALSE;
823   }
824   return kTRUE;
825 }
826
827 bool AliFemtoESDTrackCut::IsProtonTOFTime(float mom, float ttof)
828 {
829   double a1 =   000.0; double b1 =  -915.0;
830   double a2 =   000.0; double b2 =   600.0;
831   double a3 =   572.0; double b3 = -1715.0;
832
833   if (mom<0.3) return kFALSE;
834   if (mom>3.0) return kFALSE;
835   if (mom<1.4) {
836     if (ttof > a2*mom+b2) return kFALSE;
837     if (ttof < a1*mom+b1) return kFALSE;
838   }
839   if (mom<3.0) {
840     if (ttof > a2*mom+b2) return kFALSE;
841     if (ttof < a3*mom+b3) return kFALSE;
842   }
843   return kTRUE;
844 }
845
846
847
848
849 bool AliFemtoESDTrackCut::IsKaonTPCdEdxNSigma(float mom, float nsigmaK)
850 {
851   cout<<" AliFemtoESDTrackCut::IsKaonTPCdEdxNSigma "<<mom<<" "<<nsigmaK<<endl;
852
853
854   if(mom<0.35 && TMath::Abs(nsigmaK)<5.0)return true;
855   if(mom>=0.35 && mom<0.5 && TMath::Abs(nsigmaK)<3.0)return true; 
856   if(mom>=0.5 && mom<0.7 && TMath::Abs(nsigmaK)<2.0)return true;
857
858   return false;
859 }
860
861
862 bool AliFemtoESDTrackCut::IsKaonTOFNSigma(float mom, float nsigmaK)
863 {
864   cout<<" AliFemtoESDTrackCut::IsKaonTPCdEdxNSigma "<<mom<<" "<<nsigmaK<<endl;
865 //fan
866 //  if(mom<1.5 && TMath::Abs(nsigmaK)<3.0)return true;
867   if(mom>=1.5 && TMath::Abs(nsigmaK)<2.0)return true; 
868   return false;
869 }
870
871 //ML according with Roberto Preghenella talk
872
873 bool AliFemtoESDTrackCut::IsKaonNSigma(float mom, float nsigmaTPCK, float nsigmaTOFK)
874 {
875   //cout<<"//////// AliFemtoESDTrackCut::IsKaonNSigma "<<mom<<" tpc "<<nsigmaTPCK<<" tof "<<nsigmaTOFK<<endl;
876
877
878   if(TMath::Abs(nsigmaTOFK)<3.0 && mom<1.5 && TMath::Abs(nsigmaTPCK)<5.0)return true;
879   if(TMath::Abs(nsigmaTOFK)<2.0 && mom>1.5 && TMath::Abs(nsigmaTPCK)<5.0)return true;
880
881 //no TOF signal
882  
883
884   if(nsigmaTOFK<=-1000.){
885    //cout<<"//////// AliFemtoESDTrackCut::IsKaonNSigma P= "<<mom<<" tpc "<<nsigmaTPCK<<" tof "<<nsigmaTOFK<<endl;
886    //cout <<"/////////////// AliFemtoESDTrackCut::IsKaonNSigma  NO TOF SIGNAL ////////////" <<endl;
887      if(mom<0.4 && TMath::Abs(nsigmaTPCK)<1.0)return true;
888      if(mom>=0.4 && mom<0.5 && TMath::Abs(nsigmaTPCK)<2.0)return true;
889      if(mom>=0.5 && mom<0.6 && TMath::Abs(nsigmaTPCK)<2.0)return true;
890     }
891
892   return false;
893 }
894
895
896
897 bool AliFemtoESDTrackCut::IsPionNSigma(float mom, float nsigmaTPCPi, float nsigmaTOFPi)
898 {
899  // cout<<" AliFemtoESDTrackCut::IsKaonNSigma "<<mom<<" tpc "<<nsigmaTPCK<<" tof "<<nsigmaTOFK<<endl;
900  //TOF signal
901   if(TMath::Abs(nsigmaTOFPi)<3.0 && mom<1.5 && TMath::Abs(nsigmaTPCPi)<5.0)return true;
902   if(TMath::Abs(nsigmaTOFPi)<2.0 && mom>1.5 && TMath::Abs(nsigmaTPCPi)<5.0)return true;
903
904
905 //no TOF signal
906   if(nsigmaTOFPi<-999.){
907      if(mom<0.35 && TMath::Abs(nsigmaTPCPi)<5.0)return true;
908      if(mom>=0.35 && mom<0.5 && TMath::Abs(nsigmaTPCPi)<3.0)return true;
909      if(mom>=0.5 && TMath::Abs(nsigmaTPCPi)<2.0)return true;
910     }
911   return false;
912 }
913
914
915 bool AliFemtoESDTrackCut::IsProtonNSigma(float mom, float nsigmaTPCP, float nsigmaTOFP)
916 {
917  // cout<<" AliFemtoESDTrackCut::IsKaonNSigma "<<mom<<" tpc "<<nsigmaTPCK<<" tof "<<nsigmaTOFK<<endl;
918  //TOF signal
919   if(TMath::Abs(nsigmaTOFP)<3.0 && mom<1.5 && TMath::Abs(nsigmaTPCP)<5.0)return true;
920   if(TMath::Abs(nsigmaTOFP)<2.0 && mom>1.5 && TMath::Abs(nsigmaTPCP)<5.0)return true;
921
922
923 //no TOF signal
924   if(nsigmaTOFP<-999.){
925      if(mom<0.35 && TMath::Abs(nsigmaTPCP)<5.0)return true;
926      if(mom>=0.35 && mom<0.5 && TMath::Abs(nsigmaTPCP)<3.0)return true;
927      if(mom>=0.5 && mom<1.0 && TMath::Abs(nsigmaTPCP)<2.0)return true; //? 1.0 ?
928     }
929   return false;
930 }
931
932
933 void AliFemtoESDTrackCut::SetPIDMethod(ReadPIDMethodType newMethod)
934 {
935    fPIDMethod = newMethod;
936 }