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 GammaCol = 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 gReve->DisableRedraw();
28 Reve::TrackList* cont = new Reve::TrackList("Kine Tracks");
29 cont->SetMainColor(Color_t(6));
30 Reve::TrackRnrStyle* rnrStyle = cont->GetRnrStyle();
32 // !!! Watch the '-', apparently different sign convention then for ESD.
33 rnrStyle->SetMagField( - gAlice->Field()->SolenoidField() );
35 gReve->AddRenderElement(cont);
37 Int_t N = stack->GetNtrack();
38 for (Int_t i=0; i<N; ++i)
40 if(stack->IsPhysicalPrimary(i))
42 TParticle* p = stack->Particle(i);
43 Double_t pT = p->Pt();
44 if (pT<min_pt || pT>max_pt) continue;
47 Reve::Track* track = new Reve::Track(p, i, rnrStyle);
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));
54 sprintf(form,"%s [%d]", p->GetName(), i);
56 TParticlePDG* pdgp = p->GetPDG();
57 track->SetMainColor(get_pdg_color(pdgp->PdgCode()));
58 gReve->AddRenderElement(cont, track);
63 kt.SetDaughterPathMarks(cont, stack);
65 kt.SetTrackReferences(cont, rl->TreeTR());
66 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 ...
77 gReve->EnableRedraw();
84 Color_t get_pdg_color(Int_t pdg)
86 Int_t pdga = TMath::Abs(pdg);
87 Color_t col = Reve::DefCol;
89 // elementary particles
97 col = GammaCol; break;
100 else if (pdga < 100000){
102 Int_t i0 = i%10; i /= 10;
103 Int_t i1 = i%10; i /= 10;
104 Int_t i2 = i%10; i /= 10;
105 Int_t i3 = i%10; i /= 10;
107 //printf("pdg(%d) quark indices (%d,%d,%d,%d,%d) \n",pdg, i4,i3,i2, i1, i0);
109 if ((i3 == 0) && ( i4 < 2)){
110 col = MesCol1; // quarks: i1,i2 (spin = i0)
111 if(i1 == 3 || i2 == 3)
114 else if ( i2 >= i1 && i3 >= i2 ) {
115 col = BarCol; // quarks: i1,i2, i3 (spin = i0))
122 // Create mother and daughters tracks with given label.
125 kine_track(Int_t label,
126 Bool_t import_mother = kTRUE,
127 Bool_t import_daughters = kTRUE,
128 Reve::RenderElement* cont = 0)
132 Warning("kine_track", "label not set.");
136 AliRunLoader* rl = Alieve::Event::AssertRunLoader();
137 rl->LoadKinematics();
138 AliStack* stack = rl->Stack();
139 TParticle* p = stack->Particle(label);
141 if (import_mother || (import_daughters && p->GetNDaughters()))
144 TrackList* tracklist = 0;
145 TrackRnrStyle* rs = 0;
149 cont = new TrackList(Form("Kinematics of %d", label, p->GetNDaughters()));
151 Reve::TrackRnrStyle* rnrStyle = cont->GetRnrStyle();
152 // !!! Watch the '-', apparently different sign convention then for ESD.
153 rnrStyle->SetMagField( - gAlice->Field()->SolenoidField() );
155 sprintf(tooltip,"Ndaughters=%d", p->GetNDaughters());
156 cont->SetTitle(tooltip);
157 cont->SelectByPt(0.2, 100);
158 rnrStyle->fColor = 8;
159 rnrStyle->fMaxOrbs = 8;
160 cont->SetEditPathMarks(kTRUE);
161 gReve->AddRenderElement(cont);
162 rs = cont->GetRnrStyle();
165 // check if argument is TrackList
166 Reve::Track* t = dynamic_cast<Reve::Track*>(cont);
169 rs = t->GetRnrStyle();
172 Reve::TrackList* l = dynamic_cast<Reve::TrackList*>(cont);
175 rs = l->GetRnrStyle();
178 Error("kine_tracks.C", "TrackRenderStyle not set.");
185 Track* track = new Reve::Track(p, label, rs);
187 sprintf(form,"%s [%d]", p->GetName(), label);
188 track->SetName(form);
189 gReve->AddRenderElement(cont, track);
193 if (import_daughters && p->GetNDaughters())
195 for (int d=p->GetFirstDaughter(); d>0 && d<=p->GetLastDaughter(); ++d)
197 TParticle* dp = stack->Particle(d);
198 Track* track = new Reve::Track(dp, d, rs);
200 sprintf(form,"%s [%d]", dp->GetName(), d);
201 track->SetName(form);
203 gReve->AddRenderElement(cont, track);