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