]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/vertexingHF/AliRDHFCutsLctopKpi.cxx
Warnings corrected.
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliRDHFCutsLctopKpi.cxx
CommitLineData
e3d40058 1/**************************************************************************
2 * Copyright(c) 1998-2010, 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/////////////////////////////////////////////////////////////
17//
18// Class for cuts on AOD reconstructed Lc->pKpi
19//
20// Author: A.Dainese, andrea.dainese@pd.infn.it
21/////////////////////////////////////////////////////////////
22
23#include <TDatabasePDG.h>
24#include <Riostream.h>
25
26#include "AliRDHFCutsLctopKpi.h"
27#include "AliAODRecoDecayHF3Prong.h"
7ad4b782 28#include "AliRDHFCuts.h"
e3d40058 29#include "AliAODTrack.h"
30#include "AliESDtrack.h"
7ad4b782 31#include "AliKFParticle.h"
32#include "AliESDVertex.h"
e3d40058 33
34ClassImp(AliRDHFCutsLctopKpi)
35
36//--------------------------------------------------------------------------
a9b75906 37AliRDHFCutsLctopKpi::AliRDHFCutsLctopKpi(const char* name) :
7ad4b782 38AliRDHFCuts(name),
39fPidObjprot(0),
40fPidObjpion(0),
41fRecoKF(kFALSE)
e3d40058 42{
43 //
44 // Default Constructor
45 //
46 Int_t nvars=12;
47 SetNVars(nvars);
48 TString varNames[12]={"inv. mass [GeV]",
49 "pTP [GeV/c]",
50 "pTPi [GeV/c]",
51 "d0P [cm] lower limit!",
52 "d0Pi [cm] lower limit!",
53 "dist12 (cm)",
54 "sigmavert (cm)",
55 "dist prim-sec (cm)",
56 "pM=Max{pT1,pT2,pT3} (GeV/c)",
57 "cosThetaPoint",
58 "Sum d0^2 (cm^2)",
59 "dca cut (cm)"};
60 Bool_t isUpperCut[12]={kTRUE,
61 kFALSE,
62 kFALSE,
63 kFALSE,
64 kFALSE,
65 kFALSE,
66 kTRUE,
67 kFALSE,
68 kFALSE,
69 kFALSE,
70 kFALSE,
71 kTRUE};
72 SetVarNames(nvars,varNames,isUpperCut);
4755453e 73 Bool_t forOpt[12]={kFALSE,
e3d40058 74 kFALSE,
75 kFALSE,
76 kFALSE,
77 kFALSE,
78 kFALSE,
79 kTRUE,
80 kTRUE,
81 kTRUE,
82 kTRUE,
83 kTRUE,
84 kFALSE};
4755453e 85 SetVarsForOpt(5,forOpt);
e3d40058 86 Float_t limits[2]={0,999999999.};
87 SetPtBins(2,limits);
88}
89//--------------------------------------------------------------------------
90AliRDHFCutsLctopKpi::AliRDHFCutsLctopKpi(const AliRDHFCutsLctopKpi &source) :
7ad4b782 91 AliRDHFCuts(source),
92 fPidObjprot(0),
93 fPidObjpion(0),
94 fRecoKF(kFALSE)
e3d40058 95{
96 //
97 // Copy constructor
98 //
7ad4b782 99 if(source.fPidObjprot) SetPidprot(source.fPidObjprot);
100 if(source.fPidObjpion) SetPidpion(source.fPidObjpion);
e3d40058 101}
102//--------------------------------------------------------------------------
103AliRDHFCutsLctopKpi &AliRDHFCutsLctopKpi::operator=(const AliRDHFCutsLctopKpi &source)
104{
105 //
106 // assignment operator
107 //
108 if(&source == this) return *this;
109
110 AliRDHFCuts::operator=(source);
7ad4b782 111 SetPidprot(source.GetPidprot());
112 SetPidpion(source.GetPidpion());
e3d40058 113
114 return *this;
115}
7ad4b782 116//---------------------------------------------------------------------------
117AliRDHFCutsLctopKpi::~AliRDHFCutsLctopKpi() {
118 //
119 // // Default Destructor
120 //
121 if(fPidObjpion){
122 delete fPidObjpion;
123 fPidObjpion=0;
124 }
125 if(fPidObjprot){
126 delete fPidObjprot;
127 fPidObjprot=0;
128 }
e3d40058 129
7ad4b782 130}
e3d40058 131
132//---------------------------------------------------------------------------
133void AliRDHFCutsLctopKpi::GetCutVarsForOpt(AliAODRecoDecayHF *d,Float_t *vars,Int_t nvars,Int_t *pdgdaughters) {
134 //
135 // Fills in vars the values of the variables
136 //
137
138 if(nvars!=fnVarsForOpt) {
139 printf("AliRDHFCutsLctopKpi::GetCutsVarsForOpt: wrong number of variables\n");
140 return;
141 }
142
143 AliAODRecoDecayHF3Prong *dd = (AliAODRecoDecayHF3Prong*)d;
144
145 Int_t iter=-1;
146 if(fVarsForOpt[0]){
147 iter++;
148 vars[iter]=dd->InvMassLcpKpi();
149 }
150 if(fVarsForOpt[1]){
151 iter++;
152 for(Int_t iprong=0;iprong<3;iprong++){
153 if(TMath::Abs(pdgdaughters[iprong])==2212) {
154 vars[iter]=dd->PtProng(iprong);
155 }
156 }
157 }
158 if(fVarsForOpt[2]){
159 iter++;
160 for(Int_t iprong=0;iprong<3;iprong++){
161 if(TMath::Abs(pdgdaughters[iprong])==211) {
162 vars[iter]=dd->PtProng(iprong);
163 }
164 }
165 }
166 if(fVarsForOpt[3]){
167 iter++;
168 for(Int_t iprong=0;iprong<3;iprong++){
169 if(TMath::Abs(pdgdaughters[iprong])==2212) {
170 vars[iter]=dd->Getd0Prong(iprong);
171 }
172 }
173 }
174 if(fVarsForOpt[4]){
175 iter++;
176 for(Int_t iprong=0;iprong<3;iprong++){
177 if(TMath::Abs(pdgdaughters[iprong])==211) {
178 vars[iter]=dd->Getd0Prong(iprong);
179 }
180 }
181 }
182 if(fVarsForOpt[5]){
183 iter++;
184 vars[iter]=dd->GetDist12toPrim();
185 }
186 if(fVarsForOpt[6]){
187 iter++;
188 vars[iter]=dd->GetSigmaVert();
189 }
190 if(fVarsForOpt[7]){
191 iter++;
192 vars[iter] = dd->DecayLength();
193 }
194 if(fVarsForOpt[8]){
195 iter++;
196 Float_t ptmax=0;
197 for(Int_t i=0;i<3;i++){
198 if(dd->PtProng(i)>ptmax)ptmax=dd->PtProng(i);
199 }
200 vars[iter]=ptmax;
201 }
202 if(fVarsForOpt[9]){
203 iter++;
204 vars[iter]=dd->CosPointingAngle();
205 }
206 if(fVarsForOpt[10]){
207 iter++;
208 vars[iter]=dd->Getd0Prong(0)*dd->Getd0Prong(0)+dd->Getd0Prong(1)*dd->Getd0Prong(1)+dd->Getd0Prong(2)*dd->Getd0Prong(2);
209 }
210 if(fVarsForOpt[11]){
211 iter++;
212 vars[iter]=dd->GetDCA();
213 }
214
215 return;
216}
217//---------------------------------------------------------------------------
7ad4b782 218Int_t AliRDHFCutsLctopKpi::IsSelected(TObject* obj,Int_t selectionLevel,AliAODEvent *aod) {
e3d40058 219 //
220 // Apply selection
221 //
222
223 if(!fCutsRD){
224 cout<<"Cut matrice not inizialized. Exit..."<<endl;
225 return 0;
226 }
227 //PrintAll();
228 AliAODRecoDecayHF3Prong* d=(AliAODRecoDecayHF3Prong*)obj;
229
230 if(!d){
231 cout<<"AliAODRecoDecayHF3Prong null"<<endl;
232 return 0;
233 }
234
235
e3d40058 236
228974b3 237 Int_t returnvalue=3;
7ad4b782 238 Int_t returnvaluePID=3;
239
e3d40058 240
241 // selection on candidate
242 if(selectionLevel==AliRDHFCuts::kAll ||
243 selectionLevel==AliRDHFCuts::kCandidate) {
244
245 Double_t pt=d->Pt();
246
247 Int_t ptbin=PtBin(pt);
248
249 Double_t mLcpKpi,mLcpiKp;
250 Int_t okLcpKpi=1,okLcpiKp=1;
251
252 Double_t mLcPDG = TDatabasePDG::Instance()->GetParticle(4122)->Mass();
253
254 mLcpKpi=d->InvMassLcpKpi();
255 mLcpiKp=d->InvMassLcpiKp();
256
257 if(TMath::Abs(mLcpKpi-mLcPDG)>fCutsRD[GetGlobalIndex(0,ptbin)]) okLcpKpi = 0;
258 if(TMath::Abs(mLcpiKp-mLcPDG)>fCutsRD[GetGlobalIndex(0,ptbin)]) okLcpiKp = 0;
259 if(!okLcpKpi && !okLcpiKp) return 0;
260
261 if(TMath::Abs(d->PtProng(1)) < fCutsRD[GetGlobalIndex(1,ptbin)] || TMath::Abs(d->Getd0Prong(1))<fCutsRD[GetGlobalIndex(3,ptbin)]) return 0;//Kaon
228974b3 262 //if(TMath::Abs(d->PtProng(0)) < fCutsRD[GetGlobalIndex(2,ptbin)] || TMath::Abs(d->Getd0Prong(0))<fCutsRD[GetGlobalIndex(4,ptbin)]) return 0;//Proton
263 //if(TMath::Abs(d->PtProng(2)) < fCutsRD[GetGlobalIndex(2,ptbin)] || TMath::Abs(d->Getd0Prong(2))<fCutsRD[GetGlobalIndex(4,ptbin)]) return 0;//Pion
264 if((TMath::Abs(d->PtProng(0)) < fCutsRD[GetGlobalIndex(2,ptbin)]) || (TMath::Abs(d->PtProng(2)) < 0.4)) okLcpKpi=0;
7ad4b782 265 if((TMath::Abs(d->PtProng(2)) < fCutsRD[GetGlobalIndex(2,ptbin)]) || (TMath::Abs(d->PtProng(0)) < 0.4))okLcpiKp=0;
266 if(!okLcpKpi && !okLcpiKp) return 0;
e3d40058 267
268
7ad4b782 269 if(fRecoKF){
270 Int_t valueTmp=3;
271 if(okLcpKpi) returnvalue=1; //cuts passed as Lc->pKpi
272 if(okLcpiKp) returnvalue=2; //cuts passed as Lc->piKp
273 if(okLcpKpi && okLcpiKp) returnvalue=3; //cuts passed as both pKpi and piKp
274
275 Int_t valueTotTmp=CombinePIDCuts(valueTmp,returnvaluePID);
276 Int_t pdgs[3]={2212,321,211};
277 if(valueTotTmp>=2) {
278 pdgs[0]=211;
279 pdgs[2]=2212;
280 }
281 if(!d->GetOwnPrimaryVtx()){
282 AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
283 d->SetOwnPrimaryVtx(vtx1);
284 }
285 Double_t field=aod->GetMagneticField();
286 ReconstructKF(d,pdgs,field);
287 }
e3d40058 288 //2track cuts
289 if(d->GetDist12toPrim()<fCutsRD[GetGlobalIndex(5,ptbin)]|| d->GetDist23toPrim()<fCutsRD[GetGlobalIndex(5,ptbin)]) return 0;
228974b3 290 if(d->GetDist12toPrim()>1.) return 0;
291 if(d->GetDist23toPrim()>1.) return 0;
e3d40058 292 if(d->Getd0Prong(0)*d->Getd0Prong(1)<0. && d->Getd0Prong(2)*d->Getd0Prong(1)<0.) return 0;
293
294 //sec vert
295 if(d->GetSigmaVert()>fCutsRD[GetGlobalIndex(6,ptbin)]) return 0;
296
297 if(d->DecayLength()<fCutsRD[GetGlobalIndex(7,ptbin)]) return 0;
228974b3 298 if(d->DecayLength()>0.5) return 0;
e3d40058 299
300 if(TMath::Abs(d->PtProng(0))<fCutsRD[GetGlobalIndex(8,ptbin)] && TMath::Abs(d->PtProng(1))<fCutsRD[GetGlobalIndex(8,ptbin)] && TMath::Abs(d->PtProng(2))<fCutsRD[GetGlobalIndex(8,ptbin)]) return 0;
301 if(d->CosPointingAngle()< fCutsRD[GetGlobalIndex(9,ptbin)]) return 0;
302 Double_t sum2=d->Getd0Prong(0)*d->Getd0Prong(0)+d->Getd0Prong(1)*d->Getd0Prong(1)+d->Getd0Prong(2)*d->Getd0Prong(2);
303 if(sum2<fCutsRD[GetGlobalIndex(10,ptbin)]) return 0;
304
305 //DCA
306 for(Int_t i=0;i<3;i++) if(d->GetDCA(i)>fCutsRD[GetGlobalIndex(11,ptbin)]) return 0;
307
308
309 if(okLcpKpi) returnvalue=1; //cuts passed as Lc->pKpi
310 if(okLcpiKp) returnvalue=2; //cuts passed as Lc->piKp
311 if(okLcpKpi && okLcpiKp) returnvalue=3; //cuts passed as both pKpi and piKp
dcc2ade0 312
dcc2ade0 313 }
314
315 if(fUsePID || selectionLevel==AliRDHFCuts::kPID) returnvaluePID = IsSelectedPID(d);
316 if(returnvaluePID==0) return 0;
317
318 // selection on daughter tracks
319 if(selectionLevel==AliRDHFCuts::kAll ||
320 selectionLevel==AliRDHFCuts::kTracks) {
321 if(!AreDaughtersSelected(d)) return 0;
e3d40058 322 }
dcc2ade0 323
324
7ad4b782 325 Int_t returnvalueTot=CombinePIDCuts(returnvalue,returnvaluePID);
326 return returnvalueTot;
e3d40058 327}
328//---------------------------------------------------------------------------
7ad4b782 329Int_t AliRDHFCutsLctopKpi::IsSelectedPID(AliAODRecoDecayHF* obj) {
330
331
332 if(!obj) {return 3;}
333 Int_t okLcpKpi=0,okLcpiKp=0;
334 Int_t returnvalue=0;
335 Bool_t isPeriodd=fPidHF->GetOnePad();
336 Bool_t isPbPb=fPidHF->GetPbPb();
337 Bool_t ispion0=kTRUE,ispion2=kTRUE;
338 Bool_t isproton0=kFALSE,isproton2=kFALSE;
339 Bool_t iskaon1=kFALSE;
340 Double_t sigmaTOF=120.;
341 if(isPeriodd) sigmaTOF=160.;
342 if(isPbPb) sigmaTOF=160.;
343 fPidObjprot->SetTofSigma(sigmaTOF);
344 fPidHF->SetTofSigma(sigmaTOF);
345
346 for(Int_t i=0;i<3;i++){
347 AliAODTrack *track=(AliAODTrack*)obj->GetDaughter(i);
348 if(!track) return 0;
349 // identify kaon
350 if(i==1) {
351 Int_t isKaon=fPidHF->MakeRawPid(track,3);
352 if(isKaon>=1) {
353 iskaon1=kTRUE;
354 if(fPidHF->MakeRawPid(track,2)>=1) iskaon1=kFALSE;
355 }
356
357 }else{
358 //pion or proton
359
360 Int_t isProton=fPidObjprot->MakeRawPid(track,4);
361 if(isProton>=1){
362 if(fPidHF->MakeRawPid(track,2)>=1) isProton=-1;
363 if(fPidHF->MakeRawPid(track,3)>=1) isProton=-1;
364 }
365
366 Int_t isPion=fPidObjpion->MakeRawPid(track,2);
367 if(fPidHF->MakeRawPid(track,3)>=1) isPion=-1;
368 if(fPidObjprot->MakeRawPid(track,4)>=1) isPion=-1;
369
370
371 if(i==0) {
372 if(isPion<0) ispion0=kFALSE;
373 if(isProton>=1) isproton0=kTRUE;
374
375 }
376 if(i==2) {
377 if(isPion<0) ispion2=kFALSE;
378 if(isProton>=1) isproton2=kTRUE;
379 }
380
381 }
382 }
383
384 if(ispion2 && isproton0 && iskaon1) okLcpKpi=1;
385 if(ispion0 && isproton2 && iskaon1) okLcpiKp=1;
386 if(okLcpKpi) returnvalue=1; //cuts passed as Lc->pKpi
387 if(okLcpiKp) returnvalue=2; //cuts passed as Lc->piKp
388 if(okLcpKpi && okLcpiKp) returnvalue=3; //cuts passed as both pKpi and piKp
389
390 return returnvalue;
391}
392//-----------------------
393Int_t AliRDHFCutsLctopKpi::CombinePIDCuts(Int_t returnvalue, Int_t returnvaluePID) const {
394
395 Int_t returnvalueTot=0;
396 Int_t okLcpKpi=0,okLcpiKp=0;
397 if(returnvaluePID==1){
398 if(returnvalue==1 || returnvalue==3) okLcpKpi=1;
399 }
400 if(returnvaluePID==2){
401 if(returnvalue>=2) okLcpiKp=1;
402 }
403 if(returnvaluePID==3 && returnvalue>0){
404 if(returnvalue==1 || returnvalue==3) okLcpKpi=1;
405 if(returnvalue>=2) okLcpiKp=1;
406 }
407
408 if(okLcpKpi) returnvalueTot=1; //cuts passed as Lc->pKpi
409 if(okLcpiKp) returnvalueTot=2; //cuts passed as Lc->piKp
410 if(okLcpKpi && okLcpiKp) returnvalueTot=3; //cuts passed as both pKpi and piKp
411 return returnvalueTot;
412}
413//----------------------------------
414void AliRDHFCutsLctopKpi::SetStandardCutsPP2010() {
415
416 SetName("LctopKpiProdCuts");
417 SetTitle("Production cuts for Lc analysis");
418
419 AliESDtrackCuts *esdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts","default");
420 esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
421 esdTrackCuts->SetRequireTPCRefit(kTRUE);
422 esdTrackCuts->SetMinNClustersTPC(70);
423 esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
424 AliESDtrackCuts::kAny);
425 esdTrackCuts->SetRequireITSRefit(kTRUE);
426 esdTrackCuts->SetMinNClustersITS(4);
427 esdTrackCuts->SetMinDCAToVertexXY(0.);
428 esdTrackCuts->SetEtaRange(-0.8,0.8);
429 esdTrackCuts->SetPtRange(0.3,1.e10);
430 AddTrackCuts(esdTrackCuts);
431
432 const Int_t nptbins=4;
433 const Int_t nvars=12;
434 Float_t* ptbins;
435 ptbins=new Float_t[nptbins+1];
436
437 ptbins[0]=0.;
438 ptbins[1]=2.;
439 ptbins[2]=3.;
440 ptbins[3]=4.;
441 ptbins[4]=9999.;
442
443 SetGlobalIndex(nvars,nptbins);
444 SetPtBins(nptbins+1,ptbins);
445
446 Float_t** prodcutsval;
447 prodcutsval=new Float_t*[nvars];
448 for(Int_t iv=0;iv<nvars;iv++){
449 prodcutsval[iv]=new Float_t[nptbins];
450 }
e11ae259 451
7ad4b782 452 for(Int_t ipt=0;ipt<nptbins;ipt++){
453 prodcutsval[0][ipt]=0.18;
454 prodcutsval[1][ipt]=0.4;
455 prodcutsval[2][ipt]=0.5;
456 prodcutsval[3][ipt]=0.;
457 prodcutsval[4][ipt]=0.;
458 prodcutsval[5][ipt]=0.01;
459 prodcutsval[6][ipt]=0.06;
460 prodcutsval[7][ipt]=0.005;
461 prodcutsval[8][ipt]=0.;
462 prodcutsval[9][ipt]=0.;
463 prodcutsval[10][ipt]=0.;
464 prodcutsval[11][ipt]=0.05;
465 }
466 SetCuts(nvars,nptbins,prodcutsval);
467
468 AliAODPidHF* pidObjK=new AliAODPidHF();
469 Double_t sigmasK[5]={3.,1.,1.,3.,2.};
470 pidObjK->SetSigma(sigmasK);
471 pidObjK->SetAsym(kTRUE);
472 pidObjK->SetMatch(1);
473 pidObjK->SetTPC(kTRUE);
474 pidObjK->SetTOF(kTRUE);
475 pidObjK->SetITS(kTRUE);
476 Double_t plimK[2]={0.5,0.8};
477 pidObjK->SetPLimit(plimK,2);
478
479 SetPidHF(pidObjK);
480
481 AliAODPidHF* pidObjpi=new AliAODPidHF();
482 pidObjpi->SetTPC(kTRUE);
483 Double_t sigmaspi[5]={3.,0.,0.,0.,0.};
484 pidObjpi->SetSigma(sigmaspi);
485 SetPidpion(pidObjpi);
486
487 AliAODPidHF* pidObjp=new AliAODPidHF();
488 Double_t sigmasp[5]={3.,1.,1.,3.,2.};
489 pidObjp->SetSigma(sigmasp);
490 pidObjp->SetAsym(kTRUE);
491 pidObjp->SetMatch(1);
492 pidObjp->SetTPC(kTRUE);
493 pidObjp->SetTOF(kTRUE);
494 pidObjp->SetITS(kTRUE);
495 Double_t plimp[2]={1.,2.};
496 pidObjp->SetPLimit(plimp,2);
497
498 SetPidprot(pidObjp);
499
500 SetUsePID(kTRUE);
501
502 PrintAll();
503
e11ae259 504 for(Int_t iiv=0;iiv<nvars;iiv++){
505 delete [] prodcutsval[iiv];
506 }
507 delete [] prodcutsval;
508 prodcutsval=NULL;
509 delete [] ptbins;
510 ptbins=NULL;
511
512 delete pidObjp;
513 pidObjp=NULL;
514
7ad4b782 515 return;
516}
517
518//------------------
519Bool_t AliRDHFCutsLctopKpi::ReconstructKF(AliAODRecoDecayHF3Prong *d,Int_t *pdgs,Double_t field) const{
520
521 Int_t nprongs=d->GetNProngs();
522 Int_t iprongs[nprongs];
523 for(Int_t i=0;i<nprongs;i++) iprongs[i]=i;
524
525 Double_t mass[2]={0.,0.};
526
527 AliKFParticle *decay=d->ApplyVertexingKF(iprongs,nprongs,pdgs,kTRUE,field,mass);
528 if(!decay) return kTRUE;
529 AliESDVertex *vertexESD = new AliESDVertex(decay->Parameters(),
530 decay->CovarianceMatrix(),
531 decay->GetChi2(),
532 nprongs);
533 Double_t pos[3],cov[6],chi2perNDF;
534 vertexESD->GetXYZ(pos);
535 vertexESD->GetCovMatrix(cov);
536 chi2perNDF = vertexESD->GetChi2toNDF();
537 delete vertexESD; vertexESD=NULL;
538 AliAODVertex *vertexAOD = new AliAODVertex(pos,cov,chi2perNDF,0x0,-1,AliAODVertex::kUndef,nprongs);
539 d->SetSecondaryVtx(vertexAOD);
540 return kTRUE;
541}