1 /**************************************************************************
2 * Copyright(c) 1998-2009, 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 /////////////////////////////////////////////////////////////
20 // AliAnalysisTaskSE for D0 candidates invariant mass histogram
21 // and comparison with the MC truth and cut variables distributions.
23 // Authors: A.Dainese, andrea.dainese@lnl.infn.it
24 // Chiara Bianchin, chiara.bianchin@pd.infn.it (invariant mass)
25 // Carmelo Di Giglio, carmelo.digiglio@ba.infn.it (like sign)
26 /////////////////////////////////////////////////////////////
28 #include <Riostream.h>
29 #include <TClonesArray.h>
35 #include <TDatabasePDG.h>
37 #include <AliAnalysisDataSlot.h>
38 #include <AliAnalysisDataContainer.h>
39 #include "AliAnalysisManager.h"
40 #include "AliESDtrack.h"
41 #include "AliVertexerTracks.h"
42 #include "AliAODHandler.h"
43 #include "AliAODEvent.h"
44 #include "AliAODVertex.h"
45 #include "AliAODTrack.h"
46 #include "AliAODMCHeader.h"
47 #include "AliAODMCParticle.h"
48 #include "AliAODRecoDecayHF2Prong.h"
49 #include "AliAODRecoCascadeHF.h"
50 #include "AliAnalysisVertexingHF.h"
51 #include "AliAnalysisTaskSE.h"
52 #include "AliAnalysisTaskSED0Mass.h"
53 #include "AliNormalizationCounter.h"
55 ClassImp(AliAnalysisTaskSED0Mass)
58 //________________________________________________________________________
59 AliAnalysisTaskSED0Mass::AliAnalysisTaskSED0Mass():
74 fIsSelectedCandidate(0),
78 // Default constructor
81 //________________________________________________________________________
82 AliAnalysisTaskSED0Mass::AliAnalysisTaskSED0Mass(const char *name,AliRDHFCutsD0toKpi* cuts):
83 AliAnalysisTaskSE(name),
97 fIsSelectedCandidate(0),
101 // Default constructor
103 fNPtBins=cuts->GetNPtBins();
107 // Output slot #1 writes into a TList container (mass with cuts)
108 DefineOutput(1,TList::Class()); //My private output
109 // Output slot #2 writes into a TList container (distributions)
110 if(fFillVarHists) DefineOutput(2,TList::Class()); //My private output
111 // Output slot #3 writes into a TH1F container (number of events)
112 DefineOutput(3,TH1F::Class()); //My private output
113 // Output slot #4 writes into a TList container (cuts)
114 DefineOutput(4,AliRDHFCutsD0toKpi::Class()); //My private output
115 // Output slot #5 writes Normalization Counter
116 DefineOutput(5,AliNormalizationCounter::Class());
119 //________________________________________________________________________
120 AliAnalysisTaskSED0Mass::~AliAnalysisTaskSED0Mass()
145 //________________________________________________________________________
146 void AliAnalysisTaskSED0Mass::Init()
150 if(fDebug > 1) printf("AnalysisTaskSED0Mass::Init() \n");
153 AliRDHFCutsD0toKpi* copyfCuts=new AliRDHFCutsD0toKpi(*fCuts);
154 const char* nameoutput=GetOutputSlot(4)->GetContainer()->GetName();
155 copyfCuts->SetName(nameoutput);
157 PostData(4,copyfCuts);
163 //________________________________________________________________________
164 void AliAnalysisTaskSED0Mass::UserCreateOutputObjects()
167 // Create the output container
169 if(fDebug > 1) printf("AnalysisTaskSED0Mass::UserCreateOutputObjects() \n");
171 // Several histograms are more conveniently managed in a TList
172 fOutputMass = new TList();
173 fOutputMass->SetOwner();
174 fOutputMass->SetName("listMass");
176 fDistr = new TList();
178 fDistr->SetName("distributionslist");
180 TString nameMass=" ",nameSgn27=" ",nameSgn=" ", nameBkg=" ", nameRfl=" ",nameMassNocutsS =" ",nameMassNocutsB =" ", namedistr=" ";
182 for(Int_t i=0;i<fCuts->GetNPtBins();i++){
184 nameMass="histMass_";
186 nameSgn27="histSgn27_";
194 nameMassNocutsS="hMassS_";
196 nameMassNocutsB="hMassB_";
199 //histograms of cut variable distributions
205 TH1F *hdcaS = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
209 TH1F *hd0piS = new TH1F(namedistr.Data(), "Impact parameter distribution (pions);d0(#pi) [cm]",200,-0.1,0.1);
213 TH1F *hd0KS = new TH1F(namedistr.Data(), "Impact parameter distribution (kaons);d0(K) [cm]",200,-0.1,0.1);
216 TH1F *hd0d0S = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution;d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
221 TH1F *hdeclengthS = new TH1F(namedistr.Data(), "Decay Length^{2} distribution;Decay Length^{2} [cm]",200,0,0.015);
223 namedistr="hnormdeclS_";
225 TH1F *hnormdeclengthS = new TH1F(namedistr.Data(), "Normalized Decay Length^{2} distribution;(Decay Length/Err)^{2} ",200,0,12.);
227 namedistr="hdeclxyS_";
229 TH1F* hdeclxyS=new TH1F(namedistr.Data(),"Decay Length XY distribution;Decay Length XY [cm]",200,0,0.15);
230 namedistr="hnormdeclxyS_";
232 TH1F* hnormdeclxyS=new TH1F(namedistr.Data(),"Normalized decay Length XY distribution;Decay Length XY/Err",200,0,6.);
234 namedistr="hdeclxyd0d0S_";
236 TH2F* hdeclxyd0d0S=new TH2F(namedistr.Data(),"Correlation decay Length XY - d_{0}#times d_{0};Decay Length XY [cm];d_{0}#times d_{0}[cm^{2}]",200,0,0.15,200,-0.001,0.001);
238 namedistr="hnormdeclxyd0d0S_";
240 TH2F* hnormdeclxyd0d0S=new TH2F(namedistr.Data(),"Correlation normalized decay Length XY - d_{0}#times d_{0};Decay Length XY/Err;d_{0}#times d_{0}[cm^{2}]",200,0,6,200,-0.001,0.001);
243 namedistr="hcosthetapointS_";
245 TH1F *hcosthetapointS = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
247 namedistr="hcosthetapointxyS_";
249 TH1F *hcosthetapointxyS = new TH1F(namedistr.Data(), "cos#theta_{Point} XYdistribution;cos#theta_{Point}",300,0.,1.);
251 TH1F* tmpMS = new TH1F(nameMassNocutsS.Data(),"D^{0} invariant mass; M [GeV]; Entries",300,1.5648,2.1648); //range (MD0-300MeV, mD0 + 300MeV)
262 fDistr->Add(hcosthetapointS);
264 fDistr->Add(hcosthetapointxyS);
266 fDistr->Add(hdeclengthS);
268 fDistr->Add(hnormdeclengthS);
270 fDistr->Add(hdeclxyS);
272 fDistr->Add(hnormdeclxyS);
274 fDistr->Add(hdeclxyd0d0S);
275 fDistr->Add(hnormdeclxyd0d0S);
283 TH1F *hdcaB = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
288 TH1F *hd0B = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
292 TH1F *hd0d0B = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution;d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
297 TH1F *hdeclengthB = new TH1F(namedistr.Data(), "Decay Length^{2} distribution;Decay Length^{2} [cm^{2}]",200,0,0.015);
299 namedistr="hnormdeclB_";
301 TH1F *hnormdeclengthB = new TH1F(namedistr.Data(), "Normalized Decay Length distribution;(Decay Length/Err)^{2} ",200,0,12.);
303 namedistr="hdeclxyB_";
305 TH1F* hdeclxyB=new TH1F(namedistr.Data(),"Decay Length XY distribution;Decay Length XY [cm]",200,0,0.15);
306 namedistr="hnormdeclxyB_";
308 TH1F* hnormdeclxyB=new TH1F(namedistr.Data(),"Normalized decay Length XY distribution;Decay Length XY/Err",200,0,6.);
310 namedistr="hdeclxyd0d0B_";
312 TH2F* hdeclxyd0d0B=new TH2F(namedistr.Data(),"Correlation decay Length XY - d_{0}#times d_{0};Decay Length XY [cm];d_{0}#times d_{0}[cm^{2}]",200,0,0.15,200,-0.001,0.001);
314 namedistr="hnormdeclxyd0d0B_";
316 TH2F* hnormdeclxyd0d0B=new TH2F(namedistr.Data(),"Correlation normalized decay Length XY - d_{0}#times d_{0};Decay Length XY/Err;d_{0}#times d_{0}[cm^{2}]",200,0,6,200,-0.001,0.001);
319 namedistr="hcosthetapointB_";
321 TH1F *hcosthetapointB = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
323 namedistr="hcosthetapointxyB_";
325 TH1F *hcosthetapointxyB = new TH1F(namedistr.Data(), "cos#theta_{Point} XY distribution;cos#theta_{Point} XY",300,0.,1.);
327 TH1F* tmpMB = new TH1F(nameMassNocutsB.Data(),"D^{0} invariant mass; M [GeV]; Entries",300,1.5648,2.1648); //range (MD0-300MeV, mD0 + 300MeV)
338 fDistr->Add(hcosthetapointB);
340 fDistr->Add(hcosthetapointxyB);
342 fDistr->Add(hdeclengthB);
344 fDistr->Add(hnormdeclengthB);
346 fDistr->Add(hdeclxyB);
348 fDistr->Add(hnormdeclxyB);
350 fDistr->Add(hdeclxyd0d0B);
351 fDistr->Add(hnormdeclxyd0d0B);
355 //histograms filled only when the secondary vertex is recalculated w/o the daughter tracks (as requested in the cut object)
357 if(fCuts->GetIsPrimaryWithoutDaughters()){
359 namedistr="hd0vpiS_";
361 TH1F *hd0vpiS = new TH1F(namedistr.Data(), "Impact parameter distribution (pions)(vtx w/o these tracks);d0(#pi) [cm]",200,-0.1,0.1);
365 TH1F *hd0vKS = new TH1F(namedistr.Data(), "Impact parameter distribution (kaons) (vtx w/o these tracks);d0(K) [cm]",200,-0.1,0.1);
367 namedistr="hd0d0vS_";
369 TH1F *hd0d0vS = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution (vtx w/o these tracks);d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
371 namedistr="hdeclvS_";
373 TH1F *hdeclengthvS = new TH1F(namedistr.Data(), "Decay Length distribution (vtx w/o tracks);Decay Length [cm]",200,0,0.6);
375 namedistr="hnormdeclvS_";
377 TH1F *hnormdeclengthvS = new TH1F(namedistr.Data(), "Normalized Decay Length distribution (vtx w/o tracks);Decay Length/Err ",200,0,10.);
379 fDistr->Add(hd0vpiS);
381 fDistr->Add(hd0d0vS);
382 fDistr->Add(hdeclengthvS);
383 fDistr->Add(hnormdeclengthvS);
387 namedistr="hd0vmoresB_";
389 TH1F *hd0vmoresB = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
391 namedistr="hd0d0vmoresB_";
393 TH1F *hd0d0vmoresB = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.001,0.001);
398 TH1F *hd0vB = new TH1F(namedistr.Data(), "Impact parameter distribution (vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
400 namedistr="hd0vp0B_";
402 TH1F *hd0vp0B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong + ** vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
404 namedistr="hd0vp1B_";
406 TH1F *hd0vp1B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong - ** vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
408 namedistr="hd0d0vB_";
410 TH1F *hd0d0vB = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution (vtx w/o these tracks);d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
412 namedistr="hdeclvB_";
414 TH1F *hdeclengthvB = new TH1F(namedistr.Data(), "Decay Length distribution (vtx w/o tracks);Decay Length [cm]",200,0,0.6);
416 namedistr="hnormdeclvB_";
418 TH1F *hnormdeclengthvB = new TH1F(namedistr.Data(), "Normalized Decay Length distribution (vtx w/o tracks);Decay Length/Err ",200,0,10.);
421 fDistr->Add(hd0vp0B);
422 fDistr->Add(hd0vp1B);
423 fDistr->Add(hd0vmoresB);
425 fDistr->Add(hd0d0vB);
426 fDistr->Add(hd0d0vmoresB);
428 fDistr->Add(hdeclengthvB);
430 fDistr->Add(hnormdeclengthvB);
435 //histograms of invariant mass distributions
440 TH1F* tmpSt = new TH1F(nameSgn.Data(), "D^{0} invariant mass - MC; M [GeV]; Entries",200,1.5648,2.1648);
442 TH1F *tmpSl=(TH1F*)tmpSt->Clone();
446 //Reflection: histo filled with D0Mass which pass the cut (also) as D0bar and with D0bar which pass (also) the cut as D0
447 TH1F* tmpRt = new TH1F(nameRfl.Data(), "Reflected signal invariant mass - MC; M [GeV]; Entries",200,1.5648,2.1648);
448 //TH1F *tmpRl=(TH1F*)tmpRt->Clone();
449 TH1F* tmpBt = new TH1F(nameBkg.Data(), "Background invariant mass - MC; M [GeV]; Entries",200,1.5648,2.1648);
450 //TH1F *tmpBl=(TH1F*)tmpBt->Clone();
456 fOutputMass->Add(tmpSt);
457 fOutputMass->Add(tmpRt);
458 fOutputMass->Add(tmpBt);
463 TH1F* tmpMt = new TH1F(nameMass.Data(),"D^{0} invariant mass; M [GeV]; Entries",200,1.5648,2.1648);
464 //TH1F *tmpMl=(TH1F*)tmpMt->Clone();
467 //distribution w/o cuts large range
468 // TH1F* tmpMS = new TH1F(nameMassNocutsS.Data(),"D^{0} invariant mass; M [GeV]; Entries",300,0.7,3.);
470 fOutputMass->Add(tmpMt);
472 if(fSys==0){ //histograms filled only in pp to save time in PbPb
479 TH1F *hptpiS = new TH1F(namedistr.Data(), "P_{T} distribution (pions);p_{T} [GeV/c]",200,0.,8.);
483 TH1F *hptKS = new TH1F(namedistr.Data(), "P_{T} distribution (kaons);p_{T} [GeV/c]",200,0.,8.);
486 namedistr="hcosthetastarS_";
488 TH1F *hcosthetastarS = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
492 namedistr="hptpiSnoMcut_";
494 TH1F *hptpiSnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution (pions);p_{T} [GeV/c]",200,0.,8.);
496 namedistr="hptKSnoMcut_";
498 TH1F *hptKSnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution (kaons);p_{T} [GeV/c]",200,0.,8.);
502 fDistr->Add(hcosthetastarS);
504 fDistr->Add(hptpiSnoMcut);
505 fDistr->Add(hptKSnoMcut);
507 // costhetapoint vs d0 or d0d0
508 namedistr="hcosthpointd0S_";
510 TH2F *hcosthpointd0S= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0};cos#theta_{Point};d_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
511 namedistr="hcosthpointd0d0S_";
513 TH2F *hcosthpointd0d0S= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0}#timesd_{0};cos#theta_{Point};d_{0}#timesd_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
515 fDistr->Add(hcosthpointd0S);
516 fDistr->Add(hcosthpointd0d0S);
518 //to compare with AliAnalysisTaskCharmFraction
519 TH1F* tmpS27t = new TH1F(nameSgn27.Data(),"D^{0} invariant mass in M(D^{0}) +/- 27 MeV - MC; M [GeV]; Entries",200,1.5648,2.1648);
520 TH1F *tmpS27l=(TH1F*)tmpS27t->Clone();
524 fOutputMass->Add(tmpS27t);
525 fOutputMass->Add(tmpS27l);
532 TH1F *hptB = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
535 namedistr="hcosthetastarB_";
537 TH1F *hcosthetastarB = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
540 namedistr="hptB1prongnoMcut_";
542 TH1F *hptB1pnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
544 namedistr="hptB2prongsnoMcut_";
546 TH1F *hptB2pnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
549 fDistr->Add(hcosthetastarB);
551 fDistr->Add(hptB1pnoMcut);
552 fDistr->Add(hptB2pnoMcut);
554 //impact parameter of negative/positive track
557 TH1F *hd0p0B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.1,0.1);
561 TH1F *hd0p1B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong -);d0 [cm]",200,-0.1,0.1);
563 //impact parameter corrected for strangeness
564 namedistr="hd0moresB_";
566 TH1F *hd0moresB = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
568 namedistr="hd0d0moresB_";
570 TH1F *hd0d0moresB = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.001,0.001);
573 namedistr="hcosthetapointmoresB_";
575 TH1F *hcosthetapointmoresB = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
577 // costhetapoint vs d0 or d0d0
578 namedistr="hcosthpointd0B_";
580 TH2F *hcosthpointd0B= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0};cos#theta_{Point};d_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
582 namedistr="hcosthpointd0d0B_";
584 TH2F *hcosthpointd0d0B= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0}#timesd_{0};cos#theta_{Point};d_{0}#timesd_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
589 fDistr->Add(hd0moresB);
590 fDistr->Add(hd0d0moresB);
591 fDistr->Add(hcosthetapointmoresB);
594 fDistr->Add(hcosthpointd0B);
597 fDistr->Add(hcosthpointd0d0B);
604 //for Like sign analysis
607 namedistr="hpospair";
608 TH1F* hpospair=new TH1F(namedistr.Data(),"Number of positive pairs",fCuts->GetNPtBins(),-0.5,fCuts->GetNPtBins()-0.5);
609 namedistr="hnegpair";
610 TH1F* hnegpair=new TH1F(namedistr.Data(),"Number of negative pairs",fCuts->GetNPtBins(),-0.5,fCuts->GetNPtBins()-0.5);
611 fOutputMass->Add(hpospair);
612 fOutputMass->Add(hnegpair);
615 const char* nameoutput=GetOutputSlot(3)->GetContainer()->GetName();
617 fNentries=new TH1F(nameoutput, "Integral(1,2) = number of AODs *** Integral(2,3) = number of candidates selected with cuts *** Integral(3,4) = number of D0 selected with cuts *** Integral(4,5) = events with good vertex *** Integral(5,6) = pt out of bounds", 16,-0.5,15.5);
619 fNentries->GetXaxis()->SetBinLabel(1,"nEventsAnal");
620 fNentries->GetXaxis()->SetBinLabel(2,"nCandSel(Cuts)");
621 if(fReadMC) fNentries->GetXaxis()->SetBinLabel(3,"nD0Selected");
622 else fNentries->GetXaxis()->SetBinLabel(3,"Dstar<-D0");
623 fNentries->GetXaxis()->SetBinLabel(4,"nEventsGoodVtxS");
624 fNentries->GetXaxis()->SetBinLabel(5,"ptbin = -1");
625 fNentries->GetXaxis()->SetBinLabel(6,"no daughter");
626 if(fSys==0) fNentries->GetXaxis()->SetBinLabel(7,"nCandSel(Tr)");
628 fNentries->GetXaxis()->SetBinLabel(8,"PID=0");
629 fNentries->GetXaxis()->SetBinLabel(9,"PID=1");
630 fNentries->GetXaxis()->SetBinLabel(10,"PID=2");
631 fNentries->GetXaxis()->SetBinLabel(11,"PID=3");
633 if(fReadMC && fSys==0){
634 fNentries->GetXaxis()->SetBinLabel(12,"K");
635 fNentries->GetXaxis()->SetBinLabel(13,"Lambda");
637 fNentries->GetXaxis()->SetBinLabel(14,"Pile-up Rej");
638 fNentries->GetXaxis()->SetBinLabel(15,"N. of 0SMH");
639 if(fSys==1) fNentries->GetXaxis()->SetBinLabel(16,"Nev in centr");
640 fNentries->GetXaxis()->SetNdivisions(1,kFALSE);
642 fCounter = new AliNormalizationCounter(Form("%s",GetOutputSlot(5)->GetContainer()->GetName()));
645 PostData(1,fOutputMass);
646 if(fFillVarHists) PostData(2,fDistr);
647 PostData(3,fNentries);
648 PostData(5,fCounter);
652 //________________________________________________________________________
653 void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
655 // Execute analysis for current event:
656 // heavy flavor candidates association to MC truth
657 //cout<<"I'm in UserExec"<<endl;
661 // printf(" |M-MD0| [GeV] < %f\n",fD0toKpiCuts[0]);
662 // printf(" dca [cm] < %f\n",fD0toKpiCuts[1]);
663 // printf(" cosThetaStar < %f\n",fD0toKpiCuts[2]);
664 // printf(" pTK [GeV/c] > %f\n",fD0toKpiCuts[3]);
665 // printf(" pTpi [GeV/c] > %f\n",fD0toKpiCuts[4]);
666 // printf(" |d0K| [cm] < %f\n",fD0toKpiCuts[5]);
667 // printf(" |d0pi| [cm] < %f\n",fD0toKpiCuts[6]);
668 // printf(" d0d0 [cm^2] < %f\n",fD0toKpiCuts[7]);
669 // printf(" cosThetaPoint > %f\n",fD0toKpiCuts[8]);
672 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
675 if(fArray==0){ //D0 candidates
676 // load D0->Kpi candidates
677 //cout<<"D0 candidates"<<endl;
679 } else { //LikeSign candidates
680 // load like sign candidates
681 //cout<<"LS candidates"<<endl;
682 bname="LikeSign2Prong";
685 TClonesArray *inputArray=0;
687 if(!aod && AODEvent() && IsStandardAOD()) {
688 // In case there is an AOD handler writing a standard AOD, use the AOD
689 // event in memory rather than the input (ESD) event.
690 aod = dynamic_cast<AliAODEvent*> (AODEvent());
691 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
692 // have to taken from the AOD event hold by the AliAODExtension
693 AliAODHandler* aodHandler = (AliAODHandler*)
694 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
696 if(aodHandler->GetExtensions()) {
697 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
698 AliAODEvent* aodFromExt = ext->GetAOD();
699 inputArray=(TClonesArray*)aodFromExt->GetList()->FindObject(bname.Data());
702 inputArray=(TClonesArray*)aod->GetList()->FindObject(bname.Data());
706 if(!inputArray || !aod) {
707 printf("AliAnalysisTaskSED0Mass::UserExec: input branch not found!\n");
711 // fix for temporary bug in ESDfilter
712 // the AODs with null vertex pointer didn't pass the PhysSel
713 if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001) return;
716 TClonesArray *mcArray = 0;
717 AliAODMCHeader *mcHeader = 0;
721 mcArray = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
723 printf("AliAnalysisTaskSED0Mass::UserExec: MC particles branch not found!\n");
728 mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
730 printf("AliAnalysisTaskSED0Mass::UserExec: MC header branch not found!\n");
735 //printf("VERTEX Z %f %f\n",vtx1->GetZ(),mcHeader->GetVtxZ());
737 //histogram filled with 1 for every AOD
739 fCounter->StoreEvent(aod,fReadMC);
741 // trigger class for PbPb C0SMH-B-NOPF-ALLNOTRD, C0SMH-B-NOPF-ALL
742 TString trigclass=aod->GetFiredTriggerClasses();
743 if(trigclass.Contains("C0SMH-B-NOPF-ALLNOTRD") || trigclass.Contains("C0SMH-B-NOPF-ALL")) fNentries->Fill(14);
745 if(!fCuts->IsEventSelected(aod)) {
746 if(fCuts->GetWhyRejection()==1) // rejected for pileup
748 if(fSys==1 && (fCuts->GetWhyRejection()==2 || fCuts->GetWhyRejection()==3)) fNentries->Fill(15);
752 // AOD primary vertex
753 AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
755 Bool_t isGoodVtx=kFALSE;
758 TString primTitle = vtx1->GetTitle();
759 if(primTitle.Contains("VertexerTracks") && vtx1->GetNContributors()>0) {
764 // loop over candidates
765 Int_t nInD0toKpi = inputArray->GetEntriesFast();
766 if(fDebug>2) printf("Number of D0->Kpi: %d\n",nInD0toKpi);
768 // FILE *f=fopen("4display.txt","a");
769 // fprintf(f,"Number of D0->Kpi: %d\n",nInD0toKpi);
770 Int_t nSelectedloose=0,nSelectedtight=0;
771 for (Int_t iD0toKpi = 0; iD0toKpi < nInD0toKpi; iD0toKpi++) {
772 AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)inputArray->UncheckedAt(iD0toKpi);
774 if(d->GetSelectionMap()) if(!d->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts)){
776 continue; //skip the D0 from Dstar
779 Bool_t unsetvtx=kFALSE;
780 if(!d->GetOwnPrimaryVtx()) {
781 d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
786 if ( fCuts->IsInFiducialAcceptance(d->Pt(),d->Y(421)) ) {
790 if(fCuts->IsSelected(d,AliRDHFCuts::kTracks,aod))fNentries->Fill(6);
792 Int_t ptbin=fCuts->PtBin(d->Pt());
793 if(ptbin==-1) {fNentries->Fill(4); continue;} //out of bounds
794 fIsSelectedCandidate=fCuts->IsSelected(d,AliRDHFCuts::kCandidate,aod); //selected
796 //if(!fCutOnDistr || (fCutOnDistr && fIsSelectedCandidate)) {
797 fDaughterTracks.AddAt((AliAODTrack*)d->GetDaughter(0),0);
798 fDaughterTracks.AddAt((AliAODTrack*)d->GetDaughter(1),1);
800 if(!fDaughterTracks.UncheckedAt(0) || !fDaughterTracks.UncheckedAt(1)) {
801 AliDebug(1,"at least one daughter not found!");
803 fDaughterTracks.Clear();
807 FillVarHists(aod,d,mcArray,fCuts,fDistr);
810 FillMassHists(d,mcArray,fCuts,fOutputMass);
813 fDaughterTracks.Clear();
814 if(unsetvtx) d->UnsetOwnPrimaryVtx();
816 fCounter->StoreCandidates(aod,nSelectedloose,kTRUE);
817 fCounter->StoreCandidates(aod,nSelectedtight,kFALSE);
819 PostData(1,fOutputMass);
820 if(fFillVarHists) PostData(2,fDistr);
821 PostData(3,fNentries);
822 PostData(5,fCounter);
826 //____________________________________________________________________________
827 void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC, AliRDHFCutsD0toKpi *cuts, TList *listout){
829 // function used in UserExec to fill variable histograms:
833 Int_t pdgDgD0toKpi[2]={321,211};
835 if(fReadMC) lab=part->MatchToMC(421,arrMC,2,pdgDgD0toKpi); //return MC particle label if the array corresponds to a D0, -1 if not (cf. AliAODRecoDecay.cxx)
836 //Double_t pt = d->Pt(); //mother pt
837 Int_t isSelectedPID=3;
838 if(!fReadMC || (fReadMC && fUsePid4Distr)) isSelectedPID=cuts->IsSelectedPID(part); //0 rejected,1 D0,2 Dobar, 3 both
839 if (isSelectedPID==0)fNentries->Fill(7);
840 if (isSelectedPID==1)fNentries->Fill(8);
841 if (isSelectedPID==2)fNentries->Fill(9);
842 if (isSelectedPID==3)fNentries->Fill(10);
843 //fNentries->Fill(8+isSelectedPID);
845 if(fCutOnDistr && !fIsSelectedCandidate) return;
846 //printf("\nif no cuts or cuts passed\n");
852 Double_t mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
855 Double_t minvD0 = part->InvMassD0();
858 Double_t minvD0bar = part->InvMassD0bar();
859 //cout<<"inside mass cut"<<endl;
861 Double_t invmasscut=0.03;
863 TString fillthispi="",fillthisK="",fillthis="";
865 Int_t ptbin=cuts->PtBin(part->Pt());
867 Double_t dz1[2],dz2[2],covar1[3],covar2[3];//,d0xd0proper,errd0xd0proper;
868 dz1[0]=-99; dz2[0]=-99;
870 Double_t decl[2]={-99,-99};
871 Bool_t recalcvtx=kFALSE;
875 if(fCuts->GetIsPrimaryWithoutDaughters()){
878 AliAODVertex *vtxProp=0x0;
879 vtxProp=GetPrimaryVtxSkipped(aod);
881 part->SetOwnPrimaryVtx(vtxProp);
882 //Bool_t unsetvtx=kTRUE;
883 //Calculate d0 for daughter tracks with Vtx Skipped
884 AliESDtrack *esdtrack1=new AliESDtrack((AliVTrack*)fDaughterTracks.UncheckedAt(0));
885 AliESDtrack *esdtrack2=new AliESDtrack((AliVTrack*)fDaughterTracks.UncheckedAt(1));
886 esdtrack1->PropagateToDCA(vtxProp,aod->GetMagneticField(),1.,dz1,covar1);
887 esdtrack2->PropagateToDCA(vtxProp,aod->GetMagneticField(),1.,dz2,covar2);
888 delete vtxProp; vtxProp=NULL;
896 decl[0]=part->DecayLength2();
897 decl[1]=part->NormalizedDecayLength2();
898 part->UnsetOwnPrimaryVtx();
902 Double_t cosThetaStarD0 = 99;
903 Double_t cosThetaStarD0bar = 99;
904 Double_t cosPointingAngle = 99;
905 Double_t normalizedDecayLength2 = -1, normalizedDecayLengthxy=-1;
906 Double_t decayLength2 = -1, decayLengthxy=-1;
907 Double_t ptProng[2]={-99,-99};
908 Double_t d0Prong[2]={-99,-99};
912 if(!fUsePid4Distr) isSelectedPID=0;
913 if((lab>=0 && fReadMC) || (!fReadMC && isSelectedPID)){ //signal (from MC or PID)
915 //check pdg of the prongs
916 AliAODTrack *prong0=(AliAODTrack*)fDaughterTracks.UncheckedAt(0);
917 AliAODTrack *prong1=(AliAODTrack*)fDaughterTracks.UncheckedAt(1);
919 if(!prong0 || !prong1) {
924 labprong[0]=prong0->GetLabel();
925 labprong[1]=prong1->GetLabel();
927 AliAODMCParticle *mcprong=0;
928 Int_t pdgProng[2]={0,0};
930 for (Int_t iprong=0;iprong<2;iprong++){
931 if(fReadMC && labprong[iprong]>=0) {
932 mcprong= (AliAODMCParticle*)arrMC->At(labprong[iprong]);
933 pdgProng[iprong]=mcprong->GetPdgCode();
938 //no mass cut ditributions: ptbis
940 fillthispi="hptpiSnoMcut_";
943 fillthisK="hptKSnoMcut_";
946 if ((TMath::Abs(pdgProng[0]) == 211 && TMath::Abs(pdgProng[1]) == 321)
947 || (isSelectedPID==1 || isSelectedPID==3)){
948 ((TH1F*)listout->FindObject(fillthispi))->Fill(prong0->Pt());
949 ((TH1F*)listout->FindObject(fillthisK))->Fill(prong1->Pt());
952 if ((TMath::Abs(pdgProng[0]) == 321 && TMath::Abs(pdgProng[1]) == 211)
953 || (isSelectedPID==2 || isSelectedPID==3)){
954 ((TH1F*)listout->FindObject(fillthisK))->Fill(prong0->Pt());
955 ((TH1F*)listout->FindObject(fillthispi))->Fill(prong1->Pt());
959 //no mass cut ditributions: mass
963 if ((fReadMC && ((AliAODMCParticle*)arrMC->At(lab))->GetPdgCode() == 421)
964 || (!fReadMC && (isSelectedPID==1 || isSelectedPID==3))){//D0
965 ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0);
968 if(fReadMC || (!fReadMC && isSelectedPID > 1))
969 ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0bar);
972 //apply cut on invariant mass on the pair
973 if(TMath::Abs(minvD0-mPDG)<invmasscut || TMath::Abs(minvD0bar-mPDG)<invmasscut){
975 cosThetaStarD0 = part->CosThetaStarD0();
976 cosThetaStarD0bar = part->CosThetaStarD0bar();
977 cosPointingAngle = part->CosPointingAngle();
978 normalizedDecayLength2 = part->NormalizedDecayLength2();
979 decayLength2 = part->DecayLength2();
980 decayLengthxy = part->DecayLengthXY();
981 normalizedDecayLengthxy=decayLengthxy/part->DecayLengthXYError();
983 ptProng[0]=prong0->Pt(); ptProng[1]=prong1->Pt();
984 d0Prong[0]=part->Getd0Prong(0); d0Prong[1]=part->Getd0Prong(1);
986 if(fArray==1) cout<<"LS signal: ERROR"<<endl;
987 for (Int_t iprong=0; iprong<2; iprong++){
988 AliAODTrack *prong=(AliAODTrack*)fDaughterTracks.UncheckedAt(iprong);
989 if (fReadMC) labprong[iprong]=prong->GetLabel();
991 //cout<<"prong name = "<<prong->GetName()<<" label = "<<prong->GetLabel()<<endl;
993 if(fReadMC && labprong[iprong]>=0) {
994 mcprong= (AliAODMCParticle*)arrMC->At(labprong[iprong]);
995 pdgprong=mcprong->GetPdgCode();
998 Bool_t isPionHere[2]={(isSelectedPID==1 || isSelectedPID==3) ? kTRUE : kFALSE,(isSelectedPID==2 || isSelectedPID==3) ? kTRUE : kFALSE};
1000 if(TMath::Abs(pdgprong)==211 || isPionHere[iprong]) {
1004 fillthispi="hptpiS_";
1006 ((TH1F*)listout->FindObject(fillthispi))->Fill(ptProng[iprong]);
1008 fillthispi="hd0piS_";
1010 ((TH1F*)listout->FindObject(fillthispi))->Fill(d0Prong[iprong]);
1013 fillthispi="hd0vpiS_";
1015 ((TH1F*)listout->FindObject(fillthispi))->Fill(d0[iprong]);
1020 if(TMath::Abs(pdgprong)==321 || !isPionHere[iprong]) {
1021 //cout<<"kappa"<<endl;
1025 ((TH1F*)listout->FindObject(fillthisK))->Fill(ptProng[iprong]);
1029 ((TH1F*)listout->FindObject(fillthisK))->Fill(d0Prong[iprong]);
1031 fillthisK="hd0vKS_";
1033 ((TH1F*)listout->FindObject(fillthisK))->Fill(d0[iprong]);
1038 fillthis="hcosthpointd0S_";
1040 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,d0Prong[iprong]);
1042 } //end loop on prongs
1046 ((TH1F*)listout->FindObject(fillthis))->Fill(part->GetDCA());
1048 fillthis="hcosthetapointS_";
1050 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle);
1052 fillthis="hcosthetapointxyS_";
1054 ((TH1F*)listout->FindObject(fillthis))->Fill(part->CosPointingAngleXY());
1059 ((TH1F*)listout->FindObject(fillthis))->Fill(part->Prodd0d0());
1063 ((TH1F*)listout->FindObject(fillthis))->Fill(decayLength2);
1065 fillthis="hnormdeclS_";
1067 ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLength2);
1069 fillthis="hdeclxyS_";
1071 ((TH1F*)listout->FindObject(fillthis))->Fill(decayLengthxy);
1073 fillthis="hnormdeclxyS_";
1075 ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLengthxy);
1077 fillthis="hdeclxyd0d0S_";
1079 ((TH2F*)listout->FindObject(fillthis))->Fill(decayLengthxy,d0Prong[0]*d0Prong[1]);
1081 fillthis="hnormdeclxyd0d0S_";
1083 ((TH2F*)listout->FindObject(fillthis))->Fill(normalizedDecayLengthxy,d0Prong[0]*d0Prong[1]);
1086 fillthis="hdeclvS_";
1088 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[0]);
1090 fillthis="hnormdeclvS_";
1092 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[1]);
1094 fillthis="hd0d0vS_";
1096 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]*d0[1]);
1100 fillthis="hcosthetastarS_";
1102 if ((fReadMC && ((AliAODMCParticle*)arrMC->At(lab))->GetPdgCode() == 421)) ((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0);
1104 if (fReadMC || isSelectedPID>1)((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0bar);
1105 if(isSelectedPID==1 || isSelectedPID==3)((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0);
1108 fillthis="hcosthpointd0d0S_";
1110 ((TH2F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,part->Prodd0d0());
1115 } else{ //Background or LS
1117 //cout<<"is background"<<endl;
1119 //no mass cut distributions: mass, ptbis
1123 if (!fCutOnDistr || (fCutOnDistr && (fIsSelectedCandidate==1 || fIsSelectedCandidate==3))) ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0);
1124 if (!fCutOnDistr || (fCutOnDistr && fIsSelectedCandidate>1)) ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0bar);
1126 fillthis="hptB1prongnoMcut_";
1129 ((TH1F*)listout->FindObject(fillthis))->Fill(((AliAODTrack*)fDaughterTracks.UncheckedAt(0))->Pt());
1131 fillthis="hptB2prongsnoMcut_";
1133 ((TH1F*)listout->FindObject(fillthis))->Fill(((AliAODTrack*)fDaughterTracks.UncheckedAt(0))->Pt());
1134 ((TH1F*)listout->FindObject(fillthis))->Fill(((AliAODTrack*)fDaughterTracks.UncheckedAt(0))->Pt());
1136 //apply cut on invariant mass on the pair
1137 if(TMath::Abs(minvD0-mPDG)<invmasscut || TMath::Abs(minvD0bar-mPDG)<invmasscut){
1139 ptProng[0]=((AliAODTrack*)fDaughterTracks.UncheckedAt(0))->Pt(); ptProng[1]=((AliAODTrack*)fDaughterTracks.UncheckedAt(0))->Pt();
1140 cosThetaStarD0 = part->CosThetaStarD0();
1141 cosThetaStarD0bar = part->CosThetaStarD0bar();
1144 cosPointingAngle = part->CosPointingAngle();
1145 normalizedDecayLength2 = part->NormalizedDecayLength2();
1146 decayLength2 = part->DecayLength2();
1147 decayLengthxy = part->DecayLengthXY();
1148 normalizedDecayLengthxy=decayLengthxy/part->DecayLengthXYError();
1149 d0Prong[0]=part->Getd0Prong(0); d0Prong[1]=part->Getd0Prong(1);
1152 AliAODTrack *prongg=(AliAODTrack*)fDaughterTracks.UncheckedAt(0);
1154 if(fDebug>2) cout<<"No daughter found";
1159 if(prongg->Charge()==1) {
1160 //fTotPosPairs[ptbin]++;
1161 ((TH1F*)fDistr->FindObject("hpospair"))->Fill(ptbin);
1163 //fTotNegPairs[ptbin]++;
1164 ((TH1F*)fDistr->FindObject("hnegpair"))->Fill(ptbin);
1171 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[0]);
1172 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[1]);
1175 Int_t pdgMother[2]={0,0};
1176 Double_t factor[2]={1,1};
1178 for(Int_t iprong=0;iprong<2;iprong++){
1179 AliAODTrack *prong=(AliAODTrack*)fDaughterTracks.UncheckedAt(iprong);
1180 lab=prong->GetLabel();
1182 AliAODMCParticle* mcprong=(AliAODMCParticle*)arrMC->At(lab);
1184 Int_t labmom=mcprong->GetMother();
1186 AliAODMCParticle* mcmother=(AliAODMCParticle*)arrMC->At(labmom);
1187 if(mcmother) pdgMother[iprong]=mcmother->GetPdgCode();
1194 fillthis="hd0moresB_";
1197 if(TMath::Abs(pdgMother[iprong])==310 || TMath::Abs(pdgMother[iprong])==130 || TMath::Abs(pdgMother[iprong])==321){ //K^0_S, K^0_L, K^+-
1198 if(ptProng[iprong]<=1)factor[iprong]=1./.7;
1199 else factor[iprong]=1./.6;
1200 fNentries->Fill(11);
1203 if(TMath::Abs(pdgMother[iprong])==3122) { //Lambda
1204 factor[iprong]=1./0.25;
1205 fNentries->Fill(12);
1207 fillthis="hd0moresB_";
1210 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[iprong],factor[iprong]);
1213 fillthis="hd0vmoresB_";
1215 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[iprong],factor[iprong]);
1221 fillthis="hd0d0moresB_";
1223 ((TH1F*)listout->FindObject(fillthis))->Fill(part->Prodd0d0(),factor[0]*factor[1]);
1225 fillthis="hcosthetapointmoresB_";
1227 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,factor[0]*factor[1]);
1230 fillthis="hd0d0vmoresB_";
1232 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]*d0[1],factor[0]*factor[1]);
1238 //normalise pt distr to half afterwards
1241 ((TH1F*)listout->FindObject(fillthis))->Fill(ptProng[0]);
1242 ((TH1F*)listout->FindObject(fillthis))->Fill(ptProng[1]);
1244 fillthis="hcosthetastarB_";
1246 if (!fCutOnDistr || (fCutOnDistr && (fIsSelectedCandidate==1 || fIsSelectedCandidate==3)))((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0);
1247 if (!fCutOnDistr || (fCutOnDistr && fIsSelectedCandidate>1))((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0bar);
1252 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[0]);
1255 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[1]);
1257 fillthis="hcosthpointd0d0B_";
1259 ((TH2F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,part->Prodd0d0());
1261 fillthis="hcosthpointd0B_";
1263 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,d0Prong[0]);
1264 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,d0Prong[1]);
1269 fillthis="hd0vp0B_";
1271 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]);
1272 fillthis="hd0vp1B_";
1274 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[1]);
1278 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]);
1279 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[1]);
1287 ((TH1F*)listout->FindObject(fillthis))->Fill(part->GetDCA());
1291 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[0]*d0Prong[1]);
1294 fillthis="hd0d0vB_";
1296 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]*d0[1]);
1299 fillthis="hcosthetapointB_";
1301 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle);
1303 fillthis="hcosthetapointxyB_";
1305 ((TH1F*)listout->FindObject(fillthis))->Fill(part->CosPointingAngleXY());
1309 ((TH1F*)listout->FindObject(fillthis))->Fill(decayLength2);
1311 fillthis="hnormdeclB_";
1313 ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLength2);
1315 fillthis="hdeclxyB_";
1317 ((TH1F*)listout->FindObject(fillthis))->Fill(decayLengthxy);
1319 fillthis="hnormdeclxyB_";
1321 ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLengthxy);
1323 fillthis="hdeclxyd0d0B_";
1325 ((TH2F*)listout->FindObject(fillthis))->Fill(decayLengthxy,d0Prong[0]*d0Prong[1]);
1327 fillthis="hnormdeclxyd0d0B_";
1329 ((TH2F*)listout->FindObject(fillthis))->Fill(normalizedDecayLengthxy,d0Prong[0]*d0Prong[1]);
1333 fillthis="hdeclvB_";
1335 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[0]);
1337 fillthis="hnormdeclvB_";
1339 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[1]);
1344 }//else (background)
1348 //____________________________________________________________________________
1350 void AliAnalysisTaskSED0Mass::FillMassHists(AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC, AliRDHFCutsD0toKpi* cuts, TList *listout){
1352 // function used in UserExec to fill mass histograms:
1356 Double_t mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
1358 //cout<<"is selected = "<<fIsSelectedCandidate<<endl;
1360 //cout<<"check cuts = "<<endl;
1362 if (!fIsSelectedCandidate){
1363 //cout<<"Not Selected"<<endl;
1364 //cout<<"Rejected because "<<cuts->GetWhy()<<endl;
1369 if(fDebug>2) cout<<"Candidate selected"<<endl;
1371 Double_t invmassD0 = part->InvMassD0(), invmassD0bar = part->InvMassD0bar();
1372 //printf("SELECTED\n");
1373 Int_t ptbin=cuts->PtBin(part->Pt());
1375 // AliAODTrack *prong=(AliAODTrack*)fDaughterTracks.UncheckedAt(0);
1377 // AliDebug(2,"No daughter found");
1381 // if(prong->Charge()==1) {
1382 // ((TH1F*)fDistr->FindObject("hpospair"))->Fill(fCuts->GetNPtBins()+ptbin);
1383 // //fTotPosPairs[ptbin]++;
1385 // ((TH1F*)fDistr->FindObject("hnegpair"))->Fill(fCuts->GetNPtBins()+ptbin);
1386 // //fTotNegPairs[ptbin]++;
1390 // for(Int_t it=0;it<2;it++){
1392 // //request on spd points to be addes
1393 // if(/*nSPD==2 && */part->Pt() > 5. && (TMath::Abs(invmassD0-mPDG)<0.01 || TMath::Abs(invmassD0bar-mPDG)<0.01)){
1394 // FILE *f=fopen("4display.txt","a");
1395 // fprintf(f,"pt: %f \n Rapidity: %f \t Period Number: %x \t Run Number: %d \t BunchCrossNumb: %d \t OrbitNumber: %d\n",part->Pt(),part->Y(421),aod->GetPeriodNumber(),aod->GetRunNumber(),aod->GetBunchCrossNumber(),aod->GetOrbitNumber());
1397 // //printf("PrimVtx NContributors: %d \n Prongs Rel Angle: %f \n \n",ncont,relangle);
1401 TString fillthis="";
1402 Int_t pdgDgD0toKpi[2]={321,211};
1404 if (fReadMC) labD0 = part->MatchToMC(421,arrMC,2,pdgDgD0toKpi); //return MC particle label if the array corresponds to a D0, -1 if not (cf. AliAODRecoDecay.cxx)
1406 //count candidates selected by cuts
1408 //count true D0 selected by cuts
1409 if (fReadMC && labD0>=0) fNentries->Fill(2);
1411 if ((fIsSelectedCandidate==1 || fIsSelectedCandidate==3) && fFillOnlyD0D0bar<2) { //D0
1414 if(fArray==1) cout<<"LS signal ERROR"<<endl;
1416 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
1417 Int_t pdgD0 = partD0->GetPdgCode();
1418 //cout<<"pdg = "<<pdgD0<<endl;
1419 if (pdgD0==421){ //D0
1420 //cout<<"Fill S with D0"<<endl;
1421 fillthis="histSgn_";
1423 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1425 if(TMath::Abs(invmassD0 - mPDG) < 0.027){
1426 fillthis="histSgn27_";
1428 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1431 } else{ //it was a D0bar
1432 fillthis="histRfl_";
1434 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1436 } else {//background
1437 fillthis="histBkg_";
1439 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1443 fillthis="histMass_";
1445 //cout<<"Filling "<<fillthis<<endl;
1447 //printf("Fill mass with D0");
1448 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1452 if (fIsSelectedCandidate>1 && (fFillOnlyD0D0bar==0 || fFillOnlyD0D0bar==2)) { //D0bar
1455 if(fArray==1) cout<<"LS signal ERROR"<<endl;
1456 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
1457 Int_t pdgD0 = partD0->GetPdgCode();
1458 //cout<<" pdg = "<<pdgD0<<endl;
1459 if (pdgD0==-421){ //D0bar
1460 fillthis="histSgn_";
1462 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
1463 // if (TMath::Abs(invmassD0bar - mPDG) < 0.027){
1464 // fillthis="histSgn27_";
1466 // ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
1471 fillthis="histRfl_";
1473 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
1475 } else {//background or LS
1476 fillthis="histBkg_";
1478 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
1481 fillthis="histMass_";
1483 //printf("Fill mass with D0bar");
1484 ((TH1F*)listout->FindObject(fillthis))->Fill(invmassD0bar);
1492 //__________________________________________________________________________
1493 AliAODVertex* AliAnalysisTaskSED0Mass::GetPrimaryVtxSkipped(AliAODEvent *aodev){
1494 //Calculate the primary vertex w/o the daughter tracks of the candidate
1497 Int_t nTrksToSkip=2;
1498 AliAODTrack *dgTrack = (AliAODTrack*)fDaughterTracks.UncheckedAt(0);
1500 AliDebug(2,"no daughter found!");
1503 skipped[0]=dgTrack->GetID();
1504 dgTrack = (AliAODTrack*)fDaughterTracks.UncheckedAt(1);
1506 AliDebug(2,"no daughter found!");
1509 skipped[1]=dgTrack->GetID();
1511 AliESDVertex *vertexESD=0x0;
1512 AliAODVertex *vertexAOD=0x0;
1513 AliVertexerTracks *vertexer = new AliVertexerTracks(aodev->GetMagneticField());
1516 vertexer->SetSkipTracks(nTrksToSkip,skipped);
1517 vertexer->SetMinClusters(4);
1518 vertexESD = (AliESDVertex*)vertexer->FindPrimaryVertex(aodev);
1519 if(!vertexESD) return vertexAOD;
1520 if(vertexESD->GetNContributors()<=0) {
1521 AliDebug(2,"vertexing failed");
1522 delete vertexESD; vertexESD=NULL;
1526 delete vertexer; vertexer=NULL;
1529 // convert to AliAODVertex
1530 Double_t pos[3],cov[6],chi2perNDF;
1531 vertexESD->GetXYZ(pos); // position
1532 vertexESD->GetCovMatrix(cov); //covariance matrix
1533 chi2perNDF = vertexESD->GetChi2toNDF();
1534 delete vertexESD; vertexESD=NULL;
1536 vertexAOD = new AliAODVertex(pos,cov,chi2perNDF);
1542 //________________________________________________________________________
1543 void AliAnalysisTaskSED0Mass::Terminate(Option_t */*option*/)
1545 // Terminate analysis
1547 if(fDebug > 1) printf("AnalysisTaskSED0Mass: Terminate() \n");
1550 fOutputMass = dynamic_cast<TList*> (GetOutputData(1));
1552 printf("ERROR: fOutputMass not available\n");
1556 fDistr = dynamic_cast<TList*> (GetOutputData(2));
1558 printf("ERROR: fDistr not available\n");
1563 fNentries = dynamic_cast<TH1F*>(GetOutputData(3));
1566 printf("ERROR: fNEntries not available\n");
1569 fCuts = dynamic_cast<AliRDHFCutsD0toKpi*>(GetOutputData(4));
1571 printf("ERROR: fCuts not available\n");
1574 fCounter = dynamic_cast<AliNormalizationCounter*>(GetOutputData(5));
1576 printf("ERROR: fCounter not available\n");
1579 Int_t nptbins=fCuts->GetNPtBins();
1580 for(Int_t ipt=0;ipt<nptbins;ipt++){
1582 if(fArray==1 && fFillVarHists){
1583 fLsNormalization = 2.*TMath::Sqrt(((TH1F*)fDistr->FindObject("hpospair"))->Integral(nptbins+ipt+1,nptbins+ipt+2)*((TH1F*)fDistr->FindObject("hnegpair"))->Integral(nptbins+ipt+1,nptbins+ipt+2)); //after cuts
1586 if(fLsNormalization>1e-6) {
1588 TString massName="histMass_";
1590 ((TH1F*)fOutputMass->FindObject(massName))->Scale((1/fLsNormalization)*((TH1F*)fOutputMass->FindObject(massName))->GetEntries());
1595 fLsNormalization = 2.*TMath::Sqrt(((TH1F*)fDistr->FindObject("hpospair"))->Integral(ipt+1,ipt+2)*((TH1F*)fDistr->FindObject("hnegpair"))->Integral(ipt+1,ipt+2));
1596 //fLsNormalization = 2.*TMath::Sqrt(fTotPosPairs[4]*fTotNegPairs[4]);
1598 if(fLsNormalization>1e-6) {
1600 TString nameDistr="hptB_";
1602 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1605 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1606 nameDistr="hcosthetastarB_";
1608 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1611 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1612 nameDistr="hd0d0B_";
1614 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1615 nameDistr="hcosthetapointB_";
1617 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1619 nameDistr="hcosthpointd0d0B_";
1621 ((TH2F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH2F*)fDistr->FindObject(nameDistr))->GetEntries());
1626 TString cvname,cstname;
1636 TCanvas *cMass=new TCanvas(cvname,cvname);
1638 ((TH1F*)fOutputMass->FindObject("histMass_3"))->Draw();
1640 TCanvas* cStat=new TCanvas(cstname,Form("Stat%s",fArray ? "LS" : "D0"));
1643 fNentries->Draw("htext0");
1645 // TCanvas *ccheck=new TCanvas(Form("cc%d",fArray),Form("cc%d",fArray));