438976d9fa2803c1d1d20500f61f2c3b770ee4ab
[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.2  2007/05/21 10:38:25  akisiel
15  * More coding rule conformance
16  *
17  * Revision 1.1  2007/05/16 10:25:06  akisiel
18  * Making the directory structure of AliFemtoUser flat. All files go into one common directory
19  *
20  * Revision 1.4  2007/05/03 09:46:10  akisiel
21  * Fixing Effective C++ warnings
22  *
23  * Revision 1.3  2007/04/27 07:25:59  akisiel
24  * Make revisions needed for compilation from the main AliRoot tree
25  *
26  * Revision 1.1.1.1  2007/04/25 15:38:41  panos
27  * Importing the HBT code dir
28  *
29  * Revision 1.4  2007-04-03 16:00:08  mchojnacki
30  * Changes to iprove memory managing
31  *
32  * Revision 1.3  2007/03/13 15:30:03  mchojnacki
33  * adding reader for simulated data
34  *
35  * Revision 1.2  2007/03/08 14:58:03  mchojnacki
36  * adding some alice stuff
37  *
38  * Revision 1.1.1.1  2007/03/07 10:14:49  mchojnacki
39  * First version on CVS
40  *
41  **************************************************************************/
42
43 #include "AliFemtoESDTrackCut.h"
44 #include <cstdio>
45
46 #ifdef __ROOT__ 
47 ClassImp(AliFemtoESDTrackCut)
48 #endif
49
50 AliFemtoESDTrackCut::AliFemtoESDTrackCut() :
51     fCharge(0),
52     fLabel(0),
53     fStatus(0),
54     fminTPCclsF(0),
55     fminITScls(0),
56     fNTracksPassed(0),
57     fNTracksFailed(0)
58 {
59   // Default constructor
60   fNTracksPassed = fNTracksFailed = 0;
61   fCharge = 0;  // takes both charges 0
62   fPt[0]=0.0;              fPt[1] = 100.0;//100
63   fRapidity[0]=-2;       fRapidity[1]=2;//-2 2
64   fPidProbElectron[0]=-1;fPidProbElectron[1]=2;
65   fPidProbPion[0]=-1;    fPidProbPion[1]=2;
66   fPidProbKaon[0]=-1;fPidProbKaon[1]=2;
67   fPidProbProton[0]=-1;fPidProbProton[1]=2;
68   fPidProbMuon[0]=-1;fPidProbMuon[1]=2;
69   fLabel=false;
70   fStatus=0;
71   fminTPCclsF=0;
72   fminITScls=0;
73     
74 }
75 //------------------------------
76 //AliFemtoESDTrackCut::~AliFemtoESDTrackCut(){
77 //  /* noop */
78 //}
79 //------------------------------
80 bool AliFemtoESDTrackCut::Pass(const AliFemtoTrack* track)
81 {
82   // test the particle and return 
83   // true if it meets all the criteria
84   // false if it doesn't meet at least one of the criteria
85   
86   //cout<<"AliFemtoESD  cut"<<endl;
87   //cout<<fPidProbPion[0]<<" < pi ="<<track->PidProbPion()<<" <"<<fPidProbPion[1]<<endl;
88   if (fStatus!=0)
89     {
90       //cout<<" status "<<track->Label()<<" "<<track->Flags()<<" "<<track->TPCnclsF()<<" "<<track->ITSncls()<<endl;
91       if ((track->Flags()&fStatus)!=fStatus)
92         {
93           //  cout<<track->Flags()<<" "<<fStatus<<" no go through status"<<endl;
94           return false;
95         }
96         
97     }
98   if (fminTPCclsF>track->TPCnclsF())
99     {
100       //cout<<" No go because TPC Number of ClsF"<<fminTPCclsF<< " "<<track->TPCnclsF()<<endl;
101       return false;
102     }
103   if (fminITScls>track->ITSncls())
104     {
105       //cout<<" No go because ITS Number of Cls"<<fminITScls<< " "<<track->ITSncls()<<endl;
106       return false;
107     }
108         
109   if (fLabel)
110     {
111       //cout<<"labels"<<endl;
112       if(track->Label()<0)
113         {
114           fNTracksFailed++;
115           //   cout<<"No Go Through the cut"<<endl;
116           //  cout<<fLabel<<" Label="<<track->Label()<<endl;
117           return false;
118         }    
119     }
120   if (fCharge!=0)
121     {              
122       //cout<<"AliFemtoESD  cut ch "<<endl;
123       //cout<<fCharge<<" Charge="<<track->Charge()<<endl;
124       if (track->Charge()!= fCharge)    
125         {
126           fNTracksFailed++;
127           //  cout<<"No Go Through the cut"<<endl;
128           // cout<<fCharge<<" Charge="<<track->Charge()<<endl;
129           return false;
130         }
131     }
132   float tEnergy = ::sqrt(track->P().mag2()+fMass*fMass);
133   float tRapidity = 0.5*::log((tEnergy+track->P().z())/(tEnergy-track->P().z()));
134   float tPt = ::sqrt((track->P().x())*(track->P().x())+(track->P().y())*(track->P().y()));
135   if ((tRapidity<fRapidity[0])||(tRapidity>fRapidity[1]))
136     {
137       fNTracksFailed++;
138       //cout<<"No Go Through the cut"<<endl;   
139       //cout<<fRapidity[0]<<" < Rapidity ="<<tRapidity<<" <"<<fRapidity[1]<<endl;
140       return false;
141     }
142   if ((tPt<fPt[0])||(tPt>fPt[1]))
143     {
144       fNTracksFailed++;
145       //cout<<"No Go Through the cut"<<endl;
146       //cout<<fPt[0]<<" < Pt ="<<Pt<<" <"<<fPt[1]<<endl;
147       return false;
148     }
149   if ((track->PidProbElectron()<fPidProbElectron[0])||(track->PidProbElectron()>fPidProbElectron[1]))
150     {
151       fNTracksFailed++;
152       //cout<<"No Go Through the cut"<<endl;
153       //cout<<fPidProbElectron[0]<<" < e ="<<track->PidProbElectron()<<" <"<<fPidProbElectron[1]<<endl;
154       return false;
155     }
156   if ((track->PidProbPion()<fPidProbPion[0])||(track->PidProbPion()>fPidProbPion[1]))
157     {
158       fNTracksFailed++;
159       //cout<<"No Go Through the cut"<<endl;
160       //cout<<fPidProbPion[0]<<" < pi ="<<track->PidProbPion()<<" <"<<fPidProbPion[1]<<endl;
161       return false;
162     }
163   if ((track->PidProbKaon()<fPidProbKaon[0])||(track->PidProbKaon()>fPidProbKaon[1]))
164     {
165       fNTracksFailed++;
166       //cout<<"No Go Through the cut"<<endl;
167       //cout<<fPidProbKaon[0]<<" < k ="<<track->PidProbKaon()<<" <"<<fPidProbKaon[1]<<endl;
168       return false;
169     }
170   if ((track->PidProbProton()<fPidProbProton[0])||(track->PidProbProton()>fPidProbProton[1]))
171     {
172       fNTracksFailed++;
173       //cout<<"No Go Through the cut"<<endl;
174       //cout<<fPidProbProton[0]<<" < p  ="<<track->PidProbProton()<<" <"<<fPidProbProton[1]<<endl;
175       return false;
176     }
177   if ((track->PidProbMuon()<fPidProbMuon[0])||(track->PidProbMuon()>fPidProbMuon[1]))
178     {
179       fNTracksFailed++;
180       //cout<<"No Go Through the cut"<<endl;
181       //cout<<fPidProbMuon[0]<<" <  mi="<<track->PidProbMuon()<<" <"<<fPidProbMuon[1]<<endl;
182       return false;
183     }
184   
185   // cout<<"Go Through the cut"<<endl;
186   // cout<<fLabel<<" Label="<<track->Label()<<endl;
187   // cout<<fCharge<<" Charge="<<track->Charge()<<endl;
188   // cout<<fPt[0]<<" < Pt ="<<Pt<<" <"<<fPt[1]<<endl;
189   //cout<<fRapidity[0]<<" < Rapidity ="<<tRapidity<<" <"<<fRapidity[1]<<endl;
190   //cout<<fPidProbElectron[0]<<" <  e="<<track->PidProbElectron()<<" <"<<fPidProbElectron[1]<<endl;
191   //cout<<fPidProbPion[0]<<" <  pi="<<track->PidProbPion()<<" <"<<fPidProbPion[1]<<endl;
192   //cout<<fPidProbKaon[0]<<" <  k="<<track->PidProbKaon()<<" <"<<fPidProbKaon[1]<<endl;
193   //cout<<fPidProbProton[0]<<" <  p="<<track->PidProbProton()<<" <"<<fPidProbProton[1]<<endl;
194   //cout<<fPidProbMuon[0]<<" <  mi="<<track->PidProbMuon()<<" <"<<fPidProbMuon[1]<<endl;
195   fNTracksPassed++ ;
196   return true;
197     
198     
199 }
200 //------------------------------
201 AliFemtoString AliFemtoESDTrackCut::Report()
202 {
203   string tStemp;
204   char tCtemp[100];
205   sprintf(tCtemp,"Particle mass:\t%E\n",this->Mass());
206   tStemp=tCtemp;
207   sprintf(tCtemp,"Particle charge:\t%d\n",fCharge);
208   tStemp+=tCtemp;
209   sprintf(tCtemp,"Particle pT:\t%E - %E\n",fPt[0],fPt[1]);
210   tStemp+=tCtemp;
211   sprintf(tCtemp,"Particle rapidity:\t%E - %E\n",fRapidity[0],fRapidity[1]);
212   tStemp+=tCtemp;
213   sprintf(tCtemp,"Number of tracks which passed:\t%ld  Number which failed:\t%ld\n",fNTracksPassed,fNTracksFailed);
214   tStemp += tCtemp;
215   AliFemtoString returnThis = tStemp;
216   return returnThis;
217 }
218 TList *AliFemtoESDTrackCut::ListSettings()
219 {
220   // return a list of settings in a writable form
221   TList *tListSetttings = new TList();
222   char buf[200];
223   snprintf(buf, 200, "AliFemtoESDTrackCut.mass=%lf", this->Mass());
224   tListSetttings->AddLast(new TObjString(buf));
225
226   snprintf(buf, 200, "AliFemtoESDTrackCut.charge=%i", fCharge);
227   tListSetttings->AddLast(new TObjString(buf));
228   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobpion.minimum=%lf", fPidProbPion[0]);
229   tListSetttings->AddLast(new TObjString(buf));
230   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobpion.maximum=%lf", fPidProbPion[1]);
231   tListSetttings->AddLast(new TObjString(buf));
232   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobkaon.minimum=%lf", fPidProbKaon[0]);
233   tListSetttings->AddLast(new TObjString(buf));
234   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobkaon.maximum=%lf", fPidProbKaon[1]);
235   tListSetttings->AddLast(new TObjString(buf));
236   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobproton.minimum=%lf", fPidProbProton[0]);
237   tListSetttings->AddLast(new TObjString(buf));
238   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobproton.maximum=%lf", fPidProbProton[1]);
239   tListSetttings->AddLast(new TObjString(buf));
240   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobelectron.minimum=%lf", fPidProbElectron[0]);
241   tListSetttings->AddLast(new TObjString(buf));
242   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobelectron.maximum=%lf", fPidProbElectron[1]);
243   tListSetttings->AddLast(new TObjString(buf));
244   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobMuon.minimum=%lf", fPidProbMuon[0]);
245   tListSetttings->AddLast(new TObjString(buf));
246   snprintf(buf, 200, "AliFemtoESDTrackCut.pidprobMuon.maximum=%lf", fPidProbMuon[1]);
247   tListSetttings->AddLast(new TObjString(buf));
248   snprintf(buf, 200, "AliFemtoESDTrackCut.minimumtpcclusters=%i", fminTPCclsF);
249   tListSetttings->AddLast(new TObjString(buf));
250   snprintf(buf, 200, "AliFemtoESDTrackCut.minimumitsclusters=%i", fminTPCclsF);
251   tListSetttings->AddLast(new TObjString(buf));
252   snprintf(buf, 200, "AliFemtoESDTrackCut.pt.minimum=%lf", fPt[0]);
253   tListSetttings->AddLast(new TObjString(buf));
254   snprintf(buf, 200, "AliFemtoESDTrackCut.pt.maximum=%lf", fPt[1]);
255   tListSetttings->AddLast(new TObjString(buf));
256   snprintf(buf, 200, "AliFemtoESDTrackCut.rapidity.minimum=%lf", fRapidity[0]);
257   tListSetttings->AddLast(new TObjString(buf));
258   snprintf(buf, 200, "AliFemtoESDTrackCut.rapidity.maximum=%lf", fRapidity[1]);
259   tListSetttings->AddLast(new TObjString(buf));
260
261   return tListSetttings;
262 }