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