+ if (!fVertices)
+ {
+ cout << " *AliVertex*::GetVertex* No (secondary) vertices present." << endl;
+ return 0;
+ }
+ else
+ {
+ if (i<=0 || i>fNvtx)
+ {
+ cout << " *AliVertex*::GetVertex* Invalid argument i : " << i
+ << " Nvtx = " << fNvtx << endl;
+ return 0;
+ }
+ else
+ {
+ return (AliVertex*)fVertices->At(i-1);
+ }
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+AliVertex* AliVertex::GetIdVertex(Int_t id) const
+{
+// Return the (sec.) vertex with user identifier "id"
+ AliVertex* vx=0;
+ AliVertex* v=0;
+ if (!fVertices)
+ {
+ cout << " *AliVertex*::GetIdVertex* No (secondary) vertices present." << endl;
+ return 0;
+ }
+ else
+ {
+ for (Int_t i=0; i<fNvtx; i++)
+ {
+ vx=(AliVertex*)fVertices->At(i);
+ if (id == vx->GetId()) v=vx;
+ }
+ return v;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+void AliVertex::SetVertexCopy(Int_t j)
+{
+// (De)activate the creation of private copies of the added vertices.
+// j=0 ==> No private copies are made; pointers of original vertices are stored.
+// j=1 ==> Private copies of the vertices are made and these pointers are stored.
+//
+// Note : Once the storage contains pointer(s) to AliVertex objects one cannot
+// change the VertexCopy mode anymore.
+// To change the VertexCopy mode for an existing AliVertex containing
+// vertices one first has to invoke Reset().
+ if (!fVertices)
+ {
+ if (j==0 || j==1)
+ {
+ fVertexCopy=j;
+ }
+ else
+ {
+ cout << "*AliVertex::SetVertexCopy* Invalid argument : " << j << endl;
+ }
+ }
+ else
+ {
+ cout << "*AliVertex::SetVertexCopy* Storage already contained vertices."
+ << " ==> VertexCopy mode not changed." << endl;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliVertex::GetVertexCopy() const
+{
+// Provide value of the VertexCopy mode.
+// 0 ==> No private copies are made; pointers of original vertices are stored.
+// 1 ==> Private copies of the vertices are made and these pointers are stored.
+ return fVertexCopy;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliVertex::GetNjets() const
+{
+// Return the current number of jets
+ return fNjets;
+}
+///////////////////////////////////////////////////////////////////////////
+AliJet* AliVertex::GetJet(Int_t i) const
+{
+// Return the i-th jet of the current vertex
+ if (!fJets)
+ {
+ cout << " *AliVertex*::GetJet* No jets present." << endl;
+ return 0;
+ }
+ else
+ {
+ if (i<=0 || i>fNjets)
+ {
+ cout << " *AliVertex*::GetJet* Invalid argument i : " << i
+ << " Njets = " << fNjets << endl;
+ return 0;
+ }
+ else
+ {
+ return (AliJet*)fJets->At(i-1);
+ }
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+AliJet* AliVertex::GetIdJet(Int_t id) const
+{
+// Return the jet with user identifier "id"
+ AliJet* jx=0;
+ AliJet* j=0;
+ if (!fJets)
+ {
+ cout << " *AliVertex*::GetIdJet* No jets present." << endl;
+ return 0;
+ }
+ else
+ {
+ for (Int_t i=0; i<fNjets; i++)
+ {
+ jx=(AliJet*)fJets->At(i);
+ if (id == jx->GetId()) j=jx;
+ }
+ return j;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+void AliVertex::SetJetCopy(Int_t j)
+{
+// (De)activate the creation of private copies of the added jets.
+// j=0 ==> No private copies are made; pointers of original jets are stored.
+// j=1 ==> Private copies of the jets are made and these pointers are stored.
+//
+// Note : Once the storage contains pointer(s) to AliJet objects one cannot
+// change the JetCopy mode anymore.
+// To change the JetCopy mode for an existing AliVertex containing
+// jets one first has to invoke Reset().
+ if (!fJets)
+ {
+ if (j==0 || j==1)
+ {
+ fJetCopy=j;
+ }
+ else
+ {
+ cout << "*AliVertex::SetJetCopy* Invalid argument : " << j << endl;
+ }
+ }
+ else
+ {
+ cout << "*AliVertex::SetJetCopy* Storage already contained jets."
+ << " ==> JetCopy mode not changed." << endl;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliVertex::GetJetCopy() const
+{
+// Provide value of the JetCopy mode.
+// 0 ==> No private copies are made; pointers of original jets are stored.
+// 1 ==> Private copies of the jets are made and these pointers are stored.
+ return fJetCopy;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliVertex::IsConnectTrack(AliTrack* t) const
+{
+// Indicate whether a track from the tracklist was created via the
+// connection of a (secondary) vertex or not.
+// In case the track was the result of (secondary) vertex addition the
+// return value is 1, otherwise the value 0 will be returned.
+ Int_t connect=0;
+ if (fConnects)
+ {
+ if (fConnects->FindObject(t)) connect=1;
+ }
+ return connect;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliVertex::IsJetTrack(AliTrack* t) const
+{
+// Indicate whether a track from the tracklist was created via the
+// addition of a jet or not.
+// In case the track was the result of jet addition the return value is 1,
+// otherwise the value 0 will be returned.
+ Int_t jetflag=0;
+ if (fJetTracks)
+ {
+ if (fJetTracks->FindObject(t)) jetflag=1;
+ }
+ return jetflag;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliVertex::Draw(Int_t secs,Int_t cons,Int_t jets)
+{
+// 3-Dimensional visualisation of an AliVertex with its attributes.
+// The displayed tracklength is proportional to the momentum of the track.
+//
+// Color conventions :
+// -------------------
+// positive track : red
+// neutral track : green
+// negative track : blue
+// jet-track : magenta (if explicit marking selected)
+//
+// secs = 1 --> Draw secondary vertices. (Default)
+// 0 --> Don't draw secondary vertices.
+//
+// cons = 1 --> Draw (auto generated) connecting tracks. (Default)
+// 0 --> Don't draw (auto generated) connecting tracks.
+//
+// jets = 1 --> Mark tracks belonging to jets.
+// 0 --> Don't mark jet-tracks. (Default)
+//
+// Notes :
+// -------
+// Auto generated connecting tracks will be drawn as thin lines.
+// Tracks belonging to jets will be marked as somewhat thinner magenta lines.
+// This memberfunction is used recursively.
+//
+ Double_t vec[3]={0,0,0};
+ AliTrack* tx=0;
+ AliVertex* vx=0;
+ AliPosition* r=0;
+ Ali3Vector p;
+ Float_t charge;
+
+ AliPosition dummy;
+
+ if (fLines) delete fLines;
+ fLines=new TObjArray();
+ fLines->SetOwner();
+
+ Int_t ntk=GetNtracks();
+ for (Int_t jtk=1; jtk<=ntk; jtk++)
+ {
+ tx=GetTrack(jtk);
+
+ if (!tx) continue;
+
+ charge=tx->GetCharge();
+
+ TPolyLine3D* line=new TPolyLine3D();
+ fLines->Add(line);
+
+ if (IsConnectTrack(tx))
+ {
+ if (cons==1)
+ {
+ r=tx->GetBeginPoint();
+ if (!r) r=&dummy;
+ r->GetPosition(vec,"car");
+ line->SetNextPoint(vec[0],vec[1],vec[2]);
+ r=tx->GetEndPoint();
+ if (!r) r=&dummy;
+ r->GetPosition(vec,"car");
+ line->SetNextPoint(vec[0],vec[1],vec[2]);
+ line->SetLineWidth(1);
+ }
+ }
+ else
+ {
+ r=tx->GetClosestPoint();
+ if (!r) r=&dummy;
+ r->GetPosition(vec,"car");
+ line->SetNextPoint(vec[0],vec[1],vec[2]);
+ p=tx->Get3Momentum();
+ p=p+(*r);
+ p.GetVector(vec,"car");
+ line->SetNextPoint(vec[0],vec[1],vec[2]);
+ line->SetLineWidth(3);
+ }
+
+ line->SetLineColor(kGreen); // Neutral track
+ if (charge>0) line->SetLineColor(kRed); // Positive track
+ if (charge<0) line->SetLineColor(kBlue); // Negative track
+
+ // Mark tracks belonging to jets
+ if (IsJetTrack(tx))
+ {
+ if (jets==1)
+ {
+ line->SetLineWidth(2);
+ line->SetLineColor(kMagenta);
+ }
+ }
+
+ line->Draw();
+ }
+
+ // Go for secondary vertices if selected
+ if (secs==1)
+ {
+ Int_t nvtx=GetNvertices();
+ for (Int_t jvtx=1; jvtx<=nvtx; jvtx++)
+ {
+ vx=GetVertex(jvtx);
+ if (vx) vx->Draw(secs,cons,jets);
+ }
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+TObjArray* AliVertex::SortJets(Int_t mode,TObjArray* jets)
+{
+// Order the references to an array of jets by looping over the input array "jets"
+// and checking the value of a certain observable.
+// The ordered array is returned as a TObjArray.
+// In case jets=0 (default), the registered jets of the current vertex are used.
+// Note that the original jet array is not modified.
+// Via the "mode" argument the user can specify the observable to be checked upon
+// and specify whether sorting should be performed in decreasing order (mode<0)
+// or in increasing order (mode>0).
+//
+// The convention for the observable selection is the following :
+// mode : 1 ==> Number of tracks in the jet
+// 2 ==> Jet energy
+// 3 ==> Jet momentum
+// 4 ==> Invariant mass of the jet
+// 5 ==> Transverse momentum of the jet
+// 6 ==> Longitudinal momentum of the jet
+// 7 ==> Transverse energy of the jet
+// 8 ==> Longitudinal energy of the jet
+// 9 ==> Transverse mass of the jet
+// 10 ==> Jet rapidity
+// 11 ==> Pseudo-rapidity of the jet
+// 12 ==> Number of associated signals
+// 13 ==> Total charge of the jet
+//
+// The default is mode=-1.
+//
+// Note : This sorting routine uses a common area in memory, which is used
+// by various other sorting facilities as well.
+// This means that the resulting sorted TObjArray may be overwritten
+// when another sorting is invoked.
+// To retain the sorted list of pointers, the user is advised to copy
+// the pointers contained in the returned TObjArray into a private
+// TObjArray instance.
+
+ if (fSelected)
+ {
+ delete fSelected;
+ fSelected=0;
+ }
+
+ if (!jets) jets=fJets;
+
+ if (!mode || abs(mode)>13 || !jets) return fSelected;
+
+ Int_t njets=jets->GetEntries();
+ if (!njets)
+ {
+ return fSelected;
+ }
+ else
+ {
+ fSelected=new TObjArray(njets);
+ }
+
+ Double_t val1,val2; // Values of the observable to be tested upon
+
+ Int_t nord=0;
+ for (Int_t i=0; i<njets; i++) // Loop over all jets of the array
+ {
+ AliJet* jx=(AliJet*)jets->At(i);
+
+ if (!jx) continue;
+
+ if (nord == 0) // store the first jet at the first ordered position
+ {
+ nord++;
+ fSelected->AddAt(jx,nord-1);
+ continue;
+ }
+
+ for (Int_t j=0; j<=nord; j++) // put jet in the right ordered position
+ {
+ if (j == nord) // jet has smallest (mode<0) or largest (mode>0) observable value seen so far
+ {
+ nord++;
+ fSelected->AddAt(jx,j); // add jet at the end
+ break; // go for next jet
+ }
+
+ val1=0;
+ val2=0;
+
+ switch (abs(mode))
+ {
+ case 1:
+ val1=jx->GetNtracks();
+ val2=((AliJet*)fSelected->At(j))->GetNtracks();
+ break;
+ case 2:
+ val1=jx->GetEnergy(1);
+ val2=((AliJet*)fSelected->At(j))->GetEnergy(1);
+ break;
+ case 3:
+ val1=jx->GetMomentum(1);
+ val2=((AliJet*)fSelected->At(j))->GetMomentum(1);
+ break;
+ case 4:
+ val1=jx->GetInvmass(1);
+ val2=((AliJet*)fSelected->At(j))->GetInvmass(1);
+ break;
+ case 5:
+ val1=jx->GetPt(1);
+ val2=((AliJet*)fSelected->At(j))->GetPt(1);
+ break;
+ case 6:
+ val1=jx->GetPl(1);
+ val2=((AliJet*)fSelected->At(j))->GetPl(1);
+ break;
+ case 7:
+ val1=jx->GetEt(1);
+ val2=((AliJet*)fSelected->At(j))->GetEt(1);
+ break;
+ case 8:
+ val1=jx->GetEl(1);
+ val2=((AliJet*)fSelected->At(j))->GetEl(1);
+ break;
+ case 9:
+ val1=jx->GetMt(1);
+ val2=((AliJet*)fSelected->At(j))->GetMt(1);
+ break;
+ case 10:
+ val1=jx->GetRapidity();
+ val2=((AliJet*)fSelected->At(j))->GetRapidity();
+ break;
+ case 11:
+ val1=jx->GetPseudoRapidity();
+ val2=((AliJet*)fSelected->At(j))->GetPseudoRapidity();
+ break;
+ case 12:
+ val1=jx->GetNsignals();
+ val2=((AliJet*)fSelected->At(j))->GetNsignals();
+ break;
+ case 13:
+ val1=jx->GetCharge();
+ val2=((AliJet*)fSelected->At(j))->GetCharge();
+ break;
+ }
+
+ if (mode<0 && val1 <= val2) continue;
+ if (mode>0 && val1 >= val2) continue;
+
+ nord++;
+ for (Int_t k=nord-1; k>j; k--) // create empty position
+ {
+ fSelected->AddAt(fSelected->At(k-1),k);
+ }
+ fSelected->AddAt(jx,j); // put jet at empty position
+ break; // go for next jet
+ }
+ }
+ return fSelected;
+}
+///////////////////////////////////////////////////////////////////////////
+TObject* AliVertex::Clone(const char* name) const
+{
+// Make a deep copy of the current object and provide the pointer to the copy.
+// This memberfunction enables automatic creation of new objects of the
+// correct type depending on the object type, a feature which may be very useful
+// for containers when adding objects in case the container owns the objects.
+// This feature allows e.g. AliEvent to store either AliVertex objects or
+// objects derived from AliVertex via the AddVertex memberfunction, provided
+// these derived classes also have a proper Clone memberfunction.
+
+ AliVertex* vtx=new AliVertex(*this);
+ if (name)
+ {
+ if (strlen(name)) vtx->SetName(name);
+ }
+ return vtx;