load libCORRFW
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliAnalysisTaskSESelectHF.cxx
CommitLineData
0de9de87 1/**************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/////////////////////////////////////////////////////////////
17//
18// AliAnalysisTaskSE for the selection of heavy flavor
19// decay candidates and creation a stand-alone AOD.
20//
21// Author: A.Dainese, andrea.dainese@lnl.infn.it
22/////////////////////////////////////////////////////////////
23
24#include <TClonesArray.h>
25
26#include "AliAODEvent.h"
27#include "AliAODVertex.h"
28#include "AliAODTrack.h"
29#include "AliAODRecoDecayHF2Prong.h"
30#include "AliAnalysisTaskSE.h"
31#include "AliAnalysisTaskSESelectHF.h"
32
33ClassImp(AliAnalysisTaskSESelectHF)
34
35
36//________________________________________________________________________
37AliAnalysisTaskSESelectHF::AliAnalysisTaskSESelectHF():
38AliAnalysisTaskSE(),
39fVerticesHFTClArr(0),
40fD0toKpiTClArr(0)
41{
42 // Default constructor
43 SetD0toKpiCuts();
44}
45
46//________________________________________________________________________
47AliAnalysisTaskSESelectHF::AliAnalysisTaskSESelectHF(const char *name):
48AliAnalysisTaskSE(name),
49fVerticesHFTClArr(0),
50fD0toKpiTClArr(0)
51{
52 // Default constructor
53 SetD0toKpiCuts();
54}
55
56//________________________________________________________________________
57AliAnalysisTaskSESelectHF::~AliAnalysisTaskSESelectHF()
58{
59 // Destructor
60}
61
62//________________________________________________________________________
63void AliAnalysisTaskSESelectHF::Init()
64{
65 // Initialization
66
67 if(fDebug > 1) printf("AnalysisTaskSESelectHF::Init() \n");
68
69 return;
70}
71
72//________________________________________________________________________
73void AliAnalysisTaskSESelectHF::UserCreateOutputObjects()
74{
75 // Create the output container
76 //
77 if(fDebug > 1) printf("AnalysisTaskSESelectHF::UserCreateOutputObjects() \n");
78
79 fVerticesHFTClArr = new TClonesArray("AliAODVertex", 0);
80 fVerticesHFTClArr->SetName("VerticesHF");
080ac6fd 81 AddAODBranch("TClonesArray", &fVerticesHFTClArr);
0de9de87 82
83 fD0toKpiTClArr = new TClonesArray("AliAODRecoDecayHF2Prong", 0);
84 fD0toKpiTClArr->SetName("D0toKpi");
080ac6fd 85 AddAODBranch("TClonesArray", &fD0toKpiTClArr);
0de9de87 86
87 return;
88}
89
90//________________________________________________________________________
91void AliAnalysisTaskSESelectHF::UserExec(Option_t */*option*/)
92{
93 // Execute analysis for current event:
94 // heavy flavor candidates selection and histograms
95
96 AliAODEvent *aodIn = dynamic_cast<AliAODEvent*> (InputEvent());
97
98 // load D0->Kpi candidates
99 TClonesArray *inputArrayD0toKpi =
100 (TClonesArray*)aodIn->GetList()->FindObject("D0toKpi");
0bd2832b 101 if(!inputArrayD0toKpi) {
102 printf("AliAnalysisTaskSESelectHF::UserExec: D0toKpi branch not found!\n");
103 return;
104 }
0de9de87 105
106 //print event info
0bd2832b 107 //aodIn->GetHeader()->Print();
0de9de87 108
109 // primary vertex
110 AliAODVertex *vtx1 = (AliAODVertex*)aodIn->GetPrimaryVertex();
0bd2832b 111 //vtx1->Print();
0de9de87 112
113 // make trkIDtoEntry register (temporary)
114 Int_t trkIDtoEntry[100000];
115 for(Int_t it=0;it<aodIn->GetNumberOfTracks();it++) {
116 AliAODTrack *track = aodIn->GetTrack(it);
117 trkIDtoEntry[track->GetID()]=it;
118 }
119
120 Int_t iOutVerticesHF=0,iOutD0toKpi=0;
121 fVerticesHFTClArr->Delete();
122 iOutVerticesHF = fVerticesHFTClArr->GetEntriesFast();
123 TClonesArray &verticesHFRef = *fVerticesHFTClArr;
124 fD0toKpiTClArr->Delete();
125 iOutD0toKpi = fD0toKpiTClArr->GetEntriesFast();
126 TClonesArray &aodD0toKpiRef = *fD0toKpiTClArr;
127
128
129 // loop over D0->Kpi candidates
130 Int_t nInD0toKpi = inputArrayD0toKpi->GetEntriesFast();
131 printf("Number of D0->Kpi: %d\n",nInD0toKpi);
132
133 for (Int_t iD0toKpi = 0; iD0toKpi < nInD0toKpi; iD0toKpi++) {
134 AliAODRecoDecayHF2Prong *dIn = (AliAODRecoDecayHF2Prong*)inputArrayD0toKpi->UncheckedAt(iD0toKpi);
135 Bool_t unsetvtx=kFALSE;
136 if(!dIn->GetOwnPrimaryVtx()) {
137 dIn->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
138 unsetvtx=kTRUE;
139 }
140 Int_t okD0=0,okD0bar=0;
141 if(dIn->SelectD0(fD0toKpiCuts,okD0,okD0bar)) {
142 // get daughter AOD tracks
2a57ff58 143 AliAODTrack *trk0 = (AliAODTrack*)dIn->GetDaughter(0);
144 AliAODTrack *trk1 = (AliAODTrack*)dIn->GetDaughter(1);
145 if(!trk0 || !trk1) {
146 trk0=aodIn->GetTrack(trkIDtoEntry[dIn->GetProngID(0)]);
147 trk1=aodIn->GetTrack(trkIDtoEntry[dIn->GetProngID(1)]);
148 }
0de9de87 149 printf("pt of positive track: %f\n",trk0->Pt());
150 printf("pt of negative track: %f\n",trk1->Pt());
0bd2832b 151 // HERE ONE COULD RECALCULATE THE VERTEX USING THE KF PACKAGE
0de9de87 152
153 // clone candidate for output AOD
154 AliAODVertex *v = new(verticesHFRef[iOutVerticesHF++])
155 AliAODVertex(*(dIn->GetSecondaryVtx()));
0de9de87 156 AliAODRecoDecayHF2Prong *dOut=new(aodD0toKpiRef[iOutD0toKpi++])
2a57ff58 157 AliAODRecoDecayHF2Prong(*dIn);
158 dOut->SetSecondaryVtx(v);
0bd2832b 159 dOut->SetOwnPrimaryVtx((AliAODVertex*)((dIn->GetOwnPrimaryVtx())->Clone()));
b0ebe389 160 v->SetParent(dOut);
0de9de87 161 }
162 if(unsetvtx) dIn->UnsetOwnPrimaryVtx();
163 } // end loop on D0->Kpi
164
0bd2832b 165 printf("Number of selected D0->Kpi: %d\n",iOutD0toKpi);
166
0de9de87 167
168 return;
169}
170
171//________________________________________________________________________
172void AliAnalysisTaskSESelectHF::Terminate(Option_t */*option*/)
173{
174 // Terminate analysis
175 //
176 if(fDebug > 1) printf("AnalysisTaskSESelectHF: Terminate() \n");
177}
178
179//________________________________________________________________________
180void AliAnalysisTaskSESelectHF::SetD0toKpiCuts(Double_t cut0,Double_t cut1,
181 Double_t cut2,Double_t cut3,Double_t cut4,
182 Double_t cut5,Double_t cut6,
183 Double_t cut7,Double_t cut8)
184{
185 // Set the cuts for D0 selection
186 // cuts[0] = inv. mass half width [GeV]
187 // cuts[1] = dca [cm]
188 // cuts[2] = cosThetaStar
189 // cuts[3] = pTK [GeV/c]
190 // cuts[4] = pTPi [GeV/c]
191 // cuts[5] = d0K [cm] upper limit!
192 // cuts[6] = d0Pi [cm] upper limit!
193 // cuts[7] = d0d0 [cm^2]
194 // cuts[8] = cosThetaPoint
195
196 fD0toKpiCuts[0] = cut0;
197 fD0toKpiCuts[1] = cut1;
198 fD0toKpiCuts[2] = cut2;
199 fD0toKpiCuts[3] = cut3;
200 fD0toKpiCuts[4] = cut4;
201 fD0toKpiCuts[5] = cut5;
202 fD0toKpiCuts[6] = cut6;
203 fD0toKpiCuts[7] = cut7;
204 fD0toKpiCuts[8] = cut8;
205
206 return;
207}
208
209//________________________________________________________________________
210void AliAnalysisTaskSESelectHF::SetD0toKpiCuts(const Double_t cuts[9])
211{
212 // Set the cuts for D0 selection
213 // cuts[0] = inv. mass half width [GeV]
214 // cuts[1] = dca [cm]
215 // cuts[2] = cosThetaStar
216 // cuts[3] = pTK [GeV/c]
217 // cuts[4] = pTPi [GeV/c]
218 // cuts[5] = d0K [cm] upper limit!
219 // cuts[6] = d0Pi [cm] upper limit!
220 // cuts[7] = d0d0 [cm^2]
221 // cuts[8] = cosThetaPoint
222
223 for(Int_t i=0; i<9; i++) fD0toKpiCuts[i] = cuts[i];
224
225 return;
226}