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),
77 fIsRejectSDDClusters(0)
79 // Default constructor
82 //________________________________________________________________________
83 AliAnalysisTaskSED0Mass::AliAnalysisTaskSED0Mass(const char *name,AliRDHFCutsD0toKpi* cuts):
84 AliAnalysisTaskSE(name),
98 fIsSelectedCandidate(0),
101 fIsRejectSDDClusters(0)
103 // Default constructor
105 fNPtBins=cuts->GetNPtBins();
109 // Output slot #1 writes into a TList container (mass with cuts)
110 DefineOutput(1,TList::Class()); //My private output
111 // Output slot #2 writes into a TList container (distributions)
112 if(fFillVarHists) DefineOutput(2,TList::Class()); //My private output
113 // Output slot #3 writes into a TH1F container (number of events)
114 DefineOutput(3,TH1F::Class()); //My private output
115 // Output slot #4 writes into a TList container (cuts)
116 DefineOutput(4,AliRDHFCutsD0toKpi::Class()); //My private output
117 // Output slot #5 writes Normalization Counter
118 DefineOutput(5,AliNormalizationCounter::Class());
121 //________________________________________________________________________
122 AliAnalysisTaskSED0Mass::~AliAnalysisTaskSED0Mass()
147 //________________________________________________________________________
148 void AliAnalysisTaskSED0Mass::Init()
152 if(fDebug > 1) printf("AnalysisTaskSED0Mass::Init() \n");
155 AliRDHFCutsD0toKpi* copyfCuts=new AliRDHFCutsD0toKpi(*fCuts);
156 const char* nameoutput=GetOutputSlot(4)->GetContainer()->GetName();
157 copyfCuts->SetName(nameoutput);
159 PostData(4,copyfCuts);
165 //________________________________________________________________________
166 void AliAnalysisTaskSED0Mass::UserCreateOutputObjects()
169 // Create the output container
171 if(fDebug > 1) printf("AnalysisTaskSED0Mass::UserCreateOutputObjects() \n");
173 // Several histograms are more conveniently managed in a TList
174 fOutputMass = new TList();
175 fOutputMass->SetOwner();
176 fOutputMass->SetName("listMass");
178 fDistr = new TList();
180 fDistr->SetName("distributionslist");
182 TString nameMass=" ",nameSgn27=" ",nameSgn=" ", nameBkg=" ", nameRfl=" ",nameMassNocutsS =" ",nameMassNocutsB =" ", namedistr=" ";
184 for(Int_t i=0;i<fCuts->GetNPtBins();i++){
186 nameMass="histMass_";
188 nameSgn27="histSgn27_";
196 nameMassNocutsS="hMassS_";
198 nameMassNocutsB="hMassB_";
201 //histograms of cut variable distributions
207 TH1F *hdcaS = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
211 TH1F *hd0piS = new TH1F(namedistr.Data(), "Impact parameter distribution (pions);d0(#pi) [cm]",200,-0.1,0.1);
215 TH1F *hd0KS = new TH1F(namedistr.Data(), "Impact parameter distribution (kaons);d0(K) [cm]",200,-0.1,0.1);
218 TH1F *hd0d0S = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution;d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
223 TH1F *hdeclengthS = new TH1F(namedistr.Data(), "Decay Length^{2} distribution;Decay Length^{2} [cm]",200,0,0.015);
225 namedistr="hnormdeclS_";
227 TH1F *hnormdeclengthS = new TH1F(namedistr.Data(), "Normalized Decay Length^{2} distribution;(Decay Length/Err)^{2} ",200,0,12.);
229 namedistr="hdeclxyS_";
231 TH1F* hdeclxyS=new TH1F(namedistr.Data(),"Decay Length XY distribution;Decay Length XY [cm]",200,0,0.15);
232 namedistr="hnormdeclxyS_";
234 TH1F* hnormdeclxyS=new TH1F(namedistr.Data(),"Normalized decay Length XY distribution;Decay Length XY/Err",200,0,6.);
236 namedistr="hdeclxyd0d0S_";
238 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);
240 namedistr="hnormdeclxyd0d0S_";
242 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);
245 namedistr="hcosthetapointS_";
247 TH1F *hcosthetapointS = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
249 namedistr="hcosthetapointxyS_";
251 TH1F *hcosthetapointxyS = new TH1F(namedistr.Data(), "cos#theta_{Point} XYdistribution;cos#theta_{Point}",300,0.,1.);
253 TH1F* tmpMS = new TH1F(nameMassNocutsS.Data(),"D^{0} invariant mass; M [GeV]; Entries",300,1.5648,2.1648); //range (MD0-300MeV, mD0 + 300MeV)
264 fDistr->Add(hcosthetapointS);
266 fDistr->Add(hcosthetapointxyS);
268 fDistr->Add(hdeclengthS);
270 fDistr->Add(hnormdeclengthS);
272 fDistr->Add(hdeclxyS);
274 fDistr->Add(hnormdeclxyS);
276 fDistr->Add(hdeclxyd0d0S);
277 fDistr->Add(hnormdeclxyd0d0S);
285 TH1F *hdcaB = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
290 TH1F *hd0B = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
294 TH1F *hd0d0B = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution;d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
299 TH1F *hdeclengthB = new TH1F(namedistr.Data(), "Decay Length^{2} distribution;Decay Length^{2} [cm^{2}]",200,0,0.015);
301 namedistr="hnormdeclB_";
303 TH1F *hnormdeclengthB = new TH1F(namedistr.Data(), "Normalized Decay Length distribution;(Decay Length/Err)^{2} ",200,0,12.);
305 namedistr="hdeclxyB_";
307 TH1F* hdeclxyB=new TH1F(namedistr.Data(),"Decay Length XY distribution;Decay Length XY [cm]",200,0,0.15);
308 namedistr="hnormdeclxyB_";
310 TH1F* hnormdeclxyB=new TH1F(namedistr.Data(),"Normalized decay Length XY distribution;Decay Length XY/Err",200,0,6.);
312 namedistr="hdeclxyd0d0B_";
314 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);
316 namedistr="hnormdeclxyd0d0B_";
318 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);
321 namedistr="hcosthetapointB_";
323 TH1F *hcosthetapointB = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
325 namedistr="hcosthetapointxyB_";
327 TH1F *hcosthetapointxyB = new TH1F(namedistr.Data(), "cos#theta_{Point} XY distribution;cos#theta_{Point} XY",300,0.,1.);
329 TH1F* tmpMB = new TH1F(nameMassNocutsB.Data(),"D^{0} invariant mass; M [GeV]; Entries",300,1.5648,2.1648); //range (MD0-300MeV, mD0 + 300MeV)
340 fDistr->Add(hcosthetapointB);
342 fDistr->Add(hcosthetapointxyB);
344 fDistr->Add(hdeclengthB);
346 fDistr->Add(hnormdeclengthB);
348 fDistr->Add(hdeclxyB);
350 fDistr->Add(hnormdeclxyB);
352 fDistr->Add(hdeclxyd0d0B);
353 fDistr->Add(hnormdeclxyd0d0B);
357 //histograms filled only when the secondary vertex is recalculated w/o the daughter tracks (as requested in the cut object)
359 if(fCuts->GetIsPrimaryWithoutDaughters()){
361 namedistr="hd0vpiS_";
363 TH1F *hd0vpiS = new TH1F(namedistr.Data(), "Impact parameter distribution (pions)(vtx w/o these tracks);d0(#pi) [cm]",200,-0.1,0.1);
367 TH1F *hd0vKS = new TH1F(namedistr.Data(), "Impact parameter distribution (kaons) (vtx w/o these tracks);d0(K) [cm]",200,-0.1,0.1);
369 namedistr="hd0d0vS_";
371 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);
373 namedistr="hdeclvS_";
375 TH1F *hdeclengthvS = new TH1F(namedistr.Data(), "Decay Length distribution (vtx w/o tracks);Decay Length [cm]",200,0,0.6);
377 namedistr="hnormdeclvS_";
379 TH1F *hnormdeclengthvS = new TH1F(namedistr.Data(), "Normalized Decay Length distribution (vtx w/o tracks);Decay Length/Err ",200,0,10.);
381 fDistr->Add(hd0vpiS);
383 fDistr->Add(hd0d0vS);
384 fDistr->Add(hdeclengthvS);
385 fDistr->Add(hnormdeclengthvS);
389 namedistr="hd0vmoresB_";
391 TH1F *hd0vmoresB = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
393 namedistr="hd0d0vmoresB_";
395 TH1F *hd0d0vmoresB = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.001,0.001);
400 TH1F *hd0vB = new TH1F(namedistr.Data(), "Impact parameter distribution (vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
402 namedistr="hd0vp0B_";
404 TH1F *hd0vp0B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong + ** vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
406 namedistr="hd0vp1B_";
408 TH1F *hd0vp1B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong - ** vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
410 namedistr="hd0d0vB_";
412 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);
414 namedistr="hdeclvB_";
416 TH1F *hdeclengthvB = new TH1F(namedistr.Data(), "Decay Length distribution (vtx w/o tracks);Decay Length [cm]",200,0,0.6);
418 namedistr="hnormdeclvB_";
420 TH1F *hnormdeclengthvB = new TH1F(namedistr.Data(), "Normalized Decay Length distribution (vtx w/o tracks);Decay Length/Err ",200,0,10.);
423 fDistr->Add(hd0vp0B);
424 fDistr->Add(hd0vp1B);
425 fDistr->Add(hd0vmoresB);
427 fDistr->Add(hd0d0vB);
428 fDistr->Add(hd0d0vmoresB);
430 fDistr->Add(hdeclengthvB);
432 fDistr->Add(hnormdeclengthvB);
437 //histograms of invariant mass distributions
442 TH1F* tmpSt = new TH1F(nameSgn.Data(), "D^{0} invariant mass - MC; M [GeV]; Entries",200,1.5648,2.1648);
444 TH1F *tmpSl=(TH1F*)tmpSt->Clone();
448 //Reflection: histo filled with D0Mass which pass the cut (also) as D0bar and with D0bar which pass (also) the cut as D0
449 TH1F* tmpRt = new TH1F(nameRfl.Data(), "Reflected signal invariant mass - MC; M [GeV]; Entries",200,1.5648,2.1648);
450 //TH1F *tmpRl=(TH1F*)tmpRt->Clone();
451 TH1F* tmpBt = new TH1F(nameBkg.Data(), "Background invariant mass - MC; M [GeV]; Entries",200,1.5648,2.1648);
452 //TH1F *tmpBl=(TH1F*)tmpBt->Clone();
458 fOutputMass->Add(tmpSt);
459 fOutputMass->Add(tmpRt);
460 fOutputMass->Add(tmpBt);
465 TH1F* tmpMt = new TH1F(nameMass.Data(),"D^{0} invariant mass; M [GeV]; Entries",200,1.5648,2.1648);
466 //TH1F *tmpMl=(TH1F*)tmpMt->Clone();
469 //distribution w/o cuts large range
470 // TH1F* tmpMS = new TH1F(nameMassNocutsS.Data(),"D^{0} invariant mass; M [GeV]; Entries",300,0.7,3.);
472 fOutputMass->Add(tmpMt);
474 if(fSys==0){ //histograms filled only in pp to save time in PbPb
481 TH1F *hptpiS = new TH1F(namedistr.Data(), "P_{T} distribution (pions);p_{T} [GeV/c]",200,0.,8.);
485 TH1F *hptKS = new TH1F(namedistr.Data(), "P_{T} distribution (kaons);p_{T} [GeV/c]",200,0.,8.);
488 namedistr="hcosthetastarS_";
490 TH1F *hcosthetastarS = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
494 namedistr="hptpiSnoMcut_";
496 TH1F *hptpiSnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution (pions);p_{T} [GeV/c]",200,0.,8.);
498 namedistr="hptKSnoMcut_";
500 TH1F *hptKSnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution (kaons);p_{T} [GeV/c]",200,0.,8.);
504 fDistr->Add(hcosthetastarS);
506 fDistr->Add(hptpiSnoMcut);
507 fDistr->Add(hptKSnoMcut);
509 // costhetapoint vs d0 or d0d0
510 namedistr="hcosthpointd0S_";
512 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);
513 namedistr="hcosthpointd0d0S_";
515 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);
517 fDistr->Add(hcosthpointd0S);
518 fDistr->Add(hcosthpointd0d0S);
520 //to compare with AliAnalysisTaskCharmFraction
521 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);
522 TH1F *tmpS27l=(TH1F*)tmpS27t->Clone();
526 fOutputMass->Add(tmpS27t);
527 fOutputMass->Add(tmpS27l);
534 TH1F *hptB = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
537 namedistr="hcosthetastarB_";
539 TH1F *hcosthetastarB = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
542 namedistr="hptB1prongnoMcut_";
544 TH1F *hptB1pnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
546 namedistr="hptB2prongsnoMcut_";
548 TH1F *hptB2pnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
551 fDistr->Add(hcosthetastarB);
553 fDistr->Add(hptB1pnoMcut);
554 fDistr->Add(hptB2pnoMcut);
556 //impact parameter of negative/positive track
559 TH1F *hd0p0B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.1,0.1);
563 TH1F *hd0p1B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong -);d0 [cm]",200,-0.1,0.1);
565 //impact parameter corrected for strangeness
566 namedistr="hd0moresB_";
568 TH1F *hd0moresB = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
570 namedistr="hd0d0moresB_";
572 TH1F *hd0d0moresB = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.001,0.001);
575 namedistr="hcosthetapointmoresB_";
577 TH1F *hcosthetapointmoresB = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
579 // costhetapoint vs d0 or d0d0
580 namedistr="hcosthpointd0B_";
582 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);
584 namedistr="hcosthpointd0d0B_";
586 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);
591 fDistr->Add(hd0moresB);
592 fDistr->Add(hd0d0moresB);
593 fDistr->Add(hcosthetapointmoresB);
596 fDistr->Add(hcosthpointd0B);
599 fDistr->Add(hcosthpointd0d0B);
606 //for Like sign analysis
609 namedistr="hpospair";
610 TH1F* hpospair=new TH1F(namedistr.Data(),"Number of positive pairs",fCuts->GetNPtBins(),-0.5,fCuts->GetNPtBins()-0.5);
611 namedistr="hnegpair";
612 TH1F* hnegpair=new TH1F(namedistr.Data(),"Number of negative pairs",fCuts->GetNPtBins(),-0.5,fCuts->GetNPtBins()-0.5);
613 fOutputMass->Add(hpospair);
614 fOutputMass->Add(hnegpair);
617 const char* nameoutput=GetOutputSlot(3)->GetContainer()->GetName();
619 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", 17,-0.5,16.5);
621 fNentries->GetXaxis()->SetBinLabel(1,"nEventsAnal");
622 fNentries->GetXaxis()->SetBinLabel(2,"nCandSel(Cuts)");
623 if(fReadMC) fNentries->GetXaxis()->SetBinLabel(3,"nD0Selected");
624 else fNentries->GetXaxis()->SetBinLabel(3,"Dstar<-D0");
625 fNentries->GetXaxis()->SetBinLabel(4,"nEventsGoodVtxS");
626 fNentries->GetXaxis()->SetBinLabel(5,"ptbin = -1");
627 fNentries->GetXaxis()->SetBinLabel(6,"no daughter");
628 if(fSys==0) fNentries->GetXaxis()->SetBinLabel(7,"nCandSel(Tr)");
630 fNentries->GetXaxis()->SetBinLabel(8,"PID=0");
631 fNentries->GetXaxis()->SetBinLabel(9,"PID=1");
632 fNentries->GetXaxis()->SetBinLabel(10,"PID=2");
633 fNentries->GetXaxis()->SetBinLabel(11,"PID=3");
635 if(fReadMC && fSys==0){
636 fNentries->GetXaxis()->SetBinLabel(12,"K");
637 fNentries->GetXaxis()->SetBinLabel(13,"Lambda");
639 fNentries->GetXaxis()->SetBinLabel(14,"Pile-up Rej");
640 fNentries->GetXaxis()->SetBinLabel(15,"N. of 0SMH");
641 if(fSys==1) fNentries->GetXaxis()->SetBinLabel(16,"Nev in centr");
642 if(fIsRejectSDDClusters) fNentries->GetXaxis()->SetBinLabel(17,"SDD-Cls Rej");
643 fNentries->GetXaxis()->SetNdivisions(1,kFALSE);
645 fCounter = new AliNormalizationCounter(Form("%s",GetOutputSlot(5)->GetContainer()->GetName()));
648 PostData(1,fOutputMass);
649 if(fFillVarHists) PostData(2,fDistr);
650 PostData(3,fNentries);
651 PostData(5,fCounter);
655 //________________________________________________________________________
656 void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
658 // Execute analysis for current event:
659 // heavy flavor candidates association to MC truth
660 //cout<<"I'm in UserExec"<<endl;
664 // printf(" |M-MD0| [GeV] < %f\n",fD0toKpiCuts[0]);
665 // printf(" dca [cm] < %f\n",fD0toKpiCuts[1]);
666 // printf(" cosThetaStar < %f\n",fD0toKpiCuts[2]);
667 // printf(" pTK [GeV/c] > %f\n",fD0toKpiCuts[3]);
668 // printf(" pTpi [GeV/c] > %f\n",fD0toKpiCuts[4]);
669 // printf(" |d0K| [cm] < %f\n",fD0toKpiCuts[5]);
670 // printf(" |d0pi| [cm] < %f\n",fD0toKpiCuts[6]);
671 // printf(" d0d0 [cm^2] < %f\n",fD0toKpiCuts[7]);
672 // printf(" cosThetaPoint > %f\n",fD0toKpiCuts[8]);
675 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
678 if(fArray==0){ //D0 candidates
679 // load D0->Kpi candidates
680 //cout<<"D0 candidates"<<endl;
682 } else { //LikeSign candidates
683 // load like sign candidates
684 //cout<<"LS candidates"<<endl;
685 bname="LikeSign2Prong";
688 TClonesArray *inputArray=0;
690 if(!aod && AODEvent() && IsStandardAOD()) {
691 // In case there is an AOD handler writing a standard AOD, use the AOD
692 // event in memory rather than the input (ESD) event.
693 aod = dynamic_cast<AliAODEvent*> (AODEvent());
694 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
695 // have to taken from the AOD event hold by the AliAODExtension
696 AliAODHandler* aodHandler = (AliAODHandler*)
697 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
699 if(aodHandler->GetExtensions()) {
700 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
701 AliAODEvent* aodFromExt = ext->GetAOD();
702 inputArray=(TClonesArray*)aodFromExt->GetList()->FindObject(bname.Data());
705 inputArray=(TClonesArray*)aod->GetList()->FindObject(bname.Data());
709 if(!inputArray || !aod) {
710 printf("AliAnalysisTaskSED0Mass::UserExec: input branch not found!\n");
714 // fix for temporary bug in ESDfilter
715 // the AODs with null vertex pointer didn't pass the PhysSel
716 if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001) return;
719 TClonesArray *mcArray = 0;
720 AliAODMCHeader *mcHeader = 0;
724 mcArray = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
726 printf("AliAnalysisTaskSED0Mass::UserExec: MC particles branch not found!\n");
731 mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
733 printf("AliAnalysisTaskSED0Mass::UserExec: MC header branch not found!\n");
738 //printf("VERTEX Z %f %f\n",vtx1->GetZ(),mcHeader->GetVtxZ());
740 //histogram filled with 1 for every AOD
742 fCounter->StoreEvent(aod,fReadMC);
744 // trigger class for PbPb C0SMH-B-NOPF-ALLNOTRD, C0SMH-B-NOPF-ALL
745 TString trigclass=aod->GetFiredTriggerClasses();
746 if(trigclass.Contains("C0SMH-B-NOPF-ALLNOTRD") || trigclass.Contains("C0SMH-B-NOPF-ALL")) fNentries->Fill(14);
748 if(!fCuts->IsEventSelected(aod)) {
749 if(fCuts->GetWhyRejection()==1) // rejected for pileup
751 if(fSys==1 && (fCuts->GetWhyRejection()==2 || fCuts->GetWhyRejection()==3)) fNentries->Fill(15);
755 // Check the Nb of SDD clusters
756 if (fIsRejectSDDClusters) {
757 Bool_t skipEvent = kFALSE;
759 if (aod) ntracks = aod->GetNTracks();
760 for(Int_t itrack=0; itrack<ntracks; itrack++) { // loop on tacks
762 AliAODTrack * track = aod->GetTrack(itrack);
763 if(TESTBIT(track->GetITSClusterMap(),2) || TESTBIT(track->GetITSClusterMap(),3) ){
769 if (skipEvent) return;
772 // AOD primary vertex
773 AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
775 Bool_t isGoodVtx=kFALSE;
778 TString primTitle = vtx1->GetTitle();
779 if(primTitle.Contains("VertexerTracks") && vtx1->GetNContributors()>0) {
784 // loop over candidates
785 Int_t nInD0toKpi = inputArray->GetEntriesFast();
786 if(fDebug>2) printf("Number of D0->Kpi: %d\n",nInD0toKpi);
788 // FILE *f=fopen("4display.txt","a");
789 // fprintf(f,"Number of D0->Kpi: %d\n",nInD0toKpi);
790 Int_t nSelectedloose=0,nSelectedtight=0;
791 for (Int_t iD0toKpi = 0; iD0toKpi < nInD0toKpi; iD0toKpi++) {
792 AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)inputArray->UncheckedAt(iD0toKpi);
794 if(d->GetSelectionMap()) if(!d->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts)){
796 continue; //skip the D0 from Dstar
799 // Bool_t unsetvtx=kFALSE;
800 // if(!d->GetOwnPrimaryVtx()) {
801 // d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
806 if ( fCuts->IsInFiducialAcceptance(d->Pt(),d->Y(421)) ) {
810 if(fCuts->IsSelected(d,AliRDHFCuts::kTracks,aod))fNentries->Fill(6);
812 Int_t ptbin=fCuts->PtBin(d->Pt());
813 if(ptbin==-1) {fNentries->Fill(4); continue;} //out of bounds
814 fIsSelectedCandidate=fCuts->IsSelected(d,AliRDHFCuts::kCandidate,aod); //selected
816 //if(!fCutOnDistr || (fCutOnDistr && fIsSelectedCandidate)) {
817 fDaughterTracks.AddAt((AliAODTrack*)d->GetDaughter(0),0);
818 fDaughterTracks.AddAt((AliAODTrack*)d->GetDaughter(1),1);
820 if(!fDaughterTracks.UncheckedAt(0) || !fDaughterTracks.UncheckedAt(1)) {
821 AliDebug(1,"at least one daughter not found!");
823 fDaughterTracks.Clear();
827 FillVarHists(aod,d,mcArray,fCuts,fDistr);
830 FillMassHists(d,mcArray,fCuts,fOutputMass);
833 fDaughterTracks.Clear();
834 //if(unsetvtx) d->UnsetOwnPrimaryVtx();
836 fCounter->StoreCandidates(aod,nSelectedloose,kTRUE);
837 fCounter->StoreCandidates(aod,nSelectedtight,kFALSE);
839 PostData(1,fOutputMass);
840 if(fFillVarHists) PostData(2,fDistr);
841 PostData(3,fNentries);
842 PostData(5,fCounter);
846 //____________________________________________________________________________
847 void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC, AliRDHFCutsD0toKpi *cuts, TList *listout){
849 // function used in UserExec to fill variable histograms:
853 Int_t pdgDgD0toKpi[2]={321,211};
855 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)
856 //Double_t pt = d->Pt(); //mother pt
857 Int_t isSelectedPID=3;
858 if(!fReadMC || (fReadMC && fUsePid4Distr)) isSelectedPID=cuts->IsSelectedPID(part); //0 rejected,1 D0,2 Dobar, 3 both
859 if (isSelectedPID==0)fNentries->Fill(7);
860 if (isSelectedPID==1)fNentries->Fill(8);
861 if (isSelectedPID==2)fNentries->Fill(9);
862 if (isSelectedPID==3)fNentries->Fill(10);
863 //fNentries->Fill(8+isSelectedPID);
865 if(fCutOnDistr && !fIsSelectedCandidate) return;
866 //printf("\nif no cuts or cuts passed\n");
872 Double_t mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
875 Double_t minvD0 = part->InvMassD0();
878 Double_t minvD0bar = part->InvMassD0bar();
879 //cout<<"inside mass cut"<<endl;
881 Double_t invmasscut=0.03;
883 TString fillthispi="",fillthisK="",fillthis="";
885 Int_t ptbin=cuts->PtBin(part->Pt());
887 Double_t dz1[2],dz2[2],covar1[3],covar2[3];//,d0xd0proper,errd0xd0proper;
888 dz1[0]=-99; dz2[0]=-99;
890 Double_t decl[2]={-99,-99};
891 Bool_t recalcvtx=kFALSE;
895 if(fCuts->GetIsPrimaryWithoutDaughters()){
898 AliAODVertex *vtxProp=0x0;
899 vtxProp=GetPrimaryVtxSkipped(aod);
901 part->SetOwnPrimaryVtx(vtxProp);
902 //Bool_t unsetvtx=kTRUE;
903 //Calculate d0 for daughter tracks with Vtx Skipped
904 AliESDtrack *esdtrack1=new AliESDtrack((AliVTrack*)fDaughterTracks.UncheckedAt(0));
905 AliESDtrack *esdtrack2=new AliESDtrack((AliVTrack*)fDaughterTracks.UncheckedAt(1));
906 esdtrack1->PropagateToDCA(vtxProp,aod->GetMagneticField(),1.,dz1,covar1);
907 esdtrack2->PropagateToDCA(vtxProp,aod->GetMagneticField(),1.,dz2,covar2);
908 delete vtxProp; vtxProp=NULL;
916 decl[0]=part->DecayLength2();
917 decl[1]=part->NormalizedDecayLength2();
918 part->UnsetOwnPrimaryVtx();
922 Double_t cosThetaStarD0 = 99;
923 Double_t cosThetaStarD0bar = 99;
924 Double_t cosPointingAngle = 99;
925 Double_t normalizedDecayLength2 = -1, normalizedDecayLengthxy=-1;
926 Double_t decayLength2 = -1, decayLengthxy=-1;
927 Double_t ptProng[2]={-99,-99};
928 Double_t d0Prong[2]={-99,-99};
932 if(!fUsePid4Distr) isSelectedPID=0;
933 if((lab>=0 && fReadMC) || (!fReadMC && isSelectedPID)){ //signal (from MC or PID)
935 //check pdg of the prongs
936 AliAODTrack *prong0=(AliAODTrack*)fDaughterTracks.UncheckedAt(0);
937 AliAODTrack *prong1=(AliAODTrack*)fDaughterTracks.UncheckedAt(1);
939 if(!prong0 || !prong1) {
944 labprong[0]=prong0->GetLabel();
945 labprong[1]=prong1->GetLabel();
947 AliAODMCParticle *mcprong=0;
948 Int_t pdgProng[2]={0,0};
950 for (Int_t iprong=0;iprong<2;iprong++){
951 if(fReadMC && labprong[iprong]>=0) {
952 mcprong= (AliAODMCParticle*)arrMC->At(labprong[iprong]);
953 pdgProng[iprong]=mcprong->GetPdgCode();
958 //no mass cut ditributions: ptbis
960 fillthispi="hptpiSnoMcut_";
963 fillthisK="hptKSnoMcut_";
966 if ((TMath::Abs(pdgProng[0]) == 211 && TMath::Abs(pdgProng[1]) == 321)
967 || (isSelectedPID==1 || isSelectedPID==3)){
968 ((TH1F*)listout->FindObject(fillthispi))->Fill(prong0->Pt());
969 ((TH1F*)listout->FindObject(fillthisK))->Fill(prong1->Pt());
972 if ((TMath::Abs(pdgProng[0]) == 321 && TMath::Abs(pdgProng[1]) == 211)
973 || (isSelectedPID==2 || isSelectedPID==3)){
974 ((TH1F*)listout->FindObject(fillthisK))->Fill(prong0->Pt());
975 ((TH1F*)listout->FindObject(fillthispi))->Fill(prong1->Pt());
979 //no mass cut ditributions: mass
983 if ((fReadMC && ((AliAODMCParticle*)arrMC->At(lab))->GetPdgCode() == 421)
984 || (!fReadMC && (isSelectedPID==1 || isSelectedPID==3))){//D0
985 ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0);
988 if(fReadMC || (!fReadMC && isSelectedPID > 1))
989 ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0bar);
992 //apply cut on invariant mass on the pair
993 if(TMath::Abs(minvD0-mPDG)<invmasscut || TMath::Abs(minvD0bar-mPDG)<invmasscut){
995 cosThetaStarD0 = part->CosThetaStarD0();
996 cosThetaStarD0bar = part->CosThetaStarD0bar();
997 cosPointingAngle = part->CosPointingAngle();
998 normalizedDecayLength2 = part->NormalizedDecayLength2();
999 decayLength2 = part->DecayLength2();
1000 decayLengthxy = part->DecayLengthXY();
1001 normalizedDecayLengthxy=decayLengthxy/part->DecayLengthXYError();
1003 ptProng[0]=prong0->Pt(); ptProng[1]=prong1->Pt();
1004 d0Prong[0]=part->Getd0Prong(0); d0Prong[1]=part->Getd0Prong(1);
1006 if(fArray==1) cout<<"LS signal: ERROR"<<endl;
1007 for (Int_t iprong=0; iprong<2; iprong++){
1008 AliAODTrack *prong=(AliAODTrack*)fDaughterTracks.UncheckedAt(iprong);
1009 if (fReadMC) labprong[iprong]=prong->GetLabel();
1011 //cout<<"prong name = "<<prong->GetName()<<" label = "<<prong->GetLabel()<<endl;
1013 if(fReadMC && labprong[iprong]>=0) {
1014 mcprong= (AliAODMCParticle*)arrMC->At(labprong[iprong]);
1015 pdgprong=mcprong->GetPdgCode();
1018 Bool_t isPionHere[2]={(isSelectedPID==1 || isSelectedPID==3) ? kTRUE : kFALSE,(isSelectedPID==2 || isSelectedPID==3) ? kTRUE : kFALSE};
1020 if(TMath::Abs(pdgprong)==211 || isPionHere[iprong]) {
1024 fillthispi="hptpiS_";
1026 ((TH1F*)listout->FindObject(fillthispi))->Fill(ptProng[iprong]);
1028 fillthispi="hd0piS_";
1030 ((TH1F*)listout->FindObject(fillthispi))->Fill(d0Prong[iprong]);
1033 fillthispi="hd0vpiS_";
1035 ((TH1F*)listout->FindObject(fillthispi))->Fill(d0[iprong]);
1040 if(TMath::Abs(pdgprong)==321 || !isPionHere[iprong]) {
1041 //cout<<"kappa"<<endl;
1045 ((TH1F*)listout->FindObject(fillthisK))->Fill(ptProng[iprong]);
1049 ((TH1F*)listout->FindObject(fillthisK))->Fill(d0Prong[iprong]);
1051 fillthisK="hd0vKS_";
1053 ((TH1F*)listout->FindObject(fillthisK))->Fill(d0[iprong]);
1058 fillthis="hcosthpointd0S_";
1060 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,d0Prong[iprong]);
1062 } //end loop on prongs
1066 ((TH1F*)listout->FindObject(fillthis))->Fill(part->GetDCA());
1068 fillthis="hcosthetapointS_";
1070 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle);
1072 fillthis="hcosthetapointxyS_";
1074 ((TH1F*)listout->FindObject(fillthis))->Fill(part->CosPointingAngleXY());
1079 ((TH1F*)listout->FindObject(fillthis))->Fill(part->Prodd0d0());
1083 ((TH1F*)listout->FindObject(fillthis))->Fill(decayLength2);
1085 fillthis="hnormdeclS_";
1087 ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLength2);
1089 fillthis="hdeclxyS_";
1091 ((TH1F*)listout->FindObject(fillthis))->Fill(decayLengthxy);
1093 fillthis="hnormdeclxyS_";
1095 ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLengthxy);
1097 fillthis="hdeclxyd0d0S_";
1099 ((TH2F*)listout->FindObject(fillthis))->Fill(decayLengthxy,d0Prong[0]*d0Prong[1]);
1101 fillthis="hnormdeclxyd0d0S_";
1103 ((TH2F*)listout->FindObject(fillthis))->Fill(normalizedDecayLengthxy,d0Prong[0]*d0Prong[1]);
1106 fillthis="hdeclvS_";
1108 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[0]);
1110 fillthis="hnormdeclvS_";
1112 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[1]);
1114 fillthis="hd0d0vS_";
1116 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]*d0[1]);
1120 fillthis="hcosthetastarS_";
1122 if ((fReadMC && ((AliAODMCParticle*)arrMC->At(lab))->GetPdgCode() == 421)) ((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0);
1124 if (fReadMC || isSelectedPID>1)((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0bar);
1125 if(isSelectedPID==1 || isSelectedPID==3)((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0);
1128 fillthis="hcosthpointd0d0S_";
1130 ((TH2F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,part->Prodd0d0());
1135 } else{ //Background or LS
1137 //cout<<"is background"<<endl;
1139 //no mass cut distributions: mass, ptbis
1143 if (!fCutOnDistr || (fCutOnDistr && (fIsSelectedCandidate==1 || fIsSelectedCandidate==3))) ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0);
1144 if (!fCutOnDistr || (fCutOnDistr && fIsSelectedCandidate>1)) ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0bar);
1146 fillthis="hptB1prongnoMcut_";
1149 ((TH1F*)listout->FindObject(fillthis))->Fill(((AliAODTrack*)fDaughterTracks.UncheckedAt(0))->Pt());
1151 fillthis="hptB2prongsnoMcut_";
1153 ((TH1F*)listout->FindObject(fillthis))->Fill(((AliAODTrack*)fDaughterTracks.UncheckedAt(0))->Pt());
1154 ((TH1F*)listout->FindObject(fillthis))->Fill(((AliAODTrack*)fDaughterTracks.UncheckedAt(0))->Pt());
1156 //apply cut on invariant mass on the pair
1157 if(TMath::Abs(minvD0-mPDG)<invmasscut || TMath::Abs(minvD0bar-mPDG)<invmasscut){
1159 ptProng[0]=((AliAODTrack*)fDaughterTracks.UncheckedAt(0))->Pt(); ptProng[1]=((AliAODTrack*)fDaughterTracks.UncheckedAt(0))->Pt();
1160 cosThetaStarD0 = part->CosThetaStarD0();
1161 cosThetaStarD0bar = part->CosThetaStarD0bar();
1164 cosPointingAngle = part->CosPointingAngle();
1165 normalizedDecayLength2 = part->NormalizedDecayLength2();
1166 decayLength2 = part->DecayLength2();
1167 decayLengthxy = part->DecayLengthXY();
1168 normalizedDecayLengthxy=decayLengthxy/part->DecayLengthXYError();
1169 d0Prong[0]=part->Getd0Prong(0); d0Prong[1]=part->Getd0Prong(1);
1172 AliAODTrack *prongg=(AliAODTrack*)fDaughterTracks.UncheckedAt(0);
1174 if(fDebug>2) cout<<"No daughter found";
1179 if(prongg->Charge()==1) {
1180 //fTotPosPairs[ptbin]++;
1181 ((TH1F*)fOutputMass->FindObject("hpospair"))->Fill(ptbin);
1183 //fTotNegPairs[ptbin]++;
1184 ((TH1F*)fOutputMass->FindObject("hnegpair"))->Fill(ptbin);
1191 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[0]);
1192 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[1]);
1195 Int_t pdgMother[2]={0,0};
1196 Double_t factor[2]={1,1};
1198 for(Int_t iprong=0;iprong<2;iprong++){
1199 AliAODTrack *prong=(AliAODTrack*)fDaughterTracks.UncheckedAt(iprong);
1200 lab=prong->GetLabel();
1202 AliAODMCParticle* mcprong=(AliAODMCParticle*)arrMC->At(lab);
1204 Int_t labmom=mcprong->GetMother();
1206 AliAODMCParticle* mcmother=(AliAODMCParticle*)arrMC->At(labmom);
1207 if(mcmother) pdgMother[iprong]=mcmother->GetPdgCode();
1214 fillthis="hd0moresB_";
1217 if(TMath::Abs(pdgMother[iprong])==310 || TMath::Abs(pdgMother[iprong])==130 || TMath::Abs(pdgMother[iprong])==321){ //K^0_S, K^0_L, K^+-
1218 if(ptProng[iprong]<=1)factor[iprong]=1./.7;
1219 else factor[iprong]=1./.6;
1220 fNentries->Fill(11);
1223 if(TMath::Abs(pdgMother[iprong])==3122) { //Lambda
1224 factor[iprong]=1./0.25;
1225 fNentries->Fill(12);
1227 fillthis="hd0moresB_";
1230 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[iprong],factor[iprong]);
1233 fillthis="hd0vmoresB_";
1235 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[iprong],factor[iprong]);
1241 fillthis="hd0d0moresB_";
1243 ((TH1F*)listout->FindObject(fillthis))->Fill(part->Prodd0d0(),factor[0]*factor[1]);
1245 fillthis="hcosthetapointmoresB_";
1247 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,factor[0]*factor[1]);
1250 fillthis="hd0d0vmoresB_";
1252 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]*d0[1],factor[0]*factor[1]);
1258 //normalise pt distr to half afterwards
1261 ((TH1F*)listout->FindObject(fillthis))->Fill(ptProng[0]);
1262 ((TH1F*)listout->FindObject(fillthis))->Fill(ptProng[1]);
1264 fillthis="hcosthetastarB_";
1266 if (!fCutOnDistr || (fCutOnDistr && (fIsSelectedCandidate==1 || fIsSelectedCandidate==3)))((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0);
1267 if (!fCutOnDistr || (fCutOnDistr && fIsSelectedCandidate>1))((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0bar);
1272 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[0]);
1275 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[1]);
1277 fillthis="hcosthpointd0d0B_";
1279 ((TH2F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,part->Prodd0d0());
1281 fillthis="hcosthpointd0B_";
1283 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,d0Prong[0]);
1284 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,d0Prong[1]);
1289 fillthis="hd0vp0B_";
1291 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]);
1292 fillthis="hd0vp1B_";
1294 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[1]);
1298 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]);
1299 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[1]);
1307 ((TH1F*)listout->FindObject(fillthis))->Fill(part->GetDCA());
1311 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[0]*d0Prong[1]);
1314 fillthis="hd0d0vB_";
1316 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]*d0[1]);
1319 fillthis="hcosthetapointB_";
1321 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle);
1323 fillthis="hcosthetapointxyB_";
1325 ((TH1F*)listout->FindObject(fillthis))->Fill(part->CosPointingAngleXY());
1329 ((TH1F*)listout->FindObject(fillthis))->Fill(decayLength2);
1331 fillthis="hnormdeclB_";
1333 ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLength2);
1335 fillthis="hdeclxyB_";
1337 ((TH1F*)listout->FindObject(fillthis))->Fill(decayLengthxy);
1339 fillthis="hnormdeclxyB_";
1341 ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLengthxy);
1343 fillthis="hdeclxyd0d0B_";
1345 ((TH2F*)listout->FindObject(fillthis))->Fill(decayLengthxy,d0Prong[0]*d0Prong[1]);
1347 fillthis="hnormdeclxyd0d0B_";
1349 ((TH2F*)listout->FindObject(fillthis))->Fill(normalizedDecayLengthxy,d0Prong[0]*d0Prong[1]);
1353 fillthis="hdeclvB_";
1355 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[0]);
1357 fillthis="hnormdeclvB_";
1359 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[1]);
1364 }//else (background)
1368 //____________________________________________________________________________
1370 void AliAnalysisTaskSED0Mass::FillMassHists(AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC, AliRDHFCutsD0toKpi* cuts, TList *listout){
1372 // function used in UserExec to fill mass histograms:
1376 Double_t mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
1378 //cout<<"is selected = "<<fIsSelectedCandidate<<endl;
1380 //cout<<"check cuts = "<<endl;
1382 if (!fIsSelectedCandidate){
1383 //cout<<"Not Selected"<<endl;
1384 //cout<<"Rejected because "<<cuts->GetWhy()<<endl;
1389 if(fDebug>2) cout<<"Candidate selected"<<endl;
1391 Double_t invmassD0 = part->InvMassD0(), invmassD0bar = part->InvMassD0bar();
1392 //printf("SELECTED\n");
1393 Int_t ptbin=cuts->PtBin(part->Pt());
1395 // AliAODTrack *prong=(AliAODTrack*)fDaughterTracks.UncheckedAt(0);
1397 // AliDebug(2,"No daughter found");
1401 // if(prong->Charge()==1) {
1402 // ((TH1F*)fDistr->FindObject("hpospair"))->Fill(fCuts->GetNPtBins()+ptbin);
1403 // //fTotPosPairs[ptbin]++;
1405 // ((TH1F*)fDistr->FindObject("hnegpair"))->Fill(fCuts->GetNPtBins()+ptbin);
1406 // //fTotNegPairs[ptbin]++;
1410 // for(Int_t it=0;it<2;it++){
1412 // //request on spd points to be addes
1413 // if(/*nSPD==2 && */part->Pt() > 5. && (TMath::Abs(invmassD0-mPDG)<0.01 || TMath::Abs(invmassD0bar-mPDG)<0.01)){
1414 // FILE *f=fopen("4display.txt","a");
1415 // 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());
1417 // //printf("PrimVtx NContributors: %d \n Prongs Rel Angle: %f \n \n",ncont,relangle);
1421 TString fillthis="";
1422 Int_t pdgDgD0toKpi[2]={321,211};
1424 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)
1426 //count candidates selected by cuts
1428 //count true D0 selected by cuts
1429 if (fReadMC && labD0>=0) fNentries->Fill(2);
1431 if ((fIsSelectedCandidate==1 || fIsSelectedCandidate==3) && fFillOnlyD0D0bar<2) { //D0
1434 if(fArray==1) cout<<"LS signal ERROR"<<endl;
1436 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
1437 Int_t pdgD0 = partD0->GetPdgCode();
1438 // cout<<"pdg = "<<pdgD0<<endl;
1439 if (pdgD0==421){ //D0
1440 // cout<<"Fill S with D0"<<endl;
1441 fillthis="histSgn_";
1443 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1445 if(TMath::Abs(invmassD0 - mPDG) < 0.027 && fFillVarHists){
1446 fillthis="histSgn27_";
1448 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1451 } else{ //it was a D0bar
1452 fillthis="histRfl_";
1454 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1456 } else {//background
1457 fillthis="histBkg_";
1459 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1463 fillthis="histMass_";
1465 // cout<<"Filling "<<fillthis<<endl;
1467 // printf("Fill mass with D0");
1468 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1472 if (fIsSelectedCandidate>1 && (fFillOnlyD0D0bar==0 || fFillOnlyD0D0bar==2)) { //D0bar
1475 if(fArray==1) cout<<"LS signal ERROR"<<endl;
1476 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
1477 Int_t pdgD0 = partD0->GetPdgCode();
1478 // cout<<" pdg = "<<pdgD0<<endl;
1479 if (pdgD0==-421){ //D0bar
1480 fillthis="histSgn_";
1482 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
1483 // if (TMath::Abs(invmassD0bar - mPDG) < 0.027){
1484 // fillthis="histSgn27_";
1486 // ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
1491 fillthis="histRfl_";
1493 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
1495 } else {//background or LS
1496 fillthis="histBkg_";
1498 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
1501 fillthis="histMass_";
1503 // printf("Fill mass with D0bar");
1504 ((TH1F*)listout->FindObject(fillthis))->Fill(invmassD0bar);
1512 //__________________________________________________________________________
1513 AliAODVertex* AliAnalysisTaskSED0Mass::GetPrimaryVtxSkipped(AliAODEvent *aodev){
1514 //Calculate the primary vertex w/o the daughter tracks of the candidate
1517 Int_t nTrksToSkip=2;
1518 AliAODTrack *dgTrack = (AliAODTrack*)fDaughterTracks.UncheckedAt(0);
1520 AliDebug(2,"no daughter found!");
1523 skipped[0]=dgTrack->GetID();
1524 dgTrack = (AliAODTrack*)fDaughterTracks.UncheckedAt(1);
1526 AliDebug(2,"no daughter found!");
1529 skipped[1]=dgTrack->GetID();
1531 AliESDVertex *vertexESD=0x0;
1532 AliAODVertex *vertexAOD=0x0;
1533 AliVertexerTracks *vertexer = new AliVertexerTracks(aodev->GetMagneticField());
1536 vertexer->SetSkipTracks(nTrksToSkip,skipped);
1537 vertexer->SetMinClusters(4);
1538 vertexESD = (AliESDVertex*)vertexer->FindPrimaryVertex(aodev);
1539 if(!vertexESD) return vertexAOD;
1540 if(vertexESD->GetNContributors()<=0) {
1541 AliDebug(2,"vertexing failed");
1542 delete vertexESD; vertexESD=NULL;
1546 delete vertexer; vertexer=NULL;
1549 // convert to AliAODVertex
1550 Double_t pos[3],cov[6],chi2perNDF;
1551 vertexESD->GetXYZ(pos); // position
1552 vertexESD->GetCovMatrix(cov); //covariance matrix
1553 chi2perNDF = vertexESD->GetChi2toNDF();
1554 delete vertexESD; vertexESD=NULL;
1556 vertexAOD = new AliAODVertex(pos,cov,chi2perNDF);
1562 //________________________________________________________________________
1563 void AliAnalysisTaskSED0Mass::Terminate(Option_t */*option*/)
1565 // Terminate analysis
1567 if(fDebug > 1) printf("AnalysisTaskSED0Mass: Terminate() \n");
1570 fOutputMass = dynamic_cast<TList*> (GetOutputData(1));
1572 printf("ERROR: fOutputMass not available\n");
1576 fDistr = dynamic_cast<TList*> (GetOutputData(2));
1578 printf("ERROR: fDistr not available\n");
1583 fNentries = dynamic_cast<TH1F*>(GetOutputData(3));
1586 printf("ERROR: fNEntries not available\n");
1589 fCuts = dynamic_cast<AliRDHFCutsD0toKpi*>(GetOutputData(4));
1591 printf("ERROR: fCuts not available\n");
1594 fCounter = dynamic_cast<AliNormalizationCounter*>(GetOutputData(5));
1596 printf("ERROR: fCounter not available\n");
1599 Int_t nptbins=fCuts->GetNPtBins();
1600 for(Int_t ipt=0;ipt<nptbins;ipt++){
1602 if(fArray==1 && fFillVarHists){
1603 fLsNormalization = 2.*TMath::Sqrt(((TH1F*)fOutputMass->FindObject("hpospair"))->Integral(nptbins+ipt+1,nptbins+ipt+2)*((TH1F*)fOutputMass->FindObject("hnegpair"))->Integral(nptbins+ipt+1,nptbins+ipt+2)); //after cuts
1606 if(fLsNormalization>1e-6) {
1608 TString massName="histMass_";
1610 ((TH1F*)fOutputMass->FindObject(massName))->Scale((1/fLsNormalization)*((TH1F*)fOutputMass->FindObject(massName))->GetEntries());
1615 fLsNormalization = 2.*TMath::Sqrt(((TH1F*)fOutputMass->FindObject("hpospair"))->Integral(ipt+1,ipt+2)*((TH1F*)fOutputMass->FindObject("hnegpair"))->Integral(ipt+1,ipt+2));
1616 //fLsNormalization = 2.*TMath::Sqrt(fTotPosPairs[4]*fTotNegPairs[4]);
1618 if(fLsNormalization>1e-6) {
1620 TString nameDistr="hptB_";
1622 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1625 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1626 nameDistr="hcosthetastarB_";
1628 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1631 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1632 nameDistr="hd0d0B_";
1634 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1635 nameDistr="hcosthetapointB_";
1637 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1639 nameDistr="hcosthpointd0d0B_";
1641 ((TH2F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH2F*)fDistr->FindObject(nameDistr))->GetEntries());
1646 TString cvname,cstname;
1656 TCanvas *cMass=new TCanvas(cvname,cvname);
1658 ((TH1F*)fOutputMass->FindObject("histMass_3"))->Draw();
1660 TCanvas* cStat=new TCanvas(cstname,Form("Stat%s",fArray ? "LS" : "D0"));
1663 fNentries->Draw("htext0");
1665 // TCanvas *ccheck=new TCanvas(Form("cc%d",fArray),Form("cc%d",fArray));