]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/RESONANCES/AliRsnCutV0.cxx
Added cut set for kstar analysis (fbellini)
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnCutV0.cxx
1 //
2 // Class AliRsnCutV0
3 //
4 // General implementation of a single cut strategy, which can be:
5 // - a value contained in a given interval  [--> IsBetween()   ]
6 // - a value equal to a given reference     [--> MatchesValue()]
7 //
8 // In all cases, the reference value(s) is (are) given as data members
9 // and each kind of cut requires a given value type (Int, UInt, Double),
10 // but the cut check procedure is then automatized and chosen thanks to
11 // an enumeration of the implemented cut types.
12 // At the end, the user (or any other point which uses this object) has
13 // to use the method IsSelected() to check if this cut has been passed.
14 //
15 // authors: Martin Vala (martin.vala@cern.ch)
16 //          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
17 //
18
19 #include <Riostream.h>
20 #include <TFormula.h>
21 #include <TBits.h>
22
23 #include "AliLog.h"
24 #include "AliESDtrackCuts.h"
25
26 #include "AliRsnEvent.h"
27 #include "AliRsnDaughter.h"
28 #include "AliRsnCutV0.h"
29
30 ClassImp(AliRsnCutV0)
31
32 //_________________________________________________________________________________________________
33 //AliRsnCutV0::AliRsnCutV0(const char *name, Int_t hypothesis) :
34 AliRsnCutV0::AliRsnCutV0(const char *name, Int_t hypothesis, AliPID::EParticleType pid, AliPID::EParticleType pid2) :
35    AliRsnCut(name, AliRsnTarget::kDaughter),
36    fHypothesis(0),
37    fMass(0.0),
38    fTolerance(0.01),
39    fMaxDCAVertex(0.3),
40    fMinCosPointAngle(0.95),
41    fMaxDaughtersDCA(0.5),
42    fMaxRapidity(0.8),
43    fPID(pid),
44    fPID2(pid2),
45    fPIDCut1(4.0),
46    fPIDCut2(3.0),
47    fPIDCut3(3.0),
48    fESDtrackCuts(0x0)
49 {
50 //
51 // Default constructor.
52 // Initializes all cuts in such a way that all of them are disabled.
53 //
54
55    SetHypothesis(hypothesis);
56 }
57
58 //_________________________________________________________________________________________________
59 AliRsnCutV0::AliRsnCutV0(const AliRsnCutV0 &copy) :
60    AliRsnCut(copy),
61    fHypothesis(copy.fHypothesis),
62    fMass(copy.fMass),
63    fTolerance(copy.fTolerance),
64    fMaxDCAVertex(copy.fMaxDCAVertex),
65    fMinCosPointAngle(copy.fMinCosPointAngle),
66    fMaxDaughtersDCA(copy.fMaxDaughtersDCA),
67    fMaxRapidity(copy.fMaxRapidity),
68    fPID(copy.fPID),
69    fPID2(copy.fPID2),
70    fPIDCut1(copy.fPIDCut1),
71    fPIDCut2(copy.fPIDCut2),
72    fPIDCut3(copy.fPIDCut3),
73    fESDtrackCuts(copy.fESDtrackCuts)
74 {
75 //
76 // Copy constructor.
77 // Just copy all data member values.
78 //
79 }
80
81 //_________________________________________________________________________________________________
82 AliRsnCutV0 &AliRsnCutV0::operator=(const AliRsnCutV0 &copy)
83 {
84 //
85 // Assignment operator.
86 // Just copy all data member values.
87 //
88
89    if (this == &copy)
90       return *this;
91    fHypothesis = copy.fHypothesis;
92    fMass = copy.fMass;
93    fTolerance = copy.fTolerance;
94    fMaxDCAVertex = copy.fMaxDCAVertex;
95    fMinCosPointAngle = copy.fMinCosPointAngle;
96    fMaxDaughtersDCA = copy.fMaxDaughtersDCA;
97    fMaxRapidity = copy.fMaxRapidity;
98    fPID = copy.fPID;
99    fPID2 = copy.fPID2;
100    fPIDCut1 = copy.fPIDCut1;
101    fPIDCut2 = copy.fPIDCut2;
102    fPIDCut3 = copy.fPIDCut3;
103    fESDtrackCuts = copy.fESDtrackCuts;
104
105    return (*this);
106 }
107
108 //_________________________________________________________________________________________________
109 Bool_t AliRsnCutV0::IsSelected(TObject *object)
110 {
111 //
112 // Cut checker.
113 // Checks the type of object being evaluated
114 // and then calls the appropriate sub-function (for ESD or AOD)
115 //
116
117    // coherence check
118    if (!TargetOK(object)) return kFALSE;
119
120    // check cast
121    AliESDv0 *v0esd = fDaughter->Ref2ESDv0();
122    AliAODv0 *v0aod = fDaughter->Ref2AODv0();
123    //cout << fDaughter->GetRef()->ClassName() << ' ' << v0esd << ' ' << v0aod << endl;
124
125    // operate depending on cast
126    if (v0esd) {
127       return CheckESD(v0esd);
128    } else if (v0aod) {
129       return CheckAOD(v0aod);
130    } else {
131       AliDebugClass(1, "Object is not a V0");
132       return kFALSE;
133    }
134 }
135
136 //_________________________________________________________________________________________________
137 Bool_t AliRsnCutV0::CheckESD(AliESDv0 *v0)
138 {
139 //
140 // Check an ESD V0.
141 // This is done using the default track checker for ESD.
142 // It is declared static, not to recreate it every time.
143 //
144
145    AliDebugClass(1, "Check ESD");
146    if (v0->GetOnFlyStatus()) {
147       AliDebugClass(1, "Rejecting V0 in 'on fly' status");
148       return kFALSE; // if kTRUE, then this V0 is recontructed
149    }
150
151    // retrieve pointer to owner event
152    AliESDEvent *lESDEvent = fEvent->GetRefESD();
153    Double_t xPrimaryVertex = lESDEvent->GetPrimaryVertex()->GetX();
154    Double_t yPrimaryVertex = lESDEvent->GetPrimaryVertex()->GetY();
155    Double_t zPrimaryVertex = lESDEvent->GetPrimaryVertex()->GetZ();
156    AliDebugClass(2, Form("Primary vertex: %f %f %f", xPrimaryVertex, yPrimaryVertex, zPrimaryVertex));
157
158    // retrieve the V0 daughters
159    UInt_t lIdxPos      = (UInt_t) TMath::Abs(v0->GetPindex());
160    UInt_t lIdxNeg      = (UInt_t) TMath::Abs(v0->GetNindex());
161    AliESDtrack *pTrack = lESDEvent->GetTrack(lIdxPos);
162    AliESDtrack *nTrack = lESDEvent->GetTrack(lIdxNeg);
163
164    // check quality cuts
165    if (fESDtrackCuts) {
166       AliDebugClass(2, "Checking quality cuts");
167       if (!fESDtrackCuts->IsSelected(pTrack)) {
168          AliDebugClass(2, "Positive daughter failed quality cuts");
169          return kFALSE;
170       }
171       if (!fESDtrackCuts->IsSelected(nTrack)) {
172          AliDebugClass(2, "Negative daughter failed quality cuts");
173          return kFALSE;
174       }
175    }
176
177    // filter like-sign V0
178    if ( TMath::Abs( ((pTrack->GetSign()) - (nTrack->GetSign())) ) < 0.1) {
179       AliDebugClass(2, "Failed like-sign V0 check");
180       return kFALSE;
181    }
182
183
184    // check compatibility with expected species hypothesis
185    v0->ChangeMassHypothesis(fHypothesis);
186    if ((TMath::Abs(v0->GetEffMass() - fMass)) > fTolerance) {
187       AliDebugClass(2, "V0 is not in the expected inv mass range");
188       return kFALSE;
189    }
190
191    // topological checks
192    if (TMath::Abs(v0->GetD(xPrimaryVertex, yPrimaryVertex, zPrimaryVertex)) > fMaxDCAVertex) {
193       AliDebugClass(2, "Failed check on DCA to primary vertes");
194       return kFALSE;
195    }
196    if (TMath::Abs(v0->GetV0CosineOfPointingAngle()) < fMinCosPointAngle) {
197       AliDebugClass(2, "Failed check on cosine of pointing angle");
198       return kFALSE;
199    }
200    if (TMath::Abs(v0->GetDcaV0Daughters()) > fMaxDaughtersDCA) {
201       AliDebugClass(2, "Failed check on DCA between daughters");
202       return kFALSE;
203    }
204    if (TMath::Abs(v0->Y(fHypothesis)) > fMaxRapidity) {
205       AliDebugClass(2, "Failed check on V0 rapidity");
206       return kFALSE;
207    }
208
209
210    // check PID on proton or antiproton from V0
211
212    // check initialization of PID object
213    AliPIDResponse *pid = fEvent->GetPIDResponse();
214    if (!pid) {
215       AliFatal("NULL PID response");
216       return kFALSE;
217    }
218
219    // check if TOF is matched
220    // and computes all values used in the PID cut
221    //Bool_t   isTOFpos  = MatchTOF(ptrack);
222    //Bool_t   isTOFneg  = MatchTOF(ntrack);
223    Double_t pospTPC   = pTrack->GetTPCmomentum();
224    Double_t negpTPC   = nTrack->GetTPCmomentum();
225    //Double_t posp      = pTrack->P();
226    //Double_t negp      = nTrack->P();
227    Double_t posnsTPC   = TMath::Abs(pid->NumberOfSigmasTPC(pTrack, fPID));
228    Double_t posnsTPC2  = TMath::Abs(pid->NumberOfSigmasTPC(pTrack, fPID2));
229    //Double_t posnsTOF  = TMath::Abs(pid->NumberOfSigmasTOF(ptrack, fPID));
230    Double_t negnsTPC   = TMath::Abs(pid->NumberOfSigmasTPC(nTrack, fPID));
231    Double_t negnsTPC2  = TMath::Abs(pid->NumberOfSigmasTPC(nTrack, fPID2));
232    //Double_t negnsTOF  = TMath::Abs(pid->NumberOfSigmasTOF(ntrack, fPID));
233    Double_t maxTPC = 1E20;
234    Double_t maxTPC2 = 1E20;
235    //Double_t maxTOF = 1E20;
236
237    // applies the cut differently depending on the PID and the momentum
238
239    if(fHypothesis==kLambda0) {
240       //if (isTOFpos) {
241       // TPC: 5sigma cut for all
242       //if (posnsTPC > 5.0) return kFALSE;
243       // TOF: 3sigma
244       // maxTOF = 3.0;
245       //return (posnsTOF <= maxTOF);
246       //} else {
247       // TPC:
248       // below 600 MeV: 4sigma
249       // above 600 MeV: 3sigma
250
251       if (pospTPC <= 0.6 && fPID==AliPID::kProton)
252          //maxTPC = 4.0;
253          maxTPC = fPIDCut1;
254       else if (pospTPC > 0.6 && fPID==AliPID::kProton)
255          //maxTPC = 3.0;
256          maxTPC = fPIDCut2;
257       //else
258       //return kFALSE;
259
260       //maxTPC2 = 3.0;
261       maxTPC2 = fPIDCut3;
262
263       if (! ((posnsTPC <= maxTPC) && (negnsTPC2 <= maxTPC2)) ) {
264          AliDebugClass(2, "Failed check on V0 PID");
265          return kFALSE;
266       }
267    }
268
269    //}
270
271    if(fHypothesis==kLambda0Bar) {
272       //if (isTOFneg) {
273       // TPC: 5sigma cut for all
274       //if (negnsTPC > 5.0) return kFALSE;
275       // TOF: 3sigma
276       // maxTOF = 3.0;
277       //return (negnsTOF <= maxTOF);
278       //} else {
279       // TPC:
280       // below 600 MeV: 4sigma
281       // above 600 MeV: 3sigma
282
283       if (negpTPC <= 0.6 && fPID==AliPID::kProton)
284          //maxTPC = 4.0;
285          maxTPC = fPIDCut1;
286       else if (negpTPC > 0.6 && fPID==AliPID::kProton)
287          //maxTPC = 3.0;
288          maxTPC = fPIDCut2;
289       else
290          return kFALSE;
291
292       //maxTPC2 = 3.0;
293       maxTPC2 = fPIDCut3;
294
295       if(! ((negnsTPC <= maxTPC) && (posnsTPC2 <= maxTPC2)) ) {
296          AliDebugClass(2, "Failed check on V0 PID");
297          return kFALSE;
298       }
299    }
300    //}
301
302
303    // if we reach this point, all checks were successful
304    AliDebugClass(2, "Good V0 (hallelujah)");
305    return kTRUE;
306 }
307
308 //_________________________________________________________________________________________________
309 Bool_t AliRsnCutV0::CheckAOD(AliAODv0 *)
310 {
311 //
312 // Check an AOD V0.
313 // This is done doing directly all checks, since there is not
314 // an equivalend checker for AOD tracks
315 //
316
317    AliWarning("Cuts is not yet implemented for AOD");
318
319    return kTRUE;
320 }
321
322 //_________________________________________________________________________________________________
323 void AliRsnCutV0::Print(const Option_t *) const
324 {
325 //
326 // Print information on this cut
327 //
328 }