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::RenderElement* cont = 0)
129 Warning("kine_track", "label not set.");
133 AliRunLoader* rl = Alieve::Event::AssertRunLoader();
134 rl->LoadKinematics();
135 AliStack* stack = rl->Stack();
136 TParticle* p = stack->Particle(label);
138 if (import_mother || (import_daughters && p->GetNDaughters()))
141 TrackList* tracklist = 0;
142 TrackRnrStyle* rs = 0;
146 cont = new TrackList(Form("Kinematics of %d", label, p->GetNDaughters()));
148 Reve::TrackRnrStyle* rnrStyle = cont->GetRnrStyle();
149 // !!! Watch the '-', apparently different sign convention then for ESD.
150 rnrStyle->SetMagField( - gAlice->Field()->SolenoidField() );
152 sprintf(tooltip,"Ndaughters=%d", p->GetNDaughters());
153 cont->SetTitle(tooltip);
154 cont->SelectByPt(0.2, 100);
155 rnrStyle->fColor = 8;
156 rnrStyle->fMaxOrbs = 8;
157 cont->SetEditPathMarks(kTRUE);
158 gReve->AddRenderElement(cont);
159 rs = cont->GetRnrStyle();
162 // check if argument is TrackList
163 Reve::Track* t = dynamic_cast<Reve::Track*>(cont);
166 rs = t->GetRnrStyle();
169 Reve::TrackList* l = dynamic_cast<Reve::TrackList*>(cont);
172 rs = l->GetRnrStyle();
175 Error("kine_tracks.C", "TrackRenderStyle not set.");
182 Track* track = new Reve::Track(p, label, rs);
184 sprintf(form,"%s [%d]", p->GetName(), label);
185 track->SetName(form);
186 gReve->AddRenderElement(cont, track);
190 if (import_daughters && p->GetNDaughters())
192 for (int d=p->GetFirstDaughter(); d>0 && d<=p->GetLastDaughter(); ++d)
194 TParticle* dp = stack->Particle(d);
195 Track* track = new Reve::Track(dp, d, rs);
197 sprintf(form,"%s [%d]", dp->GetName(), d);
198 track->SetName(form);
200 gReve->AddRenderElement(cont, track);