]>
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 AliVertex | |
20 | // Creation and investigation of an AliVertex. | |
21 | // An AliVertex can be constructed by adding AliTracks and/or AliJets. | |
22 | // | |
23 | // Note : Also (secondary) vertices can be added to a vertex. | |
24 | // | |
f34f4acb | 25 | // To provide maximal flexibility to the user, two modes of vertex storage |
26 | // are provided by means of the memberfunction SetVertexCopy(). | |
27 | // The same holds for the storage of jets via SetJetCopy(). | |
28 | // | |
29 | // a) SetVertexCopy(0) (which is the default). | |
30 | // Only the pointers of the 'added' vertices are stored. | |
31 | // This mode is typically used by making vertex studies based on a fixed list | |
32 | // of vertices which stays under user control or is contained for instance | |
33 | // in an AliEvent. | |
34 | // In this way the AliVertex just represents a 'logical structure' for the | |
35 | // physics analysis which can be embedded in e.g. an AliEvent or AliVertex. | |
35044448 | 36 | // |
37 | // Note : | |
f34f4acb | 38 | // Modifications made to the original vertices also affect the AliVertex objects |
35044448 | 39 | // which are stored. |
40 | // | |
f34f4acb | 41 | // b) SetVertexCopy(1). |
42 | // Of every 'added' vertex a private copy will be made of which the pointer | |
43 | // will be stored. | |
44 | // In this way the AliVertex represents an entity on its own and modifications | |
45 | // made to the original vertices do not affect the AliVertex objects which are | |
46 | // stored. | |
47 | // This mode will allow 'adding' many different AliVertex objects by | |
48 | // creating only one AliVertex instance in the main programme and using the | |
35044448 | 49 | // AliVertex::Reset, AliVertex::AddTrack and parameter setting memberfunctions. |
f34f4acb | 50 | // |
8e8e6c7f | 51 | // See also the documentation provided for the memberfunction SetOwner(). |
52 | // | |
959fbac5 | 53 | // Coding example to make 3 vertices v1, v2 and v3. |
54 | // ------------------------------------------------ | |
55 | // v1 contains the tracks 1,2,3 and 4 | |
f34f4acb | 56 | // v2 contains many different tracks |
959fbac5 | 57 | // v3 contains the jets 1 and 2 |
58 | // | |
f34f4acb | 59 | // AliTrack t1,t2,t3,t4; |
959fbac5 | 60 | // ... |
61 | // ... // code to fill the track data | |
62 | // ... | |
63 | // | |
64 | // AliJet j1,j2; | |
65 | // ... | |
66 | // ... // code to fill the jet data | |
67 | // ... | |
68 | // | |
f34f4acb | 69 | // AliVertex v1; |
70 | // v1.SetVertexCopy(1); | |
959fbac5 | 71 | // |
f531a546 | 72 | // v1.AddTrack(t1); |
73 | // v1.AddTrack(t2); | |
74 | // v1.AddTrack(t3); | |
75 | // v1.AddTrack(t4); | |
959fbac5 | 76 | // |
77 | // Float_t r1[3]={2.4,0.1,-8.5}; | |
78 | // v1.SetPosition(r1,"car"); | |
79 | // | |
f34f4acb | 80 | // AliVertex v2; |
81 | // v2.SetTrackCopy(1); | |
82 | // | |
83 | // AliTrack* tx=new AliTrack(); | |
84 | // for (Int_t i=0; i<10; i++) | |
85 | // { | |
86 | // ... | |
87 | // ... // code to fill the track data | |
88 | // ... | |
89 | // v2.AddTrack(tx); | |
90 | // tx->Reset(); | |
91 | // } | |
959fbac5 | 92 | // |
93 | // Float_t r2[3]={1.6,-3.2,5.7}; | |
94 | // v2.SetPosition(r2,"car"); | |
95 | // | |
96 | // AliVertex v3; | |
97 | // | |
f531a546 | 98 | // v3.AddJet(j1); |
99 | // v3.AddJet(j2); | |
959fbac5 | 100 | // |
101 | // Float_t r3[3]={6.2,4.8,1.3}; | |
102 | // v3.SetPosition(r3,"car"); | |
103 | // | |
104 | // v1.Info("sph"); | |
105 | // v2.ListAll(); | |
106 | // v3.List("cyl"); | |
107 | // | |
108 | // Float_t e1=v1.GetEnergy(); | |
109 | // Ali3Vector p1=v1.Get3Momentum(); | |
110 | // Float_t loc[3]; | |
111 | // v1.GetPosition(loc,"sph"); | |
112 | // AliPosition r=v2.GetPosition(); | |
113 | // r.Info(); | |
114 | // Int_t nt=v2.GetNtracks(); | |
115 | // AliTrack* tv=v2.GetTrack(1); // Access track number 1 of Vertex v2 | |
116 | // | |
117 | // Specify the vertices v2 and v3 as secondary vertices of v1 | |
118 | // | |
f531a546 | 119 | // v1.AddVertex(v2); |
120 | // v1.AddVertex(v3); | |
959fbac5 | 121 | // |
122 | // v1.List(); | |
123 | // | |
124 | // Int_t nv=v1.GetNvtx(); | |
125 | // AliVertex* vx=v1.GetVertex(1); // Access 1st secondary vertex of v1 | |
126 | // Float_t e=vx->GetEnergy(); | |
127 | // | |
128 | // Float_t M=v1.GetInvmass(); | |
129 | // | |
130 | // Reconstruct Vertex v1 from scratch | |
131 | // | |
132 | // v1.Reset(); | |
133 | // v1.SetNvmax(25); // Increase initial no. of sec. vertices | |
f531a546 | 134 | // v1.AddTrack(t3); |
f34f4acb | 135 | // v1.AddTrack(t4); |
f531a546 | 136 | // v1.AddJet(j2); |
959fbac5 | 137 | // Float_t pos[3]={7,9,4}; |
138 | // v1.SetPosition(pos,"car"); | |
139 | // | |
140 | // Note : All quantities are in GeV, GeV/c or GeV/c**2 | |
141 | // | |
142 | //--- Author: Nick van Eijndhoven 04-apr-1998 UU-SAP Utrecht | |
f531a546 | 143 | //- Modified: NvE $Date$ UU-SAP Utrecht |
959fbac5 | 144 | /////////////////////////////////////////////////////////////////////////// |
145 | ||
d88f97cc | 146 | #include "AliVertex.h" |
147 | ||
148 | ClassImp(AliVertex) // Class implementation to enable ROOT I/O | |
149 | ||
150 | AliVertex::AliVertex() | |
151 | { | |
959fbac5 | 152 | // Default constructor. |
153 | // All variables initialised to 0. | |
154 | // Initial maximum number of tracks is set to the default value. | |
155 | // Initial maximum number of sec. vertices is set to the default value. | |
6516b62d | 156 | Init(); |
d88f97cc | 157 | Reset(); |
158 | SetNtinit(); | |
159 | SetNvmax(); | |
f34f4acb | 160 | SetNjmax(); |
d88f97cc | 161 | } |
162 | /////////////////////////////////////////////////////////////////////////// | |
6516b62d | 163 | void AliVertex::Init() |
d88f97cc | 164 | { |
6516b62d | 165 | // Initialisation of pointers etc... |
166 | AliJet::Init(); | |
d88f97cc | 167 | fNvmax=0; |
168 | fVertices=0; | |
29beb80d | 169 | fConnects=0; |
f34f4acb | 170 | fVertexCopy=0; |
171 | fNjmax=0; | |
172 | fJets=0; | |
6516b62d | 173 | fJetTracks=0; |
f34f4acb | 174 | fJetCopy=0; |
a37bb40e | 175 | fLines=0; |
6516b62d | 176 | } |
177 | /////////////////////////////////////////////////////////////////////////// | |
178 | AliVertex::AliVertex(Int_t n) | |
179 | { | |
180 | // Create a vertex to hold initially a maximum of n tracks | |
181 | // All variables initialised to 0 | |
182 | Init(); | |
d88f97cc | 183 | Reset(); |
184 | if (n > 0) | |
185 | { | |
186 | SetNtinit(n); | |
187 | } | |
188 | else | |
189 | { | |
190 | cout << endl; | |
191 | cout << " *AliVertex* Initial max. number of tracks entered : " << n << endl; | |
192 | cout << " This is invalid. Default initial maximum will be used." << endl; | |
193 | cout << endl; | |
194 | SetNtinit(); | |
195 | } | |
196 | SetNvmax(); | |
f34f4acb | 197 | SetNjmax(); |
d88f97cc | 198 | } |
199 | /////////////////////////////////////////////////////////////////////////// | |
200 | AliVertex::~AliVertex() | |
201 | { | |
202 | // Default destructor | |
f34f4acb | 203 | if (fVertices) |
204 | { | |
f34f4acb | 205 | delete fVertices; |
206 | fVertices=0; | |
207 | } | |
29beb80d | 208 | if (fConnects) |
209 | { | |
29beb80d | 210 | delete fConnects; |
211 | fConnects=0; | |
212 | } | |
f34f4acb | 213 | if (fJets) |
214 | { | |
f34f4acb | 215 | delete fJets; |
216 | fJets=0; | |
217 | } | |
6516b62d | 218 | if (fJetTracks) |
219 | { | |
220 | delete fJetTracks; | |
221 | fJetTracks=0; | |
222 | } | |
a37bb40e | 223 | if (fLines) |
224 | { | |
225 | delete fLines; | |
226 | fLines=0; | |
227 | } | |
6516b62d | 228 | } |
229 | /////////////////////////////////////////////////////////////////////////// | |
8e8e6c7f | 230 | void AliVertex::SetOwner(Bool_t own) |
231 | { | |
232 | // Set ownership of all added objects. | |
233 | // The default parameter is own=kTRUE. | |
234 | // | |
235 | // Invokation of this memberfunction also sets all the copy modes | |
236 | // (e.g. TrackCopy & co.) according to the value of own. | |
237 | // | |
238 | // This function (with own=kTRUE) is particularly useful when reading data | |
239 | // from a tree/file, since Reset() will then actually remove all the | |
240 | // added objects from memory irrespective of the copy mode settings | |
241 | // during the tree/file creation process. In this way it provides a nice way | |
242 | // of preventing possible memory leaks in the reading/analysis process. | |
243 | // | |
244 | // In addition this memberfunction can also be used as a shortcut to set all | |
245 | // copy modes in one go during a tree/file creation process. | |
246 | // However, in this case the user has to take care to only set/change the | |
247 | // ownership (and copy mode) for empty objects (e.g. newly created objects | |
248 | // or after invokation of the Reset() memberfunction) otherwise it will | |
249 | // very likely result in inconsistent destructor behaviour. | |
250 | ||
251 | Int_t mode=1; | |
252 | if (!own) mode=0; | |
253 | if (fVertices) fVertices->SetOwner(own); | |
254 | fVertexCopy=mode; | |
255 | if (fJets) fJets->SetOwner(own); | |
256 | fJetCopy=mode; | |
257 | ||
258 | AliJet::SetOwner(own); | |
259 | } | |
260 | /////////////////////////////////////////////////////////////////////////// | |
6516b62d | 261 | AliVertex::AliVertex(AliVertex& v) |
262 | { | |
263 | // Copy constructor | |
264 | Init(); | |
265 | Reset(); | |
266 | SetNtinit(); | |
267 | SetNvmax(); | |
268 | SetNjmax(); | |
269 | SetTrackCopy(v.GetTrackCopy()); | |
270 | SetVertexCopy(v.GetVertexCopy()); | |
271 | SetJetCopy(v.GetJetCopy()); | |
272 | SetId(v.GetId()); | |
273 | SetPosition(v.GetPosition()); | |
274 | ||
275 | // Copy all tracks except the ones coming from jets | |
276 | AliTrack* tx=0; | |
277 | Int_t jetflag=0,connect=0; | |
278 | AliTrack* tx2=0; | |
279 | for (Int_t it=1; it<=v.GetNtracks(); it++) | |
280 | { | |
281 | tx=v.GetTrack(it); | |
282 | if (tx) | |
283 | { | |
284 | jetflag=v.IsJetTrack(tx); | |
285 | connect=v.IsConnectTrack(tx); | |
286 | ||
287 | if (!jetflag && !connect) AddTrack(tx); | |
288 | ||
289 | if (connect) | |
290 | { | |
291 | if (!fConnects) | |
292 | { | |
293 | fConnects=new TObjArray(fNvmax); | |
294 | if (!fTrackCopy) fConnects->SetOwner(); | |
295 | } | |
296 | tx2=new AliTrack(*tx); | |
297 | fConnects->Add(tx2); | |
298 | AddTrack(tx2,0); | |
299 | } | |
300 | } | |
301 | } | |
302 | ||
303 | // Copy all the (secondary) vertices without re-creating connecting tracks | |
304 | // The connecting tracks have already been copied above | |
305 | AliVertex* vx=0; | |
306 | for (Int_t iv=1; iv<=v.GetNvertices(); iv++) | |
307 | { | |
308 | vx=v.GetVertex(iv); | |
309 | if (vx) AddVertex(vx,0); | |
310 | } | |
311 | ||
312 | // Copy all the jets including the jet tracks for these jets for which | |
313 | // this was also the case in the original vertex | |
314 | AliJet* jx=0; | |
315 | for (Int_t ij=1; ij<=v.GetNjets(); ij++) | |
316 | { | |
317 | jx=v.GetJet(ij); | |
318 | if (jx) | |
319 | { | |
320 | jetflag=0; | |
321 | if (jx->GetNtracks()) | |
322 | { | |
323 | tx=jx->GetTrack(1); | |
324 | if (tx) | |
325 | { | |
326 | jetflag=v.IsJetTrack(tx); | |
327 | } | |
328 | } | |
329 | AddJet(jx,jetflag); | |
330 | } | |
331 | } | |
d88f97cc | 332 | } |
333 | /////////////////////////////////////////////////////////////////////////// | |
334 | void AliVertex::SetNvmax(Int_t n) | |
335 | { | |
336 | // Set the initial maximum number of (secondary) vertices | |
337 | if (n > 0) | |
338 | { | |
339 | fNvmax=n; | |
340 | } | |
341 | else | |
342 | { | |
343 | fNvmax=1; | |
344 | } | |
f34f4acb | 345 | if (fVertices) |
346 | { | |
f34f4acb | 347 | delete fVertices; |
348 | fVertices=0; | |
349 | } | |
350 | } | |
351 | /////////////////////////////////////////////////////////////////////////// | |
352 | void AliVertex::SetNjmax(Int_t n) | |
353 | { | |
354 | // Set the initial maximum number of jets | |
355 | if (n > 0) | |
356 | { | |
357 | fNjmax=n; | |
358 | } | |
359 | else | |
360 | { | |
361 | fNjmax=1; | |
362 | } | |
363 | if (fJets) | |
364 | { | |
f34f4acb | 365 | delete fJets; |
366 | fJets=0; | |
367 | } | |
d88f97cc | 368 | } |
369 | /////////////////////////////////////////////////////////////////////////// | |
370 | void AliVertex::Reset() | |
371 | { | |
7849a8ab | 372 | // Reset all variables to 0 and reset all stored vertex and jet lists. |
d88f97cc | 373 | // The max. number of tracks is set to the initial value again |
374 | // The max. number of vertices is set to the default value again | |
7849a8ab | 375 | // The max. number of jets is set to the default value again |
d88f97cc | 376 | |
377 | AliJet::Reset(); | |
378 | ||
f531a546 | 379 | Double_t a[3]={0,0,0}; |
380 | SetPosition(a,"sph"); | |
381 | SetPositionErrors(a,"car"); | |
382 | ||
d88f97cc | 383 | fNvtx=0; |
384 | if (fNvmax>0) SetNvmax(fNvmax); | |
29beb80d | 385 | if (fConnects) |
386 | { | |
29beb80d | 387 | delete fConnects; |
388 | fConnects=0; | |
389 | } | |
f34f4acb | 390 | |
391 | fNjets=0; | |
392 | if (fNjmax>0) SetNjmax(fNjmax); | |
6516b62d | 393 | if (fJetTracks) |
394 | { | |
395 | delete fJetTracks; | |
396 | fJetTracks=0; | |
397 | } | |
a37bb40e | 398 | |
399 | if (fLines) | |
400 | { | |
401 | delete fLines; | |
402 | fLines=0; | |
403 | } | |
d88f97cc | 404 | } |
405 | /////////////////////////////////////////////////////////////////////////// | |
7849a8ab | 406 | void AliVertex::ResetVertices() |
407 | { | |
408 | // Reset the stored vertex list and delete all connecting tracks which | |
409 | // were generated automatically via connect=1 in AddVertex(). | |
410 | // The max. number of vertices is set to the default value again. | |
35044448 | 411 | // All physics quantities are updated according to the removal of the |
412 | // connecting tracks. | |
7849a8ab | 413 | AliTrack* t; |
414 | if (fConnects) | |
415 | { | |
416 | for (Int_t i=0; i<=fConnects->GetLast(); i++) | |
417 | { | |
418 | t=(AliTrack*)fConnects->At(i); | |
419 | AliTrack* test=(AliTrack*)fTracks->Remove(t); | |
35044448 | 420 | if (test) |
421 | { | |
422 | fNtrk--; | |
423 | (Ali4Vector&)(*this)-=(Ali4Vector&)(*t); | |
424 | fQ-=t->GetCharge(); | |
6516b62d | 425 | if (fTrackCopy) delete t; |
35044448 | 426 | } |
7849a8ab | 427 | } |
428 | fTracks->Compress(); | |
429 | } | |
430 | ||
7849a8ab | 431 | fNvtx=0; |
432 | if (fNvmax>0) SetNvmax(fNvmax); | |
433 | if (fConnects) | |
434 | { | |
7849a8ab | 435 | delete fConnects; |
436 | fConnects=0; | |
437 | } | |
438 | } | |
439 | /////////////////////////////////////////////////////////////////////////// | |
f34f4acb | 440 | void AliVertex::AddJet(AliJet& j,Int_t tracks) |
d88f97cc | 441 | { |
f34f4acb | 442 | // Add a jet (and its tracks) to the vertex |
443 | // In case the maximum number of jets has been reached, | |
444 | // the array space will be extended automatically | |
445 | // | |
446 | // Note : By default the tracks of the jet are added to the current (primary) | |
447 | // vertex. | |
448 | // The automatic addition of the tracks of the jet can be suppressed | |
449 | // by specifying tracks=0. In this case only the AliJet object will | |
450 | // be stored according to the mode specified by SetJetCopy(). | |
451 | // The latter will enable jet studies based on a fixed list of tracks | |
452 | // as contained e.g. in an AliVertex or AliEvent. | |
6516b62d | 453 | if (!fJets) |
454 | { | |
455 | fJets=new TObjArray(fNjmax); | |
456 | if (fJetCopy) fJets->SetOwner(); | |
457 | } | |
f34f4acb | 458 | if (fNjets == fNjmax) // Check if maximum jet number is reached |
d88f97cc | 459 | { |
f34f4acb | 460 | fNjmax++; |
461 | fJets->Expand(fNjmax); | |
462 | } | |
463 | ||
464 | // Add the jet to the list | |
6516b62d | 465 | AliJet* jx=&j; |
466 | if (fJetCopy) jx=new AliJet(j); | |
467 | ||
468 | if (jx) | |
f34f4acb | 469 | { |
6516b62d | 470 | fNjets++; |
471 | fJets->Add(jx); | |
f34f4acb | 472 | } |
473 | ||
474 | // Add the tracks of the jet to this vertex | |
475 | if (tracks) | |
476 | { | |
6516b62d | 477 | if (!fJetTracks) |
478 | { | |
479 | fJetTracks=new TObjArray(); | |
480 | } | |
481 | Int_t copy=1-(jx->GetTrackCopy()); | |
f34f4acb | 482 | AliTrack* tj; |
6516b62d | 483 | for (Int_t i=1; i<=jx->GetNtracks(); i++) |
f34f4acb | 484 | { |
6516b62d | 485 | tj=jx->GetTrack(i); |
486 | if (tj) | |
487 | { | |
488 | AddTrack(tj,copy); | |
489 | fJetTracks->Add(tj); | |
490 | } | |
f34f4acb | 491 | } |
d88f97cc | 492 | } |
493 | } | |
494 | /////////////////////////////////////////////////////////////////////////// | |
f531a546 | 495 | void AliVertex::AddVertex(AliVertex& v,Int_t connect) |
d88f97cc | 496 | { |
497 | // Add a (secondary) vertex to the current vertex. | |
498 | // In case the maximum number of (secondary) vertices has been reached, | |
499 | // the array space will be extended automatically | |
500 | // | |
29beb80d | 501 | // Note : By default the 4-momentum and charge of the current (primary) vertex |
502 | // are updated by automatically creating the track connecting | |
503 | // both vertices. The track parameters are taken from the | |
504 | // 4-momentum and charge of the secondary vertex. | |
505 | // The automatic creation of the connecting track and updating | |
506 | // of the (primary) vertex 4-momentum and charge can be suppressed | |
507 | // by specifying connect=0. In this case, however, the user | |
508 | // has to introduce the connecting track lateron by hand | |
509 | // explicitly in order to match the kinematics and charge. | |
d88f97cc | 510 | // |
6516b62d | 511 | if (!fVertices) |
512 | { | |
513 | fVertices=new TObjArray(fNvmax); | |
514 | if (fVertexCopy) fVertices->SetOwner(); | |
515 | } | |
d88f97cc | 516 | if (fNvtx == fNvmax) // Check if maximum vertex number is reached |
517 | { | |
518 | fNvmax++; | |
519 | fVertices->Expand(fNvmax); | |
520 | } | |
29beb80d | 521 | |
522 | // Add the linked (secondary) vertex to the list | |
6516b62d | 523 | AliVertex* vx=&v; |
524 | if (fVertexCopy) vx=new AliVertex(v); | |
525 | ||
526 | if (vx) | |
f34f4acb | 527 | { |
6516b62d | 528 | fNvtx++; |
529 | fVertices->Add(vx); | |
530 | } | |
29beb80d | 531 | |
532 | // Create connecting track and update 4-momentum and charge for current vertex | |
533 | if (connect) | |
534 | { | |
43bfa5be | 535 | AliTrack* t=new AliTrack(); |
6516b62d | 536 | t->SetBeginPoint(GetPosition()); |
537 | t->SetEndPoint(v.GetPosition()); | |
538 | t->SetCharge(v.GetCharge()); | |
539 | t->Set4Momentum((Ali4Vector&)v); | |
29beb80d | 540 | |
6516b62d | 541 | AddTrack(t,0); |
29beb80d | 542 | |
6516b62d | 543 | if (!fConnects) |
544 | { | |
545 | fConnects=new TObjArray(fNvmax); | |
546 | if (!fTrackCopy) fConnects->SetOwner(); | |
547 | } | |
29beb80d | 548 | fConnects->Add(t); |
549 | } | |
d88f97cc | 550 | } |
551 | /////////////////////////////////////////////////////////////////////////// | |
552 | void AliVertex::Info(TString f) | |
553 | { | |
554 | // Provide vertex information within the coordinate frame f | |
43bfa5be | 555 | cout << " *AliVertex::Info* Id : " << fUserId << " Invmass : " << GetInvmass() |
d88f97cc | 556 | << " Charge : " << GetCharge() << " Momentum : " << GetMomentum() |
f34f4acb | 557 | << " Ntracks : " << GetNtracks() << " Nvertices : " << fNvtx |
558 | << " Njets : " << fNjets << endl; | |
d88f97cc | 559 | cout << " "; |
560 | Ali4Vector::Info(f); | |
561 | cout << " Position"; | |
562 | AliPosition::Info(f); | |
563 | } | |
564 | /////////////////////////////////////////////////////////////////////////// | |
565 | void AliVertex::List(TString f) | |
566 | { | |
567 | // Provide primary track and sec. vertex information within the coordinate frame f | |
568 | ||
569 | Info(f); // Information of the current vertex | |
570 | ||
571 | // The tracks of this vertex | |
572 | AliTrack* t; | |
573 | for (Int_t it=1; it<=GetNtracks(); it++) | |
574 | { | |
575 | t=GetTrack(it); | |
576 | if (t) | |
577 | { | |
578 | cout << " ---Track no. " << it << endl; | |
579 | cout << " "; | |
580 | t->Info(f); | |
581 | } | |
582 | else | |
583 | { | |
584 | cout << " *AliVertex::List* Error : No track present." << endl; | |
585 | } | |
586 | } | |
587 | ||
588 | // The secondary vertices of this vertex | |
589 | AliVertex* v; | |
590 | for (Int_t iv=1; iv<=GetNvertices(); iv++) | |
591 | { | |
592 | v=GetVertex(iv); | |
593 | if (v) | |
594 | { | |
595 | cout << " ---Level 1 sec. vertex no. " << iv << endl; | |
596 | cout << " "; | |
597 | v->Info(f); | |
598 | } | |
599 | else | |
600 | { | |
601 | cout << " *AliVertex::List* Error : No sec. vertex present." << endl; | |
602 | } | |
603 | } | |
604 | } | |
605 | /////////////////////////////////////////////////////////////////////////// | |
606 | void AliVertex::ListAll(TString f) | |
607 | { | |
608 | // Provide complete (sec) vertex and (decay) track info within the coordinate frame f | |
609 | ||
610 | Info(f); // Information of the current vertex | |
611 | ||
612 | // The tracks of this vertex | |
613 | AliTrack* t; | |
614 | for (Int_t it=1; it<=GetNtracks(); it++) | |
615 | { | |
616 | t=GetTrack(it); | |
617 | if (t) | |
618 | { | |
619 | cout << " ---Track no. " << it << endl; | |
620 | cout << " "; | |
621 | t->ListAll(f); | |
622 | } | |
623 | else | |
624 | { | |
625 | cout << " *AliVertex::ListAll* Error : No track present." << endl; | |
626 | } | |
627 | } | |
628 | ||
629 | AliVertex* v=this; | |
630 | Dump(v,1,f); // Information of all sec. vertices | |
631 | } | |
632 | ////////////////////////////////////////////////////////////////////////// | |
633 | void AliVertex::Dump(AliVertex* v,Int_t n,TString f) | |
634 | { | |
635 | // Recursively provide the info of all secondary vertices of this vertex | |
636 | AliVertex* vs; | |
637 | for (Int_t iv=1; iv<=v->GetNvertices(); iv++) | |
638 | { | |
639 | vs=v->GetVertex(iv); | |
640 | if (vs) | |
641 | { | |
642 | cout << " ---Level " << n << " sec. vertex no. " << iv << endl; | |
643 | cout << " "; | |
644 | vs->Info(f); | |
645 | ||
646 | // The tracks of this vertex | |
647 | AliTrack* t; | |
648 | for (Int_t it=1; it<=vs->GetNtracks(); it++) | |
649 | { | |
650 | t=vs->GetTrack(it); | |
651 | if (t) | |
652 | { | |
653 | cout << " ---Track no. " << it << endl; | |
654 | cout << " "; | |
655 | t->ListAll(f); | |
656 | } | |
657 | else | |
658 | { | |
659 | cout << " *AliVertex::Dump* Error : No track present." << endl; | |
660 | } | |
661 | } | |
662 | ||
663 | // Go for next sec. vertex level of this sec. vertex recursively | |
664 | Dump(vs,n+1,f); | |
665 | } | |
666 | else | |
667 | { | |
668 | cout << " *AliVertex::Dump* Error : No sec. vertex present." << endl; | |
669 | } | |
670 | } | |
671 | } | |
672 | ////////////////////////////////////////////////////////////////////////// | |
673 | Int_t AliVertex::GetNvertices() | |
674 | { | |
675 | // Return the current number of (secondary) vertices | |
676 | return fNvtx; | |
677 | } | |
678 | /////////////////////////////////////////////////////////////////////////// | |
679 | AliVertex* AliVertex::GetVertex(Int_t i) | |
680 | { | |
681 | // Return the i-th (secondary) vertex of the current vertex | |
f34f4acb | 682 | if (!fVertices) |
683 | { | |
684 | cout << " *AliVertex*::GetVertex* No (secondary) vertices present." << endl; | |
685 | return 0; | |
686 | } | |
687 | else | |
688 | { | |
689 | if (i<=0 || i>fNvtx) | |
690 | { | |
691 | cout << " *AliVertex*::GetVertex* Invalid argument i : " << i | |
692 | << " Nvtx = " << fNvtx << endl; | |
693 | return 0; | |
694 | } | |
695 | else | |
696 | { | |
697 | return (AliVertex*)fVertices->At(i-1); | |
698 | } | |
699 | } | |
700 | } | |
701 | /////////////////////////////////////////////////////////////////////////// | |
43bfa5be | 702 | AliVertex* AliVertex::GetIdVertex(Int_t id) |
703 | { | |
704 | // Return the (sec.) vertex with user identifier "id" | |
705 | AliVertex* vx=0; | |
706 | AliVertex* v=0; | |
707 | if (!fVertices) | |
708 | { | |
709 | cout << " *AliVertex*::GetIdVertex* No (secondary) vertices present." << endl; | |
710 | return 0; | |
711 | } | |
712 | else | |
713 | { | |
714 | for (Int_t i=0; i<fNvtx; i++) | |
715 | { | |
716 | vx=(AliVertex*)fVertices->At(i); | |
717 | if (id == vx->GetId()) v=vx; | |
718 | } | |
719 | return v; | |
720 | } | |
721 | } | |
722 | /////////////////////////////////////////////////////////////////////////// | |
f34f4acb | 723 | void AliVertex::SetVertexCopy(Int_t j) |
724 | { | |
725 | // (De)activate the creation of private copies of the added vertices. | |
726 | // j=0 ==> No private copies are made; pointers of original vertices are stored. | |
727 | // j=1 ==> Private copies of the vertices are made and these pointers are stored. | |
728 | // | |
729 | // Note : Once the storage contains pointer(s) to AliVertex objects one cannot | |
730 | // change the VertexCopy mode anymore. | |
731 | // To change the VertexCopy mode for an existing AliVertex containing | |
732 | // vertices one first has to invoke Reset(). | |
733 | if (!fVertices) | |
734 | { | |
735 | if (j==0 || j==1) | |
736 | { | |
737 | fVertexCopy=j; | |
738 | } | |
739 | else | |
740 | { | |
741 | cout << "*AliVertex::SetVertexCopy* Invalid argument : " << j << endl; | |
742 | } | |
743 | } | |
744 | else | |
745 | { | |
746 | cout << "*AliVertex::SetVertexCopy* Storage already contained vertices." | |
747 | << " ==> VertexCopy mode not changed." << endl; | |
748 | } | |
749 | } | |
750 | /////////////////////////////////////////////////////////////////////////// | |
751 | Int_t AliVertex::GetVertexCopy() | |
752 | { | |
753 | // Provide value of the VertexCopy mode. | |
754 | // 0 ==> No private copies are made; pointers of original vertices are stored. | |
755 | // 1 ==> Private copies of the vertices are made and these pointers are stored. | |
756 | return fVertexCopy; | |
757 | } | |
758 | /////////////////////////////////////////////////////////////////////////// | |
759 | Int_t AliVertex::GetNjets() | |
760 | { | |
761 | // Return the current number of jets | |
762 | return fNjets; | |
763 | } | |
764 | /////////////////////////////////////////////////////////////////////////// | |
765 | AliJet* AliVertex::GetJet(Int_t i) | |
766 | { | |
767 | // Return the i-th jet of the current vertex | |
768 | if (!fJets) | |
769 | { | |
770 | cout << " *AliVertex*::GetJet* No jets present." << endl; | |
771 | return 0; | |
772 | } | |
773 | else | |
774 | { | |
775 | if (i<=0 || i>fNjets) | |
776 | { | |
777 | cout << " *AliVertex*::GetJet* Invalid argument i : " << i | |
778 | << " Njets = " << fNjets << endl; | |
779 | return 0; | |
780 | } | |
781 | else | |
782 | { | |
783 | return (AliJet*)fJets->At(i-1); | |
784 | } | |
785 | } | |
786 | } | |
787 | /////////////////////////////////////////////////////////////////////////// | |
43bfa5be | 788 | AliJet* AliVertex::GetIdJet(Int_t id) |
789 | { | |
790 | // Return the jet with user identifier "id" | |
791 | AliJet* jx=0; | |
792 | AliJet* j=0; | |
793 | if (!fJets) | |
794 | { | |
795 | cout << " *AliVertex*::GetIdJet* No jets present." << endl; | |
796 | return 0; | |
797 | } | |
798 | else | |
799 | { | |
800 | for (Int_t i=0; i<fNjets; i++) | |
801 | { | |
802 | jx=(AliJet*)fJets->At(i); | |
803 | if (id == jx->GetId()) j=jx; | |
804 | } | |
805 | return j; | |
806 | } | |
807 | } | |
808 | /////////////////////////////////////////////////////////////////////////// | |
f34f4acb | 809 | void AliVertex::SetJetCopy(Int_t j) |
810 | { | |
811 | // (De)activate the creation of private copies of the added jets. | |
812 | // j=0 ==> No private copies are made; pointers of original jets are stored. | |
813 | // j=1 ==> Private copies of the jets are made and these pointers are stored. | |
814 | // | |
815 | // Note : Once the storage contains pointer(s) to AliJet objects one cannot | |
816 | // change the JetCopy mode anymore. | |
817 | // To change the JetCopy mode for an existing AliVertex containing | |
818 | // jets one first has to invoke Reset(). | |
819 | if (!fJets) | |
820 | { | |
821 | if (j==0 || j==1) | |
822 | { | |
823 | fJetCopy=j; | |
824 | } | |
825 | else | |
826 | { | |
827 | cout << "*AliVertex::SetJetCopy* Invalid argument : " << j << endl; | |
828 | } | |
829 | } | |
830 | else | |
831 | { | |
832 | cout << "*AliVertex::SetJetCopy* Storage already contained jets." | |
833 | << " ==> JetCopy mode not changed." << endl; | |
834 | } | |
835 | } | |
836 | /////////////////////////////////////////////////////////////////////////// | |
837 | Int_t AliVertex::GetJetCopy() | |
838 | { | |
839 | // Provide value of the JetCopy mode. | |
840 | // 0 ==> No private copies are made; pointers of original jets are stored. | |
841 | // 1 ==> Private copies of the jets are made and these pointers are stored. | |
842 | return fJetCopy; | |
d88f97cc | 843 | } |
844 | /////////////////////////////////////////////////////////////////////////// | |
6516b62d | 845 | Int_t AliVertex::IsConnectTrack(AliTrack* t) |
846 | { | |
847 | // Indicate whether a track from the tracklist was created via the | |
848 | // connection of a (secondary) vertex or not. | |
849 | // In case the track was the result of (secondary) vertex addition the | |
850 | // return value is 1, otherwise the value 0 will be returned. | |
851 | Int_t connect=0; | |
852 | if (fConnects) | |
853 | { | |
854 | if (fConnects->FindObject(t)) connect=1; | |
855 | } | |
856 | return connect; | |
857 | } | |
858 | /////////////////////////////////////////////////////////////////////////// | |
859 | Int_t AliVertex::IsJetTrack(AliTrack* t) | |
860 | { | |
861 | // Indicate whether a track from the tracklist was created via the | |
862 | // addition of a jet or not. | |
863 | // In case the track was the result of jet addition the return value is 1, | |
864 | // otherwise the value 0 will be returned. | |
865 | Int_t jetflag=0; | |
866 | if (fJetTracks) | |
867 | { | |
868 | if (fJetTracks->FindObject(t)) jetflag=1; | |
869 | } | |
870 | return jetflag; | |
871 | } | |
872 | /////////////////////////////////////////////////////////////////////////// | |
a37bb40e | 873 | void AliVertex::Draw(Int_t secs,Int_t cons,Int_t jets) |
874 | { | |
875 | // 3-Dimensional visualisation of an AliVertex with its attributes. | |
876 | // The displayed tracklength is proportional to the momentum of the track. | |
877 | // | |
878 | // Color conventions : | |
879 | // ------------------- | |
880 | // positive track : red | |
881 | // neutral track : green | |
882 | // negative track : blue | |
883 | // jet-track : magenta (if explicit marking selected) | |
884 | // | |
885 | // secs = 1 --> Draw secondary vertices. | |
886 | // 0 --> Don't draw secondary vertices. | |
887 | // | |
888 | // cons = 1 --> Draw (auto generated) connecting tracks. | |
889 | // 0 --> Don't draw (auto generated) connecting tracks. | |
890 | // | |
891 | // jets = 1 --> Mark tracks belonging to jets. | |
892 | // 0 --> Don't mark jet-tracks. | |
893 | // | |
894 | // Notes : | |
895 | // ------- | |
896 | // Auto generated connecting tracks will be drawn as thin lines. | |
897 | // Tracks belonging to jets will be marked as somewhat thinner magenta lines. | |
898 | // This memberfunction is used recursively. | |
899 | // | |
900 | Double_t vec[3]={0,0,0}; | |
901 | AliTrack* tx=0; | |
902 | AliVertex* vx=0; | |
903 | AliPosition r; | |
904 | Ali3Vector p; | |
905 | Int_t charge; | |
906 | ||
907 | if (fLines) delete fLines; | |
908 | fLines=new TObjArray(); | |
909 | fLines->SetOwner(); | |
910 | ||
911 | Int_t ntk=GetNtracks(); | |
912 | for (Int_t jtk=1; jtk<=ntk; jtk++) | |
913 | { | |
914 | tx=GetTrack(jtk); | |
915 | ||
916 | if (!tx) continue; | |
917 | ||
918 | charge=tx->GetCharge(); | |
919 | ||
920 | TPolyLine3D* line=new TPolyLine3D(); | |
921 | fLines->Add(line); | |
922 | ||
923 | if (IsConnectTrack(tx)) | |
924 | { | |
925 | if (cons==1) | |
926 | { | |
927 | r=tx->GetBeginPoint(); | |
928 | r.GetPosition(vec,"car"); | |
929 | line->SetNextPoint(vec[0],vec[1],vec[2]); | |
930 | r=tx->GetEndPoint(); | |
931 | r.GetPosition(vec,"car"); | |
932 | line->SetNextPoint(vec[0],vec[1],vec[2]); | |
933 | line->SetLineWidth(1); | |
934 | } | |
935 | } | |
936 | else | |
937 | { | |
938 | r=tx->GetClosestPoint(); | |
939 | r.GetPosition(vec,"car"); | |
940 | line->SetNextPoint(vec[0],vec[1],vec[2]); | |
941 | p=tx->Get3Momentum(); | |
942 | p=p+r; | |
943 | p.GetVector(vec,"car"); | |
944 | line->SetNextPoint(vec[0],vec[1],vec[2]); | |
945 | line->SetLineWidth(3); | |
946 | } | |
947 | ||
948 | if (charge>0) line->SetLineColor(kRed); // Positive track | |
949 | if (!charge) line->SetLineColor(kGreen); // Neutral track | |
950 | if (charge<0) line->SetLineColor(kBlue); // Negative track | |
951 | ||
952 | // Mark tracks belonging to jets | |
953 | if (IsJetTrack(tx)) | |
954 | { | |
955 | if (jets==1) | |
956 | { | |
957 | line->SetLineWidth(2); | |
958 | line->SetLineColor(kMagenta); | |
959 | } | |
960 | } | |
961 | ||
962 | line->Draw(); | |
963 | } | |
964 | ||
965 | // Go for secondary vertices if selected | |
966 | if (secs==1) | |
967 | { | |
968 | Int_t nvtx=GetNvertices(); | |
969 | for (Int_t jvtx=1; jvtx<=nvtx; jvtx++) | |
970 | { | |
971 | vx=GetVertex(jvtx); | |
972 | if (vx) vx->Draw(secs,cons,jets); | |
973 | } | |
974 | } | |
975 | } | |
976 | /////////////////////////////////////////////////////////////////////////// |