Added method IsInFiducialAcceptance (Chiara Z)
[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),
53fLikeSign2ProngTClArr(0),
54fLikeSign3ProngTClArr(0)
55{
56 // Constructor
57}
58//________________________________________________________________________
59void AliAnalysisTaskMEVertexingHF::Init()
60{
61 // Initialization
62 // Instanciates vHF and loads its parameters
63 // Some parameters are changed
64
65 if(gROOT->LoadMacro("ConfigVertexingHF.C")) {
66 printf("AnalysisTaskMEVertexingHF::Init() \n Using $ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF.C\n");
67 gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF.C");
68 }
69 fvHF = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
70 fvHF->SetMixEventOn();
71 fvHF->SetInputAOD();
72 fvHF->PrintStatus();
73 if(fvHF->GetLikeSign()) {
74 printf("WARNING: fLikeSign will be switched off!");
75 fvHF->SetLikeSignOff();
76 }
77 if(fvHF->GetRecoPrimVtxSkippingTrks() || fvHF->GetRmTrksFromPrimVtx()){
78 fvHF->UnsetRecoPrimVtxSkippingTrks();
79 printf("WARNING: if on, fRecoPrimVtxSkippingTrks and fRmTrksFromPrimVtx will be switched off!\n");
80 }
81
82 AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile("AliAOD.VertexingHF.root");
83
84 return;
85}
86//________________________________________________________________________
87void AliAnalysisTaskMEVertexingHF::UserCreateOutputObjects()
88{
89// Create the output container
90
91
92 if (!AODEvent()) {
93 Fatal("UserCreateOutputObjects", "This task needs an AOD handler");
94 return;
95 }
96
97 if(!fvHF) {
98 printf("AnalysisTaskMEVertexingHF::UserCreateOutPutData() \n ERROR! no fvHF!\n");
99 return;
100 }
101 fVerticesHFTClArr = new TClonesArray("AliAODVertex", 0);
102 fVerticesHFTClArr->SetName("VerticesHF");
103 AddAODBranch("TClonesArray", &fVerticesHFTClArr);
104 if(fvHF->GetD0toKpi()) {
105 fD0toKpiTClArr = new TClonesArray("AliAODRecoDecayHF2Prong", 0);
106 fD0toKpiTClArr->SetName("D0toKpi");
107 AddAODBranch("TClonesArray", &fD0toKpiTClArr);
108 }
109 if(fvHF->GetJPSItoEle()) {
110 fJPSItoEleTClArr = new TClonesArray("AliAODRecoDecayHF2Prong", 0);
111 fJPSItoEleTClArr->SetName("JPSItoEle");
112 AddAODBranch("TClonesArray", &fJPSItoEleTClArr);
113 }
114 if(fvHF->Get3Prong()) {
115 fCharm3ProngTClArr = new TClonesArray("AliAODRecoDecayHF3Prong", 0);
116 fCharm3ProngTClArr->SetName("Charm3Prong");
117 AddAODBranch("TClonesArray", &fCharm3ProngTClArr);
118 }
119 if(fvHF->Get4Prong()) {
120 fCharm4ProngTClArr = new TClonesArray("AliAODRecoDecayHF4Prong", 0);
121 fCharm4ProngTClArr->SetName("Charm4Prong");
122 AddAODBranch("TClonesArray", &fCharm4ProngTClArr);
123 }
124
125 if(fvHF->GetDstar()) {
126 fDstarTClArr = new TClonesArray("AliAODRecoCascadeHF", 0);
127 fDstarTClArr->SetName("Dstar");
128 AddAODBranch("TClonesArray", &fDstarTClArr);
129 }
130
131 if(fvHF->GetLikeSign()) {
132 fLikeSign2ProngTClArr = new TClonesArray("AliAODRecoDecayHF2Prong", 0);
133 fLikeSign2ProngTClArr->SetName("LikeSign2Prong");
134 AddAODBranch("TClonesArray", &fLikeSign2ProngTClArr);
135 }
136
137 if(fvHF->GetLikeSign() && fvHF->Get3Prong()) {
138 fLikeSign3ProngTClArr = new TClonesArray("AliAODRecoDecayHF3Prong", 0);
139 fLikeSign3ProngTClArr->SetName("LikeSign3Prong");
140 AddAODBranch("TClonesArray", &fLikeSign3ProngTClArr);
141 }
142
143 return;
144}
145
146//________________________________________________________________________
147void AliAnalysisTaskMEVertexingHF::UserExec(Option_t *)
148{
149 // Execute analysis for current event:
150 // first build the mixed event, compute the new primary vtx
151 // then heavy flavor vertexing
152
153 Int_t nev = fInputHandler->GetBufferSize();
154 fMixedEvent = new AliMixedEvent();
155 fMixedEvent->Reset();
156 TString primTitle;
157 TString primTitleFirst;
461c10a0 158 AliAODVertex *vtxCopy=0;
a25935a9 159
160 TObjArray *vertices=new TObjArray(nev);
161 for (Int_t iev = 0; iev < nev; iev++) {
162 AliAODEvent *evt = (AliAODEvent*)GetEvent(iev);
163 if(!evt) {delete vertices;return;}
164 AliAODVertex *evtVtx=(AliAODVertex*)evt->GetPrimaryVertex();
165 if(!evtVtx) {delete vertices;return;}
166 primTitle = evtVtx->GetTitle();
167 Int_t nContrib=evtVtx->GetNContributors();
168 if(!primTitle.Contains("VertexerTracks") || nContrib<=0) {
169 delete vertices;
170 return;
171 }
172
461c10a0 173 vtxCopy=new AliAODVertex(*evtVtx);
a25935a9 174 primTitleFirst=evtVtx->GetTitle();
175
176
177 fMixedEvent->AddEvent(evt);
178
179 vertices->AddLast(vtxCopy);
180 }
181
182
183 fMixedEvent->Init();
184 Double_t vtxPos[3]={0.,0.,0.},vtxSigma[3]={0.,0.,0.};
185 Int_t nContributors[1]={0};
186 Double_t chi2=0;
187 Bool_t primaryOk=fMixedEvent->ComputeVtx(vertices,vtxPos,vtxSigma,nContributors);
461c10a0 188 if(!primaryOk) {
189 delete vertices;
190 delete vtxCopy;
191 vtxCopy=NULL;
192 return;
193 }
a25935a9 194 Int_t contribCopy=nContributors[0];
195 AliVVertex* newVertex=new AliESDVertex(vtxPos,vtxSigma,chi2,contribCopy);
196 newVertex->SetTitle(primTitleFirst.Data());
197 fMixedEvent->SetPrimaryVertex(newVertex);
198
199 delete vertices;
461c10a0 200 delete vtxCopy;
201 vtxCopy=NULL;
a25935a9 202
203 fvHF->FindCandidates(fMixedEvent,
204 fVerticesHFTClArr,
205 fD0toKpiTClArr,
206 fJPSItoEleTClArr,
207 fCharm3ProngTClArr,
208 fCharm4ProngTClArr,
209 fDstarTClArr,
210 fLikeSign2ProngTClArr,
211 fLikeSign3ProngTClArr);
212
461c10a0 213 delete newVertex;
a25935a9 214 return;
215}
216
217//________________________________________________________________________
218void AliAnalysisTaskMEVertexingHF::Terminate(Option_t *)
219{
220 // Terminate analysis
221}