* provided "as is" without express or implied warranty. *
**************************************************************************/
-/*
-$Log$
-Revision 1.2 1999/09/29 09:24:28 fca
-Introduction of the Copyright and cvs Log
-
-*/
+// $Id$
///////////////////////////////////////////////////////////////////////////
// Class AliJet
// Creation and investigation of a jet of particle tracks.
// An AliJet can be constructed by adding AliTracks.
//
+// To provide maximal flexibility to the user, two modes of track storage
+// are provided by means of the memberfunction SetTrackCopy().
+//
+// a) SetTrackCopy(0) (which is the default).
+// Only the pointers of the 'added' tracks are stored.
+// This mode is typically used by making jet studies based on a fixed list
+// of tracks which stays under user control or is contained for instance
+// 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.
+// In this way the AliJet represents an entity on its own and modifications
+// made to the original tracks do not affect the AliTrack objects which are
+// stored in the AliJet.
+// This mode will allow 'adding' many different AliTracks into an AliJet by
+// creating only one AliTrack instance in the main programme and using the
+// AliTrack::Reset() and AliTrack parameter setting memberfunctions.
+//
// Coding example to make 2 jets j1 and j2.
// ----------------------------------------
-// j1 contains the AliTracks 1 and 2
-// j2 contains the AliTracks 3 and 4
+// j1 contains the AliTracks t1 and t2
+// j2 contains 10 different AliTracks via tx
//
-// AliTrack t1,t2,t3,t4;
+// AliTrack t1,t2;
// ...
// ... // code to fill the AliTrack data
// ...
-// AliJet j1(5);
-// AliJet j2(12);
-// j1.Add(t1);
-// j1.Add(t2);
-// j2.Add(t3);
-// j2.Add(t4);
+// AliJet j1();
+// j1.AddTrack(t1);
+// j1.AddTrack(t2);
+//
+// AliJet j2();
+// j2.SetTrackCopy(1);
+// AliTrack* tx=new AliTrack();
+// for (Int_t i=0; i<10; i++)
+// {
+// ...
+// ... // code to set momentum etc... of the track tx
+// ...
+// j2.AddTrack(tx);
+// tx->Reset();
+// }
//
// j1.Info();
// j2.Info("sph");
// Int_t ntk=j1.GetNtracks();
// AliTrack* tj=j1.GetTrack(1);
//
+// delete tx;
+//
// Note : All quantities are in GeV, GeV/c or GeV/c**2
//
//--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht
-//- Modified: NvE 06-apr-1999 UU-SAP Utrecht to inherit from Ali4Vector
+//- Modified: NvE $Date$ UU-SAP Utrecht
///////////////////////////////////////////////////////////////////////////
#include "AliJet.h"
// Default constructor
// All variables initialised to 0
// Initial maximum number of tracks is set to the default value
- fTracks=0;
- fNtinit=0;
+ Init();
Reset();
SetNtinit();
}
///////////////////////////////////////////////////////////////////////////
+void AliJet::Init()
+{
+// Initialisation of pointers etc...
+ fTracks=0;
+ fNtinit=0;
+ fTrackCopy=0;
+}
+///////////////////////////////////////////////////////////////////////////
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;
+ Init();
Reset();
if (n > 0)
{
AliJet::~AliJet()
{
// Default destructor
- if (fTracks) delete fTracks;
- fTracks=0;
+ if (fTracks)
+ {
+ 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
fNtinit=n;
fNtmax=n;
- if (fTracks) delete fTracks;
- fTracks=new TObjArray(fNtmax);
+ if (fTracks)
+ {
+ delete fTracks;
+ fTracks=0;
+ }
}
///////////////////////////////////////////////////////////////////////////
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::Add(AliTrack& t)
+void AliJet::AddTrack(AliTrack& t,Int_t copy)
{
-// Add a track to the jet
+// Add a track to the jet.
+// 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
+// was initially reserved.
+ 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++;
- fTracks->Add(&t);
+ if (fTrackCopy && copy)
+ {
+ fTracks->Add(new AliTrack(t));
+ }
+ 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);
Double_t AliJet::GetMomentum()
{
// Return the value of the total jet 3-momentum
- Ali3Vector p=Get3Vector();
- Double_t p2=p.Dot(p);
- return sqrt(p2);
+// The error can be obtained by invoking GetResultError() after
+// invokation of GetMomentum().
+ Double_t norm=fV.GetNorm();
+ fDresult=fV.GetResultError();
+ return norm;
}
///////////////////////////////////////////////////////////////////////////
Ali3Vector AliJet::Get3Momentum()
AliTrack* AliJet::GetTrack(Int_t i)
{
// Return the i-th track of this jet
- return (AliTrack*)fTracks->At(i-1);
+ if (!fTracks)
+ {
+ cout << " *AliJet*::GetTrack* No tracks present." << endl;
+ return 0;
+ }
+ else
+ {
+ if (i<=0 || i>fNtrk)
+ {
+ cout << " *AliJet*::GetTrack* Invalid argument i : " << i
+ << " Ntrk = " << fNtrk << endl;
+ return 0;
+ }
+ else
+ {
+ return (AliTrack*)fTracks->At(i-1);
+ }
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+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.
+// The error on the value can be obtained by GetResultError()
+// after invokation of GetPt().
+ Ali3Vector v;
+ v=GetVecTrans();
+ Double_t norm=v.GetNorm();
+ fDresult=v.GetResultError();
+
+ return norm;
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t AliJet::GetPl()
+{
+// Provide long. momentum value w.r.t. z-axis.
+// Note : the returned value can also be negative.
+// The error on the value can be obtained by GetResultError()
+// after invokation of GetPl().
+ Ali3Vector v;
+ v=GetVecLong();
+
+ Double_t pl=v.GetNorm();
+ fDresult=v.GetResultError();
+
+ Double_t a[3];
+ v.GetVector(a,"sph");
+ if (cos(a[1])<0) pl=-pl;
+
+ return pl;
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t AliJet::GetEt()
+{
+// Provide trans. energy value w.r.t. z-axis.
+// The error on the value can be obtained by GetResultError()
+// after invokation of GetEt().
+ Double_t et=GetScaTrans();
+
+ return et;
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t AliJet::GetEl()
+{
+// Provide long. energy value w.r.t. z-axis.
+// Note : the returned value can also be negative.
+// The error on the value can be obtained by GetResultError()
+// after invokation of GetEl().
+ Double_t el=GetScaLong();
+
+ return el;
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t AliJet::GetMt()
+{
+// Provide transverse mass value w.r.t. z-axis.
+// The error on the value can be obtained by GetResultError()
+// after invokation of GetMt().
+ Double_t pt=GetPt();
+ Double_t dpt=GetResultError();
+ Double_t m=GetInvmass();
+ Double_t dm=GetResultError();
+
+ Double_t mt=sqrt(pt*pt+m*m);
+ Double_t dmt2=0;
+ if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
+
+ fDresult=sqrt(dmt2);
+ return mt;
+}
+///////////////////////////////////////////////////////////////////////////
+Double_t AliJet::GetRapidity()
+{
+// Provide rapidity value w.r.t. z-axis.
+// The error on the value can be obtained by GetResultError()
+// after invokation of GetRapidity().
+// Note : Also GetPseudoRapidity() is available since this class is
+// derived from Ali4Vector.
+ Double_t e=GetEnergy();
+ Double_t de=GetResultError();
+ Double_t pl=GetPl();
+ Double_t dpl=GetResultError();
+ Double_t sum=e+pl;
+ Double_t dif=e-pl;
+
+ Double_t y=9999,dy2=0;
+ if (sum && dif) y=0.5*log(sum/dif);
+
+ if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2));
+
+ fDresult=sqrt(dy2);
+ return y;
+}
+///////////////////////////////////////////////////////////////////////////
+void AliJet::SetTrackCopy(Int_t j)
+{
+// (De)activate the creation of private copies of the added tracks.
+// j=0 ==> No private copies are made; pointers of original tracks are stored.
+// j=1 ==> Private copies of the tracks are made and these pointers are stored.
+//
+// Note : Once the storage contains pointer(s) to AliTrack(s) one cannot
+// change the TrackCopy mode anymore.
+// To change the TrackCopy mode for an existing AliJet containing
+// tracks one first has to invoke Reset().
+ if (!fTracks)
+ {
+ if (j==0 || j==1)
+ {
+ fTrackCopy=j;
+ }
+ else
+ {
+ cout << "*AliJet::SetTrackCopy* Invalid argument : " << j << endl;
+ }
+ }
+ else
+ {
+ cout << "*AliJet::SetTrackCopy* Storage already contained tracks."
+ << " ==> TrackCopy mode not changed." << endl;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliJet::GetTrackCopy()
+{
+// Provide value of the TrackCopy mode.
+// 0 ==> No private copies are made; pointers of original tracks are stored.
+// 1 ==> Private copies of the tracks are made and these pointers are stored.
+ 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;
}
///////////////////////////////////////////////////////////////////////////