set ownership of cuts container
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliAnalysisTaskMEVertexingHF.cxx
CommitLineData
a25935a9 1/**************************************************************************
2 * Copyright(c) 1998-2009, 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 * Permission to use, copy, modify and distribute this software and its *
7 * documentation strictly for non-commercial purposes is hereby granted *
8 * without fee, provided that the above copyright notice appears in all *
9 * copies and that both the copyright notice and this permission notice *
10 * appear in the supporting documentation. The authors make no claims *
11 * about the suitability of this software for any purpose. It is *
12 * provided "as is" without express or implied warranty. *
13 **************************************************************************/
14//*************************************************************************
15// Class AliAnalysisTaskMEVertexingHF
16// AliAnalysisTaskME for event mixing, building the background for
17// heavy-flavour decay candidates
18// Author: R.Romita, r.romita@gsi.de
19//*************************************************************************
20
21
22
23#include "TH1F.h"
24#include "TObjArray.h"
25#include "TList.h"
26#include "TROOT.h"
27#include "TSystem.h"
28#include "TCanvas.h"
29
30#include "AliVEvent.h"
31#include "AliVVertex.h"
32#include "AliAODEvent.h"
33#include "AliESDEvent.h"
34#include "AliAnalysisVertexingHF.h"
35#include "AliMixedEvent.h"
36#include "AliAnalysisTaskMEVertexingHF.h"
37#include "AliAnalysisManager.h"
38#include "AliMultiEventInputHandler.h"
39
40ClassImp(AliAnalysisTaskMEVertexingHF)
41
42//________________________________________________________________________
43AliAnalysisTaskMEVertexingHF::AliAnalysisTaskMEVertexingHF(const char *name) :
44AliAnalysisTaskME(name),
45fvHF(0),
46fMixedEvent(),
47fVerticesHFTClArr(0),
48fD0toKpiTClArr(0),
49fJPSItoEleTClArr(0),
50fCharm3ProngTClArr(0),
51fCharm4ProngTClArr(0),
52fDstarTClArr(0),
a07ad8e0 53fCascadesTClArr(0),
a25935a9 54fLikeSign2ProngTClArr(0),
55fLikeSign3ProngTClArr(0)
56{
57 // Constructor
58}
59//________________________________________________________________________
60void AliAnalysisTaskMEVertexingHF::Init()
61{
62 // Initialization
63 // Instanciates vHF and loads its parameters
64 // Some parameters are changed
65
66 if(gROOT->LoadMacro("ConfigVertexingHF.C")) {
67 printf("AnalysisTaskMEVertexingHF::Init() \n Using $ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF.C\n");
68 gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF.C");
69 }
70 fvHF = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
71 fvHF->SetMixEventOn();
72 fvHF->SetInputAOD();
73 fvHF->PrintStatus();
74 if(fvHF->GetLikeSign()) {
75 printf("WARNING: fLikeSign will be switched off!");
76 fvHF->SetLikeSignOff();
77 }
78 if(fvHF->GetRecoPrimVtxSkippingTrks() || fvHF->GetRmTrksFromPrimVtx()){
79 fvHF->UnsetRecoPrimVtxSkippingTrks();
80 printf("WARNING: if on, fRecoPrimVtxSkippingTrks and fRmTrksFromPrimVtx will be switched off!\n");
81 }
82
83 AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile("AliAOD.VertexingHF.root");
84
85 return;
86}
87//________________________________________________________________________
88void AliAnalysisTaskMEVertexingHF::UserCreateOutputObjects()
89{
90// Create the output container
91
92
93 if (!AODEvent()) {
94 Fatal("UserCreateOutputObjects", "This task needs an AOD handler");
95 return;
96 }
97
98 if(!fvHF) {
99 printf("AnalysisTaskMEVertexingHF::UserCreateOutPutData() \n ERROR! no fvHF!\n");
100 return;
101 }
102 fVerticesHFTClArr = new TClonesArray("AliAODVertex", 0);
103 fVerticesHFTClArr->SetName("VerticesHF");
104 AddAODBranch("TClonesArray", &fVerticesHFTClArr);
105 if(fvHF->GetD0toKpi()) {
106 fD0toKpiTClArr = new TClonesArray("AliAODRecoDecayHF2Prong", 0);
107 fD0toKpiTClArr->SetName("D0toKpi");
108 AddAODBranch("TClonesArray", &fD0toKpiTClArr);
109 }
110 if(fvHF->GetJPSItoEle()) {
111 fJPSItoEleTClArr = new TClonesArray("AliAODRecoDecayHF2Prong", 0);
112 fJPSItoEleTClArr->SetName("JPSItoEle");
113 AddAODBranch("TClonesArray", &fJPSItoEleTClArr);
114 }
115 if(fvHF->Get3Prong()) {
116 fCharm3ProngTClArr = new TClonesArray("AliAODRecoDecayHF3Prong", 0);
117 fCharm3ProngTClArr->SetName("Charm3Prong");
118 AddAODBranch("TClonesArray", &fCharm3ProngTClArr);
119 }
120 if(fvHF->Get4Prong()) {
121 fCharm4ProngTClArr = new TClonesArray("AliAODRecoDecayHF4Prong", 0);
122 fCharm4ProngTClArr->SetName("Charm4Prong");
123 AddAODBranch("TClonesArray", &fCharm4ProngTClArr);
124 }
125
126 if(fvHF->GetDstar()) {
127 fDstarTClArr = new TClonesArray("AliAODRecoCascadeHF", 0);
128 fDstarTClArr->SetName("Dstar");
129 AddAODBranch("TClonesArray", &fDstarTClArr);
130 }
131
a07ad8e0 132 if(fvHF->GetCascades()){
133 fCascadesTClArr = new TClonesArray("AliAODRecoCascadeHF", 0);
134 fCascadesTClArr->SetName("CascadesHF");
135 AddAODBranch("TClonesArray", &fCascadesTClArr);
136 }
137
a25935a9 138 if(fvHF->GetLikeSign()) {
139 fLikeSign2ProngTClArr = new TClonesArray("AliAODRecoDecayHF2Prong", 0);
140 fLikeSign2ProngTClArr->SetName("LikeSign2Prong");
141 AddAODBranch("TClonesArray", &fLikeSign2ProngTClArr);
142 }
143
144 if(fvHF->GetLikeSign() && fvHF->Get3Prong()) {
145 fLikeSign3ProngTClArr = new TClonesArray("AliAODRecoDecayHF3Prong", 0);
146 fLikeSign3ProngTClArr->SetName("LikeSign3Prong");
147 AddAODBranch("TClonesArray", &fLikeSign3ProngTClArr);
148 }
149
150 return;
151}
152
153//________________________________________________________________________
154void AliAnalysisTaskMEVertexingHF::UserExec(Option_t *)
155{
156 // Execute analysis for current event:
157 // first build the mixed event, compute the new primary vtx
158 // then heavy flavor vertexing
159
160 Int_t nev = fInputHandler->GetBufferSize();
161 fMixedEvent = new AliMixedEvent();
162 fMixedEvent->Reset();
163 TString primTitle;
164 TString primTitleFirst;
461c10a0 165 AliAODVertex *vtxCopy=0;
a25935a9 166
167 TObjArray *vertices=new TObjArray(nev);
168 for (Int_t iev = 0; iev < nev; iev++) {
169 AliAODEvent *evt = (AliAODEvent*)GetEvent(iev);
170 if(!evt) {delete vertices;return;}
171 AliAODVertex *evtVtx=(AliAODVertex*)evt->GetPrimaryVertex();
172 if(!evtVtx) {delete vertices;return;}
173 primTitle = evtVtx->GetTitle();
174 Int_t nContrib=evtVtx->GetNContributors();
175 if(!primTitle.Contains("VertexerTracks") || nContrib<=0) {
176 delete vertices;
177 return;
178 }
179
461c10a0 180 vtxCopy=new AliAODVertex(*evtVtx);
a25935a9 181 primTitleFirst=evtVtx->GetTitle();
182
183
184 fMixedEvent->AddEvent(evt);
185
186 vertices->AddLast(vtxCopy);
187 }
188
189
190 fMixedEvent->Init();
191 Double_t vtxPos[3]={0.,0.,0.},vtxSigma[3]={0.,0.,0.};
192 Int_t nContributors[1]={0};
193 Double_t chi2=0;
194 Bool_t primaryOk=fMixedEvent->ComputeVtx(vertices,vtxPos,vtxSigma,nContributors);
461c10a0 195 if(!primaryOk) {
196 delete vertices;
197 delete vtxCopy;
198 vtxCopy=NULL;
199 return;
200 }
a25935a9 201 Int_t contribCopy=nContributors[0];
dc222f77 202 Double_t vtxCov[6]={vtxSigma[0]*vtxSigma[0],0,vtxSigma[1]*vtxSigma[1],0,0,vtxSigma[2]*vtxSigma[2]};
203 AliVVertex* newVertex=new AliESDVertex(vtxPos,vtxCov,chi2,contribCopy);
a25935a9 204 newVertex->SetTitle(primTitleFirst.Data());
205 fMixedEvent->SetPrimaryVertex(newVertex);
206
207 delete vertices;
461c10a0 208 delete vtxCopy;
209 vtxCopy=NULL;
a25935a9 210
211 fvHF->FindCandidates(fMixedEvent,
212 fVerticesHFTClArr,
213 fD0toKpiTClArr,
214 fJPSItoEleTClArr,
215 fCharm3ProngTClArr,
216 fCharm4ProngTClArr,
217 fDstarTClArr,
a07ad8e0 218 fCascadesTClArr,
a25935a9 219 fLikeSign2ProngTClArr,
220 fLikeSign3ProngTClArr);
221
461c10a0 222 delete newVertex;
a25935a9 223 return;
224}
225
226//________________________________________________________________________
227void AliAnalysisTaskMEVertexingHF::Terminate(Option_t *)
228{
229 // Terminate analysis
230}