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