]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RALICE/AliVertex.cxx
09-jun-2001 NvE Script mklibs.bat modified to match its new location in the SCRIPTS
[u/mrichter/AliRoot.git] / RALICE / AliVertex.cxx
CommitLineData
4c039060 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
f531a546 16// $Id$
4c039060 17
959fbac5 18///////////////////////////////////////////////////////////////////////////
19// Class AliVertex
20// Creation and investigation of an AliVertex.
21// An AliVertex can be constructed by adding AliTracks and/or AliJets.
22//
23// Note : Also (secondary) vertices can be added to a vertex.
24//
25// Coding example to make 3 vertices v1, v2 and v3.
26// ------------------------------------------------
27// v1 contains the tracks 1,2,3 and 4
28// v2 contains the tracks 5,6 and 7
29// v3 contains the jets 1 and 2
30//
31// AliTrack t1,t2,t3,t4,t5,t6,t7;
32// ...
33// ... // code to fill the track data
34// ...
35//
36// AliJet j1,j2;
37// ...
38// ... // code to fill the jet data
39// ...
40//
41// AliVertex v1(5);
42//
f531a546 43// v1.AddTrack(t1);
44// v1.AddTrack(t2);
45// v1.AddTrack(t3);
46// v1.AddTrack(t4);
959fbac5 47//
48// Float_t r1[3]={2.4,0.1,-8.5};
49// v1.SetPosition(r1,"car");
50//
51// AliVertex v2(2);
f531a546 52// v2.AddTrack(t5);
53// v2.AddTrack(t6);
54// v2.AddTrack(t7);
959fbac5 55//
56// Float_t r2[3]={1.6,-3.2,5.7};
57// v2.SetPosition(r2,"car");
58//
59// AliVertex v3;
60//
f531a546 61// v3.AddJet(j1);
62// v3.AddJet(j2);
959fbac5 63//
64// Float_t r3[3]={6.2,4.8,1.3};
65// v3.SetPosition(r3,"car");
66//
67// v1.Info("sph");
68// v2.ListAll();
69// v3.List("cyl");
70//
71// Float_t e1=v1.GetEnergy();
72// Ali3Vector p1=v1.Get3Momentum();
73// Float_t loc[3];
74// v1.GetPosition(loc,"sph");
75// AliPosition r=v2.GetPosition();
76// r.Info();
77// Int_t nt=v2.GetNtracks();
78// AliTrack* tv=v2.GetTrack(1); // Access track number 1 of Vertex v2
79//
80// Specify the vertices v2 and v3 as secondary vertices of v1
81//
f531a546 82// v1.AddVertex(v2);
83// v1.AddVertex(v3);
959fbac5 84//
85// v1.List();
86//
87// Int_t nv=v1.GetNvtx();
88// AliVertex* vx=v1.GetVertex(1); // Access 1st secondary vertex of v1
89// Float_t e=vx->GetEnergy();
90//
91// Float_t M=v1.GetInvmass();
92//
93// Reconstruct Vertex v1 from scratch
94//
95// v1.Reset();
96// v1.SetNvmax(25); // Increase initial no. of sec. vertices
f531a546 97// v1.AddTrack(t3);
98// v1.AddTrack(t7);
99// v1.AddJet(j2);
959fbac5 100// Float_t pos[3]={7,9,4};
101// v1.SetPosition(pos,"car");
102//
103// Note : All quantities are in GeV, GeV/c or GeV/c**2
104//
105//--- Author: Nick van Eijndhoven 04-apr-1998 UU-SAP Utrecht
f531a546 106//- Modified: NvE $Date$ UU-SAP Utrecht
959fbac5 107///////////////////////////////////////////////////////////////////////////
108
d88f97cc 109#include "AliVertex.h"
110
111ClassImp(AliVertex) // Class implementation to enable ROOT I/O
112
113AliVertex::AliVertex()
114{
959fbac5 115// Default constructor.
116// All variables initialised to 0.
117// Initial maximum number of tracks is set to the default value.
118// Initial maximum number of sec. vertices is set to the default value.
d88f97cc 119 fNvmax=0;
120 fVertices=0;
29beb80d 121 fConnects=0;
d88f97cc 122 Reset();
123 SetNtinit();
124 SetNvmax();
125}
126///////////////////////////////////////////////////////////////////////////
127AliVertex::AliVertex(Int_t n)
128{
129// Create a vertex to hold initially a maximum of n tracks
130// All variables initialised to 0
131 fNvmax=0;
132 fVertices=0;
29beb80d 133 fConnects=0;
d88f97cc 134 Reset();
135 if (n > 0)
136 {
137 SetNtinit(n);
138 }
139 else
140 {
141 cout << endl;
142 cout << " *AliVertex* Initial max. number of tracks entered : " << n << endl;
143 cout << " This is invalid. Default initial maximum will be used." << endl;
144 cout << endl;
145 SetNtinit();
146 }
147 SetNvmax();
148}
149///////////////////////////////////////////////////////////////////////////
150AliVertex::~AliVertex()
151{
152// Default destructor
153 if (fVertices) delete fVertices;
154 fVertices=0;
29beb80d 155 if (fConnects)
156 {
157 fConnects->Delete();
158 delete fConnects;
159 fConnects=0;
160 }
d88f97cc 161}
162///////////////////////////////////////////////////////////////////////////
163void AliVertex::SetNvmax(Int_t n)
164{
165// Set the initial maximum number of (secondary) vertices
166 if (n > 0)
167 {
168 fNvmax=n;
169 }
170 else
171 {
172 fNvmax=1;
173 }
174 if (fVertices) delete fVertices;
175 fVertices=new TObjArray(fNvmax);
176}
177///////////////////////////////////////////////////////////////////////////
178void AliVertex::Reset()
179{
180// Reset all variables to 0
181// The max. number of tracks is set to the initial value again
182// The max. number of vertices is set to the default value again
183
184 AliJet::Reset();
185
f531a546 186 Double_t a[3]={0,0,0};
187 SetPosition(a,"sph");
188 SetPositionErrors(a,"car");
189
d88f97cc 190 fNvtx=0;
191 if (fNvmax>0) SetNvmax(fNvmax);
29beb80d 192 if (fConnects)
193 {
194 fConnects->Delete();
195 delete fConnects;
196 fConnects=0;
197 }
d88f97cc 198}
199///////////////////////////////////////////////////////////////////////////
f531a546 200void AliVertex::AddJet(AliJet& j)
d88f97cc 201{
202// Add the tracks of a jet to the vertex
203 AliTrack* tj;
204 for (Int_t i=1; i<=j.GetNtracks(); i++)
205 {
206 tj=j.GetTrack(i);
f531a546 207 AliJet::AddTrack(tj);
d88f97cc 208 }
209}
210///////////////////////////////////////////////////////////////////////////
f531a546 211void AliVertex::AddVertex(AliVertex& v,Int_t connect)
d88f97cc 212{
213// Add a (secondary) vertex to the current vertex.
214// In case the maximum number of (secondary) vertices has been reached,
215// the array space will be extended automatically
216//
29beb80d 217// Note : By default the 4-momentum and charge of the current (primary) vertex
218// are updated by automatically creating the track connecting
219// both vertices. The track parameters are taken from the
220// 4-momentum and charge of the secondary vertex.
221// The automatic creation of the connecting track and updating
222// of the (primary) vertex 4-momentum and charge can be suppressed
223// by specifying connect=0. In this case, however, the user
224// has to introduce the connecting track lateron by hand
225// explicitly in order to match the kinematics and charge.
d88f97cc 226//
227 if (fNvtx == fNvmax) // Check if maximum vertex number is reached
228 {
229 fNvmax++;
230 fVertices->Expand(fNvmax);
231 }
29beb80d 232
233 // Add the linked (secondary) vertex to the list
d88f97cc 234 fNvtx++;
235 fVertices->Add(&v);
29beb80d 236
237 // Create connecting track and update 4-momentum and charge for current vertex
238 if (connect)
239 {
240 AliPosition r1=GetPosition();
241 AliPosition r2=v.GetPosition();
242 Float_t q=v.GetCharge();
243 Ali3Vector p=v.Get3Momentum();
244 Double_t v2=v.GetInvariant();
245 Double_t dv2=v.Ali4Vector::GetResultError();
246
247 AliTrack* t=new AliTrack;
248 t->SetBeginPoint(r1);
249 t->SetEndPoint(r2);
250 t->SetCharge(q);
251 t->Set3Momentum(p);
252 t->SetInvariant(v2,dv2);
253
f531a546 254 AliJet::AddTrack(t);
29beb80d 255
256 if (!fConnects) fConnects=new TObjArray(fNvmax);
257 fConnects->Add(t);
258 }
d88f97cc 259}
260///////////////////////////////////////////////////////////////////////////
261void AliVertex::Info(TString f)
262{
263// Provide vertex information within the coordinate frame f
264 cout << " *AliVertex::Info* Invmass : " << GetInvmass()
265 << " Charge : " << GetCharge() << " Momentum : " << GetMomentum()
266 << " Ntracks : " << GetNtracks() << " Nvertices : " << fNvtx << endl;
267 cout << " ";
268 Ali4Vector::Info(f);
269 cout << " Position";
270 AliPosition::Info(f);
271}
272///////////////////////////////////////////////////////////////////////////
273void AliVertex::List(TString f)
274{
275// Provide primary track and sec. vertex information within the coordinate frame f
276
277 Info(f); // Information of the current vertex
278
279 // The tracks of this vertex
280 AliTrack* t;
281 for (Int_t it=1; it<=GetNtracks(); it++)
282 {
283 t=GetTrack(it);
284 if (t)
285 {
286 cout << " ---Track no. " << it << endl;
287 cout << " ";
288 t->Info(f);
289 }
290 else
291 {
292 cout << " *AliVertex::List* Error : No track present." << endl;
293 }
294 }
295
296 // The secondary vertices of this vertex
297 AliVertex* v;
298 for (Int_t iv=1; iv<=GetNvertices(); iv++)
299 {
300 v=GetVertex(iv);
301 if (v)
302 {
303 cout << " ---Level 1 sec. vertex no. " << iv << endl;
304 cout << " ";
305 v->Info(f);
306 }
307 else
308 {
309 cout << " *AliVertex::List* Error : No sec. vertex present." << endl;
310 }
311 }
312}
313///////////////////////////////////////////////////////////////////////////
314void AliVertex::ListAll(TString f)
315{
316// Provide complete (sec) vertex and (decay) track info within the coordinate frame f
317
318 Info(f); // Information of the current vertex
319
320 // The tracks of this vertex
321 AliTrack* t;
322 for (Int_t it=1; it<=GetNtracks(); it++)
323 {
324 t=GetTrack(it);
325 if (t)
326 {
327 cout << " ---Track no. " << it << endl;
328 cout << " ";
329 t->ListAll(f);
330 }
331 else
332 {
333 cout << " *AliVertex::ListAll* Error : No track present." << endl;
334 }
335 }
336
337 AliVertex* v=this;
338 Dump(v,1,f); // Information of all sec. vertices
339}
340//////////////////////////////////////////////////////////////////////////
341void AliVertex::Dump(AliVertex* v,Int_t n,TString f)
342{
343// Recursively provide the info of all secondary vertices of this vertex
344 AliVertex* vs;
345 for (Int_t iv=1; iv<=v->GetNvertices(); iv++)
346 {
347 vs=v->GetVertex(iv);
348 if (vs)
349 {
350 cout << " ---Level " << n << " sec. vertex no. " << iv << endl;
351 cout << " ";
352 vs->Info(f);
353
354 // The tracks of this vertex
355 AliTrack* t;
356 for (Int_t it=1; it<=vs->GetNtracks(); it++)
357 {
358 t=vs->GetTrack(it);
359 if (t)
360 {
361 cout << " ---Track no. " << it << endl;
362 cout << " ";
363 t->ListAll(f);
364 }
365 else
366 {
367 cout << " *AliVertex::Dump* Error : No track present." << endl;
368 }
369 }
370
371 // Go for next sec. vertex level of this sec. vertex recursively
372 Dump(vs,n+1,f);
373 }
374 else
375 {
376 cout << " *AliVertex::Dump* Error : No sec. vertex present." << endl;
377 }
378 }
379}
380//////////////////////////////////////////////////////////////////////////
381Int_t AliVertex::GetNvertices()
382{
383// Return the current number of (secondary) vertices
384 return fNvtx;
385}
386///////////////////////////////////////////////////////////////////////////
387AliVertex* AliVertex::GetVertex(Int_t i)
388{
389// Return the i-th (secondary) vertex of the current vertex
390 return (AliVertex*)fVertices->At(i-1);
391}
392///////////////////////////////////////////////////////////////////////////