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
160 Double_t a[4]={0,0,0,0};
162 if (fNtinit > 0) SetNtinit(fNtinit);
164 ///////////////////////////////////////////////////////////////////////////
165 void AliJet::AddTrack(AliTrack& t)
167 // Add a track to the jet.
168 // Note : In case TrackCopy is set, the originally entered track
169 // will be automatically reset.
170 // In case the maximum number of tracks has been reached
171 // space will be extended to hold an additional amount of tracks as
172 // was initially reserved.
173 if (!fTracks) fTracks=new TObjArray(fNtmax);
174 if (fNtrk == fNtmax) // Check if maximum track number is reached
177 fTracks->Expand(fNtmax);
180 // Add the track to this jet
184 fTracks->Add(t.Clone());
191 (*this)+=(Ali4Vector&)t;
195 ///////////////////////////////////////////////////////////////////////////
196 void AliJet::Info(TString f)
198 // Provide jet information within the coordinate frame f
199 cout << " *AliJet::Info* Id : " << fUserId << " Invmass : " << GetInvmass() << " Charge : " << fQ
200 << " Momentum : " << GetMomentum() << " Ntracks : " << fNtrk << endl;
204 ///////////////////////////////////////////////////////////////////////////
205 void AliJet::List(TString f)
207 // Provide jet and primary track information within the coordinate frame f
209 Info(f); // Information of the current jet
211 // The tracks of this jet
213 for (Int_t it=1; it<=fNtrk; it++)
218 cout << " ---Track no. " << it << endl;
224 cout << " *AliJet::List* Error : No track present." << endl;
228 ///////////////////////////////////////////////////////////////////////////
229 void AliJet::ListAll(TString f)
231 // Provide jet and prim.+sec. track information within the coordinate frame f
233 Info(f); // Information of the current jet
235 // The tracks of this jet
237 for (Int_t it=1; it<=fNtrk; it++)
242 cout << " ---Track no. " << it << endl;
248 cout << " *AliJet::List* Error : No track present." << endl;
252 ///////////////////////////////////////////////////////////////////////////
253 Int_t AliJet::GetNtracks()
255 // Return the current number of tracks of this jet
258 ///////////////////////////////////////////////////////////////////////////
259 Double_t AliJet::GetEnergy()
261 // Return the total energy of the jet
264 ///////////////////////////////////////////////////////////////////////////
265 Double_t AliJet::GetMomentum()
267 // Return the value of the total jet 3-momentum
268 // The error can be obtained by invoking GetResultError() after
269 // invokation of GetMomentum().
270 Double_t norm=fV.GetNorm();
271 fDresult=fV.GetResultError();
274 ///////////////////////////////////////////////////////////////////////////
275 Ali3Vector AliJet::Get3Momentum()
277 // Return the the total jet 3-momentum
278 Ali3Vector p=Get3Vector();
281 ///////////////////////////////////////////////////////////////////////////
282 Double_t AliJet::GetInvmass()
284 // Return the invariant mass of the jet
285 Double_t m2=Dot(*this);
295 ///////////////////////////////////////////////////////////////////////////
296 Float_t AliJet::GetCharge()
298 // Return the total charge of the jet
301 ///////////////////////////////////////////////////////////////////////////
302 AliTrack* AliJet::GetTrack(Int_t i)
304 // Return the i-th track of this jet
307 cout << " *AliJet*::GetTrack* No tracks present." << endl;
314 cout << " *AliJet*::GetTrack* Invalid argument i : " << i
315 << " Ntrk = " << fNtrk << endl;
320 return (AliTrack*)fTracks->At(i-1);
324 ///////////////////////////////////////////////////////////////////////////
325 AliTrack* AliJet::GetIdTrack(Int_t id)
327 // Return the track with user identifier "id" of this jet
332 cout << " *AliJet*::GetIdTrack* No tracks present." << endl;
337 for (Int_t i=0; i<fNtrk; i++)
339 tx=(AliTrack*)fTracks->At(i);
340 if (id == tx->GetId()) t=tx;
345 ///////////////////////////////////////////////////////////////////////////
346 Double_t AliJet::GetPt()
348 // Provide trans. momentum value w.r.t. z-axis.
349 // The error on the value can be obtained by GetResultError()
350 // after invokation of GetPt().
353 Double_t norm=v.GetNorm();
354 fDresult=v.GetResultError();
358 ///////////////////////////////////////////////////////////////////////////
359 Double_t AliJet::GetPl()
361 // Provide long. momentum value w.r.t. z-axis.
362 // Note : the returned value can also be negative.
363 // The error on the value can be obtained by GetResultError()
364 // after invokation of GetPl().
368 Double_t pl=v.GetNorm();
369 fDresult=v.GetResultError();
372 v.GetVector(a,"sph");
373 if (cos(a[1])<0) pl=-pl;
377 ///////////////////////////////////////////////////////////////////////////
378 Double_t AliJet::GetEt()
380 // Provide trans. energy value w.r.t. z-axis.
381 // The error on the value can be obtained by GetResultError()
382 // after invokation of GetEt().
383 Double_t et=GetScaTrans();
387 ///////////////////////////////////////////////////////////////////////////
388 Double_t AliJet::GetEl()
390 // Provide long. energy value w.r.t. z-axis.
391 // Note : the returned value can also be negative.
392 // The error on the value can be obtained by GetResultError()
393 // after invokation of GetEl().
394 Double_t el=GetScaLong();
398 ///////////////////////////////////////////////////////////////////////////
399 Double_t AliJet::GetMt()
401 // Provide transverse mass value w.r.t. z-axis.
402 // The error on the value can be obtained by GetResultError()
403 // after invokation of GetMt().
405 Double_t dpt=GetResultError();
406 Double_t m=GetInvmass();
407 Double_t dm=GetResultError();
409 Double_t mt=sqrt(pt*pt+m*m);
411 if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
416 ///////////////////////////////////////////////////////////////////////////
417 Double_t AliJet::GetRapidity()
419 // Provide rapidity value w.r.t. z-axis.
420 // The error on the value can be obtained by GetResultError()
421 // after invokation of GetRapidity().
422 // Note : Also GetPseudoRapidity() is available since this class is
423 // derived from Ali4Vector.
424 Double_t e=GetEnergy();
425 Double_t de=GetResultError();
427 Double_t dpl=GetResultError();
431 Double_t y=9999,dy2=0;
432 if (sum && dif) y=0.5*log(sum/dif);
434 if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2));
439 ///////////////////////////////////////////////////////////////////////////
440 void AliJet::SetTrackCopy(Int_t j)
442 // (De)activate the creation of private copies of the added tracks.
443 // j=0 ==> No private copies are made; pointers of original tracks are stored.
444 // j=1 ==> Private copies of the tracks are made and these pointers are stored.
446 // Note : Once the storage contains pointer(s) to AliTrack(s) one cannot
447 // change the TrackCopy mode anymore.
448 // To change the TrackCopy mode for an existing AliJet containing
449 // tracks one first has to invoke Reset().
458 cout << "*AliJet::SetTrackCopy* Invalid argument : " << j << endl;
463 cout << "*AliJet::SetTrackCopy* Storage already contained tracks."
464 << " ==> TrackCopy mode not changed." << endl;
467 ///////////////////////////////////////////////////////////////////////////
468 Int_t AliJet::GetTrackCopy()
470 // Provide value of the TrackCopy mode.
471 // 0 ==> No private copies are made; pointers of original tracks are stored.
472 // 1 ==> Private copies of the tracks are made and these pointers are stored.
475 ///////////////////////////////////////////////////////////////////////////
476 void AliJet::SetId(Int_t id)
478 // Set a user defined identifier for this jet.
481 ///////////////////////////////////////////////////////////////////////////
482 Int_t AliJet::GetId()
484 // Provide the user defined identifier of this jet.
487 ///////////////////////////////////////////////////////////////////////////