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():
55 // Default constructor
58 //________________________________________________________________________
59 AliAnalysisTaskSED0Mass::AliAnalysisTaskSED0Mass(const char *name):
60 AliAnalysisTaskSE(name),
67 // Default constructor
69 // Output slot #1 writes into a TList container
70 DefineOutput(1,TList::Class()); //My private output
71 // Output slot #2 writes into a TList container
72 DefineOutput(2,TList::Class()); //My private output
73 // Output slot #3 writes into a TH1F container
74 DefineOutput(3,TH1F::Class()); //My private output
77 //________________________________________________________________________
78 AliAnalysisTaskSED0Mass::~AliAnalysisTaskSED0Mass()
102 //________________________________________________________________________
103 void AliAnalysisTaskSED0Mass::Init()
107 if(fDebug > 1) printf("AnalysisTaskSED0Mass::Init() \n");
109 gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF.C");
111 // 2 sets of dedidcated cuts -- defined in UserExec
112 fVHFtight = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
113 fVHFloose = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
118 //________________________________________________________________________
119 void AliAnalysisTaskSED0Mass::UserCreateOutputObjects()
122 // Create the output container
124 if(fDebug > 1) printf("AnalysisTaskSED0Mass::UserCreateOutputObjects() \n");
126 // Several histograms are more conveniently managed in a TList
127 fOutputtight = new TList();
128 fOutputtight->SetOwner();
129 fOutputtight->SetName("listtight");
131 fOutputloose = new TList();
132 fOutputloose->SetOwner();
133 fOutputloose->SetName("listloose");
137 TString nameMass=" ", nameSgn=" ", nameBkg=" ", nameRfl=" ";
139 for(Int_t i=0;i<nhist;i++){
140 nameMass="histMass_";
149 TH1F* tmpMt = new TH1F(nameMass.Data(),"D^{0} invariant mass; M [GeV]; Entries",200,1.765,1.965);
150 TH1F *tmpMl=(TH1F*)tmpMt->Clone();
154 TH1F* tmpSt = new TH1F(nameSgn.Data(), "D^{0} invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
155 TH1F *tmpSl=(TH1F*)tmpSt->Clone();
159 TH1F* tmpBt = new TH1F(nameBkg.Data(), "Background invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
160 TH1F *tmpBl=(TH1F*)tmpBt->Clone();
164 //Reflection: histo filled with D0 which pass the cut (also) as D0bar and with D0bar which pass (also) the cut as D0
165 TH1F* tmpRt = new TH1F(nameRfl.Data(), "Reflected signal invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
166 TH1F *tmpRl=(TH1F*)tmpRt->Clone();
169 // printf("Created histograms %s\t%s\t%s\t%s\n",tmpM->GetName(),tmpS->GetName(),tmpB->GetName(),tmpR->GetName());
171 fOutputtight->Add(tmpMt);
172 fOutputtight->Add(tmpSt);
173 fOutputtight->Add(tmpBt);
174 fOutputtight->Add(tmpRt);
176 fOutputloose->Add(tmpMl);
177 fOutputloose->Add(tmpSl);
178 fOutputloose->Add(tmpBl);
179 fOutputloose->Add(tmpRl);
184 //fOutputloose->ls();
185 //fOutputtight->ls();
187 fNentries=new TH1F("nentries", "Look at the number of entries! = number of AODs", 2,1.,2.);
192 //________________________________________________________________________
193 void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
195 // Execute analysis for current event:
196 // heavy flavor candidates association to MC truth
197 //cout<<"I'm in UserExec"<<endl;
198 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
200 // load D0->Kpi candidates
201 TClonesArray *inputArrayD0toKpi =
202 (TClonesArray*)aod->GetList()->FindObject("D0toKpi");
203 if(!inputArrayD0toKpi) {
204 printf("AliAnalysisTaskSECompareHFpt::UserExec: D0toKpi branch not found!\n");
208 // AOD primary vertex
209 AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
213 TClonesArray *mcArray =
214 (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
216 printf("AliAnalysisTaskSED0Mass::UserExec: MC particles branch not found!\n");
221 AliAODMCHeader *mcHeader =
222 (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
224 printf("AliAnalysisTaskSED0Mass::UserExec: MC header branch not found!\n");
229 //histogram filled with 1 for every AOD
231 PostData(3,fNentries);
232 // loop over D0->Kpi candidates
233 Int_t nInD0toKpi = inputArrayD0toKpi->GetEntriesFast();
234 if(fDebug>1) printf("Number of D0->Kpi: %d\n",nInD0toKpi);
236 for (Int_t iD0toKpi = 0; iD0toKpi < nInD0toKpi; iD0toKpi++) {
238 AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)inputArrayD0toKpi->UncheckedAt(iD0toKpi);
239 Bool_t unsetvtx=kFALSE;
240 if(!d->GetOwnPrimaryVtx()) {
241 d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
246 // printf(" |M-MD0| [GeV] < %f\n",fD0toKpiCuts[0]);
247 // printf(" dca [cm] < %f\n",fD0toKpiCuts[1]);
248 // printf(" cosThetaStar < %f\n",fD0toKpiCuts[2]);
249 // printf(" pTK [GeV/c] > %f\n",fD0toKpiCuts[3]);
250 // printf(" pTpi [GeV/c] > %f\n",fD0toKpiCuts[4]);
251 // printf(" |d0K| [cm] < %f\n",fD0toKpiCuts[5]);
252 // printf(" |d0pi| [cm] < %f\n",fD0toKpiCuts[6]);
253 // printf(" d0d0 [cm^2] < %f\n",fD0toKpiCuts[7]);
254 // printf(" cosThetaPoint > %f\n",fD0toKpiCuts[8]);
257 Double_t pt = d->Pt();
260 //cout<<"P_t = "<<pt<<endl;
261 if (pt>0. && pt<=1.) {
263 fVHFtight->SetD0toKpiCuts(0.7,0.04,0.8,0.5,0.5,0.05,0.05,-0.0003,0.7);
264 fVHFloose->SetD0toKpiCuts(0.7,0.04,0.8,0.5,0.5,0.05,0.05,-0.00025,0.7);
265 // fVHFtight->SetD0toKpiCuts(0.7,0.04,0.8,0.5,0.5,0.05,0.05,-0.0002,0.7);
266 // fVHFloose->SetD0toKpiCuts(0.7,0.04,0.8,0.5,0.5,1,1,-0.00015,0.5);
267 //printf("I'm in the bin %d\n",ptbin);
271 if(pt>1. && pt<=3.) {
273 fVHFtight->SetD0toKpiCuts(0.7,0.02,0.8,0.7,0.7,0.05,0.05,-0.0003,0.9);
274 fVHFloose->SetD0toKpiCuts(0.7,0.02,0.8,0.7,0.7,1,1,-0.00025,0.8);
275 //printf("I'm in the bin %d\n",ptbin);
280 fVHFtight->SetD0toKpiCuts(0.7,0.015,0.8,0.7,0.7,0.05,0.05,-0.0002,0.9);
281 fVHFloose->SetD0toKpiCuts(0.7,0.02,0.8,0.7,0.7,0.05,0.05,-0.00015,0.8);
282 //printf("I'm in the bin %d\n",ptbin);
286 fVHFtight->SetD0toKpiCuts(0.7,0.015,0.8,0.7,0.7,0.05,0.05,-0.0002,0.95);
287 fVHFloose->SetD0toKpiCuts(0.7,0.02,0.8,0.7,0.7,0.05,0.05,-0.00015,0.9);
290 //printf("I'm in the bin %d\n",ptbin);
292 //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
294 FillHists(ptbin,d,mcArray,fVHFtight,fOutputtight);
295 FillHists(ptbin,d,mcArray,fVHFloose,fOutputloose);
296 if(unsetvtx) d->UnsetOwnPrimaryVtx();
303 PostData(1,fOutputtight);
304 PostData(2,fOutputloose);
308 //____________________________________________________________________________*
309 void AliAnalysisTaskSED0Mass::FillHists(Int_t ptbin, AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC, AliAnalysisVertexingHF *vhf, TList *listout){
311 // function used in UserExec:
313 Int_t okD0=0,okD0bar=0;
315 if(part->SelectD0(vhf->GetD0toKpiCuts(),okD0,okD0bar)) {//selected
316 Double_t invmassD0 = part->InvMassD0(), invmassD0bar = part->InvMassD0bar();
317 //printf("SELECTED\n");
318 Int_t labD0 = part->MatchToMC(421,arrMC); //return MC particle label if the array corresponds to a D0, -1 if not (cf. AliAODRecoDecay.cxx)
319 //printf("labD0 %d",labD0);
324 fillthis="histMass_";
326 //cout<<"Filling "<<fillthis<<endl;
328 //printf("Fill mass with D0");
329 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
331 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
332 Int_t pdgD0 = partD0->GetPdgCode();
333 //cout<<"pdg = "<<pdgD0<<endl;
334 if (pdgD0==421){ //D0
335 //cout<<"Fill S with D0"<<endl;
338 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
340 } else{ //it was a D0bar
343 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
348 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
352 fillthis="histMass_";
354 //printf("Fill mass with D0bar");
355 ((TH1F*)listout->FindObject(fillthis))->Fill(invmassD0bar);
358 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
359 Int_t pdgD0 = partD0->GetPdgCode();
360 //cout<<" pdg = "<<pdgD0<<endl;
361 if (pdgD0==-421){ //D0bar
364 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
369 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
374 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
379 } //else cout<<"NOT SELECTED"<<endl;
382 //________________________________________________________________________
383 void AliAnalysisTaskSED0Mass::Terminate(Option_t */*option*/)
385 // Terminate analysis
387 if(fDebug > 1) printf("AnalysisTaskSED0Mass: Terminate() \n");
389 fOutputtight = dynamic_cast<TList*> (GetOutputData(1));
391 printf("ERROR: fOutput not available\n");
394 fOutputloose = dynamic_cast<TList*> (GetOutputData(2));
396 printf("ERROR: fOutput not available\n");