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 // See also the documentation provided for the memberfunction SetOwner().
53 // Coding example to make 3 vertices v1, v2 and v3.
54 // ------------------------------------------------
55 // v1 contains the tracks 1,2,3 and 4
56 // v2 contains many different tracks
57 // v3 contains the jets 1 and 2
59 // AliTrack t1,t2,t3,t4;
61 // ... // code to fill the track data
66 // ... // code to fill the jet data
70 // v1.SetVertexCopy(1);
77 // Float_t r1[3]={2.4,0.1,-8.5};
78 // v1.SetPosition(r1,"car");
81 // v2.SetTrackCopy(1);
83 // AliTrack* tx=new AliTrack();
84 // for (Int_t i=0; i<10; i++)
87 // ... // code to fill the track data
93 // Float_t r2[3]={1.6,-3.2,5.7};
94 // v2.SetPosition(r2,"car");
101 // Float_t r3[3]={6.2,4.8,1.3};
102 // v3.SetPosition(r3,"car");
108 // Float_t e1=v1.GetEnergy();
109 // Ali3Vector p1=v1.Get3Momentum();
111 // v1.GetPosition(loc,"sph");
112 // AliPosition r=v2.GetPosition();
114 // Int_t nt=v2.GetNtracks();
115 // AliTrack* tv=v2.GetTrack(1); // Access track number 1 of Vertex v2
117 // Specify the vertices v2 and v3 as secondary vertices of v1
124 // Int_t nv=v1.GetNvtx();
125 // AliVertex* vx=v1.GetVertex(1); // Access 1st secondary vertex of v1
126 // Float_t e=vx->GetEnergy();
128 // Float_t M=v1.GetInvmass();
130 // Reconstruct Vertex v1 from scratch
133 // v1.SetNvmax(25); // Increase initial no. of sec. vertices
137 // Float_t pos[3]={7,9,4};
138 // v1.SetPosition(pos,"car");
140 // Note : By default all quantities are in meter, GeV, GeV/c or GeV/c**2
141 // but the user can indicate the usage of a different scale for
142 // the metric and/or energy-momentum units via the SetUnitScale()
143 // and SetEscale() memberfunctions, respectively.
144 // The actual metric and energy-momentum unit scales in use can be
145 // obtained via the GetUnitScale() and GetEscale() memberfunctions.
147 //--- Author: Nick van Eijndhoven 04-apr-1998 UU-SAP Utrecht
148 //- Modified: NvE $Date$ UU-SAP Utrecht
149 ///////////////////////////////////////////////////////////////////////////
152 #include "AliVertex.h"
153 #include "Riostream.h"
155 ClassImp(AliVertex) // Class implementation to enable ROOT I/O
157 AliVertex::AliVertex() : AliJet(),AliPosition()
159 // Default constructor.
160 // All variables initialised to 0.
161 // Initial maximum number of tracks is set to the default value.
162 // Initial maximum number of sec. vertices is set to the default value.
168 ///////////////////////////////////////////////////////////////////////////
169 void AliVertex::Init()
171 // Initialisation of pointers etc...
182 ///////////////////////////////////////////////////////////////////////////
183 AliVertex::AliVertex(Int_t n) : AliJet(n),AliPosition()
185 // Create a vertex to hold initially a maximum of n tracks
186 // All variables initialised to 0
189 cout << " *** This AliJet initialisation was invoked via the AliVertex ctor." << endl;
196 ///////////////////////////////////////////////////////////////////////////
197 AliVertex::~AliVertex()
199 // Default destructor
226 ///////////////////////////////////////////////////////////////////////////
227 void AliVertex::SetOwner(Bool_t own)
229 // Set ownership of all added objects.
230 // The default parameter is own=kTRUE.
232 // Invokation of this memberfunction also sets all the copy modes
233 // (e.g. TrackCopy & co.) according to the value of own.
235 // This function (with own=kTRUE) is particularly useful when reading data
236 // from a tree/file, since Reset() will then actually remove all the
237 // added objects from memory irrespective of the copy mode settings
238 // during the tree/file creation process. In this way it provides a nice way
239 // of preventing possible memory leaks in the reading/analysis process.
241 // In addition this memberfunction can also be used as a shortcut to set all
242 // copy modes in one go during a tree/file creation process.
243 // However, in this case the user has to take care to only set/change the
244 // ownership (and copy mode) for empty objects (e.g. newly created objects
245 // or after invokation of the Reset() memberfunction) otherwise it will
246 // very likely result in inconsistent destructor behaviour.
250 if (fVertices) fVertices->SetOwner(own);
252 if (fJets) fJets->SetOwner(own);
255 AliJet::SetOwner(own);
257 ///////////////////////////////////////////////////////////////////////////
258 AliVertex::AliVertex(const AliVertex& v) : AliJet(v.fNtinit),AliPosition(v)
266 SetTrackCopy(v.GetTrackCopy());
267 SetVertexCopy(v.GetVertexCopy());
268 SetJetCopy(v.GetJetCopy());
271 // Copy all tracks except the ones coming from jets
273 Int_t jetflag=0,connect=0;
275 for (Int_t it=1; it<=v.fNtrk; it++)
280 jetflag=v.IsJetTrack(tx);
281 connect=v.IsConnectTrack(tx);
283 if (!jetflag && !connect) AddTrack(tx);
289 fConnects=new TObjArray(fNvmax);
290 if (!fTrackCopy) fConnects->SetOwner();
292 tx2=new AliTrack(*tx);
299 // Copy all the (secondary) vertices without re-creating connecting tracks
300 // The connecting tracks have already been copied above
302 for (Int_t iv=1; iv<=v.GetNvertices(); iv++)
305 if (vx) AddVertex(vx,0);
308 // Copy all the jets including the jet tracks for these jets for which
309 // this was also the case in the original vertex
311 for (Int_t ij=1; ij<=v.GetNjets(); ij++)
317 if (jx->GetNtracks())
322 jetflag=v.IsJetTrack(tx);
329 ///////////////////////////////////////////////////////////////////////////
330 void AliVertex::SetNvmax(Int_t n)
332 // Set the initial maximum number of (secondary) vertices
347 ///////////////////////////////////////////////////////////////////////////
348 void AliVertex::SetNjmax(Int_t n)
350 // Set the initial maximum number of jets
365 ///////////////////////////////////////////////////////////////////////////
366 void AliVertex::Reset()
368 // Reset all variables to 0 and reset all stored vertex and jet lists.
369 // The max. number of tracks is set to the initial value again
370 // The max. number of vertices is set to the default value again
371 // The max. number of jets is set to the default value again
375 Double_t a[3]={0,0,0};
376 SetPosition(a,"sph");
377 SetPositionErrors(a,"car");
380 if (fNvmax>0) SetNvmax(fNvmax);
388 if (fNjmax>0) SetNjmax(fNjmax);
401 ///////////////////////////////////////////////////////////////////////////
402 void AliVertex::ResetVertices()
404 // Reset the stored vertex list and delete all connecting tracks which
405 // were generated automatically via connect=1 in AddVertex().
406 // The max. number of vertices is set to the default value again.
407 // All physics quantities are updated according to the removal of the
408 // connecting tracks.
412 for (Int_t i=0; i<=fConnects->GetLast(); i++)
414 t=(AliTrack*)fConnects->At(i);
415 AliTrack* test=(AliTrack*)fTracks->Remove(t);
419 (Ali4Vector&)(*this)-=(Ali4Vector&)(*t);
421 if (fTrackCopy) delete t;
428 if (fNvmax>0) SetNvmax(fNvmax);
435 ///////////////////////////////////////////////////////////////////////////
436 void AliVertex::AddJet(AliJet& j,Int_t tracks)
438 // Add a jet (and its tracks) to the vertex
439 // In case the maximum number of jets has been reached,
440 // the array space will be extended automatically
442 // Note : By default the tracks of the jet are added to the current (primary)
444 // The automatic addition of the tracks of the jet can be suppressed
445 // by specifying tracks=0. In this case only the AliJet object will
446 // be stored according to the mode specified by SetJetCopy().
447 // The latter will enable jet studies based on a fixed list of tracks
448 // as contained e.g. in an AliVertex or AliEvent.
450 // In case a private copy is made, this is performed via the Clone() memberfunction.
451 // All AliJet and derived classes have the default TObject::Clone() memberfunction.
452 // However, derived classes generally contain an internal data structure which may
453 // include pointers to other objects. Therefore it is recommended to provide
454 // for all derived classes a specific copy constructor and override the default Clone()
455 // memberfunction using this copy constructor.
456 // An example for this may be seen from AliJet.
460 fJets=new TObjArray(fNjmax);
461 if (fJetCopy) fJets->SetOwner();
463 if (fNjets == fNjmax) // Check if maximum jet number is reached
466 fJets->Expand(fNjmax);
469 // Add the jet to the list
471 if (fJetCopy) jx=(AliJet*)j.Clone();
479 // Add the tracks of the jet to this vertex
484 fJetTracks=new TObjArray();
486 Int_t copy=1-(jx->GetTrackCopy());
488 for (Int_t i=1; i<=jx->GetNtracks(); i++)
499 ///////////////////////////////////////////////////////////////////////////
500 void AliVertex::AddVertex(AliVertex& v,Int_t connect)
502 // Add a (secondary) vertex to the current vertex.
503 // In case the maximum number of (secondary) vertices has been reached,
504 // the array space will be extended automatically
506 // Note : By default the 4-momentum and charge of the current (primary) vertex
507 // are updated by automatically creating the track connecting
508 // both vertices. The track parameters are taken from the
509 // 4-momentum and charge of the secondary vertex.
510 // The automatic creation of the connecting track and updating
511 // of the (primary) vertex 4-momentum and charge can be suppressed
512 // by specifying connect=0. In this case, however, the user
513 // has to introduce the connecting track lateron by hand
514 // explicitly in order to match the kinematics and charge.
516 // In case a private copy is made, this is performed via the Clone() memberfunction.
517 // All AliVertex and derived classes have the default TObject::Clone() memberfunction.
518 // However, derived classes generally contain an internal data structure which may
519 // include pointers to other objects. Therefore it is recommended to provide
520 // for all derived classes a specific copy constructor and override the default Clone()
521 // memberfunction using this copy constructor.
522 // An example for this may be seen from AliVertex.
526 fVertices=new TObjArray(fNvmax);
527 if (fVertexCopy) fVertices->SetOwner();
529 if (fNvtx == fNvmax) // Check if maximum vertex number is reached
532 fVertices->Expand(fNvmax);
535 // Add the linked (secondary) vertex to the list
537 if (fVertexCopy) vx=(AliVertex*)v.Clone();
545 // Create connecting track and update 4-momentum and charge for current vertex
548 AliTrack* t=new AliTrack();
549 t->SetBeginPoint(GetPosition());
550 t->SetEndPoint(v.GetPosition());
551 t->SetCharge(v.GetCharge());
552 t->Set4Momentum((Ali4Vector&)v);
558 fConnects=new TObjArray(fNvmax);
559 if (!fTrackCopy) fConnects->SetOwner();
564 ///////////////////////////////////////////////////////////////////////////
565 void AliVertex::Data(TString f,TString u)
567 // Provide vertex information within the coordinate frame f
569 // The string argument "u" allows to choose between different angular units
570 // in case e.g. a spherical frame is selected.
571 // u = "rad" : angles provided in radians
572 // "deg" : angles provided in degrees
574 // The defaults are f="car" and u="rad".
576 const char* name=GetName();
577 const char* title=GetTitle();
578 cout << " *AliVertex::Data*";
579 if (strlen(name)) cout << " Name : " << GetName();
580 if (strlen(title)) cout << " Title : " << GetTitle();
582 cout << " Id : " << fUserId << " Invmass : " << GetInvmass()
583 << " Charge : " << GetCharge() << " Momentum : " << GetMomentum()
584 << " Ntracks : " << GetNtracks() << endl;
585 cout << " Nvertices : " << fNvtx << " Njets : " << fNjets
586 << " Energy scale : " << fEscale << " GeV" << endl;
588 Ali4Vector::Data(f,u);
590 AliPosition::Data(f,u);
592 ///////////////////////////////////////////////////////////////////////////
593 void AliVertex::List(TString f,TString u)
595 // Provide primary track and sec. vertex information within the coordinate frame f
597 // The string argument "u" allows to choose between different angular units
598 // in case e.g. a spherical frame is selected.
599 // u = "rad" : angles provided in radians
600 // "deg" : angles provided in degrees
602 // The defaults are f="car" and u="rad".
604 Data(f,u); // Information of the current vertex
606 // The tracks of this vertex
608 for (Int_t it=1; it<=GetNtracks(); it++)
613 cout << " ---Track no. " << it << endl;
619 cout << " *AliVertex::List* Error : No track present." << endl;
623 // The secondary vertices of this vertex
625 for (Int_t iv=1; iv<=GetNvertices(); iv++)
630 cout << " ---Level 1 sec. vertex no. " << iv << endl;
636 cout << " *AliVertex::List* Error : No sec. vertex present." << endl;
640 ///////////////////////////////////////////////////////////////////////////
641 void AliVertex::ListAll(TString f,TString u)
643 // Provide complete (sec) vertex and (decay) track info within the coordinate frame f
645 // The string argument "u" allows to choose between different angular units
646 // in case e.g. a spherical frame is selected.
647 // u = "rad" : angles provided in radians
648 // "deg" : angles provided in degrees
650 // The defaults are f="car" and u="rad".
652 Data(f,u); // Information of the current vertex
654 // The tracks of this vertex
656 for (Int_t it=1; it<=GetNtracks(); it++)
661 cout << " ---Track no. " << it << endl;
667 cout << " *AliVertex::ListAll* Error : No track present." << endl;
672 Dumps(v,1,f,u); // Information of all sec. vertices
674 //////////////////////////////////////////////////////////////////////////
675 void AliVertex::Dumps(AliVertex* v,Int_t n,TString f,TString u)
677 // Recursively provide the info of all secondary vertices of this vertex
679 for (Int_t iv=1; iv<=v->GetNvertices(); iv++)
684 cout << " ---Level " << n << " sec. vertex no. " << iv << endl;
688 // The tracks of this vertex
690 for (Int_t it=1; it<=vs->GetNtracks(); it++)
695 cout << " ---Track no. " << it << endl;
701 cout << " *AliVertex::Dumps* Error : No track present." << endl;
705 // Go for next sec. vertex level of this sec. vertex recursively
710 cout << " *AliVertex::Dumps* Error : No sec. vertex present." << endl;
714 //////////////////////////////////////////////////////////////////////////
715 Int_t AliVertex::GetNvertices() const
717 // Return the current number of (secondary) vertices
720 ///////////////////////////////////////////////////////////////////////////
721 AliVertex* AliVertex::GetVertex(Int_t i) const
723 // Return the i-th (secondary) vertex of the current vertex
726 cout << " *AliVertex*::GetVertex* No (secondary) vertices present." << endl;
733 cout << " *AliVertex*::GetVertex* Invalid argument i : " << i
734 << " Nvtx = " << fNvtx << endl;
739 return (AliVertex*)fVertices->At(i-1);
743 ///////////////////////////////////////////////////////////////////////////
744 AliVertex* AliVertex::GetIdVertex(Int_t id) const
746 // Return the (sec.) vertex with user identifier "id"
751 cout << " *AliVertex*::GetIdVertex* No (secondary) vertices present." << endl;
756 for (Int_t i=0; i<fNvtx; i++)
758 vx=(AliVertex*)fVertices->At(i);
759 if (id == vx->GetId()) v=vx;
764 ///////////////////////////////////////////////////////////////////////////
765 void AliVertex::SetVertexCopy(Int_t j)
767 // (De)activate the creation of private copies of the added vertices.
768 // j=0 ==> No private copies are made; pointers of original vertices are stored.
769 // j=1 ==> Private copies of the vertices are made and these pointers are stored.
771 // Note : Once the storage contains pointer(s) to AliVertex objects one cannot
772 // change the VertexCopy mode anymore.
773 // To change the VertexCopy mode for an existing AliVertex containing
774 // vertices one first has to invoke Reset().
783 cout << "*AliVertex::SetVertexCopy* Invalid argument : " << j << endl;
788 cout << "*AliVertex::SetVertexCopy* Storage already contained vertices."
789 << " ==> VertexCopy mode not changed." << endl;
792 ///////////////////////////////////////////////////////////////////////////
793 Int_t AliVertex::GetVertexCopy() const
795 // Provide value of the VertexCopy mode.
796 // 0 ==> No private copies are made; pointers of original vertices are stored.
797 // 1 ==> Private copies of the vertices are made and these pointers are stored.
800 ///////////////////////////////////////////////////////////////////////////
801 Int_t AliVertex::GetNjets() const
803 // Return the current number of jets
806 ///////////////////////////////////////////////////////////////////////////
807 AliJet* AliVertex::GetJet(Int_t i) const
809 // Return the i-th jet of the current vertex
812 cout << " *AliVertex*::GetJet* No jets present." << endl;
817 if (i<=0 || i>fNjets)
819 cout << " *AliVertex*::GetJet* Invalid argument i : " << i
820 << " Njets = " << fNjets << endl;
825 return (AliJet*)fJets->At(i-1);
829 ///////////////////////////////////////////////////////////////////////////
830 AliJet* AliVertex::GetIdJet(Int_t id) const
832 // Return the jet with user identifier "id"
837 cout << " *AliVertex*::GetIdJet* No jets present." << endl;
842 for (Int_t i=0; i<fNjets; i++)
844 jx=(AliJet*)fJets->At(i);
845 if (id == jx->GetId()) j=jx;
850 ///////////////////////////////////////////////////////////////////////////
851 void AliVertex::SetJetCopy(Int_t j)
853 // (De)activate the creation of private copies of the added jets.
854 // j=0 ==> No private copies are made; pointers of original jets are stored.
855 // j=1 ==> Private copies of the jets are made and these pointers are stored.
857 // Note : Once the storage contains pointer(s) to AliJet objects one cannot
858 // change the JetCopy mode anymore.
859 // To change the JetCopy mode for an existing AliVertex containing
860 // jets one first has to invoke Reset().
869 cout << "*AliVertex::SetJetCopy* Invalid argument : " << j << endl;
874 cout << "*AliVertex::SetJetCopy* Storage already contained jets."
875 << " ==> JetCopy mode not changed." << endl;
878 ///////////////////////////////////////////////////////////////////////////
879 Int_t AliVertex::GetJetCopy() const
881 // Provide value of the JetCopy mode.
882 // 0 ==> No private copies are made; pointers of original jets are stored.
883 // 1 ==> Private copies of the jets are made and these pointers are stored.
886 ///////////////////////////////////////////////////////////////////////////
887 Int_t AliVertex::IsConnectTrack(AliTrack* t) const
889 // Indicate whether a track from the tracklist was created via the
890 // connection of a (secondary) vertex or not.
891 // In case the track was the result of (secondary) vertex addition the
892 // return value is 1, otherwise the value 0 will be returned.
896 if (fConnects->FindObject(t)) connect=1;
900 ///////////////////////////////////////////////////////////////////////////
901 Int_t AliVertex::IsJetTrack(AliTrack* t) const
903 // Indicate whether a track from the tracklist was created via the
904 // addition of a jet or not.
905 // In case the track was the result of jet addition the return value is 1,
906 // otherwise the value 0 will be returned.
910 if (fJetTracks->FindObject(t)) jetflag=1;
914 ///////////////////////////////////////////////////////////////////////////
915 void AliVertex::Draw(Int_t secs,Int_t cons,Int_t jets)
917 // 3-Dimensional visualisation of an AliVertex with its attributes.
918 // The displayed tracklength is proportional to the momentum of the track.
920 // Color conventions :
921 // -------------------
922 // positive track : red
923 // neutral track : green
924 // negative track : blue
925 // jet-track : magenta (if explicit marking selected)
927 // secs = 1 --> Draw secondary vertices. (Default)
928 // 0 --> Don't draw secondary vertices.
930 // cons = 1 --> Draw (auto generated) connecting tracks. (Default)
931 // 0 --> Don't draw (auto generated) connecting tracks.
933 // jets = 1 --> Mark tracks belonging to jets.
934 // 0 --> Don't mark jet-tracks. (Default)
938 // Auto generated connecting tracks will be drawn as thin lines.
939 // Tracks belonging to jets will be marked as somewhat thinner magenta lines.
940 // This memberfunction is used recursively.
942 Double_t vec[3]={0,0,0};
951 if (fLines) delete fLines;
952 fLines=new TObjArray();
955 Int_t ntk=GetNtracks();
956 for (Int_t jtk=1; jtk<=ntk; jtk++)
962 charge=tx->GetCharge();
964 TPolyLine3D* line=new TPolyLine3D();
967 if (IsConnectTrack(tx))
971 r=tx->GetBeginPoint();
973 r->GetPosition(vec,"car");
974 line->SetNextPoint(vec[0],vec[1],vec[2]);
977 r->GetPosition(vec,"car");
978 line->SetNextPoint(vec[0],vec[1],vec[2]);
979 line->SetLineWidth(1);
984 r=tx->GetClosestPoint();
986 r->GetPosition(vec,"car");
987 line->SetNextPoint(vec[0],vec[1],vec[2]);
988 p=tx->Get3Momentum();
990 p.GetVector(vec,"car");
991 line->SetNextPoint(vec[0],vec[1],vec[2]);
992 line->SetLineWidth(3);
995 line->SetLineColor(kGreen); // Neutral track
996 if (charge>0) line->SetLineColor(kRed); // Positive track
997 if (charge<0) line->SetLineColor(kBlue); // Negative track
999 // Mark tracks belonging to jets
1004 line->SetLineWidth(2);
1005 line->SetLineColor(kMagenta);
1012 // Go for secondary vertices if selected
1015 Int_t nvtx=GetNvertices();
1016 for (Int_t jvtx=1; jvtx<=nvtx; jvtx++)
1019 if (vx) vx->Draw(secs,cons,jets);
1023 ///////////////////////////////////////////////////////////////////////////
1024 TObjArray* AliVertex::SortJets(Int_t mode,TObjArray* jets)
1026 // Order the references to an array of jets by looping over the input array "jets"
1027 // and checking the value of a certain observable.
1028 // The ordered array is returned as a TObjArray.
1029 // In case jets=0 (default), the registered jets of the current vertex are used.
1030 // Note that the original jet array is not modified.
1031 // Via the "mode" argument the user can specify the observable to be checked upon
1032 // and specify whether sorting should be performed in decreasing order (mode<0)
1033 // or in increasing order (mode>0).
1035 // The convention for the observable selection is the following :
1036 // mode : 1 ==> Number of tracks in the jet
1038 // 3 ==> Jet momentum
1039 // 4 ==> Invariant mass of the jet
1040 // 5 ==> Transverse momentum of the jet
1041 // 6 ==> Longitudinal momentum of the jet
1042 // 7 ==> Transverse energy of the jet
1043 // 8 ==> Longitudinal energy of the jet
1044 // 9 ==> Transverse mass of the jet
1045 // 10 ==> Jet rapidity
1046 // 11 ==> Pseudo-rapidity of the jet
1047 // 12 ==> Number of associated signals
1048 // 13 ==> Total charge of the jet
1050 // The default is mode=-1.
1052 // Note : This sorting routine uses a common area in memory, which is used
1053 // by various other sorting facilities as well.
1054 // This means that the resulting sorted TObjArray may be overwritten
1055 // when another sorting is invoked.
1056 // To retain the sorted list of pointers, the user is advised to copy
1057 // the pointers contained in the returned TObjArray into a private
1058 // TObjArray instance.
1066 if (!jets) jets=fJets;
1068 if (!mode || abs(mode)>13 || !jets) return fSelected;
1070 Int_t njets=jets->GetEntries();
1077 fSelected=new TObjArray(njets);
1080 Double_t val1,val2; // Values of the observable to be tested upon
1083 for (Int_t i=0; i<njets; i++) // Loop over all jets of the array
1085 AliJet* jx=(AliJet*)jets->At(i);
1089 if (nord == 0) // store the first jet at the first ordered position
1092 fSelected->AddAt(jx,nord-1);
1096 for (Int_t j=0; j<=nord; j++) // put jet in the right ordered position
1098 if (j == nord) // jet has smallest (mode<0) or largest (mode>0) observable value seen so far
1101 fSelected->AddAt(jx,j); // add jet at the end
1102 break; // go for next jet
1111 val1=jx->GetNtracks();
1112 val2=((AliJet*)fSelected->At(j))->GetNtracks();
1115 val1=jx->GetEnergy(1);
1116 val2=((AliJet*)fSelected->At(j))->GetEnergy(1);
1119 val1=jx->GetMomentum(1);
1120 val2=((AliJet*)fSelected->At(j))->GetMomentum(1);
1123 val1=jx->GetInvmass(1);
1124 val2=((AliJet*)fSelected->At(j))->GetInvmass(1);
1128 val2=((AliJet*)fSelected->At(j))->GetPt(1);
1132 val2=((AliJet*)fSelected->At(j))->GetPl(1);
1136 val2=((AliJet*)fSelected->At(j))->GetEt(1);
1140 val2=((AliJet*)fSelected->At(j))->GetEl(1);
1144 val2=((AliJet*)fSelected->At(j))->GetMt(1);
1147 val1=jx->GetRapidity();
1148 val2=((AliJet*)fSelected->At(j))->GetRapidity();
1151 val1=jx->GetPseudoRapidity();
1152 val2=((AliJet*)fSelected->At(j))->GetPseudoRapidity();
1155 val1=jx->GetNsignals();
1156 val2=((AliJet*)fSelected->At(j))->GetNsignals();
1159 val1=jx->GetCharge();
1160 val2=((AliJet*)fSelected->At(j))->GetCharge();
1164 if (mode<0 && val1 <= val2) continue;
1165 if (mode>0 && val1 >= val2) continue;
1168 for (Int_t k=nord-1; k>j; k--) // create empty position
1170 fSelected->AddAt(fSelected->At(k-1),k);
1172 fSelected->AddAt(jx,j); // put jet at empty position
1173 break; // go for next jet
1178 ///////////////////////////////////////////////////////////////////////////
1179 TObject* AliVertex::Clone(const char* name) const
1181 // Make a deep copy of the current object and provide the pointer to the copy.
1182 // This memberfunction enables automatic creation of new objects of the
1183 // correct type depending on the object type, a feature which may be very useful
1184 // for containers when adding objects in case the container owns the objects.
1185 // This feature allows e.g. AliEvent to store either AliVertex objects or
1186 // objects derived from AliVertex via the AddVertex memberfunction, provided
1187 // these derived classes also have a proper Clone memberfunction.
1189 AliVertex* vtx=new AliVertex(*this);
1192 if (strlen(name)) vtx->SetName(name);
1196 ///////////////////////////////////////////////////////////////////////////