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 **************************************************************************/
16 /////////////////////////////////////////////////////////////
18 // AliAnalysisTaskSE for the extraction of signal(e.g D+) of heavy flavor
19 // decay candidates with the MC truth.
20 // Authors: Renu Bala, bala@to.infn.it
21 // F. Prino, prino@to.infn.it
22 // G. Ortona, ortona@to.infn.it
23 /////////////////////////////////////////////////////////////
25 #include <TClonesArray.h>
31 #include <TDatabasePDG.h>
33 #include "AliAnalysisManager.h"
34 #include "AliAODHandler.h"
35 #include "AliAODEvent.h"
36 #include "AliAODVertex.h"
37 #include "AliAODTrack.h"
38 #include "AliAODMCHeader.h"
39 #include "AliAODMCParticle.h"
40 #include "AliAODRecoDecayHF3Prong.h"
41 #include "AliAnalysisVertexingHF.h"
42 #include "AliAnalysisTaskSE.h"
43 #include "AliAnalysisTaskSEDplus.h"
45 ClassImp(AliAnalysisTaskSEDplus)
48 //________________________________________________________________________
49 AliAnalysisTaskSEDplus::AliAnalysisTaskSEDplus():
62 // Default constructor
65 //________________________________________________________________________
66 AliAnalysisTaskSEDplus::AliAnalysisTaskSEDplus(const char *name,Bool_t fillNtuple):
67 AliAnalysisTaskSE(name),
74 fFillNtuple(fillNtuple),
79 Double_t ptlim[5]={0.,2.,3.,5,9999999.};
80 SetPtBinLimit(5, ptlim);
81 // Default constructor
82 // Output slot #1 writes into a TList container
83 DefineOutput(1,TList::Class()); //My private output
86 // Output slot #2 writes into a TNtuple container
87 DefineOutput(2,TNtuple::Class()); //My private output
91 //________________________________________________________________________
92 AliAnalysisTaskSEDplus::~AliAnalysisTaskSEDplus()
104 // if(fArrayBinLimits) {
105 //delete fArrayBinLimits;
106 //fArrayBinLimits= 0;
110 //_________________________________________________________________
111 void AliAnalysisTaskSEDplus::SetMassLimits(Float_t range){
112 fUpmasslimit = 1.865+range;
113 fLowmasslimit = 1.865-range;
115 //_________________________________________________________________
116 void AliAnalysisTaskSEDplus::SetMassLimits(Float_t lowlimit, Float_t uplimit){
119 fUpmasslimit = lowlimit;
120 fLowmasslimit = uplimit;
125 //________________________________________________________________________
126 void AliAnalysisTaskSEDplus::SetPtBinLimit(Int_t n, Double_t* lim){
127 // define pt bins for analysis
129 printf("Max. number of Pt bins = %d\n",kMaxPtBins);
131 fArrayBinLimits[0]=0.;
132 fArrayBinLimits[1]=2.;
133 fArrayBinLimits[2]=3.;
134 fArrayBinLimits[3]=5.;
135 for(Int_t i=4; i<kMaxPtBins+1; i++) fArrayBinLimits[i]=99999999.;
138 fArrayBinLimits[0]=lim[0];
139 for(Int_t i=1; i<fNPtBins+1; i++)
140 if(lim[i]>fArrayBinLimits[i-1]){
141 fArrayBinLimits[i]=lim[i];
144 fArrayBinLimits[i]=fArrayBinLimits[i-1];
146 for(Int_t i=fNPtBins; i<kMaxPtBins+1; i++) fArrayBinLimits[i]=99999999.;
149 printf("Number of Pt bins = %d\n",fNPtBins);
150 for(Int_t i=0; i<fNPtBins+1; i++) printf(" Bin%d = %8.2f-%8.2f\n",i,fArrayBinLimits[i],fArrayBinLimits[i+1]);
153 //_________________________________________________________________
154 Double_t AliAnalysisTaskSEDplus::GetPtBinLimit(Int_t ibin){
155 if(ibin>fNPtBins)return -1;
156 return fArrayBinLimits[ibin];
159 //_________________________________________________________________
160 void AliAnalysisTaskSEDplus::LSAnalysis(TClonesArray *arrayOppositeSign,TClonesArray *arrayLikeSign,AliAODEvent *aod,AliAODVertex *vtx1, Int_t nDplusOS){
163 * Fill the Like Sign histograms
166 Double_t cutsDplus[12]={0.2,0.4,0.4,0.,0.,0.01,0.06,0.02,0.,0.85,0.,10000000000.};
168 //count pos/neg tracks
169 Int_t nPosTrks=0,nNegTrks=0;
170 //counter for particles passing single particle cuts
174 for(Int_t it=0;it<aod->GetNumberOfTracks();it++) {
175 AliAODTrack *track = aod->GetTrack(it);
176 if(track->Charge()>0){
178 if(track->Pt()>=0.4){
182 if(track->Charge()<0)
185 if(track->Pt()>=0.4){
191 Int_t nOStriplets = arrayOppositeSign->GetEntriesFast();
194 Int_t nLikeSign = arrayLikeSign->GetEntriesFast();
197 for(Int_t iLikeSign = 0; iLikeSign < nLikeSign; iLikeSign++) {
198 AliAODRecoDecayHF3Prong *d = (AliAODRecoDecayHF3Prong*)arrayLikeSign->UncheckedAt(iLikeSign);
199 Bool_t unsetvtx=kFALSE;
200 if(!d->GetOwnPrimaryVtx()) {
201 d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
204 if(d->SelectDplus(fVHF->GetDplusCuts()))nDplusLS++;
205 if(unsetvtx) d->UnsetOwnPrimaryVtx();
209 if(nLikeSign!=0)wei2 = (Float_t)nOStriplets/(Float_t)nLikeSign;
211 if(nDplusLS!=0)wei3 = (Float_t)nDplusOS/(Float_t)nDplusLS;
213 // loop over like sign candidates
214 for(Int_t iLikeSign = 0; iLikeSign < nLikeSign; iLikeSign++) {
215 AliAODRecoDecayHF3Prong *d = (AliAODRecoDecayHF3Prong*)arrayLikeSign->UncheckedAt(iLikeSign);
216 Bool_t unsetvtx=kFALSE;
217 if(!d->GetOwnPrimaryVtx()) {
218 d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
222 if(d->SelectDplus(fVHF->GetDplusCuts())){
224 //set tight cuts values
226 Double_t ptCand = d->Pt();
228 if(ptCand<2.){ //NO change
229 cutsDplus[6]=0.022100;//added
233 cutsDplus[10]=0.0055;
235 else if(ptCand>2. && ptCand<3){
237 cutsDplus[6]=0.034;//added
238 cutsDplus[7]=0.09;//cutsDplus[7]=0.08;
239 cutsDplus[8]=1.0;//cutsDplus[8]=0.5;
240 cutsDplus[9]=0.9975;//cutsDplus[9]=0.991;
241 cutsDplus[10]=0.0028;//cutsDplus[10]=0.005;
242 }else if(ptCand>3. && ptCand<5){
244 cutsDplus[6]=0.020667;//added
245 cutsDplus[7]=0.095;//cutsDplus[7]=0.1;
246 cutsDplus[8]=0.5;//cutsDplus[8]=0.5;
247 cutsDplus[9]=0.995;//cutsDplus[9]=0.995;
248 cutsDplus[10]=0.000883;//cutsDplus[10]=0.0035;
251 cutsDplus[6]=0.023333;//added
252 cutsDplus[7]=0.115;//cutsDplus[7]=0.1;
253 cutsDplus[8]=0.5;//cutsDplus[8]=0.5;
254 cutsDplus[9]=0.9975;//cutsDplus[9]=0.997;
255 cutsDplus[10]=0.000883;//cutsDplus[10]=0.001;
263 for(Int_t ibin=0;ibin<fNPtBins&&iPtBin<0&&ptCand>fArrayBinLimits[0]&&ptCand<fArrayBinLimits[fNPtBins];ibin++){
264 if(ptCand<fArrayBinLimits[ibin+1])iPtBin=ibin;
271 Bool_t passTightCuts=d->SelectDplus(cutsDplus);
273 Int_t sign= d->GetCharge();
276 if(sign>0&&nPosTrks>2&&nspcplus>2) { //wei* should be automatically protected, since to get a triplet there must be at least 3 good tracks in the event
278 wei=3.*(Float_t)nNegTrks/((Float_t)nPosTrks-2.);
279 wei4=3.*(Float_t)nspcminus/((Float_t)nspcplus-2.);
282 if(sign<0&&nNegTrks>2&&nspcminus>2){
283 wei=3.*(Float_t)nPosTrks/((Float_t)nNegTrks-2.);
284 wei4=3.*(Float_t)nspcplus/((Float_t)nspcminus-2.);
288 Float_t invMass = d->InvMassDplus();
289 Double_t dlen=d->DecayLength();
290 Double_t cosp=d->CosPointingAngle();
291 Double_t sumD02=d->Getd0Prong(0)*d->Getd0Prong(0)+d->Getd0Prong(1)*d->Getd0Prong(1)+d->Getd0Prong(2)*d->Getd0Prong(2);
292 Double_t dca=d->GetDCA();
294 for(Int_t i=0;i<3;i++){
295 if(d->PtProng(i)>ptmax)ptmax=d->PtProng(i);
298 index=GetLSHistoIndex(iPtBin);
299 fMassHistLS[index]->Fill(invMass,wei);
300 fMassHistLS[index+1]->Fill(invMass);
301 fMassHistLS[index+2]->Fill(invMass,wei2);
302 fMassHistLS[index+3]->Fill(invMass,wei3);
303 fMassHistLS[index+4]->Fill(invMass,wei4);
305 Int_t indexcut=GetHistoIndex(iPtBin);
306 fCosPHistLS[indexcut]->Fill(cosp);
307 fDLenHistLS[indexcut]->Fill(dlen);
308 fSumd02HistLS[indexcut]->Fill(sumD02);
309 fPtMaxHistLS[indexcut]->Fill(ptmax);
310 fDCAHistLS[indexcut]->Fill(dca);
313 fMassHistLSTC[index]->Fill(invMass,wei);
314 fMassHistLSTC[index+1]->Fill(invMass);
315 fMassHistLSTC[index+2]->Fill(invMass,wei2);
316 fMassHistLSTC[index+3]->Fill(invMass,wei3);
317 fMassHistLSTC[index+4]->Fill(invMass,wei4);
320 if(unsetvtx) d->UnsetOwnPrimaryVtx();
323 //printf("------------ N. of positive tracks in Event ----- %d \n", nPosTrks);
324 //printf("------------ N. of negative tracks in Event ----- %d \n", nNegTrks);
326 // printf("LS analysis...done\n");
330 //________________________________________________________________________
331 void AliAnalysisTaskSEDplus::Init()
335 if(fDebug > 1) printf("AnalysisTaskSEDplus::Init() \n");
337 gROOT->LoadMacro("ConfigVertexingHF.C");
339 fVHF = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
345 //________________________________________________________________________
346 void AliAnalysisTaskSEDplus::UserCreateOutputObjects()
348 // Create the output container
350 if(fDebug > 1) printf("AnalysisTaskSEDplus::UserCreateOutputObjects() \n");
352 // Several histograms are more conveniently managed in a TList
353 fOutput = new TList();
355 fOutput->SetName("OutputHistos");
360 for(Int_t i=0;i<fNPtBins;i++){
362 index=GetHistoIndex(i);
363 indexLS=GetLSHistoIndex(i);
365 hisname.Form("hMassPt%d",i);
366 fMassHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
367 fMassHist[index]->Sumw2();
368 hisname.Form("hCosPAllPt%d",i);
369 fCosPHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.5,1.);
370 fCosPHist[index]->Sumw2();
371 hisname.Form("hDLenAllPt%d",i);
372 fDLenHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,0.5);
373 fDLenHist[index]->Sumw2();
374 hisname.Form("hSumd02AllPt%d",i);
375 fSumd02Hist[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,1.);
376 fSumd02Hist[index]->Sumw2();
377 hisname.Form("hSigVertAllPt%d",i);
378 fSigVertHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,0.1);
379 fSigVertHist[index]->Sumw2();
380 hisname.Form("hPtMaxAllPt%d",i);
381 fPtMaxHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.5,5.);
382 fPtMaxHist[index]->Sumw2();
384 hisname.Form("hDCAAllPt%d",i);
385 fDCAHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,0.1);
386 fDCAHist[index]->Sumw2();
390 hisname.Form("hMassPt%dTC",i);
391 fMassHistTC[index]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
392 fMassHistTC[index]->Sumw2();
398 hisname.Form("hCosPAllPt%dLS",i);
399 fCosPHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.5,1.);
400 fCosPHistLS[index]->Sumw2();
401 hisname.Form("hDLenAllPt%dLS",i);
402 fDLenHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,0.5);
403 fDLenHistLS[index]->Sumw2();
404 hisname.Form("hSumd02AllPt%dLS",i);
405 fSumd02HistLS[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,1.);
406 fSumd02HistLS[index]->Sumw2();
407 hisname.Form("hSigVertAllPt%dLS",i);
408 fSigVertHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,0.1);
409 fSigVertHistLS[index]->Sumw2();
410 hisname.Form("hPtMaxAllPt%dLS",i);
411 fPtMaxHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.5,5.);
412 fPtMaxHistLS[index]->Sumw2();
414 hisname.Form("hDCAAllPt%dLS",i);
415 fDCAHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,0.1);
416 fDCAHistLS[index]->Sumw2();
418 hisname.Form("hLSPt%dLC",i);
419 fMassHistLS[indexLS] = new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
420 fMassHistLS[indexLS]->Sumw2();
422 hisname.Form("hLSPt%dTC",i);
423 fMassHistLSTC[indexLS] = new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
424 fMassHistLSTC[indexLS]->Sumw2();
428 index=GetSignalHistoIndex(i);
430 hisname.Form("hSigPt%d",i);
431 fMassHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
432 fMassHist[index]->Sumw2();
433 hisname.Form("hCosPSigPt%d",i);
434 fCosPHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.5,1.);
435 fCosPHist[index]->Sumw2();
436 hisname.Form("hDLenSigPt%d",i);
437 fDLenHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,0.5);
438 fDLenHist[index]->Sumw2();
439 hisname.Form("hSumd02SigPt%d",i);
440 fSumd02Hist[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,1.);
441 fSumd02Hist[index]->Sumw2();
442 hisname.Form("hSigVertSigPt%d",i);
443 fSigVertHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,0.1);
444 fSigVertHist[index]->Sumw2();
445 hisname.Form("hPtMaxSigPt%d",i);
446 fPtMaxHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.5,5.);
447 fPtMaxHist[index]->Sumw2();
449 hisname.Form("hDCASigPt%d",i);
450 fDCAHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,0.1);
451 fDCAHist[index]->Sumw2();
454 hisname.Form("hSigPt%dTC",i);
455 fMassHistTC[index]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
456 fMassHistTC[index]->Sumw2();
458 hisname.Form("hLSPt%dLCnw",i);
459 fMassHistLS[indexLS]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
460 fMassHistLS[indexLS]->Sumw2();
461 hisname.Form("hLSPt%dTCnw",i);
462 fMassHistLSTC[indexLS]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
463 fMassHistLSTC[indexLS]->Sumw2();
467 hisname.Form("hCosPSigPt%dLS",i);
468 fCosPHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.5,1.);
469 fCosPHistLS[index]->Sumw2();
470 hisname.Form("hDLenSigPt%dLS",i);
471 fDLenHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,0.5);
472 fDLenHistLS[index]->Sumw2();
473 hisname.Form("hSumd02SigPt%dLS",i);
474 fSumd02HistLS[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,1.);
475 fSumd02HistLS[index]->Sumw2();
476 hisname.Form("hSigVertSigPt%dLS",i);
477 fSigVertHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,0.1);
478 fSigVertHistLS[index]->Sumw2();
479 hisname.Form("hPtMaxSigPt%dLS",i);
480 fPtMaxHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.5,5.);
481 fPtMaxHistLS[index]->Sumw2();
483 hisname.Form("hDCASigPt%dLS",i);
484 fDCAHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,0.1);
485 fDCAHistLS[index]->Sumw2();
489 index=GetBackgroundHistoIndex(i);
491 hisname.Form("hBkgPt%d",i);
492 fMassHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
493 fMassHist[index]->Sumw2();
494 hisname.Form("hCosPBkgPt%d",i);
495 fCosPHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.5,1.);
496 fCosPHist[index]->Sumw2();
497 hisname.Form("hDLenBkgPt%d",i);
498 fDLenHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,0.5);
499 fDLenHist[index]->Sumw2();
500 hisname.Form("hSumd02BkgPt%d",i);
501 fSumd02Hist[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,1.);
502 fSumd02Hist[index]->Sumw2();
503 hisname.Form("hSigVertBkgPt%d",i);
504 fSigVertHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,0.1);
505 fSigVertHist[index]->Sumw2();
506 hisname.Form("hPtMaxBkgPt%d",i);
507 fPtMaxHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.5,5.);
508 fPtMaxHist[index]->Sumw2();
510 hisname.Form("hDCABkgPt%d",i);
511 fDCAHist[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,0.1);
512 fDCAHist[index]->Sumw2();
515 hisname.Form("hBkgPt%dTC",i);
516 fMassHistTC[index]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
517 fMassHistTC[index]->Sumw2();
519 hisname.Form("hLSPt%dLCntrip",i);
520 fMassHistLS[indexLS]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
521 fMassHistLS[indexLS]->Sumw2();
522 hisname.Form("hLSPt%dTCntrip",i);
523 fMassHistLSTC[indexLS]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
524 fMassHistLSTC[indexLS]->Sumw2();
527 hisname.Form("hCosPBkgPt%dLS",i);
528 fCosPHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.5,1.);
529 fCosPHistLS[index]->Sumw2();
530 hisname.Form("hDLenBkgPt%dLS",i);
531 fDLenHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,0.5);
532 fDLenHistLS[index]->Sumw2();
533 hisname.Form("hSumd02BkgPt%dLS",i);
534 fSumd02HistLS[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,1.);
535 fSumd02HistLS[index]->Sumw2();
536 hisname.Form("hSigVertBkgPt%dLS",i);
537 fSigVertHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,0.1);
538 fSigVertHistLS[index]->Sumw2();
539 hisname.Form("hPtMaxBkgPt%dLS",i);
540 fPtMaxHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.5,5.);
541 fPtMaxHistLS[index]->Sumw2();
542 hisname.Form("hDCABkgPt%dLS",i);
543 fDCAHistLS[index]=new TH1F(hisname.Data(),hisname.Data(),100,0.,0.1);
544 fDCAHistLS[index]->Sumw2();
548 hisname.Form("hLSPt%dLCntripsinglecut",i);
549 fMassHistLS[indexLS]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
550 fMassHistLS[indexLS]->Sumw2();
551 hisname.Form("hLSPt%dTCntripsinglecut",i);
552 fMassHistLSTC[indexLS]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
553 fMassHistLSTC[indexLS]->Sumw2();
556 hisname.Form("hLSPt%dLCspc",i);
557 fMassHistLS[indexLS]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
558 fMassHistLS[indexLS]->Sumw2();
559 hisname.Form("hLSPt%dTCspc",i);
560 fMassHistLSTC[indexLS]=new TH1F(hisname.Data(),hisname.Data(),100,fLowmasslimit,fUpmasslimit);
561 fMassHistLSTC[indexLS]->Sumw2();
564 for(Int_t i=0; i<3*fNPtBins; i++){
565 fOutput->Add(fMassHist[i]);
566 fOutput->Add(fCosPHist[i]);
567 fOutput->Add(fDLenHist[i]);
568 fOutput->Add(fSumd02Hist[i]);
569 fOutput->Add(fSigVertHist[i]);
570 fOutput->Add(fPtMaxHist[i]);
571 fOutput->Add(fDCAHist[i]);
572 fOutput->Add(fMassHistTC[i]);
574 for(Int_t i=0; i<3*fNPtBins&&fDoLS; i++){
575 fOutput->Add(fCosPHistLS[i]);
576 fOutput->Add(fDLenHistLS[i]);
577 fOutput->Add(fSumd02HistLS[i]);
578 fOutput->Add(fSigVertHistLS[i]);
579 fOutput->Add(fPtMaxHistLS[i]);
580 fOutput->Add(fDCAHistLS[i]);
582 for(Int_t i=0; i<5*fNPtBins&&fDoLS; i++){
583 fOutput->Add(fMassHistLS[i]);
584 fOutput->Add(fMassHistLSTC[i]);
588 fHistNEvents = new TH1F("fHistNEvents", "Number of processed events; ; Events",3,-1.5,1.5);
589 fHistNEvents->Sumw2();
590 fHistNEvents->SetMinimum(0);
591 fOutput->Add(fHistNEvents);
596 OpenFile(2); // 2 is the slot number of the ntuple
598 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");
605 //________________________________________________________________________
606 void AliAnalysisTaskSEDplus::UserExec(Option_t */*option*/)
608 // Execute analysis for current event:
609 // heavy flavor candidates association to MC truth
611 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
612 fHistNEvents->Fill(0); // count event
613 // Post the data already here
616 TClonesArray *array3Prong = 0;
617 TClonesArray *arrayLikeSign =0;
618 if(!aod && AODEvent() && IsStandardAOD()) {
619 // In case there is an AOD handler writing a standard AOD, use the AOD
620 // event in memory rather than the input (ESD) event.
621 aod = dynamic_cast<AliAODEvent*> (AODEvent());
622 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
623 // have to taken from the AOD event hold by the AliAODExtension
624 AliAODHandler* aodHandler = (AliAODHandler*)
625 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
626 if(aodHandler->GetExtensions()) {
627 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
628 AliAODEvent *aodFromExt = ext->GetAOD();
629 array3Prong=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong");
630 arrayLikeSign=(TClonesArray*)aodFromExt->GetList()->FindObject("LikeSign3Prong");
633 array3Prong=(TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
634 arrayLikeSign=(TClonesArray*)aod->GetList()->FindObject("LikeSign3Prong");
638 printf("AliAnalysisTaskSEDplus::UserExec: Charm3Prong branch not found!\n");
642 printf("AliAnalysisTaskSEDplus::UserExec: LikeSign3Prong branch not found!\n");
647 TClonesArray *arrayMC=0;
648 AliAODMCHeader *mcHeader=0;
650 // AOD primary vertex
651 AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
657 arrayMC = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
659 printf("AliAnalysisTaskSEDplus::UserExec: MC particles branch not found!\n");
664 mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
666 printf("AliAnalysisTaskSEDplus::UserExec: MC header branch not found!\n");
671 Int_t n3Prong = array3Prong->GetEntriesFast();
672 if(fDebug>1) printf("Number of D+->Kpipi: %d\n",n3Prong);
677 Int_t pdgDgDplustoKpipi[3]={321,211,211};
678 Double_t cutsDplus[12]={0.2,0.4,0.4,0.,0.,0.01,0.06,0.02,0.,0.85,0.,10000000000.};
679 for (Int_t i3Prong = 0; i3Prong < n3Prong; i3Prong++) {
680 AliAODRecoDecayHF3Prong *d = (AliAODRecoDecayHF3Prong*)array3Prong->UncheckedAt(i3Prong);
683 Bool_t unsetvtx=kFALSE;
684 if(!d->GetOwnPrimaryVtx()){
685 d->SetOwnPrimaryVtx(vtx1);
689 if(d->SelectDplus(fVHF->GetDplusCuts())) {
691 Double_t ptCand = d->Pt();
693 if(ptCand<2.){ //NO CHANGE
694 cutsDplus[6]=0.022100;//added
698 cutsDplus[10]=0.0055;
700 else if(ptCand>2. && ptCand<3){
702 cutsDplus[6]=0.034;//added
703 cutsDplus[7]=0.09;//cutsDplus[7]=0.08;
704 cutsDplus[8]=1.0;//cutsDplus[8]=0.5;
705 cutsDplus[9]=0.9975;//cutsDplus[9]=0.991;
706 cutsDplus[10]=0.0028;//cutsDplus[10]=0.005;
707 }else if(ptCand>3. && ptCand<5){
709 cutsDplus[6]=0.020667;//added
710 cutsDplus[7]=0.095;//cutsDplus[7]=0.1;
711 cutsDplus[8]=0.5;//cutsDplus[8]=0.5;
712 cutsDplus[9]=0.995;//cutsDplus[9]=0.995;
713 cutsDplus[10]=0.000883;//cutsDplus[10]=0.0035;
716 cutsDplus[6]=0.023333;//added
717 cutsDplus[7]=0.115;//cutsDplus[7]=0.1;
718 cutsDplus[8]=0.5;//cutsDplus[8]=0.5;
719 cutsDplus[9]=0.9975;//cutsDplus[9]=0.997;
720 cutsDplus[10]=0.000883;//cutsDplus[10]=0.001;
723 for(Int_t ibin=0;ibin<fNPtBins&&iPtBin<0&&ptCand>fArrayBinLimits[0]&&ptCand<fArrayBinLimits[fNPtBins];ibin++){
724 if(ptCand<fArrayBinLimits[ibin+1])iPtBin=ibin;
727 Bool_t passTightCuts=d->SelectDplus(cutsDplus);
738 labDp = d->MatchToMC(411,arrayMC,3,pdgDgDplustoKpipi);
740 AliAODMCParticle *partDp = (AliAODMCParticle*)arrayMC->At(labDp);
741 AliAODMCParticle *dg0 = (AliAODMCParticle*)arrayMC->At(partDp->GetDaughter(0));
742 deltaPx=partDp->Px()-d->Px();
743 deltaPy=partDp->Py()-d->Py();
744 deltaPz=partDp->Pz()-d->Pz();
749 pdgCode=TMath::Abs(partDp->GetPdgCode());
754 Double_t invMass=d->InvMassDplus();
766 tmp[8]=d->PtProng(0);
767 tmp[9]=d->PtProng(1);
768 tmp[10]=d->PtProng(2);
770 tmp[12]=d->CosPointingAngle();
771 tmp[13]=d->DecayLength();
775 tmp[17]=d->InvMassDplus();
776 tmp[18]=d->GetSigmaVert();
777 tmp[19]=d->Getd0Prong(0);
778 tmp[20]=d->Getd0Prong(1);
779 tmp[21]=d->Getd0Prong(2);
781 tmp[23]=d->Prodd0d0();
782 fNtupleDplus->Fill(tmp);
783 PostData(2,fNtupleDplus);
785 Double_t dlen=d->DecayLength();
786 Double_t cosp=d->CosPointingAngle();
787 Double_t sumD02=d->Getd0Prong(0)*d->Getd0Prong(0)+d->Getd0Prong(1)*d->Getd0Prong(1)+d->Getd0Prong(2)*d->Getd0Prong(2);
788 Double_t dca=d->GetDCA();
790 for(Int_t i=0;i<3;i++){
791 if(d->PtProng(i)>ptmax)ptmax=d->PtProng(i);
795 index=GetHistoIndex(iPtBin);
796 fMassHist[index]->Fill(invMass);
797 fCosPHist[index]->Fill(cosp);
798 fDLenHist[index]->Fill(dlen);
799 fSumd02Hist[index]->Fill(sumD02);
800 fPtMaxHist[index]->Fill(ptmax);
801 fDCAHist[index]->Fill(dca);
804 fMassHistTC[index]->Fill(invMass);
809 index=GetSignalHistoIndex(iPtBin);
810 fMassHist[index]->Fill(invMass);
811 fCosPHist[index]->Fill(cosp);
812 fDLenHist[index]->Fill(dlen);
813 fSumd02Hist[index]->Fill(sumD02);
814 fPtMaxHist[index]->Fill(ptmax);
815 fDCAHist[index]->Fill(dca);
817 fMassHistTC[index]->Fill(invMass);
822 index=GetBackgroundHistoIndex(iPtBin);
823 fMassHist[index]->Fill(invMass);
824 fCosPHist[index]->Fill(cosp);
825 fDLenHist[index]->Fill(dlen);
826 fSumd02Hist[index]->Fill(sumD02);
827 fPtMaxHist[index]->Fill(ptmax);
828 fDCAHist[index]->Fill(dca);
830 fMassHistTC[index]->Fill(invMass);
838 if(labDp<0)fHistOSbkg->Fill(d->InvMassDplus());
839 fHistOS->Fill(d->InvMassDplus());
843 if(unsetvtx) d->UnsetOwnPrimaryVtx();
847 if(fDoLS && arrayLikeSign) LSAnalysis(array3Prong,arrayLikeSign,aod,vtx1,nOS);
855 //________________________________________________________________________
856 void AliAnalysisTaskSEDplus::Terminate(Option_t */*option*/)
858 // Terminate analysis
860 if(fDebug > 1) printf("AnalysisTaskSEDplus: Terminate() \n");
862 fOutput = dynamic_cast<TList*> (GetOutputData(1));
864 printf("ERROR: fOutput not available\n");
867 fHistNEvents = dynamic_cast<TH1F*>(fOutput->FindObject("fHistNEvents"));
874 for(Int_t i=0;i<fNPtBins;i++){
875 index=GetHistoIndex(i);
876 if(fDoLS)indexLS=GetLSHistoIndex(i);
877 hisname.Form("hMassPt%d",i);
878 fMassHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
879 hisname.Form("hCosPAllPt%d",i);
880 fCosPHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
881 hisname.Form("hDLenAllPt%d",i);
882 fDLenHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
883 hisname.Form("hSumd02AllPt%d",i);
884 fSumd02Hist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
885 hisname.Form("hSigVertAllPt%d",i);
886 fSigVertHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
887 hisname.Form("hPtMaxAllPt%d",i);
888 fPtMaxHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
889 hisname.Form("hDCAAllPt%d",i);
890 fDCAHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
891 hisname.Form("hMassPt%dTC",i);
892 fMassHistTC[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
894 hisname.Form("hLSPt%dLC",i);
895 fMassHistLS[indexLS]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
896 hisname.Form("hCosPAllPt%dLS",i);
897 fCosPHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
898 hisname.Form("hDLenAllPt%dLS",i);
899 fDLenHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
900 hisname.Form("hSumd02AllPt%dLS",i);
901 fSumd02HistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
902 hisname.Form("hSigVertAllPt%dLS",i);
903 fSigVertHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
904 hisname.Form("hPtMaxAllPt%dLS",i);
905 fPtMaxHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
906 hisname.Form("hDCAAllPt%dLS",i);
907 fDCAHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
909 hisname.Form("hLSPt%dTC",i);
910 fMassHistLSTC[indexLS]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
914 index=GetSignalHistoIndex(i);
916 hisname.Form("hSigPt%d",i);
917 fMassHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
918 hisname.Form("hCosPSigPt%d",i);
919 fCosPHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
920 hisname.Form("hDLenSigPt%d",i);
921 fDLenHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
922 hisname.Form("hSumd02SigPt%d",i);
923 fSumd02Hist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
924 hisname.Form("hSigVertSigPt%d",i);
925 fSigVertHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
926 hisname.Form("hPtMaxSigPt%d",i);
927 fPtMaxHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
928 hisname.Form("hDCASigPt%d",i);
929 fDCAHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
931 hisname.Form("hSigPt%dTC",i);
932 fMassHistTC[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
934 hisname.Form("hLSPt%dLCnw",i);
935 fMassHistLS[indexLS]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
936 hisname.Form("hCosPSigPt%dLS",i);
937 fCosPHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
938 hisname.Form("hDLenSigPt%dLS",i);
939 fDLenHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
940 hisname.Form("hSumd02SigPt%dLS",i);
941 fSumd02HistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
942 hisname.Form("hSigVertSigPt%dLS",i);
943 fSigVertHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
944 hisname.Form("hPtMaxSigPt%dLS",i);
945 fPtMaxHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
946 hisname.Form("hDCASigPt%dLS",i);
947 fDCAHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
949 hisname.Form("hLSPt%dTCnw",i);
950 fMassHistLSTC[indexLS]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
953 index=GetBackgroundHistoIndex(i);
955 hisname.Form("hBkgPt%d",i);
956 fMassHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
957 hisname.Form("hCosPBkgPt%d",i);
958 fCosPHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
959 hisname.Form("hDLenBkgPt%d",i);
960 fDLenHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
961 hisname.Form("hSumd02BkgPt%d",i);
962 fSumd02Hist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
963 hisname.Form("hSigVertBkgPt%d",i);
964 fSigVertHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
965 hisname.Form("hPtMaxBkgPt%d",i);
966 fPtMaxHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
967 hisname.Form("hDCABkgPt%d",i);
968 fDCAHist[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
969 hisname.Form("hBkgPt%dTC",i);
970 fMassHistTC[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
972 hisname.Form("hLSPt%dLCntrip",i);
973 fMassHistLS[indexLS]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
976 hisname.Form("hCosPBkgPt%dLS",i);
977 fCosPHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
978 hisname.Form("hDLenBkgPt%dLS",i);
979 fDLenHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
980 hisname.Form("hSumd02BkgPt%dLS",i);
981 fSumd02HistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
982 hisname.Form("hSigVertBkgPt%dLS",i);
983 fSigVertHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
984 hisname.Form("hPtMaxBkgPt%dLS",i);
985 fPtMaxHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
986 hisname.Form("hDCABkgPt%dLS",i);
987 fDCAHistLS[index]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
989 hisname.Form("hLSPt%dTCntrip",i);
990 fMassHistLSTC[indexLS]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
994 hisname.Form("hLSPt%dLCntripsinglecut",i);
995 fMassHistLS[indexLS]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
997 hisname.Form("hLSPt%dTCntripsinglecut",i);
998 fMassHistLSTC[indexLS]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
1002 hisname.Form("hLSPt%dLCspc",i);
1003 fMassHistLS[indexLS]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
1005 hisname.Form("hLSPt%dTCspc",i);
1006 fMassHistLSTC[indexLS]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
1012 fNtupleDplus = dynamic_cast<TNtuple*>(GetOutputData(2));
1015 TCanvas *c1=new TCanvas("c1","D+ invariant mass distribution",500,500);
1017 TH1F *hMassPt=(TH1F*)fOutput->FindObject("hMassPt3TC");
1018 hMassPt->SetLineColor(kBlue);
1019 hMassPt->SetXTitle("M[GeV/c^{2}]");