]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RALICE/AliVertex.cxx
07-oct-2003 NvE Arguments of SetSignal and AddSignal memberfunctions of AliCalmodule...
[u/mrichter/AliRoot.git] / RALICE / AliVertex.cxx
index 700dac48d682a22cc9d7365d57d4b3ed87ac2ae6..13f6f3febbcd8f177588e206b3a0015217176cb4 100644 (file)
@@ -48,6 +48,8 @@
 //    creating only one AliVertex instance in the main programme and using the
 //    AliVertex::Reset, AliVertex::AddTrack and parameter setting memberfunctions.
 //
+// See also the documentation provided for the memberfunction SetOwner(). 
+//
 // Coding example to make 3 vertices v1, v2 and v3.
 // ------------------------------------------------
 // v1 contains the tracks 1,2,3 and 4
 //        Float_t r3[3]={6.2,4.8,1.3};
 //        v3.SetPosition(r3,"car");
 //
-//        v1.Info("sph");
+//        v1.Data("sph");
 //        v2.ListAll();
 //        v3.List("cyl");
 //
 //        Float_t loc[3];
 //        v1.GetPosition(loc,"sph");
 //        AliPosition r=v2.GetPosition();
-//        r.Info(); 
+//        r.Data(); 
 //        Int_t nt=v2.GetNtracks();
 //        AliTrack* tv=v2.GetTrack(1); // Access track number 1 of Vertex v2
 //
 ///////////////////////////////////////////////////////////////////////////
 
 #include "AliVertex.h"
+#include "Riostream.h"
  
 ClassImp(AliVertex) // Class implementation to enable ROOT I/O
  
-AliVertex::AliVertex()
+AliVertex::AliVertex() : AliJet(),AliPosition()
 {
 // Default constructor.
 // All variables initialised to 0.
@@ -153,7 +156,6 @@ AliVertex::AliVertex()
 // Initial maximum number of sec. vertices is set to the default value.
  Init();
  Reset();
- SetNtinit();
  SetNvmax();
  SetNjmax();
 }
@@ -161,7 +163,6 @@ AliVertex::AliVertex()
 void AliVertex::Init()
 {
 // Initialisation of pointers etc...
- AliJet::Init();
  fNvmax=0;
  fVertices=0;
  fConnects=0;
@@ -173,24 +174,16 @@ void AliVertex::Init()
  fLines=0;
 }
 ///////////////////////////////////////////////////////////////////////////
-AliVertex::AliVertex(Int_t n)
+AliVertex::AliVertex(Int_t n) : AliJet(n),AliPosition()
 {
 // Create a vertex to hold initially a maximum of n tracks
 // All variables initialised to 0
- Init();
- Reset();
- if (n > 0)
+ if (n<=0)
  {
-  SetNtinit(n);
- }
- else
- {
-  cout << endl;
-  cout << " *AliVertex* Initial max. number of tracks entered : " << n << endl;
-  cout << " This is invalid. Default initial maximum will be used." << endl;
-  cout << endl;
-  SetNtinit();
+  cout << " *** This AliJet initialisation was invoked via the AliVertex ctor." << endl;
  }
+ Init();
+ Reset();
  SetNvmax();
  SetNjmax();
 }
@@ -225,19 +218,49 @@ AliVertex::~AliVertex()
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-AliVertex::AliVertex(AliVertex& v)
+void AliVertex::SetOwner(Bool_t own)
+{
+// Set ownership of all added objects. 
+// The default parameter is own=kTRUE.
+//
+// Invokation of this memberfunction also sets all the copy modes
+// (e.g. TrackCopy & co.) according to the value of own.
+//
+// This function (with own=kTRUE) is particularly useful when reading data
+// from a tree/file, since Reset() will then actually remove all the
+// added objects from memory irrespective of the copy mode settings
+// during the tree/file creation process. In this way it provides a nice way
+// of preventing possible memory leaks in the reading/analysis process.
+//
+// In addition this memberfunction can also be used as a shortcut to set all
+// copy modes in one go during a tree/file creation process.
+// However, in this case the user has to take care to only set/change the
+// ownership (and copy mode) for empty objects (e.g. newly created objects
+// or after invokation of the Reset() memberfunction) otherwise it will
+// very likely result in inconsistent destructor behaviour.
+
+ Int_t mode=1;
+ if (!own) mode=0;
+ if (fVertices) fVertices->SetOwner(own);
+ fVertexCopy=mode;
+ if (fJets) fJets->SetOwner(own);
+ fJetCopy=mode;
+
+ AliJet::SetOwner(own);
+}
+///////////////////////////////////////////////////////////////////////////
+AliVertex::AliVertex(AliVertex& v) : AliJet(v.fNtinit),AliPosition(v)
 {
 // Copy constructor
  Init();
Reset();
SetNtinit();
- SetNvmax();
- SetNjmax();
fNvtx=0;
fNjets=0;
+ SetNvmax(v.fNvmax);
+ SetNjmax(v.fNjmax);
  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;
@@ -516,24 +539,24 @@ void AliVertex::AddVertex(AliVertex& v,Int_t connect)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliVertex::Info(TString f)
+void AliVertex::Data(TString f)
 {
 // Provide vertex information within the coordinate frame f
- cout << " *AliVertex::Info* Id : " << fUserId << " Invmass : " << GetInvmass()
+ cout << " *AliVertex::Data* Id : " << fUserId << " Invmass : " << GetInvmass()
       << " Charge : " << GetCharge() << " Momentum : " << GetMomentum()
       << " Ntracks : " << GetNtracks() << " Nvertices : " << fNvtx 
       << " Njets : " << fNjets << endl;
  cout << " ";
- Ali4Vector::Info(f);
+ Ali4Vector::Data(f);
  cout << "  Position";
- AliPosition::Info(f); 
+ AliPosition::Data(f); 
 } 
 ///////////////////////////////////////////////////////////////////////////
 void AliVertex::List(TString f)
 {
 // Provide primary track and sec. vertex information within the coordinate frame f
 
Info(f); // Information of the current vertex
Data(f); // Information of the current vertex
 
  // The tracks of this vertex
  AliTrack* t; 
@@ -544,7 +567,7 @@ void AliVertex::List(TString f)
   {
    cout << "  ---Track no. " << it << endl;
    cout << " ";
-   t->Info(f); 
+   t->Data(f); 
   }
   else
   {
@@ -561,7 +584,7 @@ void AliVertex::List(TString f)
   {
    cout << "  ---Level 1 sec. vertex no. " << iv << endl;
    cout << " ";
-   v->Info(f); 
+   v->Data(f); 
   }
   else
   {
@@ -574,7 +597,7 @@ void AliVertex::ListAll(TString f)
 {
 // Provide complete (sec) vertex and (decay) track info within the coordinate frame f
 
Info(f); // Information of the current vertex
Data(f); // Information of the current vertex
 
  // The tracks of this vertex
  AliTrack* t; 
@@ -594,10 +617,10 @@ void AliVertex::ListAll(TString f)
  }
 
  AliVertex* v=this;
- Dump(v,1,f); // Information of all sec. vertices
+ Dumps(v,1,f); // Information of all sec. vertices
 }
 //////////////////////////////////////////////////////////////////////////
-void AliVertex::Dump(AliVertex* v,Int_t n,TString f)
+void AliVertex::Dumps(AliVertex* v,Int_t n,TString f)
 {
 // Recursively provide the info of all secondary vertices of this vertex
  AliVertex* vs; 
@@ -608,7 +631,7 @@ void AliVertex::Dump(AliVertex* v,Int_t n,TString f)
   {
    cout << "  ---Level " << n << " sec. vertex no. " << iv << endl;
    cout << " ";
-   vs->Info(f); 
+   vs->Data(f); 
 
    // The tracks of this vertex
    AliTrack* t; 
@@ -623,16 +646,16 @@ void AliVertex::Dump(AliVertex* v,Int_t n,TString f)
     }
     else
     {
-     cout << " *AliVertex::Dump* Error : No track present." << endl; 
+     cout << " *AliVertex::Dumps* Error : No track present." << endl; 
     }
    }
 
    // Go for next sec. vertex level of this sec. vertex recursively
-   Dump(vs,n+1,f);
+   Dumps(vs,n+1,f);
   }
   else
   {
-   cout << " *AliVertex::Dump* Error : No sec. vertex present." << endl; 
+   cout << " *AliVertex::Dumps* Error : No sec. vertex present." << endl; 
   }
  }
 } 
@@ -849,14 +872,14 @@ void AliVertex::Draw(Int_t secs,Int_t cons,Int_t jets)
 // negative track : blue
 // jet-track      : magenta (if explicit marking selected)
 //
-// secs = 1 --> Draw secondary vertices.
+// secs = 1 --> Draw secondary vertices. (Default)
 //        0 --> Don't draw secondary vertices.
 //
-// cons = 1 --> Draw (auto generated) connecting tracks. 
+// cons = 1 --> Draw (auto generated) connecting tracks. (Default) 
 //        0 --> Don't draw (auto generated) connecting tracks.
 //                  
 // jets = 1 --> Mark tracks belonging to jets.
-//        0 --> Don't mark jet-tracks.
+//        0 --> Don't mark jet-tracks. (Default)
 //
 // Notes :
 // -------
@@ -867,9 +890,11 @@ void AliVertex::Draw(Int_t secs,Int_t cons,Int_t jets)
  Double_t vec[3]={0,0,0};
  AliTrack* tx=0;
  AliVertex* vx=0;
- AliPosition r;
+ AliPosition* r=0;
  Ali3Vector p;
- Int_t charge;
+ Float_t charge;
+
+ AliPosition dummy;
 
  if (fLines) delete fLines;
  fLines=new TObjArray();
@@ -892,10 +917,12 @@ void AliVertex::Draw(Int_t secs,Int_t cons,Int_t jets)
    if (cons==1)
    {
     r=tx->GetBeginPoint();
-    r.GetPosition(vec,"car");
+    if (!r) r=&dummy;
+    r->GetPosition(vec,"car");
     line->SetNextPoint(vec[0],vec[1],vec[2]);
     r=tx->GetEndPoint();
-    r.GetPosition(vec,"car");
+    if (!r) r=&dummy;
+    r->GetPosition(vec,"car");
     line->SetNextPoint(vec[0],vec[1],vec[2]);
     line->SetLineWidth(1);
    }
@@ -903,18 +930,19 @@ void AliVertex::Draw(Int_t secs,Int_t cons,Int_t jets)
   else
   {
    r=tx->GetClosestPoint();
-   r.GetPosition(vec,"car");
+   if (!r) r=&dummy;
+   r->GetPosition(vec,"car");
    line->SetNextPoint(vec[0],vec[1],vec[2]);
    p=tx->Get3Momentum();
-   p=p+r;
+   p=p+(*r);
    p.GetVector(vec,"car");
    line->SetNextPoint(vec[0],vec[1],vec[2]);
    line->SetLineWidth(3);
   }
 
-  if (charge>0) line->SetLineColor(kRed);   // Positive track
-  if (!charge)  line->SetLineColor(kGreen); // Neutral track
-  if (charge<0) line->SetLineColor(kBlue);  // Negative track
+  line->SetLineColor(kGreen);              // Neutral track
+  if (charge>0) line->SetLineColor(kRed);  // Positive track
+  if (charge<0) line->SetLineColor(kBlue); // Negative track
  
   // Mark tracks belonging to jets
   if (IsJetTrack(tx))