1 /**************************************************************************
2 * Copyright(c) 1998-2006, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /////////////////////////////////////////////////////////////
18 // Base class for AOD reconstructed heavy-flavour decay
20 // Author: A.Dainese, andrea.dainese@lnl.infn.it
21 /////////////////////////////////////////////////////////////
23 #include <TDatabasePDG.h>
25 #include "AliAODRecoDecay.h"
26 #include "AliAODRecoDecayHF.h"
27 #include "AliKFVertex.h"
28 #include "AliVVertex.h"
29 #include "AliESDVertex.h"
31 ClassImp(AliAODRecoDecayHF)
33 //--------------------------------------------------------------------------
34 AliAODRecoDecayHF::AliAODRecoDecayHF() :
43 // Default Constructor
46 //--------------------------------------------------------------------------
47 AliAODRecoDecayHF::AliAODRecoDecayHF(AliAODVertex *vtx2,Int_t nprongs,Short_t charge,
48 Double_t *px,Double_t *py,Double_t *pz,
49 Double_t *d0,Double_t *d0err) :
50 AliAODRecoDecay(vtx2,nprongs,charge,px,py,pz,d0),
58 // Constructor with AliAODVertex for decay vertex
60 fd0err = new Double_t[GetNProngs()];
61 for(Int_t i=0; i<GetNProngs(); i++) fd0err[i] = d0err[i];
63 //--------------------------------------------------------------------------
64 AliAODRecoDecayHF::AliAODRecoDecayHF(AliAODVertex *vtx2,Int_t nprongs,Short_t charge,
65 Double_t *d0,Double_t *d0err) :
66 AliAODRecoDecay(vtx2,nprongs,charge,d0),
74 // Constructor with AliAODVertex for decay vertex and without prongs momenta
76 fd0err = new Double_t[GetNProngs()];
77 for(Int_t i=0; i<GetNProngs(); i++) fd0err[i] = d0err[i];
79 //--------------------------------------------------------------------------
80 AliAODRecoDecayHF::AliAODRecoDecayHF(Double_t vtx1[3],Double_t vtx2[3],
81 Int_t nprongs,Short_t charge,
82 Double_t *px,Double_t *py,Double_t *pz,
84 AliAODRecoDecay(0x0,nprongs,charge,px,py,pz,d0),
92 // Constructor that can used for a "MC" object
95 fOwnPrimaryVtx = new AliAODVertex(vtx1);
97 AliAODVertex *vtx = new AliAODVertex(vtx2);
98 SetOwnSecondaryVtx(vtx);
101 //--------------------------------------------------------------------------
102 AliAODRecoDecayHF::AliAODRecoDecayHF(const AliAODRecoDecayHF &source) :
103 AliAODRecoDecay(source),
105 fEventPrimaryVtx(source.fEventPrimaryVtx),
106 fListOfCuts(source.fListOfCuts),
113 if(source.GetOwnPrimaryVtx()) fOwnPrimaryVtx = new AliAODVertex(*(source.GetOwnPrimaryVtx()));
115 if(source.GetNProngs()>0) {
116 fd0err = new Double_t[GetNProngs()];
117 memcpy(fd0err,source.fd0err,GetNProngs()*sizeof(Double_t));
118 if(source.fProngID) {
119 fProngID = new UShort_t[GetNProngs()];
120 memcpy(fProngID,source.fProngID,GetNProngs()*sizeof(UShort_t));
124 //--------------------------------------------------------------------------
125 AliAODRecoDecayHF &AliAODRecoDecayHF::operator=(const AliAODRecoDecayHF &source)
128 // assignment operator
130 if(&source == this) return *this;
132 AliAODRecoDecay::operator=(source);
134 fEventPrimaryVtx = source.fEventPrimaryVtx;
135 fListOfCuts = source.fListOfCuts;
137 if(source.GetOwnPrimaryVtx()) fOwnPrimaryVtx = new AliAODVertex(*(source.GetOwnPrimaryVtx()));
139 if(source.GetNProngs()>0) {
140 fd0err = new Double_t[GetNProngs()];
141 memcpy(fd0err,source.fd0err,GetNProngs()*sizeof(Double_t));
142 if(source.fProngID) {
143 fProngID = new UShort_t[GetNProngs()];
144 memcpy(fProngID,source.fProngID,GetNProngs()*sizeof(UShort_t));
149 //--------------------------------------------------------------------------
150 AliAODRecoDecayHF::~AliAODRecoDecayHF() {
152 // Default Destructor
154 if(fOwnPrimaryVtx) delete fOwnPrimaryVtx;
155 if(fd0err) delete [] fd0err;
156 if(fProngID) delete [] fProngID;
158 //---------------------------------------------------------------------------
159 AliKFParticle *AliAODRecoDecayHF::ApplyVertexingKF(Int_t *iprongs,Int_t nprongs,Int_t *pdgs,Bool_t topoCostraint, Double_t bzkG, Double_t *mass) const {
161 // Applies the KF vertexer
162 // Int_t iprongs[nprongs] = indices of the prongs to be used from the vertexer
163 // Int_t pdgs[nprongs] = pdgs assigned to the prongs, needed to define the AliKFParticle
164 // Bool_t topoCostraint = if kTRUE, the topological constraint is applied
165 // Double_t bzkG = magnetic field
166 // Double_t mass[2] = {mass, sigma} for the mass constraint (if mass[0]>0 the constraint is applied).
169 AliKFParticle::SetField(bzkG);
170 AliKFParticle *vertexKF=0;
173 Int_t nt=0,ntcheck=0;
175 Double_t pos[3]={0.,0.,0.};
176 if(!fOwnPrimaryVtx) {
177 printf("AliAODRecoDecayHF::ApplyVertexingKF(): cannot apply because primary vertex is not found\n");
180 fOwnPrimaryVtx->GetXYZ(pos);
181 Int_t contr=fOwnPrimaryVtx->GetNContributors();
182 Double_t covmatrix[6]={0.,0.,0.,0.,0.,0.};
183 fOwnPrimaryVtx->GetCovarianceMatrix(covmatrix);
184 Double_t chi2=fOwnPrimaryVtx->GetChi2();
185 AliESDVertex primaryVtx2(pos,covmatrix,chi2,contr,"Vertex");
189 copyKF=AliKFVertex(primaryVtx2);
190 nt=primaryVtx2.GetNContributors();
194 vertexKF = new AliKFParticle();
195 for(Int_t i= 0;i<nprongs;i++){
196 Int_t ipr=iprongs[i];
197 AliAODTrack *aodTrack = (AliAODTrack*)GetDaughter(ipr);
199 printf("AliAODRecoDecayHF::ApplyVertexingKF(): no daughters available\n");
200 delete vertexKF; vertexKF=NULL;
203 AliKFParticle daughterKF(*aodTrack,pdgs[i]);
204 vertexKF->AddDaughter(daughterKF);
206 if(topoCostraint && nt>0){
207 //Int_t index=(Int_t)GetProngID(ipr);
208 if(!aodTrack->GetUsedForPrimVtxFit()) continue;
209 copyKF -= daughterKF;
216 copyKF += (*vertexKF);
217 vertexKF->SetProductionVertex(copyKF);
222 vertexKF->SetMassConstraint(mass[0],mass[1]);