TEveTrackList* kine_tracks(Double_t min_pt, Double_t min_p, Bool_t pdg_col, Bool_t recurse, Bool_t use_track_refs) { IlcRunLoader* rl = IlcEveEventManager::AssertRunLoader(); rl->LoadKinematics(); IlcStack* stack = rl->Stack(); if (!stack) { Error("kine_tracks", "can not get kinematics."); return 0; } gEve->DisableRedraw(); TEveTrackList* cont = new TEveTrackList("Kine Tracks"); cont->SetMainColor(3); TEveTrackPropagator* trkProp = cont->GetPropagator(); kine_track_propagator_setup(trkProp); gEve->AddElement(cont); Int_t count = 0; Int_t Np = stack->GetNprimary(); for (Int_t i = 0; i < Np; ++i) { TParticle* p = stack->Particle(i); if (p->GetStatusCode() <= 1) { if (p->Pt() < min_pt && p->P() < min_p) continue; ++count; IlcEveTrack* track = new IlcEveTrack(p, i, trkProp); //PH The line below is replaced waiting for a fix in Root //PH which permits to use variable siza arguments in CINT //PH on some platforms (alphalinuxgcc, solariscc5, etc.) //PH track->SetName(Form("%s [%d]", p->GetName(), i)); char form[1000]; sprintf(form,"%s [%d]", p->GetName(), i); track->SetName(form); track->SetStdTitle(); Int_t ml = p->GetMother(0); if (ml != -1) { track->SetTitle(Form("%s\nMother label=%d\nMother Pdg=%d", track->GetElementTitle(), ml, stack->Particle(ml)->GetPdgCode())); } set_track_color(track, pdg_col); gEve->AddElement(track, cont); if (recurse) kine_daughters(track, stack, min_pt, min_p, pdg_col, recurse); } } // set path marks IlcEveKineTools kt; kt.SetDaughterPathMarks(cont, stack, recurse); if (use_track_refs && rl->LoadTrackRefs() == 0) { kt.SetTrackReferences(cont, rl->TreeTR(), recurse); trkProp->SetEditPathMarks(kTRUE); } kt.SortPathMarks(cont, recurse); //PH const Text_t* tooltip = Form("min pT=%.2lf, min P=%.2lf), N=%d", min_pt, min_p, count); char tooltip[1000]; sprintf(tooltip,"min pT=%.2lf, min P=%.2lf), N=%d", min_pt, min_p, count); cont->SetTitle(tooltip); // Not broadcasted automatically ... cont->MakeTracks(recurse); gEve->EnableRedraw(); gEve->Redraw3D(); return cont; }
TEveElement* kine_track(Int_t label, Bool_t import_mother, Bool_t import_daughters, Bool_t pdg_col, Bool_t recurse, TEveElement* cont) { // Create mother and daughters tracks with given label. // mother -> particle with label // daughters -> daughters of label if (label < 0) { Warning("kine_track", "label not set."); return 0; } IlcRunLoader* rl = IlcEveEventManager::AssertRunLoader(); rl->LoadKinematics(); IlcStack* stack = rl->Stack(); if (!stack) { Warning("kine_track", "can not get kinematics."); return 0; } if (label >= stack->GetNtrack()) { Warning("kine_track", "label out of range."); return 0; } TParticle* p = stack->Particle(label); if (import_mother || (import_daughters && p->GetNDaughters())) { TEveTrackPropagator* rs = 0; if (cont == 0) { TEveTrackList* tlist = new TEveTrackList (Form("Kinematics of %d %d", label, p->GetNDaughters())); cont = tlist; TEveTrackPropagator* trkProp = tlist->GetPropagator(); kine_track_propagator_setup(trkProp); char tooltip[1000]; sprintf(tooltip,"Ndaughters=%d", p->GetNDaughters()); tlist->SetTitle(tooltip); trkProp->SetMaxOrbs(2); trkProp->SetEditPathMarks(kTRUE); gEve->AddElement(cont); rs = tlist->GetPropagator(); } else { // check if container is TEveTrackList or IlcEveTrack (has rnr-style) IlcEveTrack* t = dynamic_cast<IlcEveTrack*>(cont); if (t) { rs = t->GetPropagator(); } else { TEveTrackList* l = dynamic_cast<TEveTrackList*>(cont); if (l) rs = l->GetPropagator(); else Error("kine_tracks.C", "TrackRenderStyle not set."); } } if (import_mother) { IlcEveTrack* track = new IlcEveTrack(p, label, rs); char form[1000]; sprintf(form,"%s [%d]", p->GetName(), label); track->SetName(form); track->SetStdTitle(); set_track_color(track, pdg_col); track->MakeTrack(); gEve->AddElement(track, cont); cont = track; } if (import_daughters && p->GetNDaughters()) { for (int d=p->GetFirstDaughter(); d>0 && d<=p->GetLastDaughter(); ++d) { TParticle* dp = stack->Particle(d); IlcEveTrack* track = new IlcEveTrack(dp, d, rs); char form[1000]; sprintf(form,"%s [%d]", dp->GetName(), d); track->SetName(form); track->SetStdTitle(); set_track_color(track, pdg_col); track->MakeTrack(); gEve->AddElement(track, cont); if (recurse) kine_daughters(track, stack, 0, 0, pdg_col, recurse); } } } gEve->Redraw3D(); return cont; }