1 // Import tracks from kinematics-tree / particle-stack.
2 // Preliminary/minimal solution.
3 #include "TParticlePDG.h"
6 static Color_t DefCol = 30;
7 static Color_t ECol = 5;
8 static Color_t MuCol = 6;
9 static Color_t GamaCol = 7;
10 static Color_t MesCol1 = 3;
11 static Color_t MesCol2 = 38;
12 static Color_t BarCol = 10;
16 kine_tracks(Double_t min_pt=0.5, Double_t max_pt=100, Bool_t pdg_col= kFALSE)
18 AliRunLoader* rl = Alieve::Event::AssertRunLoader();
20 AliStack* stack = rl->Stack();
22 Error("kine_tracks.C", "can not get kinematics.");
26 Reve::TrackList* cont = new Reve::TrackList("Kine Tracks");
27 cont->SetMainColor(Color_t(6));
28 Reve::TrackRnrStyle* rnrStyle = cont->GetRnrStyle();
30 // !!! Watch the '-', apparently different sign convention then for ESD.
31 rnrStyle->SetMagField( - gAlice->Field()->SolenoidField() );
33 gReve->AddRenderElement(cont);
36 Int_t N = stack->GetNtrack();
37 for (Int_t i=0; i<N; ++i)
39 if(stack->IsPhysicalPrimary(i))
41 TParticle* p = stack->Particle(i);
42 Double_t pT = p->Pt();
43 if (pT<min_pt || pT>max_pt) continue;
46 Reve::Track* track = new Reve::Track(p, i, rnrStyle);
48 //PH The line below is replaced waiting for a fix in Root
49 //PH which permits to use variable siza arguments in CINT
50 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
51 //PH track->SetName(Form("%s [%d]", p->GetName(), i));
53 sprintf(form,"%s [%d]", p->GetName(), i);
55 TParticlePDG* pdgp = p->GetPDG();
56 track->SetMainColor(get_pdg_color(pdgp->PdgCode()));
57 gReve->AddRenderElement(cont, track);
64 kt.SetPathMarks(cont,stack, rl->TreeTR());
65 cont->SetEditPathMarks(kTRUE);
68 //PH const Text_t* tooltip = Form("pT ~ (%.2lf, %.2lf), N=%d", min_pt, max_pt, count);
70 sprintf(tooltip,"pT ~ (%.2lf, %.2lf), N=%d", min_pt, max_pt, count);
71 cont->SetTitle(tooltip); // Not broadcasted automatically ...
82 Color_t get_pdg_color(Int_t pdg){
83 Int_t pdga = TMath::Abs(pdg);
84 Color_t col = Reve::DefCol;
86 // elementary particles
94 col = GammaCol; break;
97 else if (pdga < 100000){
99 Int_t i0 = i%10; i /= 10;
100 Int_t i1 = i%10; i /= 10;
101 Int_t i2 = i%10; i /= 10;
102 Int_t i3 = i%10; i /= 10;
104 //printf("pdg(%d) quark indices (%d,%d,%d,%d,%d) \n",pdg, i4,i3,i2, i1, i0);
106 if ((i3 == 0) && ( i4 < 2)){
107 col = MesCol1; // quarks: i1,i2 (spin = i0)
108 if(i1 == 3 || i2 == 3)
111 else if ( i2 >= i1 && i3 >= i2 ) {
112 col = BarCol; // quarks: i1,i2, i3 (spin = i0))
119 // Create mother and daughters tracks with given label.
122 kine_track(Int_t label,
123 Bool_t import_mother = kTRUE,
124 Bool_t import_daughters = kTRUE,
125 Reve::TrackList* cont = 0)
128 Warning("kine_track", "label not set.");
132 AliRunLoader* rl = Alieve::Event::AssertRunLoader();
133 rl->LoadKinematics();
134 AliStack* stack = rl->Stack();
135 TParticle* p = stack->Particle(label);
137 if (import_mother || (import_daughters && p->GetNDaughters()))
141 cont = new TrackList(Form("Kinematics of %d", label, p->GetNDaughters()));
143 Reve::TrackRnrStyle* rnrStyle = cont->GetRnrStyle();
144 // !!! Watch the '-', apparently different sign convention then for ESD.
145 rnrStyle->SetMagField( - gAlice->Field()->SolenoidField() );
147 sprintf(tooltip,"Ndaughters=%d", p->GetNDaughters());
148 cont->SetTitle(tooltip);
149 cont->SelectByPt(0.2, 100);
150 rnrStyle->fColor = 8;
151 rnrStyle->fMaxOrbs = 8;
152 cont->SetEditPathMarks(kTRUE);
153 gReve->AddRenderElement(cont);
158 Track* track = new Reve::Track(p, label, cont->GetRnrStyle());
160 sprintf(form,"%s [%d]", p->GetName(), label);
161 track->SetName(form);
162 gReve->AddRenderElement(cont, track);
165 if (import_daughters && p->GetNDaughters())
167 for (int d=p->GetFirstDaughter(); d>0 && d<=p->GetLastDaughter(); ++d)
169 TParticle* dp = stack->Particle(d);
170 Track* track = new Reve::Track(dp, d, cont->GetRnrStyle());
172 sprintf(form,"%s [%d]", dp->GetName(), d);
173 track->SetName(form);
174 gReve->AddRenderElement(cont, track);
182 if(cont->GetEditPathMarks())
184 Alieve::KineTools kt;
186 kt.SetPathMarks(cont, stack, rl->TreeTR());