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 : By default all quantities are in GeV, GeV/c or GeV/c**2
88 // but the user can indicate the usage of a different scale
89 // for the energy-momentum units via the SetEscale() memberfunction.
90 // The actual energy-momentum unit scale can be obtained via the
91 // GetEscale() memberfunction.
93 //--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht
94 //- Modified: NvE $Date$ UU-SAP Utrecht
95 ///////////////////////////////////////////////////////////////////////////
98 #include "Riostream.h"
100 ClassImp(AliJet) // Class implementation to enable ROOT I/O
102 AliJet::AliJet() : TNamed(),Ali4Vector()
104 // Default constructor
105 // All variables initialised to 0
106 // Initial maximum number of tracks is set to the default value
111 ///////////////////////////////////////////////////////////////////////////
114 // Initialisation of pointers etc...
122 ///////////////////////////////////////////////////////////////////////////
123 AliJet::AliJet(Int_t n) : TNamed(),Ali4Vector()
125 // Create a jet to hold initially a maximum of n tracks
126 // All variables initialised to 0
136 cout << " *AliJet* Initial max. number of tracks entered : " << n << endl;
137 cout << " This is invalid. Default initial maximum will be used." << endl;
142 ///////////////////////////////////////////////////////////////////////////
145 // Default destructor
162 ///////////////////////////////////////////////////////////////////////////
163 void AliJet::SetOwner(Bool_t own)
165 // Set ownership of all added objects.
166 // The default parameter is own=kTRUE.
168 // Invokation of this memberfunction also sets all the copy modes
169 // (e.g. TrackCopy & co.) according to the value of own.
171 // This function (with own=kTRUE) is particularly useful when reading data
172 // from a tree/file, since Reset() will then actually remove all the
173 // added objects from memory irrespective of the copy mode settings
174 // during the tree/file creation process. In this way it provides a nice way
175 // of preventing possible memory leaks in the reading/analysis process.
177 // In addition this memberfunction can also be used as a shortcut to set all
178 // copy modes in one go during a tree/file creation process.
179 // However, in this case the user has to take care to only set/change the
180 // ownership (and copy mode) for empty objects (e.g. newly created objects
181 // or after invokation of the Reset() memberfunction) otherwise it will
182 // very likely result in inconsistent destructor behaviour.
186 if (fTracks) fTracks->SetOwner(own);
189 ///////////////////////////////////////////////////////////////////////////
190 AliJet::AliJet(const AliJet& j) : TNamed(j),Ali4Vector(j)
198 fTrackCopy=j.fTrackCopy;
200 if (j.fRef) fRef=new AliPositionObj(*(j.fRef));
207 fTracks=new TObjArray(fNtmax);
208 if (fTrackCopy) fTracks->SetOwner();
211 for (Int_t i=1; i<=fNtrk; i++)
213 AliTrack* tx=j.GetTrack(i);
216 fTracks->Add(tx->Clone());
224 ///////////////////////////////////////////////////////////////////////////
225 void AliJet::SetNtinit(Int_t n)
227 // Set the initial maximum number of tracks for this jet
242 ///////////////////////////////////////////////////////////////////////////
245 // Reset all variables to 0
246 // The max. number of tracks is set to the initial value again
247 // Note : The scale for the energy/momentum units will not be changed.
251 Double_t a[4]={0,0,0,0};
253 if (fNtinit > 0) SetNtinit(fNtinit);
255 ///////////////////////////////////////////////////////////////////////////
256 void AliJet::AddTrack(AliTrack& t)
258 // Add a track to the jet.
259 // In case the maximum number of tracks has been reached
260 // space will be extended to hold an additional amount of tracks as
261 // was initially reserved.
262 // See SetTrackCopy() to tailor the functionality of the stored structures.
266 // In case a private copy is made, this is performed via the Clone() memberfunction.
267 // All AliTrack and derived classes have the default TObject::Clone() memberfunction.
268 // However, derived classes generally contain an internal data structure which may
269 // include pointers to other objects. Therefore it is recommended to provide
270 // for all derived classes a specific copy constructor and override the default Clone()
271 // memberfunction using this copy constructor.
272 // An example for this may be seen from AliTrack.
274 // In case NO private copy is made, a check will be performed if this
275 // specific track is already present in the jet.
276 // If this is the case, no action is performed to prevent multiple
277 // additions of the same track.
282 ///////////////////////////////////////////////////////////////////////////
283 void AliJet::AddTrack(AliTrack& t,Int_t copy)
285 // Internal memberfunction to actually add a track to the jet.
286 // In case the maximum number of tracks has been reached
287 // space will be extended to hold an additional amount of tracks as
288 // was initially reserved.
290 // If copy=0 NO copy of the track will be made, irrespective of the setting
291 // of the TrackCopy flag.
292 // This allows a proper treatment of automatically generated connecting
293 // tracks between vertices.
295 // In case NO copy of the track is made, a check will be performed if this
296 // specific track is already present in the jet.
297 // If this is the case, no action is performed to prevent multiple
298 // additions of the same track.
301 // In case a private copy is made, this is performed via the Clone() memberfunction.
305 fTracks=new TObjArray(fNtmax);
306 if (fTrackCopy) fTracks->SetOwner();
308 else if (!fTrackCopy || !copy) // Check if this track is already present
310 for (Int_t i=0; i<fNtrk; i++)
312 AliTrack* tx=(AliTrack*)fTracks->At(i);
313 if (tx == &t) return;
317 if (fNtrk == fNtmax) // Check if maximum track number is reached
320 fTracks->Expand(fNtmax);
323 // Add the track to this jet
325 if (fTrackCopy && copy)
327 fTracks->Add(t.Clone());
336 Ali4Vector p4=(Ali4Vector)t;
337 Float_t tscale=t.GetEscale();
338 if ((tscale/fEscale > 1.1) || (fEscale/tscale > 1.1)) p4=p4*(tscale/fEscale);
342 ///////////////////////////////////////////////////////////////////////////
343 void AliJet::Data(TString f,TString u)
345 // Provide jet information within the coordinate frame f
347 // The string argument "u" allows to choose between different angular units
348 // in case e.g. a spherical frame is selected.
349 // u = "rad" : angles provided in radians
350 // "deg" : angles provided in degrees
352 // The defaults are f="car" and u="rad".
354 const char* name=GetName();
355 const char* title=GetTitle();
357 cout << " *AliJet::Data*";
358 if (strlen(name)) cout << " Name : " << GetName();
359 if (strlen(title)) cout << " Title : " << GetTitle();
361 cout << " Id : " << fUserId << " Invmass : " << GetInvmass() << " Charge : " << fQ
362 << " Momentum : " << GetMomentum() << " Energy scale : " << fEscale << " GeV" << endl;
366 Ali4Vector::Data(f,u);
368 ///////////////////////////////////////////////////////////////////////////
369 void AliJet::List(TString f,TString u)
371 // Provide jet and primary track information within the coordinate frame f
373 // The string argument "u" allows to choose between different angular units
374 // in case e.g. a spherical frame is selected.
375 // u = "rad" : angles provided in radians
376 // "deg" : angles provided in degrees
378 // The defaults are f="car" and u="rad".
380 Data(f,u); // Information of the current jet
381 if (fRef) { cout << " Ref-point :"; fRef->Data(f,u); }
383 // The tracks of this jet
385 for (Int_t it=1; it<=fNtrk; it++)
390 cout << " ---Track no. " << it << endl;
396 cout << " *AliJet::List* Error : No track present." << endl;
400 ///////////////////////////////////////////////////////////////////////////
401 void AliJet::ListAll(TString f,TString u)
403 // Provide jet and prim.+sec. track information within the coordinate frame f
405 // The string argument "u" allows to choose between different angular units
406 // in case e.g. a spherical frame is selected.
407 // u = "rad" : angles provided in radians
408 // "deg" : angles provided in degrees
410 // The defaults are f="car" and u="rad".
412 Data(f,u); // Information of the current jet
413 if (fRef) { cout << " Ref-point :"; fRef->Data(f,u); }
415 // The tracks of this jet
417 for (Int_t it=1; it<=fNtrk; it++)
422 cout << " ---Track no. " << it << endl;
428 cout << " *AliJet::List* Error : No track present." << endl;
432 ///////////////////////////////////////////////////////////////////////////
433 Int_t AliJet::GetNtracks(Int_t idmode,Int_t chmode,Int_t pcode)
435 // Provide the number of user selected tracks in this jet based on the
436 // idmode, chmode and pcode selections as specified by the user.
437 // For specification of the selection parameters see GetTracks().
438 // The default parameters correspond to no selection, which implies
439 // that invokation of GetNtracks() just returns the total number of
440 // tracks registered in this jet.
442 // Note : In case certain selections are specified, this function
443 // invokes GetTracks(idmode,chmode,pcode) to determine the
444 // number of tracks corresponding to the selections.
445 // When the jet contains a large number of tracks, invokation
446 // of GetTracks(idmode,chmode,pcode) and subsequently invoking
447 // GetEntries() for the resulting TObjArray* might be slightly
451 if (idmode==0 && chmode==2 && pcode==0)
457 TObjArray* arr=GetTracks(idmode,chmode,pcode);
458 if (arr) n=arr->GetEntries();
462 ///////////////////////////////////////////////////////////////////////////
463 Int_t AliJet::GetNtracks(TString name)
465 // Provide the number of tracks with the specified name.
469 // This facility invokes the corresponding GetTracks memberfunction
470 // and as such may result in overwriting existing track selection
471 // arrays. Please refer to the docs of GetTracks for further details.
475 TObjArray* arr=GetTracks(name);
476 if (arr) n=arr->GetEntries();
479 ///////////////////////////////////////////////////////////////////////////
480 Double_t AliJet::GetEnergy(Float_t scale)
482 // Return the total energy of the jet.
483 // By default the energy is returned in the units as it was stored in the jet
484 // structure. However, the user can select a different energy unit scale by
485 // specification of the scale parameter.
486 // The convention is that scale=1 corresponds to GeV, so specification
487 // of scale=0.001 will provide the energy in MeV.
488 // The error can be obtained by invoking GetResultError() after
489 // invokation of GetEnergy().
490 Double_t E=GetScalar();
496 fDresult*=fEscale/scale;
505 ///////////////////////////////////////////////////////////////////////////
506 Double_t AliJet::GetMomentum(Float_t scale)
508 // Return the value of the total jet 3-momentum
509 // By default the momentum is returned in the units as it was stored in the jet
510 // structure. However, the user can select a different momentum unit scale by
511 // specification of the scale parameter.
512 // The convention is that scale=1 corresponds to GeV/c, so specification
513 // of scale=0.001 will provide the momentum in MeV/c.
514 // The error can be obtained by invoking GetResultError() after
515 // invokation of GetMomentum().
517 Double_t norm=fV.GetNorm();
518 fDresult=fV.GetResultError();
522 fDresult*=fEscale/scale;
526 ///////////////////////////////////////////////////////////////////////////
527 Ali3Vector AliJet::Get3Momentum(Float_t scale) const
529 // Return the the total jet 3-momentum
530 // By default the components of the 3-momentum are returned in the units
531 // as they were stored in the jet structure.
532 // However, the user can select a different momentum unit scale for the
533 // components by specification of the scale parameter.
534 // The convention is that scale=1 corresponds to GeV/c, so specification
535 // of scale=0.001 will provide the 3-momentum in MeV/c.
537 Ali3Vector p=Get3Vector();
538 if (scale>0) p*=fEscale/scale;
541 ///////////////////////////////////////////////////////////////////////////
542 Double_t AliJet::GetInvmass(Float_t scale)
544 // Return the invariant mass of the jet.
545 // By default the mass is returned in the units as it was stored in the jet
546 // structure. However, the user can select a different mass unit scale by
547 // specification of the scale parameter.
548 // The convention is that scale=1 corresponds to GeV/c**2, so specification
549 // of scale=0.001 will provide the invariant mass in MeV/c**2.
550 // The error can be obtained by invoking GetResultError() after
551 // invokation of GetInvmass().
553 Double_t inv=Dot(*this);
554 Double_t dinv=GetResultError();
558 Double_t m=sqrt(inv);
559 if (m) dm=dinv/(2.*m);
574 ///////////////////////////////////////////////////////////////////////////
575 Float_t AliJet::GetCharge() const
577 // Return the total charge of the jet
580 ///////////////////////////////////////////////////////////////////////////
581 AliTrack* AliJet::GetTrack(Int_t i) const
583 // Return the i-th track of this jet
585 if (!fTracks) return 0;
589 cout << " *AliJet*::GetTrack* Invalid argument i : " << i
590 << " Ntrk = " << fNtrk << endl;
595 return (AliTrack*)fTracks->At(i-1);
598 ///////////////////////////////////////////////////////////////////////////
599 AliTrack* AliJet::GetIdTrack(Int_t id) const
601 // Return the track with user identifier "id" of this jet
602 if (!fTracks) return 0;
605 for (Int_t i=0; i<fNtrk; i++)
607 tx=(AliTrack*)fTracks->At(i);
608 if (id == tx->GetId()) return tx;
610 return 0; // No matching id found
612 ///////////////////////////////////////////////////////////////////////////
613 TObjArray* AliJet::GetTracks(Int_t idmode,Int_t chmode,Int_t pcode)
615 // Provide references to user selected tracks based on the idmode, chmode
616 // and pcode selections as specified by the user.
618 // The following selection combinations are available :
619 // ----------------------------------------------------
620 // idmode = -1 ==> Select tracks with negative user identifier "id"
621 // 0 ==> No selection on user identifier
622 // 1 ==> Select tracks with positive user identifier "id"
624 // chmode = -1 ==> Select tracks with negative charge
625 // 0 ==> Select neutral tracks
626 // 1 ==> Select tracks with positive charge
627 // 2 ==> No selection on charge
628 // 3 ==> Select all charged tracks
630 // pcode = 0 ==> No selection on particle code
631 // X ==> Select tracks with particle code +X or -X
632 // This allows selection of both particles and anti-particles
633 // in case of PDG particle codes.
634 // Selection of either particles or anti-particles can be
635 // obtained in combination with the "chmode" selector.
639 // idmode=-1 chmode=0 pcode=0 : Selection of all neutral tracks with negative id.
640 // idmode=0 chmode=2 pcode=211 : Selection of all charged pions (PDG convention).
641 // idmode=0 chmode=1 pcode=321 : Selection of all positive kaons (PDG convention).
643 // The default values are idmode=0 chmode=2 pcode=0 (i.e. no selections applied).
647 // 1) In case the user has labeled simulated tracks with negative id and
648 // reconstructed tracks with positive id, this memberfunction provides
649 // easy access to either all simulated or reconstructed tracks.
650 // 2) Subsequent invokations of this memberfunction with e.g. chmode=-1 and chmode=1
651 // provides a convenient way to investigate particle pairs with opposite charge
652 // (e.g. for invariant mass analysis).
653 // 3) The selected track pointers are returned via a multi-purpose array,
654 // which will be overwritten by subsequent selections.
655 // In case the selected track list is to be used amongst other selections,
656 // the user is advised to store the selected track pointers in a local
657 // TObjArray or TRefArray.
665 fSelected=new TObjArray();
668 if (!fTracks) return fSelected;
674 for (Int_t i=0; i<fNtrk; i++)
676 tx=(AliTrack*)fTracks->At(i);
679 code=tx->GetParticleCode();
680 if (pcode && abs(pcode)!=abs(code)) continue;
683 if (idmode==-1 && id>=0) continue;
684 if (idmode==1 && id<=0) continue;
687 if (chmode==-1 && q>=0) continue;
688 if (chmode==0 && fabs(q)>1e-10) continue;
689 if (chmode==1 && q<=0) continue;
690 if (chmode==3 && fabs(q)<1e-10) continue;
697 ///////////////////////////////////////////////////////////////////////////
698 TObjArray* AliJet::GetTracks(TString name)
700 // Provide references to all tracks with the specified name.
704 // 1) In case the user has labeled reconstructed tracks with the name of
705 // the applied reconstruction algorithm, this memberfunction provides
706 // easy access to all tracks reconstructed by a certain method.
707 // 2) The selected track pointers are returned via a multi-purpose array,
708 // which will be overwritten by subsequent selections.
709 // In case the selected track list is to be used amongst other selections,
710 // the user is advised to store the selected track pointers in a local
711 // TObjArray or TRefArray.
719 fSelected=new TObjArray();
722 if (!fTracks) return fSelected;
726 for (Int_t i=0; i<fNtrk; i++)
728 tx=(AliTrack*)fTracks->At(i);
732 if (s == name) fSelected->Add(tx);
737 ///////////////////////////////////////////////////////////////////////////
738 void AliJet::RemoveTracks(TString name)
740 // Remove all tracks with the specified name.
741 // If name="*" all tracks will be removed.
745 // In case the user has labeled reconstructed tracks with the name of
746 // the applied reconstruction algorithm, this memberfunction provides
747 // easy removal of all tracks reconstructed by a certain method.
749 if (!fTracks) return;
754 for (Int_t i=0; i<fNtrk; i++)
756 tx=(AliTrack*)fTracks->At(i);
760 if (s==name || name=="*")
762 obj=fTracks->Remove(tx);
763 if (obj && fTracks->IsOwner()) delete tx;
767 fNtrk=fTracks->GetEntries();
769 ///////////////////////////////////////////////////////////////////////////
770 void AliJet::RemoveTracks(Int_t idmode,Int_t chmode,Int_t pcode)
772 // Remove user selected tracks based on the idmode, chmode and pcode
773 // selections as specified by the user.
774 // For defintions of these selections see the corresponding GetTracks()
777 if (!fTracks) return;
779 TObjArray* arr=GetTracks(idmode,chmode,pcode);
782 Int_t ntk=arr->GetEntries();
787 for (Int_t i=0; i<ntk; i++)
789 tx=(AliTrack*)arr->At(i);
792 obj=fTracks->Remove(tx);
793 if (obj && fTracks->IsOwner()) delete tx;
796 fNtrk=fTracks->GetEntries();
799 ///////////////////////////////////////////////////////////////////////////
800 void AliJet::ShowTracks(Int_t mode)
802 // Provide an overview of the available tracks.
803 // The argument mode determines the amount of information as follows :
804 // mode = 0 ==> Only printout of the number of tracks
805 // 1 ==> Provide a listing with 1 line of info for each track
807 // The default is mode=1.
809 Int_t ntk=GetNtracks();
814 cout << " There are " << ntk << " tracks available." << endl;
818 cout << " The following " << ntk << " tracks are available :" << endl;
819 for (Int_t i=1; i<=ntk; i++)
821 AliTrack* tx=GetTrack(i);
824 const char* name=tx->GetName();
825 const char* title=tx->GetTitle();
826 cout << " Track : " << i;
827 cout << " Id : " << tx->GetId();
828 cout << " Q : " << tx->GetCharge() << " m : " << tx->GetMass() << " p : " << tx->GetMomentum();
829 if (strlen(name)) cout << " Name : " << name;
830 if (strlen(title)) cout << " Title : " << title;
838 cout << " No tracks are present." << endl;
841 ///////////////////////////////////////////////////////////////////////////
842 Double_t AliJet::GetPt(Float_t scale)
844 // Provide the transverse momentum value w.r.t. z-axis.
845 // By default the value is returned in the units as it was stored in the jet
846 // structure. However, the user can select a different momentum unit scale by
847 // specification of the scale parameter.
848 // The convention is that scale=1 corresponds to GeV/c, so specification
849 // of scale=0.001 will provide the transverse momentum in MeV/c.
850 // The error on the value can be obtained by GetResultError()
851 // after invokation of GetPt().
854 Double_t norm=v.GetNorm();
855 fDresult=v.GetResultError();
859 fDresult*=fEscale/scale;
864 ///////////////////////////////////////////////////////////////////////////
865 Double_t AliJet::GetPl(Float_t scale)
867 // Provide the longitudinal momentum value w.r.t. z-axis.
868 // By default the value is returned in the units as it was stored in the jet
869 // structure. However, the user can select a different momentum unit scale by
870 // specification of the scale parameter.
871 // The convention is that scale=1 corresponds to GeV/c, so specification
872 // of scale=0.001 will provide the longitudinal momentum in MeV/c.
873 // Note : the returned value can also be negative.
874 // The error on the value can be obtained by GetResultError()
875 // after invokation of GetPl().
880 Double_t pl=v.GetNorm();
881 fDresult=v.GetResultError();
884 v.GetVector(a,"sph");
885 if (cos(a[1])<0) pl=-pl;
889 fDresult*=fEscale/scale;
894 ///////////////////////////////////////////////////////////////////////////
895 Double_t AliJet::GetEt(Float_t scale)
897 // Provide transverse energy value w.r.t. z-axis.
898 // By default the value is returned in the units as it was stored in the jet
899 // structure. However, the user can select a different energy unit scale by
900 // specification of the scale parameter.
901 // The convention is that scale=1 corresponds to GeV, so specification
902 // of scale=0.001 will provide the transverse energy in MeV.
903 // The error on the value can be obtained by GetResultError()
904 // after invokation of GetEt().
906 Double_t et=GetScaTrans();
910 fDresult*=fEscale/scale;
915 ///////////////////////////////////////////////////////////////////////////
916 Double_t AliJet::GetEl(Float_t scale)
918 // Provide longitudinal energy value w.r.t. z-axis.
919 // By default the value is returned in the units as it was stored in the jet
920 // structure. However, the user can select a different energy unit scale by
921 // specification of the scale parameter.
922 // The convention is that scale=1 corresponds to GeV, so specification
923 // of scale=0.001 will provide the longitudinal energy in MeV.
924 // Note : the returned value can also be negative.
925 // The error on the value can be obtained by GetResultError()
926 // after invokation of GetEl().
928 Double_t el=GetScaLong();
932 fDresult*=fEscale/scale;
937 ///////////////////////////////////////////////////////////////////////////
938 Double_t AliJet::GetMt(Float_t scale)
940 // Provide transverse mass value w.r.t. z-axis.
941 // By default the value is returned in the units as it was stored in the jet
942 // structure. However, the user can select a different energy unit scale by
943 // specification of the scale parameter.
944 // The convention is that scale=1 corresponds to GeV, so specification
945 // of scale=0.001 will provide the transverse mass in MeV.
946 // The error on the value can be obtained by GetResultError()
947 // after invokation of GetMt().
949 Double_t dpt=GetResultError();
950 Double_t m=GetInvmass();
951 Double_t dm=GetResultError();
953 Double_t mt=sqrt(pt*pt+m*m);
955 if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
961 fDresult*=fEscale/scale;
965 ///////////////////////////////////////////////////////////////////////////
966 Double_t AliJet::GetRapidity()
968 // Provide rapidity value w.r.t. z-axis.
969 // The error on the value can be obtained by GetResultError()
970 // after invokation of GetRapidity().
971 // Note : Also GetPseudoRapidity() is available since this class is
972 // derived from Ali4Vector.
973 Double_t e=GetEnergy();
974 Double_t de=GetResultError();
976 Double_t dpl=GetResultError();
980 Double_t y=9999,dy2=0;
981 if (sum && dif) y=0.5*log(sum/dif);
983 if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2));
988 ///////////////////////////////////////////////////////////////////////////
989 void AliJet::SetTrackCopy(Int_t j)
991 // (De)activate the creation of private copies of the added tracks.
992 // j=0 ==> No private copies are made; pointers of original tracks are stored.
993 // j=1 ==> Private copies of the tracks are made and these pointers are stored.
995 // Note : Once the storage contains pointer(s) to AliTrack(s) one cannot
996 // change the TrackCopy mode anymore.
997 // To change the TrackCopy mode for an existing AliJet containing
998 // tracks one first has to invoke Reset().
1007 cout << "*AliJet::SetTrackCopy* Invalid argument : " << j << endl;
1012 cout << "*AliJet::SetTrackCopy* Storage already contained tracks."
1013 << " ==> TrackCopy mode not changed." << endl;
1016 ///////////////////////////////////////////////////////////////////////////
1017 Int_t AliJet::GetTrackCopy() const
1019 // Provide value of the TrackCopy mode.
1020 // 0 ==> No private copies are made; pointers of original tracks are stored.
1021 // 1 ==> Private copies of the tracks are made and these pointers are stored.
1024 ///////////////////////////////////////////////////////////////////////////
1025 void AliJet::SetId(Int_t id)
1027 // Set a user defined identifier for this jet.
1030 ///////////////////////////////////////////////////////////////////////////
1031 Int_t AliJet::GetId() const
1033 // Provide the user defined identifier of this jet.
1036 ///////////////////////////////////////////////////////////////////////////
1037 void AliJet::SetReferencePoint(AliPosition& p)
1039 // Store the position of the jet reference-point.
1040 // The reference-point of a jet provides a means to define a generic
1041 // space-time location for the jet as a whole.
1042 // This doesn't have to be necessarily the location where all the constituent
1043 // tracks originate (e.g. a bundle of parallel tracks doesn't have such
1044 // a location). As such the meaning of this reference-point is different from
1045 // a normal vertex position and allows to provide complimentary information.
1046 // This reference point is the preferable point to start e.g. extrapolations
1047 // and investigate coincidences in space and/or time.
1048 if (fRef) delete fRef;
1049 fRef=new AliPositionObj(p);
1051 ///////////////////////////////////////////////////////////////////////////
1052 AliPosition* AliJet::GetReferencePoint()
1054 // Provide the position of the jet reference-point.
1055 // The reference-point of a jet provides a means to define a generic
1056 // space-time location for the jet as a whole.
1057 // This doesn't have to be necessarily the location where all the constituent
1058 // tracks originate (e.g. a bundle of parallel tracks doesn't have such
1059 // a location). As such the meaning of this reference-point is different from
1060 // a normal vertex position and allows to provide complimentary information.
1061 // This reference point is the preferable point to start e.g. extrapolations
1062 // and investigate coincidences in space and/or time.
1065 ///////////////////////////////////////////////////////////////////////////
1066 TObjArray* AliJet::SortTracks(Int_t mode,TObjArray* tracks)
1068 // Order the references to an array of tracks by looping over the input array "tracks"
1069 // and checking the value of a certain observable.
1070 // The ordered array is returned as a TObjArray.
1071 // In case tracks=0 (default), the registered tracks of the current jet are used.
1072 // Note that the original track array is not modified.
1073 // Via the "mode" argument the user can specify the observable to be checked upon
1074 // and specify whether sorting should be performed in decreasing order (mode<0)
1075 // or in increasing order (mode>0).
1077 // The convention for the observable selection is the following :
1078 // mode : 1 ==> Number of signals associated to the track
1079 // 2 ==> Track energy
1080 // 3 ==> Track momentum
1081 // 4 ==> Mass of the track
1082 // 5 ==> Transverse momentum of the track
1083 // 6 ==> Longitudinal momentum of the track
1084 // 7 ==> Transverse energy of the track
1085 // 8 ==> Longitudinal energy of the track
1086 // 9 ==> Transverse mass of the track
1087 // 10 ==> Track rapidity
1088 // 11 ==> Pseudo-rapidity of the track
1089 // 12 ==> Charge of the track
1090 // 13 ==> Probability of the track hypothesis
1092 // The default is mode=-1.
1094 // Note : This sorting routine uses a common area in memory, which is used
1095 // by various other sorting facilities as well.
1096 // This means that the resulting sorted TObjArray may be overwritten
1097 // when another sorting is invoked.
1098 // To retain the sorted list of pointers, the user is advised to copy
1099 // the pointers contained in the returned TObjArray into a private
1100 // TObjArray instance.
1108 if (!tracks) tracks=fTracks;
1110 if (!mode || abs(mode)>13 || !tracks) return fSelected;
1112 Int_t ntracks=tracks->GetEntries();
1119 fSelected=new TObjArray(ntracks);
1122 Double_t val1,val2; // Values of the observable to be tested upon
1125 for (Int_t i=0; i<ntracks; i++) // Loop over all tracks of the array
1127 AliTrack* tx=(AliTrack*)tracks->At(i);
1131 if (nord == 0) // store the first track at the first ordered position
1134 fSelected->AddAt(tx,nord-1);
1138 for (Int_t j=0; j<=nord; j++) // put track in the right ordered position
1140 if (j == nord) // track has smallest (mode<0) or largest (mode>0) observable value seen so far
1143 fSelected->AddAt(tx,j); // add track at the end
1144 break; // go for next track
1153 val1=tx->GetNsignals();
1154 val2=((AliTrack*)fSelected->At(j))->GetNsignals();
1157 val1=tx->GetEnergy(1);
1158 val2=((AliTrack*)fSelected->At(j))->GetEnergy(1);
1161 val1=tx->GetMomentum(1);
1162 val2=((AliTrack*)fSelected->At(j))->GetMomentum(1);
1165 val1=tx->GetMass(1);
1166 val2=((AliTrack*)fSelected->At(j))->GetMass(1);
1170 val2=((AliTrack*)fSelected->At(j))->GetPt(1);
1174 val2=((AliTrack*)fSelected->At(j))->GetPl(1);
1178 val2=((AliTrack*)fSelected->At(j))->GetEt(1);
1182 val2=((AliTrack*)fSelected->At(j))->GetEl(1);
1186 val2=((AliTrack*)fSelected->At(j))->GetMt(1);
1189 val1=tx->GetRapidity();
1190 val2=((AliTrack*)fSelected->At(j))->GetRapidity();
1193 val1=tx->GetPseudoRapidity();
1194 val2=((AliTrack*)fSelected->At(j))->GetPseudoRapidity();
1197 val1=tx->GetCharge();
1198 val2=((AliTrack*)fSelected->At(j))->GetCharge();
1202 val2=((AliTrack*)fSelected->At(j))->GetProb();
1206 if (mode<0 && val1 <= val2) continue;
1207 if (mode>0 && val1 >= val2) continue;
1210 for (Int_t k=nord-1; k>j; k--) // create empty position
1212 fSelected->AddAt(fSelected->At(k-1),k);
1214 fSelected->AddAt(tx,j); // put track at empty position
1215 break; // go for next track
1220 ///////////////////////////////////////////////////////////////////////////
1221 Double_t AliJet::GetDistance(AliPosition* p,Float_t scale)
1223 // Provide distance of the current jet to the position p.
1224 // The error on the result can be obtained as usual by invoking
1225 // GetResultError() afterwards.
1227 // By default the distance will be provided in the metric unit scale of
1228 // the AliPosition p.
1229 // However, the user can select a different metric unit scale by
1230 // specification of the scale parameter.
1231 // The convention is that scale=1 corresponds to meter, so specification
1232 // of scale=0.01 will provide the distance in cm.
1233 // As such it is possible to obtain a correctly computed distance even in case
1234 // the jet parameters have a different unit scale.
1235 // However, it is recommended to work always with one single unit scale.
1237 // Note : In case of incomplete information, a distance value of -1 is
1243 if (!p) return dist;
1245 // Obtain a defined position on this jet
1246 AliPosition* rx=fRef;
1248 if (!rx) return dist;
1250 Ali3Vector pj=Get3Momentum();
1252 if (pj.GetNorm() <= 0.) return dist;
1255 tj.Set3Momentum(pj);
1256 tj.SetReferencePoint(*rx);
1257 dist=tj.GetDistance(p,scale);
1258 fDresult=tj.GetResultError();
1261 ///////////////////////////////////////////////////////////////////////////
1262 Double_t AliJet::GetDistance(AliTrack* t,Float_t scale)
1264 // Provide distance of the current jet to the track t.
1265 // The error on the result can be obtained as usual by invoking
1266 // GetResultError() afterwards.
1268 // By default the distance will be provided in the metric unit scale of
1270 // However, the user can specify a required metric unit scale by specification
1271 // of the scale parameter.
1272 // The convention is that scale=1 corresponds to meter, so specification
1273 // of scale=0.01 will provide the distance in cm.
1274 // As such it is possible to obtain a correctly computed distance even in case
1275 // the jet and track parameters have a different unit scale.
1276 // However, it is recommended to work always with one single unit scale.
1278 // Note : In case of incomplete information, a distance value of -1 is
1284 if (!t) return dist;
1286 // Obtain a defined position on this jet
1287 AliPosition* rx=fRef;
1289 if (!rx) return dist;
1291 Ali3Vector pj=Get3Momentum();
1293 if (pj.GetNorm() <= 0.) return dist;
1296 tj.Set3Momentum(pj);
1297 tj.SetReferencePoint(*rx);
1298 dist=tj.GetDistance(t,scale);
1299 fDresult=tj.GetResultError();
1302 ///////////////////////////////////////////////////////////////////////////
1303 Double_t AliJet::GetDistance(AliJet* j,Float_t scale)
1305 // Provide distance of the current jet to the jet j.
1306 // The error on the result can be obtained as usual by invoking
1307 // GetResultError() afterwards.
1309 // By default the distance will be provided in the metric unit scale of
1311 // This implies that the results of j1.GetDistance(j2) and j2.GetDistance(j1)
1312 // may be numerically different in case j1 and j2 have different metric units.
1313 // However, the user can specify a required metric unit scale by specification
1314 // of the scale parameter.
1315 // The convention is that scale=1 corresponds to meter, so specification
1316 // of scale=0.01 will provide the distance in cm.
1317 // As such it is possible to obtain a correctly computed distance even in case
1318 // the jet parameters have a different unit scale.
1319 // However, it is recommended to work always with one single unit scale.
1321 // Note : In case of incomplete information, a distance value of -1 is
1327 if (!j) return dist;
1329 // Obtain a defined position on jet j
1330 AliPosition* rx=j->GetReferencePoint();
1332 if (!rx) return dist;
1334 Ali3Vector pj=j->Get3Momentum();
1336 if (pj.GetNorm() <= 0.) return dist;
1339 tj.Set3Momentum(pj);
1340 tj.SetReferencePoint(*rx);
1341 dist=GetDistance(tj,scale);
1344 ///////////////////////////////////////////////////////////////////////////
1345 Int_t AliJet::GetNsignals() const
1347 // Provide the number of signals associated to the jet tracks.
1348 // Note : Multiple occurrences of the same signal are only counted once.
1350 if (fNtrk<1) return 0;
1357 for (Int_t i=1; i<=fNtrk; i++)
1360 for (Int_t j=1; j<=tx->GetNsignals(); j++)
1362 AliSignal* sx=tx->GetSignal(j);
1365 for (Int_t k=0; k<arr.GetEntries(); k++)
1367 if (sx==(AliSignal*)arr.At(k))
1373 if (!exists) arr.Add(sx);
1379 ///////////////////////////////////////////////////////////////////////////
1380 void AliJet::SetEscale(Float_t scale)
1382 // Indicate the energy/momentum scale as used by the user.
1383 // The convention is that scale=1 indicates values in units
1384 // of GeV, GeV/c or GeV/c**2.
1385 // So, in case one decides to store values in units of MeV, MeV/c or MeV/c**2
1386 // the scale indicator should be set to scale=0.001.
1388 // By default scale=1 is set in the constructor.
1396 cout << " *AliJet::SetEscale* Invalid scale value : " << scale << endl;
1399 ///////////////////////////////////////////////////////////////////////////
1400 Float_t AliJet::GetEscale() const
1402 // Provide the energy/momentum scale as used by the user.
1403 // The convention is that scale=1 indicates values in units
1404 // of GeV, GeV/c or GeV/c**2.
1405 // So, a value of scale=0.001 indicates that energy/momentum values are
1406 // stored in units of MeV, MeV/c or MeV/c**2.
1409 ///////////////////////////////////////////////////////////////////////////
1410 TObject* AliJet::Clone(const char* name) const
1412 // Make a deep copy of the current object and provide the pointer to the copy.
1413 // This memberfunction enables automatic creation of new objects of the
1414 // correct type depending on the object type, a feature which may be very useful
1415 // for containers when adding objects in case the container owns the objects.
1416 // This feature allows e.g. AliVertex to store either AliJet objects or
1417 // objects derived from AliJet via the AddJet memberfunction, provided
1418 // these derived classes also have a proper Clone memberfunction.
1420 AliJet* jet=new AliJet(*this);
1423 if (strlen(name)) jet->SetName(name);
1427 ///////////////////////////////////////////////////////////////////////////