]>
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 | ||
f531a546 | 16 | // $Id$ |
4c039060 | 17 | |
959fbac5 | 18 | /////////////////////////////////////////////////////////////////////////// |
19 | // Class AliJet | |
20 | // Creation and investigation of a jet of particle tracks. | |
21 | // An AliJet can be constructed by adding AliTracks. | |
22 | // | |
c1f25d1d | 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. | |
35044448 | 33 | // |
34 | // Note : | |
c1f25d1d | 35 | // Modifications made to the original tracks also affect the AliTrack objects |
36 | // which are stored in the AliJet. | |
35044448 | 37 | // |
c1f25d1d | 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 | // | |
8e8e6c7f | 48 | // See also the documentation provided for the memberfunction SetOwner(). |
49 | // | |
959fbac5 | 50 | // Coding example to make 2 jets j1 and j2. |
51 | // ---------------------------------------- | |
c1f25d1d | 52 | // j1 contains the AliTracks t1 and t2 |
53 | // j2 contains 10 different AliTracks via tx | |
959fbac5 | 54 | // |
c1f25d1d | 55 | // AliTrack t1,t2; |
959fbac5 | 56 | // ... |
57 | // ... // code to fill the AliTrack data | |
58 | // ... | |
c1f25d1d | 59 | // AliJet j1(); |
f531a546 | 60 | // j1.AddTrack(t1); |
61 | // j1.AddTrack(t2); | |
c1f25d1d | 62 | // |
63 | // AliJet j2(); | |
64 | // j2.SetTrackCopy(1); | |
65 | // AliTrack* tx=new AliTrack(); | |
66 | // for (Int_t i=0; i<10; i++) | |
67 | // { | |
68 | // ... | |
69 | // ... // code to set momentum etc... of the track tx | |
70 | // ... | |
71 | // j2.AddTrack(tx); | |
72 | // tx->Reset(); | |
73 | // } | |
959fbac5 | 74 | // |
75 | // j1.Info(); | |
76 | // j2.Info("sph"); | |
77 | // | |
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); | |
84 | // | |
c1f25d1d | 85 | // delete tx; |
86 | // | |
959fbac5 | 87 | // Note : All quantities are in GeV, GeV/c or GeV/c**2 |
88 | // | |
89 | //--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht | |
f531a546 | 90 | //- Modified: NvE $Date$ UU-SAP Utrecht |
959fbac5 | 91 | /////////////////////////////////////////////////////////////////////////// |
92 | ||
d88f97cc | 93 | #include "AliJet.h" |
94 | ||
95 | ClassImp(AliJet) // Class implementation to enable ROOT I/O | |
96 | ||
97 | AliJet::AliJet() | |
98 | { | |
99 | // Default constructor | |
100 | // All variables initialised to 0 | |
101 | // Initial maximum number of tracks is set to the default value | |
6516b62d | 102 | Init(); |
103 | Reset(); | |
104 | SetNtinit(); | |
105 | } | |
106 | /////////////////////////////////////////////////////////////////////////// | |
107 | void AliJet::Init() | |
108 | { | |
109 | // Initialisation of pointers etc... | |
d88f97cc | 110 | fTracks=0; |
111 | fNtinit=0; | |
c1f25d1d | 112 | fTrackCopy=0; |
d88f97cc | 113 | } |
114 | /////////////////////////////////////////////////////////////////////////// | |
115 | AliJet::AliJet(Int_t n) | |
116 | { | |
117 | // Create a jet to hold initially a maximum of n tracks | |
118 | // All variables initialised to 0 | |
6516b62d | 119 | Init(); |
d88f97cc | 120 | Reset(); |
121 | if (n > 0) | |
122 | { | |
123 | SetNtinit(n); | |
124 | } | |
125 | else | |
126 | { | |
127 | cout << endl; | |
128 | cout << " *AliJet* Initial max. number of tracks entered : " << n << endl; | |
129 | cout << " This is invalid. Default initial maximum will be used." << endl; | |
130 | cout << endl; | |
131 | SetNtinit(); | |
132 | } | |
133 | } | |
134 | /////////////////////////////////////////////////////////////////////////// | |
135 | AliJet::~AliJet() | |
136 | { | |
137 | // Default destructor | |
c1f25d1d | 138 | if (fTracks) |
139 | { | |
c1f25d1d | 140 | delete fTracks; |
141 | fTracks=0; | |
142 | } | |
d88f97cc | 143 | } |
144 | /////////////////////////////////////////////////////////////////////////// | |
8e8e6c7f | 145 | void AliJet::SetOwner(Bool_t own) |
146 | { | |
147 | // Set ownership of all added objects. | |
148 | // The default parameter is own=kTRUE. | |
149 | // | |
150 | // Invokation of this memberfunction also sets all the copy modes | |
151 | // (e.g. TrackCopy & co.) according to the value of own. | |
152 | // | |
153 | // This function (with own=kTRUE) is particularly useful when reading data | |
154 | // from a tree/file, since Reset() will then actually remove all the | |
155 | // added objects from memory irrespective of the copy mode settings | |
156 | // during the tree/file creation process. In this way it provides a nice way | |
157 | // of preventing possible memory leaks in the reading/analysis process. | |
158 | // | |
159 | // In addition this memberfunction can also be used as a shortcut to set all | |
160 | // copy modes in one go during a tree/file creation process. | |
161 | // However, in this case the user has to take care to only set/change the | |
162 | // ownership (and copy mode) for empty objects (e.g. newly created objects | |
163 | // or after invokation of the Reset() memberfunction) otherwise it will | |
164 | // very likely result in inconsistent destructor behaviour. | |
165 | ||
166 | Int_t mode=1; | |
167 | if (!own) mode=0; | |
168 | if (fTracks) fTracks->SetOwner(own); | |
169 | fTrackCopy=mode; | |
170 | } | |
171 | /////////////////////////////////////////////////////////////////////////// | |
6516b62d | 172 | AliJet::AliJet(AliJet& j) |
173 | { | |
174 | // Copy constructor | |
175 | Init(); | |
176 | Reset(); | |
177 | SetNtinit(); | |
178 | SetTrackCopy(j.GetTrackCopy()); | |
179 | SetId(j.GetId()); | |
180 | ||
181 | AliTrack* tx=0; | |
182 | for (Int_t i=1; i<=j.GetNtracks(); i++) | |
183 | { | |
184 | tx=j.GetTrack(i); | |
185 | if (tx) AddTrack(tx); | |
186 | } | |
187 | } | |
188 | /////////////////////////////////////////////////////////////////////////// | |
d88f97cc | 189 | void AliJet::SetNtinit(Int_t n) |
190 | { | |
191 | // Set the initial maximum number of tracks for this jet | |
192 | fNtinit=n; | |
193 | fNtmax=n; | |
79830a7e | 194 | if (fTracks) |
c1f25d1d | 195 | { |
c1f25d1d | 196 | delete fTracks; |
197 | fTracks=0; | |
198 | } | |
d88f97cc | 199 | } |
200 | /////////////////////////////////////////////////////////////////////////// | |
201 | void AliJet::Reset() | |
202 | { | |
203 | // Reset all variables to 0 | |
204 | // The max. number of tracks is set to the initial value again | |
205 | fNtrk=0; | |
206 | fQ=0; | |
43bfa5be | 207 | fUserId=0; |
d88f97cc | 208 | Double_t a[4]={0,0,0,0}; |
209 | SetVector(a,"sph"); | |
210 | if (fNtinit > 0) SetNtinit(fNtinit); | |
211 | } | |
212 | /////////////////////////////////////////////////////////////////////////// | |
6516b62d | 213 | void AliJet::AddTrack(AliTrack& t,Int_t copy) |
d88f97cc | 214 | { |
35044448 | 215 | // Add a track to the jet. |
6516b62d | 216 | // Note : The optional parameter "copy" is for internal use only. |
d88f97cc | 217 | // In case the maximum number of tracks has been reached |
218 | // space will be extended to hold an additional amount of tracks as | |
35044448 | 219 | // was initially reserved. |
6516b62d | 220 | if (!fTracks) |
221 | { | |
222 | fTracks=new TObjArray(fNtmax); | |
223 | if (fTrackCopy) fTracks->SetOwner(); | |
224 | } | |
d88f97cc | 225 | if (fNtrk == fNtmax) // Check if maximum track number is reached |
226 | { | |
227 | fNtmax+=fNtinit; | |
228 | fTracks->Expand(fNtmax); | |
229 | } | |
230 | ||
231 | // Add the track to this jet | |
232 | fNtrk++; | |
6516b62d | 233 | if (fTrackCopy && copy) |
c1f25d1d | 234 | { |
6516b62d | 235 | fTracks->Add(new AliTrack(t)); |
c1f25d1d | 236 | } |
237 | else | |
238 | { | |
239 | fTracks->Add(&t); | |
240 | } | |
35044448 | 241 | |
d88f97cc | 242 | (*this)+=(Ali4Vector&)t; |
243 | fQ+=t.GetCharge(); | |
35044448 | 244 | |
d88f97cc | 245 | } |
246 | /////////////////////////////////////////////////////////////////////////// | |
247 | void AliJet::Info(TString f) | |
248 | { | |
249 | // Provide jet information within the coordinate frame f | |
43bfa5be | 250 | cout << " *AliJet::Info* Id : " << fUserId << " Invmass : " << GetInvmass() << " Charge : " << fQ |
d88f97cc | 251 | << " Momentum : " << GetMomentum() << " Ntracks : " << fNtrk << endl; |
252 | cout << " "; | |
253 | Ali4Vector::Info(f); | |
254 | } | |
255 | /////////////////////////////////////////////////////////////////////////// | |
256 | void AliJet::List(TString f) | |
257 | { | |
258 | // Provide jet and primary track information within the coordinate frame f | |
259 | ||
260 | Info(f); // Information of the current jet | |
261 | ||
262 | // The tracks of this jet | |
263 | AliTrack* t; | |
264 | for (Int_t it=1; it<=fNtrk; it++) | |
265 | { | |
266 | t=GetTrack(it); | |
267 | if (t) | |
268 | { | |
269 | cout << " ---Track no. " << it << endl; | |
270 | cout << " "; | |
271 | t->Info(f); | |
272 | } | |
273 | else | |
274 | { | |
275 | cout << " *AliJet::List* Error : No track present." << endl; | |
276 | } | |
277 | } | |
278 | } | |
279 | /////////////////////////////////////////////////////////////////////////// | |
280 | void AliJet::ListAll(TString f) | |
281 | { | |
282 | // Provide jet and prim.+sec. track information within the coordinate frame f | |
283 | ||
284 | Info(f); // Information of the current jet | |
285 | ||
286 | // The tracks of this jet | |
287 | AliTrack* t; | |
288 | for (Int_t it=1; it<=fNtrk; it++) | |
289 | { | |
290 | t=GetTrack(it); | |
291 | if (t) | |
292 | { | |
293 | cout << " ---Track no. " << it << endl; | |
294 | cout << " "; | |
295 | t->ListAll(f); | |
296 | } | |
297 | else | |
298 | { | |
299 | cout << " *AliJet::List* Error : No track present." << endl; | |
300 | } | |
301 | } | |
302 | } | |
303 | /////////////////////////////////////////////////////////////////////////// | |
304 | Int_t AliJet::GetNtracks() | |
305 | { | |
306 | // Return the current number of tracks of this jet | |
307 | return fNtrk; | |
308 | } | |
309 | /////////////////////////////////////////////////////////////////////////// | |
310 | Double_t AliJet::GetEnergy() | |
311 | { | |
312 | // Return the total energy of the jet | |
313 | return GetScalar(); | |
314 | } | |
315 | /////////////////////////////////////////////////////////////////////////// | |
316 | Double_t AliJet::GetMomentum() | |
317 | { | |
318 | // Return the value of the total jet 3-momentum | |
d071d629 | 319 | // The error can be obtained by invoking GetResultError() after |
320 | // invokation of GetMomentum(). | |
321 | Double_t norm=fV.GetNorm(); | |
322 | fDresult=fV.GetResultError(); | |
323 | return norm; | |
d88f97cc | 324 | } |
325 | /////////////////////////////////////////////////////////////////////////// | |
326 | Ali3Vector AliJet::Get3Momentum() | |
327 | { | |
328 | // Return the the total jet 3-momentum | |
329 | Ali3Vector p=Get3Vector(); | |
330 | return p; | |
331 | } | |
332 | /////////////////////////////////////////////////////////////////////////// | |
333 | Double_t AliJet::GetInvmass() | |
334 | { | |
335 | // Return the invariant mass of the jet | |
336 | Double_t m2=Dot(*this); | |
337 | if (m2>0) | |
338 | { | |
339 | return sqrt(m2); | |
340 | } | |
341 | else | |
342 | { | |
343 | return 0; | |
344 | } | |
345 | } | |
346 | /////////////////////////////////////////////////////////////////////////// | |
347 | Float_t AliJet::GetCharge() | |
348 | { | |
349 | // Return the total charge of the jet | |
350 | return fQ; | |
351 | } | |
352 | /////////////////////////////////////////////////////////////////////////// | |
353 | AliTrack* AliJet::GetTrack(Int_t i) | |
354 | { | |
355 | // Return the i-th track of this jet | |
f34f4acb | 356 | if (!fTracks) |
357 | { | |
358 | cout << " *AliJet*::GetTrack* No tracks present." << endl; | |
359 | return 0; | |
360 | } | |
361 | else | |
362 | { | |
363 | if (i<=0 || i>fNtrk) | |
364 | { | |
365 | cout << " *AliJet*::GetTrack* Invalid argument i : " << i | |
366 | << " Ntrk = " << fNtrk << endl; | |
367 | return 0; | |
368 | } | |
369 | else | |
370 | { | |
371 | return (AliTrack*)fTracks->At(i-1); | |
372 | } | |
373 | } | |
d88f97cc | 374 | } |
375 | /////////////////////////////////////////////////////////////////////////// | |
43bfa5be | 376 | AliTrack* AliJet::GetIdTrack(Int_t id) |
377 | { | |
378 | // Return the track with user identifier "id" of this jet | |
379 | AliTrack* tx=0; | |
380 | AliTrack* t=0; | |
381 | if (!fTracks) | |
382 | { | |
383 | cout << " *AliJet*::GetIdTrack* No tracks present." << endl; | |
384 | return 0; | |
385 | } | |
386 | else | |
387 | { | |
388 | for (Int_t i=0; i<fNtrk; i++) | |
389 | { | |
390 | tx=(AliTrack*)fTracks->At(i); | |
391 | if (id == tx->GetId()) t=tx; | |
392 | } | |
393 | return t; | |
394 | } | |
395 | } | |
396 | /////////////////////////////////////////////////////////////////////////// | |
d071d629 | 397 | Double_t AliJet::GetPt() |
398 | { | |
399 | // Provide trans. momentum value w.r.t. z-axis. | |
400 | // The error on the value can be obtained by GetResultError() | |
401 | // after invokation of GetPt(). | |
402 | Ali3Vector v; | |
403 | v=GetVecTrans(); | |
404 | Double_t norm=v.GetNorm(); | |
405 | fDresult=v.GetResultError(); | |
406 | ||
407 | return norm; | |
408 | } | |
409 | /////////////////////////////////////////////////////////////////////////// | |
410 | Double_t AliJet::GetPl() | |
411 | { | |
412 | // Provide long. momentum value w.r.t. z-axis. | |
8adaf597 | 413 | // Note : the returned value can also be negative. |
d071d629 | 414 | // The error on the value can be obtained by GetResultError() |
415 | // after invokation of GetPl(). | |
416 | Ali3Vector v; | |
417 | v=GetVecLong(); | |
8adaf597 | 418 | |
419 | Double_t pl=v.GetNorm(); | |
d071d629 | 420 | fDresult=v.GetResultError(); |
421 | ||
8adaf597 | 422 | Double_t a[3]; |
423 | v.GetVector(a,"sph"); | |
424 | if (cos(a[1])<0) pl=-pl; | |
425 | ||
426 | return pl; | |
d071d629 | 427 | } |
428 | /////////////////////////////////////////////////////////////////////////// | |
429 | Double_t AliJet::GetEt() | |
430 | { | |
431 | // Provide trans. energy value w.r.t. z-axis. | |
432 | // The error on the value can be obtained by GetResultError() | |
433 | // after invokation of GetEt(). | |
434 | Double_t et=GetScaTrans(); | |
435 | ||
436 | return et; | |
437 | } | |
438 | /////////////////////////////////////////////////////////////////////////// | |
439 | Double_t AliJet::GetEl() | |
440 | { | |
441 | // Provide long. energy value w.r.t. z-axis. | |
8adaf597 | 442 | // Note : the returned value can also be negative. |
d071d629 | 443 | // The error on the value can be obtained by GetResultError() |
444 | // after invokation of GetEl(). | |
445 | Double_t el=GetScaLong(); | |
446 | ||
447 | return el; | |
448 | } | |
449 | /////////////////////////////////////////////////////////////////////////// | |
450 | Double_t AliJet::GetMt() | |
451 | { | |
452 | // Provide transverse mass value w.r.t. z-axis. | |
453 | // The error on the value can be obtained by GetResultError() | |
454 | // after invokation of GetMt(). | |
455 | Double_t pt=GetPt(); | |
456 | Double_t dpt=GetResultError(); | |
457 | Double_t m=GetInvmass(); | |
458 | Double_t dm=GetResultError(); | |
459 | ||
460 | Double_t mt=sqrt(pt*pt+m*m); | |
461 | Double_t dmt2=0; | |
462 | if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt); | |
463 | ||
464 | fDresult=sqrt(dmt2); | |
465 | return mt; | |
466 | } | |
467 | /////////////////////////////////////////////////////////////////////////// | |
8adaf597 | 468 | Double_t AliJet::GetRapidity() |
469 | { | |
470 | // Provide rapidity value w.r.t. z-axis. | |
471 | // The error on the value can be obtained by GetResultError() | |
472 | // after invokation of GetRapidity(). | |
473 | // Note : Also GetPseudoRapidity() is available since this class is | |
474 | // derived from Ali4Vector. | |
475 | Double_t e=GetEnergy(); | |
476 | Double_t de=GetResultError(); | |
477 | Double_t pl=GetPl(); | |
478 | Double_t dpl=GetResultError(); | |
479 | Double_t sum=e+pl; | |
480 | Double_t dif=e-pl; | |
481 | ||
482 | Double_t y=9999,dy2=0; | |
483 | if (sum && dif) y=0.5*log(sum/dif); | |
484 | ||
485 | if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2)); | |
486 | ||
487 | fDresult=sqrt(dy2); | |
488 | return y; | |
489 | } | |
490 | /////////////////////////////////////////////////////////////////////////// | |
c1f25d1d | 491 | void AliJet::SetTrackCopy(Int_t j) |
492 | { | |
493 | // (De)activate the creation of private copies of the added tracks. | |
494 | // j=0 ==> No private copies are made; pointers of original tracks are stored. | |
495 | // j=1 ==> Private copies of the tracks are made and these pointers are stored. | |
496 | // | |
497 | // Note : Once the storage contains pointer(s) to AliTrack(s) one cannot | |
498 | // change the TrackCopy mode anymore. | |
499 | // To change the TrackCopy mode for an existing AliJet containing | |
500 | // tracks one first has to invoke Reset(). | |
501 | if (!fTracks) | |
502 | { | |
503 | if (j==0 || j==1) | |
504 | { | |
505 | fTrackCopy=j; | |
506 | } | |
507 | else | |
508 | { | |
509 | cout << "*AliJet::SetTrackCopy* Invalid argument : " << j << endl; | |
510 | } | |
511 | } | |
512 | else | |
513 | { | |
514 | cout << "*AliJet::SetTrackCopy* Storage already contained tracks." | |
515 | << " ==> TrackCopy mode not changed." << endl; | |
516 | } | |
517 | } | |
518 | /////////////////////////////////////////////////////////////////////////// | |
519 | Int_t AliJet::GetTrackCopy() | |
520 | { | |
521 | // Provide value of the TrackCopy mode. | |
522 | // 0 ==> No private copies are made; pointers of original tracks are stored. | |
523 | // 1 ==> Private copies of the tracks are made and these pointers are stored. | |
524 | return fTrackCopy; | |
525 | } | |
526 | /////////////////////////////////////////////////////////////////////////// | |
43bfa5be | 527 | void AliJet::SetId(Int_t id) |
528 | { | |
529 | // Set a user defined identifier for this jet. | |
530 | fUserId=id; | |
531 | } | |
532 | /////////////////////////////////////////////////////////////////////////// | |
533 | Int_t AliJet::GetId() | |
534 | { | |
535 | // Provide the user defined identifier of this jet. | |
536 | return fUserId; | |
537 | } | |
538 | /////////////////////////////////////////////////////////////////////////// |