//
// Note : Also (secondary) vertices can be added to a vertex.
//
+// To provide maximal flexibility to the user, two modes of vertex storage
+// are provided by means of the memberfunction SetVertexCopy().
+// The same holds for the storage of jets via SetJetCopy().
+//
+// a) SetVertexCopy(0) (which is the default).
+// Only the pointers of the 'added' vertices are stored.
+// This mode is typically used by making vertex studies based on a fixed list
+// of vertices which stays under user control or is contained for instance
+// in an AliEvent.
+// In this way the AliVertex just represents a 'logical structure' for the
+// physics analysis which can be embedded in e.g. an AliEvent or AliVertex.
+// Modifications made to the original vertices also affect the AliVertex objects
+// which are stored.
+// b) SetVertexCopy(1).
+// Of every 'added' vertex a private copy will be made of which the pointer
+// will be stored.
+// In this way the AliVertex represents an entity on its own and modifications
+// made to the original vertices do not affect the AliVertex objects which are
+// stored.
+// This mode will allow 'adding' many different AliVertex objects by
+// creating only one AliVertex instance in the main programme and using the
+// AliVertex::Reset() and AliVertex::AddTrack and parameter setting memberfunctions.
+//
// Coding example to make 3 vertices v1, v2 and v3.
// ------------------------------------------------
// v1 contains the tracks 1,2,3 and 4
-// v2 contains the tracks 5,6 and 7
+// v2 contains many different tracks
// v3 contains the jets 1 and 2
//
-// AliTrack t1,t2,t3,t4,t5,t6,t7;
+// AliTrack t1,t2,t3,t4;
// ...
// ... // code to fill the track data
// ...
// ... // code to fill the jet data
// ...
//
-// AliVertex v1(5);
+// AliVertex v1;
+// v1.SetVertexCopy(1);
//
// v1.AddTrack(t1);
// v1.AddTrack(t2);
// Float_t r1[3]={2.4,0.1,-8.5};
// v1.SetPosition(r1,"car");
//
-// AliVertex v2(2);
-// v2.AddTrack(t5);
-// v2.AddTrack(t6);
-// v2.AddTrack(t7);
+// AliVertex v2;
+// v2.SetTrackCopy(1);
+//
+// AliTrack* tx=new AliTrack();
+// for (Int_t i=0; i<10; i++)
+// {
+// ...
+// ... // code to fill the track data
+// ...
+// v2.AddTrack(tx);
+// tx->Reset();
+// }
//
// Float_t r2[3]={1.6,-3.2,5.7};
// v2.SetPosition(r2,"car");
// v1.Reset();
// v1.SetNvmax(25); // Increase initial no. of sec. vertices
// v1.AddTrack(t3);
-// v1.AddTrack(t7);
+// v1.AddTrack(t4);
// v1.AddJet(j2);
// Float_t pos[3]={7,9,4};
// v1.SetPosition(pos,"car");
fNvmax=0;
fVertices=0;
fConnects=0;
+ fVertexCopy=0;
+ fNjmax=0;
+ fJets=0;
+ fJetCopy=0;
Reset();
SetNtinit();
SetNvmax();
+ SetNjmax();
}
///////////////////////////////////////////////////////////////////////////
AliVertex::AliVertex(Int_t n)
fNvmax=0;
fVertices=0;
fConnects=0;
+ fVertexCopy=0;
+ fNjmax=0;
+ fJets=0;
+ fJetCopy=0;
Reset();
if (n > 0)
{
SetNtinit();
}
SetNvmax();
+ SetNjmax();
}
///////////////////////////////////////////////////////////////////////////
AliVertex::~AliVertex()
{
// Default destructor
- if (fVertices) delete fVertices;
- fVertices=0;
+ if (fVertices)
+ {
+ if (fVertexCopy) fVertices->Delete();
+ delete fVertices;
+ fVertices=0;
+ }
if (fConnects)
{
fConnects->Delete();
delete fConnects;
fConnects=0;
}
+ if (fJets)
+ {
+ if (fJetCopy) fJets->Delete();
+ delete fJets;
+ fJets=0;
+ }
}
///////////////////////////////////////////////////////////////////////////
void AliVertex::SetNvmax(Int_t n)
{
fNvmax=1;
}
- if (fVertices) delete fVertices;
- fVertices=new TObjArray(fNvmax);
+ if (fVertices)
+ {
+ if (fVertexCopy) fVertices->Delete();
+ delete fVertices;
+ fVertices=0;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+void AliVertex::SetNjmax(Int_t n)
+{
+// Set the initial maximum number of jets
+ if (n > 0)
+ {
+ fNjmax=n;
+ }
+ else
+ {
+ fNjmax=1;
+ }
+ if (fJets)
+ {
+ if (fJetCopy) fJets->Delete();
+ delete fJets;
+ fJets=0;
+ }
}
///////////////////////////////////////////////////////////////////////////
void AliVertex::Reset()
delete fConnects;
fConnects=0;
}
+
+ fNjets=0;
+ if (fNjmax>0) SetNjmax(fNjmax);
}
///////////////////////////////////////////////////////////////////////////
-void AliVertex::AddJet(AliJet& j)
+void AliVertex::AddJet(AliJet& j,Int_t tracks)
{
-// Add the tracks of a jet to the vertex
- AliTrack* tj;
- for (Int_t i=1; i<=j.GetNtracks(); i++)
+// Add a jet (and its tracks) to the vertex
+// In case the maximum number of jets has been reached,
+// the array space will be extended automatically
+//
+// Note : By default the tracks of the jet are added to the current (primary)
+// vertex.
+// The automatic addition of the tracks of the jet can be suppressed
+// by specifying tracks=0. In this case only the AliJet object will
+// be stored according to the mode specified by SetJetCopy().
+// The latter will enable jet studies based on a fixed list of tracks
+// as contained e.g. in an AliVertex or AliEvent.
+ if (!fJets) fJets=new TObjArray(fNjmax);
+ if (fNjets == fNjmax) // Check if maximum jet number is reached
{
- tj=j.GetTrack(i);
- AliJet::AddTrack(tj);
+ fNjmax++;
+ fJets->Expand(fNjmax);
+ }
+
+ // Add the jet to the list
+ fNjets++;
+ if (fJetCopy)
+ {
+ AliJet* jx=new AliJet(j);
+ fJets->Add(jx);
+ }
+ else
+ {
+ fJets->Add(&j);
+ }
+
+ // Add the tracks of the jet to this vertex
+ if (tracks)
+ {
+ AliTrack* tj;
+ for (Int_t i=1; i<=j.GetNtracks(); i++)
+ {
+ tj=j.GetTrack(i);
+ AddTrack(tj);
+ }
}
}
///////////////////////////////////////////////////////////////////////////
// has to introduce the connecting track lateron by hand
// explicitly in order to match the kinematics and charge.
//
+ if (!fVertices) fVertices=new TObjArray(fNvmax);
if (fNvtx == fNvmax) // Check if maximum vertex number is reached
{
fNvmax++;
// Add the linked (secondary) vertex to the list
fNvtx++;
- fVertices->Add(&v);
+ if (fVertexCopy)
+ {
+ AliVertex* vx=new AliVertex(v);
+ fVertices->Add(vx);
+ }
+ else
+ {
+ fVertices->Add(&v);
+ }
// Create connecting track and update 4-momentum and charge for current vertex
if (connect)
t->Set3Momentum(p);
t->SetInvariant(v2,dv2);
- AliJet::AddTrack(t);
+ AddTrack(t);
if (!fConnects) fConnects=new TObjArray(fNvmax);
fConnects->Add(t);
// Provide vertex information within the coordinate frame f
cout << " *AliVertex::Info* Invmass : " << GetInvmass()
<< " Charge : " << GetCharge() << " Momentum : " << GetMomentum()
- << " Ntracks : " << GetNtracks() << " Nvertices : " << fNvtx << endl;
+ << " Ntracks : " << GetNtracks() << " Nvertices : " << fNvtx
+ << " Njets : " << fNjets << endl;
cout << " ";
Ali4Vector::Info(f);
cout << " Position";
AliVertex* AliVertex::GetVertex(Int_t i)
{
// Return the i-th (secondary) vertex of the current vertex
- return (AliVertex*)fVertices->At(i-1);
+ 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);
+ }
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+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()
+{
+// 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()
+{
+// Return the current number of jets
+ return fNjets;
+}
+///////////////////////////////////////////////////////////////////////////
+AliJet* AliVertex::GetJet(Int_t i)
+{
+// 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);
+ }
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+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()
+{
+// 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;
}
///////////////////////////////////////////////////////////////////////////
AliVertex(Int_t n); // Create a vertex to hold initially n tracks
~AliVertex(); // Default destructor
void Reset(); // Reset all values
- void AddJet(AliJet& j); // Add a jet of tracks to the vertex
+ void AddJet(AliJet& j,Int_t tracks=1); // Add a jet (and its tracks) to the vertex
void AddVertex(AliVertex& v,Int_t connect=1);// Add (and connect) a (sec.) vertex to the current vertex
- void AddJet(AliJet* j) { AddJet(*j); }
+ void AddJet(AliJet* j,Int_t tracks=1) { AddJet(*j,tracks); }
void AddVertex(AliVertex* v,Int_t connect=1) { AddVertex(*v,connect); }
void Info(TString f="car"); // Print the vertex info within coordinate frame f
void List(TString f="car"); // Print vertex prim. track information for coord. frame f
Int_t GetNvertices(); // Return the number of (secondary) vertices
AliVertex* GetVertex(Int_t i); // Provide i-th (secondary) vertex
void SetNvmax(Int_t n=2); // Set the initial max. number of (secondary) vertices
+ void SetVertexCopy(Int_t j); // (De)activate creation of private copies in fVertices
+ Int_t GetVertexCopy(); // Provide VertexCopy flag value
+ Int_t GetNjets(); // Return the number of jets
+ AliJet* GetJet(Int_t i); // Provide i-th jet
+ void SetNjmax(Int_t n=2); // Set the initial max. number of jets
+ void SetJetCopy(Int_t j); // (De)activate creation of private copies in fJets
+ Int_t GetJetCopy(); // Provide JetCopy flag value
protected:
Int_t fNvmax; // The maximum number of (secondary) vertices
Int_t fNvtx; // The number of (secondary) vertices
TObjArray* fVertices; // Array to hold the pointers to the (secondary) vertices
TObjArray* fConnects; // Array to hold the pointers to the auto-generated connecting tracks
+ Int_t fVertexCopy; // Flag to denote creation of private copies in fVertices
+ Int_t fNjmax; // The maximum number of jets
+ Int_t fNjets; // The number of jets
+ TObjArray* fJets; // Array to hold the pointers to the jets
+ Int_t fJetCopy; // Flag to denote creation of private copies in fJets
private:
void Dump(AliVertex* v,Int_t n,TString f); // Recursively print all sec. vertices