1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////
20 // Creation and investigation of a jet of particle tracks.
21 // An AliJet can be constructed by adding AliTracks.
23 // To provide maximal flexibility to the user, two modes of track storage
24 // are provided by means of the memberfunction SetTrackCopy().
26 // a) SetTrackCopy(0) (which is the default).
27 // Only the pointers of the 'added' tracks are stored.
28 // This mode is typically used by making jet studies based on a fixed list
29 // of tracks which stays under user control or is contained for instance
31 // In this way the AliJet just represents a 'logical structure' for the
32 // physics analysis which can be embedded in e.g. an AliEvent or AliVertex.
33 // Modifications made to the original tracks also affect the AliTrack objects
34 // which are stored in the AliJet.
35 // b) SetTrackCopy(1).
36 // Of every 'added' track a private copy will be made of which the pointer
38 // In this way the AliJet represents an entity on its own and modifications
39 // made to the original tracks do not affect the AliTrack objects which are
40 // stored in the AliJet.
41 // This mode will allow 'adding' many different AliTracks into an AliJet by
42 // creating only one AliTrack instance in the main programme and using the
43 // AliTrack::Reset() and AliTrack parameter setting memberfunctions.
45 // Coding example to make 2 jets j1 and j2.
46 // ----------------------------------------
47 // j1 contains the AliTracks t1 and t2
48 // j2 contains 10 different AliTracks via tx
52 // ... // code to fill the AliTrack data
59 // j2.SetTrackCopy(1);
60 // AliTrack* tx=new AliTrack();
61 // for (Int_t i=0; i<10; i++)
64 // ... // code to set momentum etc... of the track tx
73 // Float_t e1=j1.GetEnergy();
74 // Float_t pnorm=j1->GetMomentum();
75 // Ali3Vector p=j1->Get3Momentum();
76 // Float_t m=j1.GetInvmass();
77 // Int_t ntk=j1.GetNtracks();
78 // AliTrack* tj=j1.GetTrack(1);
82 // Note : All quantities are in GeV, GeV/c or GeV/c**2
84 //--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht
85 //- Modified: NvE $Date$ UU-SAP Utrecht
86 ///////////////////////////////////////////////////////////////////////////
90 ClassImp(AliJet) // Class implementation to enable ROOT I/O
94 // Default constructor
95 // All variables initialised to 0
96 // Initial maximum number of tracks is set to the default value
103 ///////////////////////////////////////////////////////////////////////////
104 AliJet::AliJet(Int_t n)
106 // Create a jet to hold initially a maximum of n tracks
107 // All variables initialised to 0
119 cout << " *AliJet* Initial max. number of tracks entered : " << n << endl;
120 cout << " This is invalid. Default initial maximum will be used." << endl;
125 ///////////////////////////////////////////////////////////////////////////
128 // Default destructor
131 if (fTrackCopy) fTracks->Delete();
136 ///////////////////////////////////////////////////////////////////////////
137 void AliJet::SetNtinit(Int_t n)
139 // Set the initial maximum number of tracks for this jet
143 if (fTrackCopy) fTracks->Delete();
147 if (fTracks) delete fTracks;
149 ///////////////////////////////////////////////////////////////////////////
152 // Reset all variables to 0
153 // The max. number of tracks is set to the initial value again
156 Double_t a[4]={0,0,0,0};
158 if (fNtinit > 0) SetNtinit(fNtinit);
160 ///////////////////////////////////////////////////////////////////////////
161 void AliJet::AddTrack(AliTrack& t)
163 // Add a track to the jet
164 // In case the maximum number of tracks has been reached
165 // space will be extended to hold an additional amount of tracks as
166 // was initially reserved
167 if (!fTracks) fTracks=new TObjArray(fNtmax);
168 if (fNtrk == fNtmax) // Check if maximum track number is reached
171 fTracks->Expand(fNtmax);
174 // Add the track to this jet
178 AliTrack* tx=new AliTrack(t);
185 (*this)+=(Ali4Vector&)t;
188 ///////////////////////////////////////////////////////////////////////////
189 void AliJet::Info(TString f)
191 // Provide jet information within the coordinate frame f
192 cout << " *AliJet::Info* Invmass : " << GetInvmass() << " Charge : " << fQ
193 << " Momentum : " << GetMomentum() << " Ntracks : " << fNtrk << endl;
197 ///////////////////////////////////////////////////////////////////////////
198 void AliJet::List(TString f)
200 // Provide jet and primary track information within the coordinate frame f
202 Info(f); // Information of the current jet
204 // The tracks of this jet
206 for (Int_t it=1; it<=fNtrk; it++)
211 cout << " ---Track no. " << it << endl;
217 cout << " *AliJet::List* Error : No track present." << endl;
221 ///////////////////////////////////////////////////////////////////////////
222 void AliJet::ListAll(TString f)
224 // Provide jet and prim.+sec. track information within the coordinate frame f
226 Info(f); // Information of the current jet
228 // The tracks of this jet
230 for (Int_t it=1; it<=fNtrk; it++)
235 cout << " ---Track no. " << it << endl;
241 cout << " *AliJet::List* Error : No track present." << endl;
245 ///////////////////////////////////////////////////////////////////////////
246 Int_t AliJet::GetNtracks()
248 // Return the current number of tracks of this jet
251 ///////////////////////////////////////////////////////////////////////////
252 Double_t AliJet::GetEnergy()
254 // Return the total energy of the jet
257 ///////////////////////////////////////////////////////////////////////////
258 Double_t AliJet::GetMomentum()
260 // Return the value of the total jet 3-momentum
261 // The error can be obtained by invoking GetResultError() after
262 // invokation of GetMomentum().
263 Double_t norm=fV.GetNorm();
264 fDresult=fV.GetResultError();
267 ///////////////////////////////////////////////////////////////////////////
268 Ali3Vector AliJet::Get3Momentum()
270 // Return the the total jet 3-momentum
271 Ali3Vector p=Get3Vector();
274 ///////////////////////////////////////////////////////////////////////////
275 Double_t AliJet::GetInvmass()
277 // Return the invariant mass of the jet
278 Double_t m2=Dot(*this);
288 ///////////////////////////////////////////////////////////////////////////
289 Float_t AliJet::GetCharge()
291 // Return the total charge of the jet
294 ///////////////////////////////////////////////////////////////////////////
295 AliTrack* AliJet::GetTrack(Int_t i)
297 // Return the i-th track of this jet
298 return (AliTrack*)fTracks->At(i-1);
300 ///////////////////////////////////////////////////////////////////////////
301 Double_t AliJet::GetPt()
303 // Provide trans. momentum value w.r.t. z-axis.
304 // The error on the value can be obtained by GetResultError()
305 // after invokation of GetPt().
308 Double_t norm=v.GetNorm();
309 fDresult=v.GetResultError();
313 ///////////////////////////////////////////////////////////////////////////
314 Double_t AliJet::GetPl()
316 // Provide long. momentum value w.r.t. z-axis.
317 // Note : the returned value can also be negative.
318 // The error on the value can be obtained by GetResultError()
319 // after invokation of GetPl().
323 Double_t pl=v.GetNorm();
324 fDresult=v.GetResultError();
327 v.GetVector(a,"sph");
328 if (cos(a[1])<0) pl=-pl;
332 ///////////////////////////////////////////////////////////////////////////
333 Double_t AliJet::GetEt()
335 // Provide trans. energy value w.r.t. z-axis.
336 // The error on the value can be obtained by GetResultError()
337 // after invokation of GetEt().
338 Double_t et=GetScaTrans();
342 ///////////////////////////////////////////////////////////////////////////
343 Double_t AliJet::GetEl()
345 // Provide long. energy value w.r.t. z-axis.
346 // Note : the returned value can also be negative.
347 // The error on the value can be obtained by GetResultError()
348 // after invokation of GetEl().
349 Double_t el=GetScaLong();
353 ///////////////////////////////////////////////////////////////////////////
354 Double_t AliJet::GetMt()
356 // Provide transverse mass value w.r.t. z-axis.
357 // The error on the value can be obtained by GetResultError()
358 // after invokation of GetMt().
360 Double_t dpt=GetResultError();
361 Double_t m=GetInvmass();
362 Double_t dm=GetResultError();
364 Double_t mt=sqrt(pt*pt+m*m);
366 if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
371 ///////////////////////////////////////////////////////////////////////////
372 Double_t AliJet::GetRapidity()
374 // Provide rapidity value w.r.t. z-axis.
375 // The error on the value can be obtained by GetResultError()
376 // after invokation of GetRapidity().
377 // Note : Also GetPseudoRapidity() is available since this class is
378 // derived from Ali4Vector.
379 Double_t e=GetEnergy();
380 Double_t de=GetResultError();
382 Double_t dpl=GetResultError();
386 Double_t y=9999,dy2=0;
387 if (sum && dif) y=0.5*log(sum/dif);
389 if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2));
394 ///////////////////////////////////////////////////////////////////////////
395 void AliJet::SetTrackCopy(Int_t j)
397 // (De)activate the creation of private copies of the added tracks.
398 // j=0 ==> No private copies are made; pointers of original tracks are stored.
399 // j=1 ==> Private copies of the tracks are made and these pointers are stored.
401 // Note : Once the storage contains pointer(s) to AliTrack(s) one cannot
402 // change the TrackCopy mode anymore.
403 // To change the TrackCopy mode for an existing AliJet containing
404 // tracks one first has to invoke Reset().
413 cout << "*AliJet::SetTrackCopy* Invalid argument : " << j << endl;
418 cout << "*AliJet::SetTrackCopy* Storage already contained tracks."
419 << " ==> TrackCopy mode not changed." << endl;
422 ///////////////////////////////////////////////////////////////////////////
423 Int_t AliJet::GetTrackCopy()
425 // Provide value of the TrackCopy mode.
426 // 0 ==> No private copies are made; pointers of original tracks are stored.
427 // 1 ==> Private copies of the tracks are made and these pointers are stored.
430 ///////////////////////////////////////////////////////////////////////////