]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/RESONANCES/AliRsnCutKaonForPhi2010.cxx
Updated treatment of TOF PID in QA task (Francesco+Pietro)
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnCutKaonForPhi2010.cxx
1 //
2 // This cut implements all the checks done to accept a track as a Kaon
3 // for the PbPb analysis using 2010 runs.
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.
6 //
7
8 #include <Riostream.h>
9
10 #include "AliLog.h"
11 #include "AliPID.h"
12 #include "AliPIDResponse.h"
13 #include "AliESDpid.h"
14 #include "AliAODpidUtil.h"
15 #include "AliRsnCutKaonForPhi2010.h"
16
17 ClassImp(AliRsnCutKaonForPhi2010)
18
19 //__________________________________________________________________________________________________
20 AliRsnCutKaonForPhi2010::AliRsnCutKaonForPhi2010
21 (const char *name, Double_t nSigmaTPC, Double_t nSigmaTOF, Double_t tofLimit) :
22    AliRsnCut(name, AliRsnTarget::kDaughter),
23    fMode(kDefaultPID),
24    fCutTPC(nSigmaTPC),
25    fCutTOF(nSigmaTOF),
26    fTOFthreshold(tofLimit),
27    fMyPID(0x0),
28    fCutQuality(Form("%s_quality", name))
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 //__________________________________________________________________________________________________
53 AliRsnCutKaonForPhi2010::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 //__________________________________________________________________________________________________
68 AliRsnCutKaonForPhi2010 &AliRsnCutKaonForPhi2010::operator=(const AliRsnCutKaonForPhi2010 &copy)
69 {
70 //
71 // Assignment operator
72 //
73
74    AliRsnCut::operator=(copy);
75    if (this == &copy)
76       return *this;
77    fMode = copy.fMode;
78    fCutTPC = copy.fCutTPC;
79    fCutTOF = copy.fCutTOF;
80    fTOFthreshold = copy.fTOFthreshold;
81    fMyPID = copy.fMyPID;
82    fCutQuality = copy.fCutQuality;
83
84    return *this;
85 }
86
87 //__________________________________________________________________________________________________
88 void AliRsnCutKaonForPhi2010::InitMyPID(Bool_t isMC, Bool_t isESD)
89 {
90 //
91 // Initialize manual PID object
92 //
93
94    if (isESD)
95       fMyPID = new AliESDpid(isMC);
96    else
97       fMyPID = new AliAODpidUtil(isMC);
98 }
99
100 //__________________________________________________________________________________________________
101 Bool_t AliRsnCutKaonForPhi2010::IsSelected(TObject *obj)
102 {
103 //
104 // Global check
105 //
106
107    // coherence check
108    if (!TargetOK(obj)) return kFALSE;
109
110    // check track
111    AliVTrack *track = fDaughter->Ref2Vtrack();
112    if (!track) {
113       if (!fDaughter->GetRef()) AliWarning("NULL ref");
114       return kFALSE;
115    }
116
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;
121
122    // check quality and reject always bad quality tracks
123    if (!fCutQuality.IsSelected(obj)) {
124       AliDebugClass(1, Form("[%s] Track quality is bad", GetName()));
125       return kFALSE;
126    }
127
128    // initialize check variables
129    Bool_t   accept = kFALSE;
130    Bool_t   isTOF  = MatchTOF(track);
131    Double_t nsTPC  = 1E20;
132    Double_t nsTOF  = 1E20;
133
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;
140       }
141       // TPC PID
142       if (fMyPID)
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    }
149
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));
168          if (isTOF) {
169             accept = (nsTOF <= fCutTOF);
170          } else {
171             AliDebugClass(1, Form("[%s] TOF not matched", GetName()));
172             accept = kFALSE;
173          }
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()));
185             accept = kFALSE;
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             }
198          }
199          break;
200       default:
201          AliDebugClass(1, Form("[%s] Wrong mode", GetName()));
202          accept = kFALSE;
203    }
204
205    AliDebugClass(1, Form("[%s] Track %s", GetName(), (accept ? "accepted" : "rejected")));
206    return accept;
207 }