]>
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 | // |
84bb7c66 | 75 | // j1.Data(); |
76 | // j2.Data("sph"); | |
959fbac5 | 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" |
c72198f1 | 94 | #include "Riostream.h" |
d88f97cc | 95 | |
96 | ClassImp(AliJet) // Class implementation to enable ROOT I/O | |
97 | ||
387a745b | 98 | AliJet::AliJet() : TNamed(),Ali4Vector() |
d88f97cc | 99 | { |
100 | // Default constructor | |
101 | // All variables initialised to 0 | |
102 | // Initial maximum number of tracks is set to the default value | |
6516b62d | 103 | Init(); |
104 | Reset(); | |
105 | SetNtinit(); | |
106 | } | |
107 | /////////////////////////////////////////////////////////////////////////// | |
108 | void AliJet::Init() | |
109 | { | |
110 | // Initialisation of pointers etc... | |
d88f97cc | 111 | fTracks=0; |
112 | fNtinit=0; | |
c1f25d1d | 113 | fTrackCopy=0; |
ea0b5b7f | 114 | fSelected=0; |
d88f97cc | 115 | } |
116 | /////////////////////////////////////////////////////////////////////////// | |
387a745b | 117 | AliJet::AliJet(Int_t n) : TNamed(),Ali4Vector() |
d88f97cc | 118 | { |
119 | // Create a jet to hold initially a maximum of n tracks | |
120 | // All variables initialised to 0 | |
6516b62d | 121 | Init(); |
d88f97cc | 122 | Reset(); |
123 | if (n > 0) | |
124 | { | |
125 | SetNtinit(n); | |
126 | } | |
127 | else | |
128 | { | |
129 | cout << endl; | |
130 | cout << " *AliJet* Initial max. number of tracks entered : " << n << endl; | |
131 | cout << " This is invalid. Default initial maximum will be used." << endl; | |
132 | cout << endl; | |
133 | SetNtinit(); | |
134 | } | |
135 | } | |
136 | /////////////////////////////////////////////////////////////////////////// | |
137 | AliJet::~AliJet() | |
138 | { | |
139 | // Default destructor | |
c1f25d1d | 140 | if (fTracks) |
141 | { | |
c1f25d1d | 142 | delete fTracks; |
143 | fTracks=0; | |
144 | } | |
ea0b5b7f | 145 | if (fSelected) |
146 | { | |
147 | delete fSelected; | |
148 | fSelected=0; | |
149 | } | |
d88f97cc | 150 | } |
151 | /////////////////////////////////////////////////////////////////////////// | |
8e8e6c7f | 152 | void AliJet::SetOwner(Bool_t own) |
153 | { | |
154 | // Set ownership of all added objects. | |
155 | // The default parameter is own=kTRUE. | |
156 | // | |
157 | // Invokation of this memberfunction also sets all the copy modes | |
158 | // (e.g. TrackCopy & co.) according to the value of own. | |
159 | // | |
160 | // This function (with own=kTRUE) is particularly useful when reading data | |
161 | // from a tree/file, since Reset() will then actually remove all the | |
162 | // added objects from memory irrespective of the copy mode settings | |
163 | // during the tree/file creation process. In this way it provides a nice way | |
164 | // of preventing possible memory leaks in the reading/analysis process. | |
165 | // | |
166 | // In addition this memberfunction can also be used as a shortcut to set all | |
167 | // copy modes in one go during a tree/file creation process. | |
168 | // However, in this case the user has to take care to only set/change the | |
169 | // ownership (and copy mode) for empty objects (e.g. newly created objects | |
170 | // or after invokation of the Reset() memberfunction) otherwise it will | |
171 | // very likely result in inconsistent destructor behaviour. | |
172 | ||
173 | Int_t mode=1; | |
174 | if (!own) mode=0; | |
175 | if (fTracks) fTracks->SetOwner(own); | |
176 | fTrackCopy=mode; | |
177 | } | |
178 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 179 | AliJet::AliJet(const AliJet& j) : TNamed(j),Ali4Vector(j) |
6516b62d | 180 | { |
181 | // Copy constructor | |
c72198f1 | 182 | fNtinit=j.fNtinit; |
183 | fNtmax=j.fNtmax; | |
184 | fQ=j.fQ; | |
185 | fNtrk=j.fNtrk; | |
186 | fTrackCopy=j.fTrackCopy; | |
187 | fUserId=j.fUserId; | |
188 | ||
ea0b5b7f | 189 | fSelected=0; |
190 | ||
c72198f1 | 191 | fTracks=0; |
192 | if (fNtrk) | |
193 | { | |
194 | fTracks=new TObjArray(fNtmax); | |
195 | if (fTrackCopy) fTracks->SetOwner(); | |
196 | } | |
6516b62d | 197 | |
c72198f1 | 198 | for (Int_t i=1; i<=fNtrk; i++) |
6516b62d | 199 | { |
c72198f1 | 200 | AliTrack* tx=j.GetTrack(i); |
201 | if (fTrackCopy) | |
202 | { | |
5f25234b | 203 | fTracks->Add(tx->Clone()); |
c72198f1 | 204 | } |
205 | else | |
206 | { | |
207 | fTracks->Add(tx); | |
208 | } | |
6516b62d | 209 | } |
210 | } | |
211 | /////////////////////////////////////////////////////////////////////////// | |
d88f97cc | 212 | void AliJet::SetNtinit(Int_t n) |
213 | { | |
214 | // Set the initial maximum number of tracks for this jet | |
215 | fNtinit=n; | |
216 | fNtmax=n; | |
79830a7e | 217 | if (fTracks) |
c1f25d1d | 218 | { |
c1f25d1d | 219 | delete fTracks; |
220 | fTracks=0; | |
221 | } | |
d88f97cc | 222 | } |
223 | /////////////////////////////////////////////////////////////////////////// | |
224 | void AliJet::Reset() | |
225 | { | |
226 | // Reset all variables to 0 | |
227 | // The max. number of tracks is set to the initial value again | |
228 | fNtrk=0; | |
229 | fQ=0; | |
43bfa5be | 230 | fUserId=0; |
d88f97cc | 231 | Double_t a[4]={0,0,0,0}; |
232 | SetVector(a,"sph"); | |
233 | if (fNtinit > 0) SetNtinit(fNtinit); | |
234 | } | |
235 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 236 | void AliJet::AddTrack(AliTrack& t) |
d88f97cc | 237 | { |
35044448 | 238 | // Add a track to the jet. |
d88f97cc | 239 | // In case the maximum number of tracks has been reached |
240 | // space will be extended to hold an additional amount of tracks as | |
35044448 | 241 | // was initially reserved. |
1fbffa23 | 242 | // See SetTrackCopy() to tailor the functionality of the stored structures. |
5f25234b | 243 | // |
244 | // Note : | |
245 | // In case a private copy is made, this is performed via the Clone() memberfunction. | |
246 | // All AliTrack and derived classes have the default TObject::Clone() memberfunction. | |
247 | // However, derived classes generally contain an internal data structure which may | |
248 | // include pointers to other objects. Therefore it is recommended to provide | |
249 | // for all derived classes a specific copy constructor and override the default Clone() | |
250 | // memberfunction using this copy constructor. | |
251 | // An example for this may be seen from AliTrack. | |
252 | ||
1fbffa23 | 253 | AddTrack(t,1); |
254 | } | |
255 | /////////////////////////////////////////////////////////////////////////// | |
256 | void AliJet::AddTrack(AliTrack& t,Int_t copy) | |
257 | { | |
258 | // Internal memberfunction to actually 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 | // | |
263 | // If copy=0 NO copy of the track will be made, irrespective of the setting | |
264 | // of the TrackCopy flag. | |
265 | // This allows a proper treatment of automatically generated connecting | |
266 | // tracks between vertices. | |
5f25234b | 267 | // |
268 | // Note : | |
269 | // In case a private copy is made, this is performed via the Clone() memberfunction. | |
270 | ||
6516b62d | 271 | if (!fTracks) |
272 | { | |
273 | fTracks=new TObjArray(fNtmax); | |
274 | if (fTrackCopy) fTracks->SetOwner(); | |
275 | } | |
d88f97cc | 276 | if (fNtrk == fNtmax) // Check if maximum track number is reached |
277 | { | |
278 | fNtmax+=fNtinit; | |
279 | fTracks->Expand(fNtmax); | |
280 | } | |
281 | ||
282 | // Add the track to this jet | |
283 | fNtrk++; | |
6516b62d | 284 | if (fTrackCopy && copy) |
c1f25d1d | 285 | { |
5f25234b | 286 | fTracks->Add(t.Clone()); |
c1f25d1d | 287 | } |
288 | else | |
289 | { | |
290 | fTracks->Add(&t); | |
291 | } | |
35044448 | 292 | |
d88f97cc | 293 | (*this)+=(Ali4Vector&)t; |
294 | fQ+=t.GetCharge(); | |
35044448 | 295 | |
d88f97cc | 296 | } |
297 | /////////////////////////////////////////////////////////////////////////// | |
84bb7c66 | 298 | void AliJet::Data(TString f) |
d88f97cc | 299 | { |
300 | // Provide jet information within the coordinate frame f | |
5f25234b | 301 | const char* name=GetName(); |
302 | const char* title=GetTitle(); | |
303 | ||
304 | cout << " *AliJet::Data*"; | |
305 | if (strlen(name)) cout << " Name : " << GetName(); | |
306 | if (strlen(title)) cout << " Title : " << GetTitle(); | |
307 | cout << endl; | |
387a745b | 308 | cout << " Id : " << fUserId << " Invmass : " << GetInvmass() << " Charge : " << fQ |
ea0b5b7f | 309 | << " Momentum : " << GetMomentum() << endl; |
310 | ||
311 | ShowTracks(0); | |
c72198f1 | 312 | |
84bb7c66 | 313 | Ali4Vector::Data(f); |
d88f97cc | 314 | } |
315 | /////////////////////////////////////////////////////////////////////////// | |
316 | void AliJet::List(TString f) | |
317 | { | |
318 | // Provide jet and primary track information within the coordinate frame f | |
319 | ||
84bb7c66 | 320 | Data(f); // Information of the current jet |
d88f97cc | 321 | |
322 | // The tracks of this jet | |
323 | AliTrack* t; | |
324 | for (Int_t it=1; it<=fNtrk; it++) | |
325 | { | |
326 | t=GetTrack(it); | |
327 | if (t) | |
328 | { | |
329 | cout << " ---Track no. " << it << endl; | |
330 | cout << " "; | |
84bb7c66 | 331 | t->Data(f); |
d88f97cc | 332 | } |
333 | else | |
334 | { | |
335 | cout << " *AliJet::List* Error : No track present." << endl; | |
336 | } | |
337 | } | |
338 | } | |
339 | /////////////////////////////////////////////////////////////////////////// | |
340 | void AliJet::ListAll(TString f) | |
341 | { | |
342 | // Provide jet and prim.+sec. track information within the coordinate frame f | |
343 | ||
84bb7c66 | 344 | Data(f); // Information of the current jet |
d88f97cc | 345 | |
346 | // The tracks of this jet | |
347 | AliTrack* t; | |
348 | for (Int_t it=1; it<=fNtrk; it++) | |
349 | { | |
350 | t=GetTrack(it); | |
351 | if (t) | |
352 | { | |
353 | cout << " ---Track no. " << it << endl; | |
354 | cout << " "; | |
355 | t->ListAll(f); | |
356 | } | |
357 | else | |
358 | { | |
359 | cout << " *AliJet::List* Error : No track present." << endl; | |
360 | } | |
361 | } | |
362 | } | |
363 | /////////////////////////////////////////////////////////////////////////// | |
325b076c | 364 | Int_t AliJet::GetNtracks(Int_t idmode,Int_t chmode,Int_t pcode) |
d88f97cc | 365 | { |
325b076c | 366 | // Provide the number of user selected tracks in this jet based on the |
367 | // idmode, chmode and pcode selections as specified by the user. | |
368 | // For specification of the selection parameters see GetTracks(). | |
369 | // The default parameters correspond to no selection, which implies | |
370 | // that invokation of GetNtracks() just returns the total number of | |
371 | // tracks registered in this jet. | |
372 | // | |
373 | // Note : In case certain selections are specified, this function | |
374 | // invokes GetTracks(idmode,chmode,pcode) to determine the | |
375 | // number of tracks corresponding to the selections. | |
376 | // When the jet contains a large number of tracks, invokation | |
377 | // of GetTracks(idmode,chmode,pcode) and subsequently invoking | |
378 | // GetEntries() for the resulting TObjArray* might be slightly | |
379 | // faster. | |
380 | ||
381 | Int_t n=0; | |
382 | if (idmode==0 && chmode==2 && pcode==0) | |
383 | { | |
384 | return fNtrk; | |
385 | } | |
386 | else | |
387 | { | |
388 | TObjArray* arr=GetTracks(idmode,chmode,pcode); | |
389 | n=arr->GetEntries(); | |
390 | return n; | |
391 | } | |
d88f97cc | 392 | } |
393 | /////////////////////////////////////////////////////////////////////////// | |
394 | Double_t AliJet::GetEnergy() | |
395 | { | |
396 | // Return the total energy of the jet | |
397 | return GetScalar(); | |
398 | } | |
399 | /////////////////////////////////////////////////////////////////////////// | |
400 | Double_t AliJet::GetMomentum() | |
401 | { | |
402 | // Return the value of the total jet 3-momentum | |
d071d629 | 403 | // The error can be obtained by invoking GetResultError() after |
404 | // invokation of GetMomentum(). | |
405 | Double_t norm=fV.GetNorm(); | |
406 | fDresult=fV.GetResultError(); | |
407 | return norm; | |
d88f97cc | 408 | } |
409 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 410 | Ali3Vector AliJet::Get3Momentum() const |
d88f97cc | 411 | { |
412 | // Return the the total jet 3-momentum | |
413 | Ali3Vector p=Get3Vector(); | |
414 | return p; | |
415 | } | |
416 | /////////////////////////////////////////////////////////////////////////// | |
417 | Double_t AliJet::GetInvmass() | |
418 | { | |
419 | // Return the invariant mass of the jet | |
420 | Double_t m2=Dot(*this); | |
421 | if (m2>0) | |
422 | { | |
423 | return sqrt(m2); | |
424 | } | |
425 | else | |
426 | { | |
427 | return 0; | |
428 | } | |
429 | } | |
430 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 431 | Float_t AliJet::GetCharge() const |
d88f97cc | 432 | { |
433 | // Return the total charge of the jet | |
434 | return fQ; | |
435 | } | |
436 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 437 | AliTrack* AliJet::GetTrack(Int_t i) const |
d88f97cc | 438 | { |
439 | // Return the i-th track of this jet | |
ea0b5b7f | 440 | |
441 | if (!fTracks) return 0; | |
442 | ||
443 | if (i<=0 || i>fNtrk) | |
f34f4acb | 444 | { |
ea0b5b7f | 445 | cout << " *AliJet*::GetTrack* Invalid argument i : " << i |
446 | << " Ntrk = " << fNtrk << endl; | |
f34f4acb | 447 | return 0; |
448 | } | |
449 | else | |
450 | { | |
ea0b5b7f | 451 | return (AliTrack*)fTracks->At(i-1); |
f34f4acb | 452 | } |
d88f97cc | 453 | } |
454 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 455 | AliTrack* AliJet::GetIdTrack(Int_t id) const |
43bfa5be | 456 | { |
457 | // Return the track with user identifier "id" of this jet | |
4f368c8c | 458 | if (!fTracks) return 0; |
459 | ||
43bfa5be | 460 | AliTrack* tx=0; |
4f368c8c | 461 | for (Int_t i=0; i<fNtrk; i++) |
43bfa5be | 462 | { |
4f368c8c | 463 | tx=(AliTrack*)fTracks->At(i); |
464 | if (id == tx->GetId()) return tx; | |
43bfa5be | 465 | } |
4f368c8c | 466 | return 0; // No matching id found |
43bfa5be | 467 | } |
468 | /////////////////////////////////////////////////////////////////////////// | |
ea0b5b7f | 469 | TObjArray* AliJet::GetTracks(Int_t idmode,Int_t chmode,Int_t pcode) |
470 | { | |
471 | // Provide references to user selected tracks based on the idmode, chmode | |
472 | // and pcode selections as specified by the user. | |
473 | // | |
474 | // The following selection combinations are available : | |
475 | // ---------------------------------------------------- | |
476 | // idmode = -1 ==> Select tracks with negative user identifier "id" | |
477 | // 0 ==> No selection on user identifier | |
478 | // 1 ==> Select tracks with positive user identifier "id" | |
479 | // | |
480 | // chmode = -1 ==> Select tracks with negative charge | |
481 | // 0 ==> Select neutral tracks | |
482 | // 1 ==> Select tracks with positive charge | |
483 | // 2 ==> No selection on charge | |
325b076c | 484 | // 3 ==> Select all charged tracks |
ea0b5b7f | 485 | // |
486 | // pcode = 0 ==> No selection on particle code | |
487 | // X ==> Select tracks with particle code +X or -X | |
488 | // This allows selection of both particles and anti-particles | |
489 | // in case of PDG particle codes. | |
490 | // Selection of either particles or anti-particles can be | |
491 | // obtained in combination with the "chmode" selector. | |
492 | // | |
493 | // Examples : | |
494 | // ---------- | |
495 | // idmode=-1 chmode=0 pcode=0 : Selection of all neutral tracks with negative id. | |
496 | // idmode=0 chmode=2 pcode=211 : Selection of all charged pions (PDG convention). | |
497 | // idmode=0 chmode=1 pcode=321 : Selection of all positive kaons (PDG convention). | |
498 | // | |
499 | // The default values are idmode=0 chmode=2 pcode=0 (i.e. no selections applied). | |
500 | // | |
501 | // Notes : | |
502 | // ------- | |
503 | // 1) In case the user has labeled simulated tracks with negative id and | |
504 | // reconstructed tracks with positive id, this memberfunction provides | |
505 | // easy access to either all simulated or reconstructed tracks. | |
506 | // 2) Subsequent invokations of this memberfunction with e.g. chmode=-1 and chmode=1 | |
507 | // provides a convenient way to investigate particle pairs with opposite charge | |
508 | // (e.g. for invariant mass analysis). | |
509 | ||
510 | if (fSelected) | |
511 | { | |
512 | fSelected->Clear(); | |
513 | } | |
514 | else | |
515 | { | |
516 | fSelected=new TObjArray(); | |
517 | } | |
518 | ||
519 | if (!fTracks) return fSelected; | |
520 | ||
521 | AliTrack* tx=0; | |
522 | Int_t code=0; | |
523 | Int_t id=0; | |
524 | Float_t q=0; | |
525 | for (Int_t i=0; i<fNtrk; i++) | |
526 | { | |
527 | tx=(AliTrack*)fTracks->At(i); | |
528 | if (!tx) continue; | |
529 | ||
530 | code=tx->GetParticleCode(); | |
531 | if (pcode && abs(pcode)!=abs(code)) continue; | |
532 | ||
533 | id=tx->GetId(); | |
534 | if (idmode==-1 && id>=0) continue; | |
535 | if (idmode==1 && id<=0) continue; | |
536 | ||
537 | q=tx->GetCharge(); | |
538 | if (chmode==-1 && q>=0) continue; | |
539 | if (chmode==0 && fabs(q)>1e-10) continue; | |
540 | if (chmode==1 && q<=0) continue; | |
325b076c | 541 | if (chmode==3 && fabs(q)<1e-10) continue; |
ea0b5b7f | 542 | |
543 | fSelected->Add(tx); | |
544 | } | |
545 | ||
546 | return fSelected; | |
547 | } | |
548 | /////////////////////////////////////////////////////////////////////////// | |
325b076c | 549 | void AliJet::ShowTracks(Int_t mode) |
ea0b5b7f | 550 | { |
551 | // Provide an overview of the available tracks. | |
552 | // The argument mode determines the amount of information as follows : | |
553 | // mode = 0 ==> Only printout of the number of tracks | |
554 | // 1 ==> Provide a listing with 1 line of info for each track | |
555 | // | |
556 | // The default is mode=1. | |
557 | // | |
558 | Int_t ntk=GetNtracks(); | |
559 | if (ntk) | |
560 | { | |
561 | if (!mode) | |
562 | { | |
563 | cout << " There are " << ntk << " tracks available." << endl; | |
564 | } | |
565 | else | |
566 | { | |
567 | cout << " The following " << ntk << " tracks are available :" << endl; | |
568 | for (Int_t i=1; i<=ntk; i++) | |
569 | { | |
570 | AliTrack* tx=GetTrack(i); | |
571 | if (tx) | |
572 | { | |
573 | const char* name=tx->GetName(); | |
574 | const char* title=tx->GetTitle(); | |
575 | cout << " Track : " << i; | |
576 | cout << " Id : " << tx->GetId(); | |
577 | cout << " Q : " << tx->GetCharge() << " m : " << tx->GetMass() << " p : " << tx->GetMomentum(); | |
578 | if (strlen(name)) cout << " Name : " << name; | |
579 | if (strlen(title)) cout << " Title : " << title; | |
580 | cout << endl; | |
581 | } | |
582 | } | |
583 | } | |
584 | } | |
585 | else | |
586 | { | |
587 | cout << " No tracks are present." << endl; | |
588 | } | |
589 | } | |
590 | /////////////////////////////////////////////////////////////////////////// | |
d071d629 | 591 | Double_t AliJet::GetPt() |
592 | { | |
593 | // Provide trans. momentum value w.r.t. z-axis. | |
594 | // The error on the value can be obtained by GetResultError() | |
595 | // after invokation of GetPt(). | |
596 | Ali3Vector v; | |
597 | v=GetVecTrans(); | |
598 | Double_t norm=v.GetNorm(); | |
599 | fDresult=v.GetResultError(); | |
600 | ||
601 | return norm; | |
602 | } | |
603 | /////////////////////////////////////////////////////////////////////////// | |
604 | Double_t AliJet::GetPl() | |
605 | { | |
606 | // Provide long. momentum value w.r.t. z-axis. | |
8adaf597 | 607 | // Note : the returned value can also be negative. |
d071d629 | 608 | // The error on the value can be obtained by GetResultError() |
609 | // after invokation of GetPl(). | |
610 | Ali3Vector v; | |
611 | v=GetVecLong(); | |
8adaf597 | 612 | |
613 | Double_t pl=v.GetNorm(); | |
d071d629 | 614 | fDresult=v.GetResultError(); |
615 | ||
8adaf597 | 616 | Double_t a[3]; |
617 | v.GetVector(a,"sph"); | |
618 | if (cos(a[1])<0) pl=-pl; | |
619 | ||
620 | return pl; | |
d071d629 | 621 | } |
622 | /////////////////////////////////////////////////////////////////////////// | |
623 | Double_t AliJet::GetEt() | |
624 | { | |
625 | // Provide trans. energy value w.r.t. z-axis. | |
626 | // The error on the value can be obtained by GetResultError() | |
627 | // after invokation of GetEt(). | |
628 | Double_t et=GetScaTrans(); | |
629 | ||
630 | return et; | |
631 | } | |
632 | /////////////////////////////////////////////////////////////////////////// | |
633 | Double_t AliJet::GetEl() | |
634 | { | |
635 | // Provide long. energy value w.r.t. z-axis. | |
8adaf597 | 636 | // Note : the returned value can also be negative. |
d071d629 | 637 | // The error on the value can be obtained by GetResultError() |
638 | // after invokation of GetEl(). | |
639 | Double_t el=GetScaLong(); | |
640 | ||
641 | return el; | |
642 | } | |
643 | /////////////////////////////////////////////////////////////////////////// | |
644 | Double_t AliJet::GetMt() | |
645 | { | |
646 | // Provide transverse mass value w.r.t. z-axis. | |
647 | // The error on the value can be obtained by GetResultError() | |
648 | // after invokation of GetMt(). | |
649 | Double_t pt=GetPt(); | |
650 | Double_t dpt=GetResultError(); | |
651 | Double_t m=GetInvmass(); | |
652 | Double_t dm=GetResultError(); | |
653 | ||
654 | Double_t mt=sqrt(pt*pt+m*m); | |
655 | Double_t dmt2=0; | |
656 | if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt); | |
657 | ||
658 | fDresult=sqrt(dmt2); | |
659 | return mt; | |
660 | } | |
661 | /////////////////////////////////////////////////////////////////////////// | |
8adaf597 | 662 | Double_t AliJet::GetRapidity() |
663 | { | |
664 | // Provide rapidity value w.r.t. z-axis. | |
665 | // The error on the value can be obtained by GetResultError() | |
666 | // after invokation of GetRapidity(). | |
667 | // Note : Also GetPseudoRapidity() is available since this class is | |
668 | // derived from Ali4Vector. | |
669 | Double_t e=GetEnergy(); | |
670 | Double_t de=GetResultError(); | |
671 | Double_t pl=GetPl(); | |
672 | Double_t dpl=GetResultError(); | |
673 | Double_t sum=e+pl; | |
674 | Double_t dif=e-pl; | |
675 | ||
676 | Double_t y=9999,dy2=0; | |
677 | if (sum && dif) y=0.5*log(sum/dif); | |
678 | ||
679 | if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2)); | |
680 | ||
681 | fDresult=sqrt(dy2); | |
682 | return y; | |
683 | } | |
684 | /////////////////////////////////////////////////////////////////////////// | |
c1f25d1d | 685 | void AliJet::SetTrackCopy(Int_t j) |
686 | { | |
687 | // (De)activate the creation of private copies of the added tracks. | |
688 | // j=0 ==> No private copies are made; pointers of original tracks are stored. | |
689 | // j=1 ==> Private copies of the tracks are made and these pointers are stored. | |
690 | // | |
691 | // Note : Once the storage contains pointer(s) to AliTrack(s) one cannot | |
692 | // change the TrackCopy mode anymore. | |
693 | // To change the TrackCopy mode for an existing AliJet containing | |
694 | // tracks one first has to invoke Reset(). | |
695 | if (!fTracks) | |
696 | { | |
697 | if (j==0 || j==1) | |
698 | { | |
699 | fTrackCopy=j; | |
700 | } | |
701 | else | |
702 | { | |
703 | cout << "*AliJet::SetTrackCopy* Invalid argument : " << j << endl; | |
704 | } | |
705 | } | |
706 | else | |
707 | { | |
708 | cout << "*AliJet::SetTrackCopy* Storage already contained tracks." | |
709 | << " ==> TrackCopy mode not changed." << endl; | |
710 | } | |
711 | } | |
712 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 713 | Int_t AliJet::GetTrackCopy() const |
c1f25d1d | 714 | { |
715 | // Provide value of the TrackCopy mode. | |
716 | // 0 ==> No private copies are made; pointers of original tracks are stored. | |
717 | // 1 ==> Private copies of the tracks are made and these pointers are stored. | |
718 | return fTrackCopy; | |
719 | } | |
720 | /////////////////////////////////////////////////////////////////////////// | |
43bfa5be | 721 | void AliJet::SetId(Int_t id) |
722 | { | |
723 | // Set a user defined identifier for this jet. | |
724 | fUserId=id; | |
725 | } | |
726 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 727 | Int_t AliJet::GetId() const |
43bfa5be | 728 | { |
729 | // Provide the user defined identifier of this jet. | |
730 | return fUserId; | |
731 | } | |
732 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 733 | TObject* AliJet::Clone(const char* name) const |
5f25234b | 734 | { |
735 | // Make a deep copy of the current object and provide the pointer to the copy. | |
736 | // This memberfunction enables automatic creation of new objects of the | |
737 | // correct type depending on the object type, a feature which may be very useful | |
738 | // for containers when adding objects in case the container owns the objects. | |
739 | // This feature allows e.g. AliVertex to store either AliJet objects or | |
740 | // objects derived from AliJet via the AddJet memberfunction, provided | |
741 | // these derived classes also have a proper Clone memberfunction. | |
742 | ||
743 | AliJet* jet=new AliJet(*this); | |
744 | if (name) | |
745 | { | |
746 | if (strlen(name)) jet->SetName(name); | |
747 | } | |
748 | return jet; | |
749 | } | |
750 | /////////////////////////////////////////////////////////////////////////// |