From 6516b62d14050353cbc6a3fcdd128de88700b2db Mon Sep 17 00:00:00 2001 From: nick Date: Fri, 18 Jan 2002 08:46:59 +0000 Subject: [PATCH] 01-dec-2001 NvE SetOwner() introduced for certain TObjArray's in AliCalcluster, AliEvent, AliInvmass, AliJet, AliTrack and AliVertex to adapt to the new memory management of ROOT 3.01 (and later) in case of reading trees. 06-dec-2001 NvE Memory usage optimised for AliVertex & co. and memory leak due to cloning solved. 07-dec-2001 NvE ClassDef() and ClassImp() statements introduced for AliSample. 17-dec-2001 NvE Copy constructor and Init() memberfunction introduced for AliTrack & co. 14-jan-2002 NvE New schema evolution activated via the "+" behind the classnames in RALICELinkDef.h. Note that the new schema evolution only works correctly for ROOT version 3.02/07 and later. --- RALICE/AliCalcluster.cxx | 22 ++-- RALICE/AliCalorimeter.cxx | 3 + RALICE/AliEvent.cxx | 14 +-- RALICE/AliInvmass.cxx | 16 +-- RALICE/AliJet.cxx | 48 ++++++--- RALICE/AliJet.h | 6 +- RALICE/AliSample.cxx | 4 +- RALICE/AliSample.h | 2 + RALICE/AliTrack.cxx | 110 ++++++++++++++++--- RALICE/AliTrack.h | 2 + RALICE/AliVertex.cxx | 220 +++++++++++++++++++++++++++++--------- RALICE/AliVertex.h | 5 + RALICE/RALICELinkDef.h | 38 +++---- RALICE/history.txt | 10 ++ 14 files changed, 380 insertions(+), 120 deletions(-) diff --git a/RALICE/AliCalcluster.cxx b/RALICE/AliCalcluster.cxx index 297cf1a46e5..9bba932a2fd 100644 --- a/RALICE/AliCalcluster.cxx +++ b/RALICE/AliCalcluster.cxx @@ -52,7 +52,6 @@ AliCalcluster::~AliCalcluster() // Destructor to delete dynamically allocated memory if (fVetos) { - fVetos->Delete(); delete fVetos; fVetos=0; } @@ -259,6 +258,7 @@ void AliCalcluster::AddVetoSignal(Float_t* r,TString f,Float_t s) { fNvetos=0; fVetos=new TObjArray(); + fVetos->SetOwner(); } fVetos->Add(new AliSignal(1)); @@ -278,17 +278,23 @@ AliSignal* AliCalcluster::GetVetoSignal(Int_t i) { // Provide access to the i-th veto signal of this cluster. // Note : The first hit corresponds to i=1. - - if (i>0 && i<=fNvetos) + if (!fVetos) { - return (AliSignal*)fVetos->At(i-1); + cout << " *AliCalcluster::GetVetoSignal* No veto signals present." << endl; + return 0; } else { - cout << " *AliCalcluster::GetVetoSignal* Signal number " << i - << " out of range." << endl; - cout << " --- First signal (if any) returned." << endl; - return (AliSignal*)fVetos->At(0); + if (i>0 && i<=fNvetos) + { + return (AliSignal*)fVetos->At(i-1); + } + else + { + cout << " *AliCalcluster::GetVetoSignal* Signal number " << i << " out of range." + << " Nvetos = " << fNvetos << endl; + return 0; + } } } /////////////////////////////////////////////////////////////////////////// diff --git a/RALICE/AliCalorimeter.cxx b/RALICE/AliCalorimeter.cxx index bc7218ae0fa..7ab5b1f36e9 100644 --- a/RALICE/AliCalorimeter.cxx +++ b/RALICE/AliCalorimeter.cxx @@ -178,6 +178,7 @@ AliCalorimeter::AliCalorimeter(Int_t nrow,Int_t ncol) } fModules=new TObjArray(); // Default size, expanded automatically + fModules->SetOwner(); fHmodules=0; fHclusters=0; @@ -732,6 +733,7 @@ void AliCalorimeter::Group(Int_t n) fClusters=0; } fClusters=new TObjArray(); + fClusters->SetOwner(); fNclusters=0; Int_t row=0; Int_t col=0; @@ -1064,6 +1066,7 @@ void AliCalorimeter::AddVetoSignal(Float_t* r,TString f,Float_t s) { fNvetos=0; fVetos=new TObjArray(); + fVetos->SetOwner(); } fVetos->Add(new AliSignal); diff --git a/RALICE/AliEvent.cxx b/RALICE/AliEvent.cxx index ba0dc900f25..5f4b8a6bdb8 100644 --- a/RALICE/AliEvent.cxx +++ b/RALICE/AliEvent.cxx @@ -13,7 +13,7 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ -// $Id: AliEvent.cxx,v 1.3 2001/07/04 15:59:20 nick Exp $ +// $Id: AliEvent.cxx,v 1.4 2001/07/06 09:30:59 nick Exp $ /////////////////////////////////////////////////////////////////////////// // Class AliEvent @@ -187,7 +187,7 @@ // Note : All quantities are in GeV, GeV/c or GeV/c**2 // //--- Author: Nick van Eijndhoven 27-may-2001 UU-SAP Utrecht -//- Modified: NvE $Date: 2001/07/04 15:59:20 $ UU-SAP Utrecht +//- Modified: NvE $Date: 2001/07/06 09:30:59 $ UU-SAP Utrecht /////////////////////////////////////////////////////////////////////////// #include "AliEvent.h" @@ -223,7 +223,6 @@ AliEvent::~AliEvent() // Default destructor if (fCalorimeters) { - if (fCalCopy) fCalorimeters->Delete(); delete fCalorimeters; fCalorimeters=0; } @@ -241,7 +240,6 @@ void AliEvent::Reset() fNcals=0; if (fCalorimeters) { - if (fCalCopy) fCalorimeters->Delete(); delete fCalorimeters; fCalorimeters=0; } @@ -325,13 +323,17 @@ Int_t AliEvent::GetNcalorimeters() void AliEvent::AddCalorimeter(AliCalorimeter& c) { // Add a calorimeter system to the event - if (!fCalorimeters) fCalorimeters=new TObjArray(); + if (!fCalorimeters) + { + fCalorimeters=new TObjArray(); + if (fCalCopy) fCalorimeters->SetOwner(); + } // Add the calorimeter system to this event fNcals++; if (fCalCopy) { - fCalorimeters->AddLast(c.Clone()); + fCalorimeters->AddLast((AliCalorimeter*)c.Clone()); } else { diff --git a/RALICE/AliInvmass.cxx b/RALICE/AliInvmass.cxx index a68812965ba..ecd0d0c6b8b 100644 --- a/RALICE/AliInvmass.cxx +++ b/RALICE/AliInvmass.cxx @@ -123,14 +123,12 @@ AliInvmass::~AliInvmass() // Destructor to delete dynamically allocated memory if (fMinv) { - fMinv->Delete(); delete fMinv; fMinv=0; } if (fMbkg) { - fMbkg->Delete(); delete fMbkg; fMbkg=0; } @@ -206,14 +204,12 @@ void AliInvmass::Combine(TObjArray* a1,TObjArray* a2) if ((!fBkg || fMode==1) && fMinv) { - fMinv->Delete(); delete fMinv; fMinv=0; } if (fBkg && (fMode !=1) && fMbkg) { - fMbkg->Delete(); delete fMbkg; fMbkg=0; } @@ -298,12 +294,20 @@ void AliInvmass::Combine(TObjArray* a1,TObjArray* a2) t->SetCharge(q1+q2); if (!fBkg || fMode==1) { - if (!fMinv) fMinv=new TObjArray(); + if (!fMinv) + { + fMinv=new TObjArray(); + fMinv->SetOwner(); + } fMinv->Add(t); } else { - if (!fMbkg) fMbkg=new TObjArray(); + if (!fMbkg) + { + fMbkg=new TObjArray(); + fMbkg->SetOwner(); + } fMbkg->Add(t); } } diff --git a/RALICE/AliJet.cxx b/RALICE/AliJet.cxx index ae492ff4c67..a59e90e736f 100644 --- a/RALICE/AliJet.cxx +++ b/RALICE/AliJet.cxx @@ -97,20 +97,24 @@ AliJet::AliJet() // Default constructor // All variables initialised to 0 // Initial maximum number of tracks is set to the default value + Init(); + Reset(); + SetNtinit(); +} +/////////////////////////////////////////////////////////////////////////// +void AliJet::Init() +{ +// Initialisation of pointers etc... fTracks=0; fNtinit=0; fTrackCopy=0; - Reset(); - SetNtinit(); } /////////////////////////////////////////////////////////////////////////// AliJet::AliJet(Int_t n) { // Create a jet to hold initially a maximum of n tracks // All variables initialised to 0 - fTracks=0; - fNtinit=0; - fTrackCopy=0; + Init(); Reset(); if (n > 0) { @@ -131,12 +135,28 @@ AliJet::~AliJet() // Default destructor if (fTracks) { - if (fTrackCopy) fTracks->Delete(); delete fTracks; fTracks=0; } } /////////////////////////////////////////////////////////////////////////// +AliJet::AliJet(AliJet& j) +{ +// Copy constructor + Init(); + Reset(); + SetNtinit(); + SetTrackCopy(j.GetTrackCopy()); + SetId(j.GetId()); + + AliTrack* tx=0; + for (Int_t i=1; i<=j.GetNtracks(); i++) + { + tx=j.GetTrack(i); + if (tx) AddTrack(tx); + } +} +/////////////////////////////////////////////////////////////////////////// void AliJet::SetNtinit(Int_t n) { // Set the initial maximum number of tracks for this jet @@ -144,7 +164,6 @@ void AliJet::SetNtinit(Int_t n) fNtmax=n; if (fTracks) { - if (fTrackCopy) fTracks->Delete(); delete fTracks; fTracks=0; } @@ -162,15 +181,18 @@ void AliJet::Reset() if (fNtinit > 0) SetNtinit(fNtinit); } /////////////////////////////////////////////////////////////////////////// -void AliJet::AddTrack(AliTrack& t) +void AliJet::AddTrack(AliTrack& t,Int_t copy) { // Add a track to the jet. -// Note : In case TrackCopy is set, the originally entered track -// will be automatically reset. +// Note : The optional parameter "copy" is for internal use only. // In case the maximum number of tracks has been reached // space will be extended to hold an additional amount of tracks as // was initially reserved. - if (!fTracks) fTracks=new TObjArray(fNtmax); + if (!fTracks) + { + fTracks=new TObjArray(fNtmax); + if (fTrackCopy) fTracks->SetOwner(); + } if (fNtrk == fNtmax) // Check if maximum track number is reached { fNtmax+=fNtinit; @@ -179,9 +201,9 @@ void AliJet::AddTrack(AliTrack& t) // Add the track to this jet fNtrk++; - if (fTrackCopy) + if (fTrackCopy && copy) { - fTracks->Add(t.Clone()); + fTracks->Add(new AliTrack(t)); } else { diff --git a/RALICE/AliJet.h b/RALICE/AliJet.h index 43d191059f7..a1ff2a96f14 100644 --- a/RALICE/AliJet.h +++ b/RALICE/AliJet.h @@ -20,9 +20,10 @@ class AliJet : public TObject,public Ali4Vector AliJet(); // Default constructor AliJet(Int_t n); // Create a Jet to hold initially n Tracks ~AliJet(); // Default destructor + AliJet(AliJet& j); // Copy constructor void Reset(); // Reset all values - virtual void AddTrack(AliTrack& t);// Add a track to the jet - virtual void AddTrack(AliTrack* t) { AddTrack(*t); } + void AddTrack(AliTrack& t,Int_t copy=1);// Add a track to the jet + void AddTrack(AliTrack* t,Int_t copy=1) { AddTrack(*t,copy); } void Info(TString f); // Print jet information in coordinate frame f void List(TString f="car"); // Print jet prim. track information for coord. frame f void ListAll(TString f="car"); // Print jet prim. and decay track information for coord. frame f @@ -46,6 +47,7 @@ class AliJet : public TObject,public Ali4Vector Int_t GetId(); // Provide the user defined identifier protected: + void Init(); // Initialisation of pointers etc... void SetNtinit(Int_t n=2); // Set the initial max. number of tracks for this Jet Int_t fNtinit; // The initial max. number of tracks for this jet Int_t fNtmax; // The maximum number of tracks for this Jet diff --git a/RALICE/AliSample.cxx b/RALICE/AliSample.cxx index 2670a940aed..9a591e24815 100644 --- a/RALICE/AliSample.cxx +++ b/RALICE/AliSample.cxx @@ -17,7 +17,7 @@ /////////////////////////////////////////////////////////////////////////// // Class AliSample -// Perform statistics on various multi-dimensional data samples +// Perform statistics on various multi-dimensional data samples. // A data sample can be filled using the "Enter" and/or "Remove" functions, // whereas the "Reset" function resets the complete sample to 'empty'. // The info which can be extracted from a certain data sample are the @@ -44,6 +44,8 @@ #include "AliSample.h" +ClassImp(AliSample) // Class implementation to enable ROOT I/O + AliSample::AliSample() { // Creation of an Aliample object and resetting the statistics values diff --git a/RALICE/AliSample.h b/RALICE/AliSample.h index 66bdd118d9a..1f30c3405ac 100644 --- a/RALICE/AliSample.h +++ b/RALICE/AliSample.h @@ -47,5 +47,7 @@ class AliSample Float_t fSigma[fMaxdim]; // Standard deviation for each variable Float_t fCov[fMaxdim][fMaxdim]; // Covariances of pairs of variables Float_t fCor[fMaxdim][fMaxdim]; // Correlations of pairs of variables + + ClassDef(AliSample,0) // Statistics tools for various multi-dimensional data samples. }; #endif diff --git a/RALICE/AliTrack.cxx b/RALICE/AliTrack.cxx index c38721eb21a..4a64ec553fd 100644 --- a/RALICE/AliTrack.cxx +++ b/RALICE/AliTrack.cxx @@ -97,12 +97,18 @@ AliTrack::AliTrack() { // Default constructor // All variables initialised to 0 + Init(); + Reset(); +} +/////////////////////////////////////////////////////////////////////////// +void AliTrack::Init() +{ +// Initialisation of pointers etc... fDecays=0; fSignals=0; fMasses=0; fDmasses=0; fPmasses=0; - Reset(); } /////////////////////////////////////////////////////////////////////////// AliTrack::~AliTrack() @@ -110,7 +116,6 @@ AliTrack::~AliTrack() // Destructor to delete memory allocated for decay tracks array if (fDecays) { - fDecays->Delete(); delete fDecays; fDecays=0; } @@ -122,6 +127,67 @@ AliTrack::~AliTrack() } } /////////////////////////////////////////////////////////////////////////// +AliTrack::AliTrack(AliTrack& t) +{ +// Copy constructor + Init(); + + fQ=t.GetCharge(); + fChi2=t.GetChi2(); + fNdf=t.GetNdf(); + fUserId=t.GetId(); + fNdec=t.GetNdecay(); + fNsig=t.GetNsignals(); + fNmasses=t.GetNMassHypotheses(); + Set4Momentum((Ali4Vector&)t); + fBegin=t.GetBeginPoint(); + fEnd=t.GetEndPoint(); + fImpactXY=t.GetImpactPoint("z"); + fImpactXZ=t.GetImpactPoint("y"); + fImpactYZ=t.GetImpactPoint("x"); + fClosest=t.GetClosestPoint(); + + AliTrack* tx; + if (fNdec) + { + fDecays=new TObjArray(fNdec); + fDecays->SetOwner(); + for (Int_t it=1; it<=fNdec; it++) + { + tx=t.GetDecayTrack(it); + fDecays->Add(new AliTrack(*tx)); + } + } + + AliSignal* sx; + if (fNsig) + { + fSignals=new TObjArray(fNsig); + for (Int_t is=1; is<=fNsig; is++) + { + sx=t.GetSignal(is); + fSignals->Add(sx); + } + } + + Double_t prob,m,dm; + if (fNmasses) + { + fMasses=new TArrayD(fNmasses); + fDmasses=new TArrayD(fNmasses); + fPmasses=new TArrayD(fNmasses); + for (Int_t ih=1; ih<=fNmasses; ih++) + { + prob=t.GetMassHypothesisProb(ih); + m=t.GetMassHypothesis(ih); + dm=t.GetResultError(); + fMasses->AddAt(m,ih-1); + fDmasses->AddAt(dm,ih-1); + fPmasses->AddAt(prob,ih-1); + } + } +} +/////////////////////////////////////////////////////////////////////////// void AliTrack::Reset() { // Reset all variables to 0 and delete all auto-generated decay tracks. @@ -136,7 +202,6 @@ void AliTrack::Reset() SetVector(a,"sph"); if (fDecays) { - fDecays->Delete(); delete fDecays; fDecays=0; } @@ -407,10 +472,11 @@ void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms) // Enter the boosted data into the decay tracks array if (fDecays) { - fDecays->Delete(); delete fDecays; + fDecays=0; } fDecays=new TObjArray(); + fDecays->SetOwner(); fDecays->Add(new AliTrack); ((AliTrack*)fDecays->At(0))->Set4Momentum(p1); @@ -430,15 +496,23 @@ AliTrack* AliTrack::GetDecayTrack(Int_t j) { // Provide decay produced track number j // Note : j=1 denotes the first decay track - if ((j >= 1) && (j <= fNdec)) + if (!fDecays) { - return (AliTrack*)fDecays->At(j-1); + cout << " *AliTrack::GetDecayTrack* No tracks present." << endl; + return 0; } else { - cout << " *AliTrack* decay track number : " << j << " out of range." << endl; - cout << " -- Decay track number 1 (if any) returned." << endl; - return (AliTrack*)fDecays->At(0); + if ((j >= 1) && (j <= fNdec)) + { + return (AliTrack*)fDecays->At(j-1); + } + else + { + cout << " *AliTrack* decay track number : " << j << " out of range." + << " Ndec = " << fNdec << endl; + return 0; + } } } /////////////////////////////////////////////////////////////////////////// @@ -474,15 +548,23 @@ AliSignal* AliTrack::GetSignal(Int_t j) { // Provide the related AliSignal number j. // Note : j=1 denotes the first signal. - if ((j >= 1) && (j <= fNsig)) + if (!fSignals) { - return (AliSignal*)fSignals->At(j-1); + cout << " *AliTrack::GetSignal* No signals present." << endl; + return 0; } else { - cout << " *AliTrack* signal number : " << j << " out of range." << endl; - cout << " -- Signal number 1 (if any) returned." << endl; - return (AliSignal*)fDecays->At(0); + if ((j >= 1) && (j <= fNsig)) + { + return (AliSignal*)fSignals->At(j-1); + } + else + { + cout << " *AliTrack* signal number : " << j << " out of range." + << " Nsig = " << fNsig << endl; + return 0; + } } } /////////////////////////////////////////////////////////////////////////// diff --git a/RALICE/AliTrack.h b/RALICE/AliTrack.h index 77f8298b61d..09c8445b31f 100644 --- a/RALICE/AliTrack.h +++ b/RALICE/AliTrack.h @@ -20,6 +20,7 @@ class AliTrack : public TObject,public Ali4Vector public: AliTrack(); // Default constructor ~AliTrack(); // Destructor + AliTrack(AliTrack& t); // Copy constructor void Reset(); // Reset all values to 0 void Set4Momentum(Ali4Vector& p); // Set track 4-momentum void Set3Momentum(Ali3Vector& p); // Set track 3-momentum @@ -70,6 +71,7 @@ class AliTrack : public TObject,public Ali4Vector protected: + void Init(); // Initialisation of pointers etc... Float_t fQ; // The charge of the particle Int_t fNdec; // The number of decay products TObjArray* fDecays; // The array of decay produced tracks diff --git a/RALICE/AliVertex.cxx b/RALICE/AliVertex.cxx index 8ee85692029..b8d1bc7442e 100644 --- a/RALICE/AliVertex.cxx +++ b/RALICE/AliVertex.cxx @@ -151,30 +151,32 @@ AliVertex::AliVertex() // All variables initialised to 0. // Initial maximum number of tracks is set to the default value. // Initial maximum number of sec. vertices is set to the default value. - fNvmax=0; - fVertices=0; - fConnects=0; - fVertexCopy=0; - fNjmax=0; - fJets=0; - fJetCopy=0; + Init(); Reset(); SetNtinit(); SetNvmax(); SetNjmax(); } /////////////////////////////////////////////////////////////////////////// -AliVertex::AliVertex(Int_t n) +void AliVertex::Init() { -// Create a vertex to hold initially a maximum of n tracks -// All variables initialised to 0 +// Initialisation of pointers etc... + AliJet::Init(); fNvmax=0; fVertices=0; fConnects=0; fVertexCopy=0; fNjmax=0; fJets=0; + fJetTracks=0; fJetCopy=0; +} +/////////////////////////////////////////////////////////////////////////// +AliVertex::AliVertex(Int_t n) +{ +// Create a vertex to hold initially a maximum of n tracks +// All variables initialised to 0 + Init(); Reset(); if (n > 0) { @@ -197,22 +199,97 @@ AliVertex::~AliVertex() // Default destructor if (fVertices) { - if (fVertexCopy) fVertices->Delete(); delete fVertices; fVertices=0; } if (fConnects) { - fConnects->Delete(); delete fConnects; fConnects=0; } if (fJets) { - if (fJetCopy) fJets->Delete(); delete fJets; fJets=0; } + if (fJetTracks) + { + delete fJetTracks; + fJetTracks=0; + } +} +/////////////////////////////////////////////////////////////////////////// +AliVertex::AliVertex(AliVertex& v) +{ +// Copy constructor + Init(); + Reset(); + SetNtinit(); + SetNvmax(); + SetNjmax(); + SetTrackCopy(v.GetTrackCopy()); + SetVertexCopy(v.GetVertexCopy()); + SetJetCopy(v.GetJetCopy()); + SetId(v.GetId()); + SetPosition(v.GetPosition()); + + // Copy all tracks except the ones coming from jets + AliTrack* tx=0; + Int_t jetflag=0,connect=0; + AliTrack* tx2=0; + for (Int_t it=1; it<=v.GetNtracks(); it++) + { + tx=v.GetTrack(it); + if (tx) + { + jetflag=v.IsJetTrack(tx); + connect=v.IsConnectTrack(tx); + + if (!jetflag && !connect) AddTrack(tx); + + if (connect) + { + if (!fConnects) + { + fConnects=new TObjArray(fNvmax); + if (!fTrackCopy) fConnects->SetOwner(); + } + tx2=new AliTrack(*tx); + fConnects->Add(tx2); + AddTrack(tx2,0); + } + } + } + + // Copy all the (secondary) vertices without re-creating connecting tracks + // The connecting tracks have already been copied above + AliVertex* vx=0; + for (Int_t iv=1; iv<=v.GetNvertices(); iv++) + { + vx=v.GetVertex(iv); + if (vx) AddVertex(vx,0); + } + + // Copy all the jets including the jet tracks for these jets for which + // this was also the case in the original vertex + AliJet* jx=0; + for (Int_t ij=1; ij<=v.GetNjets(); ij++) + { + jx=v.GetJet(ij); + if (jx) + { + jetflag=0; + if (jx->GetNtracks()) + { + tx=jx->GetTrack(1); + if (tx) + { + jetflag=v.IsJetTrack(tx); + } + } + AddJet(jx,jetflag); + } + } } /////////////////////////////////////////////////////////////////////////// void AliVertex::SetNvmax(Int_t n) @@ -228,7 +305,6 @@ void AliVertex::SetNvmax(Int_t n) } if (fVertices) { - if (fVertexCopy) fVertices->Delete(); delete fVertices; fVertices=0; } @@ -247,7 +323,6 @@ void AliVertex::SetNjmax(Int_t n) } if (fJets) { - if (fJetCopy) fJets->Delete(); delete fJets; fJets=0; } @@ -270,13 +345,17 @@ void AliVertex::Reset() if (fNvmax>0) SetNvmax(fNvmax); if (fConnects) { - fConnects->Delete(); delete fConnects; fConnects=0; } fNjets=0; if (fNjmax>0) SetNjmax(fNjmax); + if (fJetTracks) + { + delete fJetTracks; + fJetTracks=0; + } } /////////////////////////////////////////////////////////////////////////// void AliVertex::ResetVertices() @@ -298,6 +377,7 @@ void AliVertex::ResetVertices() fNtrk--; (Ali4Vector&)(*this)-=(Ali4Vector&)(*t); fQ-=t->GetCharge(); + if (fTrackCopy) delete t; } } fTracks->Compress(); @@ -307,7 +387,6 @@ void AliVertex::ResetVertices() if (fNvmax>0) SetNvmax(fNvmax); if (fConnects) { - fConnects->Delete(); delete fConnects; fConnects=0; } @@ -326,7 +405,11 @@ void AliVertex::AddJet(AliJet& j,Int_t tracks) // be stored according to the mode specified by SetJetCopy(). // The latter will enable jet studies based on a fixed list of tracks // as contained e.g. in an AliVertex or AliEvent. - if (!fJets) fJets=new TObjArray(fNjmax); + if (!fJets) + { + fJets=new TObjArray(fNjmax); + if (fJetCopy) fJets->SetOwner(); + } if (fNjets == fNjmax) // Check if maximum jet number is reached { fNjmax++; @@ -334,24 +417,32 @@ void AliVertex::AddJet(AliJet& j,Int_t tracks) } // Add the jet to the list - fNjets++; - if (fJetCopy) - { - fJets->Add(j.Clone()); - } - else + AliJet* jx=&j; + if (fJetCopy) jx=new AliJet(j); + + if (jx) { - fJets->Add(&j); + fNjets++; + fJets->Add(jx); } // Add the tracks of the jet to this vertex if (tracks) { + if (!fJetTracks) + { + fJetTracks=new TObjArray(); + } + Int_t copy=1-(jx->GetTrackCopy()); AliTrack* tj; - for (Int_t i=1; i<=j.GetNtracks(); i++) + for (Int_t i=1; i<=jx->GetNtracks(); i++) { - tj=j.GetTrack(i); - AddTrack(tj); + tj=jx->GetTrack(i); + if (tj) + { + AddTrack(tj,copy); + fJetTracks->Add(tj); + } } } } @@ -372,7 +463,11 @@ void AliVertex::AddVertex(AliVertex& v,Int_t connect) // has to introduce the connecting track lateron by hand // explicitly in order to match the kinematics and charge. // - if (!fVertices) fVertices=new TObjArray(fNvmax); + if (!fVertices) + { + fVertices=new TObjArray(fNvmax); + if (fVertexCopy) fVertices->SetOwner(); + } if (fNvtx == fNvmax) // Check if maximum vertex number is reached { fNvmax++; @@ -380,36 +475,31 @@ void AliVertex::AddVertex(AliVertex& v,Int_t connect) } // Add the linked (secondary) vertex to the list - fNvtx++; - if (fVertexCopy) - { - fVertices->Add(v.Clone()); - } - else + AliVertex* vx=&v; + if (fVertexCopy) vx=new AliVertex(v); + + if (vx) { - fVertices->Add(&v); - } + fNvtx++; + fVertices->Add(vx); + } // Create connecting track and update 4-momentum and charge for current vertex if (connect) { - AliPosition r1=GetPosition(); - AliPosition r2=v.GetPosition(); - Float_t q=v.GetCharge(); - Ali3Vector p=v.Get3Momentum(); - Double_t v2=v.GetInvariant(); - Double_t dv2=v.Ali4Vector::GetResultError(); - AliTrack* t=new AliTrack(); - t->SetBeginPoint(r1); - t->SetEndPoint(r2); - t->SetCharge(q); - t->Set3Momentum(p); - t->SetInvariant(v2,dv2); + t->SetBeginPoint(GetPosition()); + t->SetEndPoint(v.GetPosition()); + t->SetCharge(v.GetCharge()); + t->Set4Momentum((Ali4Vector&)v); - AddTrack(t); + AddTrack(t,0); - if (!fConnects) fConnects=new TObjArray(fNvmax); + if (!fConnects) + { + fConnects=new TObjArray(fNvmax); + if (!fTrackCopy) fConnects->SetOwner(); + } fConnects->Add(t); } } @@ -707,3 +797,31 @@ Int_t AliVertex::GetJetCopy() return fJetCopy; } /////////////////////////////////////////////////////////////////////////// +Int_t AliVertex::IsConnectTrack(AliTrack* t) +{ +// Indicate whether a track from the tracklist was created via the +// connection of a (secondary) vertex or not. +// In case the track was the result of (secondary) vertex addition the +// return value is 1, otherwise the value 0 will be returned. + Int_t connect=0; + if (fConnects) + { + if (fConnects->FindObject(t)) connect=1; + } + return connect; +} +/////////////////////////////////////////////////////////////////////////// +Int_t AliVertex::IsJetTrack(AliTrack* t) +{ +// Indicate whether a track from the tracklist was created via the +// addition of a jet or not. +// In case the track was the result of jet addition the return value is 1, +// otherwise the value 0 will be returned. + Int_t jetflag=0; + if (fJetTracks) + { + if (fJetTracks->FindObject(t)) jetflag=1; + } + return jetflag; +} +/////////////////////////////////////////////////////////////////////////// diff --git a/RALICE/AliVertex.h b/RALICE/AliVertex.h index 57507546b1a..779882e39a8 100644 --- a/RALICE/AliVertex.h +++ b/RALICE/AliVertex.h @@ -20,6 +20,7 @@ class AliVertex : public AliJet,public AliPosition AliVertex(); // Default constructor AliVertex(Int_t n); // Create a vertex to hold initially n tracks ~AliVertex(); // Default destructor + AliVertex(AliVertex& v); // Copy constructor void Reset(); // Reset all values and stored vertex and jet lists void ResetVertices(); // Reset stored vertex list void AddJet(AliJet& j,Int_t tracks=1); // Add a jet (and its tracks) to the vertex @@ -41,8 +42,11 @@ class AliVertex : public AliJet,public AliPosition void SetNjmax(Int_t n=2); // Set the initial max. number of jets void SetJetCopy(Int_t j); // (De)activate creation of private copies in fJets Int_t GetJetCopy(); // Provide JetCopy flag value + Int_t IsConnectTrack(AliTrack* t); // Indicate if track is created by vertex connection + Int_t IsJetTrack(AliTrack* t); // Indicate if track is resulting from jet addition protected: + void Init(); // Initialisation of pointers etc... Int_t fNvmax; // The maximum number of (secondary) vertices Int_t fNvtx; // The number of (secondary) vertices TObjArray* fVertices; // Array to hold the pointers to the (secondary) vertices @@ -51,6 +55,7 @@ class AliVertex : public AliJet,public AliPosition Int_t fNjmax; // The maximum number of jets Int_t fNjets; // The number of jets TObjArray* fJets; // Array to hold the pointers to the jets + TObjArray* fJetTracks;// Array to hold the pointers to tracks introduced by jet addition Int_t fJetCopy; // Flag to denote creation of private copies in fJets private: diff --git a/RALICE/RALICELinkDef.h b/RALICE/RALICELinkDef.h index dbe623429a1..f00c8ee124a 100644 --- a/RALICE/RALICELinkDef.h +++ b/RALICE/RALICELinkDef.h @@ -14,24 +14,24 @@ #pragma link off all classes; #pragma link off all functions; - #pragma link C++ class AliMath; - #pragma link C++ class AliSample; - #pragma link C++ class AliRandom; - #pragma link C++ class Ali3Vector; - #pragma link C++ class Ali3VectorObj; - #pragma link C++ class Ali4Vector; - #pragma link C++ class Ali4VectorObj; - #pragma link C++ class AliBoost; - #pragma link C++ class AliPosition; - #pragma link C++ class AliPositionObj; - #pragma link C++ class AliSignal; - #pragma link C++ class AliCalorimeter; - #pragma link C++ class AliCalmodule; - #pragma link C++ class AliCalcluster; - #pragma link C++ class AliTrack; - #pragma link C++ class AliJet; - #pragma link C++ class AliVertex; - #pragma link C++ class AliInvmass; - #pragma link C++ class AliEvent; + #pragma link C++ class AliMath+; + #pragma link C++ class AliSample+; + #pragma link C++ class AliRandom+; + #pragma link C++ class Ali3Vector+; + #pragma link C++ class Ali3VectorObj+; + #pragma link C++ class Ali4Vector+; + #pragma link C++ class Ali4VectorObj+; + #pragma link C++ class AliBoost+; + #pragma link C++ class AliPosition+; + #pragma link C++ class AliPositionObj+; + #pragma link C++ class AliSignal+; + #pragma link C++ class AliCalorimeter+; + #pragma link C++ class AliCalmodule+; + #pragma link C++ class AliCalcluster+; + #pragma link C++ class AliTrack+; + #pragma link C++ class AliJet+; + #pragma link C++ class AliVertex+; + #pragma link C++ class AliInvmass+; + #pragma link C++ class AliEvent+; #endif diff --git a/RALICE/history.txt b/RALICE/history.txt index 07cd44e5d2d..5b043f2b53a 100644 --- a/RALICE/history.txt +++ b/RALICE/history.txt @@ -290,3 +290,13 @@ 12-jul-2001 NvE Memberfunction GetDistance() introduced for AliPosition and support for point of closest approach introduced in AliTrack. 24-jul-2001 NvE Support for Chi2 and NDF information of track fit introduced in AliTrack. +01-dec-2001 NvE SetOwner() introduced for certain TObjArray's in AliCalcluster, AliEvent, + AliInvmass, AliJet, AliTrack and AliVertex to adapt to the new memory + management of ROOT 3.01 (and later) in case of reading trees. +06-dec-2001 NvE Memory usage optimised for AliVertex & co. and memory leak due to + cloning solved. +07-dec-2001 NvE ClassDef() and ClassImp() statements introduced for AliSample. +17-dec-2001 NvE Copy constructor and Init() memberfunction introduced for AliTrack & co. +14-jan-2002 NvE New schema evolution activated via the "+" behind the classnames + in RALICELinkDef.h. Note that the new schema evolution only works + correctly for ROOT version 3.02/07 and later. -- 2.43.0