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 selection of heavy flavor
19 // decay candidates and creation a stand-alone AOD.
21 // Author: A.Dainese, andrea.dainese@lnl.infn.it
22 /////////////////////////////////////////////////////////////
24 #include <TClonesArray.h>
26 #include "AliAODEvent.h"
27 #include "AliAODVertex.h"
28 #include "AliAODTrack.h"
29 #include "AliAODRecoDecayHF2Prong.h"
30 #include "AliAnalysisTaskSE.h"
31 #include "AliAnalysisTaskSESelectHF.h"
33 ClassImp(AliAnalysisTaskSESelectHF)
36 //________________________________________________________________________
37 AliAnalysisTaskSESelectHF::AliAnalysisTaskSESelectHF():
42 // Default constructor
46 //________________________________________________________________________
47 AliAnalysisTaskSESelectHF::AliAnalysisTaskSESelectHF(const char *name):
48 AliAnalysisTaskSE(name),
52 // Default constructor
56 //________________________________________________________________________
57 AliAnalysisTaskSESelectHF::~AliAnalysisTaskSESelectHF()
62 //________________________________________________________________________
63 void AliAnalysisTaskSESelectHF::Init()
67 if(fDebug > 1) printf("AnalysisTaskSESelectHF::Init() \n");
72 //________________________________________________________________________
73 void AliAnalysisTaskSESelectHF::UserCreateOutputObjects()
75 // Create the output container
77 if(fDebug > 1) printf("AnalysisTaskSESelectHF::UserCreateOutputObjects() \n");
79 fVerticesHFTClArr = new TClonesArray("AliAODVertex", 0);
80 fVerticesHFTClArr->SetName("VerticesHF");
81 AddAODBranch("TClonesArray", fVerticesHFTClArr);
83 fD0toKpiTClArr = new TClonesArray("AliAODRecoDecayHF2Prong", 0);
84 fD0toKpiTClArr->SetName("D0toKpi");
85 AddAODBranch("TClonesArray", fD0toKpiTClArr);
90 //________________________________________________________________________
91 void AliAnalysisTaskSESelectHF::UserExec(Option_t */*option*/)
93 // Execute analysis for current event:
94 // heavy flavor candidates selection and histograms
96 AliAODEvent *aodIn = dynamic_cast<AliAODEvent*> (InputEvent());
98 // load D0->Kpi candidates
99 TClonesArray *inputArrayD0toKpi =
100 (TClonesArray*)aodIn->GetList()->FindObject("D0toKpi");
103 aodIn->GetHeader()->Print();
106 AliAODVertex *vtx1 = (AliAODVertex*)aodIn->GetPrimaryVertex();
109 // make trkIDtoEntry register (temporary)
110 Int_t trkIDtoEntry[100000];
111 for(Int_t it=0;it<aodIn->GetNumberOfTracks();it++) {
112 AliAODTrack *track = aodIn->GetTrack(it);
113 trkIDtoEntry[track->GetID()]=it;
116 Int_t iOutVerticesHF=0,iOutD0toKpi=0;
117 fVerticesHFTClArr->Delete();
118 iOutVerticesHF = fVerticesHFTClArr->GetEntriesFast();
119 TClonesArray &verticesHFRef = *fVerticesHFTClArr;
120 fD0toKpiTClArr->Delete();
121 iOutD0toKpi = fD0toKpiTClArr->GetEntriesFast();
122 TClonesArray &aodD0toKpiRef = *fD0toKpiTClArr;
125 // loop over D0->Kpi candidates
126 Int_t nInD0toKpi = inputArrayD0toKpi->GetEntriesFast();
127 printf("Number of D0->Kpi: %d\n",nInD0toKpi);
129 for (Int_t iD0toKpi = 0; iD0toKpi < nInD0toKpi; iD0toKpi++) {
130 AliAODRecoDecayHF2Prong *dIn = (AliAODRecoDecayHF2Prong*)inputArrayD0toKpi->UncheckedAt(iD0toKpi);
131 Bool_t unsetvtx=kFALSE;
132 if(!dIn->GetOwnPrimaryVtx()) {
133 dIn->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
136 Int_t okD0=0,okD0bar=0;
137 if(dIn->SelectD0(fD0toKpiCuts,okD0,okD0bar)) {
138 // get daughter AOD tracks
139 AliAODTrack *trk0=aodIn->GetTrack(trkIDtoEntry[dIn->GetProngID(0)]);
140 AliAODTrack *trk1=aodIn->GetTrack(trkIDtoEntry[dIn->GetProngID(1)]);
141 // this will be replaced by
142 //AliAODTrack *trk0 = (AliAODTrack*)(dIn->GetSecondaryVtx()->GetDaughter(0));
143 printf("pt of positive track: %f\n",trk0->Pt());
144 printf("pt of negative track: %f\n",trk1->Pt());
147 // clone candidate for output AOD
148 AliAODVertex *v = new(verticesHFRef[iOutVerticesHF++])
149 AliAODVertex(*(dIn->GetSecondaryVtx()));
150 Double_t px[2]={dIn->PxProng(0),dIn->PxProng(1)};
151 Double_t py[2]={dIn->PyProng(0),dIn->PyProng(1)};
152 Double_t pz[2]={dIn->PzProng(0),dIn->PzProng(1)};
153 Double_t d0[2]={dIn->Getd0Prong(0),dIn->Getd0Prong(1)};
154 Double_t d0err[2]={dIn->Getd0errProng(0),dIn->Getd0errProng(1)};
155 AliAODRecoDecayHF2Prong *dOut=new(aodD0toKpiRef[iOutD0toKpi++])
156 AliAODRecoDecayHF2Prong(v,px,py,pz,d0,d0err,dIn->GetDCA());
157 dOut->SetOwnPrimaryVtx(dIn->GetOwnPrimaryVtx());
159 if(unsetvtx) dIn->UnsetOwnPrimaryVtx();
160 } // end loop on D0->Kpi
166 //________________________________________________________________________
167 void AliAnalysisTaskSESelectHF::Terminate(Option_t */*option*/)
169 // Terminate analysis
171 if(fDebug > 1) printf("AnalysisTaskSESelectHF: Terminate() \n");
174 //________________________________________________________________________
175 void AliAnalysisTaskSESelectHF::SetD0toKpiCuts(Double_t cut0,Double_t cut1,
176 Double_t cut2,Double_t cut3,Double_t cut4,
177 Double_t cut5,Double_t cut6,
178 Double_t cut7,Double_t cut8)
180 // Set the cuts for D0 selection
181 // cuts[0] = inv. mass half width [GeV]
182 // cuts[1] = dca [cm]
183 // cuts[2] = cosThetaStar
184 // cuts[3] = pTK [GeV/c]
185 // cuts[4] = pTPi [GeV/c]
186 // cuts[5] = d0K [cm] upper limit!
187 // cuts[6] = d0Pi [cm] upper limit!
188 // cuts[7] = d0d0 [cm^2]
189 // cuts[8] = cosThetaPoint
191 fD0toKpiCuts[0] = cut0;
192 fD0toKpiCuts[1] = cut1;
193 fD0toKpiCuts[2] = cut2;
194 fD0toKpiCuts[3] = cut3;
195 fD0toKpiCuts[4] = cut4;
196 fD0toKpiCuts[5] = cut5;
197 fD0toKpiCuts[6] = cut6;
198 fD0toKpiCuts[7] = cut7;
199 fD0toKpiCuts[8] = cut8;
204 //________________________________________________________________________
205 void AliAnalysisTaskSESelectHF::SetD0toKpiCuts(const Double_t cuts[9])
207 // Set the cuts for D0 selection
208 // cuts[0] = inv. mass half width [GeV]
209 // cuts[1] = dca [cm]
210 // cuts[2] = cosThetaStar
211 // cuts[3] = pTK [GeV/c]
212 // cuts[4] = pTPi [GeV/c]
213 // cuts[5] = d0K [cm] upper limit!
214 // cuts[6] = d0Pi [cm] upper limit!
215 // cuts[7] = d0d0 [cm^2]
216 // cuts[8] = cosThetaPoint
218 for(Int_t i=0; i<9; i++) fD0toKpiCuts[i] = cuts[i];