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 **************************************************************************/
16 /////////////////////////////////////////////////////////////
18 // AliAnalysisTaskSE for D0 candidates invariant mass histogram
19 // and comparison with the MC truth and cut variables distributions.
21 // Authors: A.Dainese, andrea.dainese@lnl.infn.it
22 // Chiara Bianchin, chiara.bianchin@pd.infn.it (invariant mass)
23 // Carmelo Di Giglio, carmelo.digiglio@ba.infn.it (like sign)
24 /////////////////////////////////////////////////////////////
26 #include <Riostream.h>
27 #include <TClonesArray.h>
33 #include <TDatabasePDG.h>
35 #include <AliAnalysisDataSlot.h>
36 #include <AliAnalysisDataContainer.h>
37 #include "AliAnalysisManager.h"
38 #include "AliESDtrack.h"
39 #include "AliVertexerTracks.h"
40 #include "AliAODHandler.h"
41 #include "AliAODEvent.h"
42 #include "AliAODVertex.h"
43 #include "AliAODTrack.h"
44 #include "AliAODMCHeader.h"
45 #include "AliAODMCParticle.h"
46 #include "AliAODRecoDecayHF2Prong.h"
47 #include "AliAODRecoCascadeHF.h"
48 #include "AliAnalysisVertexingHF.h"
49 #include "AliAnalysisTaskSE.h"
50 #include "AliAnalysisTaskSED0Mass.h"
53 ClassImp(AliAnalysisTaskSED0Mass)
56 //________________________________________________________________________
57 AliAnalysisTaskSED0Mass::AliAnalysisTaskSED0Mass():
75 // Default constructor
78 //________________________________________________________________________
79 AliAnalysisTaskSED0Mass::AliAnalysisTaskSED0Mass(const char *name,AliRDHFCutsD0toKpi* cuts):
80 AliAnalysisTaskSE(name),
97 // Default constructor
99 fNPtBins=cuts->GetNPtBins();
100 fTotPosPairs=new Int_t[fNPtBins];
101 fTotNegPairs=new Int_t[fNPtBins];
102 for(Int_t i=0;i<fNPtBins;i++) {fTotPosPairs[i]=0; fTotNegPairs[i]=0;}
106 // Output slot #1 writes into a TList container (mass with cuts)
107 DefineOutput(1,TList::Class()); //My private output
108 // Output slot #2 writes into a TList container (distributions)
109 DefineOutput(2,TList::Class()); //My private output
110 // Output slot #3 writes into a TH1F container (number of events)
111 DefineOutput(3,TH1F::Class()); //My private output
112 // Output slot #4 writes into a TList container (quality check)
113 DefineOutput(4,TList::Class()); //My private output
114 // Output slot #5 writes into a TList container (cuts)
115 DefineOutput(5,AliRDHFCutsD0toKpi::Class()); //My private output
119 //________________________________________________________________________
120 AliAnalysisTaskSED0Mass::~AliAnalysisTaskSED0Mass()
146 //________________________________________________________________________
147 void AliAnalysisTaskSED0Mass::Init()
151 if(fDebug > 1) printf("AnalysisTaskSED0Mass::Init() \n");
154 AliRDHFCutsD0toKpi* copyfCuts=new AliRDHFCutsD0toKpi(*fCuts);
155 const char* nameoutput=GetOutputSlot(5)->GetContainer()->GetName();
156 copyfCuts->SetName(nameoutput);
158 PostData(5,copyfCuts);
164 //________________________________________________________________________
165 void AliAnalysisTaskSED0Mass::UserCreateOutputObjects()
168 // Create the output container
170 if(fDebug > 1) printf("AnalysisTaskSED0Mass::UserCreateOutputObjects() \n");
172 // Several histograms are more conveniently managed in a TList
173 fOutputMass = new TList();
174 fOutputMass->SetOwner();
175 fOutputMass->SetName("listMass");
177 fDistr = new TList();
179 fDistr->SetName("distributionslist");
181 fChecks = new TList();
183 fChecks->SetName("checkHistograms");
185 TString nameMass=" ",nameSgn27=" ",nameSgn=" ", nameBkg=" ", nameRfl=" ",nameMassNocutsS =" ",nameMassNocutsB =" ", namedistr=" ";
187 for(Int_t i=0;i<fCuts->GetNPtBins();i++){
189 nameMass="histMass_";
191 nameSgn27="histSgn27_";
199 nameMassNocutsS="hMassS_";
201 nameMassNocutsB="hMassB_";
204 //histograms of cut variable distributions
209 TH1F *hptpiS = new TH1F(namedistr.Data(), "P_{T} distribution (pions);p_{T} [GeV/c]",200,0.,8.);
213 TH1F *hptKS = new TH1F(namedistr.Data(), "P_{T} distribution (kaons);p_{T} [GeV/c]",200,0.,8.);
217 TH1F *hptB = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
220 namedistr="hptpiSnoMcut_";
222 TH1F *hptpiSnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution (pions);p_{T} [GeV/c]",200,0.,8.);
224 namedistr="hptKSnoMcut_";
226 TH1F *hptKSnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution (kaons);p_{T} [GeV/c]",200,0.,8.);
228 namedistr="hptB1prongnoMcut_";
230 TH1F *hptB1pnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
232 namedistr="hptB2prongsnoMcut_";
234 TH1F *hptB2pnoMcut = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
240 TH1F *hdcaS = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
243 TH1F *hdcaB = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
246 namedistr="hcosthetastarS_";
248 TH1F *hcosthetastarS = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
249 namedistr="hcosthetastarB_";
251 TH1F *hcosthetastarB = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
256 TH1F *hd0piS = new TH1F(namedistr.Data(), "Impact parameter distribution (pions);d0(#pi) [cm]",200,-0.1,0.1);
260 TH1F *hd0KS = new TH1F(namedistr.Data(), "Impact parameter distribution (kaons);d0(K) [cm]",200,-0.1,0.1);
264 TH1F *hd0B = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
268 TH1F *hd0p0B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.1,0.1);
270 namedistr="hd0moresB_";
272 TH1F *hd0moresB = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
274 namedistr="hd0d0moresB_";
276 TH1F *hd0d0moresB = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.001,0.001);
278 namedistr="hd0vmoresB_";
280 TH1F *hd0vmoresB = new TH1F(namedistr.Data(), "Impact parameter distribution (both);d0 [cm]",200,-0.1,0.1);
282 namedistr="hd0d0vmoresB_";
284 TH1F *hd0d0vmoresB = new TH1F(namedistr.Data(), "Impact parameter distribution (prong +);d0 [cm]",200,-0.001,0.001);
288 TH1F *hd0p1B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong -);d0 [cm]",200,-0.1,0.1);
290 namedistr="hd0vpiS_";
292 TH1F *hd0vpiS = new TH1F(namedistr.Data(), "Impact parameter distribution (pions)(vtx w/o these tracks);d0(#pi) [cm]",200,-0.1,0.1);
296 TH1F *hd0vKS = new TH1F(namedistr.Data(), "Impact parameter distribution (kaons) (vtx w/o these tracks);d0(K) [cm]",200,-0.1,0.1);
299 TH1F *hd0vB = new TH1F(namedistr.Data(), "Impact parameter distribution (vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
301 namedistr="hd0vp0B_";
303 TH1F *hd0vp0B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong + ** vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
305 namedistr="hd0vp1B_";
307 TH1F *hd0vp1B = new TH1F(namedistr.Data(), "Impact parameter distribution (prong - ** vtx w/o these tracks);d0 [cm]",200,-0.1,0.1);
311 TH1F *hd0d0S = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution;d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
314 TH1F *hd0d0B = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution;d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
316 namedistr="hd0d0vS_";
318 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);
319 namedistr="hd0d0vB_";
321 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);
326 TH1F *hdeclengthS = new TH1F(namedistr.Data(), "Decay Length distribution;Decay Length [cm]",200,0,0.15);
330 TH1F *hdeclengthB = new TH1F(namedistr.Data(), "Decay Length distribution;Decay Length [cm]",200,0,0.15);
332 namedistr="hnormdeclS_";
334 TH1F *hnormdeclengthS = new TH1F(namedistr.Data(), "Normalized Decay Length distribution;Decay Length/Err ",200,0,6.);
336 namedistr="hnormdeclB_";
338 TH1F *hnormdeclengthB = new TH1F(namedistr.Data(), "Normalized Decay Length distribution;Decay Length/Err ",200,0,6.);
340 namedistr="hdeclvS_";
342 TH1F *hdeclengthvS = new TH1F(namedistr.Data(), "Decay Length distribution (vtx w/o tracks);Decay Length [cm]",200,0,0.6);
344 namedistr="hdeclvB_";
346 TH1F *hdeclengthvB = new TH1F(namedistr.Data(), "Decay Length distribution (vtx w/o tracks);Decay Length [cm]",200,0,0.6);
348 namedistr="hnormdeclvS_";
350 TH1F *hnormdeclengthvS = new TH1F(namedistr.Data(), "Normalized Decay Length distribution (vtx w/o tracks);Decay Length/Err ",200,0,10.);
352 namedistr="hnormdeclvB_";
354 TH1F *hnormdeclengthvB = new TH1F(namedistr.Data(), "Normalized Decay Length distribution (vtx w/o tracks);Decay Length/Err ",200,0,10.);
357 namedistr="hcosthetapointS_";
359 TH1F *hcosthetapointS = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
360 namedistr="hcosthetapointB_";
362 TH1F *hcosthetapointB = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
364 namedistr="hcosthetapointmoresB_";
366 TH1F *hcosthetapointmoresB = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
368 // costhetapoint vs d0 or d0d0
369 namedistr="hcosthpointd0S_";
371 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);
373 namedistr="hcosthpointd0B_";
375 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);
377 namedistr="hcosthpointd0d0S_";
379 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);
380 namedistr="hcosthpointd0d0B_";
382 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);
388 fDistr->Add(hptpiSnoMcut);
389 fDistr->Add(hptKSnoMcut);
390 fDistr->Add(hptB1pnoMcut);
391 fDistr->Add(hptB2pnoMcut);
400 fDistr->Add(hd0moresB);
403 fDistr->Add(hd0vpiS);
406 fDistr->Add(hd0vp0B);
407 fDistr->Add(hd0vp1B);
408 fDistr->Add(hd0vmoresB);
412 fDistr->Add(hd0d0moresB);
414 fDistr->Add(hd0d0vS);
415 fDistr->Add(hd0d0vB);
416 fDistr->Add(hd0d0vmoresB);
418 fDistr->Add(hcosthetastarS);
419 fDistr->Add(hcosthetastarB);
421 fDistr->Add(hcosthetapointS);
422 fDistr->Add(hcosthetapointB);
423 fDistr->Add(hcosthetapointmoresB);
425 fDistr->Add(hdeclengthS);
426 fDistr->Add(hdeclengthB);
428 fDistr->Add(hnormdeclengthS);
429 fDistr->Add(hnormdeclengthB);
431 fDistr->Add(hdeclengthvS);
432 fDistr->Add(hdeclengthvB);
434 fDistr->Add(hnormdeclengthvS);
435 fDistr->Add(hnormdeclengthvB);
437 fDistr->Add(hcosthpointd0S);
438 fDistr->Add(hcosthpointd0B);
440 fDistr->Add(hcosthpointd0d0S);
441 fDistr->Add(hcosthpointd0d0B);
444 //histograms of invariant mass distributions
446 TH1F* tmpMt = new TH1F(nameMass.Data(),"D^{0} invariant mass; M [GeV]; Entries",200,1.765,1.965);
447 TH1F *tmpMl=(TH1F*)tmpMt->Clone();
451 //to compare with AliAnalysisTaskCharmFraction
452 TH1F* tmpS27t = new TH1F(nameSgn27.Data(),"D^{0} invariant mass in M(D^{0}) +/- 27 MeV - MC; M [GeV]; Entries",200,1.765,1.965);
453 TH1F *tmpS27l=(TH1F*)tmpS27t->Clone();
457 //distribution w/o cuts
458 // TH1F* tmpMS = new TH1F(nameMassNocutsS.Data(),"D^{0} invariant mass; M [GeV]; Entries",300,0.7,3.);
459 TH1F* tmpMS = new TH1F(nameMassNocutsS.Data(),"D^{0} invariant mass; M [GeV]; Entries",300,1.56484,2.16484); //range (MD0-300MeV, mD0 + 300MeV)
460 TH1F *tmpMB=(TH1F*)tmpMS->Clone();
461 tmpMB->SetName(nameMassNocutsB.Data());
465 //MC signal and background
466 TH1F* tmpSt = new TH1F(nameSgn.Data(), "D^{0} invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
467 TH1F *tmpSl=(TH1F*)tmpSt->Clone();
471 TH1F* tmpBt = new TH1F(nameBkg.Data(), "Background invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
472 TH1F *tmpBl=(TH1F*)tmpBt->Clone();
476 //Reflection: histo filled with D0Mass which pass the cut (also) as D0bar and with D0bar which pass (also) the cut as D0
477 TH1F* tmpRt = new TH1F(nameRfl.Data(), "Reflected signal invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
478 TH1F *tmpRl=(TH1F*)tmpRt->Clone();
481 // printf("Created histograms %s\t%s\t%s\t%s\n",tmpM->GetName(),tmpS->GetName(),tmpB->GetName(),tmpR->GetName());
483 fOutputMass->Add(tmpMt);
484 fOutputMass->Add(tmpSt);
485 fOutputMass->Add(tmpS27t);
486 fOutputMass->Add(tmpBt);
487 fOutputMass->Add(tmpRt);
495 //histograms for vertex checking and TOF checking
496 TString checkname="hptGoodTr";
498 TH1F* hptGoodTr=new TH1F(checkname.Data(),"Pt distribution of 'good' tracks;p_{t}[GeV];Number",200,0.,8.);
499 hptGoodTr->SetTitleOffset(1.3,"Y");
500 checkname="hdistrGoodTr";
502 TH1F* hdistrGoodTr=new TH1F(checkname.Data(),"Distribution of number of good tracks per event;no.good-tracks/ev;Entries",31,0,31);
503 hdistrGoodTr->SetTitleOffset(1.3,"Y");
506 TH1F* hTOFsig=new TH1F(checkname.Data(),"Distribution of TOF signal;TOF time [ps];Entries", 100, -2.e3,40.e3);
509 TH1F* hTPCsig=new TH1F(checkname.Data(),"Distribution of TPC signal;TPC sig;Entries", 100, 35.,100.);
511 checkname="hTOFtimeKaonHyptime";
512 TH2F* hTOFtimeKaonHyptime=new TH2F(checkname.Data(),"TOFtime - timeHypothesisForKaon;p[GeV/c];TOFtime - timeHypothesisForKaon [ps]",200,0.,4.,1000,-20000.,20000.);
514 checkname="hTOFtimeKaonHyptimeAC";
515 TH2F* hTOFtimeKaonHyptimeAC=new TH2F(checkname.Data(),"TOFtime - timeHypothesisForKaon;p[GeV/c];TOFtime - timeHypothesisForKaon [ps]",200,0.,4.,1000,-20000.,20000.);
517 checkname="hTPCsigvsp";
518 TH2F* hTPCsigvsp=new TH2F(checkname.Data(),"TPCsig vs p;p[GeV/c];TPCsig",200,0.,4.,1000,35.,100.);
520 checkname="hTOFtime";
521 TH1F* hTOFtime=new TH1F(checkname.Data(),"Distribution of TOF time Kaon;TOF time(Kaon) [ps];Entries", 1000, 0.,50000.);
524 fChecks->Add(hptGoodTr);
525 fChecks->Add(hdistrGoodTr);
526 fChecks->Add(hTOFsig);
527 fChecks->Add(hTPCsig);
528 fChecks->Add(hTOFtimeKaonHyptime);
529 fChecks->Add(hTOFtimeKaonHyptimeAC);
530 fChecks->Add(hTPCsigvsp);
531 fChecks->Add(hTOFtime);
533 const char* nameoutput=GetOutputSlot(3)->GetContainer()->GetName();
535 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", 14,-0.5,13.5);
537 fNentries->GetXaxis()->SetBinLabel(1,"nEventsAnal");
538 fNentries->GetXaxis()->SetBinLabel(2,"nCandSel(Cuts)");
539 fNentries->GetXaxis()->SetBinLabel(3,"nD0Selected");
540 fNentries->GetXaxis()->SetBinLabel(4,"nEventsGoodVtxS");
541 fNentries->GetXaxis()->SetBinLabel(5,"nEventsGoodVtx+>2tracks");
542 fNentries->GetXaxis()->SetBinLabel(6,"ptbin = -1");
543 fNentries->GetXaxis()->SetBinLabel(7,"no daughter");
544 fNentries->GetXaxis()->SetBinLabel(8,"nCandSel(Tr)");
545 fNentries->GetXaxis()->SetBinLabel(9,"PID=0");
546 fNentries->GetXaxis()->SetBinLabel(10,"PID=1");
547 fNentries->GetXaxis()->SetBinLabel(11,"PID=2");
548 fNentries->GetXaxis()->SetBinLabel(12,"PID=3");
549 fNentries->GetXaxis()->SetBinLabel(13,"K");
550 fNentries->GetXaxis()->SetBinLabel(14,"Lambda");
551 fNentries->GetXaxis()->SetNdivisions(1,kFALSE);
555 PostData(1,fOutputMass);
557 PostData(3,fNentries);
563 //________________________________________________________________________
564 void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
566 // Execute analysis for current event:
567 // heavy flavor candidates association to MC truth
568 //cout<<"I'm in UserExec"<<endl;
572 // printf(" |M-MD0| [GeV] < %f\n",fD0toKpiCuts[0]);
573 // printf(" dca [cm] < %f\n",fD0toKpiCuts[1]);
574 // printf(" cosThetaStar < %f\n",fD0toKpiCuts[2]);
575 // printf(" pTK [GeV/c] > %f\n",fD0toKpiCuts[3]);
576 // printf(" pTpi [GeV/c] > %f\n",fD0toKpiCuts[4]);
577 // printf(" |d0K| [cm] < %f\n",fD0toKpiCuts[5]);
578 // printf(" |d0pi| [cm] < %f\n",fD0toKpiCuts[6]);
579 // printf(" d0d0 [cm^2] < %f\n",fD0toKpiCuts[7]);
580 // printf(" cosThetaPoint > %f\n",fD0toKpiCuts[8]);
583 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
586 if(fArray==0){ //D0 candidates
587 // load D0->Kpi candidates
588 //cout<<"D0 candidates"<<endl;
590 } else { //LikeSign candidates
591 // load like sign candidates
592 //cout<<"LS candidates"<<endl;
593 bname="LikeSign2Prong";
596 TClonesArray *inputArray=0;
598 if(!aod && AODEvent() && IsStandardAOD()) {
599 // In case there is an AOD handler writing a standard AOD, use the AOD
600 // event in memory rather than the input (ESD) event.
601 aod = dynamic_cast<AliAODEvent*> (AODEvent());
602 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
603 // have to taken from the AOD event hold by the AliAODExtension
604 AliAODHandler* aodHandler = (AliAODHandler*)
605 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
607 if(aodHandler->GetExtensions()) {
608 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
609 AliAODEvent* aodFromExt = ext->GetAOD();
610 inputArray=(TClonesArray*)aodFromExt->GetList()->FindObject(bname.Data());
613 inputArray=(TClonesArray*)aod->GetList()->FindObject(bname.Data());
618 printf("AliAnalysisTaskSED0Mass::UserExec: input branch not found!\n");
622 // fix for temporary bug in ESDfilter
623 // the AODs with null vertex pointer didn't pass the PhysSel
624 if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001) return;
627 TClonesArray *mcArray = 0;
628 AliAODMCHeader *mcHeader = 0;
632 mcArray = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
634 printf("AliAnalysisTaskSED0Mass::UserExec: MC particles branch not found!\n");
639 mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
641 printf("AliAnalysisTaskSED0Mass::UserExec: MC header branch not found!\n");
646 //printf("VERTEX Z %f %f\n",vtx1->GetZ(),mcHeader->GetVtxZ());
648 //histogram filled with 1 for every AOD
651 if(!fCuts->IsEventSelected(aod)) return;
653 // AOD primary vertex
654 AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
656 Bool_t isGoodVtx=kFALSE;
659 TString primTitle = vtx1->GetTitle();
660 if(primTitle.Contains("VertexerTracks") && vtx1->GetNContributors()>0) {
666 //cout<<"Start checks"<<endl;
667 Int_t ntracks=0,isGoodTrack=0;
669 if(aod) ntracks=aod->GetNTracks();
671 //cout<<"ntracks = "<<ntracks<<endl;
673 //loop on tracks in the event
674 for (Int_t k=0;k<ntracks;k++){
675 AliAODTrack* track=aod->GetTrack(k);
676 //cout<<"track n = "<<k<<endl;
679 if(!(track->GetStatus()&AliESDtrack::kTPCrefit &&
680 track->GetStatus()&AliESDtrack::kITSrefit &&
681 track->GetTPCNcls() >=70 &&
682 track->GetStatus()&AliESDtrack::kTOFpid &&
683 track->GetStatus()&AliESDtrack::kTOFout &&
684 track->GetStatus()&AliESDtrack::kTIME)) continue;
685 AliAODPid *pid = track->GetDetPid();
686 if(!pid) {if (fDebug>1)cout<<"No AliAODPid found"<<endl; continue;}
689 pid->GetIntegratedTimes(times);
691 ((TH1F*)fChecks->FindObject("hTOFtime"))->Fill(times[3]);
692 ((TH1F*)fChecks->FindObject("hTOFtimeKaonHyptime"))->Fill(track->P(),pid->GetTOFsignal()-times[3]); //3 is kaon
694 ((TH1F*)fChecks->FindObject("hTOFsig"))->Fill(pid->GetTOFsignal());
695 ((TH1F*)fChecks->FindObject("hTPCsig"))->Fill(pid->GetTPCsignal());
696 ((TH1F*)fChecks->FindObject("hTPCsigvsp"))->Fill(track->P(),pid->GetTPCsignal());
697 if (pid->GetTOFsignal()< 0) ((TH1F*)fChecks->FindObject("hTOFsig"))->Fill(-1);
699 //check clusters of the tracks
700 Int_t nclsTot=0,nclsSPD=0;
702 for(Int_t l=0;l<6;l++) {
703 if(TESTBIT(track->GetITSClusterMap(),l)) {
704 nclsTot++; if(l<2) nclsSPD++;
708 if (track->Pt()>0.3 &&
709 track->GetStatus()&AliESDtrack::kTPCrefit &&
710 track->GetStatus()&AliESDtrack::kITSrefit &&
712 nclsSPD>0) {//fill hist good tracks
714 ((TH1F*)fChecks->FindObject("hptGoodTr"))->Fill(track->Pt());
717 //cout<<"isGoodTrack = "<<isGoodTrack<<endl;
718 ((TH1F*)fChecks->FindObject("hdistrGoodTr"))->Fill(isGoodTrack);
720 //number of events with good vertex and at least 2 good tracks
721 if (isGoodTrack>=2 && isGoodVtx) fNentries->Fill(4);
723 // loop over candidates
724 Int_t nInD0toKpi = inputArray->GetEntriesFast();
725 if(fDebug>2) printf("Number of D0->Kpi: %d\n",nInD0toKpi);
727 // FILE *f=fopen("4display.txt","a");
728 // fprintf(f,"Number of D0->Kpi: %d\n",nInD0toKpi);
730 for (Int_t iD0toKpi = 0; iD0toKpi < nInD0toKpi; iD0toKpi++) {
731 //Int_t nPosPairs=0, nNegPairs=0;
732 //cout<<"inside the loop"<<endl;
733 AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)inputArray->UncheckedAt(iD0toKpi);
736 if(!(d->GetDaughter(0) || d->GetDaughter(1))) {
737 AliDebug(1,"at least one daughter not found!");
742 // Bool_t unsetvtx=kFALSE;
743 // if(!d->GetOwnPrimaryVtx()) {
744 // d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
749 //check reco daughter in acceptance
751 Double_t eta0=d->EtaProng(0);
752 Double_t eta1=d->EtaProng(1);
754 if ( fCuts->IsInFiducialAcceptance(d->Pt(),d->Y(421)) ) {
755 //if( TMath::Abs(eta0)<0.9 && TMath::Abs(eta1)<0.9 ){
756 //apply cuts on tracks
757 Int_t isSelected = fCuts->IsSelected(d,AliRDHFCuts::kTracks);
759 if(((AliAODTrack*)d->GetDaughter(0))->GetTPCNcls() < 70 || ((AliAODTrack*)d->GetDaughter(1))->GetTPCNcls() < 70) isSelected=kFALSE;
760 if (!isSelected) return;
762 if(fDebug>2) cout<<"tracks selected"<<endl;
764 Int_t ptbin=fCuts->PtBin(d->Pt());
765 if(ptbin==-1) {fNentries->Fill(5); return;} //out of bounds
766 FillVarHists(aod,d,mcArray,fCuts,fDistr);
767 FillMassHists(aod,d,mcArray,fCuts,fOutputMass);
770 //if(unsetvtx) d->UnsetOwnPrimaryVtx();
775 PostData(1,fOutputMass);
777 PostData(3,fNentries);
783 //____________________________________________________________________________
784 void AliAnalysisTaskSED0Mass::FillVarHists(AliAODEvent* aod,AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC, AliRDHFCutsD0toKpi *cuts, TList *listout){
786 // function used in UserExec to fill variable histograms:
792 Double_t mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
795 Double_t minvD0 = part->InvMassD0();
798 Double_t minvD0bar = part->InvMassD0bar();
799 //cout<<"inside mass cut"<<endl;
801 Int_t pdgDgD0toKpi[2]={321,211};
803 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)
804 //Double_t pt = d->Pt(); //mother pt
806 Int_t isSelectedPID=99;
808 //isSelectedPID = cuts->IsSelected(part,AliRDHFCuts::kPID); //0 rejected,1 D0,2 Dobar, 3 both
809 isSelectedPID = cuts->IsSelectedPID(part); //0 rejected,1 D0,2 Dobar, 3 both
810 if (isSelectedPID==0)fNentries->Fill(8);
811 if (isSelectedPID==1)fNentries->Fill(9);
812 if (isSelectedPID==2)fNentries->Fill(10);
813 if (isSelectedPID==3)fNentries->Fill(11);
814 //fNentries->Fill(8+isSelectedPID);
817 isSelected = cuts->IsSelected(part,AliRDHFCuts::kCandidate,aod); //cuts with variables recalculated with new vertex (w/o daughters)
819 //cout<<"Not Selected"<<endl;
824 Double_t invmasscut=0.03;
826 TString fillthispi="",fillthisK="",fillthis="";
828 Int_t ptbin=cuts->PtBin(part->Pt());
832 AliAODVertex *vtxProp=0x0;
833 vtxProp=GetPrimaryVtxSkipped(aod,part);
834 Double_t dz1[2],dz2[2],covar1[3],covar2[3];//,d0xd0proper,errd0xd0proper;
835 dz1[0]=-99; dz2[0]=-99;
837 part->SetOwnPrimaryVtx(vtxProp);
838 //Bool_t unsetvtx=kTRUE;
839 //Calculate d0 for daughter tracks with Vtx Skipped
840 AliESDtrack *esdtrack1=new AliESDtrack((AliVTrack*)part->GetDaughter(0));
841 AliESDtrack *esdtrack2=new AliESDtrack((AliVTrack*)part->GetDaughter(1));
842 esdtrack1->PropagateToDCA(vtxProp,aod->GetMagneticField(),1.,dz1,covar1);
843 esdtrack2->PropagateToDCA(vtxProp,aod->GetMagneticField(),1.,dz2,covar2);
844 delete vtxProp; vtxProp=NULL;
849 Double_t d0[2]={dz1[0],dz2[0]};
850 Double_t decl[2]={part->DecayLength(),part->NormalizedDecayLength()};
851 part->UnsetOwnPrimaryVtx();
853 if(!fCutOnDistr || (fCutOnDistr && isSelected)){ //if no cuts or cuts passed
854 //printf("\nif no cuts or cuts passed\n");
857 if(!fUsePid4Distr) isSelectedPID=0;
858 if((lab>=0 && fReadMC) || (!fReadMC && isSelectedPID)){ //signal (from MC or PID)
859 //if(!vtxProp) fNentries->Fill(3);
860 //check pdg of the prongs
861 AliAODTrack *prong0=(AliAODTrack*)part->GetDaughter(0);
862 AliAODTrack *prong1=(AliAODTrack*)part->GetDaughter(1);
863 if(!prong0 || !prong1) {
868 labprong[0]=prong0->GetLabel();
869 labprong[1]=prong1->GetLabel();
871 AliAODMCParticle *mcprong=0;
872 Int_t pdgProng[2]={0,0};
874 for (Int_t iprong=0;iprong<2;iprong++){
875 if(fReadMC && labprong[iprong]>=0) {
876 mcprong= (AliAODMCParticle*)arrMC->At(labprong[iprong]);
877 pdgProng[iprong]=mcprong->GetPdgCode();
882 //no mass cut ditributions: ptbis
884 fillthispi="hptpiSnoMcut_";
887 fillthisK="hptKSnoMcut_";
890 if ((TMath::Abs(pdgProng[0]) == 211 && TMath::Abs(pdgProng[1]) == 321)
891 || (isSelectedPID==1 || isSelectedPID==3)){
892 ((TH1F*)listout->FindObject(fillthispi))->Fill(part->PtProng(0));
893 ((TH1F*)listout->FindObject(fillthisK))->Fill(part->PtProng(1));
896 if ((TMath::Abs(pdgProng[0]) == 321 && TMath::Abs(pdgProng[1]) == 211)
897 || (isSelectedPID==2 || isSelectedPID==3)){
898 ((TH1F*)listout->FindObject(fillthisK))->Fill(part->PtProng(0));
899 ((TH1F*)listout->FindObject(fillthispi))->Fill(part->PtProng(1));
902 //no mass cut ditributions: mass
906 if ((fReadMC && ((AliAODMCParticle*)arrMC->At(lab))->GetPdgCode() == 421)
907 || (!fReadMC && (isSelectedPID==1 || isSelectedPID==3))){//D0
908 ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0);
911 if(fReadMC || (!fReadMC && isSelectedPID > 1))
912 ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0bar);
915 //apply cut on invariant mass on the pair
916 if(TMath::Abs(minvD0-mPDG)<invmasscut || TMath::Abs(minvD0bar-mPDG)<invmasscut){
918 if(fArray==1) cout<<"LS signal: ERROR"<<endl;
919 for (Int_t iprong=0; iprong<2; iprong++){
920 AliAODTrack *prong=(AliAODTrack*)part->GetDaughter(iprong);
921 if (fReadMC) labprong[iprong]=prong->GetLabel();
923 //cout<<"prong name = "<<prong->GetName()<<" label = "<<prong->GetLabel()<<endl;
925 if(fReadMC && labprong[iprong]>=0) {
926 mcprong= (AliAODMCParticle*)arrMC->At(labprong[iprong]);
927 pdgprong=mcprong->GetPdgCode();
930 Bool_t isPionHere[2]={(isSelectedPID==1 || isSelectedPID==3) ? kTRUE : kFALSE,(isSelectedPID==2 || isSelectedPID==3) ? kTRUE : kFALSE};
932 if(TMath::Abs(pdgprong)==211 || isPionHere[iprong]) {
935 fillthispi="hptpiS_";
937 ((TH1F*)listout->FindObject(fillthispi))->Fill(part->PtProng(iprong));
938 fillthispi="hd0piS_";
940 ((TH1F*)listout->FindObject(fillthispi))->Fill(part->Getd0Prong(iprong));
941 if(d0[iprong] != -99) {
943 fillthispi="hd0vpiS_";
945 ((TH1F*)listout->FindObject(fillthispi))->Fill(d0[iprong]);
950 if(TMath::Abs(pdgprong)==321 || !isPionHere[iprong]) {
951 //cout<<"kappa"<<endl;
955 ((TH1F*)listout->FindObject(fillthisK))->Fill(part->PtProng(iprong));
958 ((TH1F*)listout->FindObject(fillthisK))->Fill(part->Getd0Prong(iprong));
959 if (d0[iprong] != -99){
962 ((TH1F*)listout->FindObject(fillthisK))->Fill(d0[iprong]);
966 fillthis="hcosthpointd0S_";
968 ((TH1F*)listout->FindObject(fillthis))->Fill(part->CosPointingAngle(),part->Getd0Prong(iprong));
970 } //end loop on prongs
974 ((TH1F*)listout->FindObject(fillthis))->Fill(part->GetDCA());
976 fillthis="hcosthetapointS_";
978 ((TH1F*)listout->FindObject(fillthis))->Fill(part->CosPointingAngle());
980 fillthis="hcosthpointd0d0S_";
982 ((TH2F*)listout->FindObject(fillthis))->Fill(part->CosPointingAngle(),part->Prodd0d0());
984 fillthis="hcosthetastarS_";
986 if ((fReadMC && ((AliAODMCParticle*)arrMC->At(lab))->GetPdgCode() == 421)) ((TH1F*)listout->FindObject(fillthis))->Fill(part->CosThetaStarD0());
988 if (fReadMC || isSelectedPID>1)((TH1F*)listout->FindObject(fillthis))->Fill(part->CosThetaStarD0bar());
989 if(isSelectedPID==1 || isSelectedPID==3)((TH1F*)listout->FindObject(fillthis))->Fill(part->CosThetaStarD0());
993 ((TH1F*)listout->FindObject(fillthis))->Fill(part->Prodd0d0());
995 if(d0[0] != -99 && d0[1] != -99 ){
998 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]*d0[1]);
1003 ((TH1F*)listout->FindObject(fillthis))->Fill(part->DecayLength());
1005 fillthis="hnormdeclS_";
1007 ((TH1F*)listout->FindObject(fillthis))->Fill(part->NormalizedDecayLength());
1010 fillthis="hdeclvS_";
1012 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[0]);
1014 fillthis="hnormdeclvS_";
1016 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[1]);
1020 } else{ //Background or LS
1022 //cout<<"is background"<<endl;
1024 //no mass cut distributions: mass, ptbis
1028 if (!fCutOnDistr || (fCutOnDistr && (isSelected==1 || isSelected==3))) ((TH1F*)listout->FindObject(fillthis))->Fill(minvD0);
1029 if (!fCutOnDistr || (fCutOnDistr && isSelected>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){
1045 AliAODTrack *prongg=(AliAODTrack*)part->GetDaughter(0);
1047 if(fDebug>2) cout<<"No daughter found";
1051 if(prongg->Charge()==1) {fTotPosPairs[ptbin]++;} else {fTotNegPairs[ptbin]++;}
1054 //normalise pt distr to half afterwards
1057 ((TH1F*)listout->FindObject(fillthis))->Fill(part->PtProng(0));
1058 ((TH1F*)listout->FindObject(fillthis))->Fill(part->PtProng(1));
1062 ((TH1F*)listout->FindObject(fillthis))->Fill(part->Getd0Prong(0));
1065 ((TH1F*)listout->FindObject(fillthis))->Fill(part->Getd0Prong(1));
1068 ((TH1F*)listout->FindObject(fillthis))->Fill(part->Getd0Prong(0));
1069 ((TH1F*)listout->FindObject(fillthis))->Fill(part->Getd0Prong(1));
1072 Int_t pdgMother[2]={0,0};
1073 Double_t factor[2]={1,1};
1075 for(Int_t iprong=0;iprong<2;iprong++){
1076 AliAODTrack *prong=(AliAODTrack*)part->GetDaughter(iprong);
1077 lab=prong->GetLabel();
1079 AliAODMCParticle* mcprong=(AliAODMCParticle*)arrMC->At(lab);
1081 Int_t labmom=mcprong->GetMother();
1083 AliAODMCParticle* mcmother=(AliAODMCParticle*)arrMC->At(labmom);
1084 if(mcmother) pdgMother[iprong]=mcmother->GetPdgCode();
1089 fillthis="hd0moresB_";
1092 if(TMath::Abs(pdgMother[iprong])==310 || TMath::Abs(pdgMother[iprong])==130 || TMath::Abs(pdgMother[iprong])==321){ //K^0_S, K^0_L, K^+-
1093 if(part->PtProng(iprong)<=1)factor[iprong]=1./.7;
1094 else factor[iprong]=1./.6;
1095 fNentries->Fill(12);
1098 if(TMath::Abs(pdgMother[iprong])==3122) { //Lambda
1099 factor[iprong]=1./0.25;
1100 fNentries->Fill(13);
1102 fillthis="hd0moresB_";
1105 ((TH1F*)listout->FindObject(fillthis))->Fill(part->Getd0Prong(iprong),factor[iprong]);
1107 fillthis="hd0vmoresB_";
1109 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[iprong],factor[iprong]);
1113 fillthis="hd0d0moresB_";
1115 ((TH1F*)listout->FindObject(fillthis))->Fill(part->Prodd0d0(),factor[0]*factor[1]);
1117 fillthis="hd0d0vmoresB_";
1119 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]*d0[1],factor[0]*factor[1]);
1121 fillthis="hcosthetapointmoresB_";
1123 ((TH1F*)listout->FindObject(fillthis))->Fill(part->CosPointingAngle(),factor[0]*factor[1]);
1126 fillthis="hd0vp0B_";
1128 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]);
1129 fillthis="hd0vp1B_";
1131 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[1]);
1135 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]);
1136 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[1]);
1139 fillthis="hcosthpointd0B_";
1141 ((TH1F*)listout->FindObject(fillthis))->Fill(part->CosPointingAngle(),part->Getd0Prong(0));
1142 ((TH1F*)listout->FindObject(fillthis))->Fill(part->CosPointingAngle(),part->Getd0Prong(1));
1147 ((TH1F*)listout->FindObject(fillthis))->Fill(part->GetDCA());
1149 fillthis="hcosthetastarB_";
1151 if (!fCutOnDistr || (fCutOnDistr && (isSelected==1 || isSelected==3)))((TH1F*)listout->FindObject(fillthis))->Fill(part->CosThetaStarD0());
1152 if (!fCutOnDistr || (fCutOnDistr && isSelected>1))((TH1F*)listout->FindObject(fillthis))->Fill(part->CosThetaStarD0bar());
1156 ((TH1F*)listout->FindObject(fillthis))->Fill(part->Prodd0d0());
1158 if(d0[0] != -99 && d0[1] != -99 ){
1159 fillthis="hd0d0vB_";
1161 ((TH1F*)listout->FindObject(fillthis))->Fill(d0[0]*d0[1]);
1164 fillthis="hcosthetapointB_";
1166 ((TH1F*)listout->FindObject(fillthis))->Fill(part->CosPointingAngle());
1168 fillthis="hcosthpointd0d0B_";
1170 ((TH2F*)listout->FindObject(fillthis))->Fill(part->CosPointingAngle(),part->Prodd0d0());
1174 ((TH1F*)listout->FindObject(fillthis))->Fill(part->DecayLength());
1176 fillthis="hnormdeclB_";
1178 ((TH1F*)listout->FindObject(fillthis))->Fill(part->NormalizedDecayLength());
1181 fillthis="hdeclvB_";
1183 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[0]);
1185 fillthis="hnormdeclvB_";
1187 ((TH1F*)listout->FindObject(fillthis))->Fill(decl[1]);
1190 }//else (background)
1194 //____________________________________________________________________________
1196 void AliAnalysisTaskSED0Mass::FillMassHists(AliAODEvent* aod,AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC, AliRDHFCutsD0toKpi* cuts, TList *listout){
1198 // function used in UserExec to fill mass histograms:
1202 Double_t mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
1204 Int_t isSelected=cuts->IsSelected(part,AliRDHFCuts::kCandidate,aod); //selected
1206 //cout<<"is selected = "<<isSelected<<endl;
1208 //cout<<"check cuts = "<<endl;
1211 //cout<<"Not Selected"<<endl;
1212 //cout<<"Rejected because "<<cuts->GetWhy()<<endl;
1217 if(fDebug>2) cout<<"Candidate selected"<<endl;
1219 Double_t invmassD0 = part->InvMassD0(), invmassD0bar = part->InvMassD0bar();
1220 //printf("SELECTED\n");
1221 Int_t ptbin=cuts->PtBin(part->Pt());
1223 AliAODTrack *prong=(AliAODTrack*)part->GetDaughter(0);
1225 AliDebug(2,"No daughter found");
1229 if(prong->Charge()==1) {fTotPosPairs[ptbin]++;} else {fTotNegPairs[ptbin]++;}
1232 for(Int_t it=0;it<2;it++){
1233 //fill TOFsig-kaontime
1234 AliAODTrack* track=(AliAODTrack*)part->GetDaughter(it);
1235 AliAODPid *pid = track->GetDetPid();
1237 pid->GetIntegratedTimes(times);
1238 ((TH2F*)fChecks->FindObject("hTOFtimeKaonHyptimeAC"))->Fill(track->P(),pid->GetTOFsignal()-times[3]);
1241 //request on spd points to be addes
1242 if(/*nSPD==2 && */part->Pt() > 5. && (TMath::Abs(invmassD0-mPDG)<0.01 || TMath::Abs(invmassD0bar-mPDG)<0.01)){
1243 FILE *f=fopen("4display.txt","a");
1244 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());
1246 //printf("PrimVtx NContributors: %d \n Prongs Rel Angle: %f \n \n",ncont,relangle);
1251 TString fillthis="";
1252 Int_t pdgDgD0toKpi[2]={321,211};
1254 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)
1256 //count candidates selected by cuts
1258 //count true D0 selected by cuts
1259 if (fReadMC && labD0>=0) fNentries->Fill(2);
1260 //PostData(3,fNentries);
1262 if (isSelected==1 || isSelected==3) { //D0
1263 fillthis="histMass_";
1265 //cout<<"Filling "<<fillthis<<endl;
1267 //printf("Fill mass with D0");
1268 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1271 if(fArray==1) cout<<"LS signal ERROR"<<endl;
1273 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
1274 Int_t pdgD0 = partD0->GetPdgCode();
1275 //cout<<"pdg = "<<pdgD0<<endl;
1276 if (pdgD0==421){ //D0
1277 //cout<<"Fill S with D0"<<endl;
1278 fillthis="histSgn_";
1280 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1281 if(TMath::Abs(invmassD0 - mPDG) < 0.027){
1282 fillthis="histSgn27_";
1284 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1286 } else{ //it was a D0bar
1287 fillthis="histRfl_";
1289 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1291 } else {//background
1292 fillthis="histBkg_";
1294 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
1298 if (isSelected>1) { //D0bar
1299 fillthis="histMass_";
1301 //printf("Fill mass with D0bar");
1302 ((TH1F*)listout->FindObject(fillthis))->Fill(invmassD0bar);
1305 if(fArray==1) cout<<"LS signal ERROR"<<endl;
1306 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
1307 Int_t pdgD0 = partD0->GetPdgCode();
1308 //cout<<" pdg = "<<pdgD0<<endl;
1309 if (pdgD0==-421){ //D0bar
1310 fillthis="histSgn_";
1312 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
1313 if (TMath::Abs(invmassD0bar - mPDG) < 0.027){
1314 fillthis="histSgn27_";
1316 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
1321 fillthis="histRfl_";
1323 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
1325 } else {//background or LS
1326 fillthis="histBkg_";
1328 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
1335 //__________________________________________________________________________
1336 AliAODVertex* AliAnalysisTaskSED0Mass::GetPrimaryVtxSkipped(AliAODEvent *aodev,AliAODRecoDecayHF2Prong *d){
1337 //Calculate the primary vertex w/o the daughter tracks of the candidate
1340 Int_t nTrksToSkip=2;
1341 AliAODTrack *dgTrack = (AliAODTrack*)d->GetDaughter(0);
1343 AliDebug(2,"no daughter found!");
1346 skipped[0]=dgTrack->GetID();
1347 dgTrack = (AliAODTrack*)d->GetDaughter(1);
1349 AliDebug(2,"no daughter found!");
1352 skipped[1]=dgTrack->GetID();
1354 AliESDVertex *vertexESD=0x0;
1355 AliAODVertex *vertexAOD=0x0;
1356 AliVertexerTracks *vertexer = new AliVertexerTracks(aodev->GetMagneticField());
1359 vertexer->SetSkipTracks(nTrksToSkip,skipped);
1360 vertexer->SetMinClusters(4);
1361 vertexESD = (AliESDVertex*)vertexer->FindPrimaryVertex(aodev);
1362 if(!vertexESD) return vertexAOD;
1363 if(vertexESD->GetNContributors()<=0) {
1364 AliDebug(2,"vertexing failed");
1365 delete vertexESD; vertexESD=NULL;
1369 delete vertexer; vertexer=NULL;
1372 // convert to AliAODVertex
1373 Double_t pos[3],cov[6],chi2perNDF;
1374 vertexESD->GetXYZ(pos); // position
1375 vertexESD->GetCovMatrix(cov); //covariance matrix
1376 chi2perNDF = vertexESD->GetChi2toNDF();
1377 delete vertexESD; vertexESD=NULL;
1379 vertexAOD = new AliAODVertex(pos,cov,chi2perNDF);
1385 //________________________________________________________________________
1386 void AliAnalysisTaskSED0Mass::Terminate(Option_t */*option*/)
1388 // Terminate analysis
1390 if(fDebug > 1) printf("AnalysisTaskSED0Mass: Terminate() \n");
1393 fOutputMass = dynamic_cast<TList*> (GetOutputData(1));
1395 printf("ERROR: fOutputMass not available\n");
1398 fDistr = dynamic_cast<TList*> (GetOutputData(2));
1400 printf("ERROR: fDistr not available\n");
1404 fNentries = dynamic_cast<TH1F*>(GetOutputData(3));
1407 printf("ERROR: fNEntries not available\n");
1411 fChecks = dynamic_cast<TList*> (GetOutputData(4));
1413 printf("ERROR: fChecks not available\n");
1418 for(Int_t ipt=0;ipt<5;ipt++){ //change 5 in GetNPtBins when sure it is written and check
1422 fLsNormalization = 2.*TMath::Sqrt(fTotPosPairs[ipt]*fTotNegPairs[ipt]);
1425 if(fLsNormalization>1e-6) {
1427 TString massName="histMass_";
1429 ((TH1F*)fOutputMass->FindObject(massName))->Scale((1/fLsNormalization)*((TH1F*)fOutputMass->FindObject(massName))->GetEntries());
1434 fLsNormalization = 2.*TMath::Sqrt(fTotPosPairs[4]*fTotNegPairs[4]);
1436 if(fLsNormalization>1e-6) {
1438 TString nameDistr="hptB_";
1440 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1443 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1444 nameDistr="hcosthetastarB_";
1446 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1449 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1450 nameDistr="hd0d0B_";
1452 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1453 nameDistr="hcosthetapointB_";
1455 ((TH1F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH1F*)fDistr->FindObject(nameDistr))->GetEntries());
1456 nameDistr="hcosthpointd0d0B_";
1458 ((TH2F*)fDistr->FindObject(nameDistr))->Scale((1/fLsNormalization)*((TH2F*)fDistr->FindObject(nameDistr))->GetEntries());
1463 TString cvname,cstname;
1473 TCanvas *cMass=new TCanvas(cvname,cvname);
1475 ((TH1F*)fOutputMass->FindObject("histMass_3"))->Draw();
1477 TCanvas* cStat=new TCanvas(cstname,Form("Stat%s",fArray ? "LS" : "D0"));
1480 fNentries->Draw("htext0");
1482 // TCanvas *ccheck=new TCanvas(Form("cc%d",fArray),Form("cc%d",fArray));