]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RALICE/AliJet.cxx
Buffer Size can be defined
[u/mrichter/AliRoot.git] / RALICE / AliJet.cxx
index e667584238754d58b3b715e066aa17f28f18a41a..a59e90e736f499009eafd50b6d3985d19fe1c8db 100644 (file)
@@ -97,20 +97,24 @@ AliJet::AliJet()
 // 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)
  {
@@ -131,12 +135,28 @@ AliJet::~AliJet()
 // 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
@@ -144,7 +164,6 @@ void AliJet::SetNtinit(Int_t n)
  fNtmax=n;
  if (fTracks)
  {
-  if (fTrackCopy) fTracks->Delete();
   delete fTracks;
   fTracks=0;
  }
@@ -156,20 +175,24 @@ void AliJet::Reset()
 // 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;
@@ -178,9 +201,9 @@ void AliJet::AddTrack(AliTrack& t)
  
  // Add the track to this jet
  fNtrk++;
- if (fTrackCopy)
+ if (fTrackCopy && copy)
  {
-  fTracks->Add(t.Clone());
+  fTracks->Add(new AliTrack(t));
  }
  else
  {
@@ -195,7 +218,7 @@ void AliJet::AddTrack(AliTrack& t)
 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); 
@@ -321,6 +344,27 @@ AliTrack* AliJet::GetTrack(Int_t i)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
+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.
@@ -451,3 +495,15 @@ Int_t AliJet::GetTrackCopy()
  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;
+}
+///////////////////////////////////////////////////////////////////////////