New AliAnalysisTaskSE for selection of HF candidates (Andrea)
[u/mrichter/AliRoot.git] / PWG3 / 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");
81 AddAODBranch("TClonesArray", fVerticesHFTClArr);
82
83 fD0toKpiTClArr = new TClonesArray("AliAODRecoDecayHF2Prong", 0);
84 fD0toKpiTClArr->SetName("D0toKpi");
85 AddAODBranch("TClonesArray", fD0toKpiTClArr);
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");
101
102 //print event info
103 aodIn->GetHeader()->Print();
104
105 // primary vertex
106 AliAODVertex *vtx1 = (AliAODVertex*)aodIn->GetPrimaryVertex();
107 vtx1->Print();
108
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;
114 }
115
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;
123
124
125 // loop over D0->Kpi candidates
126 Int_t nInD0toKpi = inputArrayD0toKpi->GetEntriesFast();
127 printf("Number of D0->Kpi: %d\n",nInD0toKpi);
128
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
134 unsetvtx=kTRUE;
135 }
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());
145
146
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());
158 }
159 if(unsetvtx) dIn->UnsetOwnPrimaryVtx();
160 } // end loop on D0->Kpi
161
162
163 return;
164}
165
166//________________________________________________________________________
167void AliAnalysisTaskSESelectHF::Terminate(Option_t */*option*/)
168{
169 // Terminate analysis
170 //
171 if(fDebug > 1) printf("AnalysisTaskSESelectHF: Terminate() \n");
172}
173
174//________________________________________________________________________
175void 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)
179{
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
190
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;
200
201 return;
202}
203
204//________________________________________________________________________
205void AliAnalysisTaskSESelectHF::SetD0toKpiCuts(const Double_t cuts[9])
206{
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
217
218 for(Int_t i=0; i<9; i++) fD0toKpiCuts[i] = cuts[i];
219
220 return;
221}