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.
20 // Author: Renu Bala, bala@to.infn.it
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
69 // Output slot #2 writes into a TNtuple container
70 DefineOutput(2,TNtuple::Class()); //My private output
71 // Output slot #3 writes into a TNtuple container
72 DefineOutput(3,TNtuple::Class()); //My private output
75 //________________________________________________________________________
76 AliAnalysisTaskSEDplus::~AliAnalysisTaskSEDplus()
89 //________________________________________________________________________
90 void AliAnalysisTaskSEDplus::Init()
94 if(fDebug > 1) printf("AnalysisTaskSEDplus::Init() \n");
96 gROOT->LoadMacro("ConfigVertexingHF.C");
98 fVHF = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
104 //________________________________________________________________________
105 void AliAnalysisTaskSEDplus::UserCreateOutputObjects()
107 // Create the output container
109 if(fDebug > 1) printf("AnalysisTaskSEDplus::UserCreateOutputObjects() \n");
111 // Several histograms are more conveniently managed in a TList
112 fOutput = new TList();
115 fHistMass = new TH1F("fHistMass", "D^{+} invariant mass; M [GeV]; Entries",100,1.765,1.965);
116 fHistSignal = new TH1F("fHistSignal", "D^{+} invariant mass - MC; M [GeV]; Entries",100,1.765,1.965);
117 fHistBackground =new TH1F("fHistBackground", "Background invariant mass - MC; M [GeV]; Entries",100,1.765,1.965);
123 fHistSignal->Sumw2();
124 fHistBackground->Sumw2();
127 //fHistMass->SetMinimum(0);
128 //fHistSignal->SetMinimum(0);
129 //fHistBackground->SetMinimum(0);
130 fOutput->Add(fHistMass);
131 fOutput->Add(fHistSignal);
132 fOutput->Add(fHistBackground);
134 OpenFile(2); // 2 is the slot number of the ntuple
135 fNtupleDplus = new TNtuple("fNtupleDplus","D +","pdg:Px:Py:Pz:Ptpi:PtK:Ptpi2:PtRec:PtTrue:PointingAngle:DecLeng:VxTrue:VxRec:VyRec,VzRec,InvMass:sigvert:d0Pi:d0K:d0Pi2");
136 OpenFile(3); // 3 is the slot number of the ntuple
137 fNtupleDplusbackg = new TNtuple("fNtupleDplusbackg","D + backg","Ptpibkg:Ptkbkg:Ptpi2bkg:PtRecbkg:PointingAnglebkg:DLbkg:VxRecbkg:VyRecbkg:VzRecbkg:InvMassbkg:sigvertbkg:d0Pibkg:d0Kbkg:d0Pi2bkg");
142 //________________________________________________________________________
143 void AliAnalysisTaskSEDplus::UserExec(Option_t */*option*/)
145 // Execute analysis for current event:
146 // heavy flavor candidates association to MC truth
150 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
152 // load Dplus->Kpipi candidates
153 TClonesArray *array3Prong =
154 (TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
156 printf("AliAnalysisTaskSEDplus::UserExec: Charm3Prong branch not found!\n");
160 // AOD primary vertex
161 AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
165 TClonesArray *arrayMC =
166 (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
168 printf("AliAnalysisTaskSEDplus::UserExec: MC particles branch not found!\n");
173 AliAODMCHeader *mcHeader =
174 (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
176 printf("AliAnalysisTaskSEDplus::UserExec: MC header branch not found!\n");
179 Int_t n3Prong = array3Prong->GetEntriesFast();
180 if(fDebug>1) printf("Number of D+->Kpipi: %d\n",n3Prong);
183 for (Int_t i3Prong = 0; i3Prong < n3Prong; i3Prong++) {
184 AliAODRecoDecayHF3Prong *d = (AliAODRecoDecayHF3Prong*)array3Prong->UncheckedAt(i3Prong);
187 Bool_t unsetvtx=kFALSE;
188 if(!d->GetOwnPrimaryVtx()){
189 d->SetOwnPrimaryVtx(vtx1);
192 if(d->SelectDplus(fVHF->GetDplusCuts())) {
195 Int_t labDp = d->MatchToMC(411,arrayMC);
198 AliAODMCParticle *partDp = (AliAODMCParticle*)arrayMC->At(labDp);
199 Int_t pdgDp = TMath::Abs(partDp->GetPdgCode());
202 fHistSignal->Fill(d->InvMassDplus());
203 fHistMass->Fill(d->InvMassDplus());
205 // Post the data already here
208 AliAODMCParticle *dg0 = (AliAODMCParticle*)arrayMC->At(partDp->GetDaughter(0));
212 tmp[1]=partDp->Px()-d->Px();
213 tmp[2]=partDp->Py()-d->Py();
214 tmp[3]=partDp->Pz()-d->Pz();
215 tmp[4]=d->PtProng(0);
216 tmp[5]=d->PtProng(1);
217 tmp[6]=d->PtProng(2);
220 tmp[9]=d->CosPointingAngle();
221 tmp[10]=d->DecayLength();
226 tmp[15]=d->InvMassDplus();
227 tmp[16]=d->GetSigmaVert();
228 tmp[17]=d->Getd0Prong(0);
229 tmp[18]=d->Getd0Prong(1);
230 tmp[19]=d->Getd0Prong(2);
233 fNtupleDplus->Fill(tmp);
234 PostData(2,fNtupleDplus);
239 tmpbkg[0]=d->PtProng(0);
240 tmpbkg[1]=d->PtProng(1);
241 tmpbkg[2]=d->PtProng(2);
243 tmpbkg[4]=d->CosPointingAngle();
244 tmpbkg[5]=d->DecayLength();
248 tmpbkg[9]=d->InvMassDplus();
249 tmpbkg[10]=d->GetSigmaVert();
250 tmpbkg[11]=d->Getd0Prong(0);
251 tmpbkg[12]=d->Getd0Prong(1);
252 tmpbkg[13]=d->Getd0Prong(2);
254 fHistBackground->Fill(d->InvMassDplus());
255 fNtupleDplusbackg->Fill(tmpbkg);
256 PostData(3,fNtupleDplusbackg);
257 fHistMass->Fill(d->InvMassDplus());
263 if(unsetvtx) d->UnsetOwnPrimaryVtx();
266 // end loop on D+->Kpipi
272 //________________________________________________________________________
273 void AliAnalysisTaskSEDplus::Terminate(Option_t */*option*/)
275 // Terminate analysis
277 if(fDebug > 1) printf("AnalysisTaskSEDplus: Terminate() \n");
279 fOutput = dynamic_cast<TList*> (GetOutputData(1));
281 printf("ERROR: fOutput not available\n");
285 fHistMass = dynamic_cast<TH1F*>(fOutput->FindObject("fHistMass"));
286 fHistSignal = dynamic_cast<TH1F*>(fOutput->FindObject("fHistSignal"));
287 fHistBackground = dynamic_cast<TH1F*>(fOutput->FindObject("fHistBackground"));
288 fNtupleDplus = dynamic_cast<TNtuple*>(GetOutputData(2));
289 fNtupleDplusbackg = dynamic_cast<TNtuple*>(GetOutputData(3));