1 /**************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 /////////////////////////////////////////////////////////////
18 // AliAnalysisTaskSE for the extraction of signal(e.g D+) of heavy flavor
19 // decay candidates with the MC truth.
21 /////////////////////////////////////////////////////////////
23 #include <TClonesArray.h>
27 #include "AliAODEvent.h"
28 #include "AliAODVertex.h"
29 #include "AliAODTrack.h"
30 #include "AliAODMCHeader.h"
31 #include "AliAODMCParticle.h"
32 #include "AliAODRecoDecayHF3Prong.h"
33 #include "AliAnalysisVertexingHF.h"
34 #include "AliAnalysisTaskSE.h"
35 #include "AliAnalysisTaskSEDplus.h"
37 ClassImp(AliAnalysisTaskSEDplus)
40 //________________________________________________________________________
41 AliAnalysisTaskSEDplus::AliAnalysisTaskSEDplus():
51 // Default constructor
54 //________________________________________________________________________
55 AliAnalysisTaskSEDplus::AliAnalysisTaskSEDplus(const char *name):
56 AliAnalysisTaskSE(name),
65 // Default constructor
67 // Output slot #1 writes into a TList container
68 DefineOutput(1,TList::Class()); //My private output
71 //________________________________________________________________________
72 AliAnalysisTaskSEDplus::~AliAnalysisTaskSEDplus()
85 //________________________________________________________________________
86 void AliAnalysisTaskSEDplus::Init()
90 if(fDebug > 1) printf("AnalysisTaskSEDplus::Init() \n");
92 gROOT->LoadMacro("ConfigVertexingHF.C");
94 fVHF = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
100 //________________________________________________________________________
101 void AliAnalysisTaskSEDplus::UserCreateOutputObjects()
103 // Create the output container
105 if(fDebug > 1) printf("AnalysisTaskSEDplus::UserCreateOutputObjects() \n");
107 // Several histograms are more conveniently managed in a TList
108 fOutput = new TList();
111 fHistMass = new TH1F("fHistMass", "D^{+} invariant mass; M [GeV]; Entries",100,1.765,1.965);
112 fHistSignal = new TH1F("fHistSignal", "D^{+} invariant mass - MC; M [GeV]; Entries",100,1.765,1.965);
113 fHistBackground =new TH1F("fHistBackground", "Background invariant mass - MC; M [GeV]; Entries",100,1.765,1.965);
119 fHistSignal->Sumw2();
120 fHistBackground->Sumw2();
123 //fHistMass->SetMinimum(0);
124 //fHistSignal->SetMinimum(0);
125 //fHistBackground->SetMinimum(0);
126 fOutput->Add(fHistMass);
127 fOutput->Add(fHistSignal);
128 fOutput->Add(fHistBackground);
131 fNtupleDplus = new TNtuple("fNtupleDplus","D +","pdg:Px:Py:Pz:Ptpi:Ptpi2:PtK:PtRec:PtTrue:PointingAngle:DecLeng:VxTrue:VxRec:InvMass:sigvert");
132 fNtupleDplusbackg = new TNtuple("fNtupleDplusbackg","D + backg","Ptpibkg:Ptpi2bkg:PtKbkg:PtRecbkg:PointingAnglebkg:DLbkg:VxRecbkg:InvMassbkg:sigvertbkg");
134 fOutput->Add(fNtupleDplus);
135 fOutput->Add(fNtupleDplusbackg);
140 //________________________________________________________________________
141 void AliAnalysisTaskSEDplus::UserExec(Option_t */*option*/)
143 // Execute analysis for current event:
144 // heavy flavor candidates association to MC truth
148 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
150 // load Dplus->Kpipi candidates
151 TClonesArray *array3Prong =
152 (TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
154 printf("AliAnalysisTaskSEDplus::UserExec: Charm3Prong branch not found!\n");
158 // AOD primary vertex
159 AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
163 TClonesArray *arrayMC =
164 (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
166 printf("AliAnalysisTaskSEDplus::UserExec: MC particles branch not found!\n");
171 AliAODMCHeader *mcHeader =
172 (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
174 printf("AliAnalysisTaskSEDplus::UserExec: MC header branch not found!\n");
177 Int_t n3Prong = array3Prong->GetEntriesFast();
178 printf("Number of D+->Kpipi: %d\n",n3Prong);
181 for (Int_t i3Prong = 0; i3Prong < n3Prong; i3Prong++) {
182 AliAODRecoDecayHF3Prong *d = (AliAODRecoDecayHF3Prong*)array3Prong->UncheckedAt(i3Prong);
185 Bool_t unsetvtx=kFALSE;
186 if(!d->GetOwnPrimaryVtx()){
187 d->SetOwnPrimaryVtx(vtx1);
190 if(d->SelectDplus(fVHF->GetDplusCuts())) {
193 Int_t labDp = d->MatchToMC(411,arrayMC);
196 AliAODMCParticle *partDp = (AliAODMCParticle*)arrayMC->At(labDp);
197 Int_t pdgDp = TMath::Abs(partDp->GetPdgCode());
200 fHistSignal->Fill(d->InvMassDplus());
201 fHistMass->Fill(d->InvMassDplus());
203 // Post the data already here
206 fNtupleDplus->Fill(pdgDp,partDp->Px()-d->Px(),partDp->Py()-d->Py(),partDp->Pz()-d->Pz(),d->PtProng(0),d->PtProng(2),d->PtProng(1),d->Pt(),partDp->Pt(),d->CosPointingAngle(),d->DecayLength(),partDp->Xv(),d->Xv(),d->InvMassDplus(),d->GetSigmaVert());
210 fHistBackground->Fill(d->InvMassDplus());
211 fNtupleDplusbackg->Fill(d->PtProng(0),d->PtProng(2),d->PtProng(1),d->Pt(),d->CosPointingAngle(),d->DecayLength(),d->Xv(),d->InvMassDplus(),d->GetSigmaVert());
213 fHistMass->Fill(d->InvMassDplus());
221 if(unsetvtx) d->UnsetOwnPrimaryVtx();
224 // end loop on D+->Kpipi
230 //________________________________________________________________________
231 void AliAnalysisTaskSEDplus::Terminate(Option_t */*option*/)
233 // Terminate analysis
235 if(fDebug > 1) printf("AnalysisTaskSEDplus: Terminate() \n");
237 fOutput = dynamic_cast<TList*> (GetOutputData(1));
239 printf("ERROR: fOutput not available\n");
243 fNtupleDplus = dynamic_cast<TNtuple*>(fOutput->FindObject("fNtupleDplus"));
244 fHistMass = dynamic_cast<TH1F*>(fOutput->FindObject("fHistMass"));
245 fHistSignal = dynamic_cast<TH1F*>(fOutput->FindObject("fHistSignal"));
246 fHistBackground = dynamic_cast<TH1F*>(fOutput->FindObject("fHistBackground"));
247 fNtupleDplusbackg = dynamic_cast<TNtuple*>(fOutput->FindObject("fNtupleDplusbackg"));