a1963aee9ae040403ce10ff841e7bf4f212714ad
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / Nuclei / B2 / macros / TrackCuts.C
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 // macro for a predefined set of track cuts
17 // author: Eulogio Serradilla <eulogio.serradilla@cern.ch>
18
19 void AddNSigmaCuts(AliESDtrackCuts* trkCuts, Float_t maxNSigma=3)
20 {
21 //
22 // nsigma cuts
23 //
24         trkCuts->SetRequireSigmaToVertex(kTRUE);
25         trkCuts->SetMaxNsigmaToVertex(maxNSigma);
26 }
27
28 void AddDCACuts(AliESDtrackCuts* trkCuts, Float_t maxDCAxy=1.5, Float_t maxDCAz=2)
29 {
30 //
31 // DCA cuts
32 //
33         trkCuts->SetMaxDCAToVertexXY(maxDCAxy);
34         trkCuts->SetMaxDCAToVertexZ(maxDCAz);
35 }
36
37 AliESDtrackCuts* TrackCuts(AliAnalysisTaskB2* task, const TString& trksel, Double_t maxDCAxy, Double_t maxDCAz, Double_t maxNSigma, Bool_t xrows, Int_t minTPCnClsOrXRows, Double_t maxEta)
38 {
39 //
40 // Create an AliESDtrackCuts from a predefined set
41 //
42         AliESDtrackCuts* trkCuts = new AliESDtrackCuts("AliESDtrackCuts");
43         
44         trkCuts->SetEtaRange(-maxEta, maxEta);
45         trkCuts->SetPtRange(0.15, 100.);
46         trkCuts->SetAcceptKinkDaughters(kFALSE);
47         
48         // ITS
49         trkCuts->SetRequireITSRefit(kTRUE);
50         trkCuts->SetMinNClustersITS(2);
51         trkCuts->SetMaxChi2PerClusterITS(36);
52         
53         // TPC
54         trkCuts->SetRequireTPCRefit(kTRUE);
55         if(xrows)
56         {
57                 trkCuts->SetMinNCrossedRowsTPC(minTPCnClsOrXRows);
58                 trkCuts->SetMinRatioCrossedRowsOverFindableClustersTPC(0.8);
59         }
60         else
61         {
62                 trkCuts->SetMinNClustersTPC(minTPCnClsOrXRows);
63         }
64         trkCuts->SetMaxChi2PerClusterTPC(4.);
65         //trkCuts->SetMaxChi2TPCConstrainedGlobal(36);
66         
67         TString tracksel = trksel;
68         tracksel.ToLower();
69         
70         Int_t clusterCut = (xrows) ? 1 : 0;
71         
72         if(tracksel == "its_tpc_nsigma")
73         {
74                 AddNSigmaCuts(trkCuts, maxNSigma);
75         }
76         else if(tracksel == "its_tpc_nsigma_spd1")
77         {
78                 AddNSigmaCuts(trkCuts, maxNSigma);
79                 trkCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kFirst);
80         }
81         else if(tracksel == "its_tpc_nsigma_spd")
82         {
83                 AddNSigmaCuts(trkCuts, maxNSigma);
84                 trkCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
85         }
86         else if(tracksel == "its_tpc_dca")
87         {
88                 AddDCACuts(trkCuts,maxDCAxy,maxDCAz);
89         }
90         else if(tracksel == "its_tpc_dca_spd1")
91         {
92                 AddDCACuts(trkCuts,maxDCAxy,maxDCAz);
93                 trkCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kFirst);
94         }
95         else if(tracksel == "its_tpc_dca_spd")
96         {
97                 AddDCACuts(trkCuts,maxDCAxy,maxDCAz);
98                 trkCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
99         }
100         else if(tracksel == "its_tpc_tof_nsigma")
101         {
102                 AddNSigmaCuts(trkCuts, maxNSigma);
103                 task->SetTOFmatch(1);
104         }
105         else if(tracksel == "its_tpc_tof_nsigma_spd1")
106         {
107                 AddNSigmaCuts(trkCuts, maxNSigma);
108                 task->SetTOFmatch(1);
109                 trkCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kFirst);
110         }
111         else if(tracksel == "its_tpc_tof_nsigma_spd")
112         {
113                 AddNSigmaCuts(trkCuts, maxNSigma);
114                 task->SetTOFmatch(1);
115                 trkCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
116         }
117         else if(tracksel == "its_tpc_tof_dca")
118         {
119                 AddDCACuts(trkCuts,maxDCAxy,maxDCAz);
120                 task->SetTOFmatch(1);
121         }
122         else if(tracksel == "its_tpc_tof_dca_spd1")
123         {
124                 AddDCACuts(trkCuts,maxDCAxy,maxDCAz);
125                 task->SetTOFmatch(1);
126                 trkCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kFirst);
127         }
128         else if(tracksel == "its_tpc_tof_dca_spd")
129         {
130                 AddDCACuts(trkCuts,maxDCAxy,maxDCAz);
131                 task->SetTOFmatch(1);
132                 trkCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
133         }
134         else if(tracksel == "std_its_tpc_2009") // pp data 2009
135         {
136                 delete trkCuts;
137                 return AliESDtrackCuts::GetStandardITSTPCTrackCuts2009(1, clusterCut);
138         }
139         else if(tracksel == "std_its_tpc_2010") // pp data 2010
140         {
141                 delete trkCuts;
142                 return AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(1, clusterCut);
143         }
144         else if(tracksel == "std_its_tpc_2011") // pp data 2011
145         {
146                 delete trkCuts;
147                 return AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(1, clusterCut);
148         }
149         else
150         {
151                 std::cerr << "Warning: no track selection criteria selected" << std::endl;
152         }
153         
154         return trkCuts;
155 }