]>
Commit | Line | Data |
---|---|---|
4c039060 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | $Log$ | |
959fbac5 | 18 | Revision 1.2 1999/09/29 09:24:28 fca |
19 | Introduction of the Copyright and cvs Log | |
20 | ||
4c039060 | 21 | */ |
22 | ||
959fbac5 | 23 | /////////////////////////////////////////////////////////////////////////// |
24 | // Class AliJet | |
25 | // Creation and investigation of a jet of particle tracks. | |
26 | // An AliJet can be constructed by adding AliTracks. | |
27 | // | |
28 | // Coding example to make 2 jets j1 and j2. | |
29 | // ---------------------------------------- | |
30 | // j1 contains the AliTracks 1 and 2 | |
31 | // j2 contains the AliTracks 3 and 4 | |
32 | // | |
33 | // AliTrack t1,t2,t3,t4; | |
34 | // ... | |
35 | // ... // code to fill the AliTrack data | |
36 | // ... | |
37 | // AliJet j1(5); | |
38 | // AliJet j2(12); | |
39 | // j1.Add(t1); | |
40 | // j1.Add(t2); | |
41 | // j2.Add(t3); | |
42 | // j2.Add(t4); | |
43 | // | |
44 | // j1.Info(); | |
45 | // j2.Info("sph"); | |
46 | // | |
47 | // Float_t e1=j1.GetEnergy(); | |
48 | // Float_t pnorm=j1->GetMomentum(); | |
49 | // Ali3Vector p=j1->Get3Momentum(); | |
50 | // Float_t m=j1.GetInvmass(); | |
51 | // Int_t ntk=j1.GetNtracks(); | |
52 | // AliTrack* tj=j1.GetTrack(1); | |
53 | // | |
54 | // Note : All quantities are in GeV, GeV/c or GeV/c**2 | |
55 | // | |
56 | //--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht | |
57 | //- Modified: NvE 06-apr-1999 UU-SAP Utrecht to inherit from Ali4Vector | |
58 | /////////////////////////////////////////////////////////////////////////// | |
59 | ||
d88f97cc | 60 | #include "AliJet.h" |
61 | ||
62 | ClassImp(AliJet) // Class implementation to enable ROOT I/O | |
63 | ||
64 | AliJet::AliJet() | |
65 | { | |
66 | // Default constructor | |
67 | // All variables initialised to 0 | |
68 | // Initial maximum number of tracks is set to the default value | |
69 | fTracks=0; | |
70 | fNtinit=0; | |
71 | Reset(); | |
72 | SetNtinit(); | |
73 | } | |
74 | /////////////////////////////////////////////////////////////////////////// | |
75 | AliJet::AliJet(Int_t n) | |
76 | { | |
77 | // Create a jet to hold initially a maximum of n tracks | |
78 | // All variables initialised to 0 | |
79 | fTracks=0; | |
80 | fNtinit=0; | |
81 | Reset(); | |
82 | if (n > 0) | |
83 | { | |
84 | SetNtinit(n); | |
85 | } | |
86 | else | |
87 | { | |
88 | cout << endl; | |
89 | cout << " *AliJet* Initial max. number of tracks entered : " << n << endl; | |
90 | cout << " This is invalid. Default initial maximum will be used." << endl; | |
91 | cout << endl; | |
92 | SetNtinit(); | |
93 | } | |
94 | } | |
95 | /////////////////////////////////////////////////////////////////////////// | |
96 | AliJet::~AliJet() | |
97 | { | |
98 | // Default destructor | |
99 | if (fTracks) delete fTracks; | |
100 | fTracks=0; | |
101 | } | |
102 | /////////////////////////////////////////////////////////////////////////// | |
103 | void AliJet::SetNtinit(Int_t n) | |
104 | { | |
105 | // Set the initial maximum number of tracks for this jet | |
106 | fNtinit=n; | |
107 | fNtmax=n; | |
108 | if (fTracks) delete fTracks; | |
109 | fTracks=new TObjArray(fNtmax); | |
110 | } | |
111 | /////////////////////////////////////////////////////////////////////////// | |
112 | void AliJet::Reset() | |
113 | { | |
114 | // Reset all variables to 0 | |
115 | // The max. number of tracks is set to the initial value again | |
116 | fNtrk=0; | |
117 | fQ=0; | |
118 | Double_t a[4]={0,0,0,0}; | |
119 | SetVector(a,"sph"); | |
120 | if (fNtinit > 0) SetNtinit(fNtinit); | |
121 | } | |
122 | /////////////////////////////////////////////////////////////////////////// | |
123 | void AliJet::Add(AliTrack& t) | |
124 | { | |
125 | // Add a track to the jet | |
126 | // In case the maximum number of tracks has been reached | |
127 | // space will be extended to hold an additional amount of tracks as | |
128 | // was initially reserved | |
129 | if (fNtrk == fNtmax) // Check if maximum track number is reached | |
130 | { | |
131 | fNtmax+=fNtinit; | |
132 | fTracks->Expand(fNtmax); | |
133 | } | |
134 | ||
135 | // Add the track to this jet | |
136 | fNtrk++; | |
137 | fTracks->Add(&t); | |
138 | (*this)+=(Ali4Vector&)t; | |
139 | fQ+=t.GetCharge(); | |
140 | } | |
141 | /////////////////////////////////////////////////////////////////////////// | |
142 | void AliJet::Info(TString f) | |
143 | { | |
144 | // Provide jet information within the coordinate frame f | |
145 | cout << " *AliJet::Info* Invmass : " << GetInvmass() << " Charge : " << fQ | |
146 | << " Momentum : " << GetMomentum() << " Ntracks : " << fNtrk << endl; | |
147 | cout << " "; | |
148 | Ali4Vector::Info(f); | |
149 | } | |
150 | /////////////////////////////////////////////////////////////////////////// | |
151 | void AliJet::List(TString f) | |
152 | { | |
153 | // Provide jet and primary track information within the coordinate frame f | |
154 | ||
155 | Info(f); // Information of the current jet | |
156 | ||
157 | // The tracks of this jet | |
158 | AliTrack* t; | |
159 | for (Int_t it=1; it<=fNtrk; it++) | |
160 | { | |
161 | t=GetTrack(it); | |
162 | if (t) | |
163 | { | |
164 | cout << " ---Track no. " << it << endl; | |
165 | cout << " "; | |
166 | t->Info(f); | |
167 | } | |
168 | else | |
169 | { | |
170 | cout << " *AliJet::List* Error : No track present." << endl; | |
171 | } | |
172 | } | |
173 | } | |
174 | /////////////////////////////////////////////////////////////////////////// | |
175 | void AliJet::ListAll(TString f) | |
176 | { | |
177 | // Provide jet and prim.+sec. track information within the coordinate frame f | |
178 | ||
179 | Info(f); // Information of the current jet | |
180 | ||
181 | // The tracks of this jet | |
182 | AliTrack* t; | |
183 | for (Int_t it=1; it<=fNtrk; it++) | |
184 | { | |
185 | t=GetTrack(it); | |
186 | if (t) | |
187 | { | |
188 | cout << " ---Track no. " << it << endl; | |
189 | cout << " "; | |
190 | t->ListAll(f); | |
191 | } | |
192 | else | |
193 | { | |
194 | cout << " *AliJet::List* Error : No track present." << endl; | |
195 | } | |
196 | } | |
197 | } | |
198 | /////////////////////////////////////////////////////////////////////////// | |
199 | Int_t AliJet::GetNtracks() | |
200 | { | |
201 | // Return the current number of tracks of this jet | |
202 | return fNtrk; | |
203 | } | |
204 | /////////////////////////////////////////////////////////////////////////// | |
205 | Double_t AliJet::GetEnergy() | |
206 | { | |
207 | // Return the total energy of the jet | |
208 | return GetScalar(); | |
209 | } | |
210 | /////////////////////////////////////////////////////////////////////////// | |
211 | Double_t AliJet::GetMomentum() | |
212 | { | |
213 | // Return the value of the total jet 3-momentum | |
214 | Ali3Vector p=Get3Vector(); | |
215 | Double_t p2=p.Dot(p); | |
216 | return sqrt(p2); | |
217 | } | |
218 | /////////////////////////////////////////////////////////////////////////// | |
219 | Ali3Vector AliJet::Get3Momentum() | |
220 | { | |
221 | // Return the the total jet 3-momentum | |
222 | Ali3Vector p=Get3Vector(); | |
223 | return p; | |
224 | } | |
225 | /////////////////////////////////////////////////////////////////////////// | |
226 | Double_t AliJet::GetInvmass() | |
227 | { | |
228 | // Return the invariant mass of the jet | |
229 | Double_t m2=Dot(*this); | |
230 | if (m2>0) | |
231 | { | |
232 | return sqrt(m2); | |
233 | } | |
234 | else | |
235 | { | |
236 | return 0; | |
237 | } | |
238 | } | |
239 | /////////////////////////////////////////////////////////////////////////// | |
240 | Float_t AliJet::GetCharge() | |
241 | { | |
242 | // Return the total charge of the jet | |
243 | return fQ; | |
244 | } | |
245 | /////////////////////////////////////////////////////////////////////////// | |
246 | AliTrack* AliJet::GetTrack(Int_t i) | |
247 | { | |
248 | // Return the i-th track of this jet | |
249 | return (AliTrack*)fTracks->At(i-1); | |
250 | } | |
251 | /////////////////////////////////////////////////////////////////////////// |