1 /**************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //*************************************************************************
19 // Class AliAnalysisTaskSEDplus
20 // AliAnalysisTaskSE for the D+ candidates Invariant Mass Histogram and
21 //comparison of heavy-flavour decay candidates
22 // to MC truth (kinematics stored in the AOD)
23 // Authors: Renu Bala, bala@to.infn.it
24 // F. Prino, prino@to.infn.it
25 // G. Ortona, ortona@to.infn.it
26 /////////////////////////////////////////////////////////////
28 #include <TClonesArray.h>
33 #include <TDatabasePDG.h>
35 #include "AliAnalysisManager.h"
36 #include "AliRDHFCutsDplustoKpipi.h"
37 #include "AliAODHandler.h"
38 #include "AliAODEvent.h"
39 #include "AliAODVertex.h"
40 #include "AliAODTrack.h"
41 #include "AliAODRecoDecayHF3Prong.h"
42 #include "AliAnalysisVertexingHF.h"
43 #include "AliAnalysisTaskSE.h"
44 #include "AliAnalysisTaskSEDplus.h"
45 #include "AliNormalizationCounter.h"
47 ClassImp(AliAnalysisTaskSEDplus)
50 //________________________________________________________________________
51 AliAnalysisTaskSEDplus::AliAnalysisTaskSEDplus():
72 fUseStrangeness(kFALSE),
81 // Default constructor
84 //________________________________________________________________________
85 AliAnalysisTaskSEDplus::AliAnalysisTaskSEDplus(const char *name,AliRDHFCutsDplustoKpipi *dpluscutsana,AliRDHFCutsDplustoKpipi *dpluscutsprod,Bool_t fillNtuple):
86 AliAnalysisTaskSE(name),
101 fRDCutsProduction(dpluscutsprod),
102 fRDCutsAnalysis(dpluscutsana),
104 fFillNtuple(fillNtuple),
106 fUseStrangeness(kFALSE),
111 fLowerImpPar(-2000.),
112 fHigherImpPar(2000.),
116 // Standrd constructor
118 fNPtBins=fRDCutsAnalysis->GetNPtBins();
120 for(Int_t i=0;i<3;i++){
121 if(fHistCentrality[i])fHistCentrality[i]=0;
122 if(fCorreld0Kd0pi[i])fCorreld0Kd0pi[i]=0;
125 for(Int_t i=0; i<5; i++)fHistMassPtImpParTC[i]=0;
128 for(Int_t i=0;i<3*fNPtBins;i++){
129 if(fMassHist[i])fMassHist[i]=0;
130 if(fCosPHist[i])fCosPHist[i]=0;
131 if(fDLenHist[i])fDLenHist[i]=0;
132 if(fSumd02Hist[i])fSumd02Hist[i]=0;
133 if(fSigVertHist[i])fSigVertHist[i]=0;
134 if(fPtMaxHist[i])fPtMaxHist[i]=0;
135 if(fPtKHist[i])fPtKHist[i]=0;
136 if(fPtpi1Hist[i])fPtpi1Hist[i]=0;
137 if(fPtpi2Hist[i])fPtpi2Hist[i]=0;
138 if(fDCAHist[i])fDCAHist[i]=0;
139 if(fMassHistTC[i])fMassHistTC[i]=0;
140 if(fMassHistTCPlus[i])fMassHistTCPlus[i]=0;
141 if(fMassHistTCMinus[i])fMassHistTCMinus[i]=0;
143 if(fDLxy[i])fDLxy[i]=0;
144 if(fDLxyTC[i])fDLxyTC[i]=0;
145 if(fCosxy[i])fCosxy[i]=0;
146 if(fCosxyTC[i])fCosxyTC[i]=0;
147 if(fMassHistLS[i])fMassHistLS[i]=0;
148 if(fCosPHistLS[i])fCosPHistLS[i]=0;
149 if(fDLenHistLS[i])fDLenHistLS[i]=0;
150 if(fSumd02HistLS[i])fSumd02HistLS[i]=0;
151 if(fSigVertHistLS[i])fSigVertHistLS[i]=0;
152 if(fPtMaxHistLS[i])fPtMaxHistLS[i]=0;
153 if(fDCAHistLS[i])fDCAHistLS[i]=0;
154 if(fMassHistLSTC[i])fMassHistLSTC[i]=0;
159 // Default constructor
160 // Output slot #1 writes into a TList container
161 DefineOutput(1,TList::Class()); //My private output
162 // Output slot #2 writes cut to private output
163 // DefineOutput(2,AliRDHFCutsDplustoKpipi::Class());
164 DefineOutput(2,TList::Class());
165 // Output slot #3 writes cut to private output
166 DefineOutput(3,AliNormalizationCounter::Class());
169 // Output slot #4 writes into a TNtuple container
170 DefineOutput(4,TNtuple::Class()); //My private output
174 //________________________________________________________________________
175 AliAnalysisTaskSEDplus::~AliAnalysisTaskSEDplus()
188 for(Int_t i=0;i<3;i++){
189 if(fHistCentrality[i]){delete fHistCentrality[i]; fHistCentrality[i]=0;}
192 for(Int_t i=0;i<3*fNPtBins;i++){
193 if(fMassHist[i]){ delete fMassHist[i]; fMassHist[i]=0;}
194 if(fCosPHist[i]){ delete fCosPHist[i]; fCosPHist[i]=0;}
195 if(fDLenHist[i]){ delete fDLenHist[i]; fDLenHist[i]=0;}
196 if(fSumd02Hist[i]){ delete fSumd02Hist[i]; fSumd02Hist[i]=0;}
197 if(fSigVertHist[i]){ delete fSigVertHist[i]; fSigVertHist[i]=0;}
198 if(fPtMaxHist[i]){ delete fPtMaxHist[i]; fPtMaxHist[i]=0;}
199 if(fPtKHist[i]){ delete fPtKHist[i]; fPtKHist[i]=0;}
200 if(fPtpi1Hist[i]){ delete fPtpi1Hist[i]; fPtpi1Hist[i]=0;}
201 if(fPtpi2Hist[i]){ delete fPtpi2Hist[i]; fPtpi2Hist[i]=0;}
202 if(fDCAHist[i]){ delete fDCAHist[i]; fDCAHist[i]=0;}
203 if(fMassHistTC[i]){ delete fMassHistTC[i]; fMassHistTC[i]=0;}
204 if(fMassHistTCPlus[i]){ delete fMassHistTCPlus[i]; fMassHistTCPlus[i]=0;}
205 if(fMassHistTCMinus[i]){ delete fMassHistTCMinus[i]; fMassHistTCMinus[i]=0;}
207 if(fDLxy[i]){delete fDLxy[i]; fDLxy[i]=0;}
208 if(fDLxyTC[i]){delete fDLxyTC[i]; fDLxyTC[i]=0;}
209 if(fCosxy[i]){delete fCosxy[i]; fCosxy[i]=0;}
210 if(fCosxyTC[i]){delete fCosxyTC[i]; fCosxyTC[i]=0;}
211 if(fMassHistLS[i]){ delete fMassHistLS[i]; fMassHistLS[i]=0;}
212 if(fCosPHistLS[i]){ delete fCosPHistLS[i]; fCosPHistLS[i]=0;}
213 if(fDLenHistLS[i]){ delete fDLenHistLS[i]; fDLenHistLS[i]=0;}
214 if(fSumd02HistLS[i]){ delete fSumd02HistLS[i]; fSumd02HistLS[i]=0;}
215 if(fSigVertHistLS[i]){ delete fSigVertHistLS[i]; fSigVertHistLS[i]=0;}
216 if(fPtMaxHistLS[i]){ delete fPtMaxHistLS[i]; fPtMaxHistLS[i]=0;}
217 if(fDCAHistLS[i]){ delete fDCAHistLS[i]; fDCAHistLS[i]=0;}
218 if(fMassHistLSTC[i]){ delete fMassHistLSTC[i]; fMassHistLSTC[i]=0;}
221 for(Int_t i=0;i<3;i++){
222 if(fCorreld0Kd0pi[i]){ delete fCorreld0Kd0pi[i]; fCorreld0Kd0pi[i]=0;}
257 if(fRDCutsProduction){
258 delete fRDCutsProduction;
259 fRDCutsProduction = 0;
262 delete fRDCutsAnalysis;
265 for(Int_t i=0; i<5; i++){
266 delete fHistMassPtImpParTC[i];
275 //_________________________________________________________________
276 void AliAnalysisTaskSEDplus::SetMassLimits(Float_t range){
277 // set invariant mass limits
278 Float_t bw=GetBinWidth();
279 fUpmasslimit = 1.865+range;
280 fLowmasslimit = 1.865-range;
283 //_________________________________________________________________
284 void AliAnalysisTaskSEDplus::SetMassLimits(Float_t lowlimit, Float_t uplimit){
285 // set invariant mass limits
288 Float_t bw=GetBinWidth();
289 fUpmasslimit = lowlimit;
290 fLowmasslimit = uplimit;
294 //________________________________________________________________
295 void AliAnalysisTaskSEDplus::SetBinWidth(Float_t w){
297 Int_t nbins=(Int_t)((fUpmasslimit-fLowmasslimit)/width+0.5);
298 Int_t missingbins=4-nbins%4;
299 nbins=nbins+missingbins;
300 width=(fUpmasslimit-fLowmasslimit)/nbins;
302 printf("AliAnalysisTaskSEDplus::SetBinWidth: W-bin width of %f will produce histograms not rebinnable by 4. New width set to %f\n",w,width);
305 if(fDebug>1) printf("AliAnalysisTaskSEDplus::SetBinWidth: width set to %f\n",width);
309 //_________________________________________________________________
310 Int_t AliAnalysisTaskSEDplus::GetNBinsHistos(){
311 return (Int_t)((fUpmasslimit-fLowmasslimit)/fBinWidth+0.5);
313 //_________________________________________________________________
314 void AliAnalysisTaskSEDplus::LSAnalysis(TClonesArray *arrayOppositeSign,TClonesArray *arrayLikeSign,AliAODEvent *aod,AliAODVertex *vtx1, Int_t nDplusOS){
317 // Fill the Like Sign histograms
319 if(fDebug>1)printf("started LS\n");
321 //histograms for like sign
322 Int_t nbins=GetNBinsHistos();;
323 TH1F *histLSPlus = new TH1F("LSPlus","LSPlus",nbins,fLowmasslimit,fUpmasslimit);
324 TH1F *histLSMinus = new TH1F("LSMinus","LSMinus",nbins,fLowmasslimit,fUpmasslimit);
326 Int_t nPosTrks=0,nNegTrks=0;
327 Int_t nOStriplets = arrayOppositeSign->GetEntriesFast();
330 Int_t nLikeSign = arrayLikeSign->GetEntriesFast();
333 // loop over like sign candidates
334 for(Int_t iLikeSign = 0; iLikeSign < nLikeSign; iLikeSign++) {
335 AliAODRecoDecayHF3Prong *d = (AliAODRecoDecayHF3Prong*)arrayLikeSign->UncheckedAt(iLikeSign);
336 if(fUseBit && !d->HasSelectionBit(AliRDHFCuts::kDplusCuts))continue;
337 Bool_t unsetvtx=kFALSE;
338 if(!d->GetOwnPrimaryVtx()) {
339 d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
342 Double_t ptCand = d->Pt();
343 Int_t iPtBin = fRDCutsAnalysis->PtBin(ptCand);
344 if(iPtBin<0)continue;
345 Int_t sign= d->GetCharge();
351 // if(fRDCutsProduction->IsSelected(d,AliRDHFCuts::kCandidate,aod)){
352 fRDCutsAnalysis->IsSelected(d,AliRDHFCuts::kCandidate,aod);
353 Int_t passTightCuts=fRDCutsAnalysis->GetIsSelectedCuts();
355 Float_t invMass = d->InvMassDplus();
356 index=GetLSHistoIndex(iPtBin);
357 fMassHistLS[index+1]->Fill(invMass);
359 histLSPlus->Fill(invMass);
362 histLSMinus->Fill(invMass);
366 Double_t dlen=d->DecayLength();
367 Double_t cosp=d->CosPointingAngle();
368 Double_t sumD02=d->Getd0Prong(0)*d->Getd0Prong(0)+d->Getd0Prong(1)*d->Getd0Prong(1)+d->Getd0Prong(2)*d->Getd0Prong(2);
369 Double_t dca=d->GetDCA();
370 Double_t sigvert=d->GetSigmaVert();
372 for(Int_t i=0;i<3;i++){
373 if(d->PtProng(i)>ptmax)ptmax=d->PtProng(i);
375 fCosPHistLS[iPtBin]->Fill(cosp);
376 fDLenHistLS[iPtBin]->Fill(dlen);
377 fSumd02HistLS[iPtBin]->Fill(sumD02);
378 fSigVertHistLS[iPtBin]->Fill(sigvert);
379 fPtMaxHistLS[iPtBin]->Fill(ptmax);
380 fDCAHistLS[iPtBin]->Fill(dca);
383 if(unsetvtx) d->UnsetOwnPrimaryVtx();
385 //wei:normalized to the number of combinations (production)
386 //wei2:normalized to the number of LS/OS (production)
387 //wei3:normalized to the number of LS/OS (analysis)
388 //wei4:normalized to the number of combinations (analysis)
390 if(nLikeSign!=0)wei2 = (Float_t)nOStriplets/(Float_t)nLikeSign;
392 if(nDplusLS!=0)wei3 = (Float_t)nDplusOS/(Float_t)(nDplusLS+nDminusLS);
393 Float_t weiplus=1.,weiminus=1.;
394 Float_t wei4plus=1.,wei4minus=1.;
395 //wei* should be automatically protected, since to get a triplet there must be at least 3 good tracks in the event
396 if(nPosTrks>2)weiplus=3.*(Float_t)nNegTrks/((Float_t)nPosTrks-2.);
397 if(nDplusLS>2)wei4plus=3.*(Float_t)nDminusLS/((Float_t)nDplusLS-2.);
398 if(nNegTrks>2)weiminus=3.*(Float_t)nPosTrks/((Float_t)nNegTrks-2.);
399 if(nDminusLS>2)wei4minus=3.*(Float_t)nDplusLS/((Float_t)nDminusLS-2.);
401 fMassHistLS[index]->Add(histLSPlus,weiplus);
402 fMassHistLS[index]->Add(histLSMinus,weiminus);
403 fMassHistLS[index+2]->Add(histLSPlus,wei2);
404 fMassHistLS[index+2]->Add(histLSMinus,wei2);
405 fMassHistLS[index+3]->Add(histLSPlus,wei3);
406 fMassHistLS[index+3]->Add(histLSMinus,wei3);
407 fMassHistLS[index+4]->Add(histLSPlus,wei4plus);
408 fMassHistLS[index+4]->Add(histLSMinus,wei4minus);
410 delete histLSPlus;histLSPlus=0;
411 delete histLSMinus;histLSMinus=0;
413 if(fDebug>1) printf("LS analysis terminated\n");
416 //__________________________________________
417 void AliAnalysisTaskSEDplus::Init(){
421 if(fDebug > 1) printf("AnalysisTaskSEDplus::Init() \n");
423 //PostData(2,fRDCutsloose);//we should then put those cuts in a tlist if we have more than 1
424 fListCuts=new TList();
425 AliRDHFCutsDplustoKpipi *production = new AliRDHFCutsDplustoKpipi(*fRDCutsProduction);
426 production->SetName("ProductionCuts");
427 AliRDHFCutsDplustoKpipi *analysis = new AliRDHFCutsDplustoKpipi(*fRDCutsAnalysis);
428 analysis->SetName("AnalysisCuts");
430 fListCuts->Add(production);
431 fListCuts->Add(analysis);
432 PostData(2,fListCuts);
437 //________________________________________________________________________
438 void AliAnalysisTaskSEDplus::UserCreateOutputObjects()
440 // Create the output container
442 if(fDebug > 1) printf("AnalysisTaskSEDplus::UserCreateOutputObjects() \n");
444 // Several histograms are more conveniently managed in a TList
445 fOutput = new TList();
447 fOutput->SetName("OutputHistos");
451 Int_t nbins=GetNBinsHistos();
452 fHistCentrality[0]=new TH1F("centrality","centrality",100,0.5,30000.5);
453 fHistCentrality[1]=new TH1F("centrality(selectedCent)","centrality(selectedCent)",100,0.5,30000.5);
454 fHistCentrality[2]=new TH1F("centrality(OutofCent)","centrality(OutofCent)",100,0.5,30000.5);
455 for(Int_t i=0;i<3;i++){
456 fHistCentrality[i]->Sumw2();
457 fOutput->Add(fHistCentrality[i]);
459 for(Int_t i=0;i<fNPtBins;i++){
461 index=GetHistoIndex(i);
463 hisname.Form("hMassPt%d",i);
464 fMassHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
465 fMassHist[index]->Sumw2();
466 hisname.Form("hCosPAllPt%d",i);
467 fCosPHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,1.);
468 fCosPHist[index]->Sumw2();
469 hisname.Form("hDLenAllPt%d",i);
470 fDLenHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.5);
471 fDLenHist[index]->Sumw2();
472 hisname.Form("hSumd02AllPt%d",i);
473 fSumd02Hist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,1.);
474 fSumd02Hist[index]->Sumw2();
475 hisname.Form("hSigVertAllPt%d",i);
476 fSigVertHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
477 fSigVertHist[index]->Sumw2();
478 hisname.Form("hPtMaxAllPt%d",i);
479 fPtMaxHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
480 fPtMaxHist[index]->Sumw2();
481 hisname.Form("hPtKPt%d",i);
482 fPtKHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
483 fPtKHist[index]->Sumw2();
484 hisname.Form("hPtpi1Pt%d",i);
485 fPtpi1Hist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
486 fPtpi1Hist[index]->Sumw2();
487 hisname.Form("hPtpi2Pt%d",i);
488 fPtpi2Hist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
489 fPtpi2Hist[index]->Sumw2();
490 hisname.Form("hDCAAllPt%d",i);
491 fDCAHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
492 fDCAHist[index]->Sumw2();
494 hisname.Form("hDLxyPt%d",i);
495 fDLxy[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,10.);
496 fDLxy[index]->Sumw2();
497 hisname.Form("hCosxyPt%d",i);
498 fCosxy[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.85,1.);
499 fCosxy[index]->Sumw2();
500 hisname.Form("hDLxyPt%dTC",i);
501 fDLxyTC[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,10.);
502 fDLxyTC[index]->Sumw2();
503 hisname.Form("hCosxyPt%dTC",i);
504 fCosxyTC[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.85,1.);
505 fCosxyTC[index]->Sumw2();
507 hisname.Form("hMassPt%dTC",i);
508 fMassHistTC[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
509 fMassHistTC[index]->Sumw2();
510 hisname.Form("hMassPt%dTCPlus",i);
511 fMassHistTCPlus[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
512 fMassHistTCPlus[index]->Sumw2();
513 hisname.Form("hMassPt%dTCMinus",i);
514 fMassHistTCMinus[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
515 fMassHistTCMinus[index]->Sumw2();
519 index=GetSignalHistoIndex(i);
520 hisname.Form("hSigPt%d",i);
521 fMassHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
522 fMassHist[index]->Sumw2();
523 hisname.Form("hCosPSigPt%d",i);
524 fCosPHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,1.);
525 fCosPHist[index]->Sumw2();
526 hisname.Form("hDLenSigPt%d",i);
527 fDLenHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.5);
528 fDLenHist[index]->Sumw2();
529 hisname.Form("hSumd02SigPt%d",i);
530 fSumd02Hist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,1.);
531 fSumd02Hist[index]->Sumw2();
532 hisname.Form("hSigVertSigPt%d",i);
533 fSigVertHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
534 fSigVertHist[index]->Sumw2();
535 hisname.Form("hPtMaxSigPt%d",i);
536 fPtMaxHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
537 fPtMaxHist[index]->Sumw2();
538 hisname.Form("hPtKSigPt%d",i);
539 fPtKHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
540 fPtKHist[index]->Sumw2();
541 hisname.Form("hPtpi1SigPt%d",i);
542 fPtpi1Hist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
543 fPtpi1Hist[index]->Sumw2();
544 hisname.Form("hPtpi2SigPt%d",i);
545 fPtpi2Hist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
546 fPtpi2Hist[index]->Sumw2();
548 hisname.Form("hDCASigPt%d",i);
549 fDCAHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
550 fDCAHist[index]->Sumw2();
552 hisname.Form("hDLxySigPt%d",i);
553 fDLxy[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,10.);
554 fDLxy[index]->Sumw2();
555 hisname.Form("hCosxySigPt%d",i);
556 fCosxy[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.85,1.);
557 fCosxy[index]->Sumw2();
558 hisname.Form("hDLxySigPt%dTC",i);
559 fDLxyTC[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,10.);
560 fDLxyTC[index]->Sumw2();
561 hisname.Form("hCosxySigPt%dTC",i);
562 fCosxyTC[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.85,1.);
563 fCosxyTC[index]->Sumw2();
564 hisname.Form("hSigPt%dTC",i);
565 fMassHistTC[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
566 fMassHistTC[index]->Sumw2();
567 hisname.Form("hSigPt%dTCPlus",i);
568 fMassHistTCPlus[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
569 fMassHistTCPlus[index]->Sumw2();
570 hisname.Form("hSigPt%dTCMinus",i);
571 fMassHistTCMinus[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
572 fMassHistTCMinus[index]->Sumw2();
575 index=GetBackgroundHistoIndex(i);
576 hisname.Form("hBkgPt%d",i);
577 fMassHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
578 fMassHist[index]->Sumw2();
579 hisname.Form("hCosPBkgPt%d",i);
580 fCosPHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,1.);
581 fCosPHist[index]->Sumw2();
582 hisname.Form("hDLenBkgPt%d",i);
583 fDLenHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.5);
584 fDLenHist[index]->Sumw2();
585 hisname.Form("hSumd02BkgPt%d",i);
586 fSumd02Hist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,1.);
587 fSumd02Hist[index]->Sumw2();
588 hisname.Form("hSigVertBkgPt%d",i);
589 fSigVertHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
590 fSigVertHist[index]->Sumw2();
591 hisname.Form("hPtMaxBkgPt%d",i);
592 fPtMaxHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
593 fPtMaxHist[index]->Sumw2();
594 hisname.Form("hPtKBkgPt%d",i);
595 fPtKHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
596 fPtKHist[index]->Sumw2();
597 hisname.Form("hPtpi1BkgPt%d",i);
598 fPtpi1Hist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
599 fPtpi1Hist[index]->Sumw2();
600 hisname.Form("hPtpi2BkgPt%d",i);
601 fPtpi2Hist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
602 fPtpi2Hist[index]->Sumw2();
603 hisname.Form("hDCABkgPt%d",i);
604 fDCAHist[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
605 fDCAHist[index]->Sumw2();
607 hisname.Form("hDLxyBkgPt%d",i);
608 fDLxy[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,10.);
609 fDLxy[index]->Sumw2();
610 hisname.Form("hCosxyBkgPt%d",i);
611 fCosxy[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.85,1.);
612 fCosxy[index]->Sumw2();
613 hisname.Form("hDLxyBkgPt%dTC",i);
614 fDLxyTC[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,10.);
615 fDLxyTC[index]->Sumw2();
616 hisname.Form("hCosxyBkgPt%dTC",i);
617 fCosxyTC[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.85,1.);
618 fCosxyTC[index]->Sumw2();
621 hisname.Form("hBkgPt%dTC",i);
622 fMassHistTC[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
623 fMassHistTC[index]->Sumw2();
624 hisname.Form("hBkgPt%dTCPlus",i);
625 fMassHistTCPlus[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
626 fMassHistTCPlus[index]->Sumw2();
627 hisname.Form("hBkgPt%dTCMinus",i);
628 fMassHistTCMinus[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
629 fMassHistTCMinus[index]->Sumw2();
633 for(Int_t i=0; i<3*fNPtBins; i++){
634 fOutput->Add(fMassHist[i]);
636 fOutput->Add(fCosPHist[i]);
637 fOutput->Add(fDLenHist[i]);
638 fOutput->Add(fSumd02Hist[i]);
639 fOutput->Add(fSigVertHist[i]);
640 fOutput->Add(fPtMaxHist[i]);
641 fOutput->Add(fPtKHist[i]);
642 fOutput->Add(fPtpi1Hist[i]);
643 fOutput->Add(fPtpi2Hist[i]);
644 fOutput->Add(fDCAHist[i]);
645 fOutput->Add(fDLxy[i]);
646 fOutput->Add(fDLxyTC[i]);
647 fOutput->Add(fCosxy[i]);
648 fOutput->Add(fCosxyTC[i]);
650 fOutput->Add(fMassHistTC[i]);
651 fOutput->Add(fMassHistTCPlus[i]);
652 fOutput->Add(fMassHistTCMinus[i]);
657 fCorreld0Kd0pi[0]=new TH2F("hCorreld0Kd0piAll","",100,-0.02,0.02,100,-0.02,0.02);
658 fCorreld0Kd0pi[1]=new TH2F("hCorreld0Kd0piSig","",100,-0.02,0.02,100,-0.02,0.02);
659 fCorreld0Kd0pi[2]=new TH2F("hCorreld0Kd0piBkg","",100,-0.02,0.02,100,-0.02,0.02);
660 for(Int_t i=0; i<3; i++){
661 fCorreld0Kd0pi[i]->Sumw2();
662 fOutput->Add(fCorreld0Kd0pi[i]);
666 fHistNEvents = new TH1F("fHistNEvents", "number of events ",9,-0.5,8.5);
667 fHistNEvents->GetXaxis()->SetBinLabel(1,"nEventsAnal");
668 fHistNEvents->GetXaxis()->SetBinLabel(2,"nEvents with good vertex");
669 fHistNEvents->GetXaxis()->SetBinLabel(3,"nEvents with PbPb HM trigger");
670 fHistNEvents->GetXaxis()->SetBinLabel(4,"no. of Rejected pileup events");
671 fHistNEvents->GetXaxis()->SetBinLabel(5,"no. of candidate");
672 fHistNEvents->GetXaxis()->SetBinLabel(6,"no. of D+ after loose cuts");
673 fHistNEvents->GetXaxis()->SetBinLabel(7,"no. of D+ after tight cuts");
674 fHistNEvents->GetXaxis()->SetBinLabel(8,"no. of out centrality events");
675 fHistNEvents->GetXaxis()->SetBinLabel(9,"no. of cand wo bitmask");
676 fHistNEvents->GetXaxis()->SetNdivisions(1,kFALSE);
677 fHistNEvents->Sumw2();
678 fHistNEvents->SetMinimum(0);
679 fOutput->Add(fHistNEvents);
681 fPtVsMass=new TH2F("hPtVsMass","PtVsMass (prod. cuts)",nbins,fLowmasslimit,fUpmasslimit,200,0.,20.);
682 fPtVsMassTC=new TH2F("hPtVsMassTC","PtVsMass (analysis cuts)",nbins,fLowmasslimit,fUpmasslimit,200,0.,20.);
683 fYVsPt=new TH2F("hYVsPt","YvsPt (prod. cuts)",40,0.,20.,80,-2.,2.);
684 fYVsPtTC=new TH2F("hYVsPtTC","YvsPt (analysis cuts)",40,0.,20.,80,-2.,2.);
685 fYVsPtSig=new TH2F("hYVsPtSig","YvsPt (MC, only sig., prod. cuts)",40,0.,20.,80,-2.,2.);
686 fYVsPtSigTC=new TH2F("hYVsPtSigTC","YvsPt (MC, only Sig, analysis cuts)",40,0.,20.,80,-2.,2.);
688 fOutput->Add(fPtVsMass);
689 fOutput->Add(fPtVsMassTC);
690 fOutput->Add(fYVsPt);
691 fOutput->Add(fYVsPtTC);
692 fOutput->Add(fYVsPtSig);
693 fOutput->Add(fYVsPtSigTC);
696 //Counter for Normalization
697 TString normName="NormalizationCounter";
698 AliAnalysisDataContainer *cont = GetOutputSlot(3)->GetContainer();
699 if(cont)normName=(TString)cont->GetName();
700 fCounter = new AliNormalizationCounter(normName.Data());
703 if(fDoLS) CreateLikeSignHistos();
704 if(fDoImpPar) CreateImpactParameterHistos();
707 OpenFile(4); // 4 is the slot number of the ntuple
709 fNtupleDplus = new TNtuple("fNtupleDplus","D +","pdg:Px:Py:Pz:PtTrue:VxTrue:VyTrue:VzTrue:Ptpi:PtK:Ptpi2:PtRec:PointingAngle:DecLeng:VxRec:VyRec:VzRec:InvMass:sigvert:d0Pi:d0K:d0Pi2:dca:d0square");
716 //________________________________________________________________________
717 void AliAnalysisTaskSEDplus::UserExec(Option_t */*option*/)
719 // Execute analysis for current event:
720 // heavy flavor candidates association to MC truth
722 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
726 TClonesArray *array3Prong = 0;
727 TClonesArray *arrayLikeSign =0;
728 if(!aod && AODEvent() && IsStandardAOD()) {
729 // In case there is an AOD handler writing a standard AOD, use the AOD
730 // event in memory rather than the input (ESD) event.
731 aod = dynamic_cast<AliAODEvent*> (AODEvent());
732 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
733 // have to taken from the AOD event hold by the AliAODExtension
734 AliAODHandler* aodHandler = (AliAODHandler*)
735 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
736 if(aodHandler->GetExtensions()) {
737 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
738 AliAODEvent *aodFromExt = ext->GetAOD();
739 array3Prong=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong");
740 arrayLikeSign=(TClonesArray*)aodFromExt->GetList()->FindObject("LikeSign3Prong");
743 array3Prong=(TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
744 arrayLikeSign=(TClonesArray*)aod->GetList()->FindObject("LikeSign3Prong");
747 if(!aod || !array3Prong) {
748 printf("AliAnalysisTaskSEDplus::UserExec: Charm3Prong branch not found!\n");
751 if(!arrayLikeSign && fDoLS) {
752 printf("AliAnalysisTaskSEDplus::UserExec: LikeSign3Prong branch not found!\n");
757 // fix for temporary bug in ESDfilter
758 // the AODs with null vertex pointer didn't pass the PhysSel
759 if(!aod->GetPrimaryVertex()||TMath::Abs(aod->GetMagneticField())<0.001) return;
760 fCounter->StoreEvent(aod,fRDCutsAnalysis,fReadMC);
761 fHistNEvents->Fill(0); // count event
763 Bool_t isEvSel=fRDCutsAnalysis->IsEventSelected(aod);
764 Bool_t isEvSelP=kTRUE;
765 isEvSelP=fRDCutsProduction->IsEventSelected(aod); // to have proper PID object settings
767 Float_t centrality=aod->GetNTracks();//fRDCutsAnalysis->GetCentrality(aod);
768 fHistCentrality[0]->Fill(centrality);
769 // trigger class for PbPb C0SMH-B-NOPF-ALLNOTRD
770 TString trigclass=aod->GetFiredTriggerClasses();
771 if(trigclass.Contains("C0SMH-B-NOPF-ALLNOTRD")||trigclass.Contains("C0SMH-B-NOPF-ALL")) fHistNEvents->Fill(2);
772 if(fRDCutsAnalysis->GetWhyRejection()==1)fHistNEvents->Fill(3);
773 if(fRDCutsAnalysis->GetWhyRejection()==2){fHistNEvents->Fill(7);fHistCentrality[2]->Fill(centrality);}
775 // Post the data already here
779 fHistCentrality[1]->Fill(centrality);
780 fHistNEvents->Fill(1);
782 TClonesArray *arrayMC=0;
783 AliAODMCHeader *mcHeader=0;
785 // AOD primary vertex
786 AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
788 TString primTitle = vtx1->GetTitle();
789 //if(primTitle.Contains("VertexerTracks") && vtx1->GetNContributors()>0)fHistNEvents->Fill(2);
794 arrayMC = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
796 printf("AliAnalysisTaskSEDplus::UserExec: MC particles branch not found!\n");
801 mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
803 printf("AliAnalysisTaskSEDplus::UserExec: MC header branch not found!\n");
808 Int_t n3Prong = array3Prong->GetEntriesFast();
809 // printf("Number of D+->Kpipi: %d and of tracks: %d\n",n3Prong,aod->GetNumberOfTracks());
814 Int_t pdgDgDplustoKpipi[3]={321,211,211};
817 for (Int_t i3Prong = 0; i3Prong < n3Prong; i3Prong++) {
818 AliAODRecoDecayHF3Prong *d = (AliAODRecoDecayHF3Prong*)array3Prong->UncheckedAt(i3Prong);
819 if(fUseBit && !d->HasSelectionBit(AliRDHFCuts::kDplusCuts)){
820 if(fRDCutsAnalysis->IsSelected(d,AliRDHFCuts::kCandidate,aod))nOS++;
824 // Double_t cutsDplus[12]={0.2,0.4,0.4,0.,0.,0.01,0.06,0.02,0.,0.85,0.,10000000000.};//TO REMOVE
825 //Double_t *cutsDplus = new (Double_t*)fRDCuts->GetCuts();
826 Int_t nSelectedloose=0,nSelectedtight=0;
827 for (Int_t i3Prong = 0; i3Prong < n3Prong; i3Prong++) {
828 AliAODRecoDecayHF3Prong *d = (AliAODRecoDecayHF3Prong*)array3Prong->UncheckedAt(i3Prong);
829 fHistNEvents->Fill(4);
830 if(fUseBit && !d->HasSelectionBit(AliRDHFCuts::kDplusCuts)){
831 fHistNEvents->Fill(8);
834 Bool_t unsetvtx=kFALSE;
835 if(!d->GetOwnPrimaryVtx()){
836 d->SetOwnPrimaryVtx(vtx1);
840 if(fRDCutsProduction->IsSelected(d,AliRDHFCuts::kCandidate,aod)) {
842 Double_t ptCand = d->Pt();
843 Int_t iPtBin = fRDCutsProduction->PtBin(ptCand);
845 Int_t passTightCuts=fRDCutsAnalysis->IsSelected(d,AliRDHFCuts::kCandidate,aod);
846 Bool_t recVtx=kFALSE;
847 AliAODVertex *origownvtx=0x0;
848 if(fRDCutsProduction->GetIsPrimaryWithoutDaughters()){
849 if(d->GetOwnPrimaryVtx()) origownvtx=new AliAODVertex(*d->GetOwnPrimaryVtx());
850 if(fRDCutsProduction->RecalcOwnPrimaryVtx(d,aod))recVtx=kTRUE;
851 else fRDCutsProduction->CleanOwnPrimaryVtx(d,aod,origownvtx);
855 Bool_t isPrimary=kTRUE;
864 Float_t trueImpParXY=0.;
866 labDp = d->MatchToMC(411,arrayMC,3,pdgDgDplustoKpipi);
868 AliAODMCParticle *partDp = (AliAODMCParticle*)arrayMC->At(labDp);
869 if(CheckOrigin(arrayMC,partDp)==5) isPrimary=kFALSE;
870 AliAODMCParticle *dg0 = (AliAODMCParticle*)arrayMC->At(partDp->GetDaughter(0));
871 deltaPx=partDp->Px()-d->Px();
872 deltaPy=partDp->Py()-d->Py();
873 deltaPz=partDp->Pz()-d->Pz();
878 pdgCode=TMath::Abs(partDp->GetPdgCode());
880 trueImpParXY=GetTrueImpactParameter(mcHeader,arrayMC,partDp)*10000.;
887 Double_t invMass=d->InvMassDplus();
888 Double_t rapid=d->YDplus();
889 fYVsPt->Fill(ptCand,rapid);
890 if(passTightCuts) {fYVsPtTC->Fill(ptCand,rapid);nOS++;}
891 Bool_t isFidAcc=fRDCutsAnalysis->IsInFiducialAcceptance(ptCand,rapid);
893 fPtVsMass->Fill(invMass,ptCand);
894 if(passTightCuts) fPtVsMassTC->Fill(invMass,ptCand);
897 Double_t dlen=d->DecayLength();
898 Double_t cosp=d->CosPointingAngle();
899 Double_t sumD02=d->Getd0Prong(0)*d->Getd0Prong(0)+d->Getd0Prong(1)*d->Getd0Prong(1)+d->Getd0Prong(2)*d->Getd0Prong(2);
900 Double_t dca=d->GetDCA();
901 Double_t sigvert=d->GetSigmaVert();
903 for(Int_t i=0;i<3;i++){
904 if(d->PtProng(i)>ptmax)ptmax=d->PtProng(i);
906 Double_t impparXY=d->ImpParXY()*10000.;
907 Double_t arrayForSparse[3]={invMass,ptCand,impparXY};
908 Double_t arrayForSparseTrue[3]={invMass,ptCand,trueImpParXY};
918 tmp[8]=d->PtProng(0);
919 tmp[9]=d->PtProng(1);
920 tmp[10]=d->PtProng(2);
927 tmp[17]=d->InvMassDplus();
929 tmp[19]=d->Getd0Prong(0);
930 tmp[20]=d->Getd0Prong(1);
931 tmp[21]=d->Getd0Prong(2);
933 tmp[23]=d->Prodd0d0();
934 fNtupleDplus->Fill(tmp);
935 PostData(4,fNtupleDplus);
938 Float_t dlxy=d->NormalizedDecayLengthXY();
939 Float_t cxy=d->CosPointingAngleXY();
940 index=GetHistoIndex(iPtBin);
942 fHistNEvents->Fill(5);
944 fMassHist[index]->Fill(invMass);
946 fCosPHist[index]->Fill(cosp);
947 fDLenHist[index]->Fill(dlen);
948 fSumd02Hist[index]->Fill(sumD02);
949 fSigVertHist[index]->Fill(sigvert);
950 fPtMaxHist[index]->Fill(ptmax);
951 fPtKHist[index]->Fill(d->PtProng(1));
952 fPtpi1Hist[index]->Fill(d->PtProng(0));
953 fPtpi2Hist[index]->Fill(d->PtProng(2));
954 fDCAHist[index]->Fill(dca);
955 fDLxy[index]->Fill(dlxy);
956 fCosxy[index]->Fill(cxy);
957 fCorreld0Kd0pi[0]->Fill(d->Getd0Prong(0)*d->Getd0Prong(1),
958 d->Getd0Prong(2)*d->Getd0Prong(1));
960 if(passTightCuts){ fHistNEvents->Fill(6);
962 fMassHistTC[index]->Fill(invMass);
964 fDLxyTC[index]->Fill(dlxy);
965 fCosxyTC[index]->Fill(cxy);
967 if(d->GetCharge()>0) fMassHistTCPlus[index]->Fill(invMass);
968 else if(d->GetCharge()<0) fMassHistTCMinus[index]->Fill(invMass);
970 fHistMassPtImpParTC[0]->Fill(arrayForSparse);
978 index=GetSignalHistoIndex(iPtBin);
980 Float_t factor[3]={1.,1.,1.};
982 for(Int_t iprong=0;iprong<3;iprong++){
983 AliAODTrack *trad = (AliAODTrack*)d->GetDaughter(iprong);
984 Int_t labd= trad->GetLabel();
986 AliAODMCParticle *dau = (AliAODMCParticle*)arrayMC->At(labd);
988 Int_t labm = dau->GetMother();
990 AliAODMCParticle *mot = (AliAODMCParticle*)arrayMC->At(labm);
992 if(TMath::Abs(mot->GetPdgCode())==310 || TMath::Abs(mot->GetPdgCode())==130 || TMath::Abs(mot->GetPdgCode())==321){ //K0_S, K0_L, K^+-
993 if(d->PtProng(iprong)<=1)factor[iprong]=1./.7;
994 else factor[iprong]=1./.6;
995 // fNentries->Fill(12);
997 if(TMath::Abs(mot->GetPdgCode())==3122) { //Lambda
998 factor[iprong]=1./0.25;
999 // fNentries->Fill(13);
1007 Float_t fact=1.;for(Int_t k=0;k<3;k++)fact=fact*factor[k];
1008 fMassHist[index]->Fill(invMass);
1010 fCosPHist[index]->Fill(cosp,fact);
1011 fDLenHist[index]->Fill(dlen,fact);
1012 fDLxy[index]->Fill(dlxy);
1013 fCosxy[index]->Fill(cxy);
1015 Float_t sumd02s=d->Getd0Prong(0)*d->Getd0Prong(0)*factor[0]*factor[0]+d->Getd0Prong(1)*d->Getd0Prong(1)*factor[1]*factor[1]+d->Getd0Prong(2)*d->Getd0Prong(2)*factor[2]*factor[2];
1016 fSumd02Hist[index]->Fill(sumd02s);
1017 fSigVertHist[index]->Fill(sigvert,fact);
1018 fPtMaxHist[index]->Fill(ptmax,fact);
1019 fPtKHist[index]->Fill(d->PtProng(1),fact);
1020 fPtpi1Hist[index]->Fill(d->PtProng(0),fact);
1021 fPtpi2Hist[index]->Fill(d->PtProng(2),fact);
1022 fDCAHist[index]->Fill(dca,fact);
1023 fCorreld0Kd0pi[1]->Fill(d->Getd0Prong(0)*d->Getd0Prong(1),
1024 d->Getd0Prong(2)*d->Getd0Prong(1));
1027 fMassHistTC[index]->Fill(invMass);
1029 fDLxyTC[index]->Fill(dlxy);
1030 fCosxyTC[index]->Fill(cxy);
1032 if(d->GetCharge()>0) fMassHistTCPlus[index]->Fill(invMass);
1033 else if(d->GetCharge()<0) fMassHistTCMinus[index]->Fill(invMass);
1035 if(isPrimary) fHistMassPtImpParTC[1]->Fill(arrayForSparse);
1037 fHistMassPtImpParTC[2]->Fill(arrayForSparse);
1038 fHistMassPtImpParTC[3]->Fill(arrayForSparseTrue);
1043 fYVsPtSig->Fill(ptCand,rapid);
1044 if(passTightCuts) fYVsPtSigTC->Fill(ptCand,rapid);
1046 index=GetBackgroundHistoIndex(iPtBin);
1048 Float_t factor[3]={1.,1.,1.};
1049 if(fUseStrangeness){
1050 for(Int_t iprong=0;iprong<3;iprong++){
1051 AliAODTrack *trad = (AliAODTrack*)d->GetDaughter(iprong);
1052 Int_t labd= trad->GetLabel();
1054 AliAODMCParticle *dau = (AliAODMCParticle*)arrayMC->At(labd);
1056 Int_t labm = dau->GetMother();
1058 AliAODMCParticle *mot = (AliAODMCParticle*)arrayMC->At(labm);
1060 if(TMath::Abs(mot->GetPdgCode())==310 || TMath::Abs(mot->GetPdgCode())==130 || TMath::Abs(mot->GetPdgCode())==321){ //K0_S, K0_L, K^+-
1061 if(d->PtProng(iprong)<=1)factor[iprong]=1./.7;
1062 else factor[iprong]=1./.6;
1063 // fNentries->Fill(12);
1065 if(TMath::Abs(mot->GetPdgCode())==3122) { //Lambda
1066 factor[iprong]=1./0.25;
1067 // fNentries->Fill(13);
1076 Float_t fact=1.;for(Int_t k=0;k<3;k++)fact=fact*factor[k];
1077 fMassHist[index]->Fill(invMass);
1079 fCosPHist[index]->Fill(cosp,fact);
1080 fDLenHist[index]->Fill(dlen,fact);
1081 fDLxy[index]->Fill(dlxy);
1082 fCosxy[index]->Fill(cxy);
1084 Float_t sumd02s=d->Getd0Prong(0)*d->Getd0Prong(0)*factor[0]*factor[0]+d->Getd0Prong(1)*d->Getd0Prong(1)*factor[1]*factor[1]+d->Getd0Prong(2)*d->Getd0Prong(2)*factor[2]*factor[2];
1085 fSumd02Hist[index]->Fill(sumd02s);
1086 fSigVertHist[index]->Fill(sigvert,fact);
1087 fPtMaxHist[index]->Fill(ptmax,fact);
1088 fPtKHist[index]->Fill(d->PtProng(1),fact);
1089 fPtpi1Hist[index]->Fill(d->PtProng(0),fact);
1090 fPtpi2Hist[index]->Fill(d->PtProng(2),fact);
1091 fDCAHist[index]->Fill(dca,fact);
1092 fCorreld0Kd0pi[2]->Fill(d->Getd0Prong(0)*d->Getd0Prong(1),
1093 d->Getd0Prong(2)*d->Getd0Prong(1));
1096 fMassHistTC[index]->Fill(invMass);
1098 fDLxyTC[index]->Fill(dlxy);
1099 fCosxyTC[index]->Fill(cxy);
1101 if(d->GetCharge()>0) fMassHistTCPlus[index]->Fill(invMass);
1102 else if(d->GetCharge()<0) fMassHistTCMinus[index]->Fill(invMass);
1104 fHistMassPtImpParTC[4]->Fill(arrayForSparse);
1113 if(recVtx)fRDCutsProduction->CleanOwnPrimaryVtx(d,aod,origownvtx);
1115 if(unsetvtx) d->UnsetOwnPrimaryVtx();
1117 fCounter->StoreCandidates(aod,nSelectedloose,kTRUE);
1118 fCounter->StoreCandidates(aod,nSelectedtight,kFALSE);
1121 if(fDoLS && arrayLikeSign) LSAnalysis(array3Prong,arrayLikeSign,aod,vtx1,nOS);
1123 PostData(1,fOutput);
1124 PostData(2,fListCuts);
1125 PostData(3,fCounter);
1129 //________________________________________________________________________
1130 void AliAnalysisTaskSEDplus::CreateLikeSignHistos(){
1131 // Histos for Like Sign bckground
1136 Int_t nbins=GetNBinsHistos();
1137 for(Int_t i=0;i<fNPtBins;i++){
1139 index=GetHistoIndex(i);
1140 indexLS=GetLSHistoIndex(i);
1142 hisname.Form("hLSPt%dLC",i);
1143 fMassHistLS[indexLS] = new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
1144 fMassHistLS[indexLS]->Sumw2();
1145 hisname.Form("hLSPt%dTC",i);
1146 fMassHistLSTC[indexLS] = new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
1147 fMassHistLSTC[indexLS]->Sumw2();
1149 hisname.Form("hCosPAllPt%dLS",i);
1150 fCosPHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,1.);
1151 fCosPHistLS[index]->Sumw2();
1152 hisname.Form("hDLenAllPt%dLS",i);
1153 fDLenHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.5);
1154 fDLenHistLS[index]->Sumw2();
1155 hisname.Form("hSumd02AllPt%dLS",i);
1156 fSumd02HistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,1.);
1157 fSumd02HistLS[index]->Sumw2();
1158 hisname.Form("hSigVertAllPt%dLS",i);
1159 fSigVertHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
1160 fSigVertHistLS[index]->Sumw2();
1161 hisname.Form("hPtMaxAllPt%dLS",i);
1162 fPtMaxHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
1163 fPtMaxHistLS[index]->Sumw2();
1164 hisname.Form("hDCAAllPt%dLS",i);
1165 fDCAHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
1166 fDCAHistLS[index]->Sumw2();
1168 index=GetSignalHistoIndex(i);
1171 hisname.Form("hLSPt%dLCnw",i);
1172 fMassHistLS[indexLS]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
1173 fMassHistLS[indexLS]->Sumw2();
1174 hisname.Form("hLSPt%dTCnw",i);
1175 fMassHistLSTC[indexLS]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
1176 fMassHistLSTC[indexLS]->Sumw2();
1178 hisname.Form("hCosPSigPt%dLS",i);
1179 fCosPHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,1.);
1180 fCosPHistLS[index]->Sumw2();
1181 hisname.Form("hDLenSigPt%dLS",i);
1182 fDLenHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.5);
1183 fDLenHistLS[index]->Sumw2();
1184 hisname.Form("hSumd02SigPt%dLS",i);
1185 fSumd02HistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,1.);
1186 fSumd02HistLS[index]->Sumw2();
1187 hisname.Form("hSigVertSigPt%dLS",i);
1188 fSigVertHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
1189 fSigVertHistLS[index]->Sumw2();
1190 hisname.Form("hPtMaxSigPt%dLS",i);
1191 fPtMaxHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
1192 fPtMaxHistLS[index]->Sumw2();
1193 hisname.Form("hDCASigPt%dLS",i);
1194 fDCAHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
1195 fDCAHistLS[index]->Sumw2();
1197 index=GetBackgroundHistoIndex(i);
1200 hisname.Form("hLSPt%dLCntrip",i);
1201 fMassHistLS[indexLS]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
1202 fMassHistLS[indexLS]->Sumw2();
1203 hisname.Form("hLSPt%dTCntrip",i);
1204 fMassHistLSTC[indexLS]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
1205 fMassHistLSTC[indexLS]->Sumw2();
1207 hisname.Form("hCosPBkgPt%dLS",i);
1208 fCosPHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,1.);
1209 fCosPHistLS[index]->Sumw2();
1210 hisname.Form("hDLenBkgPt%dLS",i);
1211 fDLenHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.5);
1212 fDLenHistLS[index]->Sumw2();
1213 hisname.Form("hSumd02BkgPt%dLS",i);
1214 fSumd02HistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,1.);
1215 fSumd02HistLS[index]->Sumw2();
1216 hisname.Form("hSigVertBkgPt%dLS",i);
1217 fSigVertHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
1218 fSigVertHistLS[index]->Sumw2();
1219 hisname.Form("hPtMaxBkgPt%dLS",i);
1220 fPtMaxHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.5,5.);
1221 fPtMaxHistLS[index]->Sumw2();
1222 hisname.Form("hDCABkgPt%dLS",i);
1223 fDCAHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),nbins,0.,0.1);
1224 fDCAHistLS[index]->Sumw2();
1227 hisname.Form("hLSPt%dLCntripsinglecut",i);
1228 fMassHistLS[indexLS]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
1229 fMassHistLS[indexLS]->Sumw2();
1230 hisname.Form("hLSPt%dTCntripsinglecut",i);
1231 fMassHistLSTC[indexLS]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
1232 fMassHistLSTC[indexLS]->Sumw2();
1235 hisname.Form("hLSPt%dLCspc",i);
1236 fMassHistLS[indexLS]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
1237 fMassHistLS[indexLS]->Sumw2();
1238 hisname.Form("hLSPt%dTCspc",i);
1239 fMassHistLSTC[indexLS]=new TH1F(hisname.Data(),hisname.Data(),nbins,fLowmasslimit,fUpmasslimit);
1240 fMassHistLSTC[indexLS]->Sumw2();
1243 for(Int_t i=0; i<3*fNPtBins; i++){
1244 fOutput->Add(fCosPHistLS[i]);
1245 fOutput->Add(fDLenHistLS[i]);
1246 fOutput->Add(fSumd02HistLS[i]);
1247 fOutput->Add(fSigVertHistLS[i]);
1248 fOutput->Add(fPtMaxHistLS[i]);
1249 fOutput->Add(fDCAHistLS[i]);
1251 for(Int_t i=0; i<5*fNPtBins; i++){
1252 fOutput->Add(fMassHistLS[i]);
1253 fOutput->Add(fMassHistLSTC[i]);
1257 //________________________________________________________________________
1258 void AliAnalysisTaskSEDplus::CreateImpactParameterHistos(){
1259 // Histos for impact paramter study
1261 Int_t nmassbins=GetNBinsHistos();
1262 Int_t nbins[3]={nmassbins,200,fNImpParBins};
1263 Double_t xmin[3]={fLowmasslimit,0.,fLowerImpPar};
1264 Double_t xmax[3]={fUpmasslimit,20.,fHigherImpPar};
1266 fHistMassPtImpParTC[0]=new THnSparseF("hMassPtImpParAll",
1267 "Mass vs. pt vs.imppar - All",
1269 fHistMassPtImpParTC[1]=new THnSparseF("hMassPtImpParPrompt",
1270 "Mass vs. pt vs.imppar - promptD",
1272 fHistMassPtImpParTC[2]=new THnSparseF("hMassPtImpParBfeed",
1273 "Mass vs. pt vs.imppar - DfromB",
1275 fHistMassPtImpParTC[3]=new THnSparseF("hMassPtImpParTrueBfeed",
1276 "Mass vs. pt vs.true imppar -DfromB",
1278 fHistMassPtImpParTC[4]=new THnSparseF("hMassPtImpParBkg",
1279 "Mass vs. pt vs.imppar - backgr.",
1282 for(Int_t i=0; i<5;i++){
1283 fOutput->Add(fHistMassPtImpParTC[i]);
1287 //________________________________________________________________________
1288 void AliAnalysisTaskSEDplus::Terminate(Option_t */*option*/)
1290 // Terminate analysis
1292 if(fDebug > 1) printf("AnalysisTaskSEDplus: Terminate() \n");
1294 fOutput = dynamic_cast<TList*> (GetOutputData(1));
1296 printf("ERROR: fOutput not available\n");
1299 fHistNEvents = dynamic_cast<TH1F*>(fOutput->FindObject("fHistNEvents"));
1304 for(Int_t i=0;i<fNPtBins;i++){
1305 index=GetHistoIndex(i);
1307 hisname.Form("hMassPt%dTC",i);
1308 fMassHistTC[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
1311 TCanvas *c1=new TCanvas("c1","D+ invariant mass distribution",500,500);
1313 TH1F *hMassPt=(TH1F*)fOutput->FindObject("hMassPt3TC");
1314 hMassPt->SetLineColor(kBlue);
1315 hMassPt->SetXTitle("M[GeV/c^{2}]");
1320 //_________________________________________________________________________________________________
1321 Int_t AliAnalysisTaskSEDplus::CheckOrigin(TClonesArray* arrayMC, AliAODMCParticle *mcPartCandidate) const {
1323 // checking whether the mother of the particles come from a charm or a bottom quark
1326 Int_t pdgGranma = 0;
1328 mother = mcPartCandidate->GetMother();
1330 Int_t abspdgGranma =0;
1331 Bool_t isFromB=kFALSE;
1332 Bool_t isQuarkFound=kFALSE;
1335 AliAODMCParticle* mcGranma = dynamic_cast<AliAODMCParticle*>(arrayMC->At(mother));
1337 pdgGranma = mcGranma->GetPdgCode();
1338 abspdgGranma = TMath::Abs(pdgGranma);
1339 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)){
1342 if(abspdgGranma==4 || abspdgGranma==5) isQuarkFound=kTRUE;
1343 mother = mcGranma->GetMother();
1345 AliError("Failed casting the mother particle!");
1350 if(isFromB) return 5;
1353 //_________________________________________________________________________________________________
1354 Float_t AliAnalysisTaskSEDplus::GetTrueImpactParameter(AliAODMCHeader *mcHeader, TClonesArray* arrayMC, AliAODMCParticle *partDp) const {
1355 // true impact parameter calculation
1357 Double_t vtxTrue[3];
1358 mcHeader->GetVertex(vtxTrue);
1360 partDp->XvYvZv(origD);
1361 Short_t charge=partDp->Charge();
1362 Double_t pXdauTrue[3],pYdauTrue[3],pZdauTrue[3];
1363 for(Int_t iDau=0; iDau<3; iDau++){
1369 Int_t nDau=partDp->GetNDaughters();
1370 Int_t labelFirstDau = partDp->GetDaughter(0);
1372 for(Int_t iDau=0; iDau<3; iDau++){
1373 Int_t ind = labelFirstDau+iDau;
1374 AliAODMCParticle* part = dynamic_cast<AliAODMCParticle*>(arrayMC->At(ind));
1376 AliError("Daughter particle not found in MC array");
1379 pXdauTrue[iDau]=part->Px();
1380 pYdauTrue[iDau]=part->Py();
1381 pZdauTrue[iDau]=part->Pz();
1385 for(Int_t iDau=0; iDau<2; iDau++){
1386 Int_t ind = labelFirstDau+iDau;
1387 AliAODMCParticle* part = dynamic_cast<AliAODMCParticle*>(arrayMC->At(ind));
1389 AliError("Daughter particle not found in MC array");
1392 Int_t pdgCode=TMath::Abs(part->GetPdgCode());
1393 if(pdgCode==211 || pdgCode==321){
1394 pXdauTrue[theDau]=part->Px();
1395 pYdauTrue[theDau]=part->Py();
1396 pZdauTrue[theDau]=part->Pz();
1399 Int_t nDauRes=part->GetNDaughters();
1401 Int_t labelFirstDauRes = part->GetDaughter(0);
1402 for(Int_t iDauRes=0; iDauRes<2; iDauRes++){
1403 Int_t indDR = labelFirstDauRes+iDauRes;
1404 AliAODMCParticle* partDR = dynamic_cast<AliAODMCParticle*>(arrayMC->At(indDR));
1406 AliError("Daughter particle not found in MC array");
1410 Int_t pdgCodeDR=TMath::Abs(partDR->GetPdgCode());
1411 if(pdgCodeDR==211 || pdgCodeDR==321){
1412 pXdauTrue[theDau]=partDR->Px();
1413 pYdauTrue[theDau]=partDR->Py();
1414 pZdauTrue[theDau]=partDR->Pz();
1422 AliError("Wrong number of decay prongs");
1427 Double_t d0dummy[3]={0.,0.,0.};
1428 AliAODRecoDecayHF aodDplusMC(vtxTrue,origD,3,charge,pXdauTrue,pYdauTrue,pZdauTrue,d0dummy);
1429 return aodDplusMC.ImpParXY();