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 // To provide maximal flexibility to the user, two modes of vertex storage
26 // are provided by means of the memberfunction SetVertexCopy().
27 // The same holds for the storage of jets via SetJetCopy().
29 // a) SetVertexCopy(0) (which is the default).
30 // Only the pointers of the 'added' vertices are stored.
31 // This mode is typically used by making vertex studies based on a fixed list
32 // of vertices which stays under user control or is contained for instance
34 // In this way the AliVertex just represents a 'logical structure' for the
35 // physics analysis which can be embedded in e.g. an AliEvent or AliVertex.
38 // Modifications made to the original vertices also affect the AliVertex objects
41 // b) SetVertexCopy(1).
42 // Of every 'added' vertex a private copy will be made of which the pointer
44 // In this way the AliVertex represents an entity on its own and modifications
45 // made to the original vertices do not affect the AliVertex objects which are
47 // This mode will allow 'adding' many different AliVertex objects by
48 // creating only one AliVertex instance in the main programme and using the
49 // AliVertex::Reset, AliVertex::AddTrack and parameter setting memberfunctions.
51 // Coding example to make 3 vertices v1, v2 and v3.
52 // ------------------------------------------------
53 // v1 contains the tracks 1,2,3 and 4
54 // v2 contains many different tracks
55 // v3 contains the jets 1 and 2
57 // AliTrack t1,t2,t3,t4;
59 // ... // code to fill the track data
64 // ... // code to fill the jet data
68 // v1.SetVertexCopy(1);
75 // Float_t r1[3]={2.4,0.1,-8.5};
76 // v1.SetPosition(r1,"car");
79 // v2.SetTrackCopy(1);
81 // AliTrack* tx=new AliTrack();
82 // for (Int_t i=0; i<10; i++)
85 // ... // code to fill the track data
91 // Float_t r2[3]={1.6,-3.2,5.7};
92 // v2.SetPosition(r2,"car");
99 // Float_t r3[3]={6.2,4.8,1.3};
100 // v3.SetPosition(r3,"car");
106 // Float_t e1=v1.GetEnergy();
107 // Ali3Vector p1=v1.Get3Momentum();
109 // v1.GetPosition(loc,"sph");
110 // AliPosition r=v2.GetPosition();
112 // Int_t nt=v2.GetNtracks();
113 // AliTrack* tv=v2.GetTrack(1); // Access track number 1 of Vertex v2
115 // Specify the vertices v2 and v3 as secondary vertices of v1
122 // Int_t nv=v1.GetNvtx();
123 // AliVertex* vx=v1.GetVertex(1); // Access 1st secondary vertex of v1
124 // Float_t e=vx->GetEnergy();
126 // Float_t M=v1.GetInvmass();
128 // Reconstruct Vertex v1 from scratch
131 // v1.SetNvmax(25); // Increase initial no. of sec. vertices
135 // Float_t pos[3]={7,9,4};
136 // v1.SetPosition(pos,"car");
138 // Note : All quantities are in GeV, GeV/c or GeV/c**2
140 //--- Author: Nick van Eijndhoven 04-apr-1998 UU-SAP Utrecht
141 //- Modified: NvE $Date$ UU-SAP Utrecht
142 ///////////////////////////////////////////////////////////////////////////
144 #include "AliVertex.h"
146 ClassImp(AliVertex) // Class implementation to enable ROOT I/O
148 AliVertex::AliVertex()
150 // Default constructor.
151 // All variables initialised to 0.
152 // Initial maximum number of tracks is set to the default value.
153 // Initial maximum number of sec. vertices is set to the default value.
166 ///////////////////////////////////////////////////////////////////////////
167 AliVertex::AliVertex(Int_t n)
169 // Create a vertex to hold initially a maximum of n tracks
170 // All variables initialised to 0
186 cout << " *AliVertex* Initial max. number of tracks entered : " << n << endl;
187 cout << " This is invalid. Default initial maximum will be used." << endl;
194 ///////////////////////////////////////////////////////////////////////////
195 AliVertex::~AliVertex()
197 // Default destructor
200 if (fVertexCopy) fVertices->Delete();
212 if (fJetCopy) fJets->Delete();
217 ///////////////////////////////////////////////////////////////////////////
218 void AliVertex::SetNvmax(Int_t n)
220 // Set the initial maximum number of (secondary) vertices
231 if (fVertexCopy) fVertices->Delete();
236 ///////////////////////////////////////////////////////////////////////////
237 void AliVertex::SetNjmax(Int_t n)
239 // Set the initial maximum number of jets
250 if (fJetCopy) fJets->Delete();
255 ///////////////////////////////////////////////////////////////////////////
256 void AliVertex::Reset()
258 // Reset all variables to 0 and reset all stored vertex and jet lists.
259 // The max. number of tracks is set to the initial value again
260 // The max. number of vertices is set to the default value again
261 // The max. number of jets is set to the default value again
265 Double_t a[3]={0,0,0};
266 SetPosition(a,"sph");
267 SetPositionErrors(a,"car");
270 if (fNvmax>0) SetNvmax(fNvmax);
279 if (fNjmax>0) SetNjmax(fNjmax);
281 ///////////////////////////////////////////////////////////////////////////
282 void AliVertex::ResetVertices()
284 // Reset the stored vertex list and delete all connecting tracks which
285 // were generated automatically via connect=1 in AddVertex().
286 // The max. number of vertices is set to the default value again.
287 // All physics quantities are updated according to the removal of the
288 // connecting tracks.
292 for (Int_t i=0; i<=fConnects->GetLast(); i++)
294 t=(AliTrack*)fConnects->At(i);
295 AliTrack* test=(AliTrack*)fTracks->Remove(t);
299 (Ali4Vector&)(*this)-=(Ali4Vector&)(*t);
307 if (fNvmax>0) SetNvmax(fNvmax);
315 ///////////////////////////////////////////////////////////////////////////
316 void AliVertex::AddJet(AliJet& j,Int_t tracks)
318 // Add a jet (and its tracks) to the vertex
319 // In case the maximum number of jets has been reached,
320 // the array space will be extended automatically
322 // Note : By default the tracks of the jet are added to the current (primary)
324 // The automatic addition of the tracks of the jet can be suppressed
325 // by specifying tracks=0. In this case only the AliJet object will
326 // be stored according to the mode specified by SetJetCopy().
327 // The latter will enable jet studies based on a fixed list of tracks
328 // as contained e.g. in an AliVertex or AliEvent.
329 if (!fJets) fJets=new TObjArray(fNjmax);
330 if (fNjets == fNjmax) // Check if maximum jet number is reached
333 fJets->Expand(fNjmax);
336 // Add the jet to the list
340 fJets->Add(j.Clone());
347 // Add the tracks of the jet to this vertex
351 for (Int_t i=1; i<=j.GetNtracks(); i++)
358 ///////////////////////////////////////////////////////////////////////////
359 void AliVertex::AddVertex(AliVertex& v,Int_t connect)
361 // Add a (secondary) vertex to the current vertex.
362 // In case the maximum number of (secondary) vertices has been reached,
363 // the array space will be extended automatically
365 // Note : By default the 4-momentum and charge of the current (primary) vertex
366 // are updated by automatically creating the track connecting
367 // both vertices. The track parameters are taken from the
368 // 4-momentum and charge of the secondary vertex.
369 // The automatic creation of the connecting track and updating
370 // of the (primary) vertex 4-momentum and charge can be suppressed
371 // by specifying connect=0. In this case, however, the user
372 // has to introduce the connecting track lateron by hand
373 // explicitly in order to match the kinematics and charge.
375 if (!fVertices) fVertices=new TObjArray(fNvmax);
376 if (fNvtx == fNvmax) // Check if maximum vertex number is reached
379 fVertices->Expand(fNvmax);
382 // Add the linked (secondary) vertex to the list
386 fVertices->Add(v.Clone());
393 // Create connecting track and update 4-momentum and charge for current vertex
396 AliPosition r1=GetPosition();
397 AliPosition r2=v.GetPosition();
398 Float_t q=v.GetCharge();
399 Ali3Vector p=v.Get3Momentum();
400 Double_t v2=v.GetInvariant();
401 Double_t dv2=v.Ali4Vector::GetResultError();
403 AliTrack* t=new AliTrack();
404 t->SetBeginPoint(r1);
408 t->SetInvariant(v2,dv2);
412 if (!fConnects) fConnects=new TObjArray(fNvmax);
416 ///////////////////////////////////////////////////////////////////////////
417 void AliVertex::Info(TString f)
419 // Provide vertex information within the coordinate frame f
420 cout << " *AliVertex::Info* Id : " << fUserId << " Invmass : " << GetInvmass()
421 << " Charge : " << GetCharge() << " Momentum : " << GetMomentum()
422 << " Ntracks : " << GetNtracks() << " Nvertices : " << fNvtx
423 << " Njets : " << fNjets << endl;
427 AliPosition::Info(f);
429 ///////////////////////////////////////////////////////////////////////////
430 void AliVertex::List(TString f)
432 // Provide primary track and sec. vertex information within the coordinate frame f
434 Info(f); // Information of the current vertex
436 // The tracks of this vertex
438 for (Int_t it=1; it<=GetNtracks(); it++)
443 cout << " ---Track no. " << it << endl;
449 cout << " *AliVertex::List* Error : No track present." << endl;
453 // The secondary vertices of this vertex
455 for (Int_t iv=1; iv<=GetNvertices(); iv++)
460 cout << " ---Level 1 sec. vertex no. " << iv << endl;
466 cout << " *AliVertex::List* Error : No sec. vertex present." << endl;
470 ///////////////////////////////////////////////////////////////////////////
471 void AliVertex::ListAll(TString f)
473 // Provide complete (sec) vertex and (decay) track info within the coordinate frame f
475 Info(f); // Information of the current vertex
477 // The tracks of this vertex
479 for (Int_t it=1; it<=GetNtracks(); it++)
484 cout << " ---Track no. " << it << endl;
490 cout << " *AliVertex::ListAll* Error : No track present." << endl;
495 Dump(v,1,f); // Information of all sec. vertices
497 //////////////////////////////////////////////////////////////////////////
498 void AliVertex::Dump(AliVertex* v,Int_t n,TString f)
500 // Recursively provide the info of all secondary vertices of this vertex
502 for (Int_t iv=1; iv<=v->GetNvertices(); iv++)
507 cout << " ---Level " << n << " sec. vertex no. " << iv << endl;
511 // The tracks of this vertex
513 for (Int_t it=1; it<=vs->GetNtracks(); it++)
518 cout << " ---Track no. " << it << endl;
524 cout << " *AliVertex::Dump* Error : No track present." << endl;
528 // Go for next sec. vertex level of this sec. vertex recursively
533 cout << " *AliVertex::Dump* Error : No sec. vertex present." << endl;
537 //////////////////////////////////////////////////////////////////////////
538 Int_t AliVertex::GetNvertices()
540 // Return the current number of (secondary) vertices
543 ///////////////////////////////////////////////////////////////////////////
544 AliVertex* AliVertex::GetVertex(Int_t i)
546 // Return the i-th (secondary) vertex of the current vertex
549 cout << " *AliVertex*::GetVertex* No (secondary) vertices present." << endl;
556 cout << " *AliVertex*::GetVertex* Invalid argument i : " << i
557 << " Nvtx = " << fNvtx << endl;
562 return (AliVertex*)fVertices->At(i-1);
566 ///////////////////////////////////////////////////////////////////////////
567 AliVertex* AliVertex::GetIdVertex(Int_t id)
569 // Return the (sec.) vertex with user identifier "id"
574 cout << " *AliVertex*::GetIdVertex* No (secondary) vertices present." << endl;
579 for (Int_t i=0; i<fNvtx; i++)
581 vx=(AliVertex*)fVertices->At(i);
582 if (id == vx->GetId()) v=vx;
587 ///////////////////////////////////////////////////////////////////////////
588 void AliVertex::SetVertexCopy(Int_t j)
590 // (De)activate the creation of private copies of the added vertices.
591 // j=0 ==> No private copies are made; pointers of original vertices are stored.
592 // j=1 ==> Private copies of the vertices are made and these pointers are stored.
594 // Note : Once the storage contains pointer(s) to AliVertex objects one cannot
595 // change the VertexCopy mode anymore.
596 // To change the VertexCopy mode for an existing AliVertex containing
597 // vertices one first has to invoke Reset().
606 cout << "*AliVertex::SetVertexCopy* Invalid argument : " << j << endl;
611 cout << "*AliVertex::SetVertexCopy* Storage already contained vertices."
612 << " ==> VertexCopy mode not changed." << endl;
615 ///////////////////////////////////////////////////////////////////////////
616 Int_t AliVertex::GetVertexCopy()
618 // Provide value of the VertexCopy mode.
619 // 0 ==> No private copies are made; pointers of original vertices are stored.
620 // 1 ==> Private copies of the vertices are made and these pointers are stored.
623 ///////////////////////////////////////////////////////////////////////////
624 Int_t AliVertex::GetNjets()
626 // Return the current number of jets
629 ///////////////////////////////////////////////////////////////////////////
630 AliJet* AliVertex::GetJet(Int_t i)
632 // Return the i-th jet of the current vertex
635 cout << " *AliVertex*::GetJet* No jets present." << endl;
640 if (i<=0 || i>fNjets)
642 cout << " *AliVertex*::GetJet* Invalid argument i : " << i
643 << " Njets = " << fNjets << endl;
648 return (AliJet*)fJets->At(i-1);
652 ///////////////////////////////////////////////////////////////////////////
653 AliJet* AliVertex::GetIdJet(Int_t id)
655 // Return the jet with user identifier "id"
660 cout << " *AliVertex*::GetIdJet* No jets present." << endl;
665 for (Int_t i=0; i<fNjets; i++)
667 jx=(AliJet*)fJets->At(i);
668 if (id == jx->GetId()) j=jx;
673 ///////////////////////////////////////////////////////////////////////////
674 void AliVertex::SetJetCopy(Int_t j)
676 // (De)activate the creation of private copies of the added jets.
677 // j=0 ==> No private copies are made; pointers of original jets are stored.
678 // j=1 ==> Private copies of the jets are made and these pointers are stored.
680 // Note : Once the storage contains pointer(s) to AliJet objects one cannot
681 // change the JetCopy mode anymore.
682 // To change the JetCopy mode for an existing AliVertex containing
683 // jets one first has to invoke Reset().
692 cout << "*AliVertex::SetJetCopy* Invalid argument : " << j << endl;
697 cout << "*AliVertex::SetJetCopy* Storage already contained jets."
698 << " ==> JetCopy mode not changed." << endl;
701 ///////////////////////////////////////////////////////////////////////////
702 Int_t AliVertex::GetJetCopy()
704 // Provide value of the JetCopy mode.
705 // 0 ==> No private copies are made; pointers of original jets are stored.
706 // 1 ==> Private copies of the jets are made and these pointers are stored.
709 ///////////////////////////////////////////////////////////////////////////