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
204 TH1F *hptpiS = new TH1F(namedistr.Data(), "P_{T} distribution (pions);p_{T} [GeV/c]",200,0.,8.);
208 TH1F *hptKS = new TH1F(namedistr.Data(), "P_{T} distribution (kaons);p_{T} [GeV/c]",200,0.,8.);
212 TH1F *hptB = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
218 TH1F *hdcaS = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
221 TH1F *hdcaB = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
224 namedistr="hcosthetastarS_";
226 TH1F *hcosthetastarS = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
227 namedistr="hcosthetastarB_";
229 TH1F *hcosthetastarB = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
234 TH1F *hd0piS = new TH1F(namedistr.Data(), "Impact parameter distribution (pions);d0(#pi) [cm]",200,-0.1,0.1);
238 TH1F *hd0KS = new TH1F(namedistr.Data(), "Impact parameter distribution (kaons);d0(K) [cm]",200,-0.1,0.1);
242 TH1F *hd0B = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
246 TH1F *hd0d0S = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution;d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
249 TH1F *hd0d0B = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution;d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
254 TH1F *hdeclengthS = new TH1F(namedistr.Data(), "Decay Length^{2} distribution;Decay Length^{2} [cm]",200,0,0.025);
258 TH1F *hdeclengthB = new TH1F(namedistr.Data(), "Decay Length^{2} distribution;Decay Length^{2} [cm^{2}]",200,0,0.025);
260 namedistr="hnormdeclS_";
262 TH1F *hnormdeclengthS = new TH1F(namedistr.Data(), "Normalized Decay Length^{2} distribution;(Decay Length/Err)^{2} ",200,0,6.);
264 namedistr="hnormdeclB_";
266 TH1F *hnormdeclengthB = new TH1F(namedistr.Data(), "Normalized Decay Length distribution;(Decay Length/Err)^{2} ",200,0,6.);
269 namedistr="hcosthetapointS_";
271 TH1F *hcosthetapointS = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
272 namedistr="hcosthetapointB_";
274 TH1F *hcosthetapointB = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
276 namedistr="hdeclxyS_";
278 TH1F* hdeclxyS=new TH1F(namedistr.Data(),"Decay Length XY distribution;Decay Length XY [cm]",200,0,0.15);
279 namedistr="hnormdeclxyS_";
281 TH1F* hnormdeclxyS=new TH1F(namedistr.Data(),"Normalized decay Length XY distribution;Decay Length XY/Err",200,0,6); //check range 0.15
283 namedistr="hdeclxyB_";
285 TH1F* hdeclxyB=new TH1F(namedistr.Data(),"Decay Length XY distribution;Decay Length XY [cm]",200,0,0.15);//chech range 0.15
286 namedistr="hnormdeclxyB_";
288 TH1F* hnormdeclxyB=new TH1F(namedistr.Data(),"Normalized decay Length XY distribution;Decay Length XY/Err",200,0,6); //check range 0.15
304 fDistr->Add(hcosthetastarS);
305 fDistr->Add(hcosthetastarB);
307 fDistr->Add(hcosthetapointS);
308 fDistr->Add(hcosthetapointB);
311 fDistr->Add(hdeclengthS);
312 fDistr->Add(hdeclengthB);
314 fDistr->Add(hnormdeclengthS);
315 fDistr->Add(hnormdeclengthB);
317 fDistr->Add(hdeclxyS);
318 fDistr->Add(hdeclxyB);
320 fDistr->Add(hnormdeclxyS);
321 fDistr->Add(hnormdeclxyB);
323 //histograms filled only when the secondary vertex is recalculated w/o the daughter tracks (as requested in the cut object)
325 if(fCuts->GetIsPrimaryWithoutDaughters()){
326 namedistr="hd0vmoresB_";
328 TH1F *hd0vmoresB = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
330 namedistr="hd0d0vmoresB_";
332 TH1F *hd0d0vmoresB = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.001,0.001);
335 namedistr="hd0vpiS_";
337 TH1F *hd0vpiS = new TH1F(namedistr.Data(), "Impact parameter distribution (pions)(vtx w/o these tracks);d0(#pi) [cm]",200,-0.1,0.1);
341 TH1F *hd0vKS = new TH1F(namedistr.Data(), "Impact parameter distribution (kaons) (vtx w/o these tracks);d0(K) [cm]",200,-0.1,0.1);
344 TH1F *hd0vB = new TH1F(namedistr.Data(), "Impact parameter distribution (vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
346 namedistr="hd0vp0B_";
348 TH1F *hd0vp0B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong + ** vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
350 namedistr="hd0vp1B_";
352 TH1F *hd0vp1B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong - ** vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
355 namedistr="hd0d0vS_";
357 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);
358 namedistr="hd0d0vB_";
360 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);
363 namedistr="hdeclvS_";
365 TH1F *hdeclengthvS = new TH1F(namedistr.Data(), "Decay Length distribution (vtx w/o tracks);Decay Length [cm]",200,0,0.6);
367 namedistr="hdeclvB_";
369 TH1F *hdeclengthvB = new TH1F(namedistr.Data(), "Decay Length distribution (vtx w/o tracks);Decay Length [cm]",200,0,0.6);
371 namedistr="hnormdeclvS_";
373 TH1F *hnormdeclengthvS = new TH1F(namedistr.Data(), "Normalized Decay Length distribution (vtx w/o tracks);Decay Length/Err ",200,0,10.);
375 namedistr="hnormdeclvB_";
377 TH1F *hnormdeclengthvB = new TH1F(namedistr.Data(), "Normalized Decay Length distribution (vtx w/o tracks);Decay Length/Err ",200,0,10.);
381 fDistr->Add(hd0vpiS);
384 fDistr->Add(hd0vp0B);
385 fDistr->Add(hd0vp1B);
386 fDistr->Add(hd0vmoresB);
388 fDistr->Add(hd0d0vS);
389 fDistr->Add(hd0d0vB);
390 fDistr->Add(hd0d0vmoresB);
392 fDistr->Add(hdeclengthvS);
393 fDistr->Add(hdeclengthvB);
395 fDistr->Add(hnormdeclengthvS);
396 fDistr->Add(hnormdeclengthvB);
399 TH1F* tmpMS = new TH1F(nameMassNocutsS.Data(),"D^{0} invariant mass; M [GeV]; Entries",300,1.5648,2.1648); //range (MD0-300MeV, mD0 + 300MeV)
400 TH1F *tmpMB=(TH1F*)tmpMS->Clone();
401 tmpMB->SetName(nameMassNocutsB.Data());
409 //histograms of invariant mass distributions
412 //MC signal and background
413 TH1F* tmpSt = new TH1F(nameSgn.Data(), "D^{0} invariant mass - MC; M [GeV]; Entries",200,1.5648,2.1648);
414 TH1F *tmpSl=(TH1F*)tmpSt->Clone();
418 TH1F* tmpBt = new TH1F(nameBkg.Data(), "Background invariant mass - MC; M [GeV]; Entries",200,1.5648,2.1648);
419 TH1F *tmpBl=(TH1F*)tmpBt->Clone();
423 //Reflection: histo filled with D0Mass which pass the cut (also) as D0bar and with D0bar which pass (also) the cut as D0
424 TH1F* tmpRt = new TH1F(nameRfl.Data(), "Reflected signal invariant mass - MC; M [GeV]; Entries",200,1.5648,2.1648);
425 TH1F *tmpRl=(TH1F*)tmpRt->Clone();
428 // printf("Created histograms %s\t%s\t%s\t%s\n",tmpM->GetName(),tmpS->GetName(),tmpB->GetName(),tmpR->GetName());
430 fOutputMass->Add(tmpSt);
431 fOutputMass->Add(tmpBt);
432 fOutputMass->Add(tmpRt);
435 TH1F* tmpMt = new TH1F(nameMass.Data(),"D^{0} invariant mass; M [GeV]; Entries",200,1.5648,2.1648);
436 TH1F *tmpMl=(TH1F*)tmpMt->Clone();
439 //distribution w/o cuts large range
440 // TH1F* tmpMS = new TH1F(nameMassNocutsS.Data(),"D^{0} invariant mass; M [GeV]; Entries",300,0.7,3.);
442 fOutputMass->Add(tmpMt);
444 if(fSys==0){ //histograms filled only in pp to save time in PbPb
448 namedistr="hptpiSnoMcut_";
450 TH1F *hptpiSnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution (pions);p_{T} [GeV/c]",200,0.,8.);
452 namedistr="hptKSnoMcut_";
454 TH1F *hptKSnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution (kaons);p_{T} [GeV/c]",200,0.,8.);
456 namedistr="hptB1prongnoMcut_";
458 TH1F *hptB1pnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
460 namedistr="hptB2prongsnoMcut_";
462 TH1F *hptB2pnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
464 fDistr->Add(hptpiSnoMcut);
465 fDistr->Add(hptKSnoMcut);
466 fDistr->Add(hptB1pnoMcut);
467 fDistr->Add(hptB2pnoMcut);
469 //impact parameter of negative/positive track
472 TH1F *hd0p0B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.1,0.1);
476 TH1F *hd0p1B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong -);d0 [cm]",200,-0.1,0.1);
478 //impact parameter corrected for strangeness
479 namedistr="hd0moresB_";
481 TH1F *hd0moresB = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
483 namedistr="hd0d0moresB_";
485 TH1F *hd0d0moresB = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.001,0.001);
488 namedistr="hcosthetapointmoresB_";
490 TH1F *hcosthetapointmoresB = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
492 // costhetapoint vs d0 or d0d0
493 namedistr="hcosthpointd0S_";
495 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);
497 namedistr="hcosthpointd0B_";
499 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);
501 namedistr="hcosthpointd0d0S_";
503 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);
504 namedistr="hcosthpointd0d0B_";
506 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);
511 fDistr->Add(hd0moresB);
512 fDistr->Add(hd0d0moresB);
513 fDistr->Add(hcosthetapointmoresB);
515 fDistr->Add(hcosthpointd0S);
516 fDistr->Add(hcosthpointd0B);
518 fDistr->Add(hcosthpointd0d0S);
519 fDistr->Add(hcosthpointd0d0B);
522 //to compare with AliAnalysisTaskCharmFraction
523 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);
524 TH1F *tmpS27l=(TH1F*)tmpS27t->Clone();
528 fOutputMass->Add(tmpS27t);
529 fOutputMass->Add(tmpS27l);
534 //for Like sign analysis
537 namedistr="hpospair";
538 TH1F* hpospair=new TH1F(namedistr.Data(),"Number of positive pairs",fCuts->GetNPtBins(),-0.5,fCuts->GetNPtBins()-0.5);
539 namedistr="hnegpair";
540 TH1F* hnegpair=new TH1F(namedistr.Data(),"Number of negative pairs",fCuts->GetNPtBins(),-0.5,fCuts->GetNPtBins()-0.5);
541 fDistr->Add(hpospair);
542 fDistr->Add(hnegpair);
545 const char* nameoutput=GetOutputSlot(3)->GetContainer()->GetName();
547 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", 15,-0.5,14.5);
549 fNentries->GetXaxis()->SetBinLabel(1,"nEventsAnal");
550 fNentries->GetXaxis()->SetBinLabel(2,"nCandSel(Cuts)");
551 fNentries->GetXaxis()->SetBinLabel(3,"nD0Selected");
552 fNentries->GetXaxis()->SetBinLabel(4,"nEventsGoodVtxS");
553 fNentries->GetXaxis()->SetBinLabel(5,"ptbin = -1");
554 fNentries->GetXaxis()->SetBinLabel(6,"no daughter");
555 if(fSys==0) fNentries->GetXaxis()->SetBinLabel(7,"nCandSel(Tr)");
557 fNentries->GetXaxis()->SetBinLabel(8,"PID=0");
558 fNentries->GetXaxis()->SetBinLabel(9,"PID=1");
559 fNentries->GetXaxis()->SetBinLabel(10,"PID=2");
560 fNentries->GetXaxis()->SetBinLabel(11,"PID=3");
562 if(fReadMC && fSys==0){
563 fNentries->GetXaxis()->SetBinLabel(12,"K");
564 fNentries->GetXaxis()->SetBinLabel(13,"Lambda");
566 fNentries->GetXaxis()->SetBinLabel(14,"Pile-up Rej");
567 fNentries->GetXaxis()->SetBinLabel(15,"N. of 0SMH");
568 fNentries->GetXaxis()->SetNdivisions(1,kFALSE);
570 fCounter = new AliNormalizationCounter(Form("%s",GetOutputSlot(5)->GetContainer()->GetName()));
573 PostData(1,fOutputMass);
574 if(fFillVarHists) PostData(2,fDistr);
575 PostData(3,fNentries);
576 PostData(5,fCounter);
580 //________________________________________________________________________
581 void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
583 // Execute analysis for current event:
584 // heavy flavor candidates association to MC truth
585 //cout<<"I'm in UserExec"<<endl;
589 // printf(" |M-MD0| [GeV] < %f\n",fD0toKpiCuts[0]);
590 // printf(" dca [cm] < %f\n",fD0toKpiCuts[1]);
591 // printf(" cosThetaStar < %f\n",fD0toKpiCuts[2]);
592 // printf(" pTK [GeV/c] > %f\n",fD0toKpiCuts[3]);
593 // printf(" pTpi [GeV/c] > %f\n",fD0toKpiCuts[4]);
594 // printf(" |d0K| [cm] < %f\n",fD0toKpiCuts[5]);
595 // printf(" |d0pi| [cm] < %f\n",fD0toKpiCuts[6]);
596 // printf(" d0d0 [cm^2] < %f\n",fD0toKpiCuts[7]);
597 // printf(" cosThetaPoint > %f\n",fD0toKpiCuts[8]);
600 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
603 if(fArray==0){ //D0 candidates
604 // load D0->Kpi candidates
605 //cout<<"D0 candidates"<<endl;
607 } else { //LikeSign candidates
608 // load like sign candidates
609 //cout<<"LS candidates"<<endl;
610 bname="LikeSign2Prong";
613 TClonesArray *inputArray=0;
615 if(!aod && AODEvent() && IsStandardAOD()) {
616 // In case there is an AOD handler writing a standard AOD, use the AOD
617 // event in memory rather than the input (ESD) event.
618 aod = dynamic_cast<AliAODEvent*> (AODEvent());
619 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
620 // have to taken from the AOD event hold by the AliAODExtension
621 AliAODHandler* aodHandler = (AliAODHandler*)
622 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
624 if(aodHandler->GetExtensions()) {
625 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
626 AliAODEvent* aodFromExt = ext->GetAOD();
627 inputArray=(TClonesArray*)aodFromExt->GetList()->FindObject(bname.Data());
630 inputArray=(TClonesArray*)aod->GetList()->FindObject(bname.Data());
634 if(!inputArray || !aod) {
635 printf("AliAnalysisTaskSED0Mass::UserExec: input branch not found!\n");
639 // fix for temporary bug in ESDfilter
640 // the AODs with null vertex pointer didn't pass the PhysSel
641 if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001) return;
644 TClonesArray *mcArray = 0;
645 AliAODMCHeader *mcHeader = 0;
649 mcArray = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
651 printf("AliAnalysisTaskSED0Mass::UserExec: MC particles branch not found!\n");
656 mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
658 printf("AliAnalysisTaskSED0Mass::UserExec: MC header branch not found!\n");
663 //printf("VERTEX Z %f %f\n",vtx1->GetZ(),mcHeader->GetVtxZ());
665 //histogram filled with 1 for every AOD
667 fCounter->StoreEvent(aod,fReadMC);
669 // trigger class for PbPb C0SMH-B-NOPF-ALLNOTRD, C0SMH-B-NOPF-ALL
670 TString trigclass=aod->GetFiredTriggerClasses();
671 if(trigclass.Contains("C0SMH-B-NOPF-ALLNOTRD") || trigclass.Contains("C0SMH-B-NOPF-ALL")) fNentries->Fill(14);
673 if(!fCuts->IsEventSelected(aod)) {
674 if(fCuts->GetWhyRejection()==1) // rejected for pileup
679 // AOD primary vertex
680 AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
682 Bool_t isGoodVtx=kFALSE;
685 TString primTitle = vtx1->GetTitle();
686 if(primTitle.Contains("VertexerTracks") && vtx1->GetNContributors()>0) {
691 // loop over candidates
692 Int_t nInD0toKpi = inputArray->GetEntriesFast();
693 if(fDebug>2) printf("Number of D0->Kpi: %d\n",nInD0toKpi);
695 // FILE *f=fopen("4display.txt","a");
696 // fprintf(f,"Number of D0->Kpi: %d\n",nInD0toKpi);
697 Int_t nSelectedloose=0,nSelectedtight=0;
698 for (Int_t iD0toKpi = 0; iD0toKpi < nInD0toKpi; iD0toKpi++) {
699 AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)inputArray->UncheckedAt(iD0toKpi);
701 Bool_t unsetvtx=kFALSE;
702 if(!d->GetOwnPrimaryVtx()) {
703 d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
708 if ( fCuts->IsInFiducialAcceptance(d->Pt(),d->Y(421)) ) {
712 if(fCuts->IsSelected(d,AliRDHFCuts::kTracks,aod))fNentries->Fill(6);
714 Int_t ptbin=fCuts->PtBin(d->Pt());
715 if(ptbin==-1) {fNentries->Fill(4); continue;} //out of bounds
716 fIsSelectedCandidate=fCuts->IsSelected(d,AliRDHFCuts::kCandidate,aod); //selected
718 //if(!fCutOnDistr || (fCutOnDistr && fIsSelectedCandidate)) {
719 fDaughterTracks.AddAt((AliAODTrack*)d->GetDaughter(0),0);
720 fDaughterTracks.AddAt((AliAODTrack*)d->GetDaughter(1),1);
722 if(!fDaughterTracks.UncheckedAt(0) || !fDaughterTracks.UncheckedAt(1)) {
723 AliDebug(1,"at least one daughter not found!");
725 fDaughterTracks.Clear();
729 FillVarHists(aod,d,mcArray,fCuts,fDistr);
732 FillMassHists(d,mcArray,fCuts,fOutputMass);
735 fDaughterTracks.Clear();
736 if(unsetvtx) d->UnsetOwnPrimaryVtx();
738 fCounter->StoreCandidates(aod,nSelectedloose,kTRUE);
739 fCounter->StoreCandidates(aod,nSelectedtight,kFALSE);
741 PostData(1,fOutputMass);
742 if(fFillVarHists) PostData(2,fDistr);
743 PostData(3,fNentries);
744 PostData(5,fCounter);
748 //____________________________________________________________________________
749 void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC, AliRDHFCutsD0toKpi *cuts, TList *listout){
751 // function used in UserExec to fill variable histograms:
755 Int_t pdgDgD0toKpi[2]={321,211};
757 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)
758 //Double_t pt = d->Pt(); //mother pt
759 Int_t isSelectedPID=3;
760 if(!fReadMC || (fReadMC && fUsePid4Distr)) isSelectedPID=cuts->IsSelectedPID(part); //0 rejected,1 D0,2 Dobar, 3 both
761 if (isSelectedPID==0)fNentries->Fill(7);
762 if (isSelectedPID==1)fNentries->Fill(8);
763 if (isSelectedPID==2)fNentries->Fill(9);
764 if (isSelectedPID==3)fNentries->Fill(10);
765 //fNentries->Fill(8+isSelectedPID);
767 if(fCutOnDistr && !fIsSelectedCandidate) return;
768 //printf("\nif no cuts or cuts passed\n");
774 Double_t mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
777 Double_t minvD0 = part->InvMassD0();
780 Double_t minvD0bar = part->InvMassD0bar();
781 //cout<<"inside mass cut"<<endl;
783 Double_t invmasscut=0.03;
785 TString fillthispi="",fillthisK="",fillthis="";
787 Int_t ptbin=cuts->PtBin(part->Pt());
789 Double_t dz1[2],dz2[2],covar1[3],covar2[3];//,d0xd0proper,errd0xd0proper;
790 dz1[0]=-99; dz2[0]=-99;
792 Double_t decl[2]={-99,-99};
793 Bool_t recalcvtx=kFALSE;
797 if(fCuts->GetIsPrimaryWithoutDaughters()){
800 AliAODVertex *vtxProp=0x0;
801 vtxProp=GetPrimaryVtxSkipped(aod);
803 part->SetOwnPrimaryVtx(vtxProp);
804 //Bool_t unsetvtx=kTRUE;
805 //Calculate d0 for daughter tracks with Vtx Skipped
806 AliESDtrack *esdtrack1=new AliESDtrack((AliVTrack*)fDaughterTracks.UncheckedAt(0));
807 AliESDtrack *esdtrack2=new AliESDtrack((AliVTrack*)fDaughterTracks.UncheckedAt(1));
808 esdtrack1->PropagateToDCA(vtxProp,aod->GetMagneticField(),1.,dz1,covar1);
809 esdtrack2->PropagateToDCA(vtxProp,aod->GetMagneticField(),1.,dz2,covar2);
810 delete vtxProp; vtxProp=NULL;
818 decl[0]=part->DecayLength2();
819 decl[1]=part->NormalizedDecayLength2();
820 part->UnsetOwnPrimaryVtx();
824 Double_t cosThetaStarD0 = 99;
825 Double_t cosThetaStarD0bar = 99;
826 Double_t cosPointingAngle = 99;
827 Double_t normalizedDecayLength2 = -1, normalizedDecayLengthxy=-1;
828 Double_t decayLength2 = -1, decayLengthxy=-1;
829 Double_t ptProng[2]={-99,-99};
830 Double_t d0Prong[2]={-99,-99};
834 if(!fUsePid4Distr) isSelectedPID=0;
835 if((lab>=0 && fReadMC) || (!fReadMC && isSelectedPID)){ //signal (from MC or PID)
837 //check pdg of the prongs
838 AliAODTrack *prong0=(AliAODTrack*)fDaughterTracks.UncheckedAt(0);
839 AliAODTrack *prong1=(AliAODTrack*)fDaughterTracks.UncheckedAt(1);
840 if(!prong0 || !prong1) {
845 labprong[0]=prong0->GetLabel();
846 labprong[1]=prong1->GetLabel();
848 AliAODMCParticle *mcprong=0;
849 Int_t pdgProng[2]={0,0};
851 for (Int_t iprong=0;iprong<2;iprong++){
852 if(fReadMC && labprong[iprong]>=0) {
853 mcprong= (AliAODMCParticle*)arrMC->At(labprong[iprong]);
854 pdgProng[iprong]=mcprong->GetPdgCode();
859 //no mass cut ditributions: ptbis
861 fillthispi="hptpiSnoMcut_";
864 fillthisK="hptKSnoMcut_";
867 if ((TMath::Abs(pdgProng[0]) == 211 && TMath::Abs(pdgProng[1]) == 321)
868 || (isSelectedPID==1 || isSelectedPID==3)){
869 ((TH1F*)listout->FindObject(fillthispi))->Fill(part->PtProng(0));
870 ((TH1F*)listout->FindObject(fillthisK))->Fill(part->PtProng(1));
873 if ((TMath::Abs(pdgProng[0]) == 321 && TMath::Abs(pdgProng[1]) == 211)
874 || (isSelectedPID==2 || isSelectedPID==3)){
875 ((TH1F*)listout->FindObject(fillthisK))->Fill(part->PtProng(0));
876 ((TH1F*)listout->FindObject(fillthispi))->Fill(part->PtProng(1));
880 //no mass cut ditributions: mass
884 if ((fReadMC && ((AliAODMCParticle*)arrMC->At(lab))->GetPdgCode() == 421)
885 || (!fReadMC && (isSelectedPID==1 || isSelectedPID==3))){//D0
886 ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0);
889 if(fReadMC || (!fReadMC && isSelectedPID > 1))
890 ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0bar);
893 //apply cut on invariant mass on the pair
894 if(TMath::Abs(minvD0-mPDG)<invmasscut || TMath::Abs(minvD0bar-mPDG)<invmasscut){
896 cosThetaStarD0 = part->CosThetaStarD0();
897 cosThetaStarD0bar = part->CosThetaStarD0bar();
898 cosPointingAngle = part->CosPointingAngle();
899 normalizedDecayLength2 = part->NormalizedDecayLength2();
900 decayLength2 = part->DecayLength2();
901 decayLengthxy = part->DecayLengthXY();
902 normalizedDecayLengthxy=decayLengthxy/part->DecayLengthXYError();
904 ptProng[0]=part->PtProng(0); ptProng[1]=part->PtProng(1);
905 d0Prong[0]=part->Getd0Prong(0); d0Prong[1]=part->Getd0Prong(1);
907 if(fArray==1) cout<<"LS signal: ERROR"<<endl;
908 for (Int_t iprong=0; iprong<2; iprong++){
909 AliAODTrack *prong=(AliAODTrack*)fDaughterTracks.UncheckedAt(iprong);
910 if (fReadMC) labprong[iprong]=prong->GetLabel();
912 //cout<<"prong name = "<<prong->GetName()<<" label = "<<prong->GetLabel()<<endl;
914 if(fReadMC && labprong[iprong]>=0) {
915 mcprong= (AliAODMCParticle*)arrMC->At(labprong[iprong]);
916 pdgprong=mcprong->GetPdgCode();
919 Bool_t isPionHere[2]={(isSelectedPID==1 || isSelectedPID==3) ? kTRUE : kFALSE,(isSelectedPID==2 || isSelectedPID==3) ? kTRUE : kFALSE};
921 if(TMath::Abs(pdgprong)==211 || isPionHere[iprong]) {
924 fillthispi="hptpiS_";
926 ((TH1F*)listout->FindObject(fillthispi))->Fill(ptProng[iprong]);
927 fillthispi="hd0piS_";
929 ((TH1F*)listout->FindObject(fillthispi))->Fill(d0Prong[iprong]);
932 fillthispi="hd0vpiS_";
934 ((TH1F*)listout->FindObject(fillthispi))->Fill(d0[iprong]);
939 if(TMath::Abs(pdgprong)==321 || !isPionHere[iprong]) {
940 //cout<<"kappa"<<endl;
944 ((TH1F*)listout->FindObject(fillthisK))->Fill(ptProng[iprong]);
947 ((TH1F*)listout->FindObject(fillthisK))->Fill(d0Prong[iprong]);
951 ((TH1F*)listout->FindObject(fillthisK))->Fill(d0[iprong]);
956 fillthis="hcosthpointd0S_";
958 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,d0Prong[iprong]);
960 } //end loop on prongs
964 ((TH1F*)listout->FindObject(fillthis))->Fill(part->GetDCA());
966 fillthis="hcosthetapointS_";
968 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle);
971 fillthis="hcosthetastarS_";
973 if ((fReadMC && ((AliAODMCParticle*)arrMC->At(lab))->GetPdgCode() == 421)) ((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0);
975 if (fReadMC || isSelectedPID>1)((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0bar);
976 if(isSelectedPID==1 || isSelectedPID==3)((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0);
980 ((TH1F*)listout->FindObject(fillthis))->Fill(part->Prodd0d0());
984 ((TH1F*)listout->FindObject(fillthis))->Fill(decayLength2);
986 fillthis="hnormdeclS_";
988 ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLength2);
990 fillthis="hdeclxyS_";
992 ((TH1F*)listout->FindObject(fillthis))->Fill(decayLengthxy);
994 fillthis="hnormdeclxyS_";
996 ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLengthxy);
1001 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[0]);
1003 fillthis="hnormdeclvS_";
1005 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[1]);
1007 fillthis="hd0d0vS_";
1009 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]*d0[1]);
1013 fillthis="hcosthpointd0d0S_";
1015 ((TH2F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,part->Prodd0d0());
1020 } else{ //Background or LS
1022 //cout<<"is background"<<endl;
1024 //no mass cut distributions: mass, ptbis
1028 if (!fCutOnDistr || (fCutOnDistr && (fIsSelectedCandidate==1 || fIsSelectedCandidate==3))) ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0);
1029 if (!fCutOnDistr || (fCutOnDistr && fIsSelectedCandidate>1)) ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0bar);
1031 fillthis="hptB1prongnoMcut_";
1034 ((TH1F*)listout->FindObject(fillthis))->Fill(part->PtProng(0));
1036 fillthis="hptB2prongsnoMcut_";
1038 ((TH1F*)listout->FindObject(fillthis))->Fill(part->PtProng(0));
1039 ((TH1F*)listout->FindObject(fillthis))->Fill(part->PtProng(1));
1041 //apply cut on invariant mass on the pair
1042 if(TMath::Abs(minvD0-mPDG)<invmasscut || TMath::Abs(minvD0bar-mPDG)<invmasscut){
1044 cosThetaStarD0 = part->CosThetaStarD0();
1045 cosThetaStarD0bar = part->CosThetaStarD0bar();
1046 cosPointingAngle = part->CosPointingAngle();
1047 normalizedDecayLength2 = part->NormalizedDecayLength2();
1048 decayLength2 = part->DecayLength2();
1049 decayLengthxy = part->DecayLengthXY();
1050 normalizedDecayLengthxy=decayLengthxy/part->DecayLengthXYError();
1051 ptProng[0]=part->PtProng(0); ptProng[1]=part->PtProng(1);
1052 d0Prong[0]=part->Getd0Prong(0); d0Prong[1]=part->Getd0Prong(1);
1055 AliAODTrack *prongg=(AliAODTrack*)fDaughterTracks.UncheckedAt(0);
1057 if(fDebug>2) cout<<"No daughter found";
1062 if(prongg->Charge()==1) {
1063 //fTotPosPairs[ptbin]++;
1064 ((TH1F*)fDistr->FindObject("hpospair"))->Fill(ptbin);
1066 //fTotNegPairs[ptbin]++;
1067 ((TH1F*)fDistr->FindObject("hnegpair"))->Fill(ptbin);
1072 //normalise pt distr to half afterwards
1075 ((TH1F*)listout->FindObject(fillthis))->Fill(ptProng[0]);
1076 ((TH1F*)listout->FindObject(fillthis))->Fill(ptProng[1]);
1080 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[0]);
1081 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[1]);
1084 Int_t pdgMother[2]={0,0};
1085 Double_t factor[2]={1,1};
1087 for(Int_t iprong=0;iprong<2;iprong++){
1088 AliAODTrack *prong=(AliAODTrack*)fDaughterTracks.UncheckedAt(iprong);
1089 lab=prong->GetLabel();
1091 AliAODMCParticle* mcprong=(AliAODMCParticle*)arrMC->At(lab);
1093 Int_t labmom=mcprong->GetMother();
1095 AliAODMCParticle* mcmother=(AliAODMCParticle*)arrMC->At(labmom);
1096 if(mcmother) pdgMother[iprong]=mcmother->GetPdgCode();
1103 fillthis="hd0moresB_";
1106 if(TMath::Abs(pdgMother[iprong])==310 || TMath::Abs(pdgMother[iprong])==130 || TMath::Abs(pdgMother[iprong])==321){ //K^0_S, K^0_L, K^+-
1107 if(ptProng[iprong]<=1)factor[iprong]=1./.7;
1108 else factor[iprong]=1./.6;
1109 fNentries->Fill(11);
1112 if(TMath::Abs(pdgMother[iprong])==3122) { //Lambda
1113 factor[iprong]=1./0.25;
1114 fNentries->Fill(12);
1116 fillthis="hd0moresB_";
1119 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[iprong],factor[iprong]);
1122 fillthis="hd0vmoresB_";
1124 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[iprong],factor[iprong]);
1130 fillthis="hd0d0moresB_";
1132 ((TH1F*)listout->FindObject(fillthis))->Fill(part->Prodd0d0(),factor[0]*factor[1]);
1134 fillthis="hcosthetapointmoresB_";
1136 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,factor[0]*factor[1]);
1139 fillthis="hd0d0vmoresB_";
1141 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]*d0[1],factor[0]*factor[1]);
1149 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[0]);
1152 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[1]);
1154 fillthis="hcosthpointd0d0B_";
1156 ((TH2F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,part->Prodd0d0());
1158 fillthis="hcosthpointd0B_";
1160 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,d0Prong[0]);
1161 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle,d0Prong[1]);
1166 fillthis="hd0vp0B_";
1168 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]);
1169 fillthis="hd0vp1B_";
1171 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[1]);
1175 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]);
1176 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[1]);
1184 ((TH1F*)listout->FindObject(fillthis))->Fill(part->GetDCA());
1186 fillthis="hcosthetastarB_";
1188 if (!fCutOnDistr || (fCutOnDistr && (fIsSelectedCandidate==1 || fIsSelectedCandidate==3)))((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0);
1189 if (!fCutOnDistr || (fCutOnDistr && fIsSelectedCandidate>1))((TH1F*)listout->FindObject(fillthis))->Fill(cosThetaStarD0bar);
1193 ((TH1F*)listout->FindObject(fillthis))->Fill(d0Prong[0]*d0Prong[1]);
1196 fillthis="hd0d0vB_";
1198 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]*d0[1]);
1201 fillthis="hcosthetapointB_";
1203 ((TH1F*)listout->FindObject(fillthis))->Fill(cosPointingAngle);
1207 ((TH1F*)listout->FindObject(fillthis))->Fill(decayLength2);
1209 fillthis="hnormdeclB_";
1211 ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLength2);
1213 fillthis="hdeclxyB_";
1215 ((TH1F*)listout->FindObject(fillthis))->Fill(decayLengthxy);
1217 fillthis="hnormdeclxyB_";
1219 ((TH1F*)listout->FindObject(fillthis))->Fill(normalizedDecayLengthxy);
1223 fillthis="hdeclvB_";
1225 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[0]);
1227 fillthis="hnormdeclvB_";
1229 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[1]);
1234 }//else (background)
1238 //____________________________________________________________________________
1240 void AliAnalysisTaskSED0Mass::FillMassHists(AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC, AliRDHFCutsD0toKpi* cuts, TList *listout){
1242 // function used in UserExec to fill mass histograms:
1246 Double_t mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
1248 //cout<<"is selected = "<<fIsSelectedCandidate<<endl;
1250 //cout<<"check cuts = "<<endl;
1252 if (!fIsSelectedCandidate){
1253 //cout<<"Not Selected"<<endl;
1254 //cout<<"Rejected because "<<cuts->GetWhy()<<endl;
1259 if(fDebug>2) cout<<"Candidate selected"<<endl;
1261 Double_t invmassD0 = part->InvMassD0(), invmassD0bar = part->InvMassD0bar();
1262 //printf("SELECTED\n");
1263 Int_t ptbin=cuts->PtBin(part->Pt());
1265 AliAODTrack *prong=(AliAODTrack*)fDaughterTracks.UncheckedAt(0);
1267 AliDebug(2,"No daughter found");
1271 // if(prong->Charge()==1) {
1272 // ((TH1F*)fDistr->FindObject("hpospair"))->Fill(fCuts->GetNPtBins()+ptbin);
1273 // //fTotPosPairs[ptbin]++;
1275 // ((TH1F*)fDistr->FindObject("hnegpair"))->Fill(fCuts->GetNPtBins()+ptbin);
1276 // //fTotNegPairs[ptbin]++;
1280 // for(Int_t it=0;it<2;it++){
1282 // //request on spd points to be addes
1283 // if(/*nSPD==2 && */part->Pt() > 5. && (TMath::Abs(invmassD0-mPDG)<0.01 || TMath::Abs(invmassD0bar-mPDG)<0.01)){
1284 // FILE *f=fopen("4display.txt","a");
1285 // 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());
1287 // //printf("PrimVtx NContributors: %d \n Prongs Rel Angle: %f \n \n",ncont,relangle);
1291 TString fillthis="";
1292 Int_t pdgDgD0toKpi[2]={321,211};
1294 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)
1296 //count candidates selected by cuts
1298 //count true D0 selected by cuts
1299 if (fReadMC && labD0>=0) fNentries->Fill(2);
1301 if ((fIsSelectedCandidate==1 || fIsSelectedCandidate==3) && fFillOnlyD0D0bar<2) { //D0
1302 fillthis="histMass_";
1304 //cout<<"Filling "<<fillthis<<endl;
1306 //printf("Fill mass with D0");
1307 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1310 if(fArray==1) cout<<"LS signal ERROR"<<endl;
1312 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
1313 Int_t pdgD0 = partD0->GetPdgCode();
1314 //cout<<"pdg = "<<pdgD0<<endl;
1315 if (pdgD0==421){ //D0
1316 //cout<<"Fill S with D0"<<endl;
1317 fillthis="histSgn_";
1319 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1321 if(TMath::Abs(invmassD0 - mPDG) < 0.027){
1322 fillthis="histSgn27_";
1324 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1327 } else{ //it was a D0bar
1328 fillthis="histRfl_";
1330 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1332 } else {//background
1333 fillthis="histBkg_";
1335 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1339 if (fIsSelectedCandidate>1 && (fFillOnlyD0D0bar==0 || fFillOnlyD0D0bar==2)) { //D0bar
1340 fillthis="histMass_";
1342 //printf("Fill mass with D0bar");
1343 ((TH1F*)listout->FindObject(fillthis))->Fill(invmassD0bar);
1346 if(fArray==1) cout<<"LS signal ERROR"<<endl;
1347 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
1348 Int_t pdgD0 = partD0->GetPdgCode();
1349 //cout<<" pdg = "<<pdgD0<<endl;
1350 if (pdgD0==-421){ //D0bar
1351 fillthis="histSgn_";
1353 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
1354 // if (TMath::Abs(invmassD0bar - mPDG) < 0.027){
1355 // fillthis="histSgn27_";
1357 // ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
1362 fillthis="histRfl_";
1364 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
1366 } else {//background or LS
1367 fillthis="histBkg_";
1369 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
1376 //__________________________________________________________________________
1377 AliAODVertex* AliAnalysisTaskSED0Mass::GetPrimaryVtxSkipped(AliAODEvent *aodev){
1378 //Calculate the primary vertex w/o the daughter tracks of the candidate
1381 Int_t nTrksToSkip=2;
1382 AliAODTrack *dgTrack = (AliAODTrack*)fDaughterTracks.UncheckedAt(0);
1384 AliDebug(2,"no daughter found!");
1387 skipped[0]=dgTrack->GetID();
1388 dgTrack = (AliAODTrack*)fDaughterTracks.UncheckedAt(1);
1390 AliDebug(2,"no daughter found!");
1393 skipped[1]=dgTrack->GetID();
1395 AliESDVertex *vertexESD=0x0;
1396 AliAODVertex *vertexAOD=0x0;
1397 AliVertexerTracks *vertexer = new AliVertexerTracks(aodev->GetMagneticField());
1400 vertexer->SetSkipTracks(nTrksToSkip,skipped);
1401 vertexer->SetMinClusters(4);
1402 vertexESD = (AliESDVertex*)vertexer->FindPrimaryVertex(aodev);
1403 if(!vertexESD) return vertexAOD;
1404 if(vertexESD->GetNContributors()<=0) {
1405 AliDebug(2,"vertexing failed");
1406 delete vertexESD; vertexESD=NULL;
1410 delete vertexer; vertexer=NULL;
1413 // convert to AliAODVertex
1414 Double_t pos[3],cov[6],chi2perNDF;
1415 vertexESD->GetXYZ(pos); // position
1416 vertexESD->GetCovMatrix(cov); //covariance matrix
1417 chi2perNDF = vertexESD->GetChi2toNDF();
1418 delete vertexESD; vertexESD=NULL;
1420 vertexAOD = new AliAODVertex(pos,cov,chi2perNDF);
1426 //________________________________________________________________________
1427 void AliAnalysisTaskSED0Mass::Terminate(Option_t */*option*/)
1429 // Terminate analysis
1431 if(fDebug > 1) printf("AnalysisTaskSED0Mass: Terminate() \n");
1434 fOutputMass = dynamic_cast<TList*> (GetOutputData(1));
1436 printf("ERROR: fOutputMass not available\n");
1440 fDistr = dynamic_cast<TList*> (GetOutputData(2));
1442 printf("ERROR: fDistr not available\n");
1447 fNentries = dynamic_cast<TH1F*>(GetOutputData(3));
1450 printf("ERROR: fNEntries not available\n");
1453 fCuts = dynamic_cast<AliRDHFCutsD0toKpi*>(GetOutputData(4));
1455 printf("ERROR: fCuts not available\n");
1458 fCounter = dynamic_cast<AliNormalizationCounter*>(GetOutputData(5));
1460 printf("ERROR: fCounter not available\n");
1463 Int_t nptbins=fCuts->GetNPtBins();
1464 for(Int_t ipt=0;ipt<nptbins;ipt++){
1466 if(fArray==1 && fFillVarHists){
1467 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
1470 if(fLsNormalization>1e-6) {
1472 TString massName="histMass_";
1474 ((TH1F*)fOutputMass->FindObject(massName))->Scale((1/fLsNormalization)*((TH1F*)fOutputMass->FindObject(massName))->GetEntries());
1479 fLsNormalization = 2.*TMath::Sqrt(((TH1F*)fDistr->FindObject("hpospair"))->Integral(ipt+1,ipt+2)*((TH1F*)fDistr->FindObject("hnegpair"))->Integral(ipt+1,ipt+2));
1480 //fLsNormalization = 2.*TMath::Sqrt(fTotPosPairs[4]*fTotNegPairs[4]);
1482 if(fLsNormalization>1e-6) {
1484 TString nameDistr="hptB_";
1486 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1489 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1490 nameDistr="hcosthetastarB_";
1492 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1495 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1496 nameDistr="hd0d0B_";
1498 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1499 nameDistr="hcosthetapointB_";
1501 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1502 nameDistr="hcosthpointd0d0B_";
1504 ((TH2F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH2F*)fDistr->FindObject(nameDistr))->GetEntries());
1509 TString cvname,cstname;
1519 TCanvas *cMass=new TCanvas(cvname,cvname);
1521 ((TH1F*)fOutputMass->FindObject("histMass_3"))->Draw();
1523 TCanvas* cStat=new TCanvas(cstname,Form("Stat%s",fArray ? "LS" : "D0"));
1526 fNentries->Draw("htext0");
1528 // TCanvas *ccheck=new TCanvas(Form("cc%d",fArray),Form("cc%d",fArray));