1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////
20 // Creation and investigation of an AliVertex.
21 // An AliVertex can be constructed by adding AliTracks and/or AliJets.
23 // Note : Also (secondary) vertices can be added to a vertex.
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
31 // AliTrack t1,t2,t3,t4,t5,t6,t7;
33 // ... // code to fill the track data
38 // ... // code to fill the jet data
48 // Float_t r1[3]={2.4,0.1,-8.5};
49 // v1.SetPosition(r1,"car");
56 // Float_t r2[3]={1.6,-3.2,5.7};
57 // v2.SetPosition(r2,"car");
64 // Float_t r3[3]={6.2,4.8,1.3};
65 // v3.SetPosition(r3,"car");
71 // Float_t e1=v1.GetEnergy();
72 // Ali3Vector p1=v1.Get3Momentum();
74 // v1.GetPosition(loc,"sph");
75 // AliPosition r=v2.GetPosition();
77 // Int_t nt=v2.GetNtracks();
78 // AliTrack* tv=v2.GetTrack(1); // Access track number 1 of Vertex v2
80 // Specify the vertices v2 and v3 as secondary vertices of v1
87 // Int_t nv=v1.GetNvtx();
88 // AliVertex* vx=v1.GetVertex(1); // Access 1st secondary vertex of v1
89 // Float_t e=vx->GetEnergy();
91 // Float_t M=v1.GetInvmass();
93 // Reconstruct Vertex v1 from scratch
96 // v1.SetNvmax(25); // Increase initial no. of sec. vertices
100 // Float_t pos[3]={7,9,4};
101 // v1.SetPosition(pos,"car");
103 // Note : All quantities are in GeV, GeV/c or GeV/c**2
105 //--- Author: Nick van Eijndhoven 04-apr-1998 UU-SAP Utrecht
106 //- Modified: NvE $Date$ UU-SAP Utrecht
107 ///////////////////////////////////////////////////////////////////////////
109 #include "AliVertex.h"
111 ClassImp(AliVertex) // Class implementation to enable ROOT I/O
113 AliVertex::AliVertex()
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.
126 ///////////////////////////////////////////////////////////////////////////
127 AliVertex::AliVertex(Int_t n)
129 // Create a vertex to hold initially a maximum of n tracks
130 // All variables initialised to 0
142 cout << " *AliVertex* Initial max. number of tracks entered : " << n << endl;
143 cout << " This is invalid. Default initial maximum will be used." << endl;
149 ///////////////////////////////////////////////////////////////////////////
150 AliVertex::~AliVertex()
152 // Default destructor
153 if (fVertices) delete fVertices;
162 ///////////////////////////////////////////////////////////////////////////
163 void AliVertex::SetNvmax(Int_t n)
165 // Set the initial maximum number of (secondary) vertices
174 if (fVertices) delete fVertices;
175 fVertices=new TObjArray(fNvmax);
177 ///////////////////////////////////////////////////////////////////////////
178 void AliVertex::Reset()
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
186 Double_t a[3]={0,0,0};
187 SetPosition(a,"sph");
188 SetPositionErrors(a,"car");
191 if (fNvmax>0) SetNvmax(fNvmax);
199 ///////////////////////////////////////////////////////////////////////////
200 void AliVertex::AddJet(AliJet& j)
202 // Add the tracks of a jet to the vertex
204 for (Int_t i=1; i<=j.GetNtracks(); i++)
207 AliJet::AddTrack(tj);
210 ///////////////////////////////////////////////////////////////////////////
211 void AliVertex::AddVertex(AliVertex& v,Int_t connect)
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
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.
227 if (fNvtx == fNvmax) // Check if maximum vertex number is reached
230 fVertices->Expand(fNvmax);
233 // Add the linked (secondary) vertex to the list
237 // Create connecting track and update 4-momentum and charge for current vertex
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();
247 AliTrack* t=new AliTrack;
248 t->SetBeginPoint(r1);
252 t->SetInvariant(v2,dv2);
256 if (!fConnects) fConnects=new TObjArray(fNvmax);
260 ///////////////////////////////////////////////////////////////////////////
261 void AliVertex::Info(TString f)
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;
270 AliPosition::Info(f);
272 ///////////////////////////////////////////////////////////////////////////
273 void AliVertex::List(TString f)
275 // Provide primary track and sec. vertex information within the coordinate frame f
277 Info(f); // Information of the current vertex
279 // The tracks of this vertex
281 for (Int_t it=1; it<=GetNtracks(); it++)
286 cout << " ---Track no. " << it << endl;
292 cout << " *AliVertex::List* Error : No track present." << endl;
296 // The secondary vertices of this vertex
298 for (Int_t iv=1; iv<=GetNvertices(); iv++)
303 cout << " ---Level 1 sec. vertex no. " << iv << endl;
309 cout << " *AliVertex::List* Error : No sec. vertex present." << endl;
313 ///////////////////////////////////////////////////////////////////////////
314 void AliVertex::ListAll(TString f)
316 // Provide complete (sec) vertex and (decay) track info within the coordinate frame f
318 Info(f); // Information of the current vertex
320 // The tracks of this vertex
322 for (Int_t it=1; it<=GetNtracks(); it++)
327 cout << " ---Track no. " << it << endl;
333 cout << " *AliVertex::ListAll* Error : No track present." << endl;
338 Dump(v,1,f); // Information of all sec. vertices
340 //////////////////////////////////////////////////////////////////////////
341 void AliVertex::Dump(AliVertex* v,Int_t n,TString f)
343 // Recursively provide the info of all secondary vertices of this vertex
345 for (Int_t iv=1; iv<=v->GetNvertices(); iv++)
350 cout << " ---Level " << n << " sec. vertex no. " << iv << endl;
354 // The tracks of this vertex
356 for (Int_t it=1; it<=vs->GetNtracks(); it++)
361 cout << " ---Track no. " << it << endl;
367 cout << " *AliVertex::Dump* Error : No track present." << endl;
371 // Go for next sec. vertex level of this sec. vertex recursively
376 cout << " *AliVertex::Dump* Error : No sec. vertex present." << endl;
380 //////////////////////////////////////////////////////////////////////////
381 Int_t AliVertex::GetNvertices()
383 // Return the current number of (secondary) vertices
386 ///////////////////////////////////////////////////////////////////////////
387 AliVertex* AliVertex::GetVertex(Int_t i)
389 // Return the i-th (secondary) vertex of the current vertex
390 return (AliVertex*)fVertices->At(i-1);
392 ///////////////////////////////////////////////////////////////////////////