From bca58dd7400168cd59c5e79c1a9d842fb081359e Mon Sep 17 00:00:00 2001 From: morsch Date: Fri, 9 Jan 2009 07:44:58 +0000 Subject: [PATCH] Array of TRefs for n-prong vertices built in separate reconstruction passes (processes). --- STEER/AliAODVertex.cxx | 97 ++++++++++++++++++++++++++++++++---------- STEER/AliAODVertex.h | 54 ++++++++++++++++++----- 2 files changed, 117 insertions(+), 34 deletions(-) diff --git a/STEER/AliAODVertex.cxx b/STEER/AliAODVertex.cxx index b9b3d8bb09d..ac908fc4330 100644 --- a/STEER/AliAODVertex.cxx +++ b/STEER/AliAODVertex.cxx @@ -34,9 +34,12 @@ AliAODVertex::AliAODVertex() : fChi2perNDF(-999.), fID(-1), fType(kUndef), + fNprong(0), + fIprong(0), fCovMatrix(NULL), fParent(), - fDaughters() + fDaughters(), + fProngs(NULL) { // default constructor @@ -49,19 +52,24 @@ AliAODVertex::AliAODVertex(const Double_t position[3], Double_t chi2perNDF, TObject *parent, Short_t id, - Char_t vtype) : + 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(); } //______________________________________________________________________________ @@ -70,54 +78,68 @@ AliAODVertex::AliAODVertex(const Float_t position[3], Double_t chi2perNDF, TObject *parent, Short_t id, - Char_t vtype) : + 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 chi2perNDF, - Char_t vtype) : + Char_t vtype, + Int_t nprong) : AliVVertex(), fChi2perNDF(chi2perNDF), fID(-1), fType(vtype), + fNprong(nprong), + fIprong(0), fCovMatrix(NULL), fParent(), - fDaughters() + fDaughters(), + fProngs(0) { // constructor without covariance matrix SetPosition(position); + MakeProngs(); } //______________________________________________________________________________ AliAODVertex::AliAODVertex(const Float_t position[3], Double_t chi2perNDF, - Char_t vtype) : + Char_t vtype, Int_t nprong) : AliVVertex(), fChi2perNDF(chi2perNDF), fID(-1), fType(vtype), + fNprong(nprong), + fIprong(0), fCovMatrix(NULL), fParent(), - fDaughters() + fDaughters(), + fProngs(0) { // constructor without covariance matrix SetPosition(position); + MakeProngs(); } //______________________________________________________________________________ @@ -126,6 +148,7 @@ AliAODVertex::~AliAODVertex() // Destructor delete fCovMatrix; + if (fNprong > 0) delete[] fProngs; } //______________________________________________________________________________ @@ -134,9 +157,12 @@ AliAODVertex::AliAODVertex(const AliAODVertex& 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. @@ -144,6 +170,10 @@ AliAODVertex::AliAODVertex(const AliAODVertex& vtx) : fPosition[i] = vtx.fPosition[i]; if (vtx.fCovMatrix) fCovMatrix=new AliAODRedCov<3>(*vtx.fCovMatrix); + MakeProngs(); + for (int i = 0; i < fNprong; i++) { + fProngs[i] = vtx.fProngs[i]; + } } //______________________________________________________________________________ @@ -171,6 +201,13 @@ AliAODVertex& AliAODVertex::operator=(const AliAODVertex& vtx) //other stuff fParent = vtx.fParent; fDaughters = vtx.fDaughters; + fNprong = vtx.fNprong; + fIprong = vtx.fIprong; + + MakeProngs(); + for (int i = 0; i < fNprong; i++) { + fProngs[i] = vtx.fProngs[i]; + } } return *this; @@ -180,16 +217,23 @@ AliAODVertex& AliAODVertex::operator=(const AliAODVertex& vtx) void AliAODVertex::AddDaughter(TObject *daughter) { // Add reference to daughter track - - if (fDaughters.GetEntries()==0) { - TRefArray* arr = &fDaughters; - new(arr)TRefArray(TProcessID::GetProcessWithUID(daughter)); - } - fDaughters.Add(daughter); - + 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 { @@ -228,12 +272,19 @@ Int_t AliAODVertex::GetNContributors() const Bool_t AliAODVertex::HasDaughter(TObject *daughter) const { // Checks if the given daughter (particle) is part of this vertex. - - TRefArrayIter iter(&fDaughters); - while (TObject *daugh = iter.Next()) { - if (daugh == daughter) return kTRUE; - } - return kFALSE; + 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; i < fNprong; i++) { + if (fProngs[i].GetObject() == daughter) has = kTRUE; + } + return has; + } } //______________________________________________________________________________ diff --git a/STEER/AliAODVertex.h b/STEER/AliAODVertex.h index 4133ac3f85e..04317be52fd 100644 --- a/STEER/AliAODVertex.h +++ b/STEER/AliAODVertex.h @@ -17,6 +17,7 @@ #include "AliVVertex.h" #include "AliAODRedCov.h" +#include "AliLog.h" class AliAODVertex : public AliVVertex { @@ -30,19 +31,23 @@ class AliAODVertex : public AliVVertex { Double_t chi2perNDF = -999., TObject *parent = 0x0, Short_t id=-1, - Char_t vtype=kUndef); + Char_t vtype=kUndef, + Int_t nprong = 0); AliAODVertex(const Float_t *position, const Float_t *covMatrix=0x0, Double_t chi2perNDF = -999., TObject *parent = 0x0, Short_t id=-1, - Char_t vtype=kUndef); + Char_t vtype=kUndef, + Int_t nprong = 0); AliAODVertex(const Double_t *position, Double_t chi2perNDF, - Char_t vtype=kUndef); + Char_t vtype=kUndef, + Int_t nprong = 0); AliAODVertex(const Float_t *position, Double_t chi2perNDF, - Char_t vtype=kUndef); + Char_t vtype=kUndef, + Int_t nprong = 0); virtual ~AliAODVertex(); AliAODVertex(const AliAODVertex& vtx); @@ -97,9 +102,9 @@ class AliAODVertex : public AliVVertex { void AddDaughter(TObject *daughter); void RemoveDaughter(TObject *daughter) { fDaughters.Remove(daughter); } void RemoveDaughters() { fDaughters.Clear(); } - TObject* GetDaughter(Int_t i) { return fDaughters.At(i); } + TObject* GetDaughter(Int_t i); Bool_t HasDaughter(TObject *daughter) const; - Int_t GetNDaughters() const { return fDaughters.GetEntriesFast(); } + Int_t GetNDaughters() const; Int_t GetNContributors() const; // covariance matrix elements after rotation by phi around z-axis @@ -119,19 +124,46 @@ class AliAODVertex : public AliVVertex { void PrintIndices() const; void Print(Option_t* option = "") const; - - private : + private: + void MakeProngs() {if (fNprong > 0) fProngs = new TRef[fNprong];} + + private: Double32_t fPosition[3]; // vertex position Double32_t fChi2perNDF; // chi2/NDF of vertex fit Short_t fID; // vertex ID; corresponds to the array index of the appropriate ESD container Char_t fType; // vertex type - + Int_t fNprong; // number of prongs + Int_t fIprong; //!index of prong AliAODRedCov<3> *fCovMatrix; // vertex covariance matrix; values of and below the diagonal TRef fParent; // reference to the parent particle TRefArray fDaughters; // references to the daughter particles - - ClassDef(AliAODVertex,4); + TRef *fProngs; //[fNprong] alternative daughters for n-prong vertex + + ClassDef(AliAODVertex, 5); }; +inline Int_t AliAODVertex::GetNDaughters() const +{ + if (!fProngs) { + return fDaughters.GetEntriesFast(); + } else { + return fNprong; + } +} + +inline TObject* AliAODVertex::GetDaughter(Int_t i) +{ + if (!fProngs) { + return fDaughters.At(i); + } else { + if (i < fNprong) { + return fProngs[i].GetObject(); + } else { + AliWarning("Daughter index out of range !\n"); + return 0; + } + } +} + #endif -- 2.43.0