]>
Commit | Line | Data |
---|---|---|
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 | // $Id$ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////// | |
19 | // Class AliJet | |
20 | // Creation and investigation of a jet of particle tracks. | |
21 | // An AliJet can be constructed by adding AliTracks. | |
22 | // | |
23 | // To provide maximal flexibility to the user, two modes of track storage | |
24 | // are provided by means of the memberfunction SetTrackCopy(). | |
25 | // | |
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 | |
30 | // in an AliEvent. | |
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. | |
33 | // | |
34 | // Note : | |
35 | // Modifications made to the original tracks also affect the AliTrack objects | |
36 | // which are stored in the AliJet. | |
37 | // | |
38 | // b) SetTrackCopy(1). | |
39 | // Of every 'added' track a private copy will be made of which the pointer | |
40 | // will be stored. | |
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. | |
47 | // | |
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 | |
52 | // | |
53 | // AliTrack t1,t2; | |
54 | // ... | |
55 | // ... // code to fill the AliTrack data | |
56 | // ... | |
57 | // AliJet j1(); | |
58 | // j1.AddTrack(t1); | |
59 | // j1.AddTrack(t2); | |
60 | // | |
61 | // AliJet j2(); | |
62 | // j2.SetTrackCopy(1); | |
63 | // AliTrack* tx=new AliTrack(); | |
64 | // for (Int_t i=0; i<10; i++) | |
65 | // { | |
66 | // ... | |
67 | // ... // code to set momentum etc... of the track tx | |
68 | // ... | |
69 | // j2.AddTrack(tx); | |
70 | // tx->Reset(); | |
71 | // } | |
72 | // | |
73 | // j1.Info(); | |
74 | // j2.Info("sph"); | |
75 | // | |
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); | |
82 | // | |
83 | // delete tx; | |
84 | // | |
85 | // Note : All quantities are in GeV, GeV/c or GeV/c**2 | |
86 | // | |
87 | //--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht | |
88 | //- Modified: NvE $Date$ UU-SAP Utrecht | |
89 | /////////////////////////////////////////////////////////////////////////// | |
90 | ||
91 | #include "AliJet.h" | |
92 | ||
93 | ClassImp(AliJet) // Class implementation to enable ROOT I/O | |
94 | ||
95 | AliJet::AliJet() | |
96 | { | |
97 | // Default constructor | |
98 | // All variables initialised to 0 | |
99 | // Initial maximum number of tracks is set to the default value | |
100 | fTracks=0; | |
101 | fNtinit=0; | |
102 | fTrackCopy=0; | |
103 | Reset(); | |
104 | SetNtinit(); | |
105 | } | |
106 | /////////////////////////////////////////////////////////////////////////// | |
107 | AliJet::AliJet(Int_t n) | |
108 | { | |
109 | // Create a jet to hold initially a maximum of n tracks | |
110 | // All variables initialised to 0 | |
111 | fTracks=0; | |
112 | fNtinit=0; | |
113 | fTrackCopy=0; | |
114 | Reset(); | |
115 | if (n > 0) | |
116 | { | |
117 | SetNtinit(n); | |
118 | } | |
119 | else | |
120 | { | |
121 | cout << endl; | |
122 | cout << " *AliJet* Initial max. number of tracks entered : " << n << endl; | |
123 | cout << " This is invalid. Default initial maximum will be used." << endl; | |
124 | cout << endl; | |
125 | SetNtinit(); | |
126 | } | |
127 | } | |
128 | /////////////////////////////////////////////////////////////////////////// | |
129 | AliJet::~AliJet() | |
130 | { | |
131 | // Default destructor | |
132 | if (fTracks) | |
133 | { | |
134 | if (fTrackCopy) fTracks->Delete(); | |
135 | delete fTracks; | |
136 | fTracks=0; | |
137 | } | |
138 | } | |
139 | /////////////////////////////////////////////////////////////////////////// | |
140 | void AliJet::SetNtinit(Int_t n) | |
141 | { | |
142 | // Set the initial maximum number of tracks for this jet | |
143 | fNtinit=n; | |
144 | fNtmax=n; | |
145 | if (fTracks) | |
146 | { | |
147 | if (fTrackCopy) fTracks->Delete(); | |
148 | delete fTracks; | |
149 | fTracks=0; | |
150 | } | |
151 | } | |
152 | /////////////////////////////////////////////////////////////////////////// | |
153 | void AliJet::Reset() | |
154 | { | |
155 | // Reset all variables to 0 | |
156 | // The max. number of tracks is set to the initial value again | |
157 | fNtrk=0; | |
158 | fQ=0; | |
159 | fUserId=0; | |
160 | Double_t a[4]={0,0,0,0}; | |
161 | SetVector(a,"sph"); | |
162 | if (fNtinit > 0) SetNtinit(fNtinit); | |
163 | } | |
164 | /////////////////////////////////////////////////////////////////////////// | |
165 | void AliJet::AddTrack(AliTrack& t) | |
166 | { | |
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 | |
175 | { | |
176 | fNtmax+=fNtinit; | |
177 | fTracks->Expand(fNtmax); | |
178 | } | |
179 | ||
180 | // Add the track to this jet | |
181 | fNtrk++; | |
182 | if (fTrackCopy) | |
183 | { | |
184 | fTracks->Add(t.Clone()); | |
185 | } | |
186 | else | |
187 | { | |
188 | fTracks->Add(&t); | |
189 | } | |
190 | ||
191 | (*this)+=(Ali4Vector&)t; | |
192 | fQ+=t.GetCharge(); | |
193 | ||
194 | } | |
195 | /////////////////////////////////////////////////////////////////////////// | |
196 | void AliJet::Info(TString f) | |
197 | { | |
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; | |
201 | cout << " "; | |
202 | Ali4Vector::Info(f); | |
203 | } | |
204 | /////////////////////////////////////////////////////////////////////////// | |
205 | void AliJet::List(TString f) | |
206 | { | |
207 | // Provide jet and primary track information within the coordinate frame f | |
208 | ||
209 | Info(f); // Information of the current jet | |
210 | ||
211 | // The tracks of this jet | |
212 | AliTrack* t; | |
213 | for (Int_t it=1; it<=fNtrk; it++) | |
214 | { | |
215 | t=GetTrack(it); | |
216 | if (t) | |
217 | { | |
218 | cout << " ---Track no. " << it << endl; | |
219 | cout << " "; | |
220 | t->Info(f); | |
221 | } | |
222 | else | |
223 | { | |
224 | cout << " *AliJet::List* Error : No track present." << endl; | |
225 | } | |
226 | } | |
227 | } | |
228 | /////////////////////////////////////////////////////////////////////////// | |
229 | void AliJet::ListAll(TString f) | |
230 | { | |
231 | // Provide jet and prim.+sec. track information within the coordinate frame f | |
232 | ||
233 | Info(f); // Information of the current jet | |
234 | ||
235 | // The tracks of this jet | |
236 | AliTrack* t; | |
237 | for (Int_t it=1; it<=fNtrk; it++) | |
238 | { | |
239 | t=GetTrack(it); | |
240 | if (t) | |
241 | { | |
242 | cout << " ---Track no. " << it << endl; | |
243 | cout << " "; | |
244 | t->ListAll(f); | |
245 | } | |
246 | else | |
247 | { | |
248 | cout << " *AliJet::List* Error : No track present." << endl; | |
249 | } | |
250 | } | |
251 | } | |
252 | /////////////////////////////////////////////////////////////////////////// | |
253 | Int_t AliJet::GetNtracks() | |
254 | { | |
255 | // Return the current number of tracks of this jet | |
256 | return fNtrk; | |
257 | } | |
258 | /////////////////////////////////////////////////////////////////////////// | |
259 | Double_t AliJet::GetEnergy() | |
260 | { | |
261 | // Return the total energy of the jet | |
262 | return GetScalar(); | |
263 | } | |
264 | /////////////////////////////////////////////////////////////////////////// | |
265 | Double_t AliJet::GetMomentum() | |
266 | { | |
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(); | |
272 | return norm; | |
273 | } | |
274 | /////////////////////////////////////////////////////////////////////////// | |
275 | Ali3Vector AliJet::Get3Momentum() | |
276 | { | |
277 | // Return the the total jet 3-momentum | |
278 | Ali3Vector p=Get3Vector(); | |
279 | return p; | |
280 | } | |
281 | /////////////////////////////////////////////////////////////////////////// | |
282 | Double_t AliJet::GetInvmass() | |
283 | { | |
284 | // Return the invariant mass of the jet | |
285 | Double_t m2=Dot(*this); | |
286 | if (m2>0) | |
287 | { | |
288 | return sqrt(m2); | |
289 | } | |
290 | else | |
291 | { | |
292 | return 0; | |
293 | } | |
294 | } | |
295 | /////////////////////////////////////////////////////////////////////////// | |
296 | Float_t AliJet::GetCharge() | |
297 | { | |
298 | // Return the total charge of the jet | |
299 | return fQ; | |
300 | } | |
301 | /////////////////////////////////////////////////////////////////////////// | |
302 | AliTrack* AliJet::GetTrack(Int_t i) | |
303 | { | |
304 | // Return the i-th track of this jet | |
305 | if (!fTracks) | |
306 | { | |
307 | cout << " *AliJet*::GetTrack* No tracks present." << endl; | |
308 | return 0; | |
309 | } | |
310 | else | |
311 | { | |
312 | if (i<=0 || i>fNtrk) | |
313 | { | |
314 | cout << " *AliJet*::GetTrack* Invalid argument i : " << i | |
315 | << " Ntrk = " << fNtrk << endl; | |
316 | return 0; | |
317 | } | |
318 | else | |
319 | { | |
320 | return (AliTrack*)fTracks->At(i-1); | |
321 | } | |
322 | } | |
323 | } | |
324 | /////////////////////////////////////////////////////////////////////////// | |
325 | AliTrack* AliJet::GetIdTrack(Int_t id) | |
326 | { | |
327 | // Return the track with user identifier "id" of this jet | |
328 | AliTrack* tx=0; | |
329 | AliTrack* t=0; | |
330 | if (!fTracks) | |
331 | { | |
332 | cout << " *AliJet*::GetIdTrack* No tracks present." << endl; | |
333 | return 0; | |
334 | } | |
335 | else | |
336 | { | |
337 | for (Int_t i=0; i<fNtrk; i++) | |
338 | { | |
339 | tx=(AliTrack*)fTracks->At(i); | |
340 | if (id == tx->GetId()) t=tx; | |
341 | } | |
342 | return t; | |
343 | } | |
344 | } | |
345 | /////////////////////////////////////////////////////////////////////////// | |
346 | Double_t AliJet::GetPt() | |
347 | { | |
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(). | |
351 | Ali3Vector v; | |
352 | v=GetVecTrans(); | |
353 | Double_t norm=v.GetNorm(); | |
354 | fDresult=v.GetResultError(); | |
355 | ||
356 | return norm; | |
357 | } | |
358 | /////////////////////////////////////////////////////////////////////////// | |
359 | Double_t AliJet::GetPl() | |
360 | { | |
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(). | |
365 | Ali3Vector v; | |
366 | v=GetVecLong(); | |
367 | ||
368 | Double_t pl=v.GetNorm(); | |
369 | fDresult=v.GetResultError(); | |
370 | ||
371 | Double_t a[3]; | |
372 | v.GetVector(a,"sph"); | |
373 | if (cos(a[1])<0) pl=-pl; | |
374 | ||
375 | return pl; | |
376 | } | |
377 | /////////////////////////////////////////////////////////////////////////// | |
378 | Double_t AliJet::GetEt() | |
379 | { | |
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(); | |
384 | ||
385 | return et; | |
386 | } | |
387 | /////////////////////////////////////////////////////////////////////////// | |
388 | Double_t AliJet::GetEl() | |
389 | { | |
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(); | |
395 | ||
396 | return el; | |
397 | } | |
398 | /////////////////////////////////////////////////////////////////////////// | |
399 | Double_t AliJet::GetMt() | |
400 | { | |
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(). | |
404 | Double_t pt=GetPt(); | |
405 | Double_t dpt=GetResultError(); | |
406 | Double_t m=GetInvmass(); | |
407 | Double_t dm=GetResultError(); | |
408 | ||
409 | Double_t mt=sqrt(pt*pt+m*m); | |
410 | Double_t dmt2=0; | |
411 | if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt); | |
412 | ||
413 | fDresult=sqrt(dmt2); | |
414 | return mt; | |
415 | } | |
416 | /////////////////////////////////////////////////////////////////////////// | |
417 | Double_t AliJet::GetRapidity() | |
418 | { | |
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(); | |
426 | Double_t pl=GetPl(); | |
427 | Double_t dpl=GetResultError(); | |
428 | Double_t sum=e+pl; | |
429 | Double_t dif=e-pl; | |
430 | ||
431 | Double_t y=9999,dy2=0; | |
432 | if (sum && dif) y=0.5*log(sum/dif); | |
433 | ||
434 | if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2)); | |
435 | ||
436 | fDresult=sqrt(dy2); | |
437 | return y; | |
438 | } | |
439 | /////////////////////////////////////////////////////////////////////////// | |
440 | void AliJet::SetTrackCopy(Int_t j) | |
441 | { | |
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. | |
445 | // | |
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(). | |
450 | if (!fTracks) | |
451 | { | |
452 | if (j==0 || j==1) | |
453 | { | |
454 | fTrackCopy=j; | |
455 | } | |
456 | else | |
457 | { | |
458 | cout << "*AliJet::SetTrackCopy* Invalid argument : " << j << endl; | |
459 | } | |
460 | } | |
461 | else | |
462 | { | |
463 | cout << "*AliJet::SetTrackCopy* Storage already contained tracks." | |
464 | << " ==> TrackCopy mode not changed." << endl; | |
465 | } | |
466 | } | |
467 | /////////////////////////////////////////////////////////////////////////// | |
468 | Int_t AliJet::GetTrackCopy() | |
469 | { | |
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. | |
473 | return fTrackCopy; | |
474 | } | |
475 | /////////////////////////////////////////////////////////////////////////// | |
476 | void AliJet::SetId(Int_t id) | |
477 | { | |
478 | // Set a user defined identifier for this jet. | |
479 | fUserId=id; | |
480 | } | |
481 | /////////////////////////////////////////////////////////////////////////// | |
482 | Int_t AliJet::GetId() | |
483 | { | |
484 | // Provide the user defined identifier of this jet. | |
485 | return fUserId; | |
486 | } | |
487 | /////////////////////////////////////////////////////////////////////////// |