X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;ds=sidebyside;f=STEER%2FAliAODVertex.cxx;h=f9b25960b62ae4da28d4881a6855a2139afed52b;hb=1e122ba8ea49d0934052b7fba98235f2f440c60d;hp=822b6e8d564e4f35b91ea4ec60432e60b28f23cd;hpb=df9db588647be9607192b8513f9285e636ac1ebd;p=u%2Fmrichter%2FAliRoot.git diff --git a/STEER/AliAODVertex.cxx b/STEER/AliAODVertex.cxx index 822b6e8d564..f9b25960b62 100644 --- a/STEER/AliAODVertex.cxx +++ b/STEER/AliAODVertex.cxx @@ -20,21 +20,27 @@ // Base class for Analysis Object Data // Generic version // Author: Markus Oldenburg, CERN +// Inheritance from AliVVertex: A. Dainese //------------------------------------------------------------------------- #include "AliAODVertex.h" +#include "AliAODTrack.h" ClassImp(AliAODVertex) //______________________________________________________________________________ AliAODVertex::AliAODVertex() : - TObject(), - fCovMatrix(NULL), - fChi2(-999.), + AliVVertex(), + fChi2perNDF(-999.), + fID(-1), fType(kUndef), - fParent(0x0), - fDaughters() -{ + fNprong(0), + fIprong(0), + fCovMatrix(NULL), + fParent(), + fDaughters(), + fProngs(NULL) + { // default constructor fPosition[0] = fPosition[1] = fPosition[2] = -999.; @@ -42,72 +48,98 @@ AliAODVertex::AliAODVertex() : //______________________________________________________________________________ AliAODVertex::AliAODVertex(const Double_t position[3], - const Double_t covMatrix[6], - Double_t chi2, + const Double_t covMatrix[6], + Double_t chi2perNDF, TObject *parent, - Char_t vtype) : - TObject(), - fCovMatrix(NULL), - fChi2(chi2), + Short_t id, + Char_t vtype, + Int_t nprong) : + AliVVertex(), + fChi2perNDF(chi2perNDF), + fID(id), fType(vtype), + fNprong(nprong), + fIprong(0), + fCovMatrix(NULL), fParent(parent), - fDaughters() + fDaughters(), + fProngs(0) { // constructor SetPosition(position); if (covMatrix) SetCovMatrix(covMatrix); + MakeProngs(); } //______________________________________________________________________________ AliAODVertex::AliAODVertex(const Float_t position[3], const Float_t covMatrix[6], - Double_t chi2, + Double_t chi2perNDF, TObject *parent, - Char_t vtype) : - TObject(), - fCovMatrix(NULL), - fChi2(chi2), + Short_t id, + Char_t vtype, + Int_t nprong) : + + AliVVertex(), + fChi2perNDF(chi2perNDF), + fID(id), fType(vtype), + fNprong(nprong), + fIprong(0), + fCovMatrix(NULL), fParent(parent), - fDaughters() + fDaughters(), + fProngs(0) { // constructor SetPosition(position); if (covMatrix) SetCovMatrix(covMatrix); + MakeProngs(); } //______________________________________________________________________________ AliAODVertex::AliAODVertex(const Double_t position[3], - Double_t chi2, - Char_t vtype) : - TObject(), - fCovMatrix(NULL), - fChi2(chi2), + Double_t chi2perNDF, + Char_t vtype, + Int_t nprong) : + AliVVertex(), + fChi2perNDF(chi2perNDF), + fID(-1), fType(vtype), - fParent(0x0), - fDaughters() + fNprong(nprong), + fIprong(0), + fCovMatrix(NULL), + fParent(), + fDaughters(), + fProngs(0) { // constructor without covariance matrix SetPosition(position); + MakeProngs(); } //______________________________________________________________________________ AliAODVertex::AliAODVertex(const Float_t position[3], - Double_t chi2, - Char_t vtype) : - TObject(), - fCovMatrix(NULL), - fChi2(chi2), + Double_t chi2perNDF, + Char_t vtype, Int_t nprong) : + AliVVertex(), + fChi2perNDF(chi2perNDF), + fID(-1), fType(vtype), - fParent(0x0), - fDaughters() + fNprong(nprong), + fIprong(0), + fCovMatrix(NULL), + fParent(), + fDaughters(), + fProngs(0) { // constructor without covariance matrix SetPosition(position); + MakeProngs(); } //______________________________________________________________________________ @@ -116,23 +148,32 @@ AliAODVertex::~AliAODVertex() // Destructor delete fCovMatrix; + if (fNprong > 0) delete[] fProngs; } //______________________________________________________________________________ AliAODVertex::AliAODVertex(const AliAODVertex& vtx) : - TObject(vtx), - fCovMatrix(NULL), - fChi2(vtx.fChi2), + AliVVertex(vtx), + fChi2perNDF(vtx.fChi2perNDF), + fID(vtx.fID), fType(vtx.fType), + fNprong(vtx.fNprong), + fIprong(vtx.fIprong), + fCovMatrix(NULL), fParent(vtx.fParent), - fDaughters(vtx.fDaughters) + fDaughters(vtx.fDaughters), + fProngs(0) { // Copy constructor. for (int i = 0; i < 3; i++) fPosition[i] = vtx.fPosition[i]; - if (vtx.fCovMatrix) fCovMatrix=new AliAODVtxCov(*vtx.fCovMatrix); + if (vtx.fCovMatrix) fCovMatrix=new AliAODRedCov<3>(*vtx.fCovMatrix); + MakeProngs(); + for (int i = 0; i < fNprong; i++) { + fProngs[i] = vtx.fProngs[i]; + } } //______________________________________________________________________________ @@ -142,29 +183,57 @@ AliAODVertex& AliAODVertex::operator=(const AliAODVertex& vtx) if (this != &vtx) { // name and type - TObject::operator=(vtx); + AliVVertex::operator=(vtx); //momentum for (int i = 0; i < 3; i++) fPosition[i] = vtx.fPosition[i]; + fChi2perNDF = vtx.fChi2perNDF; + fID = vtx.fID; + fType = vtx.fType; + //covariance matrix delete fCovMatrix; - fCovMatrix = NULL; - - if (vtx.fCovMatrix) fCovMatrix=new AliAODVtxCov(*vtx.fCovMatrix); - + fCovMatrix = NULL; + if (vtx.fCovMatrix) fCovMatrix=new AliAODRedCov<3>(*vtx.fCovMatrix); //other stuff - fChi2 = vtx.fChi2; fParent = vtx.fParent; fDaughters = vtx.fDaughters; - fType = vtx.fType; + fNprong = vtx.fNprong; + fIprong = vtx.fIprong; + + MakeProngs(); + for (int i = 0; i < fNprong; i++) { + fProngs[i] = vtx.fProngs[i]; + } } return *this; } +//______________________________________________________________________________ +void AliAODVertex::AddDaughter(TObject *daughter) +{ + // Add reference to daughter track + if (!fProngs) { + if (fDaughters.GetEntries()==0) { + TRefArray* arr = &fDaughters; + new(arr)TRefArray(TProcessID::GetProcessWithUID(daughter)); + } + fDaughters.Add(daughter); + } else { + if (fIprong < fNprong) { + fProngs[fIprong++] = daughter; + } else { + AliWarning("Number of daughters out of range !\n"); + } + } + return; +} + + //______________________________________________________________________________ template void AliAODVertex::GetSigmaXYZ(T sigma[3]) const { @@ -186,15 +255,36 @@ template void AliAODVertex::GetSigmaXYZ(T sigma[3]) const } //______________________________________________________________________________ -Bool_t AliAODVertex::HasDaughter(TObject *daughter) const +Int_t AliAODVertex::GetNContributors() const { - // Checks if the given daughter (particle) is part of this vertex. + // Returns the number of tracks used to fit this vertex. + + Int_t cont = 0; - TRefArrayIter iter(&fDaughters); - while (TObject *daugh = iter.Next()) { - if (daugh == daughter) return kTRUE; + for (Int_t iDaug = 0; iDaug < GetNDaughters(); iDaug++) { + if (((AliAODTrack*)fDaughters.At(iDaug))->GetUsedForVtxFit()) cont++; } - return kFALSE; + + return cont; +} + +//______________________________________________________________________________ +Bool_t AliAODVertex::HasDaughter(TObject *daughter) const +{ + // Checks if the given daughter (particle) is part of this vertex. + if (!fProngs) { + TRefArrayIter iter(&fDaughters); + while (TObject *daugh = iter.Next()) { + if (daugh == daughter) return kTRUE; + } + return kFALSE; + } else { + Bool_t has = kFALSE; + for (int i = 0; i < fNprong; i++) { + if (fProngs[i].GetObject() == daughter) has = kTRUE; + } + return has; + } } //______________________________________________________________________________ @@ -418,7 +508,7 @@ void AliAODVertex::PhiAndThetaToVertex(AliAODVertex *vtx, P &phi, T &theta) cons // rotation angles around z-axis (phi) and around new y-axis (theta) // with which vtx is seen (used by RotatedCovMatrix... methods) - phi = TMath::ATan2(vtx->GetY()-GetY(),vtx->GetX()-GetX()); + phi = TMath::Pi()+TMath::ATan2(-vtx->GetY()+GetY(),-vtx->GetX()+GetX()); Double_t vtxxphi = vtx->GetX()*TMath::Cos(phi)+vtx->GetY()*TMath::Sin(phi); Double_t xphi = GetX()*TMath::Cos(phi)+GetY()*TMath::Sin(phi); theta = TMath::ATan2(vtx->GetZ()-GetZ(),vtxxphi-xphi); @@ -431,7 +521,7 @@ void AliAODVertex::PrintIndices() const TRefArrayIter iter(&fDaughters); while (TObject *daugh = iter.Next()) { - printf("Particle %p originates from this vertex.\n", daugh); + printf("Particle %p originates from this vertex.\n", static_cast(daugh)); } } @@ -444,7 +534,7 @@ void AliAODVertex::Print(Option_t* /*option*/) const printf(" x = %f\n", fPosition[0]); printf(" y = %f\n", fPosition[1]); printf(" z = %f\n", fPosition[2]); - printf(" parent particle: %p\n", fParent.GetObject()); + printf(" parent particle: %p\n", static_cast(fParent.GetObject())); printf(" origin of %d particles\n", fDaughters.GetEntriesFast()); printf(" vertex type %d\n", fType); @@ -462,48 +552,6 @@ void AliAODVertex::Print(Option_t* /*option*/) const fCovMatrix[4], fCovMatrix[5]); } */ - printf(" Chi^2 = %f\n", fChi2); + printf(" Chi^2/NDF = %f\n", fChi2perNDF); } -//------------------------------------------------------------------------- -// AOD track cov matrix base class -//------------------------------------------------------------------------- - -ClassImp(AliAODVertex::AliAODVtxCov) - -//______________________________________________________________________________ -template void AliAODVertex::AliAODVtxCov::GetCovMatrix(T *cmat) const -{ - // - // Returns the external cov matrix - // - cmat[ 0] = fDiag[ 0]*fDiag[ 0]; - cmat[ 2] = fDiag[ 1]*fDiag[ 1]; - cmat[ 5] = fDiag[ 2]*fDiag[ 2]; - - // - cmat[ 1] = fODia[ 0]*fDiag[ 0]*fDiag[ 1]; - cmat[ 3] = fODia[ 1]*fDiag[ 0]*fDiag[ 2]; - cmat[ 4] = fODia[ 2]*fDiag[ 1]*fDiag[ 2]; -} - - -//______________________________________________________________________________ -template void AliAODVertex::AliAODVtxCov::SetCovMatrix(T *cmat) -{ - // - // Sets the external cov matrix - // - if(cmat) { - fDiag[ 0] = TMath::Sqrt(cmat[ 0]); - fDiag[ 1] = TMath::Sqrt(cmat[ 2]); - fDiag[ 2] = TMath::Sqrt(cmat[ 5]); - // - fODia[ 0] = cmat[ 1]/(fDiag[ 0]*fDiag[ 1]); - fODia[ 1] = cmat[ 3]/(fDiag[ 0]*fDiag[ 2]); - fODia[ 2] = cmat[ 4]/(fDiag[ 1]*fDiag[ 2]); - } else { - for(Int_t i=0; i< 3; ++i) { - fDiag[i]=-999.; fODia[i]=0.;} - } -}