]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/vertexingHF/AliAnalysisTaskSEVertexingHF.cxx
Tell AliAnalysisManager to register the extra file AliAOD.VertexingHF.root (Andrei)
[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
28 #include "AliVEvent.h"
29 #include "AliAODEvent.h"
30 #include "AliESDEvent.h"
31 #include "AliAnalysisVertexingHF.h"
32 #include "AliAnalysisTaskSE.h"
33 #include "AliAnalysisManager.h"
34 #include "AliAnalysisTaskSEVertexingHF.h"
35
36 ClassImp(AliAnalysisTaskSEVertexingHF)
37
38
39 //________________________________________________________________________
40 AliAnalysisTaskSEVertexingHF::AliAnalysisTaskSEVertexingHF():
41 AliAnalysisTaskSE(),
42 fVHF(0),
43 fVerticesHFTClArr(0),
44 fD0toKpiTClArr(0),
45 fJPSItoEleTClArr(0),
46 fCharm3ProngTClArr(0),
47 fCharm4ProngTClArr(0),
48 fDstarTClArr(0),
49 fLikeSign2ProngTClArr(0),
50 fLikeSign3ProngTClArr(0)
51 {
52   // Default constructor
53 }
54
55 //________________________________________________________________________
56 AliAnalysisTaskSEVertexingHF::AliAnalysisTaskSEVertexingHF(const char *name):
57 AliAnalysisTaskSE(name),
58 fVHF(0),
59 fVerticesHFTClArr(0),
60 fD0toKpiTClArr(0),
61 fJPSItoEleTClArr(0),
62 fCharm3ProngTClArr(0),
63 fCharm4ProngTClArr(0),
64 fDstarTClArr(0),
65 fLikeSign2ProngTClArr(0),
66 fLikeSign3ProngTClArr(0)
67 {
68   // Default constructor
69 }
70
71 //________________________________________________________________________
72 AliAnalysisTaskSEVertexingHF::~AliAnalysisTaskSEVertexingHF()
73 {
74   // Destructor
75 }  
76
77 //________________________________________________________________________
78 void AliAnalysisTaskSEVertexingHF::Init()
79 {
80   // Initialization
81   // Instanciates vHF and loads its parameters
82
83   if(fDebug > 1) printf("AnalysisTaskSEVertexingHF::Init() \n");
84
85   if(gROOT->LoadMacro("ConfigVertexingHF.C")) {
86     printf("AnalysisTaskSEVertexingHF::Init() \n Using $ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF.C\n");
87     gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF.C");
88   }
89
90   fVHF = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");  
91   fVHF->PrintStatus();
92   AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile("AliAOD.VertexingHF.root");
93
94   return;
95 }
96
97 //________________________________________________________________________
98 void AliAnalysisTaskSEVertexingHF::UserCreateOutputObjects()
99 {
100   // Create the output container
101   //
102   if(fDebug > 1) printf("AnalysisTaskSEVertexingHF::UserCreateOutPutData() \n");
103   // Support both the case when the AOD + deltaAOD are produced in an ESD
104   // analysis or if the deltaAOD is produced on an analysis on AOD's. (A.G. 27/04/09)
105   if (!AODEvent()) {
106      Fatal("UserCreateOutputObjects", "This task needs an AOD handler");
107      return;
108   }   
109   TString filename = "AliAOD.VertexingHF.root";
110   if (!IsStandardAOD()) filename = "";
111   if(!fVHF) {
112     printf("AnalysisTaskSEVertexingHF::UserCreateOutPutData() \n ERROR! no fvHF!\n");
113     return;
114   }
115
116   fVerticesHFTClArr = new TClonesArray("AliAODVertex", 0);
117   fVerticesHFTClArr->SetName("VerticesHF");
118   AddAODBranch("TClonesArray", &fVerticesHFTClArr, filename);
119
120   if(fVHF->GetD0toKpi()) {
121     fD0toKpiTClArr = new TClonesArray("AliAODRecoDecayHF2Prong", 0);
122     fD0toKpiTClArr->SetName("D0toKpi");
123     AddAODBranch("TClonesArray", &fD0toKpiTClArr, filename);
124   }
125
126   if(fVHF->GetJPSItoEle()) {
127     fJPSItoEleTClArr = new TClonesArray("AliAODRecoDecayHF2Prong", 0);
128     fJPSItoEleTClArr->SetName("JPSItoEle");
129     AddAODBranch("TClonesArray", &fJPSItoEleTClArr, filename);
130   }
131
132   if(fVHF->Get3Prong()) {
133     fCharm3ProngTClArr = new TClonesArray("AliAODRecoDecayHF3Prong", 0);
134     fCharm3ProngTClArr->SetName("Charm3Prong");
135     AddAODBranch("TClonesArray", &fCharm3ProngTClArr, filename);
136   }
137
138   if(fVHF->Get4Prong()) {
139     fCharm4ProngTClArr = new TClonesArray("AliAODRecoDecayHF4Prong", 0);
140     fCharm4ProngTClArr->SetName("Charm4Prong");
141     AddAODBranch("TClonesArray", &fCharm4ProngTClArr, filename);
142   }
143
144   if(fVHF->GetDstar()) {
145     fDstarTClArr = new TClonesArray("AliAODRecoCascadeHF", 0);
146     fDstarTClArr->SetName("Dstar");
147     AddAODBranch("TClonesArray", &fDstarTClArr, filename);
148   }
149
150   if(fVHF->GetLikeSign()) {                      
151     fLikeSign2ProngTClArr = new TClonesArray("AliAODRecoDecayHF2Prong", 0);
152     fLikeSign2ProngTClArr->SetName("LikeSign2Prong");
153     AddAODBranch("TClonesArray", &fLikeSign2ProngTClArr, filename);
154   }
155
156   if(fVHF->GetLikeSign() && fVHF->Get3Prong()) {                      
157     fLikeSign3ProngTClArr = new TClonesArray("AliAODRecoDecayHF3Prong", 0);
158     fLikeSign3ProngTClArr->SetName("LikeSign3Prong");
159     AddAODBranch("TClonesArray", &fLikeSign3ProngTClArr, filename);
160   }
161
162   return;
163 }
164
165 //________________________________________________________________________
166 void AliAnalysisTaskSEVertexingHF::UserExec(Option_t */*option*/)
167 {
168   // Execute analysis for current event:
169   // heavy flavor vertexing
170   
171   AliVEvent *event = dynamic_cast<AliVEvent*> (InputEvent());
172   // In case there is an AOD handler writing a standard AOD, use the AOD 
173   // event in memory rather than the input (ESD) event. (A.G. 27/04/09)
174   if (AODEvent() && IsStandardAOD()) event = dynamic_cast<AliVEvent*> (AODEvent());
175
176   // heavy flavor vertexing
177   fVHF->FindCandidates(event,
178                        fVerticesHFTClArr,
179                        fD0toKpiTClArr,
180                        fJPSItoEleTClArr,
181                        fCharm3ProngTClArr,
182                        fCharm4ProngTClArr,
183                        fDstarTClArr,
184                        fLikeSign2ProngTClArr,
185                        fLikeSign3ProngTClArr);
186   
187   return;
188 }
189
190 //________________________________________________________________________
191 void AliAnalysisTaskSEVertexingHF::Terminate(Option_t */*option*/)
192 {
193   // Terminate analysis
194   //
195   if(fDebug > 1) printf("AnalysisTaskSEVertexingHF: Terminate() \n");
196 }