2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
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 **************************************************************************/
10 // Import tracks from kinematics-tree / particle-stack.
11 // Preliminary/minimal solution.
13 #include "TParticlePDG.h"
16 kine_tracks(Double_t min_pt = 0, Double_t min_p = 0,
17 Bool_t pdg_col = kTRUE, Bool_t recurse = kTRUE,
18 Bool_t use_track_refs = kTRUE)
20 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
22 AliStack* stack = rl->Stack();
24 Error("kine_tracks.C", "can not get kinematics.");
28 gEve->DisableRedraw();
30 TEveTrackList* cont = new TEveTrackList("Kine Tracks");
31 cont->SetMainColor(3);
32 TEveTrackPropagator* rnrStyle = cont->GetPropagator();
33 // !!! Watch the '-', apparently different sign convention then for ESD.
34 rnrStyle->SetMagField( -0.1*gAlice->Field()->SolenoidField() );
36 gEve->AddElement(cont);
38 Int_t N = stack->GetNtrack();
39 for (Int_t i=0; i<N; ++i)
41 if (stack->IsPhysicalPrimary(i))
43 TParticle* p = stack->Particle(i);
44 if (p->Pt() < min_pt && p->P() < min_p) continue;
47 TEveTrack* track = new TEveTrack(p, i, rnrStyle);
49 //PH The line below is replaced waiting for a fix in Root
50 //PH which permits to use variable siza arguments in CINT
51 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
52 //PH track->SetName(Form("%s [%d]", p->GetName(), i));
54 sprintf(form,"%s [%d]", p->GetName(), i);
57 Int_t ml = p->GetMother(0);
60 track->SetTitle(Form("%s\nMother label=%d\nMother Pdg=%d",
61 track->GetElementTitle(),
62 ml, stack->Particle(ml)->GetPdgCode()));
64 set_track_color(track, pdg_col);
66 gEve->AddElement(track, cont);
69 kine_daughters(track, stack, min_pt, min_p, pdg_col, recurse);
75 kt.SetDaughterPathMarks(cont, stack, recurse);
76 if (use_track_refs && rl->LoadTrackRefs() == 0)
78 kt.SetTrackReferences(cont, rl->TreeTR(), recurse);
79 rnrStyle->SetEditPathMarks(kTRUE);
81 kt.SortPathMarks(cont, recurse);
83 //PH const Text_t* tooltip = Form("min pT=%.2lf, min P=%.2lf), N=%d", min_pt, min_p, count);
85 sprintf(tooltip,"min pT=%.2lf, min P=%.2lf), N=%d", min_pt, min_p, count);
86 cont->SetTitle(tooltip); // Not broadcasted automatically ...
88 cont->MakeTracks(recurse);
95 void kine_daughters(TEveTrack* parent, AliStack* stack,
96 Double_t min_pt, Double_t min_p,
97 Bool_t pdg_col, Bool_t recurse)
99 TParticle *p = stack->Particle(parent->GetLabel());
100 if (p->GetNDaughters() > 0)
102 TEveTrackPropagator* rs = parent->GetPropagator();
103 for (int d=p->GetFirstDaughter(); d>0 && d<=p->GetLastDaughter(); ++d)
105 TParticle* dp = stack->Particle(d);
106 if (dp->Pt() < min_pt && dp->P() < min_p) continue;
108 TEveTrack* dtrack = new TEveTrack(dp, d, rs);
110 sprintf(form,"%s [%d]", dp->GetName(), d);
111 dtrack->SetName(form);
112 dtrack->SetStdTitle();
113 set_track_color(dtrack, pdg_col);
115 gEve->AddElement(dtrack, parent);
118 kine_daughters(dtrack, stack, min_pt, min_p, pdg_col, recurse);
123 Color_t set_track_color(TEveTrack* t, Bool_t pdg_col)
126 t->SetMainColor(get_pdg_color(t->GetPdg()));
131 Color_t get_pdg_color(Int_t pdg)
134 static const Color_t DefCol = 30;
135 static const Color_t ECol = 5;
136 static const Color_t MuCol = 6;
137 static const Color_t GammaCol = 7;
138 static const Color_t MesCol1 = 3;
139 static const Color_t MesCol2 = 38;
140 static const Color_t BarCol = 10;
142 Int_t pdga = TMath::Abs(pdg);
143 Color_t col = DefCol;
145 // elementary particles
153 col = GammaCol; break;
156 // mesons and barions
157 else if (pdga < 100000) {
159 Int_t i0 = i%10; i /= 10;
160 Int_t i1 = i%10; i /= 10;
161 Int_t i2 = i%10; i /= 10;
162 Int_t i3 = i%10; i /= 10;
164 //printf("pdg(%d) quark indices (%d,%d,%d,%d,%d) \n",pdg, i4,i3,i2, i1, i0);
166 if ((i3 == 0) && ( i4 < 2)){
167 col = MesCol1; // quarks: i1,i2 (spin = i0)
168 if(i1 == 3 || i2 == 3)
171 else if ( i2 >= i1 && i3 >= i2 ) {
172 col = BarCol; // quarks: i1,i2, i3 (spin = i0))
179 /******************************************************************************/
182 kine_track(Int_t label,
183 Bool_t import_mother = kTRUE, Bool_t import_daughters = kTRUE,
184 Bool_t pdg_col = kTRUE, Bool_t recurse = kTRUE,
185 TEveElement* cont = 0)
188 // Create mother and daughters tracks with given label.
189 // mother -> particle with label
190 // daughters -> daughters of label
193 Warning("kine_track", "label not set.");
197 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
198 rl->LoadKinematics();
199 AliStack* stack = rl->Stack();
200 if (label >= stack->GetNtrack())
202 Warning("kine_track", "label out of range.");
206 TParticle* p = stack->Particle(label);
208 if (import_mother || (import_daughters && p->GetNDaughters()))
210 TEveTrack* toptrack = 0;
211 TEveTrackList* tracklist = 0;
212 TEveTrackPropagator* rs = 0;
216 TEveTrackList* tlist = new TEveTrackList
217 (Form("Kinematics of %d", label, p->GetNDaughters()));
220 TEveTrackPropagator* rnrStyle = tlist->GetPropagator();
221 // !!! Watch the '-', apparently different sign convention then for ESD.
222 rnrStyle->SetMagField( -0.1*gAlice->Field()->SolenoidField() );
224 sprintf(tooltip,"Ndaughters=%d", p->GetNDaughters());
225 tlist->SetTitle(tooltip);
226 rnrStyle->fMaxOrbs = 2;
227 rnrStyle->SetEditPathMarks(kTRUE);
229 gEve->AddElement(cont);
230 rs = tlist->GetPropagator();
234 // check if container is TEveTrackList or TEveTrack (has rnr-style)
235 TEveTrack* t = dynamic_cast<TEveTrack*>(cont);
237 rs = t->GetPropagator();
239 TEveTrackList* l = dynamic_cast<TEveTrackList*>(cont);
241 rs = l->GetPropagator();
243 Error("kine_tracks.C", "TrackRenderStyle not set.");
249 TEveTrack* track = new TEveTrack(p, label, rs);
251 sprintf(form,"%s [%d]", p->GetName(), label);
252 track->SetName(form);
253 track->SetStdTitle();
254 set_track_color(track, pdg_col);
257 gEve->AddElement(track, cont);
261 if (import_daughters && p->GetNDaughters())
263 for (int d=p->GetFirstDaughter(); d>0 && d<=p->GetLastDaughter(); ++d)
265 TParticle* dp = stack->Particle(d);
266 TEveTrack* track = new TEveTrack(dp, d, rs);
268 sprintf(form,"%s [%d]", dp->GetName(), d);
269 track->SetName(form);
270 track->SetStdTitle();
271 set_track_color(track, pdg_col);
274 gEve->AddElement(track, cont);
277 kine_daughters(track, stack, 0, 0, pdg_col, recurse);