1 #include "AliAnalysisTaskLambdaBayes.h"
7 #include "AliInputEventHandler.h"
8 #include "AliAODEvent.h"
9 #include "AliAODVertex.h"
10 #include "AliAODTrack.h"
11 #include "AliESDtrack.h"
12 #include "AliCentrality.h"
13 #include "AliVHeader.h"
14 #include "AliAODVZERO.h"
16 #include "AliOADBContainer.h"
19 #include "AliGenHijingEventHeader.h"
20 #include "AliMCEvent.h"
21 #include "AliAODMCHeader.h"
22 #include "AliAODMCParticle.h"
24 #include "AliESDtrackCuts.h"
25 #include "AliESDVertex.h"
26 #include "AliEventplane.h"
27 #include "AliAnalysisManager.h"
31 Float_t AliAnalysisTaskLambdaBayes::fPtLambdaMin[AliAnalysisTaskLambdaBayes::nPtBin] = {0.,0.25,0.5,0.75,1,1.5,2,2.5,3,3.5,4.,5.,6.};// ptmin bin
32 Float_t AliAnalysisTaskLambdaBayes::fPtLambdaMax[AliAnalysisTaskLambdaBayes::nPtBin] = {0.25,0.5,0.75,1,1.5,2,2.5,3,3.5,4.,5.,6.,10.};// ptmax bin
36 //using namespace std;
38 ClassImp(AliAnalysisTaskLambdaBayes)
39 //_____________________________________________________________________________
40 AliAnalysisTaskLambdaBayes::AliAnalysisTaskLambdaBayes():
42 fVtxCut(10.0), // cut on |vertex| < fVtxCut
43 fEtaCut(0.8), // cut on |eta| < fEtaCut
44 fMinPt(0.15), // cut on pt > fMinPt
84 // Default constructor (should not be used)
85 fList->SetName("contLambdaBayes1");
86 fList2->SetName("contLambdaBayes2");
87 fList3->SetName("contLambdaBayes3");
89 fList->SetOwner(kTRUE);
90 fList2->SetOwner(kTRUE);
91 fList3->SetOwner(kTRUE);
93 TFile *fmism = new TFile("$ALICE_ROOT/TOF/data/TOFmismatchDistr.root");
94 fHmismTOF = (TH1F *) fmism->Get("TOFmismDistr");
96 TFile *fchDist = new TFile("$ALICE_ROOT/TOF/data/TOFchannelDist.root");
97 fHchannelTOFdistr = (TH1D *) fchDist->Get("hTOFchanDist");
99 for(Int_t i=0;i < nCentrBin;i++){
109 for(Int_t i=0;i < 4;i++){
114 for(Int_t i=0;i < 1000;i++){
121 fMassLambda[i] = 0.0;
125 //______________________________________________________________________________
126 AliAnalysisTaskLambdaBayes::AliAnalysisTaskLambdaBayes(const char *name):
127 AliAnalysisTaskSE(name),
128 fVtxCut(10.0), // cut on |vertex| < fVtxCut
129 fEtaCut(0.8), // cut on |eta| < fEtaCut
130 fMinPt(0.15), // cut on pt > fMinPt
164 fHchannelTOFdistr(0),
171 DefineOutput(1, TList::Class());
172 DefineOutput(2, TList::Class());
173 DefineOutput(3, TList::Class());
174 DefineOutput(4, TList::Class());
176 // Output slot #1 writes into a TTree
177 fList->SetName("contLambdaBayes1");
178 fList2->SetName("contLambdaBayes2");
179 fList3->SetName("contLambdaBayes3");
181 fList->SetOwner(kTRUE);
182 fList2->SetOwner(kTRUE);
183 fList3->SetOwner(kTRUE);
185 TFile *fmism = new TFile("$ALICE_ROOT/TOF/data/TOFmismatchDistr.root");
186 fHmismTOF = (TH1F *) fmism->Get("TOFmismDistr");
188 TFile *fchDist = new TFile("$ALICE_ROOT/TOF/data/TOFchannelDist.root");
189 fHchannelTOFdistr = (TH1D *) fchDist->Get("hTOFchanDist");
191 for(Int_t i=0;i < nCentrBin;i++){
201 for(Int_t i=0;i < 4;i++){
206 for(Int_t i=0;i < 1000;i++){
213 fMassLambda[i] = 0.0;
216 //_____________________________________________________________________________
217 AliAnalysisTaskLambdaBayes::~AliAnalysisTaskLambdaBayes()
222 //______________________________________________________________________________
223 void AliAnalysisTaskLambdaBayes::UserCreateOutputObjects()
226 fPIDCombined=new AliPIDCombined;
227 fPIDCombined->SetDefaultTPCPriors();
228 fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTOF);
230 Float_t invMmin = 1.115-0.005*8;
231 Float_t invMmax = 1.115+0.005*8;
233 const Int_t nBinPid = 14;
235 Int_t binPid[nBinPid] = {1/*ptKs*/,1+7*(!fToEP)/*EtaPiP*/,20/*pt+*/,1/*pt-*/,5/*P+*/,1/*P-*/,2/*TOFmatch+*/,1/*TOFmatch-*/,2/*istrue*/,4/*Nsigma+*/,1/*Nsigma-*/,1+4*(fToEP)/*DeltaPhi+*/,1/*DeltaPhi-*/,1+4*(fToEP)/*Psi*/};
237 Int_t binPid2[nBinPid] = {1/*ptKs*/,1+7*(!fToEP)/*EtaPiN*/,1/*pt+*/,20/*pt-*/,1/*P+*/,5/*P-*/,1/*TOFmatch+*/,2/*TOFmatch-*/,2/*istrue*/,1/*Nsigma+*/,4/*Nsigma-*/,1/*DeltaPhi+*/,1+4*(fToEP)/*DeltaPhi-*/,1+4*(fToEP)/*Psi*/};
239 fContPid = new AliPIDperfContainer("contPID",nBinPid,binPid);
240 fContPid->SetTitleX("M_{#Lambda}");
241 fContPid->SetTitleY("centrality (%)");
242 fContPid->SetVarName(0,"p_{T}^{#Lambda}");
243 fContPid->SetVarRange(0,0,10);
244 fContPid->SetVarName(1,"#eta^{#Lambda}");
245 fContPid->SetVarRange(1,-0.8,0.8);
246 fContPid->SetVarName(2,"p_{T}^{Kp}");
247 fContPid->SetVarRange(2,0.3,4.3);
248 fContPid->SetVarName(3,"p_{T}^{Kn}");
249 fContPid->SetVarRange(3,0.3,4.3);
250 fContPid->SetVarName(4,"BayesProb^{Kp}");
251 fContPid->SetVarRange(4,0,1.);
252 fContPid->SetVarName(5,"BayesProb^{Kn}");
253 fContPid->SetVarRange(5,0,1.);
254 fContPid->SetVarName(6,"isTOFmatch^{Kp}");
255 fContPid->SetVarRange(6,-0.5,1.5);
256 fContPid->SetVarName(7,"isTOFmatch^{Kn}");
257 fContPid->SetVarRange(7,-0.5,1.5);
258 fContPid->SetVarName(8,"isLambdaTrue^{Kn}");
259 fContPid->SetVarRange(8,-0.5,1.5);
260 fContPid->SetVarName(9,"N#sigma^{Kp}");
261 fContPid->SetVarRange(9,1.25,6.25);
262 fContPid->SetVarName(10,"N#sigma^{Kn}");
263 fContPid->SetVarRange(10,1.25,6.25);
264 fContPid->SetVarName(11,"#Delta#phi^{Kp}");
265 fContPid->SetVarRange(11,-TMath::Pi(),TMath::Pi());
266 fContPid->SetVarName(12,"#Delta#phi^{Kn}");
267 fContPid->SetVarRange(12,-TMath::Pi(),TMath::Pi());
268 fContPid->SetVarName(13,"#Psi");
269 fContPid->SetVarRange(13,-TMath::Pi()/2,TMath::Pi()/2);
271 fContPid2 = new AliPIDperfContainer("contPID2",nBinPid,binPid2);
272 fContPid2->SetTitleX("M_{#Lambda}");
273 fContPid2->SetTitleY("centrality (%)");
274 fContPid2->SetVarName(0,"p_{T}^{#Lambda}");
275 fContPid2->SetVarRange(0,0,10);
276 fContPid2->SetVarName(1,"#eta^{#Lambda}");
277 fContPid2->SetVarRange(1,-0.8,0.8);
278 fContPid2->SetVarName(2,"p_{T}^{Kp}");
279 fContPid2->SetVarRange(2,0.3,4.3);
280 fContPid2->SetVarName(3,"p_{T}^{Kn}");
281 fContPid2->SetVarRange(3,0.3,4.3);
282 fContPid2->SetVarName(4,"BayesProb^{Kp}");
283 fContPid2->SetVarRange(4,0,1.);
284 fContPid2->SetVarName(5,"BayesProb^{Kn}");
285 fContPid2->SetVarRange(5,0,1.);
286 fContPid2->SetVarName(6,"isTOFmatch^{Kp}");
287 fContPid2->SetVarRange(6,-0.5,1.5);
288 fContPid2->SetVarName(7,"isTOFmatch^{Kn}");
289 fContPid2->SetVarRange(7,-0.5,1.5);
290 fContPid2->SetVarName(8,"isLambdaTrue^{Kn}");
291 fContPid2->SetVarRange(8,-0.5,1.5);
292 fContPid2->SetVarName(9,"N#sigma^{Kp}");
293 fContPid2->SetVarRange(9,1.25,6.25);
294 fContPid2->SetVarName(10,"N#sigma^{Kn}");
295 fContPid2->SetVarRange(10,1.25,6.25);
296 fContPid2->SetVarName(11,"#Delta#phi^{Kp}");
297 fContPid2->SetVarRange(11,-TMath::Pi(),TMath::Pi());
298 fContPid2->SetVarName(12,"#Delta#phi^{Kn}");
299 fContPid2->SetVarRange(12,-TMath::Pi(),TMath::Pi());
300 fContPid2->SetVarName(13,"#Psi");
301 fContPid2->SetVarRange(13,-TMath::Pi()/2,TMath::Pi()/2);
305 const Int_t nDETsignal = 100; // mass
306 Double_t binDETsignal[nDETsignal+1];
307 for(Int_t i=0;i<nDETsignal+1;i++){
308 binDETsignal[i] = invMmin + i*(invMmax - invMmin) / nDETsignal;
310 const Int_t nDETsignal2 = 10; // centrality
311 Double_t binDETsignal2[nDETsignal2+1];
312 for(Int_t i=0;i<nDETsignal2+1;i++){
313 binDETsignal2[i] = i*100./ nDETsignal2;
315 fContPid->AddSpecies("Lambda",nDETsignal,binDETsignal,nDETsignal2,binDETsignal2);
316 fContPid2->AddSpecies("Lambda2",nDETsignal,binDETsignal,nDETsignal2,binDETsignal2);
318 fList->Add(fContPid);
319 fList->Add(fContPid2);
321 const Int_t nBinUser = 6;
322 Int_t binUser[nBinUser] = {8/*Eta*/,20/*pt*/,2/*istrue*/,4/*whatSelection*/,1/*DeltaPhi*/,1/*Psi*/};
323 fContUser = new AliPIDperfContainer("contUserPID",nBinUser,binUser);
324 fContUser->SetTitleX("M_{#Lambda}");
325 fContUser->SetTitleY("centrality (%)");
326 fContUser->SetVarName(0,"#eta");
327 fContUser->SetVarRange(0,-0.8,0.8);
328 fContUser->SetVarName(1,"p_{T}");
329 fContUser->SetVarRange(1,0.3,4.3);
330 fContUser->SetVarName(2,"isLambdaTrue");
331 fContUser->SetVarRange(2,-0.5,1.5);
332 fContUser->SetVarName(3,"whatSelected"); // 0=no, 1=pi, 2=K, 3=p
333 fContUser->SetVarRange(3,-0.5,3.5);
334 fContUser->SetVarName(4,"#Delta#phi");
335 fContUser->SetVarRange(4,-TMath::Pi(),TMath::Pi());
336 fContUser->SetVarName(5,"#Psi");
337 fContUser->SetVarRange(5,-TMath::Pi()/2,TMath::Pi()/2);
339 fContUser2 = new AliPIDperfContainer("contUserPID2",nBinUser,binUser);
340 fContUser2->SetTitleX("M_{#Lambda}");
341 fContUser2->SetTitleY("centrality (%)");
342 fContUser2->SetVarName(0,"#eta");
343 fContUser2->SetVarRange(0,-0.8,0.8);
344 fContUser2->SetVarName(1,"p_{T}");
345 fContUser2->SetVarRange(1,0.3,4.3);
346 fContUser2->SetVarName(2,"isLambdaTrue");
347 fContUser2->SetVarRange(2,-0.5,1.5);
348 fContUser2->SetVarName(3,"whatSelected");
349 fContUser2->SetVarRange(3,-0.5,3.5);
350 fContUser2->SetVarName(4,"#Delta#phi");
351 fContUser2->SetVarRange(4,-TMath::Pi(),TMath::Pi());
352 fContUser2->SetVarName(5,"#Psi");
353 fContUser2->SetVarRange(5,-TMath::Pi()/2,TMath::Pi()/2);
355 fContUser->AddSpecies("Lambda",nDETsignal,binDETsignal,nDETsignal2,binDETsignal2);
356 fContUser2->AddSpecies("Lambda2",nDETsignal,binDETsignal,nDETsignal2,binDETsignal2);
358 fList->Add(fContUser);
359 fList->Add(fContUser2);
361 hMatching[0] = new TH2F("hMatchAll","TOF matched (all);p_{T} (GeV/#it{c});centrality (%)",50,0,10,nDETsignal2,0,100);
362 hMatching[1] = new TH2F("hMatchPi","TOF matched (#pi);p_{T} (GeV/#it{c});centrality (%)",50,0,10,nDETsignal2,0,100);
363 hMatching[2] = new TH2F("hMatchKa","TOF matched (K);p_{T} (GeV/#it{c});centrality (%)",50,0,10,nDETsignal2,0,100);
364 hMatching[3] = new TH2F("hMatchPr","TOF matched (p);p_{T} (GeV/#it{c});centrality (%)",50,0,10,nDETsignal2,0,100);
366 hTracking[0] = new TH2F("hTrackingAll","TPC tracks (all);p_{T} (GeV/#it{c});centrality (%)",50,0,10,nDETsignal2,0,100);
367 hTracking[1] = new TH2F("hTrackingPi","TPC tracks (#pi);p_{T} (GeV/#it{c});centrality (%)",50,0,10,nDETsignal2,0,100);
368 hTracking[2] = new TH2F("hTrackingKa","TPC tracks (K);p_{T} (GeV/#it{c});centrality (%)",50,0,10,nDETsignal2,0,100);
369 hTracking[3] = new TH2F("hTrackingPr","TPC tracks (p);p_{T} (GeV/#it{c});centrality (%)",50,0,10,nDETsignal2,0,100);
371 fList2->Add(hMatching[0]);
372 fList2->Add(hMatching[1]);
373 fList2->Add(hMatching[2]);
374 fList2->Add(hMatching[3]);
375 fList2->Add(hTracking[0]);
376 fList2->Add(hTracking[1]);
377 fList2->Add(hTracking[2]);
378 fList2->Add(hTracking[3]);
380 fTOFTPCsignal = new TH2F("hTOFTPCsignal","TOF-TPC signal for protons (1.2 < p_{T} < 1.3 GeV/#it{c}, cent. = 0-20);N#sigma_{TOF};N#sigma_{TPC}",100,-5,5,100,-5,5);
381 fList2->Add(fTOFTPCsignal);
382 fCombsignal = new TH1F("hCombsignal","Combined signal for protons (1.2 < p_{T} < 1.3 GeV/#it{c}, cent. = 0-20);N#sigma",100,0,5);
383 fList2->Add(fCombsignal);
386 char name[100],title[400];
387 for(Int_t i=0;i < nCentrBin;i++){
388 snprintf(name,100,"hPiTPCQA_%i",i);
389 snprintf(title,400,"TPC signal for #pi cent=%i-%i%c;p_{T} (GeV/#it{c});N#sigma",i*10,(i+1)*10,'%');
390 fPiTPC[i] = new TH2F(name,title,50,0,4,200,-10,10);
391 fList3->Add(fPiTPC[i]);
393 snprintf(name,100,"hKaTPCQA_%i",i);
394 snprintf(title,400,"TPC signal for K cent=%i-%i%c;p_{T} (GeV/#it{c});N#sigma",i*10,(i+1)*10,'%');
395 fKaTPC[i] = new TH2F(name,title,50,0,4,200,-10,10);
396 fList3->Add(fKaTPC[i]);
398 snprintf(name,100,"hPrTPCQA_%i",i);
399 snprintf(title,400,"TPC signal for p cent=%i-%i%c;p_{T} (GeV/#it{c});N#sigma",i*10,(i+1)*10,'%');
400 fPrTPC[i] = new TH2F(name,title,50,0,4,200,-10,10);
401 fList3->Add(fPrTPC[i]);
403 snprintf(name,100,"hElTPCQA_%i",i);
404 snprintf(title,400,"TPC signal for e cent=%i-%i%c;p_{T} (GeV/#it{c});N#sigma",i*10,(i+1)*10,'%');
405 fElTPC[i] = new TH2F(name,title,50,0,4,200,-10,10);
406 fList3->Add(fElTPC[i]);
408 snprintf(name,100,"hPiTOFQA_%i",i);
409 snprintf(title,400,"TOF signal for #pi cent=%i-%i%c;p_{T} (GeV/#it{c});N#sigma",i*10,(i+1)*10,'%');
410 fPiTOF[i] = new TH2F(name,title,50,0,4,200,-10,10);
411 fList3->Add(fPiTOF[i]);
413 snprintf(name,100,"hKaTOFQA_%i",i);
414 snprintf(title,400,"TOF signal for K cent=%i-%i%c;p_{T} (GeV/#it{c});N#sigma",i*10,(i+1)*10,'%');
415 fKaTOF[i] = new TH2F(name,title,50,0,4,200,-10,10);
416 fList3->Add(fKaTOF[i]);
418 snprintf(name,100,"hPrTOFQA_%i",i);
419 snprintf(title,400,"TOF signal for p cent=%i-%i%c;p_{T} (GeV/#it{c});N#sigma",i*10,(i+1)*10,'%');
420 fPrTOF[i] = new TH2F(name,title,50,0,4,200,-10,10);
421 fList3->Add(fPrTOF[i]);
423 snprintf(name,100,"hElTOFQA_%i",i);
424 snprintf(title,400,"TOF signal for e cent=%i-%i%c;p_{T} (GeV/#it{c});N#sigma",i*10,(i+1)*10,'%');
425 fElTOF[i] = new TH2F(name,title,50,0,4,200,-10,10);
426 fList3->Add(fElTOF[i]);
436 //______________________________________________________________________________
437 void AliAnalysisTaskLambdaBayes::UserExec(Option_t *)
440 // Called for each event
442 fOutputAOD = dynamic_cast<AliAODEvent*>(InputEvent());
444 Printf("%s:%d AODEvent not found in Input Manager",(char*)__FILE__,__LINE__);
449 Float_t zvtx = GetVertex(fOutputAOD);
455 AliAODMCHeader *mcHeader = dynamic_cast<AliAODMCHeader*>(fOutputAOD->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
457 AliError("Could not find MC Header in AOD");
462 if (TMath::Abs(zvtx) < fVtxCut) {
467 Float_t v0Centr = -10.;
468 Float_t trkCentr = -10.;
469 AliCentrality *centrality = fOutputAOD->GetCentrality();
471 trkCentr = centrality->GetCentralityPercentile("V0M");
472 v0Centr = centrality->GetCentralityPercentile("TRK");
476 v0Centr=100./(fOutputAOD->GetNumberOfTracks()/12.+1);
480 if((TMath::Abs(v0Centr - trkCentr) < 5.0 || (fTypeCol!=2)) && v0Centr>0){ // consistency cut on centrality selection
481 fCentrality = v0Centr;
482 Analyze(fOutputAOD); // Do analysis!!!!
489 //________________________________________________________________________
490 void AliAnalysisTaskLambdaBayes::Analyze(AliAODEvent* aodEvent)
493 Int_t ntrack = aodEvent->GetNumberOfTracks();
495 fPtKp=0.,fPhiKp=0.,fEtaKp=0.;
496 fPtKn=0.,fPhiKn=0.,fEtaKn=0.;
504 Float_t invMmin = 1.115-0.005*8;
505 Float_t invMmax = 1.115+0.005*8;
508 if(fCentrality < 0) icentr = 8;
509 else if(fCentrality < 10) icentr = 0;
510 else if(fCentrality < 20) icentr = 1;
511 else if(fCentrality < 30) icentr = 2;
512 else if(fCentrality < 40) icentr = 3;
513 else if(fCentrality < 50) icentr = 4;
514 else if(fCentrality < 60) icentr = 5;
515 else if(fCentrality < 70) icentr = 6;
516 else if(fCentrality < 80) icentr = 7;
518 Float_t addMismatchForMC = 0.005;
519 if(fCentrality < 50) addMismatchForMC += 0.005;
520 if(fCentrality < 20) addMismatchForMC += 0.02;
522 if(fTypeCol == 0 || fTypeCol == 1) addMismatchForMC = 0.005;
526 Double_t Qx2 = 0, Qy2 = 0;
527 Double_t Qx3 = 0, Qy3 = 0;
528 for(Int_t iT = 0; iT < ntrack; iT++) {
529 AliAODTrack* aodTrack = aodEvent->GetTrack(iT);
535 Bool_t trkFlag = aodTrack->TestFilterBit(fFilterBit);
537 if ((TMath::Abs(aodTrack->Eta()) > 0.8) || (aodTrack->Pt() < 0.2) || (aodTrack->GetTPCNcls() < fNcluster) || !trkFlag)
540 Double_t b[2] = {-99., -99.};
541 Double_t bCov[3] = {-99., -99., -99.};
542 if (!aodTrack->PropagateToDCA(aodEvent->GetPrimaryVertex(), aodEvent->GetMagneticField(), 100., b, bCov))
545 if ((TMath::Abs(b[0]) > 3.0) || (TMath::Abs(b[1]) > 2.4))
548 Qx2 += TMath::Cos(2*aodTrack->Phi());
549 Qy2 += TMath::Sin(2*aodTrack->Phi());
550 Qx3 += TMath::Cos(3*aodTrack->Phi());
551 Qy3 += TMath::Sin(3*aodTrack->Phi());
555 fPsi = TMath::ATan2(Qy2, Qx2)/2.;
557 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
558 AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
559 AliPIDResponse *PIDResponse=inputHandler->GetPIDResponse();
561 // PIDResponse->GetTOFResponse().SetTrackParameter(0,0.);
562 // PIDResponse->GetTOFResponse().SetTrackParameter(1,0.);
563 // PIDResponse->GetTOFResponse().SetTrackParameter(2,0.018);
564 // PIDResponse->GetTOFResponse().SetTrackParameter(3,50.0);
566 fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF);
569 Double_t probP[10] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
570 Double_t probN[10] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
571 Double_t nSigmaTPC,nSigmaTOF=6,nSigmaTPC2,nSigmaTOF2=6,nSigmaComb,nSigmaComb2;
572 Double_t nSigmaTPCRef,nSigmaTOFRef=6,nSigmaCombRef;
574 AliAODMCHeader *mcHeader = dynamic_cast<AliAODMCHeader*>(aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
575 TClonesArray *mcArray = NULL;
577 mcArray = (TClonesArray*)aodEvent->GetList()->FindObject(AliAODMCParticle::StdBranchName());
581 nmc = mcArray->GetEntries();
583 for(Int_t i=0;i < ntrack;i++){ // loop on tracks
584 AliAODTrack* track = aodEvent->GetTrack(i);
586 AliAODMCParticle *mcp = NULL;
593 Int_t tofMatch = (track->GetStatus() & AliVTrack::kTOFout) && (track->GetStatus() & AliVTrack::kTIME);
597 label = track->GetLabel();
598 if(label != -1 && label < nmc){
599 label = TMath::Abs(label);
600 mcp = (AliAODMCParticle*)mcArray->At(label);
601 pdg = TMath::Abs(mcp->GetPdgCode());
607 /*UInt_t detUsed =*/ fPIDCombined->ComputeProbabilities(track, PIDResponse, probP);
610 if(track->TestFilterBit(fFilterBit) && TMath::Abs(track->Eta()) < 0.8 && track->Charge() > 0){
611 hTracking[0]->Fill(track->Pt(),fCentrality);
613 hTracking[1]->Fill(track->Pt(),fCentrality);
615 hTracking[2]->Fill(track->Pt(),fCentrality);
617 hTracking[3]->Fill(track->Pt(),fCentrality);
618 else if(! mcp){ // Fill matching histo with the prob
619 hTracking[1]->Fill(track->Pt(),fCentrality,probP[2]);
620 hTracking[2]->Fill(track->Pt(),fCentrality,probP[3]);
621 hTracking[3]->Fill(track->Pt(),fCentrality,probP[4]);
625 if(!tofMatch) continue;
627 if(track->TestFilterBit(fFilterBit) && TMath::Abs(track->Eta()) < 0.8 && track->Charge() > 0){
628 hMatching[0]->Fill(track->Pt(),fCentrality);
630 hMatching[1]->Fill(track->Pt(),fCentrality);
632 hMatching[2]->Fill(track->Pt(),fCentrality);
634 hMatching[3]->Fill(track->Pt(),fCentrality);
635 else if(! mcp){ // Fill matching histo with the prob
636 hMatching[1]->Fill(track->Pt(),fCentrality,probP[2]);
637 hMatching[2]->Fill(track->Pt(),fCentrality,probP[3]);
638 hMatching[3]->Fill(track->Pt(),fCentrality,probP[4]);
647 // start analysis Lambda
648 for(Int_t i=0;i < ntrack;i++){ // loop on proton candidate tracks
649 AliAODTrack* KpTrack = aodEvent->GetTrack(i);
655 if(!(KpTrack->Pt() > 0.3 && TMath::Abs(KpTrack->Eta()) < 0.8)) continue;
657 Bool_t isLambda = (KpTrack->Charge() > 0);
663 fPtKp=KpTrack->Pt(),fPhiKp=KpTrack->Phi(),fEtaKp=KpTrack->Eta();
666 UInt_t detUsedP = fPIDCombined->ComputeProbabilities(KpTrack, PIDResponse, probP);
669 fPIDCombined->GetPriors(KpTrack, oldpP, PIDResponse, detUsedP);
672 nSigmaTPC = PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kProton);
673 nSigmaTPCRef = PIDResponse->NumberOfSigmasTPC(KpTrack,(AliPID::EParticleType) fSpeciesRef);
675 if(! (TMath::Abs(nSigmaTPC) < 5)) continue;
677 Int_t tofMatch1 = (KpTrack->GetStatus() & AliVTrack::kTOFout) && (KpTrack->GetStatus() & AliVTrack::kTIME);
680 Int_t labelK = TMath::Abs(KpTrack->GetLabel());
681 AliAODMCParticle *mcp1 = (AliAODMCParticle*)mcArray->At(labelK);
682 pdg1 = TMath::Abs(mcp1->GetPdgCode());
686 fPidKp = Int_t(probP[4]*100);
689 if(!IsChannelValid(TMath::Abs(KpTrack->Eta()))){
690 // remove this tof hit
691 fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC);
692 detUsedP = fPIDCombined->ComputeProbabilities(KpTrack, PIDResponse, probP);
693 fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF);
694 fPidKp = Int_t(probP[4]*100);
698 if(probP[4] > probP[3] && probP[4] > probP[2] && probP[4] > probP[0]) fPidKp += 128; // max prob
701 nSigmaTOF = PIDResponse->NumberOfSigmasTOF(KpTrack,AliPID::kElectron);
702 if(TMath::Abs(PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kElectron))<1) fElTOF[icentr]->Fill(fPtKp,nSigmaTOF);
703 if(TMath::Abs(nSigmaTOF)<1) fElTPC[icentr]->Fill(fPtKp,PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kElectron));
704 nSigmaTOF = PIDResponse->NumberOfSigmasTOF(KpTrack,AliPID::kPion);
705 if(TMath::Abs(PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kPion))<1) fPiTOF[icentr]->Fill(fPtKp,nSigmaTOF);
706 if(TMath::Abs(nSigmaTOF)<1) fPiTPC[icentr]->Fill(fPtKp,PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kPion));
707 nSigmaTOF = PIDResponse->NumberOfSigmasTOF(KpTrack,AliPID::kKaon);
708 if(TMath::Abs(PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kKaon))<1) fKaTOF[icentr]->Fill(fPtKp,nSigmaTOF);
709 if(TMath::Abs(nSigmaTOF)<1) fKaTPC[icentr]->Fill(fPtKp,PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kKaon));
711 nSigmaTOF = PIDResponse->NumberOfSigmasTOF(KpTrack,AliPID::kProton);
712 nSigmaTOFRef = PIDResponse->NumberOfSigmasTOF(KpTrack,(AliPID::EParticleType) fSpeciesRef);
714 if(TMath::Abs(PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kProton))<1) fPrTOF[icentr]->Fill(fPtKp,nSigmaTOF);
715 if(TMath::Abs(nSigmaTOF)<1) fPrTPC[icentr]->Fill(fPtKp,PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kProton));
719 Float_t mismAdd = addMismatchForMC;
720 if(KpTrack->Pt() < 1) mismAdd = addMismatchForMC/KpTrack->Pt();
722 if(gRandom->Rndm() < mismAdd){
723 Float_t etaAbs = TMath::Abs(KpTrack->Eta());
724 Int_t channel = Int_t(4334.09 - 4758.36 * etaAbs -1989.71 * etaAbs*etaAbs + 1957.62*etaAbs*etaAbs*etaAbs);
725 channel = channel % 8736;
726 Float_t distIP = fHchannelTOFdistr->GetBinContent(channel);
728 // generate random time
729 Float_t timeRandom = fHmismTOF->GetRandom() + distIP*3.35655419905265973e+01;
730 Double_t times[AliPID::kSPECIESC];
731 KpTrack->GetIntegratedTimes(times,AliPID::kSPECIESC);
732 nSigmaTOF = TMath::Abs(timeRandom - times[4])/PIDResponse->GetTOFResponse().GetExpectedSigma(KpTrack->P(), times[4], AliPID::kProton);
733 nSigmaTOFRef = TMath::Abs(timeRandom - times[fSpeciesRef])/PIDResponse->GetTOFResponse().GetExpectedSigma(KpTrack->P(), times[fSpeciesRef], (AliPID::EParticleType) fSpeciesRef);
737 if(fCentrality < 20 && KpTrack->Pt() < 1.3 && KpTrack->Pt() > 1.2)fTOFTPCsignal->Fill(nSigmaTOF,nSigmaTPC);
738 nSigmaTOF = TMath::Abs(nSigmaTOF);
740 if(nSigmaTOF < 2) fPidKp += 256;
741 else if(nSigmaTOF < 3) fPidKp += 512;
746 nSigmaComb = TMath::Sqrt(nSigmaTOF*nSigmaTOF + nSigmaTPC*nSigmaTPC);
747 nSigmaCombRef = TMath::Sqrt(nSigmaTOFRef*nSigmaTOFRef + nSigmaTPCRef*nSigmaTPCRef);
748 if(nSigmaTOF < 5 && fCentrality < 20 && KpTrack->Pt() < 1.3 && KpTrack->Pt() > 1.2){
749 fCombsignal->Fill(nSigmaComb);
752 nSigmaComb = TMath::Abs(nSigmaTPC);
753 nSigmaCombRef = TMath::Abs(nSigmaTPCRef);
756 // use sigmaTOF instead of sigmaComb
757 nSigmaTOFRef = TMath::Abs(nSigmaTOFRef);
760 nSigmaComb = nSigmaTOF;
761 nSigmaCombRef = nSigmaTOFRef;
764 if(nSigmaComb < 2) nSigmaComb = 2;
765 else if(nSigmaComb < 3) nSigmaComb = 3;
766 else if(nSigmaComb < 5) nSigmaComb = 4.99;
769 if(nSigmaCombRef < 2) nSigmaCombRef = 2;
770 else if(nSigmaCombRef < 3) nSigmaCombRef = 3;
771 else if(nSigmaCombRef < 5) nSigmaCombRef = 4.99;
772 else nSigmaCombRef = 6;
775 for(Int_t k=0;k < fNLambda;k++){ // find the Lambda which contains the positive track
776 if(i == fIpP[k]) iks = k;
779 if(fPtKp > 4.299) fPtKp = 4.299;
781 if(iks > -1 && fIpN[iks] > -1){
782 //for(Int_t j=0;j < ntrack;j++){ // loop on negative tracks
784 AliAODTrack* KnTrack = aodEvent->GetTrack(j);
793 if(!(KnTrack->Pt() > 0.3 && TMath::Abs(KnTrack->Eta()) < 0.8)) continue;
795 fPtKn=KnTrack->Pt(),fPhiKn=KnTrack->Phi(),fEtaKn=KnTrack->Eta();
798 UInt_t detUsedN = fPIDCombined->ComputeProbabilities(KnTrack, PIDResponse, probN);
800 fPIDCombined->GetPriors(KnTrack, oldpN, PIDResponse, detUsedN);
802 nSigmaTPC2 = PIDResponse->NumberOfSigmasTPC(KnTrack,AliPID::kPion);
804 if(! (TMath::Abs(nSigmaTPC2) < 5)) continue;
806 Int_t tofMatch2 = (KnTrack->GetStatus() & AliVTrack::kTOFout) && (KnTrack->GetStatus() & AliVTrack::kTIME);
809 Int_t labelK = TMath::Abs(KnTrack->GetLabel());
810 AliAODMCParticle *mcp2 = (AliAODMCParticle*)mcArray->At(labelK);
811 pdg2 = TMath::Abs(mcp2->GetPdgCode());
815 fPidKn = Int_t(probN[2]*100);
818 if(probN[2] > probN[3] && probN[2] > probN[4] && probN[2] > probN[0]) fPidKn += 128; // max prob
820 nSigmaTOF2 = PIDResponse->NumberOfSigmasTOF(KnTrack,AliPID::kPion);
823 Float_t mismAdd = addMismatchForMC;
824 if(KnTrack->Pt() < 1) mismAdd = addMismatchForMC/KnTrack->Pt();
826 if(gRandom->Rndm() < mismAdd){
827 Float_t etaAbs = TMath::Abs(KnTrack->Eta());
828 Int_t channel = Int_t(4334.09 - 4758.36 * etaAbs -1989.71 * etaAbs*etaAbs + 1957.62*etaAbs*etaAbs*etaAbs);
829 channel = channel % 8736;
830 Float_t distIP = fHchannelTOFdistr->GetBinContent(channel);
832 // generate random time
833 Float_t timeRandom = fHmismTOF->GetRandom() + distIP*3.35655419905265973e+01;
834 Double_t times[AliPID::kSPECIESC];
835 KnTrack->GetIntegratedTimes(times,AliPID::kSPECIESC);
836 nSigmaTOF2 = TMath::Abs(timeRandom - times[4])/PIDResponse->GetTOFResponse().GetExpectedSigma(KnTrack->P(), times[4], AliPID::kProton);
842 nSigmaTOF2 = TMath::Abs(nSigmaTOF2);
844 if(nSigmaTOF2 < 2) fPidKn += 256;
845 else if(nSigmaTOF2 < 3) fPidKn += 512;
848 px = KpTrack->Px() + KnTrack->Px();
849 py = KpTrack->Py() + KnTrack->Py();
850 pz = KpTrack->Pz() + KnTrack->Pz();
851 E = TMath::Sqrt(KpTrack->P()*KpTrack->P() + 0.938e-01*0.938e-01);
852 E += TMath::Sqrt(KnTrack->P()*KnTrack->P()+ 1.39e-01*1.39e-01);
854 ksV.SetPxPyPzE(px,py,pz,E);
855 fMassV0 = fMassLambda[iks];
857 if(fMassV0 < invMmin || fMassV0 > invMmax) continue;
860 fPtLambdaC = ksV.Pt();
861 fEtaLambda = ksV.Eta();
862 fPhiLambdaC = ksV.Phi();
865 nSigmaComb2 = TMath::Sqrt(nSigmaTOF2*nSigmaTOF2+ nSigmaTPC2*nSigmaTPC2);
867 nSigmaComb2 = TMath::Abs(nSigmaTPC2);
870 // use sigmaTOF instead of sigmaComb
871 if(tofMatch2) nSigmaComb2 = nSigmaTOF2;
873 if(nSigmaComb2 < 2) nSigmaComb2 = 2;
874 else if(nSigmaComb2 < 3) nSigmaComb2 = 3;
875 else if(nSigmaComb2 < 5) nSigmaComb2 = 4.99;
876 else nSigmaComb2 = 6;
878 Bool_t isTrue = kFALSE;
881 Int_t labelP = TMath::Abs(KpTrack->GetLabel());
882 Int_t labelN = TMath::Abs(KnTrack->GetLabel());
884 if(labelP > -1 && labelN > -1){
885 AliAODMCParticle *partP = (AliAODMCParticle*)mcArray->At(labelP);
886 AliAODMCParticle *partN = (AliAODMCParticle*)mcArray->At(labelN);
888 Int_t mP = partP->GetMother();
889 Int_t mN = partN->GetMother();
890 if(mP == mN && mP > -1){
891 AliAODMCParticle *partM = (AliAODMCParticle*)mcArray->At(mP);
892 Int_t pdgM = partM->GetPdgCode();
893 if(TMath::Abs(pdgM) == 3122) isTrue = kTRUE;
899 Double_t deltaphi1 = KpTrack->Phi() - fPsi;
900 Double_t deltaphi2 = KnTrack->Phi() - fPsi;
902 if(gRandom->Rndm() < 0.5){
903 deltaphi1 += TMath::Pi();
904 deltaphi2 += TMath::Pi();
907 while(deltaphi1 > TMath::Pi()) deltaphi1 -= TMath::Pi()*2;
908 while(deltaphi1 < -TMath::Pi()) deltaphi1 += TMath::Pi()*2;
909 while(deltaphi2 > TMath::Pi()) deltaphi2 -= TMath::Pi()*2;
910 while(deltaphi2 < -TMath::Pi()) deltaphi2 += TMath::Pi()*2;
912 if(fPtKn > 4.299) fPtKn = 4.299;
914 Float_t xTOfill[] = {fPtLambdaC,KpTrack->Eta(),fPtKp,fPtKn,(fPidKp%128)*0.01,(fPidKn%128)*0.01,tofMatch1,tofMatch2,isTrue,nSigmaComb,nSigmaComb2,deltaphi1,deltaphi2,fPsi};
915 Float_t xTOfill2[] = {fPtLambdaC,KpTrack->Eta(),fPtKn,fPtKp,(fPidKn%128)*0.01,(fPidKp%128)*0.01,tofMatch2,tofMatch1,isTrue,nSigmaComb2,nSigmaComb,deltaphi2,deltaphi1,fPsi};
919 while(fPtLambdaMin[ipt] < fPtLambdaC && ipt < nPtBin){
923 if(ipt < 0) ipt = 0; // just to be sure
925 if(TMath::Abs(fEtaLambda) < 0.8 && fPtKp > 0.3 && fPtKn > 0.3){
926 if(fSpeciesRef != 4){
927 xTOfill[4] = probP[fSpeciesRef];
928 xTOfill2[5] = probP[fSpeciesRef];
930 xTOfill[9] = nSigmaCombRef;
931 xTOfill2[10] = nSigmaCombRef;
935 if(isLambda) fContPid->Fill(0,fMassV0,fCentrality,xTOfill);
936 else fContPid2->Fill(0,fMassV0,fCentrality,xTOfill2);
941 Float_t xUser[] = {KpTrack->Eta(),fPtKp,isTrue,0,deltaphi1,fPsi};
943 if(fPIDuserCut->IsSelected(KpTrack,AliPID::kPion)){ // to be filled
945 } else if(fPIDuserCut->IsSelected(KpTrack,AliPID::kKaon)){
947 } else if(fPIDuserCut->IsSelected(KpTrack,AliPID::kProton)){
951 if(isLambda) fContUser->Fill(0,fMassV0,fCentrality,xUser);
952 else fContUser2->Fill(0,fMassV0,fCentrality,xUser);
958 } // end analysi Lambda
961 //_____________________________________________________________________________
962 Float_t AliAnalysisTaskLambdaBayes::GetVertex(AliAODEvent* aod) const
967 const AliAODVertex* vtxAOD = aod->GetPrimaryVertex();
970 if(vtxAOD->GetNContributors()>0)
971 zvtx = vtxAOD->GetZ();
975 //_____________________________________________________________________________
976 void AliAnalysisTaskLambdaBayes::Terminate(Option_t *)
979 Printf("Terminate()");
981 //=======================================================================
982 void AliAnalysisTaskLambdaBayes::SelectLambda(){
987 Int_t nV0s = fOutputAOD->GetNumberOfV0s();
990 for (Int_t i=0; i!=nV0s; ++i) {
991 myV0 = (AliAODv0*) fOutputAOD->GetV0(i);
993 if(myV0->Pt()<0.1 || TMath::Abs(myV0->Eta()) > 0.8) continue; // skipping low momentum
994 Int_t pass = PassesAODCuts(myV0,fOutputAOD,1); // check for Lambda
996 if(pass==1) dMASS = myV0->MassLambda();
997 else dMASS = myV0->MassAntiLambda();
999 Float_t massKs = myV0->MassK0Short();
1001 if(TMath::Abs(dMASS-1.115)/0.005 < 8 && TMath::Abs(massKs - 0.497)/0.005 > 8){
1002 AliAODTrack *iT=(AliAODTrack*) myV0->GetDaughter(0); // positive
1003 AliAODTrack *jT=(AliAODTrack*) myV0->GetDaughter(1); // negative
1005 iT=(AliAODTrack*) myV0->GetDaughter(1); // positive
1006 jT=(AliAODTrack*) myV0->GetDaughter(0); // negative
1008 fPhiLambda[fNLambda] = myV0->Phi();
1009 fPtLambda[fNLambda] = myV0->Pt();
1010 fIpP[fNLambda] = FindDaugheterIndex(iT);
1011 fIpN[fNLambda] = FindDaugheterIndex(jT);
1014 Int_t itemp = fIpP[fNLambda];
1015 fIpP[fNLambda] = fIpN[fNLambda];
1016 fIpN[fNLambda] = itemp;
1019 fMassLambda[fNLambda] = dMASS;
1020 if(fIpP[fNLambda] > -1 && fIpN[fNLambda] > -1){
1029 //=======================================================================
1030 Int_t AliAnalysisTaskLambdaBayes::PassesAODCuts(AliAODv0 *myV0, AliAODEvent *tAOD,Int_t specie)
1032 if (myV0->GetOnFlyStatus() ) return 0;
1034 //the following is needed in order to evualuate track-quality
1035 AliAODTrack *iT, *jT;
1036 AliAODVertex *vV0s = myV0->GetSecondaryVtx();
1037 Double_t pos[3],cov[6];
1039 vV0s->GetCovarianceMatrix(cov);
1040 const AliESDVertex vESD(pos,cov,100.,100);
1044 iT=(AliAODTrack*) myV0->GetDaughter(0);
1045 if(iT->Charge()>0) {
1052 iT=(AliAODTrack*) myV0->GetDaughter(iPos); // positive
1054 jT=(AliAODTrack*) myV0->GetDaughter(iNeg); // negative
1056 Bool_t trkFlag = iT->TestFilterBit(fFilterBit);
1057 if(!trkFlag) return 0;
1058 Bool_t trkFlag2 = jT->TestFilterBit(fFilterBit);
1059 if(!trkFlag2) return 0;
1061 Double_t pvertex[3];
1062 pvertex[0]=tAOD->GetPrimaryVertex()->GetX();
1063 pvertex[1]=tAOD->GetPrimaryVertex()->GetY();
1064 pvertex[2]=tAOD->GetPrimaryVertex()->GetZ();
1066 Double_t dDL=myV0->DecayLengthV0( pvertex );
1067 if(dDL < 0.5 || dDL > 25) return 0;
1069 Double_t dDCA=myV0->DcaV0Daughters();
1070 if(dDCA >0.5) return 0;
1072 Double_t dCTP=myV0->CosPointingAngle( pvertex );
1073 if(dCTP < -1) return 0;
1075 // AliESDtrack ieT( iT );
1076 // Double_t dD0P=ieT.GetD(pvertex[0],pvertex[1],tAOD->GetMagneticField());
1077 // if(TMath::Abs(dD0P) < 0]) return 0;
1079 // AliESDtrack jeT( jT );
1080 // Double_t dD0M=jeT.GetD(pvertex[0],pvertex[1],tAOD->GetMagneticField());
1081 // if(TMath::Abs(dD0M) < 0) return 0;
1083 // Double_t dD0D0=dD0P*dD0M;
1084 // if(dD0D0>0) return 0;
1086 // Double_t dETA=myV0->Eta();
1087 // if(dETA <-0.8) return 0;
1088 // if(dETA >0.8) return 0;
1090 // Double_t dQT=myV0->PtArmV0();
1091 // if(specie==0) if(dQT<???) return 0;
1093 Double_t dALPHA=myV0->AlphaV0(); // AlphaV0 -> AODRecoDecat::Alpha -> return 1.-2./(1.+QlProng(0)/QlProng(1));
1094 if(myV0->ChargeProng(iPos)<0) dALPHA = -dALPHA; // protects for a change in convention
1096 if(specie==1 && dALPHA<0) return 2; // antilambda
1097 return 1; // Ks or lambda
1099 //-------------------------------------------------------------------------
1100 Int_t AliAnalysisTaskLambdaBayes::FindDaugheterIndex(AliAODTrack *trk){
1101 Int_t ntrack = fOutputAOD->GetNumberOfTracks();
1103 for(Int_t i=0;i < ntrack;i++){ // loop on tracks
1104 AliAODTrack* track = fOutputAOD->GetTrack(i);
1105 if(track == trk) return i;
1108 printf("Daughter for %p not found\n",trk);
1111 //-------------------------------------------------------------------------
1112 Int_t AliAnalysisTaskLambdaBayes::IsChannelValid(Float_t etaAbs){
1113 if(!fIsMC) return 1; // used only on MC
1115 if( fTypeCol==2){ // LHC10h or LHC11h because of TOF matching window at 3 cm
1116 Int_t channel = Int_t(4334.09 - 4758.36 * etaAbs -1989.71 * etaAbs*etaAbs + 1957.62*etaAbs*etaAbs*etaAbs);
1118 if(!(channel%20)) return 0; // 5% additional loss in MC