]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/alice-macros/kine_tracks.C
Added function SortPathMarks().
[u/mrichter/AliRoot.git] / EVE / alice-macros / kine_tracks.C
CommitLineData
1b337638 1// Import tracks from kinematics-tree / particle-stack.
2// Preliminary/minimal solution.
a7867742 3#include "TParticlePDG.h"
1b337638 4
a7867742 5// PDG color indices
539d6798 6static Color_t DefCol = 30;
7static Color_t ECol = 5;
8static Color_t MuCol = 6;
9static Color_t GammaCol = 7;
10static Color_t MesCol1 = 3;
11static Color_t MesCol2 = 38;
12static Color_t BarCol = 10;
a7867742 13
14
b65b3044 15Reve::TrackList*
ef9d2241 16kine_tracks(Double_t min_pt = 0.1, Double_t min_p = 0.2,
17 Bool_t pdg_col = kTRUE, Bool_t recurse = kTRUE)
1b337638 18{
19 AliRunLoader* rl = Alieve::Event::AssertRunLoader();
20 rl->LoadKinematics();
21 AliStack* stack = rl->Stack();
22 if (!stack) {
23 Error("kine_tracks.C", "can not get kinematics.");
24 return 0;
25 }
26
af4b8b4b 27 gReve->DisableRedraw();
28
1b337638 29 Reve::TrackList* cont = new Reve::TrackList("Kine Tracks");
30 cont->SetMainColor(Color_t(6));
31 Reve::TrackRnrStyle* rnrStyle = cont->GetRnrStyle();
32 rnrStyle->fColor = 8;
33 // !!! Watch the '-', apparently different sign convention then for ESD.
32aee3cf 34 rnrStyle->SetMagField( - gAlice->Field()->SolenoidField() );
1b337638 35
36 gReve->AddRenderElement(cont);
1b337638 37 Int_t count = 0;
43d68fc4 38 Int_t N = stack->GetNtrack();
39 for (Int_t i=0; i<N; ++i)
40 {
41 if(stack->IsPhysicalPrimary(i))
42 {
43 TParticle* p = stack->Particle(i);
ef9d2241 44 if (p->Pt() < min_pt && p->P() < min_p) continue;
43d68fc4 45
46 ++count;
47 Reve::Track* track = new Reve::Track(p, i, rnrStyle);
48
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));
53 char form[1000];
54 sprintf(form,"%s [%d]", p->GetName(), i);
55 track->SetName(form);
ef9d2241 56 if (pdg_col && p->GetPDG())
57 track->SetMainColor(get_pdg_color(p->GetPDG()->PdgCode()));
43d68fc4 58 gReve->AddRenderElement(cont, track);
ef9d2241 59
60 if (recurse)
61 kine_daughters(track, stack, min_pt, min_p, pdg_col, recurse);
43d68fc4 62 }
1b337638 63 }
ef9d2241 64
43d68fc4 65 // set path marks
66 Alieve::KineTools kt;
ef9d2241 67 kt.SetDaughterPathMarks(cont, stack, recurse);
43d68fc4 68 rl->LoadTrackRefs();
ef9d2241 69 kt.SetTrackReferences(cont, rl->TreeTR(), recurse);
43d68fc4 70 cont->SetEditPathMarks(kTRUE);
71
ef9d2241 72 //PH const Text_t* tooltip = Form("min pT=%.2lf, min P=%.2lf), N=%d", min_pt, min_p, count);
7be1e8cd 73 char tooltip[1000];
ef9d2241 74 sprintf(tooltip,"min pT=%.2lf, min P=%.2lf), N=%d", min_pt, min_p, count);
1b337638 75 cont->SetTitle(tooltip); // Not broadcasted automatically ...
76 cont->UpdateItems();
77
ef9d2241 78 cont->MakeTracks(recurse);
1b337638 79 cont->MakeMarkers();
af4b8b4b 80
81 gReve->EnableRedraw();
1b337638 82 gReve->Redraw3D();
83
84 return cont;
85}
a7867742 86
ef9d2241 87void kine_daughters(Reve::Track* parent, AliStack* stack,
88 Double_t min_pt, Double_t min_p,
89 Bool_t pdg_col, Bool_t recurse)
90{
91 TParticle *p = stack->Particle(parent->GetLabel());
92 if (p->GetNDaughters() > 0)
93 {
94 Reve::TrackRnrStyle* rs = parent->GetRnrStyle();
95 for (int d=p->GetFirstDaughter(); d>0 && d<=p->GetLastDaughter(); ++d)
96 {
97 TParticle* dp = stack->Particle(d);
98 if (dp->Pt() < min_pt && dp->P() < min_p) continue;
99
100 Track* dtrack = new Reve::Track(dp, d, rs);
101 char form[1000];
102 sprintf(form,"%s [%d]", dp->GetName(), d);
103 dtrack->SetName(form);
104 if (pdg_col && dp->GetPDG())
105 dtrack->SetMainColor(get_pdg_color(dp->GetPDG()->PdgCode()));
106 gReve->AddRenderElement(parent, dtrack);
107
108 if (recurse)
109 kine_daughters(dtrack, stack, min_pt, min_p, pdg_col, recurse);
110 }
111 }
112}
a7867742 113
539d6798 114Color_t get_pdg_color(Int_t pdg)
115{
a7867742 116 Int_t pdga = TMath::Abs(pdg);
117 Color_t col = Reve::DefCol;
118
119 // elementary particles
120 if (pdga < 100) {
121 switch (pdga) {
122 case 11:
123 col = ECol; break;
124 case 12:
125 col = MuCol; break;
126 case 22:
127 col = GammaCol; break;
128 }
129 }
130 else if (pdga < 100000){
131 Int_t i = pdga;
132 Int_t i0 = i%10; i /= 10;
133 Int_t i1 = i%10; i /= 10;
134 Int_t i2 = i%10; i /= 10;
135 Int_t i3 = i%10; i /= 10;
136 Int_t i4 = i%10;
137 //printf("pdg(%d) quark indices (%d,%d,%d,%d,%d) \n",pdg, i4,i3,i2, i1, i0);
138 // meson
139 if ((i3 == 0) && ( i4 < 2)){
140 col = MesCol1; // quarks: i1,i2 (spin = i0)
141 if(i1 == 3 || i2 == 3)
142 col = MesCol2;
143 } // barion
144 else if ( i2 >= i1 && i3 >= i2 ) {
145 col = BarCol; // quarks: i1,i2, i3 (spin = i0))
146 }
147 }
148 return col;
149}
c7b57c0b 150
151
152// Create mother and daughters tracks with given label.
153
2caed564 154Reve::RenderElement*
b65b3044 155kine_track(Int_t label,
156 Bool_t import_mother = kTRUE,
2caed564 157 Bool_t import_daughters = kTRUE,
539d6798 158 Reve::RenderElement* cont = 0)
2caed564 159
c7b57c0b 160{
c7b57c0b 161 if (label < 0) {
162 Warning("kine_track", "label not set.");
163 return 0;
164 }
165
166 AliRunLoader* rl = Alieve::Event::AssertRunLoader();
167 rl->LoadKinematics();
168 AliStack* stack = rl->Stack();
169 TParticle* p = stack->Particle(label);
170
b65b3044 171 if (import_mother || (import_daughters && p->GetNDaughters()))
c7b57c0b 172 {
2caed564 173 Track* toptrack = 0;
174 TrackList* tracklist = 0;
175 TrackRnrStyle* rs = 0;
176
b65b3044 177 if (cont == 0)
178 {
ef9d2241 179 Reve::TrackList* tlist = new Reve::TrackList
180 (Form("Kinematics of %d", label, p->GetNDaughters()));
181 cont = tlist;
c7b57c0b 182
ef9d2241 183 Reve::TrackRnrStyle* rnrStyle = tlist->GetRnrStyle();
c7b57c0b 184 // !!! Watch the '-', apparently different sign convention then for ESD.
185 rnrStyle->SetMagField( - gAlice->Field()->SolenoidField() );
186 char tooltip[1000];
b65b3044 187 sprintf(tooltip,"Ndaughters=%d", p->GetNDaughters());
ef9d2241 188 tlist->SetTitle(tooltip);
189 tlist->SelectByPt(0.2, 100);
2caed564 190 rnrStyle->fColor = 8;
191 rnrStyle->fMaxOrbs = 8;
ef9d2241 192 tlist->SetEditPathMarks(kTRUE);
c7b57c0b 193 gReve->AddRenderElement(cont);
ef9d2241 194 rs = tlist->GetRnrStyle();
2caed564 195 }
ef9d2241 196 else
197 {
2caed564 198 // check if argument is TrackList
199 Reve::Track* t = dynamic_cast<Reve::Track*>(cont);
200 if(t)
201 {
202 rs = t->GetRnrStyle();
203 }
ef9d2241 204 else
205 {
2caed564 206 Reve::TrackList* l = dynamic_cast<Reve::TrackList*>(cont);
207 if(l)
208 {
209 rs = l->GetRnrStyle();
210 }
ef9d2241 211 else
212 {
2caed564 213 Error("kine_tracks.C", "TrackRenderStyle not set.");
214 }
215 }
c7b57c0b 216 }
2caed564 217
b65b3044 218 if (import_mother)
219 {
2caed564 220 Track* track = new Reve::Track(p, label, rs);
c7b57c0b 221 char form[1000];
222 sprintf(form,"%s [%d]", p->GetName(), label);
223 track->SetName(form);
224 gReve->AddRenderElement(cont, track);
2caed564 225
c7b57c0b 226 }
227
b65b3044 228 if (import_daughters && p->GetNDaughters())
c7b57c0b 229 {
230 for (int d=p->GetFirstDaughter(); d>0 && d<=p->GetLastDaughter(); ++d)
231 {
232 TParticle* dp = stack->Particle(d);
2caed564 233 Track* track = new Reve::Track(dp, d, rs);
c7b57c0b 234 char form[1000];
235 sprintf(form,"%s [%d]", dp->GetName(), d);
236 track->SetName(form);
2caed564 237 track->MakeTrack();
c7b57c0b 238 gReve->AddRenderElement(cont, track);
239 }
240 }
241 }
242
2caed564 243 cont->UpdateItems();
c7b57c0b 244 gReve->Redraw3D();
245 return cont;
246}
2caed564 247