Modified macros for phi analysis: improved pseudorapidity cut flexibility (A.Knospe)
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnCutKaonForPhi2010.cxx
CommitLineData
2895972e 1//
4e4fb2f6 2// This cut implements all the checks done to accept a track as a Kaon
61f275d1 3// for the PbPb analysis using 2010 runs.
4e4fb2f6 4// It is based on standard cuts on track quality and nsigma cuts
5// with respect to the TPC and TOF signals for the PID.
2895972e 6//
7
8#include <Riostream.h>
9
739706ae 10#include "AliLog.h"
2895972e 11#include "AliPID.h"
12#include "AliPIDResponse.h"
739706ae 13#include "AliESDpid.h"
14#include "AliAODpidUtil.h"
2895972e 15#include "AliRsnCutKaonForPhi2010.h"
16
17ClassImp(AliRsnCutKaonForPhi2010)
18
19//__________________________________________________________________________________________________
0efb7042 20AliRsnCutKaonForPhi2010::AliRsnCutKaonForPhi2010
21(const char *name, Double_t nSigmaTPC, Double_t nSigmaTOF, Double_t tofLimit) :
22 AliRsnCut(name, AliRsnTarget::kDaughter),
739706ae 23 fMode(kDefaultPID),
0efb7042 24 fCutTPC(nSigmaTPC),
25 fCutTOF(nSigmaTOF),
26 fTOFthreshold(tofLimit),
739706ae 27 fMyPID(0x0),
4e4fb2f6 28 fCutQuality(Form("%s_quality", name))
2895972e 29{
30//
31// Constructor
32// Initialize the contained cuts and sets defaults
33//
34
35 // track quality
36 //fCutQuality.AddStatusFlag(AliESDtrack::kTPCin , kTRUE);
37 //fCutQuality.AddStatusFlag(AliESDtrack::kTPCrefit, kTRUE);
38 //fCutQuality.AddStatusFlag(AliESDtrack::kITSrefit, kTRUE);
39 fCutQuality.SetPtRange(0.15, 1E+20);
40 fCutQuality.SetEtaRange(-0.8, 0.8);
41 fCutQuality.SetDCARPtFormula("0.0182+0.0350/pt^1.01");
42 fCutQuality.SetDCAZmax(2.0);
43 fCutQuality.SetSPDminNClusters(1);
44 fCutQuality.SetITSminNClusters(0);
45 fCutQuality.SetITSmaxChi2(1E+20);
46 fCutQuality.SetTPCminNClusters(70);
47 fCutQuality.SetTPCmaxChi2(4.0);
48 fCutQuality.SetRejectKinkDaughters();
49 fCutQuality.SetAODTestFilterBit(5);
50}
51
52//__________________________________________________________________________________________________
739706ae 53AliRsnCutKaonForPhi2010::AliRsnCutKaonForPhi2010(const AliRsnCutKaonForPhi2010 &copy) :
54 AliRsnCut(copy),
55 fMode(copy.fMode),
56 fCutTPC(copy.fCutTPC),
57 fCutTOF(copy.fCutTOF),
58 fTOFthreshold(copy.fTOFthreshold),
59 fMyPID(copy.fMyPID),
60 fCutQuality(copy.fCutQuality)
61{
62//
63// Copy constructor
64//
65}
66
67//__________________________________________________________________________________________________
61f275d1 68AliRsnCutKaonForPhi2010 &AliRsnCutKaonForPhi2010::operator=(const AliRsnCutKaonForPhi2010 &copy)
739706ae 69{
70//
71// Assignment operator
72//
73
74 AliRsnCut::operator=(copy);
e6f3a909 75 if (this == &copy)
61f275d1 76 return *this;
739706ae 77 fMode = copy.fMode;
78 fCutTPC = copy.fCutTPC;
79 fCutTOF = copy.fCutTOF;
80 fTOFthreshold = copy.fTOFthreshold;
81 fMyPID = copy.fMyPID;
82 fCutQuality = copy.fCutQuality;
61f275d1 83
739706ae 84 return *this;
85}
86
87//__________________________________________________________________________________________________
88void AliRsnCutKaonForPhi2010::InitMyPID(Bool_t isMC, Bool_t isESD)
89{
90//
91// Initialize manual PID object
92//
93
61f275d1 94 if (isESD)
739706ae 95 fMyPID = new AliESDpid(isMC);
96 else
97 fMyPID = new AliAODpidUtil(isMC);
98}
99
100//__________________________________________________________________________________________________
2895972e 101Bool_t AliRsnCutKaonForPhi2010::IsSelected(TObject *obj)
102{
103//
104// Global check
105//
106
107 // coherence check
108 if (!TargetOK(obj)) return kFALSE;
61f275d1 109
2895972e 110 // check track
111 AliVTrack *track = fDaughter->Ref2Vtrack();
112 if (!track) {
113 if (!fDaughter->GetRef()) AliWarning("NULL ref");
114 return kFALSE;
115 }
61f275d1 116
2895972e 117 // check flags
118 if ((track->GetStatus() & AliESDtrack::kTPCin ) == 0) return kFALSE;
119 if ((track->GetStatus() & AliESDtrack::kTPCrefit) == 0) return kFALSE;
120 if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) return kFALSE;
61f275d1 121
739706ae 122 // check quality and reject always bad quality tracks
123 if (!fCutQuality.IsSelected(obj)) {
124 AliDebugClass(1, Form("[%s] Track quality is bad", GetName()));
2895972e 125 return kFALSE;
126 }
61f275d1 127
739706ae 128 // initialize check variables
7196ee4f 129 Bool_t accept = kFALSE;
3dced4f8 130 Bool_t isTOF = MatchTOF(track);
739706ae 131 Double_t nsTPC = 1E20;
132 Double_t nsTOF = 1E20;
61f275d1 133
739706ae 134 // if PID is required, compute it check initialization of PID object
135 if (fMode >= kOnlyTPC && fMode <= kDefaultPID) {
136 AliPIDResponse *pid = fEvent->GetPIDResponse();
137 if (!pid) {
138 AliFatal("NULL PID response");
139 return kFALSE;
7196ee4f 140 }
739706ae 141 // TPC PID
61f275d1 142 if (fMyPID)
739706ae 143 nsTPC = TMath::Abs(fMyPID->NumberOfSigmasTPC(track, AliPID::kKaon));
144 else
145 nsTPC = TMath::Abs(pid->NumberOfSigmasTPC(track, AliPID::kKaon));
146 // TOF PID
147 nsTOF = TMath::Abs(pid->NumberOfSigmasTOF(track, AliPID::kKaon));
148 }
61f275d1 149
739706ae 150 // decide cut result depending on mode
151 switch (fMode) {
152 case kQuality:
153 // in this case, since bad quality tracks are rejected above,
154 // all tracks arrived here can be accepted
155 AliDebugClass(1, Form("[%s] Required only track quality", GetName()));
156 accept = kTRUE;
157 break;
158 case kOnlyTPC:
159 // in this case, only TPC PID is checked
160 // all tracks have one, so nothing additional is checked
161 AliDebugClass(1, Form("[%s] Checking only TPC: nsigma = %f - cut = %f", GetName(), nsTPC, fCutTPC));
162 accept = (nsTPC <= fCutTPC);
163 break;
164 case kOnlyTOF:
165 // in this case, only TOF PID is checked
166 // additional check: we want that TOF is matched
167 AliDebugClass(1, Form("[%s] Checking only TOF: nsigma = %f - cut = %f", GetName(), nsTOF, fCutTOF));
7196ee4f 168 if (isTOF) {
739706ae 169 accept = (nsTOF <= fCutTOF);
7196ee4f 170 } else {
739706ae 171 AliDebugClass(1, Form("[%s] TOF not matched", GetName()));
172 accept = kFALSE;
7196ee4f 173 }
739706ae 174 break;
175 case kDefaultPID:
176 // in this case, default PID check is done
177 // TPC PID is checked and tracks are rejected if it is not passed
178 // if their momentum is below the TOF threshold, they are required
179 // to be matched in TOF, otherwise TPC only is OK
180 AliDebugClass(1, Form("[%s] Default PID TPC: nsigma = %f - cut = %f", GetName(), nsTPC, fCutTPC));
181 AliDebugClass(1, Form("[%s] Default PID TOF: nsigma = %f - cut = %f", GetName(), nsTOF, fCutTOF));
182 // step 0: check TPC
183 if (nsTPC > fCutTPC) {
184 AliDebugClass(1, Form("[%s] TPC PID cut not passed", GetName()));
7196ee4f 185 accept = kFALSE;
739706ae 186 } else {
187 if (isTOF) {
188 accept = (nsTOF <= fCutTOF);
189 } else {
190 if (track->P() >= fTOFthreshold) {
191 AliDebugClass(1, Form("[%s] p = %f above threshold: TOF is required but missing", GetName(), track->P()));
192 accept = kFALSE;
193 } else {
194 AliDebugClass(1, Form("[%s] p = %f below threshold: TOF is not required", GetName(), track->P()));
195 accept = kTRUE;
196 }
197 }
7196ee4f 198 }
739706ae 199 break;
200 default:
201 AliDebugClass(1, Form("[%s] Wrong mode", GetName()));
202 accept = kFALSE;
2895972e 203 }
61f275d1 204
739706ae 205 AliDebugClass(1, Form("[%s] Track %s", GetName(), (accept ? "accepted" : "rejected")));
7196ee4f 206 return accept;
2895972e 207}