]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RALICE/AliJet.cxx
A pointer was set to zero in the default constructor to avoid memory management problems
[u/mrichter/AliRoot.git] / RALICE / AliJet.cxx
index 6a22c617d0d46c61f65b3ca46ccf6a6398d4bdff..ae492ff4c675005c70a29f16d813f48fdbf8932c 100644 (file)
 //    in an AliEvent.  
 //    In this way the AliJet just represents a 'logical structure' for the
 //    physics analysis which can be embedded in e.g. an AliEvent or AliVertex.
+//
+//    Note :
 //    Modifications made to the original tracks also affect the AliTrack objects
 //    which are stored in the AliJet. 
+//
 // b) SetTrackCopy(1).
 //    Of every 'added' track a private copy will be made of which the pointer
 //    will be stored.
@@ -153,6 +156,7 @@ 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);
@@ -160,10 +164,12 @@ void AliJet::Reset()
 ///////////////////////////////////////////////////////////////////////////
 void AliJet::AddTrack(AliTrack& t)
 {
-// Add a track to the jet
+// Add a track to the jet.
+// Note : In case TrackCopy is set, the originally entered track
+//        will be automatically reset.
 // 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
+// was initially reserved.
  if (!fTracks) fTracks=new TObjArray(fNtmax);
  if (fNtrk == fNtmax) // Check if maximum track number is reached
  {
@@ -175,21 +181,22 @@ void AliJet::AddTrack(AliTrack& t)
  fNtrk++;
  if (fTrackCopy)
  {
-  AliTrack* tx=new AliTrack(t);
-  fTracks->Add(tx);
+  fTracks->Add(t.Clone());
  }
  else
  {
   fTracks->Add(&t);
  }
+
  (*this)+=(Ali4Vector&)t;
  fQ+=t.GetCharge();
+
 }
 ///////////////////////////////////////////////////////////////////////////
 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); 
@@ -315,6 +322,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.
@@ -445,3 +473,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;
+}
+///////////////////////////////////////////////////////////////////////////