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 // See also the documentation provided for the memberfunction SetOwner().
50 // Coding example to make 2 jets j1 and j2.
51 // ----------------------------------------
52 // j1 contains the AliTracks t1 and t2
53 // j2 contains 10 different AliTracks via tx
57 // ... // code to fill the AliTrack data
64 // j2.SetTrackCopy(1);
65 // AliTrack* tx=new AliTrack();
66 // for (Int_t i=0; i<10; i++)
69 // ... // code to set momentum etc... of the track tx
78 // Float_t e1=j1.GetEnergy();
79 // Float_t pnorm=j1->GetMomentum();
80 // Ali3Vector p=j1->Get3Momentum();
81 // Float_t m=j1.GetInvmass();
82 // Int_t ntk=j1.GetNtracks();
83 // AliTrack* tj=j1.GetTrack(1);
87 // Note : All quantities are in GeV, GeV/c or GeV/c**2
89 //--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht
90 //- Modified: NvE $Date$ UU-SAP Utrecht
91 ///////////////////////////////////////////////////////////////////////////
94 #include "Riostream.h"
96 ClassImp(AliJet) // Class implementation to enable ROOT I/O
98 AliJet::AliJet() : TNamed(),Ali4Vector()
100 // Default constructor
101 // All variables initialised to 0
102 // Initial maximum number of tracks is set to the default value
106 SetName("Unspecified");
107 SetTitle("Unspecified");
109 ///////////////////////////////////////////////////////////////////////////
112 // Initialisation of pointers etc...
117 ///////////////////////////////////////////////////////////////////////////
118 AliJet::AliJet(Int_t n) : TNamed(),Ali4Vector()
120 // Create a jet to hold initially a maximum of n tracks
121 // All variables initialised to 0
131 cout << " *AliJet* Initial max. number of tracks entered : " << n << endl;
132 cout << " This is invalid. Default initial maximum will be used." << endl;
136 SetName("Unspecified");
137 SetTitle("Unspecified");
139 ///////////////////////////////////////////////////////////////////////////
142 // Default destructor
149 ///////////////////////////////////////////////////////////////////////////
150 void AliJet::SetOwner(Bool_t own)
152 // Set ownership of all added objects.
153 // The default parameter is own=kTRUE.
155 // Invokation of this memberfunction also sets all the copy modes
156 // (e.g. TrackCopy & co.) according to the value of own.
158 // This function (with own=kTRUE) is particularly useful when reading data
159 // from a tree/file, since Reset() will then actually remove all the
160 // added objects from memory irrespective of the copy mode settings
161 // during the tree/file creation process. In this way it provides a nice way
162 // of preventing possible memory leaks in the reading/analysis process.
164 // In addition this memberfunction can also be used as a shortcut to set all
165 // copy modes in one go during a tree/file creation process.
166 // However, in this case the user has to take care to only set/change the
167 // ownership (and copy mode) for empty objects (e.g. newly created objects
168 // or after invokation of the Reset() memberfunction) otherwise it will
169 // very likely result in inconsistent destructor behaviour.
173 if (fTracks) fTracks->SetOwner(own);
176 ///////////////////////////////////////////////////////////////////////////
177 AliJet::AliJet(AliJet& j) : TNamed(j),Ali4Vector(j)
184 fTrackCopy=j.fTrackCopy;
190 fTracks=new TObjArray(fNtmax);
191 if (fTrackCopy) fTracks->SetOwner();
194 for (Int_t i=1; i<=fNtrk; i++)
196 AliTrack* tx=j.GetTrack(i);
199 fTracks->Add(new AliTrack(*tx));
207 ///////////////////////////////////////////////////////////////////////////
208 void AliJet::SetNtinit(Int_t n)
210 // Set the initial maximum number of tracks for this jet
219 ///////////////////////////////////////////////////////////////////////////
222 // Reset all variables to 0
223 // The max. number of tracks is set to the initial value again
227 Double_t a[4]={0,0,0,0};
229 if (fNtinit > 0) SetNtinit(fNtinit);
231 ///////////////////////////////////////////////////////////////////////////
232 void AliJet::AddTrack(AliTrack& t)
234 // Add a track to the jet.
235 // In case the maximum number of tracks has been reached
236 // space will be extended to hold an additional amount of tracks as
237 // was initially reserved.
238 // See SetTrackCopy() to tailor the functionality of the stored structures.
241 ///////////////////////////////////////////////////////////////////////////
242 void AliJet::AddTrack(AliTrack& t,Int_t copy)
244 // Internal memberfunction to actually add a track to the jet.
245 // In case the maximum number of tracks has been reached
246 // space will be extended to hold an additional amount of tracks as
247 // was initially reserved.
249 // If copy=0 NO copy of the track will be made, irrespective of the setting
250 // of the TrackCopy flag.
251 // This allows a proper treatment of automatically generated connecting
252 // tracks between vertices.
255 fTracks=new TObjArray(fNtmax);
256 if (fTrackCopy) fTracks->SetOwner();
258 if (fNtrk == fNtmax) // Check if maximum track number is reached
261 fTracks->Expand(fNtmax);
264 // Add the track to this jet
266 if (fTrackCopy && copy)
268 fTracks->Add(new AliTrack(t));
275 (*this)+=(Ali4Vector&)t;
279 ///////////////////////////////////////////////////////////////////////////
280 void AliJet::Data(TString f)
282 // Provide jet information within the coordinate frame f
283 cout << " *AliJet::Data* Name : " << GetName() << " Title : " << GetTitle() << endl;
284 cout << " Id : " << fUserId << " Invmass : " << GetInvmass() << " Charge : " << fQ
285 << " Momentum : " << GetMomentum() << " Ntracks : " << fNtrk << endl;
289 ///////////////////////////////////////////////////////////////////////////
290 void AliJet::List(TString f)
292 // Provide jet and primary track information within the coordinate frame f
294 Data(f); // Information of the current jet
296 // The tracks of this jet
298 for (Int_t it=1; it<=fNtrk; it++)
303 cout << " ---Track no. " << it << endl;
309 cout << " *AliJet::List* Error : No track present." << endl;
313 ///////////////////////////////////////////////////////////////////////////
314 void AliJet::ListAll(TString f)
316 // Provide jet and prim.+sec. track information within the coordinate frame f
318 Data(f); // Information of the current jet
320 // The tracks of this jet
322 for (Int_t it=1; it<=fNtrk; it++)
327 cout << " ---Track no. " << it << endl;
333 cout << " *AliJet::List* Error : No track present." << endl;
337 ///////////////////////////////////////////////////////////////////////////
338 Int_t AliJet::GetNtracks()
340 // Return the current number of tracks of this jet
343 ///////////////////////////////////////////////////////////////////////////
344 Double_t AliJet::GetEnergy()
346 // Return the total energy of the jet
349 ///////////////////////////////////////////////////////////////////////////
350 Double_t AliJet::GetMomentum()
352 // Return the value of the total jet 3-momentum
353 // The error can be obtained by invoking GetResultError() after
354 // invokation of GetMomentum().
355 Double_t norm=fV.GetNorm();
356 fDresult=fV.GetResultError();
359 ///////////////////////////////////////////////////////////////////////////
360 Ali3Vector AliJet::Get3Momentum()
362 // Return the the total jet 3-momentum
363 Ali3Vector p=Get3Vector();
366 ///////////////////////////////////////////////////////////////////////////
367 Double_t AliJet::GetInvmass()
369 // Return the invariant mass of the jet
370 Double_t m2=Dot(*this);
380 ///////////////////////////////////////////////////////////////////////////
381 Float_t AliJet::GetCharge()
383 // Return the total charge of the jet
386 ///////////////////////////////////////////////////////////////////////////
387 AliTrack* AliJet::GetTrack(Int_t i)
389 // Return the i-th track of this jet
392 cout << " *AliJet*::GetTrack* No tracks present." << endl;
399 cout << " *AliJet*::GetTrack* Invalid argument i : " << i
400 << " Ntrk = " << fNtrk << endl;
405 return (AliTrack*)fTracks->At(i-1);
409 ///////////////////////////////////////////////////////////////////////////
410 AliTrack* AliJet::GetIdTrack(Int_t id)
412 // Return the track with user identifier "id" of this jet
417 cout << " *AliJet*::GetIdTrack* No tracks present." << endl;
422 for (Int_t i=0; i<fNtrk; i++)
424 tx=(AliTrack*)fTracks->At(i);
425 if (id == tx->GetId()) t=tx;
430 ///////////////////////////////////////////////////////////////////////////
431 Double_t AliJet::GetPt()
433 // Provide trans. momentum value w.r.t. z-axis.
434 // The error on the value can be obtained by GetResultError()
435 // after invokation of GetPt().
438 Double_t norm=v.GetNorm();
439 fDresult=v.GetResultError();
443 ///////////////////////////////////////////////////////////////////////////
444 Double_t AliJet::GetPl()
446 // Provide long. momentum value w.r.t. z-axis.
447 // Note : the returned value can also be negative.
448 // The error on the value can be obtained by GetResultError()
449 // after invokation of GetPl().
453 Double_t pl=v.GetNorm();
454 fDresult=v.GetResultError();
457 v.GetVector(a,"sph");
458 if (cos(a[1])<0) pl=-pl;
462 ///////////////////////////////////////////////////////////////////////////
463 Double_t AliJet::GetEt()
465 // Provide trans. energy value w.r.t. z-axis.
466 // The error on the value can be obtained by GetResultError()
467 // after invokation of GetEt().
468 Double_t et=GetScaTrans();
472 ///////////////////////////////////////////////////////////////////////////
473 Double_t AliJet::GetEl()
475 // Provide long. energy value w.r.t. z-axis.
476 // Note : the returned value can also be negative.
477 // The error on the value can be obtained by GetResultError()
478 // after invokation of GetEl().
479 Double_t el=GetScaLong();
483 ///////////////////////////////////////////////////////////////////////////
484 Double_t AliJet::GetMt()
486 // Provide transverse mass value w.r.t. z-axis.
487 // The error on the value can be obtained by GetResultError()
488 // after invokation of GetMt().
490 Double_t dpt=GetResultError();
491 Double_t m=GetInvmass();
492 Double_t dm=GetResultError();
494 Double_t mt=sqrt(pt*pt+m*m);
496 if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
501 ///////////////////////////////////////////////////////////////////////////
502 Double_t AliJet::GetRapidity()
504 // Provide rapidity value w.r.t. z-axis.
505 // The error on the value can be obtained by GetResultError()
506 // after invokation of GetRapidity().
507 // Note : Also GetPseudoRapidity() is available since this class is
508 // derived from Ali4Vector.
509 Double_t e=GetEnergy();
510 Double_t de=GetResultError();
512 Double_t dpl=GetResultError();
516 Double_t y=9999,dy2=0;
517 if (sum && dif) y=0.5*log(sum/dif);
519 if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2));
524 ///////////////////////////////////////////////////////////////////////////
525 void AliJet::SetTrackCopy(Int_t j)
527 // (De)activate the creation of private copies of the added tracks.
528 // j=0 ==> No private copies are made; pointers of original tracks are stored.
529 // j=1 ==> Private copies of the tracks are made and these pointers are stored.
531 // Note : Once the storage contains pointer(s) to AliTrack(s) one cannot
532 // change the TrackCopy mode anymore.
533 // To change the TrackCopy mode for an existing AliJet containing
534 // tracks one first has to invoke Reset().
543 cout << "*AliJet::SetTrackCopy* Invalid argument : " << j << endl;
548 cout << "*AliJet::SetTrackCopy* Storage already contained tracks."
549 << " ==> TrackCopy mode not changed." << endl;
552 ///////////////////////////////////////////////////////////////////////////
553 Int_t AliJet::GetTrackCopy()
555 // Provide value of the TrackCopy mode.
556 // 0 ==> No private copies are made; pointers of original tracks are stored.
557 // 1 ==> Private copies of the tracks are made and these pointers are stored.
560 ///////////////////////////////////////////////////////////////////////////
561 void AliJet::SetId(Int_t id)
563 // Set a user defined identifier for this jet.
566 ///////////////////////////////////////////////////////////////////////////
567 Int_t AliJet::GetId()
569 // Provide the user defined identifier of this jet.
572 ///////////////////////////////////////////////////////////////////////////