]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RALICE/AliVertex.cxx
05-jul-2001 NvE Clone() facility used in AddTrack() etc... of AliEvent & co. instead of
[u/mrichter/AliRoot.git] / RALICE / AliVertex.cxx
index 38fd633c9b9cc1b5b8e3a7380cfc5b8d723e91e3..9550e8b0cb1f2c842a99f1fa24b9c3c7d9234129 100644 (file)
 //    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.
 //    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
 //    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.
 // 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
 //    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.
 // ------------------------------------------------
 //
 // Coding example to make 3 vertices v1, v2 and v3.
 // ------------------------------------------------
@@ -252,9 +255,10 @@ void AliVertex::SetNjmax(Int_t n)
 ///////////////////////////////////////////////////////////////////////////
 void AliVertex::Reset()
 {
 ///////////////////////////////////////////////////////////////////////////
 void AliVertex::Reset()
 {
-// Reset all variables to 0
+// Reset all variables to 0 and reset all stored vertex and jet lists.
 // The max. number of tracks is set to the initial value again
 // The max. number of vertices is set to the default value again
 // The max. number of tracks is set to the initial value again
 // The max. number of vertices is set to the default value again
+// The max. number of jets is set to the default value again
 
  AliJet::Reset();
 
 
  AliJet::Reset();
 
@@ -275,6 +279,40 @@ void AliVertex::Reset()
  if (fNjmax>0) SetNjmax(fNjmax);
 }
 ///////////////////////////////////////////////////////////////////////////
  if (fNjmax>0) SetNjmax(fNjmax);
 }
 ///////////////////////////////////////////////////////////////////////////
+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 removal of the
+// connecting tracks.
+ AliTrack* t;
+ if (fConnects)
+ {
+  for (Int_t i=0; i<=fConnects->GetLast(); i++)
+  {
+   t=(AliTrack*)fConnects->At(i);
+   AliTrack* test=(AliTrack*)fTracks->Remove(t);
+   if (test)
+   {
+    fNtrk--;
+    (Ali4Vector&)(*this)-=(Ali4Vector&)(*t);
+    fQ-=t->GetCharge();
+   }
+  }
+  fTracks->Compress();
+ }
+
+ fNvtx=0;
+ if (fNvmax>0) SetNvmax(fNvmax);
+ if (fConnects)
+ {
+  fConnects->Delete();
+  delete fConnects;
+  fConnects=0;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
 void AliVertex::AddJet(AliJet& j,Int_t tracks)
 {
 // Add a jet (and its tracks) to the vertex
 void AliVertex::AddJet(AliJet& j,Int_t tracks)
 {
 // Add a jet (and its tracks) to the vertex
@@ -299,8 +337,7 @@ void AliVertex::AddJet(AliJet& j,Int_t tracks)
  fNjets++;
  if (fJetCopy)
  {
  fNjets++;
  if (fJetCopy)
  {
-  AliJet* jx=new AliJet(j);
-  fJets->Add(jx);
+  fJets->Add(j.Clone());
  }
  else
  {
  }
  else
  {
@@ -346,8 +383,7 @@ void AliVertex::AddVertex(AliVertex& v,Int_t connect)
  fNvtx++;
  if (fVertexCopy)
  {
  fNvtx++;
  if (fVertexCopy)
  {
-  AliVertex* vx=new AliVertex(v);
-  fVertices->Add(vx);
+  fVertices->Add(v.Clone());
  }
  else
  {
  }
  else
  {