// Default constructor
// All variables initialised to 0
// Initial maximum number of tracks is set to the default value
+ Init();
+ Reset();
+ SetNtinit();
+}
+///////////////////////////////////////////////////////////////////////////
+void AliJet::Init()
+{
+// Initialisation of pointers etc...
fTracks=0;
fNtinit=0;
fTrackCopy=0;
- Reset();
- SetNtinit();
}
///////////////////////////////////////////////////////////////////////////
AliJet::AliJet(Int_t n)
{
// Create a jet to hold initially a maximum of n tracks
// All variables initialised to 0
- fTracks=0;
- fNtinit=0;
- fTrackCopy=0;
+ Init();
Reset();
if (n > 0)
{
// Default destructor
if (fTracks)
{
- if (fTrackCopy) fTracks->Delete();
delete fTracks;
fTracks=0;
}
}
///////////////////////////////////////////////////////////////////////////
+AliJet::AliJet(AliJet& j)
+{
+// Copy constructor
+ Init();
+ Reset();
+ SetNtinit();
+ SetTrackCopy(j.GetTrackCopy());
+ SetId(j.GetId());
+
+ AliTrack* tx=0;
+ for (Int_t i=1; i<=j.GetNtracks(); i++)
+ {
+ tx=j.GetTrack(i);
+ if (tx) AddTrack(tx);
+ }
+}
+///////////////////////////////////////////////////////////////////////////
void AliJet::SetNtinit(Int_t n)
{
// Set the initial maximum number of tracks for this jet
fNtmax=n;
if (fTracks)
{
- if (fTrackCopy) fTracks->Delete();
delete fTracks;
fTracks=0;
}
// The max. number of tracks is set to the initial value again
fNtrk=0;
fQ=0;
+ fUserId=0;
Double_t a[4]={0,0,0,0};
SetVector(a,"sph");
if (fNtinit > 0) SetNtinit(fNtinit);
}
///////////////////////////////////////////////////////////////////////////
-void AliJet::AddTrack(AliTrack& t)
+void AliJet::AddTrack(AliTrack& t,Int_t copy)
{
// Add a track to the jet.
-// Note : In case TrackCopy is set, the originally entered track
-// will be automatically reset.
+// Note : The optional parameter "copy" is for internal use only.
// In case the maximum number of tracks has been reached
// space will be extended to hold an additional amount of tracks as
// was initially reserved.
- if (!fTracks) fTracks=new TObjArray(fNtmax);
+ if (!fTracks)
+ {
+ fTracks=new TObjArray(fNtmax);
+ if (fTrackCopy) fTracks->SetOwner();
+ }
if (fNtrk == fNtmax) // Check if maximum track number is reached
{
fNtmax+=fNtinit;
// Add the track to this jet
fNtrk++;
- if (fTrackCopy)
+ if (fTrackCopy && copy)
{
- fTracks->Add(t.Clone());
+ fTracks->Add(new AliTrack(t));
}
else
{
void AliJet::Info(TString f)
{
// Provide jet information within the coordinate frame f
- cout << " *AliJet::Info* Invmass : " << GetInvmass() << " Charge : " << fQ
+ cout << " *AliJet::Info* Id : " << fUserId << " Invmass : " << GetInvmass() << " Charge : " << fQ
<< " Momentum : " << GetMomentum() << " Ntracks : " << fNtrk << endl;
cout << " ";
Ali4Vector::Info(f);
}
}
///////////////////////////////////////////////////////////////////////////
+AliTrack* AliJet::GetIdTrack(Int_t id)
+{
+// Return the track with user identifier "id" of this jet
+ AliTrack* tx=0;
+ AliTrack* t=0;
+ if (!fTracks)
+ {
+ cout << " *AliJet*::GetIdTrack* No tracks present." << endl;
+ return 0;
+ }
+ else
+ {
+ for (Int_t i=0; i<fNtrk; i++)
+ {
+ tx=(AliTrack*)fTracks->At(i);
+ if (id == tx->GetId()) t=tx;
+ }
+ return t;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
Double_t AliJet::GetPt()
{
// Provide trans. momentum value w.r.t. z-axis.
return fTrackCopy;
}
///////////////////////////////////////////////////////////////////////////
+void AliJet::SetId(Int_t id)
+{
+// Set a user defined identifier for this jet.
+ fUserId=id;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliJet::GetId()
+{
+// Provide the user defined identifier of this jet.
+ return fUserId;
+}
+///////////////////////////////////////////////////////////////////////////