]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RALICE/AliVertex.cxx
This commit was generated by cvs2svn to compensate for changes in r165,
[u/mrichter/AliRoot.git] / RALICE / AliVertex.cxx
1 #include "AliVertex.h"
2  
3 ClassImp(AliVertex) // Class implementation to enable ROOT I/O
4  
5 AliVertex::AliVertex()
6 {
7 // Default constructor
8 // All variables initialised to 0
9 // Initial maximum number of tracks is set to the default value
10 // Initial maximum number of sec. vertices is set to the default value
11  fNvmax=0;
12  fVertices=0;
13  Reset();
14  SetNtinit();
15  SetNvmax();
16 }
17 ///////////////////////////////////////////////////////////////////////////
18 AliVertex::AliVertex(Int_t n)
19 {
20 // Create a vertex to hold initially a maximum of n tracks
21 // All variables initialised to 0
22  fNvmax=0;
23  fVertices=0;
24  Reset();
25  if (n > 0)
26  {
27   SetNtinit(n);
28  }
29  else
30  {
31   cout << endl;
32   cout << " *AliVertex* Initial max. number of tracks entered : " << n << endl;
33   cout << " This is invalid. Default initial maximum will be used." << endl;
34   cout << endl;
35   SetNtinit();
36  }
37  SetNvmax();
38 }
39 ///////////////////////////////////////////////////////////////////////////
40 AliVertex::~AliVertex()
41 {
42 // Default destructor
43  if (fVertices) delete fVertices;
44  fVertices=0;
45 }
46 ///////////////////////////////////////////////////////////////////////////
47 void AliVertex::SetNvmax(Int_t n)
48 {
49 // Set the initial maximum number of (secondary) vertices
50  if (n > 0)
51  {
52   fNvmax=n;
53  }
54  else
55  {
56   fNvmax=1;
57  }
58  if (fVertices) delete fVertices;
59  fVertices=new TObjArray(fNvmax);
60 }
61 ///////////////////////////////////////////////////////////////////////////
62 void AliVertex::Reset()
63 {
64 // Reset all variables to 0
65 // The max. number of tracks is set to the initial value again
66 // The max. number of vertices is set to the default value again
67
68  AliJet::Reset();
69
70  fNvtx=0;
71  if (fNvmax>0) SetNvmax(fNvmax);
72 }
73 ///////////////////////////////////////////////////////////////////////////
74 void AliVertex::Add(AliJet& j)
75 {
76 // Add the tracks of a jet to the vertex
77  AliTrack* tj;
78  for (Int_t i=1; i<=j.GetNtracks(); i++)
79  {
80   tj=j.GetTrack(i);
81   AliJet::Add(tj);
82  }
83 }
84 ///////////////////////////////////////////////////////////////////////////
85 void AliVertex::Add(AliVertex& v)
86 {
87 // Add a (secondary) vertex to the current vertex.
88 // In case the maximum number of (secondary) vertices has been reached,
89 // the array space will be extended automatically
90 //
91 // Note : The 4-momentum of the current (primary) vertex
92 //        is updated automatically, but the track connecting
93 //        both vertices has to be entered separately by the user.
94 //
95  if (fNvtx == fNvmax) // Check if maximum vertex number is reached
96  {
97   fNvmax++;
98   fVertices->Expand(fNvmax);
99  }
100  
101  // Update 4-momentum for current vertex
102  fNvtx++;
103  fVertices->Add(&v);
104  (Ali4Vector)(*this)+=v;
105 }
106 ///////////////////////////////////////////////////////////////////////////
107 void AliVertex::Info(TString f)
108 {
109 // Provide vertex information within the coordinate frame f
110  cout << " *AliVertex::Info* Invmass : " << GetInvmass()
111       << " Charge : " << GetCharge() << " Momentum : " << GetMomentum()
112       << " Ntracks : " << GetNtracks() << " Nvertices : " << fNvtx << endl;
113  cout << " ";
114  Ali4Vector::Info(f);
115  cout << "  Position";
116  AliPosition::Info(f); 
117
118 ///////////////////////////////////////////////////////////////////////////
119 void AliVertex::List(TString f)
120 {
121 // Provide primary track and sec. vertex information within the coordinate frame f
122
123  Info(f); // Information of the current vertex
124
125  // The tracks of this vertex
126  AliTrack* t; 
127  for (Int_t it=1; it<=GetNtracks(); it++)
128  {
129   t=GetTrack(it);
130   if (t)
131   {
132    cout << "  ---Track no. " << it << endl;
133    cout << " ";
134    t->Info(f); 
135   }
136   else
137   {
138    cout << " *AliVertex::List* Error : No track present." << endl; 
139   }
140  }
141
142  // The secondary vertices of this vertex
143  AliVertex* v; 
144  for (Int_t iv=1; iv<=GetNvertices(); iv++)
145  {
146   v=GetVertex(iv);
147   if (v)
148   {
149    cout << "  ---Level 1 sec. vertex no. " << iv << endl;
150    cout << " ";
151    v->Info(f); 
152   }
153   else
154   {
155    cout << " *AliVertex::List* Error : No sec. vertex present." << endl; 
156   }
157  }
158
159 ///////////////////////////////////////////////////////////////////////////
160 void AliVertex::ListAll(TString f)
161 {
162 // Provide complete (sec) vertex and (decay) track info within the coordinate frame f
163
164  Info(f); // Information of the current vertex
165
166  // The tracks of this vertex
167  AliTrack* t; 
168  for (Int_t it=1; it<=GetNtracks(); it++)
169  {
170   t=GetTrack(it);
171   if (t)
172   {
173    cout << "  ---Track no. " << it << endl;
174    cout << " ";
175    t->ListAll(f); 
176   }
177   else
178   {
179    cout << " *AliVertex::ListAll* Error : No track present." << endl; 
180   }
181  }
182
183  AliVertex* v=this;
184  Dump(v,1,f); // Information of all sec. vertices
185 }
186 //////////////////////////////////////////////////////////////////////////
187 void AliVertex::Dump(AliVertex* v,Int_t n,TString f)
188 {
189 // Recursively provide the info of all secondary vertices of this vertex
190  AliVertex* vs; 
191  for (Int_t iv=1; iv<=v->GetNvertices(); iv++)
192  {
193   vs=v->GetVertex(iv);
194   if (vs)
195   {
196    cout << "  ---Level " << n << " sec. vertex no. " << iv << endl;
197    cout << " ";
198    vs->Info(f); 
199
200    // The tracks of this vertex
201    AliTrack* t; 
202    for (Int_t it=1; it<=vs->GetNtracks(); it++)
203    {
204     t=vs->GetTrack(it);
205     if (t)
206     {
207      cout << "  ---Track no. " << it << endl;
208      cout << " ";
209      t->ListAll(f); 
210     }
211     else
212     {
213      cout << " *AliVertex::Dump* Error : No track present." << endl; 
214     }
215    }
216
217    // Go for next sec. vertex level of this sec. vertex recursively
218    Dump(vs,n+1,f);
219   }
220   else
221   {
222    cout << " *AliVertex::Dump* Error : No sec. vertex present." << endl; 
223   }
224  }
225
226 //////////////////////////////////////////////////////////////////////////
227 Int_t AliVertex::GetNvertices()
228 {
229 // Return the current number of (secondary) vertices
230  return fNvtx;
231 }
232 ///////////////////////////////////////////////////////////////////////////
233 AliVertex* AliVertex::GetVertex(Int_t i)
234 {
235 // Return the i-th (secondary) vertex of the current vertex
236  return (AliVertex*)fVertices->At(i-1);
237 }
238 ///////////////////////////////////////////////////////////////////////////