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