Add method:
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveTrack.cxx
CommitLineData
0e33c639 1// $Id$
2// Author: Matevz Tadel 2009
3
4/**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
9
10#include "AliEveTrack.h"
11
50ac85c6 12#include "AliESDtrack.h"
13#include "AliAODTrack.h"
14
0e33c639 15#include <TROOT.h>
16
17//______________________________________________________________________________
18// Full description of AliEveTrack
19//
20
21ClassImp(AliEveTrack)
22
23//______________________________________________________________________________
24AliEveTrack::AliEveTrack() :
25 TEveTrack()
26{
27 // Constructor.
28}
29
30//______________________________________________________________________________
50ac85c6 31AliEveTrack::AliEveTrack(TParticle* t, Int_t label, TEveTrackPropagator* prop) :
32 TEveTrack(t, label, prop)
33{
34 // Constructor.
35}
36
37//______________________________________________________________________________
38AliEveTrack::AliEveTrack(TEveMCTrack* t, TEveTrackPropagator* prop) :
39 TEveTrack(t, prop)
40{
41 // Constructor.
42}
43
44//______________________________________________________________________________
45AliEveTrack::AliEveTrack(TEveRecTrack* t, TEveTrackPropagator* prop) :
46 TEveTrack(t, prop)
0e33c639 47{
48 // Constructor.
49}
50
51//______________________________________________________________________________
50ac85c6 52AliEveTrack::AliEveTrack(AliESDtrack* t, TEveTrackPropagator* prop) :
53 TEveTrack()
0e33c639 54{
55 // Constructor.
50ac85c6 56
57 Double_t buf[3];
58 t->GetXYZ(buf); fV.Set(buf);
59 t->GetPxPyPz(buf); fP.Set(buf);
60
61 Double_t ep = t->GetP(), mc = t->GetMass();
62 fBeta = ep/TMath::Sqrt(ep*ep + mc*mc);
63 // fPdg = 0; // ??? Use PID ?
64 fCharge= t->GetSign();
65
66 fLabel = t->GetLabel();
67 fIndex = t->GetID();
68 // fStatus = (Int_t) t->GetStatus(); // RRRR Uncomment for root-5.26.
69
70 SetPropagator(prop);
0e33c639 71}
72
73//______________________________________________________________________________
50ac85c6 74AliEveTrack::AliEveTrack(AliAODTrack* t, TEveTrackPropagator* prop) :
75 TEveTrack()
0e33c639 76{
77 // Constructor.
50ac85c6 78
79 Double_t buf[3];
80
81 t->GetXYZ(buf); fV.Set(buf);
82 t->PxPyPz(buf); fP.Set(buf);
83
84 // fBeta = 0; // Unknown, no mass function
85 // fPdg = 0; // ??? Use PID ?
86 fCharge= t->Charge();
87
88 fLabel = t->GetLabel();
89 fIndex = t->GetID();
90 // fStatus = (Int_t) t->GetStatus(); // RRRR Uncomment for root-5.26.
91
92 SetPropagator(prop);
0e33c639 93}
94
95//______________________________________________________________________________
96AliEveTrack::AliEveTrack(const AliEveTrack& t) :
97 TEveTrack(t)
98{
99 // Copy constructor.
100}
101
102//______________________________________________________________________________
103AliEveTrack::~AliEveTrack()
104{
105 // Destructor.
106}
107
3013fa45 108//______________________________________________________________________________
109void AliEveTrack::SetStartParams(const AliExternalTrackParam* tp)
110{
111 // Set the initial vertex / momentum of eve track from 'tp'.
112
113 Double_t buf[3];
114
115 tp->GetXYZ(buf); fV.Set(buf);
116 tp->PxPyPz(buf); fP.Set(buf);
117}
118
0e33c639 119/******************************************************************************/
120
121//______________________________________________________________________________
122void AliEveTrack::ImportHits()
123{
124 // Import hits with same label as the track.
125 // Uses macro "hits_from_label.C".
126
127 TEveUtil::LoadMacro("hits_from_label.C");
128 gROOT->ProcessLine(Form("hits_from_label(%d, (TEveElement*)%p);",
129 fLabel, this));
130}
131
132//______________________________________________________________________________
4267948f 133void AliEveTrack::ImportClustersFromLabel()
0e33c639 134{
135 // Import clusters with same label as the track.
136 // Uses macro "clusters_from_label.C".
137
138 TEveUtil::LoadMacro("clusters_from_label.C");
139 gROOT->ProcessLine(Form("clusters_from_label(%d, (TEveElement*)%p);",
140 fLabel, this));
141}
142
143//______________________________________________________________________________
144void AliEveTrack::ImportClustersFromIndex()
145{
146 // Import clusters marked with same reconstructed track index as the track.
147 // Uses macro "clusters_from_index.C".
148
149 static const TEveException kEH("AliEveTrack::ImportClustersFromIndex ");
150
151 if (fIndex == kMinInt)
1349dd2e 152 throw kEH + "index not set.";
0e33c639 153
154 TEveUtil::LoadMacro("clusters_from_index.C");
155 gROOT->ProcessLine(Form("clusters_from_index(%d, (TEveElement*)%p);",
156 fIndex, this));
157}
158
159/******************************************************************************/
160
161//______________________________________________________________________________
162void AliEveTrack::ImportKine()
163{
164 // Import kinematics of the track's label recursively.
165 // Uses macro "kine_tracks.C".
166
167 static const TEveException kEH("AliEveTrack::ImportKine ");
168
169 if (fLabel == kMinInt)
1349dd2e 170 throw kEH + "label not set.";
0e33c639 171
172 Int_t label;
173 if (fLabel < 0) {
174 Warning(kEH, "label negative, taking absolute value.");
175 label = -fLabel;
176 } else {
177 label = fLabel;
178 }
179
180 TEveUtil::LoadMacro("kine_tracks.C");
181 gROOT->ProcessLine(Form("kine_track(%d, kTRUE, kTRUE, kTRUE, kTRUE, (TEveElement*)%p);",
182 label, this));
183
184}
185
186//______________________________________________________________________________
187void AliEveTrack::ImportKineWithArgs(Bool_t importMother, Bool_t importDaugters,
188 Bool_t colorPdg, Bool_t recurse)
189{
190 // Import kinematics of the track's label. Arguments steer the
191 // import process:
192 // importMother import particle with track's label
193 // importDaugters import direct daughters of label
194 // colorPdg color kinematics by PDG code
195 // recurse recursive import of daughters' daughters
196 // Uses macro "kine_tracks.C".
197
198 static const TEveException kEH("AliEveTrack::ImportKineWithArgs ");
199
200 if (fLabel == kMinInt)
1349dd2e 201 throw kEH + "label not set.";
0e33c639 202
203 Int_t label;
204 if (fLabel < 0) {
205 Warning(kEH, "label negative, taking absolute value.");
206 label = -fLabel;
207 } else {
208 label = fLabel;
209 }
210
211 TEveUtil::LoadMacro("kine_tracks.C");
212 gROOT->ProcessLine(Form("kine_track(%d, %d, %d, %d, %d, (TEveElement*)%p);",
213 label, importMother, importDaugters, colorPdg, recurse, this));
214}
215
216//______________________________________________________________________________
217void AliEveTrack::PrintKineStack()
218{
219 // Print kinematics pertaining to track's label.
220 // Uses macro "print_kine_from_label.C".
221
222 static const TEveException kEH("AliEveTrack::PrintKineStack ");
223
224 if (fLabel == kMinInt)
1349dd2e 225 throw kEH + "label not set.";
0e33c639 226
227 Int_t label;
228 if (fLabel < 0) {
229 Warning(kEH, "label negative, taking absolute value.");
230 label = -fLabel;
231 } else {
232 label = fLabel;
233 }
234
235 TEveUtil::LoadMacro("print_kine_from_label.C");
236 gROOT->ProcessLine(Form("print_kine_from_label(%d);", label));
237}
3a20f984 238
239//______________________________________________________________________________
240void AliEveTrack::SecSelected(TEveTrack* track)
241{
242 // Emits "SecSelected(TEveTrack*)" signal.
243 // Called from TEveTrackGL on secondary-selection.
244
245 Emit("SecSelected(TEveTrack*)", (Long_t)track);
246 SecSelectedTrack((AliEveTrack*) track);
247}
248
249//______________________________________________________________________________
250void AliEveTrack::SecSelectedTrack(AliEveTrack* track)
251{
252 // Emits "SecSelectedTrack(AliEveTrack*)" signal.
253
254 Emit("SecSelectedTrack(AliEveTrack*)", (Long_t)track);
255}
bccc8088 256
257//______________________________________________________________________________
258AliESDtrack* AliEveTrack::GetESDTrack() const
259{
260 // Return source object dyn-casted to AliESDtrack.
261
262 return dynamic_cast<AliESDtrack*>(GetSourceObject());
263}
264
265//______________________________________________________________________________
266AliAODTrack* AliEveTrack::GetAODTrack() const
267{
268 // Return source object dyn-casted to AliAODTrack.
269
270 return dynamic_cast<AliAODTrack*>(GetSourceObject());
271}