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.
35 // Modifications made to the original tracks also affect the AliTrack objects
36 // which are stored in the AliJet.
38 // b) SetTrackCopy(1).
39 // Of every 'added' track a private copy will be made of which the pointer
41 // In this way the AliJet represents an entity on its own and modifications
42 // made to the original tracks do not affect the AliTrack objects which are
43 // stored in the AliJet.
44 // This mode will allow 'adding' many different AliTracks into an AliJet by
45 // creating only one AliTrack instance in the main programme and using the
46 // AliTrack::Reset() and AliTrack parameter setting memberfunctions.
48 // Coding example to make 2 jets j1 and j2.
49 // ----------------------------------------
50 // j1 contains the AliTracks t1 and t2
51 // j2 contains 10 different AliTracks via tx
55 // ... // code to fill the AliTrack data
62 // j2.SetTrackCopy(1);
63 // AliTrack* tx=new AliTrack();
64 // for (Int_t i=0; i<10; i++)
67 // ... // code to set momentum etc... of the track tx
76 // Float_t e1=j1.GetEnergy();
77 // Float_t pnorm=j1->GetMomentum();
78 // Ali3Vector p=j1->Get3Momentum();
79 // Float_t m=j1.GetInvmass();
80 // Int_t ntk=j1.GetNtracks();
81 // AliTrack* tj=j1.GetTrack(1);
85 // Note : All quantities are in GeV, GeV/c or GeV/c**2
87 //--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht
88 //- Modified: NvE $Date$ UU-SAP Utrecht
89 ///////////////////////////////////////////////////////////////////////////
93 ClassImp(AliJet) // Class implementation to enable ROOT I/O
97 // Default constructor
98 // All variables initialised to 0
99 // Initial maximum number of tracks is set to the default value
106 ///////////////////////////////////////////////////////////////////////////
107 AliJet::AliJet(Int_t n)
109 // Create a jet to hold initially a maximum of n tracks
110 // All variables initialised to 0
122 cout << " *AliJet* Initial max. number of tracks entered : " << n << endl;
123 cout << " This is invalid. Default initial maximum will be used." << endl;
128 ///////////////////////////////////////////////////////////////////////////
131 // Default destructor
134 if (fTrackCopy) fTracks->Delete();
139 ///////////////////////////////////////////////////////////////////////////
140 void AliJet::SetNtinit(Int_t n)
142 // Set the initial maximum number of tracks for this jet
147 if (fTrackCopy) fTracks->Delete();
152 ///////////////////////////////////////////////////////////////////////////
155 // Reset all variables to 0
156 // The max. number of tracks is set to the initial value again
159 Double_t a[4]={0,0,0,0};
161 if (fNtinit > 0) SetNtinit(fNtinit);
163 ///////////////////////////////////////////////////////////////////////////
164 void AliJet::AddTrack(AliTrack& t)
166 // Add a track to the jet.
167 // Note : In case TrackCopy is set, the originally entered track
168 // will be automatically reset.
169 // In case the maximum number of tracks has been reached
170 // space will be extended to hold an additional amount of tracks as
171 // was initially reserved.
172 if (!fTracks) fTracks=new TObjArray(fNtmax);
173 if (fNtrk == fNtmax) // Check if maximum track number is reached
176 fTracks->Expand(fNtmax);
179 // Add the track to this jet
183 fTracks->Add(t.Clone());
190 (*this)+=(Ali4Vector&)t;
194 ///////////////////////////////////////////////////////////////////////////
195 void AliJet::Info(TString f)
197 // Provide jet information within the coordinate frame f
198 cout << " *AliJet::Info* Invmass : " << GetInvmass() << " Charge : " << fQ
199 << " Momentum : " << GetMomentum() << " Ntracks : " << fNtrk << endl;
203 ///////////////////////////////////////////////////////////////////////////
204 void AliJet::List(TString f)
206 // Provide jet and primary track information within the coordinate frame f
208 Info(f); // Information of the current jet
210 // The tracks of this jet
212 for (Int_t it=1; it<=fNtrk; it++)
217 cout << " ---Track no. " << it << endl;
223 cout << " *AliJet::List* Error : No track present." << endl;
227 ///////////////////////////////////////////////////////////////////////////
228 void AliJet::ListAll(TString f)
230 // Provide jet and prim.+sec. track information within the coordinate frame f
232 Info(f); // Information of the current jet
234 // The tracks of this jet
236 for (Int_t it=1; it<=fNtrk; it++)
241 cout << " ---Track no. " << it << endl;
247 cout << " *AliJet::List* Error : No track present." << endl;
251 ///////////////////////////////////////////////////////////////////////////
252 Int_t AliJet::GetNtracks()
254 // Return the current number of tracks of this jet
257 ///////////////////////////////////////////////////////////////////////////
258 Double_t AliJet::GetEnergy()
260 // Return the total energy of the jet
263 ///////////////////////////////////////////////////////////////////////////
264 Double_t AliJet::GetMomentum()
266 // Return the value of the total jet 3-momentum
267 // The error can be obtained by invoking GetResultError() after
268 // invokation of GetMomentum().
269 Double_t norm=fV.GetNorm();
270 fDresult=fV.GetResultError();
273 ///////////////////////////////////////////////////////////////////////////
274 Ali3Vector AliJet::Get3Momentum()
276 // Return the the total jet 3-momentum
277 Ali3Vector p=Get3Vector();
280 ///////////////////////////////////////////////////////////////////////////
281 Double_t AliJet::GetInvmass()
283 // Return the invariant mass of the jet
284 Double_t m2=Dot(*this);
294 ///////////////////////////////////////////////////////////////////////////
295 Float_t AliJet::GetCharge()
297 // Return the total charge of the jet
300 ///////////////////////////////////////////////////////////////////////////
301 AliTrack* AliJet::GetTrack(Int_t i)
303 // Return the i-th track of this jet
306 cout << " *AliJet*::GetTrack* No tracks present." << endl;
313 cout << " *AliJet*::GetTrack* Invalid argument i : " << i
314 << " Ntrk = " << fNtrk << endl;
319 return (AliTrack*)fTracks->At(i-1);
323 ///////////////////////////////////////////////////////////////////////////
324 Double_t AliJet::GetPt()
326 // Provide trans. momentum value w.r.t. z-axis.
327 // The error on the value can be obtained by GetResultError()
328 // after invokation of GetPt().
331 Double_t norm=v.GetNorm();
332 fDresult=v.GetResultError();
336 ///////////////////////////////////////////////////////////////////////////
337 Double_t AliJet::GetPl()
339 // Provide long. momentum value w.r.t. z-axis.
340 // Note : the returned value can also be negative.
341 // The error on the value can be obtained by GetResultError()
342 // after invokation of GetPl().
346 Double_t pl=v.GetNorm();
347 fDresult=v.GetResultError();
350 v.GetVector(a,"sph");
351 if (cos(a[1])<0) pl=-pl;
355 ///////////////////////////////////////////////////////////////////////////
356 Double_t AliJet::GetEt()
358 // Provide trans. energy value w.r.t. z-axis.
359 // The error on the value can be obtained by GetResultError()
360 // after invokation of GetEt().
361 Double_t et=GetScaTrans();
365 ///////////////////////////////////////////////////////////////////////////
366 Double_t AliJet::GetEl()
368 // Provide long. energy value w.r.t. z-axis.
369 // Note : the returned value can also be negative.
370 // The error on the value can be obtained by GetResultError()
371 // after invokation of GetEl().
372 Double_t el=GetScaLong();
376 ///////////////////////////////////////////////////////////////////////////
377 Double_t AliJet::GetMt()
379 // Provide transverse mass value w.r.t. z-axis.
380 // The error on the value can be obtained by GetResultError()
381 // after invokation of GetMt().
383 Double_t dpt=GetResultError();
384 Double_t m=GetInvmass();
385 Double_t dm=GetResultError();
387 Double_t mt=sqrt(pt*pt+m*m);
389 if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
394 ///////////////////////////////////////////////////////////////////////////
395 Double_t AliJet::GetRapidity()
397 // Provide rapidity value w.r.t. z-axis.
398 // The error on the value can be obtained by GetResultError()
399 // after invokation of GetRapidity().
400 // Note : Also GetPseudoRapidity() is available since this class is
401 // derived from Ali4Vector.
402 Double_t e=GetEnergy();
403 Double_t de=GetResultError();
405 Double_t dpl=GetResultError();
409 Double_t y=9999,dy2=0;
410 if (sum && dif) y=0.5*log(sum/dif);
412 if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2));
417 ///////////////////////////////////////////////////////////////////////////
418 void AliJet::SetTrackCopy(Int_t j)
420 // (De)activate the creation of private copies of the added tracks.
421 // j=0 ==> No private copies are made; pointers of original tracks are stored.
422 // j=1 ==> Private copies of the tracks are made and these pointers are stored.
424 // Note : Once the storage contains pointer(s) to AliTrack(s) one cannot
425 // change the TrackCopy mode anymore.
426 // To change the TrackCopy mode for an existing AliJet containing
427 // tracks one first has to invoke Reset().
436 cout << "*AliJet::SetTrackCopy* Invalid argument : " << j << endl;
441 cout << "*AliJet::SetTrackCopy* Storage already contained tracks."
442 << " ==> TrackCopy mode not changed." << endl;
445 ///////////////////////////////////////////////////////////////////////////
446 Int_t AliJet::GetTrackCopy()
448 // Provide value of the TrackCopy mode.
449 // 0 ==> No private copies are made; pointers of original tracks are stored.
450 // 1 ==> Private copies of the tracks are made and these pointers are stored.
453 ///////////////////////////////////////////////////////////////////////////