]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/SPECTRA/Nuclei/B2/AliLnAODtrackCuts.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / Nuclei / B2 / AliLnAODtrackCuts.cxx
CommitLineData
9e44412b 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16// AOD track cuts for B2
17// author: Eulogio Serradilla <eulogio.serradilla@cern.ch>
18
19#include <TMath.h>
20#include <TString.h>
21#include <TVector3.h>
22#include <AliPID.h>
23#include <AliAODEvent.h>
24#include <AliAODMCParticle.h>
25#include <AliAODTrack.h>
368c671a 26#include <AliAODVertex.h>
9e44412b 27#include "AliLnAODtrackCuts.h"
28
29ClassImp(AliLnAODtrackCuts)
30
31AliLnAODtrackCuts::AliLnAODtrackCuts()
32: TObject()
33, fTrackSel("its_tpc_dca")
34, fMaxDCAxy(1)
35, fMaxDCAz(2)
36, fMaxNSigma(3)
37, fMaxEta(0.8)
38, fTPCXRows(0)
39, fMinTPCnClsOrXRows(70)
40, fTOFmatch(0)
41{
42//
43// constructor
44}
45
46AliLnAODtrackCuts::~AliLnAODtrackCuts()
47{
48//
49// virtual destructor
50}
51
52void AliLnAODtrackCuts::SetSelectionCriteria(const TString& trksel)
53{
54//
55// set track selection criteria
56//
57 fTrackSel = trksel;
58 fTrackSel.ToLower();
59 fTOFmatch = (fTrackSel.Contains("tof")) ? kTRUE : kFALSE;
60}
61
62Bool_t AliLnAODtrackCuts::IsWithinGeoAcceptance(const AliAODMCParticle* prt) const
63{
64//
65// is particle within the geometrical acceptance?
66//
368c671a 67 if( TMath::Abs(prt->Eta()) < fMaxEta ) return kTRUE;
9e44412b 68
368c671a 69 return kFALSE;
9e44412b 70}
71
72Bool_t AliLnAODtrackCuts::IsWithinGeoAcceptance(const AliAODTrack* trk) const
73{
74//
75// is track within the geometrical acceptance?
76//
77//
368c671a 78 if( TMath::Abs(trk->Eta()) < fMaxEta ) return kTRUE;
9e44412b 79
368c671a 80 return kFALSE;
9e44412b 81}
82
83Bool_t AliLnAODtrackCuts::IsWithinGeoAcceptance(Double_t p[3]) const
84{
85//
86// is track within the geometrical acceptance?
87//
88//
89 TVector3 trk(p[0],p[1],p[2]);
368c671a 90 if( TMath::Abs(trk.Eta()) < fMaxEta ) return kTRUE;
9e44412b 91
368c671a 92 return kFALSE;
93}
94
95Bool_t AliLnAODtrackCuts::IsKinkDaughter(const AliAODTrack* trk) const
96{
97//
98// is this track a kink daughter?
99//
100//
101 AliAODVertex* vtx = trk->GetProdVertex();
102
103 if(vtx == 0 ) return kFALSE;
104 if(vtx->GetType() == AliAODVertex::kKink) return kTRUE;
105
106 return kFALSE;
9e44412b 107}
108
109Double_t AliLnAODtrackCuts::GetNTPCXRowsOverFindable(const AliAODTrack* trk) const
110{
111//
112// number of TPC crossed rows over findable
113//
368c671a 114 if(trk->GetTPCNclsF() <= 0) return 1;
9e44412b 115
116 return static_cast<Double_t>(trk->GetTPCNCrossedRows())/static_cast<Double_t>(trk->GetTPCNclsF());
117}
118
119Bool_t AliLnAODtrackCuts::AcceptItsTpcNSigma(const AliAODTrack* trk, Double_t b[2], Double_t bCov[3]) const
120{
121//
122// Check ITS-TPC nsigma base cuts
123//
124 if(!trk->IsOn(AliAODTrack::kITSrefit)) return kFALSE;
125 if(trk->GetITSNcls()<2) return kFALSE;
126 //if(trk->GetITSchi2PerCluster()>36) return kFALSE;
127
128 if(!trk->TestFilterBit(AliAODTrack::kTrkTPCOnly)) return kFALSE;
129 if(!trk->IsOn(AliAODTrack::kTPCrefit) ) return kFALSE;
130
368c671a 131 if(this->IsKinkDaughter(trk)) return kFALSE;
132
9e44412b 133 if(fTPCXRows)
134 {
135 if(trk->GetTPCNCrossedRows()<fMinTPCnClsOrXRows) return kFALSE;
136 if(this->GetNTPCXRowsOverFindable(trk)< 0.8 ) return kFALSE;
137 }
138 else
139 {
140 if(trk->GetTPCNcls()<fMinTPCnClsOrXRows) return kFALSE;
141 }
142
143 //if(trk->GetTPCchi2Global()>36) return kFALSE;
144
145 if(this->GetNSigmaToVertex(b, bCov) > fMaxNSigma) return kFALSE;
146
147 return kTRUE;
148}
149
150Bool_t AliLnAODtrackCuts::AcceptItsTpcDCA(const AliAODTrack* trk, Double_t b[2]) const
151{
152//
153// Check ITS-TPC-DCA base cuts
154//
9e44412b 155 if(!trk->IsOn(AliAODTrack::kITSrefit) ) return kFALSE;
156 if(trk->GetITSNcls()<2) return kFALSE;
157 //if(trk->GetITSchi2PerCluster()>36) return kFALSE;
158
159 if(!trk->IsOn(AliAODTrack::kTPCrefit) ) return kFALSE;
160 if(!trk->TestFilterBit(AliAODTrack::kTrkTPCOnly)) return kFALSE;
161
368c671a 162 if(this->IsKinkDaughter(trk)) return kFALSE;
163
9e44412b 164 if(fTPCXRows)
165 {
166 if(trk->GetTPCNCrossedRows()<fMinTPCnClsOrXRows) return kFALSE;
167 if(this->GetNTPCXRowsOverFindable(trk)< 0.8 ) return kFALSE;
168 }
169 else
170 {
171 if(trk->GetTPCNcls()<fMinTPCnClsOrXRows) return kFALSE;
172 }
173
174 //if(trk->GetTPCchi2Global()>36) return kFALSE;
175
176 if(TMath::Abs(b[0]) > fMaxDCAxy) return kFALSE;
177 if(TMath::Abs(b[1]) > fMaxDCAz) return kFALSE;
178
179 return kTRUE;
180}
181
182Bool_t AliLnAODtrackCuts::AcceptItsTpcStdCut(const AliAODTrack* trk, Double_t b[2]) const
183{
184//
185// standard cuts with very loose DCA
186//
187 if(!trk->TestFilterBit(AliAODTrack::kTrkGlobalNoDCA)) return kFALSE;
188
189 if(trk->GetTPCNcls()<70) return kFALSE;
190
191 if(TMath::Abs(b[0]) > fMaxDCAxy) return kFALSE;
192 if(TMath::Abs(b[1]) > fMaxDCAz) return kFALSE;
193
194 return kTRUE;
195}
196
197Bool_t AliLnAODtrackCuts::AcceptTOF(const AliAODTrack* trk) const
198{
199//
200// check TOF match signal
201//
202 if( !trk->IsOn(AliAODTrack::kTOFout) || !trk->IsOn(AliAODTrack::kTIME)) return kFALSE;
203 //if( trk->GetIntegratedLength() < 350) return kFALSE;
204 if( this->GetIntegratedLength(trk) < 350) return kFALSE;
205 if( trk->GetTOFsignal() < 1e-6) return kFALSE;
206
207 return kTRUE;
208}
209
210Bool_t AliLnAODtrackCuts::AcceptTrack(const AliAODTrack* trk, Double_t b[2], Double_t bCov[3]) const
211{
212//
213// check if the tracks fulfill the track selection criteria
214// from a predefined set of track cuts
215//
216 if(fTrackSel == "its_tpc_dca")
217 {
218 if(!this->AcceptItsTpcDCA(trk, b)) return kFALSE;
219 }
220 else if(fTrackSel == "its_tpc_dca_spd1")
221 {
222 if(!this->AcceptItsTpcDCA(trk, b)) return kFALSE;
223 if(!trk->HasPointOnITSLayer(0) ) return kFALSE;
224 }
225 else if(fTrackSel == "its_tpc_dca_spd" || fTrackSel == "its_tpc_dca_spd2")
226 {
227 if(!this->AcceptItsTpcDCA(trk, b)) return kFALSE;
228 if(!trk->HasPointOnITSLayer(0) && !trk->HasPointOnITSLayer(1) ) return kFALSE;
229 }
230 else if(fTrackSel == "its_tpc_tof_nsigma")
231 {
232 if(!this->AcceptItsTpcNSigma(trk, b, bCov)) return kFALSE;
233 if(!this->AcceptTOF(trk)) return kFALSE;
234 }
235 else if(fTrackSel == "its_tpc_tof_nsigma_spd" || fTrackSel == "its_tpc_tof_nsigma_spd2")
236 {
237 if(!this->AcceptItsTpcNSigma(trk, b, bCov)) return kFALSE;
238 if(!this->AcceptTOF(trk)) return kFALSE;
239 if(!trk->HasPointOnITSLayer(0) && !trk->HasPointOnITSLayer(1) ) return kFALSE;
240 }
241 else if(fTrackSel == "its_tpc_tof_dca")
242 {
243 if(!this->AcceptItsTpcDCA(trk, b)) return kFALSE;
244 if(!this->AcceptTOF(trk)) return kFALSE;
245 }
246 else if(fTrackSel == "its_tpc_tof_dca_spd1")
247 {
248 if(!this->AcceptItsTpcDCA(trk, b)) return kFALSE;
249 if(!this->AcceptTOF(trk)) return kFALSE;
250 if(!trk->HasPointOnITSLayer(0) ) return kFALSE;
251 }
252 else if(fTrackSel == "its_tpc_tof_dca_spd" || fTrackSel == "its_tpc_tof_dca_spd2")
253 {
254 if(!this->AcceptItsTpcDCA(trk, b)) return kFALSE;
255 if(!this->AcceptTOF(trk)) return kFALSE;
256 if(!trk->HasPointOnITSLayer(0) && !trk->HasPointOnITSLayer(1) ) return kFALSE;
257 }
258 else if(fTrackSel == "std_its_tpc_dca")
259 {
260 if(!this->AcceptItsTpcStdCut(trk, b)) return kFALSE;
261 }
262 else if(fTrackSel == "std_its_tpc_tof_dca")
263 {
264 if(!this->AcceptItsTpcStdCut(trk, b)) return kFALSE;
265 if(!this->AcceptTOF(trk)) return kFALSE;
266 }
267 else if(fTrackSel == "std_its_tpc_2010" || fTrackSel == "std_its_tpc_2011")
268 {
269 if(!trk->TestFilterBit(AliAODTrack::kTrkGlobal)) return kFALSE;
270 if(trk->GetTPCNcls()<70) return kFALSE;
271 }
272 else if(fTrackSel == "std_its_tpc_tof_2010" || fTrackSel == "std_its_tpc_tof_2011")
273 {
274 if(!trk->TestFilterBit(AliAODTrack::kTrkGlobal)) return kFALSE;
275 if(trk->GetTPCNcls()<70) return kFALSE;
276 if(!this->AcceptTOF(trk)) return kFALSE;
277 }
278 else
279 {
280 // default to standard cuts with tight DCA cut
281 return trk->TestFilterBit(AliAODTrack::kTrkGlobal);
282 }
283
284 return kTRUE;
285}
286
287Double_t AliLnAODtrackCuts::GetIntegratedLength(const AliAODTrack* trk, Int_t pid) const
288{
289//
290// track length workaround (cm)
291//
292 Double_t times[10];
293 trk->GetIntegratedTimes(times);
294
295 Double_t m = AliPID::ParticleMass(AliPID::kElectron);
296 Double_t t = times[0];
297 Double_t p = (pid > AliPID::kTriton) ? 2.*trk->P() : trk->P();
298 Double_t c = 2.99792458e-2; // cm/ps
299 Double_t beta = p/TMath::Sqrt(p*p+m*m);
300
301 return c*t*beta;
302}
303
304Double_t AliLnAODtrackCuts::GetNSigmaToVertex(Double_t b[2], Double_t bCov[3]) const
305{
306//
307// Number of sigma to the vertex (adapted from AliESDtrackCuts.cxx)
308//
309 //Double_t b[2];
310 Double_t bRes[2];
311 //Double_t bCov[3];
312
313 //if(!this->GetImpactParameters(trk, b, b, bCov)) return 1.e+6;
314
315 if (bCov[0]<=0 || bCov[2]<=0) {
316 AliDebugClass(1, "Estimated b resolution lower or equal zero!");
317 bCov[0]=0; bCov[2]=0;
318 }
319 bRes[0] = TMath::Sqrt(bCov[0]);
320 bRes[1] = TMath::Sqrt(bCov[2]);
321
322 // -----------------------------------
323 // How to get to a n-sigma cut?
324 //
325 // The accumulated statistics from 0 to d is
326 //
327 // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
328 // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
329 //
330 // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-d**2)/2)
331 // Can this be expressed in a different way?
332
333 if (bRes[0] == 0 || bRes[1] ==0)
334 return -1;
335
336 Double_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
337
338 // work around precision problem
339 // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
340 // 1e-15 corresponds to nsigma ~ 7.7
341 if (TMath::Exp(-d * d / 2) < 1e-15)
342 return 1000;
343
344 Double_t nSigma = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
345 return nSigma;
346}