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.
21 // Authors: A.Dainese, andrea.dainese@lnl.infn.it
22 // and Chiara Bianchin, chiara.bianchin@pd.infn.it
23 /////////////////////////////////////////////////////////////
25 #include <Riostream.h>
26 #include <TClonesArray.h>
32 #include "AliAODEvent.h"
33 #include "AliAODVertex.h"
34 #include "AliAODTrack.h"
35 #include "AliAODMCHeader.h"
36 #include "AliAODMCParticle.h"
37 #include "AliAODRecoDecayHF2Prong.h"
38 #include "AliAODRecoCascadeHF.h"
39 #include "AliAnalysisVertexingHF.h"
40 #include "AliAnalysisTaskSE.h"
41 #include "AliAnalysisTaskSED0Mass.h"
43 ClassImp(AliAnalysisTaskSED0Mass)
46 //________________________________________________________________________
47 AliAnalysisTaskSED0Mass::AliAnalysisTaskSED0Mass():
56 // Default constructor
59 //________________________________________________________________________
60 AliAnalysisTaskSED0Mass::AliAnalysisTaskSED0Mass(const char *name):
61 AliAnalysisTaskSE(name),
69 // Default constructor
71 // Output slot #1 writes into a TList container
72 DefineOutput(1,TList::Class()); //My private output
75 //________________________________________________________________________
76 AliAnalysisTaskSED0Mass::~AliAnalysisTaskSED0Mass()
106 //________________________________________________________________________
107 void AliAnalysisTaskSED0Mass::Init()
111 if(fDebug > 1) printf("AnalysisTaskSED0Mass::Init() \n");
113 gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF.C");
115 fVHF = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
116 // set dedidcated cuts
117 fVHF->SetD0toKpiCuts(0.7,0.03,0.8,0.06,0.06,0.05,0.05,-0.0002,0.6); //2.p-p vertex reconstructed
123 //________________________________________________________________________
124 void AliAnalysisTaskSED0Mass::UserCreateOutputObjects()
127 // Create the output container
129 if(fDebug > 1) printf("AnalysisTaskSED0Mass::UserCreateOutputObjects() \n");
131 // Several histograms are more conveniently managed in a TList
132 fOutput = new TList();
136 fhistMass=new TClonesArray("TH1F",nhist);
137 fhistMass->SetName("fhistMass");
138 fhistSgn =new TClonesArray("TH1F",nhist);
139 fhistSgn->SetName("fhistSgn");
140 fhistBkg =new TClonesArray("TH1F",nhist);
141 fhistBkg->SetName("fhistBkg");
143 TString nameMass, nameSgn, nameBkg;
145 for(Int_t i=0;i<nhist;i++){
146 nameMass="fhistMass_";
148 cout<<"Creating TH1F with name "<<nameMass<<endl;
149 new ((*fhistMass)[i]) TH1F(nameMass.Data(),"D^{0} invariant mass; M [GeV]; Entries",200,1.765,1.965);
152 new ((*fhistSgn)[i]) TH1F(nameSgn.Data(), "D^{0} invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
155 new ((*fhistBkg)[i]) TH1F(nameBkg.Data(), "Background invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
156 printf("Created histograms %s\t%s\t%s\n",fhistMass->UncheckedAt(i)->GetName(),fhistSgn->UncheckedAt(i)->GetName(),fhistBkg->UncheckedAt(i)->GetName());
159 fOutput->Add(fhistMass);
160 fOutput->Add(fhistSgn);
161 fOutput->Add(fhistBkg);
166 //________________________________________________________________________
167 void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
169 // Execute analysis for current event:
170 // heavy flavor candidates association to MC truth
172 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
174 // load D0->Kpi candidates
175 TClonesArray *inputArrayD0toKpi =
176 (TClonesArray*)aod->GetList()->FindObject("D0toKpi");
177 if(!inputArrayD0toKpi) {
178 printf("AliAnalysisTaskSECompareHFpt::UserExec: D0toKpi branch not found!\n");
182 // AOD primary vertex
183 AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
187 TClonesArray *mcArray =
188 (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
190 printf("AliAnalysisTaskSED0Mass::UserExec: MC particles branch not found!\n");
195 AliAODMCHeader *mcHeader =
196 (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
198 printf("AliAnalysisTaskSED0Mass::UserExec: MC header branch not found!\n");
203 // loop over D0->Kpi candidates
204 Int_t nInD0toKpi = inputArrayD0toKpi->GetEntriesFast();
205 printf("Number of D0->Kpi: %d\n",nInD0toKpi);
207 for (Int_t iD0toKpi = 0; iD0toKpi < nInD0toKpi; iD0toKpi++) {
209 AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)inputArrayD0toKpi->UncheckedAt(iD0toKpi);
210 Bool_t unsetvtx=kFALSE;
211 if(!d->GetOwnPrimaryVtx()) {
212 d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
216 // cout<<"Cuts applied: ";
217 // Double_t *cutsapplied=(Double_t*)fVHF->GetD0toKpiCuts();
218 // for (Int_t i=0;i<9;i++){
219 // printf(cutsapplied[i]\t);
224 Double_t pt = d->Pt();
227 //cout<<"P_t = "<<pt<<endl;
228 if (pt>0. && pt<=1.) {
230 //printf("I'm in the bin %d\n",ptbin);
233 if(pt>1. && pt<=3.) {
235 //printf("I'm in the bin %d\n",ptbin);
239 //printf("I'm in the bin %d\n",ptbin);
243 FillHists(ptbin,d,mcArray);
245 if(unsetvtx) d->UnsetOwnPrimaryVtx();
257 //____________________________________________________________________________*
258 void AliAnalysisTaskSED0Mass::FillHists(Int_t ptbin, AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC){
260 // function used in UserExec:
262 Int_t okD0=0,okD0bar=0;
264 if(part->SelectD0(fVHF->GetD0toKpiCuts(),okD0,okD0bar)) {//selected
265 Double_t invmassD0 = part->InvMassD0(), invmassD0bar = part->InvMassD0bar();
266 //printf("SELECTED\n");
267 Int_t labD0 = part->MatchToMC(421,arrMC); //return MC particle label if the array corresponds to a D0, -1 if not (cf. AliAODRecoDecay.cxx)
268 //printf("labD0 %d",labD0);
272 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
274 Int_t pdgD0 = partD0->GetPdgCode();
276 //printf(" pdgD0 %d\n",pdgD0);
278 if (pdgD0==421){ //D0
279 //cout<<"Fill S with D0"<<endl;
280 ((TH1F*)(fhistSgn->UncheckedAt(ptbin-1)))->Fill(invmassD0);
283 //printf("Fill S with D0bar");
284 ((TH1F*)(fhistSgn->UncheckedAt(ptbin-1)))->Fill(invmassD0bar);
289 //printf("Fill background");
290 ((TH1F*)(fhistBkg->UncheckedAt(ptbin-1)))->Fill(invmassD0);
291 ((TH1F*)(fhistBkg->UncheckedAt(ptbin-1)))->Fill(invmassD0bar);
294 //no MC info, just cut selection
296 //printf("Fill mass with D0");
297 ((TH1F*)(fhistMass->UncheckedAt(ptbin-1)))->Fill(invmassD0);
301 ((TH1F*)fhistMass->UncheckedAt(ptbin-1))->Fill(invmassD0bar);
302 //printf("Fill mass with D0bar");
305 } //else cout<<"NOT SELECTED"<<endl;
308 //________________________________________________________________________
309 void AliAnalysisTaskSED0Mass::Terminate(Option_t */*option*/)
311 // Terminate analysis
313 if(fDebug > 1) printf("AnalysisTaskSED0Mass: Terminate() \n");
315 fOutput = dynamic_cast<TList*> (GetOutputData(1));
317 printf("ERROR: fOutput not available\n");
322 fhistMass = dynamic_cast<TClonesArray*>(fOutput->FindObject("fhistMass"));
323 fhistSgn = dynamic_cast<TClonesArray*>(fOutput->FindObject("fhistSgn"));
324 fhistBkg = dynamic_cast<TClonesArray*>(fOutput->FindObject("fhistBkg"));