Fix in the last caall to CleanOwnPrimaryVertex
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliAnalysisTaskSEVertexingHF.cxx
CommitLineData
699a38d6 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
27de2dfb 16/* $Id$ */
17
699a38d6 18/////////////////////////////////////////////////////////////
19//
20// AliAnalysisTaskSE for the reconstruction of heavy flavor
21// decays, using the class AliAnalysisVertexingHF.
22//
23// Author: A.Dainese, andrea.dainese@lnl.infn.it
24/////////////////////////////////////////////////////////////
25
26#include <TROOT.h>
27#include <TSystem.h>
28#include <TClonesArray.h>
a9b75906 29#include <TList.h>
30#include <TString.h>
699a38d6 31
dcb444c9 32#include "AliVEvent.h"
699a38d6 33#include "AliAODEvent.h"
e07c9999 34#include "AliAODHandler.h"
699a38d6 35#include "AliESDEvent.h"
36#include "AliAnalysisVertexingHF.h"
37#include "AliAnalysisTaskSE.h"
6ed0d659 38#include "AliAnalysisManager.h"
699a38d6 39#include "AliAnalysisTaskSEVertexingHF.h"
40
4569a83a 41#include "AliESDUtils.h"
42#include "AliAODHFUtil.h"
43
44
699a38d6 45ClassImp(AliAnalysisTaskSEVertexingHF)
46
47
48//________________________________________________________________________
49AliAnalysisTaskSEVertexingHF::AliAnalysisTaskSEVertexingHF():
50AliAnalysisTaskSE(),
51fVHF(0),
a9b75906 52fListOfCuts(0),
53fDeltaAODFileName("AliAOD.VertexingHF.root"),
699a38d6 54fVerticesHFTClArr(0),
55fD0toKpiTClArr(0),
56fJPSItoEleTClArr(0),
57fCharm3ProngTClArr(0),
2ff20727 58fCharm4ProngTClArr(0),
dc963de9 59fDstarTClArr(0),
a07ad8e0 60fCascadesTClArr(0),
423fb9ae 61fLikeSign2ProngTClArr(0),
4569a83a 62fLikeSign3ProngTClArr(0),
63fHFUtilInfo(0)
699a38d6 64{
65 // Default constructor
66}
67
68//________________________________________________________________________
69AliAnalysisTaskSEVertexingHF::AliAnalysisTaskSEVertexingHF(const char *name):
70AliAnalysisTaskSE(name),
71fVHF(0),
a9b75906 72fListOfCuts(0),
73fDeltaAODFileName("AliAOD.VertexingHF.root"),
699a38d6 74fVerticesHFTClArr(0),
75fD0toKpiTClArr(0),
76fJPSItoEleTClArr(0),
77fCharm3ProngTClArr(0),
2ff20727 78fCharm4ProngTClArr(0),
dc963de9 79fDstarTClArr(0),
a07ad8e0 80fCascadesTClArr(0),
423fb9ae 81fLikeSign2ProngTClArr(0),
4569a83a 82fLikeSign3ProngTClArr(0),
83fHFUtilInfo(0)
699a38d6 84{
a9b75906 85 // Standard constructor
86
87 DefineOutput(1,TList::Class()); // analysis cuts
699a38d6 88}
89
90//________________________________________________________________________
91AliAnalysisTaskSEVertexingHF::~AliAnalysisTaskSEVertexingHF()
92{
93 // Destructor
a9b75906 94
95 if(fListOfCuts) {
96 delete fListOfCuts;
97 fListOfCuts=NULL;
98 }
99
699a38d6 100}
101
102//________________________________________________________________________
103void AliAnalysisTaskSEVertexingHF::Init()
104{
105 // Initialization
106 // Instanciates vHF and loads its parameters
107
108 if(fDebug > 1) printf("AnalysisTaskSEVertexingHF::Init() \n");
109
423fb9ae 110 if(gROOT->LoadMacro("ConfigVertexingHF.C")) {
111 printf("AnalysisTaskSEVertexingHF::Init() \n Using $ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF.C\n");
112 gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF.C");
113 }
699a38d6 114
115 fVHF = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
116 fVHF->PrintStatus();
a9b75906 117
118
119 // write the objects AliRDHFCuts to a list to store in the output
120
121 fListOfCuts = fVHF->FillListOfCuts();
122
123 PostData(1,fListOfCuts);
124
125 AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile(fDeltaAODFileName.Data());
699a38d6 126
127 return;
128}
129
130//________________________________________________________________________
131void AliAnalysisTaskSEVertexingHF::UserCreateOutputObjects()
132{
133 // Create the output container
134 //
135 if(fDebug > 1) printf("AnalysisTaskSEVertexingHF::UserCreateOutPutData() \n");
0392e556 136 // Support both the case when the AOD + deltaAOD are produced in an ESD
137 // analysis or if the deltaAOD is produced on an analysis on AOD's. (A.G. 27/04/09)
5a0b85ff 138 if(!AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()) {
139 Fatal("UserCreateOutputObjects", "This task needs an AOD handler");
140 return;
0392e556 141 }
a9b75906 142 TString filename = fDeltaAODFileName;
5a0b85ff 143 // When running on standard AOD to produce deltas, IsStandardAOD is never set,
144 // If AODEvent is NULL, new branches have to be added to the new file(s) (A.G. 15/01/10)
145 if(!IsStandardAOD() && AODEvent()) filename = "";
699a38d6 146 if(!fVHF) {
147 printf("AnalysisTaskSEVertexingHF::UserCreateOutPutData() \n ERROR! no fvHF!\n");
148 return;
149 }
150
151 fVerticesHFTClArr = new TClonesArray("AliAODVertex", 0);
152 fVerticesHFTClArr->SetName("VerticesHF");
0392e556 153 AddAODBranch("TClonesArray", &fVerticesHFTClArr, filename);
699a38d6 154
dc963de9 155 if(fVHF->GetD0toKpi()) {
699a38d6 156 fD0toKpiTClArr = new TClonesArray("AliAODRecoDecayHF2Prong", 0);
157 fD0toKpiTClArr->SetName("D0toKpi");
0392e556 158 AddAODBranch("TClonesArray", &fD0toKpiTClArr, filename);
699a38d6 159 }
160
161 if(fVHF->GetJPSItoEle()) {
162 fJPSItoEleTClArr = new TClonesArray("AliAODRecoDecayHF2Prong", 0);
163 fJPSItoEleTClArr->SetName("JPSItoEle");
0392e556 164 AddAODBranch("TClonesArray", &fJPSItoEleTClArr, filename);
699a38d6 165 }
166
167 if(fVHF->Get3Prong()) {
168 fCharm3ProngTClArr = new TClonesArray("AliAODRecoDecayHF3Prong", 0);
169 fCharm3ProngTClArr->SetName("Charm3Prong");
0392e556 170 AddAODBranch("TClonesArray", &fCharm3ProngTClArr, filename);
699a38d6 171 }
172
173 if(fVHF->Get4Prong()) {
174 fCharm4ProngTClArr = new TClonesArray("AliAODRecoDecayHF4Prong", 0);
175 fCharm4ProngTClArr->SetName("Charm4Prong");
0392e556 176 AddAODBranch("TClonesArray", &fCharm4ProngTClArr, filename);
699a38d6 177 }
178
2ff20727 179 if(fVHF->GetDstar()) {
180 fDstarTClArr = new TClonesArray("AliAODRecoCascadeHF", 0);
181 fDstarTClArr->SetName("Dstar");
0392e556 182 AddAODBranch("TClonesArray", &fDstarTClArr, filename);
2ff20727 183 }
184
a07ad8e0 185 if(fVHF->GetCascades()){
186 fCascadesTClArr = new TClonesArray("AliAODRecoCascadeHF", 0);
187 fCascadesTClArr->SetName("CascadesHF");
188 AddAODBranch("TClonesArray", &fCascadesTClArr, filename);
189 }
190
dc963de9 191 if(fVHF->GetLikeSign()) {
423fb9ae 192 fLikeSign2ProngTClArr = new TClonesArray("AliAODRecoDecayHF2Prong", 0);
193 fLikeSign2ProngTClArr->SetName("LikeSign2Prong");
0392e556 194 AddAODBranch("TClonesArray", &fLikeSign2ProngTClArr, filename);
423fb9ae 195 }
196
197 if(fVHF->GetLikeSign() && fVHF->Get3Prong()) {
198 fLikeSign3ProngTClArr = new TClonesArray("AliAODRecoDecayHF3Prong", 0);
199 fLikeSign3ProngTClArr->SetName("LikeSign3Prong");
0392e556 200 AddAODBranch("TClonesArray", &fLikeSign3ProngTClArr, filename);
dc963de9 201 }
202
4569a83a 203 //---Way to pass information temporarily not available in AOD---
204 // no if() {
205 fHFUtilInfo = new AliAODHFUtil("fHFUtilInfoC");
206 fHFUtilInfo->SetName("fHFUtilInfo");
207 AddAODBranch( "AliAODHFUtil", &fHFUtilInfo, filename);
208 // }
209 //--------------------------------------------------------------
210
699a38d6 211 return;
212}
213
214//________________________________________________________________________
215void AliAnalysisTaskSEVertexingHF::UserExec(Option_t */*option*/)
216{
217 // Execute analysis for current event:
218 // heavy flavor vertexing
219
dcb444c9 220 AliVEvent *event = dynamic_cast<AliVEvent*> (InputEvent());
0392e556 221 // In case there is an AOD handler writing a standard AOD, use the AOD
222 // event in memory rather than the input (ESD) event. (A.G. 27/04/09)
223 if (AODEvent() && IsStandardAOD()) event = dynamic_cast<AliVEvent*> (AODEvent());
699a38d6 224
e07c9999 225 if (dynamic_cast<AliAODEvent*>(event)) {
226 AliAODHandler *aodhandler = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());
227 if (aodhandler) aodhandler->SetFillExtension(kTRUE);
228 }
229
699a38d6 230 // heavy flavor vertexing
dcb444c9 231 fVHF->FindCandidates(event,
232 fVerticesHFTClArr,
233 fD0toKpiTClArr,
234 fJPSItoEleTClArr,
235 fCharm3ProngTClArr,
2ff20727 236 fCharm4ProngTClArr,
dc963de9 237 fDstarTClArr,
a07ad8e0 238 fCascadesTClArr,
423fb9ae 239 fLikeSign2ProngTClArr,
240 fLikeSign3ProngTClArr);
699a38d6 241
4569a83a 242 //---Way to pass information temporarily not available in AOD---
243 AliESDEvent *eventE = dynamic_cast<AliESDEvent*> (InputEvent());
244 if(eventE) {
245 Float_t *vChCorr = new Float_t[64];
246 Float_t dummy;
56bf3066 247 AliESDUtils::GetCorrV0(eventE,dummy,NULL,vChCorr);
4569a83a 248 fHFUtilInfo->SetVZERO( vChCorr );
fd20854c 249 delete [] vChCorr;
4569a83a 250 }
251 //--------------------------------------------------------------
252
699a38d6 253 return;
254}
255
256//________________________________________________________________________
257void AliAnalysisTaskSEVertexingHF::Terminate(Option_t */*option*/)
258{
259 // Terminate analysis
260 //
261 if(fDebug > 1) printf("AnalysisTaskSEVertexingHF: Terminate() \n");
262}