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