In class Track: renamed ImportDaughters() to ImportKine(), added ImportKineWithArgs...
[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
6static Color_t DefCol = 30;
7static Color_t ECol = 5;
8static Color_t MuCol = 6;
9static Color_t GamaCol = 7;
10static Color_t MesCol1 = 3;
11static Color_t MesCol2 = 38;
12static Color_t BarCol = 10;
13
14
15Reve::TrackList* kine_tracks(Double_t min_pt=0.5, Double_t max_pt=100, Bool_t pdg_col= kFALSE)
1b337638 16{
17 AliRunLoader* rl = Alieve::Event::AssertRunLoader();
18 rl->LoadKinematics();
19 AliStack* stack = rl->Stack();
20 if (!stack) {
21 Error("kine_tracks.C", "can not get kinematics.");
22 return 0;
23 }
24
25 Reve::TrackList* cont = new Reve::TrackList("Kine Tracks");
26 cont->SetMainColor(Color_t(6));
27 Reve::TrackRnrStyle* rnrStyle = cont->GetRnrStyle();
28 rnrStyle->fColor = 8;
29 // !!! Watch the '-', apparently different sign convention then for ESD.
32aee3cf 30 rnrStyle->SetMagField( - gAlice->Field()->SolenoidField() );
1b337638 31
32 gReve->AddRenderElement(cont);
33
34 Int_t count = 0;
43d68fc4 35 Int_t N = stack->GetNtrack();
36 for (Int_t i=0; i<N; ++i)
37 {
38 if(stack->IsPhysicalPrimary(i))
39 {
40 TParticle* p = stack->Particle(i);
41 Double_t pT = p->Pt();
42 if (pT<min_pt || pT>max_pt) continue;
43
44 ++count;
45 Reve::Track* track = new Reve::Track(p, i, rnrStyle);
46
47 //PH The line below is replaced waiting for a fix in Root
48 //PH which permits to use variable siza arguments in CINT
49 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
50 //PH track->SetName(Form("%s [%d]", p->GetName(), i));
51 char form[1000];
52 sprintf(form,"%s [%d]", p->GetName(), i);
53 track->SetName(form);
a7867742 54 TParticlePDG* pdgp = p->GetPDG();
55 track->SetMainColor(get_pdg_color(pdgp->PdgCode()));
43d68fc4 56 gReve->AddRenderElement(cont, track);
57 }
1b337638 58 }
59
43d68fc4 60 // set path marks
61 Alieve::KineTools kt;
62 rl->LoadTrackRefs();
63 kt.SetPathMarks(cont,stack, rl->TreeTR());
64 cont->SetEditPathMarks(kTRUE);
65
66
7be1e8cd 67 //PH const Text_t* tooltip = Form("pT ~ (%.2lf, %.2lf), N=%d", min_pt, max_pt, count);
68 char tooltip[1000];
69 sprintf(tooltip,"pT ~ (%.2lf, %.2lf), N=%d", min_pt, max_pt, count);
1b337638 70 cont->SetTitle(tooltip); // Not broadcasted automatically ...
71 cont->UpdateItems();
72
73 cont->MakeTracks();
74 cont->MakeMarkers();
75 gReve->Redraw3D();
76
77 return cont;
78}
a7867742 79
80
81Color_t get_pdg_color(Int_t pdg){
82 Int_t pdga = TMath::Abs(pdg);
83 Color_t col = Reve::DefCol;
84
85 // elementary particles
86 if (pdga < 100) {
87 switch (pdga) {
88 case 11:
89 col = ECol; break;
90 case 12:
91 col = MuCol; break;
92 case 22:
93 col = GammaCol; break;
94 }
95 }
96 else if (pdga < 100000){
97 Int_t i = pdga;
98 Int_t i0 = i%10; i /= 10;
99 Int_t i1 = i%10; i /= 10;
100 Int_t i2 = i%10; i /= 10;
101 Int_t i3 = i%10; i /= 10;
102 Int_t i4 = i%10;
103 //printf("pdg(%d) quark indices (%d,%d,%d,%d,%d) \n",pdg, i4,i3,i2, i1, i0);
104 // meson
105 if ((i3 == 0) && ( i4 < 2)){
106 col = MesCol1; // quarks: i1,i2 (spin = i0)
107 if(i1 == 3 || i2 == 3)
108 col = MesCol2;
109 } // barion
110 else if ( i2 >= i1 && i3 >= i2 ) {
111 col = BarCol; // quarks: i1,i2, i3 (spin = i0))
112 }
113 }
114 return col;
115}
c7b57c0b 116
117
118// Create mother and daughters tracks with given label.
119
120Reve::TrackList*
121kine_track(Int_t label, Bool_t create_mother = kTRUE, Reve::TrackList* cont = 0)
122{
123 gSystem->IgnoreSignal(kSigSegmentationViolation, true);
124 if (label < 0) {
125 Warning("kine_track", "label not set.");
126 return 0;
127 }
128
129 AliRunLoader* rl = Alieve::Event::AssertRunLoader();
130 rl->LoadKinematics();
131 AliStack* stack = rl->Stack();
132 TParticle* p = stack->Particle(label);
133
134 if (create_mother | p->GetNDaughters())
135 {
136 if(cont == 0) {
137 cont =
138 new TrackList(Form("%d kine_tracks %d", p->GetNDaughters(), label));
139
140 Reve::TrackRnrStyle* rnrStyle = cont->GetRnrStyle();
141 // !!! Watch the '-', apparently different sign convention then for ESD.
142 rnrStyle->SetMagField( - gAlice->Field()->SolenoidField() );
143 char tooltip[1000];
144 sprintf(tooltip,"%d, mother %d", p->GetNDaughters(), label);
145 cont->SetTitle(tooltip);
146 cont->SelectByPt(0.2, 100);
147 rnrStyle->fColor = 8;
148 rnrStyle->fMaxOrbs = 8;
149 cont->SetEditPathMarks(kTRUE);
150 gReve->AddRenderElement(cont);
151 }
152
153 if(create_mother){
154 Track* track = new Reve::Track(p, label, cont->GetRnrStyle());
155 char form[1000];
156 sprintf(form,"%s [%d]", p->GetName(), label);
157 track->SetName(form);
158 gReve->AddRenderElement(cont, track);
159 }
160
161 if (p->GetNDaughters())
162 {
163 for (int d=p->GetFirstDaughter(); d>0 && d<=p->GetLastDaughter(); ++d)
164 {
165 TParticle* dp = stack->Particle(d);
166 Track* track = new Reve::Track(dp, d, cont->GetRnrStyle());
167 char form[1000];
168 sprintf(form,"%s [%d]", dp->GetName(), d);
169 track->SetName(form);
170 gReve->AddRenderElement(cont, track);
171 }
172 }
173 }
174
175 // set path marks
176 if(cont->GetEditPathMarks()) {
177 Alieve::KineTools kt;
178 rl->LoadTrackRefs();
179 kt.SetPathMarks(cont,stack, rl->TreeTR());
180 }
181
182 cont->UpdateItems(); // update list tree
183 cont->MakeTracks();
184 cont->MakeMarkers();
185
186 gReve->Redraw3D();
187 return cont;
188}