From 35044448b3b932262528667636bc6ae32d5e374a Mon Sep 17 00:00:00 2001 From: nick Date: Fri, 6 Jul 2001 09:30:59 +0000 Subject: [PATCH] 05-jul-2001 NvE Clone() facility used in AddTrack() etc... of AliEvent & co. instead of "new" in the case of TrackCopy etc... This in order to enable 'permanent' AliTrack etc... storage in AliEvent & co. Also (Ali4Vector&) casting stmt. in AliVertex::ResetVertices() changed to make it ANSI compatible for all compilers/platforms. --- RALICE/AliEvent.cxx | 55 ++++++++++++++++++++++++++------------------ RALICE/AliJet.cxx | 14 +++++++---- RALICE/AliTrack.cxx | 2 +- RALICE/AliVertex.cxx | 34 ++++++++++++--------------- RALICE/history.txt | 5 ++++ 5 files changed, 64 insertions(+), 46 deletions(-) diff --git a/RALICE/AliEvent.cxx b/RALICE/AliEvent.cxx index 139bdaf0313..ba0dc900f25 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.2 2001/06/25 09:37:23 hristov Exp $ +// $Id: AliEvent.cxx,v 1.3 2001/07/04 15:59:20 nick Exp $ /////////////////////////////////////////////////////////////////////////// // Class AliEvent @@ -22,8 +22,8 @@ // and/or AliCalorimeters. // // The basic functionality of AliEvent is identical to the one of AliVertex. -// So, an AliEvent may be regarded as the primary vertex with some -// additional functionality compared to AliVertex. +// So, an AliEvent may be used as the primary vertex with some additional +// functionality compared to AliVertex. // // To provide maximal flexibility to the user, the two modes of track/jet/vertex // storage as described in AliJet and AliVertex can be used. @@ -37,8 +37,11 @@ // file/tree. // In this way the AliEvent just represents a 'logical structure' for the // physics analysis. +// +// Note : // Modifications made to the original calorimeters also affect the AliCalorimeter // objects which are stored in the AliEvent. +// // b) SetCalCopy(1). // Of every 'added' calorimeter a private copy will be made of which the pointer // will be stored. @@ -56,11 +59,6 @@ // v1 contains the tracks 5,6 and 7 (sec. vertex) // v2 contains the jets 1 and 2 (sec. vertex) // -// AliCalorimeter emcal; -// ... -// ... // code to fill the calorimeter data -// ... -// // AliEvent evt; // // Specify the event object as the repository of all objects @@ -71,9 +69,14 @@ // // Fill the event structure with the basic objects // +// AliCalorimeter emcal; +// ... +// ... // code to fill the calorimeter data +// ... +// // evt.AddCalorimeter(emcal); // -// AliTrack* tx; +// AliTrack* tx=new AliTrack(); // for (Int_t i=0; i<10; i++) // { // ... @@ -83,6 +86,12 @@ // tx->Reset(); // } // +// if (tx) +// { +// delete tx; +// tx=0; +// } +// // Build the event structure (vertices, jets, ...) for physics analysis // based on the basic objects from the event repository. // @@ -96,24 +105,24 @@ // } // // AliVertex vp; -// tx=evt.GetTrack(1) +// tx=evt.GetTrack(1); // vp.AddTrack(tx); -// tx=evt.GetTrack(2) +// tx=evt.GetTrack(2); // vp.AddTrack(tx); -// tx=evt.GetTrack(3) +// tx=evt.GetTrack(3); // vp.AddTrack(tx); -// tx=evt.GetTrack(4) +// tx=evt.GetTrack(4); // vp.AddTrack(tx); // // Float_t rp[3]={2.4,0.1,-8.5}; // vp.SetPosition(rp,"car"); // // AliVertex v1; -// tx=evt.GetTrack(5) +// tx=evt.GetTrack(5); // v1.AddTrack(tx); -// tx=evt.GetTrack(6) +// tx=evt.GetTrack(6); // v1.AddTrack(tx); -// tx=evt.GetTrack(7) +// tx=evt.GetTrack(7); // v1.AddTrack(tx); // // Float_t r1[3]={1.6,-3.2,5.7}; @@ -178,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/06/25 09:37:23 $ UU-SAP Utrecht +//- Modified: NvE $Date: 2001/07/04 15:59:20 $ UU-SAP Utrecht /////////////////////////////////////////////////////////////////////////// #include "AliEvent.h" @@ -295,7 +304,7 @@ void AliEvent::HeaderInfo() cout << " *AliEvent::Info* Run : " << fRun << " Event : " << fEvent; cout.fill('0'); cout << " Date : " << setw(2) << day << "-" << c[month-1] << "-" << year - << " Time : " << setw(2) << hh << ":" << setw(2) << mm << ":" << setw(2) << ss << endl; + << " Time : " << setw(2) << hh << ":" << setw(2) << mm << ":" << setw(2) << ss; cout.fill(' '); cout << " Ncalorimeters : " << fNcals << endl; } @@ -322,8 +331,7 @@ void AliEvent::AddCalorimeter(AliCalorimeter& c) fNcals++; if (fCalCopy) { - AliCalorimeter* cx=new AliCalorimeter(c); - fCalorimeters->AddLast(cx); + fCalorimeters->AddLast(c.Clone()); } else { @@ -405,8 +413,11 @@ AliCalorimeter* AliEvent::GetCalorimeter(TString name) for (Int_t i=0; iAt(i); - s=cx->GetName(); - if (s == name) return cx; + if (cx) + { + s=cx->GetName(); + if (s == name) return cx; + } } return 0; // No matching name found diff --git a/RALICE/AliJet.cxx b/RALICE/AliJet.cxx index 6a22c617d0d..e6675842387 100644 --- a/RALICE/AliJet.cxx +++ b/RALICE/AliJet.cxx @@ -30,8 +30,11 @@ // in an AliEvent. // In this way the AliJet just represents a 'logical structure' for the // physics analysis which can be embedded in e.g. an AliEvent or AliVertex. +// +// Note : // Modifications made to the original tracks also affect the AliTrack objects // which are stored in the AliJet. +// // b) SetTrackCopy(1). // Of every 'added' track a private copy will be made of which the pointer // will be stored. @@ -160,10 +163,12 @@ void AliJet::Reset() /////////////////////////////////////////////////////////////////////////// void AliJet::AddTrack(AliTrack& t) { -// Add a track to the jet +// Add a track to the jet. +// Note : In case TrackCopy is set, the originally entered track +// will be automatically reset. // 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 +// was initially reserved. if (!fTracks) fTracks=new TObjArray(fNtmax); if (fNtrk == fNtmax) // Check if maximum track number is reached { @@ -175,15 +180,16 @@ void AliJet::AddTrack(AliTrack& t) fNtrk++; if (fTrackCopy) { - AliTrack* tx=new AliTrack(t); - fTracks->Add(tx); + fTracks->Add(t.Clone()); } else { fTracks->Add(&t); } + (*this)+=(Ali4Vector&)t; fQ+=t.GetCharge(); + } /////////////////////////////////////////////////////////////////////////// void AliJet::Info(TString f) diff --git a/RALICE/AliTrack.cxx b/RALICE/AliTrack.cxx index 191300dec63..9b76f1c9775 100644 --- a/RALICE/AliTrack.cxx +++ b/RALICE/AliTrack.cxx @@ -124,7 +124,7 @@ AliTrack::~AliTrack() /////////////////////////////////////////////////////////////////////////// void AliTrack::Reset() { -// Reset all variables to 0 +// Reset all variables to 0 and delete all auto-generated decay tracks. fQ=0; fNdec=0; fNsig=0; diff --git a/RALICE/AliVertex.cxx b/RALICE/AliVertex.cxx index d11db625850..9550e8b0cb1 100644 --- a/RALICE/AliVertex.cxx +++ b/RALICE/AliVertex.cxx @@ -33,8 +33,11 @@ // in an AliEvent. // In this way the AliVertex just represents a 'logical structure' for the // physics analysis which can be embedded in e.g. an AliEvent or AliVertex. +// +// Note : // Modifications made to the original vertices also affect the AliVertex objects -// which are stored. +// which are stored. +// // b) SetVertexCopy(1). // Of every 'added' vertex a private copy will be made of which the pointer // will be stored. @@ -43,7 +46,7 @@ // stored. // This mode will allow 'adding' many different AliVertex objects by // creating only one AliVertex instance in the main programme and using the -// AliVertex::Reset() and AliVertex::AddTrack and parameter setting memberfunctions. +// AliVertex::Reset, AliVertex::AddTrack and parameter setting memberfunctions. // // Coding example to make 3 vertices v1, v2 and v3. // ------------------------------------------------ @@ -281,8 +284,8 @@ void AliVertex::ResetVertices() // Reset the stored vertex list and delete all connecting tracks which // were generated automatically via connect=1 in AddVertex(). // The max. number of vertices is set to the default value again. -// All physics quantities are updated according to the remaining structure -// of connected tracks. +// All physics quantities are updated according to the removal of the +// connecting tracks. AliTrack* t; if (fConnects) { @@ -290,21 +293,16 @@ void AliVertex::ResetVertices() { t=(AliTrack*)fConnects->At(i); AliTrack* test=(AliTrack*)fTracks->Remove(t); - if (test) fNtrk--; + if (test) + { + fNtrk--; + (Ali4Vector&)(*this)-=(Ali4Vector&)(*t); + fQ-=t->GetCharge(); + } } fTracks->Compress(); } - fQ=0; - Double_t a[4]={0,0,0,0}; - Ali4Vector::SetVector(a,"sph"); - for (Int_t i=0; iGetCharge(); - } - fNvtx=0; if (fNvmax>0) SetNvmax(fNvmax); if (fConnects) @@ -339,8 +337,7 @@ void AliVertex::AddJet(AliJet& j,Int_t tracks) fNjets++; if (fJetCopy) { - AliJet* jx=new AliJet(j); - fJets->Add(jx); + fJets->Add(j.Clone()); } else { @@ -386,8 +383,7 @@ void AliVertex::AddVertex(AliVertex& v,Int_t connect) fNvtx++; if (fVertexCopy) { - AliVertex* vx=new AliVertex(v); - fVertices->Add(vx); + fVertices->Add(v.Clone()); } else { diff --git a/RALICE/history.txt b/RALICE/history.txt index 61e08b2c540..eef5361f116 100644 --- a/RALICE/history.txt +++ b/RALICE/history.txt @@ -280,3 +280,8 @@ storage of (secondary) vertices. 04-jul-2001 NvE Storage of calorimeters introduced in AliEvent and ResetVertices() added to AliVertex. +05-jul-2001 NvE Clone() facility used in AddTrack() etc... of AliEvent & co. instead of + "new" in the case of TrackCopy etc... This in order to enable 'permanent' + AliTrack etc... storage in AliEvent & co. + Also (Ali4Vector&) casting stmt. in AliVertex::ResetVertices() changed + to make it ANSI compatible for all compilers/platforms. -- 2.43.0