]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FEMTOSCOPY/AliFemtoUser/AliFemtoESDTrackCut.cxx
DCA has sign - correct cut to use absolute value
[u/mrichter/AliRoot.git] / PWG2 / FEMTOSCOPY / AliFemtoUser / AliFemtoESDTrackCut.cxx
1 /***************************************************************************
2  *
3  * $Id$ 
4  *
5  * 
6  ***************************************************************************
7  *
8  * 
9  *              
10  *
11  ***************************************************************************
12  *
13  * $Log$
14  * Revision 1.3  2007/05/22 09:01:42  akisiel
15  * Add the possibiloity to save cut settings in the ROOT file
16  *
17  * Revision 1.2  2007/05/21 10:38:25  akisiel
18  * More coding rule conformance
19  *
20  * Revision 1.1  2007/05/16 10:25:06  akisiel
21  * Making the directory structure of AliFemtoUser flat. All files go into one common directory
22  *
23  * Revision 1.4  2007/05/03 09:46:10  akisiel
24  * Fixing Effective C++ warnings
25  *
26  * Revision 1.3  2007/04/27 07:25:59  akisiel
27  * Make revisions needed for compilation from the main AliRoot tree
28  *
29  * Revision 1.1.1.1  2007/04/25 15:38:41  panos
30  * Importing the HBT code dir
31  *
32  * Revision 1.4  2007-04-03 16:00:08  mchojnacki
33  * Changes to iprove memory managing
34  *
35  * Revision 1.3  2007/03/13 15:30:03  mchojnacki
36  * adding reader for simulated data
37  *
38  * Revision 1.2  2007/03/08 14:58:03  mchojnacki
39  * adding some alice stuff
40  *
41  * Revision 1.1.1.1  2007/03/07 10:14:49  mchojnacki
42  * First version on CVS
43  *
44  **************************************************************************/
45
46 #include "AliFemtoESDTrackCut.h"
47 #include <cstdio>
48
49 #ifdef __ROOT__ 
50 ClassImp(AliFemtoESDTrackCut)
51 #endif
52
53
54 // electron
55 // 0.13 - 1.8
56 // 0       7.594129e-02    8.256141e-03
57 // 1       -5.535827e-01   8.170825e-02
58 // 2       1.728591e+00    3.104210e-01
59 // 3       -2.827893e+00   5.827802e-01
60 // 4       2.503553e+00    5.736207e-01
61 // 5       -1.125965e+00   2.821170e-01
62 // 6       2.009036e-01    5.438876e-02
63
64 // pion
65 // 0.13 - 2.0
66 // 0       1.063457e+00    8.872043e-03
67 // 1       -4.222208e-01   2.534402e-02
68 // 2       1.042004e-01    1.503945e-02
69
70 // kaon
71 // 0.18 - 2.0
72 // 0       -7.289406e-02   1.686074e-03
73 // 1       4.415666e-01    1.143939e-02
74 // 2       -2.996790e-01   1.840964e-02
75 // 3       6.704652e-02    7.783990e-03
76
77 // proton
78 // 0.26 - 2.0
79 // 0       -3.730200e-02   2.347311e-03
80 // 1       1.163684e-01    1.319316e-02
81 // 2       8.354116e-02    1.997948e-02
82 // 3       -4.608098e-02   8.336400e-03
83
84
85 AliFemtoESDTrackCut::AliFemtoESDTrackCut() :
86     fCharge(0),
87     fLabel(0),
88     fStatus(0),
89     fminTPCclsF(0),
90     fminTPCncls(0),
91     fminITScls(0),
92     fMaxITSchiNdof(1000.0),
93     fMaxTPCchiNdof(1000.0),
94     fMaxSigmaToVertex(1000.0),
95     fNTracksPassed(0),
96     fNTracksFailed(0),
97     fRemoveKinks(kFALSE),
98     fMostProbable(0), 
99     fMaxImpactXY(1000.0),
100     fMaxImpactZ(1000.0),
101     fMinPforTOFpid(0.0),
102     fMaxPforTOFpid(10000.0),
103     fMinPforTPCpid(0.0),
104     fMaxPforTPCpid(10000.0),
105     fMinPforITSpid(0.0),
106     fMaxPforITSpid(10000.0)
107 {
108   // Default constructor
109   fNTracksPassed = fNTracksFailed = 0;
110   fCharge = 0;  // takes both charges 0
111   fPt[0]=0.0;              fPt[1] = 100.0;//100
112   fRapidity[0]=-2;       fRapidity[1]=2;//-2 2
113   fPidProbElectron[0]=-1;fPidProbElectron[1]=2;
114   fPidProbPion[0]=-1;    fPidProbPion[1]=2;
115   fPidProbKaon[0]=-1;fPidProbKaon[1]=2;
116   fPidProbProton[0]=-1;fPidProbProton[1]=2;
117   fPidProbMuon[0]=-1;fPidProbMuon[1]=2;
118   fLabel=false;
119   fStatus=0;
120   fminTPCclsF=0;
121   fminITScls=0;
122 }
123 //------------------------------
124 AliFemtoESDTrackCut::~AliFemtoESDTrackCut(){
125   /* noop */
126 }
127 //------------------------------
128 bool AliFemtoESDTrackCut::Pass(const AliFemtoTrack* track)
129 {
130   // test the particle and return 
131   // true if it meets all the criteria
132   // false if it doesn't meet at least one of the criteria
133   float tMost[5];
134   
135   //cout<<"AliFemtoESD  cut"<<endl;
136   //cout<<fPidProbPion[0]<<" < pi ="<<track->PidProbPion()<<" <"<<fPidProbPion[1]<<endl;
137   if (fStatus!=0)
138     {
139       //cout<<" status "<<track->Label()<<" "<<track->Flags()<<" "<<track->TPCnclsF()<<" "<<track->ITSncls()<<endl;
140       if ((track->Flags()&fStatus)!=fStatus)
141         {
142           //      cout<<track->Flags()<<" "<<fStatus<<" no go through status"<<endl;
143           return false;
144         }
145         
146     }
147   if (fRemoveKinks) {
148     if ((track->KinkIndex(0)) || (track->KinkIndex(1)) || (track->KinkIndex(2)))
149       return false;
150   }
151   if (fminTPCclsF>track->TPCnclsF())
152     {
153       //cout<<" No go because TPC Number of ClsF"<<fminTPCclsF<< " "<<track->TPCnclsF()<<endl;
154       return false;
155     }
156   if (fminTPCncls>track->TPCncls())
157     {
158       //cout<<" No go because TPC Number of ClsF"<<fminTPCclsF<< " "<<track->TPCnclsF()<<endl;
159       return false;
160     }
161   if (fminITScls>track->ITSncls())
162     {
163       //cout<<" No go because ITS Number of Cls"<<fminITScls<< " "<<track->ITSncls()<<endl;
164       return false;
165     }
166         
167   if (fMaxImpactXY < TMath::Abs(track->ImpactD()))
168     return false;
169
170   if (fMaxImpactZ < TMath::Abs(track->ImpactZ()))
171     return false;
172   
173   if (fMaxSigmaToVertex < track->SigmaToVertex()) {
174     return false;
175   }
176   
177   if (track->ITSncls() > 0) 
178     if ((track->ITSchi2()/track->ITSncls()) > fMaxITSchiNdof) {
179       return false;
180     }
181
182   if (track->TPCncls() > 0)
183     if ((track->TPCchi2()/track->TPCncls()) > fMaxTPCchiNdof) {
184       return false;
185     }
186
187   if (fLabel)
188     {
189       //cout<<"labels"<<endl;
190       if(track->Label()<0)
191         {
192           fNTracksFailed++;
193           //   cout<<"No Go Through the cut"<<endl;
194           //  cout<<fLabel<<" Label="<<track->Label()<<endl;
195           return false;
196         }    
197     }
198   if (fCharge!=0)
199     {              
200       //cout<<"AliFemtoESD  cut ch "<<endl;
201       //cout<<fCharge<<" Charge="<<track->Charge()<<endl;
202       if (track->Charge()!= fCharge)    
203         {
204           fNTracksFailed++;
205           //  cout<<"No Go Through the cut"<<endl;
206           // cout<<fCharge<<" Charge="<<track->Charge()<<endl;
207           return false;
208         }
209     }
210   Bool_t tTPCPidIn = (track->Flags()&AliFemtoTrack::kTPCpid)>0;
211   Bool_t tITSPidIn = (track->Flags()&AliFemtoTrack::kITSpid)>0;
212   Bool_t tTOFPidIn = (track->Flags()&AliFemtoTrack::kTOFpid)>0;
213   
214   if(fMinPforTOFpid > 0 && track->P().mag() > fMinPforTOFpid &&
215      track->P().mag() < fMaxPforTOFpid && !tTOFPidIn)
216     {
217       fNTracksFailed++;
218       return false;
219     }
220   
221   if(fMinPforTPCpid > 0 && track->P().mag() > fMinPforTPCpid &&
222      track->P().mag() < fMaxPforTPCpid && !tTPCPidIn)
223     {
224       fNTracksFailed++;
225       return false;
226     }
227   
228   if(fMinPforITSpid > 0 && track->P().mag() > fMinPforITSpid &&
229      track->P().mag() < fMaxPforITSpid && !tITSPidIn)
230     {
231       fNTracksFailed++;
232       return false;
233     }
234   
235
236   float tEnergy = ::sqrt(track->P().mag2()+fMass*fMass);
237   float tRapidity = 0.5*::log((tEnergy+track->P().z())/(tEnergy-track->P().z()));
238   float tPt = ::sqrt((track->P().x())*(track->P().x())+(track->P().y())*(track->P().y()));
239   if ((tRapidity<fRapidity[0])||(tRapidity>fRapidity[1]))
240     {
241       fNTracksFailed++;
242       //cout<<"No Go Through the cut"<<endl;   
243       //cout<<fRapidity[0]<<" < Rapidity ="<<tRapidity<<" <"<<fRapidity[1]<<endl;
244       return false;
245     }
246   if ((tPt<fPt[0])||(tPt>fPt[1]))
247     {
248       fNTracksFailed++;
249       //cout<<"No Go Through the cut"<<endl;
250       //cout<<fPt[0]<<" < Pt ="<<Pt<<" <"<<fPt[1]<<endl;
251       return false;
252     }
253 //   cout << "Track has pids: " 
254 //        << track->PidProbElectron() << " " 
255 //        << track->PidProbMuon() << " " 
256 //        << track->PidProbPion() << " " 
257 //        << track->PidProbKaon() << " " 
258 //        << track->PidProbProton() << " " 
259 //        << track->PidProbElectron()+track->PidProbMuon()+track->PidProbPion()+track->PidProbKaon()+track->PidProbProton() << endl;
260
261     
262   if ((track->PidProbElectron()<fPidProbElectron[0])||(track->PidProbElectron()>fPidProbElectron[1]))
263     {
264       fNTracksFailed++;
265       //cout<<"No Go Through the cut"<<endl;
266       //cout<<fPidProbElectron[0]<<" < e ="<<track->PidProbElectron()<<" <"<<fPidProbElectron[1]<<endl;
267       return false;
268     }
269   if ((track->PidProbPion()<fPidProbPion[0])||(track->PidProbPion()>fPidProbPion[1]))
270     {
271       fNTracksFailed++;
272       //cout<<"No Go Through the cut"<<endl;
273       //cout<<fPidProbPion[0]<<" < pi ="<<track->PidProbPion()<<" <"<<fPidProbPion[1]<<endl;
274       return false;
275     }
276   if ((track->PidProbKaon()<fPidProbKaon[0])||(track->PidProbKaon()>fPidProbKaon[1]))
277     {
278       fNTracksFailed++;
279       //cout<<"No Go Through the cut"<<endl;
280       //cout<<fPidProbKaon[0]<<" < k ="<<track->PidProbKaon()<<" <"<<fPidProbKaon[1]<<endl;
281       return false;
282     }
283   if ((track->PidProbProton()<fPidProbProton[0])||(track->PidProbProton()>fPidProbProton[1]))
284     {
285       fNTracksFailed++;
286       //cout<<"No Go Through the cut"<<endl;
287       //cout<<fPidProbProton[0]<<" < p  ="<<track->PidProbProton()<<" <"<<fPidProbProton[1]<<endl;
288       return false;
289     }
290   if ((track->PidProbMuon()<fPidProbMuon[0])||(track->PidProbMuon()>fPidProbMuon[1]))
291     {
292       fNTracksFailed++;
293       //cout<<"No Go Through the cut"<<endl;
294       //cout<<fPidProbMuon[0]<<" <  mi="<<track->PidProbMuon()<<" <"<<fPidProbMuon[1]<<endl;
295       return false;
296     }
297
298   if (fMostProbable) {
299     tMost[0] = track->PidProbElectron()*PidFractionElectron(track->P().mag());
300     tMost[1] = 0.0;
301     tMost[2] = track->PidProbPion()*PidFractionPion(track->P().mag());
302     tMost[3] = track->PidProbKaon()*PidFractionKaon(track->P().mag());
303     tMost[4] = track->PidProbProton()*PidFractionProton(track->P().mag());
304     int imost=0;
305     float ipidmax = 0.0;
306     for (int ip=0; ip<5; ip++)
307       if (tMost[ip] > ipidmax) { ipidmax = tMost[ip]; imost = ip; };
308     if (imost != fMostProbable) return false;
309   }
310   
311   // cout<<"Go Through the cut"<<endl;
312   // cout<<fLabel<<" Label="<<track->Label()<<endl;
313   // cout<<fCharge<<" Charge="<<track->Charge()<<endl;
314   // cout<<fPt[0]<<" < Pt ="<<Pt<<" <"<<fPt[1]<<endl;
315   //cout<<fRapidity[0]<<" < Rapidity ="<<tRapidity<<" <"<<fRapidity[1]<<endl;
316   //cout<<fPidProbElectron[0]<<" <  e="<<track->PidProbElectron()<<" <"<<fPidProbElectron[1]<<endl;
317   //cout<<fPidProbPion[0]<<" <  pi="<<track->PidProbPion()<<" <"<<fPidProbPion[1]<<endl;
318   //cout<<fPidProbKaon[0]<<" <  k="<<track->PidProbKaon()<<" <"<<fPidProbKaon[1]<<endl;
319   //cout<<fPidProbProton[0]<<" <  p="<<track->PidProbProton()<<" <"<<fPidProbProton[1]<<endl;
320   //cout<<fPidProbMuon[0]<<" <  mi="<<track->PidProbMuon()<<" <"<<fPidProbMuon[1]<<endl;
321   fNTracksPassed++ ;
322   return true;
323     
324     
325 }
326 //------------------------------
327 AliFemtoString AliFemtoESDTrackCut::Report()
328 {
329   // Prepare report from the execution
330   string tStemp;
331   char tCtemp[100];
332   sprintf(tCtemp,"Particle mass:\t%E\n",this->Mass());
333   tStemp=tCtemp;
334   sprintf(tCtemp,"Particle charge:\t%d\n",fCharge);
335   tStemp+=tCtemp;
336   sprintf(tCtemp,"Particle pT:\t%E - %E\n",fPt[0],fPt[1]);
337   tStemp+=tCtemp;
338   sprintf(tCtemp,"Particle rapidity:\t%E - %E\n",fRapidity[0],fRapidity[1]);
339   tStemp+=tCtemp;
340   sprintf(tCtemp,"Number of tracks which passed:\t%ld  Number which failed:\t%ld\n",fNTracksPassed,fNTracksFailed);
341   tStemp += tCtemp;
342   AliFemtoString returnThis = tStemp;
343   return returnThis;
344 }
345 TList *AliFemtoESDTrackCut::ListSettings()
346 {
347   // return a list of settings in a writable form
348   TList *tListSetttings = new TList();
349   char buf[200];
350   snprintf(buf, 200, "AliFemtoESDTrackCut.mass=%f", this->Mass());
351   tListSetttings->AddLast(new TObjString(buf));
352
353   snprintf(buf, 200, "AliFemtoESDTrackCut.charge=%i", fCharge);
354   tListSetttings->AddLast(new TObjString(buf));
355   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobpion.minimum=%f", fPidProbPion[0]);
356   tListSetttings->AddLast(new TObjString(buf));
357   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobpion.maximum=%f", fPidProbPion[1]);
358   tListSetttings->AddLast(new TObjString(buf));
359   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobkaon.minimum=%f", fPidProbKaon[0]);
360   tListSetttings->AddLast(new TObjString(buf));
361   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobkaon.maximum=%f", fPidProbKaon[1]);
362   tListSetttings->AddLast(new TObjString(buf));
363   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobproton.minimum=%f", fPidProbProton[0]);
364   tListSetttings->AddLast(new TObjString(buf));
365   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobproton.maximum=%f", fPidProbProton[1]);
366   tListSetttings->AddLast(new TObjString(buf));
367   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobelectron.minimum=%f", fPidProbElectron[0]);
368   tListSetttings->AddLast(new TObjString(buf));
369   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobelectron.maximum=%f", fPidProbElectron[1]);
370   tListSetttings->AddLast(new TObjString(buf));
371   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobMuon.minimum=%f", fPidProbMuon[0]);
372   tListSetttings->AddLast(new TObjString(buf));
373   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobMuon.maximum=%f", fPidProbMuon[1]);
374   tListSetttings->AddLast(new TObjString(buf));
375   snprintf(buf, 200, "AliFemtoESDTrackCut.minimumtpcclusters=%i", fminTPCclsF);
376   tListSetttings->AddLast(new TObjString(buf));
377   snprintf(buf, 200, "AliFemtoESDTrackCut.minimumitsclusters=%i", fminTPCclsF);
378   tListSetttings->AddLast(new TObjString(buf));
379   snprintf(buf, 200, "AliFemtoESDTrackCut.pt.minimum=%f", fPt[0]);
380   tListSetttings->AddLast(new TObjString(buf));
381   snprintf(buf, 200, "AliFemtoESDTrackCut.pt.maximum=%f", fPt[1]);
382   tListSetttings->AddLast(new TObjString(buf));
383   snprintf(buf, 200, "AliFemtoESDTrackCut.rapidity.minimum=%f", fRapidity[0]);
384   tListSetttings->AddLast(new TObjString(buf));
385   snprintf(buf, 200, "AliFemtoESDTrackCut.rapidity.maximum=%f", fRapidity[1]);
386   tListSetttings->AddLast(new TObjString(buf));
387   snprintf(buf, 200, "AliFemtoESDTrackCut.removekinks=%i", fRemoveKinks);
388   tListSetttings->AddLast(new TObjString(buf));
389   snprintf(buf, 200, "AliFemtoESDTrackCut.maxitschindof=%f", fMaxITSchiNdof);
390   tListSetttings->AddLast(new TObjString(buf));
391   snprintf(buf, 200, "AliFemtoESDTrackCut.maxtpcchindof=%f", fMaxTPCchiNdof);
392   tListSetttings->AddLast(new TObjString(buf));
393   snprintf(buf, 200, "AliFemtoESDTrackCut.maxsigmatovertex=%f", fMaxSigmaToVertex);
394   tListSetttings->AddLast(new TObjString(buf));
395   snprintf(buf, 200, "AliFemtoESDTrackCut.maximpactxy=%f", fMaxImpactXY);
396   tListSetttings->AddLast(new TObjString(buf));
397   snprintf(buf, 200, "AliFemtoESDTrackCut.maximpactz=%f", fMaxImpactZ);
398   tListSetttings->AddLast(new TObjString(buf));
399   if (fMostProbable) {
400     if (fMostProbable == 2)
401       snprintf(buf, 200, "AliFemtoESDTrackCut.mostprobable=%s", "Pion");
402     if (fMostProbable == 3)
403       snprintf(buf, 200, "AliFemtoESDTrackCut.mostprobable=%s", "Kaon");
404     if (fMostProbable == 4)
405       snprintf(buf, 200, "AliFemtoESDTrackCut.mostprobable=%s", "Proton");
406     tListSetttings->AddLast(new TObjString(buf));
407   }
408   return tListSetttings;
409 }
410 void AliFemtoESDTrackCut::SetRemoveKinks(const bool& flag)
411 {
412   fRemoveKinks = flag;
413 }
414                             
415                             // electron
416 // 0.13 - 1.8
417 // 0       7.594129e-02    8.256141e-03
418 // 1       -5.535827e-01   8.170825e-02
419 // 2       1.728591e+00    3.104210e-01
420 // 3       -2.827893e+00   5.827802e-01
421 // 4       2.503553e+00    5.736207e-01
422 // 5       -1.125965e+00   2.821170e-01
423 // 6       2.009036e-01    5.438876e-02
424 float AliFemtoESDTrackCut::PidFractionElectron(float mom) const
425 {
426   // Provide a parameterized fraction of electrons dependent on momentum
427   if (mom<0.13) return 0.0;
428   if (mom>1.8) return 0.0;
429   return (7.594129e-02 
430           -5.535827e-01*mom        
431           +1.728591e+00*mom*mom    
432           -2.827893e+00*mom*mom*mom 
433           +2.503553e+00*mom*mom*mom*mom    
434           -1.125965e+00*mom*mom*mom*mom*mom      
435           +2.009036e-01*mom*mom*mom*mom*mom*mom);   
436 }
437
438 // pion
439 // 0.13 - 2.0
440 // 0       1.063457e+00    8.872043e-03
441 // 1       -4.222208e-01   2.534402e-02
442 // 2       1.042004e-01    1.503945e-02
443 float AliFemtoESDTrackCut::PidFractionPion(float mom) const
444 {
445   // Provide a parameterized fraction of pions dependent on momentum
446   if (mom<0.13) return 0.0;
447   if (mom>2.0) return 0.0;
448   return ( 1.063457e+00
449            -4.222208e-01*mom
450            +1.042004e-01*mom*mom);
451 }
452
453 // kaon
454 // 0.18 - 2.0
455 // 0       -7.289406e-02   1.686074e-03
456 // 1       4.415666e-01    1.143939e-02
457 // 2       -2.996790e-01   1.840964e-02
458 // 3       6.704652e-02    7.783990e-03
459 float AliFemtoESDTrackCut::PidFractionKaon(float mom) const
460 {
461   // Provide a parameterized fraction of kaons dependent on momentum
462   if (mom<0.18) return 0.0;
463   if (mom>2.0) return 0.0;
464   return (-7.289406e-02
465           +4.415666e-01*mom        
466           -2.996790e-01*mom*mom    
467           +6.704652e-02*mom*mom*mom);
468 }
469
470 // proton
471 // 0.26 - 2.0
472 // 0       -3.730200e-02   2.347311e-03
473 // 1       1.163684e-01    1.319316e-02
474 // 2       8.354116e-02    1.997948e-02
475 // 3       -4.608098e-02   8.336400e-03
476 float AliFemtoESDTrackCut::PidFractionProton(float mom) const
477 {
478   // Provide a parameterized fraction of protons dependent on momentum
479   if (mom<0.26) return  0.0;
480   if (mom>2.0) return 0.0;
481   return (-3.730200e-02  
482           +1.163684e-01*mom           
483           +8.354116e-02*mom*mom       
484           -4.608098e-02*mom*mom*mom);  
485 }
486
487 void AliFemtoESDTrackCut::SetMomRangeTOFpidIs(const float& minp, const float& maxp)
488 {
489   fMinPforTOFpid = minp;
490   fMaxPforTOFpid = maxp;
491 }
492
493 void AliFemtoESDTrackCut::SetMomRangeTPCpidIs(const float& minp, const float& maxp)
494 {
495   fMinPforTPCpid = minp;
496   fMaxPforTPCpid = maxp;
497 }
498
499 void AliFemtoESDTrackCut::SetMomRangeITSpidIs(const float& minp, const float& maxp)
500 {
501   fMinPforITSpid = minp;
502   fMaxPforITSpid = maxp;
503 }
504