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