<commit_before>// $Id$
// Main authors: <NAME> & <NAME>: 2006, 2007

/**************************************************************************
 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
 * full copyright notice.                                                 *
 **************************************************************************/

// Import tracks from kinematics-tree / particle-stack.
// Preliminary/minimal solution.

#include "TParticlePDG.h"

TEveTrackList*
kine_tracks(Double_t min_pt  = 0.1,   Double_t min_p   = 0.2,
	    Bool_t   pdg_col = kTRUE, Bool_t   recurse = kTRUE,
	    Bool_t   use_track_refs = kTRUE)
{
  AliRunLoader* rl =  AliEveEventManager::AssertRunLoader();
  rl->LoadKinematics();
  AliStack* stack = rl->Stack();
  if (!stack) {
    Error("kine_tracks.C", "can not get kinematics.");
    return 0;
  }

  gEve->DisableRedraw();

  TEveTrackList* cont = new TEveTrackList("Kine Tracks");
  cont->SetMainColor(Color_t(3));
  TEveTrackPropagator* rnrStyle = cont->GetPropagator();
  // !!! Watch the '-', apparently different sign convention then for ESD.
  rnrStyle->SetMagField( -0.1*gAlice->Field()->SolenoidField() );

  gEve->AddElement(cont);
  Int_t count = 0;
  Int_t N = stack->GetNtrack();
  for (Int_t i=0; i<N; ++i)
  {
    if(stack->IsPhysicalPrimary(i))
    {
      TParticle* p = stack->Particle(i);
      if (p->Pt() < min_pt && p->P() < min_p) continue;

      ++count;
      TEveTrack* track = new TEveTrack(p, i, rnrStyle);

      //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();
      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
  AliEveKineTools kt;
  kt.SetDaughterPathMarks(cont, stack, recurse);
  if (use_track_refs && rl->LoadTrackRefs() == 0)
  {
    kt.SetTrackReferences(cont, rl->TreeTR(), recurse);
    rnrStyle->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->UpdateItems();

  cont->MakeTracks(recurse);
  gEve->EnableRedraw();
  gEve->Redraw3D();<commit_msg>For primary tracks, when mother-particle is defined, add label and pdg-code of the mother to the tooltip.<commit_after>// $Id$
// Main authors: <NAME> & <NAME>: 2006, 2007

/**************************************************************************
 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
 * full copyright notice.                                                 *
 **************************************************************************/

// Import tracks from kinematics-tree / particle-stack.
// Preliminary/minimal solution.

#include "TParticlePDG.h"

TEveTrackList*
kine_tracks(Double_t min_pt  = 0.1,   Double_t min_p   = 0.2,
	    Bool_t   pdg_col = kTRUE, Bool_t   recurse = kTRUE,
	    Bool_t   use_track_refs = kTRUE)
{
  AliRunLoader* rl =  AliEveEventManager::AssertRunLoader();
  rl->LoadKinematics();
  AliStack* stack = rl->Stack();
  if (!stack) {
    Error("kine_tracks.C", "can not get kinematics.");
    return 0;
  }

  gEve->DisableRedraw();

  TEveTrackList* cont = new TEveTrackList("Kine Tracks");
  cont->SetMainColor(Color_t(3));
  TEveTrackPropagator* rnrStyle = cont->GetPropagator();
  // !!! Watch the '-', apparently different sign convention then for ESD.
  rnrStyle->SetMagField( -0.1*gAlice->Field()->SolenoidField() );

  gEve->AddElement(cont);
  Int_t count = 0;
  Int_t N = stack->GetNtrack();
  for (Int_t i=0; i<N; ++i)
  {
    if(stack->IsPhysicalPrimary(i))
    {
      TParticle* p = stack->Particle(i);
      if (p->Pt() < min_pt && p->P() < min_p) continue;

      ++count;
      TEveTrack* track = new TEveTrack(p, i, rnrStyle);

      //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
  AliEveKineTools kt;
  kt.SetDaughterPathMarks(cont, stack, recurse);
  if (use_track_refs && rl->LoadTrackRefs() == 0)
  {
    kt.SetTrackReferences(cont, rl->TreeTR(), recurse);
    rnrStyle->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->UpdateItems();

  cont->MakeTracks(recurse);
  gEve->EnableRedraw();
  gEve->Redraw3D();
{'fraction_non_alphanumeric': 0.19908968307484828, 'fraction_numerical': 0.014160485502360081, 'mean_word_length': 3.207801418439716, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 68, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4126357', 'n_tokens_mistral': 2172, 'n_tokens_neox': 2025, 'n_words': 459}