Added method to add a default set of jet fidners for a deltaAOD
[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"
12bfc069 30#include "AliAnalysisVertexingHF.h"
0de9de87 31#include "AliAnalysisTaskSE.h"
32#include "AliAnalysisTaskSESelectHF.h"
33
34ClassImp(AliAnalysisTaskSESelectHF)
35
36
37//________________________________________________________________________
38AliAnalysisTaskSESelectHF::AliAnalysisTaskSESelectHF():
39AliAnalysisTaskSE(),
40fVerticesHFTClArr(0),
12bfc069 41fD0toKpiTClArr(0),
42fVHF(0)
0de9de87 43{
44 // Default constructor
0de9de87 45}
46
47//________________________________________________________________________
48AliAnalysisTaskSESelectHF::AliAnalysisTaskSESelectHF(const char *name):
49AliAnalysisTaskSE(name),
50fVerticesHFTClArr(0),
12bfc069 51fD0toKpiTClArr(0),
52fVHF(0)
0de9de87 53{
54 // Default constructor
0de9de87 55}
56
57//________________________________________________________________________
58AliAnalysisTaskSESelectHF::~AliAnalysisTaskSESelectHF()
59{
60 // Destructor
12bfc069 61
62 if (fVHF) {
63 delete fVHF;
64 fVHF = 0;
65 }
66
0de9de87 67}
68
69//________________________________________________________________________
70void AliAnalysisTaskSESelectHF::Init()
71{
72 // Initialization
73
74 if(fDebug > 1) printf("AnalysisTaskSESelectHF::Init() \n");
75
12bfc069 76 gROOT->LoadMacro("ConfigVertexingHF.C");
77
78 fVHF = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
79 fVHF->PrintStatus();
80
0de9de87 81 return;
82}
83
84//________________________________________________________________________
85void AliAnalysisTaskSESelectHF::UserCreateOutputObjects()
86{
87 // Create the output container
88 //
89 if(fDebug > 1) printf("AnalysisTaskSESelectHF::UserCreateOutputObjects() \n");
90
91 fVerticesHFTClArr = new TClonesArray("AliAODVertex", 0);
92 fVerticesHFTClArr->SetName("VerticesHF");
080ac6fd 93 AddAODBranch("TClonesArray", &fVerticesHFTClArr);
0de9de87 94
95 fD0toKpiTClArr = new TClonesArray("AliAODRecoDecayHF2Prong", 0);
96 fD0toKpiTClArr->SetName("D0toKpi");
080ac6fd 97 AddAODBranch("TClonesArray", &fD0toKpiTClArr);
0de9de87 98
99 return;
100}
101
102//________________________________________________________________________
103void AliAnalysisTaskSESelectHF::UserExec(Option_t */*option*/)
104{
105 // Execute analysis for current event:
106 // heavy flavor candidates selection and histograms
107
108 AliAODEvent *aodIn = dynamic_cast<AliAODEvent*> (InputEvent());
109
8931c313 110 // In case there is an AOD handler writing a standard AOD, use the AOD
111 // event in memory rather than the input (ESD) event.
112 if (!aodIn && AODEvent() && IsStandardAOD()) aodIn = dynamic_cast<AliAODEvent*> (AODEvent());
113
0de9de87 114 // load D0->Kpi candidates
115 TClonesArray *inputArrayD0toKpi =
116 (TClonesArray*)aodIn->GetList()->FindObject("D0toKpi");
0bd2832b 117 if(!inputArrayD0toKpi) {
118 printf("AliAnalysisTaskSESelectHF::UserExec: D0toKpi branch not found!\n");
119 return;
120 }
0de9de87 121
122 //print event info
0bd2832b 123 //aodIn->GetHeader()->Print();
0de9de87 124
125 // primary vertex
126 AliAODVertex *vtx1 = (AliAODVertex*)aodIn->GetPrimaryVertex();
0bd2832b 127 //vtx1->Print();
0de9de87 128
129 // make trkIDtoEntry register (temporary)
130 Int_t trkIDtoEntry[100000];
131 for(Int_t it=0;it<aodIn->GetNumberOfTracks();it++) {
132 AliAODTrack *track = aodIn->GetTrack(it);
133 trkIDtoEntry[track->GetID()]=it;
134 }
135
136 Int_t iOutVerticesHF=0,iOutD0toKpi=0;
137 fVerticesHFTClArr->Delete();
138 iOutVerticesHF = fVerticesHFTClArr->GetEntriesFast();
139 TClonesArray &verticesHFRef = *fVerticesHFTClArr;
140 fD0toKpiTClArr->Delete();
141 iOutD0toKpi = fD0toKpiTClArr->GetEntriesFast();
142 TClonesArray &aodD0toKpiRef = *fD0toKpiTClArr;
143
144
145 // loop over D0->Kpi candidates
146 Int_t nInD0toKpi = inputArrayD0toKpi->GetEntriesFast();
147 printf("Number of D0->Kpi: %d\n",nInD0toKpi);
148
149 for (Int_t iD0toKpi = 0; iD0toKpi < nInD0toKpi; iD0toKpi++) {
150 AliAODRecoDecayHF2Prong *dIn = (AliAODRecoDecayHF2Prong*)inputArrayD0toKpi->UncheckedAt(iD0toKpi);
151 Bool_t unsetvtx=kFALSE;
152 if(!dIn->GetOwnPrimaryVtx()) {
153 dIn->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
154 unsetvtx=kTRUE;
155 }
156 Int_t okD0=0,okD0bar=0;
12bfc069 157 if(dIn->SelectD0(fVHF->GetD0toKpiCuts(),okD0,okD0bar)) {
0de9de87 158 // get daughter AOD tracks
2a57ff58 159 AliAODTrack *trk0 = (AliAODTrack*)dIn->GetDaughter(0);
160 AliAODTrack *trk1 = (AliAODTrack*)dIn->GetDaughter(1);
161 if(!trk0 || !trk1) {
162 trk0=aodIn->GetTrack(trkIDtoEntry[dIn->GetProngID(0)]);
163 trk1=aodIn->GetTrack(trkIDtoEntry[dIn->GetProngID(1)]);
164 }
0de9de87 165 printf("pt of positive track: %f\n",trk0->Pt());
166 printf("pt of negative track: %f\n",trk1->Pt());
0bd2832b 167 // HERE ONE COULD RECALCULATE THE VERTEX USING THE KF PACKAGE
0de9de87 168
169 // clone candidate for output AOD
170 AliAODVertex *v = new(verticesHFRef[iOutVerticesHF++])
171 AliAODVertex(*(dIn->GetSecondaryVtx()));
0de9de87 172 AliAODRecoDecayHF2Prong *dOut=new(aodD0toKpiRef[iOutD0toKpi++])
2a57ff58 173 AliAODRecoDecayHF2Prong(*dIn);
174 dOut->SetSecondaryVtx(v);
0bd2832b 175 dOut->SetOwnPrimaryVtx((AliAODVertex*)((dIn->GetOwnPrimaryVtx())->Clone()));
b0ebe389 176 v->SetParent(dOut);
0de9de87 177 }
178 if(unsetvtx) dIn->UnsetOwnPrimaryVtx();
179 } // end loop on D0->Kpi
180
0bd2832b 181 printf("Number of selected D0->Kpi: %d\n",iOutD0toKpi);
182
0de9de87 183
184 return;
185}
186
187//________________________________________________________________________
188void AliAnalysisTaskSESelectHF::Terminate(Option_t */*option*/)
189{
190 // Terminate analysis
191 //
192 if(fDebug > 1) printf("AnalysisTaskSESelectHF: Terminate() \n");
193}
194