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