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