Added function kine_track() to import a track with given label and its daughters.
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 26 Feb 2007 17:12:08 +0000 (17:12 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 26 Feb 2007 17:12:08 +0000 (17:12 +0000)
EVE/alice-macros/kine_tracks.C

index 041b8fa..35044eb 100644 (file)
@@ -113,3 +113,76 @@ Color_t get_pdg_color(Int_t pdg){
   }
   return col;
 }
+
+
+// Create mother and daughters tracks with given label.
+
+Reve::TrackList*
+kine_track(Int_t label, Bool_t create_mother = kTRUE, Reve::TrackList* cont = 0)
+{
+  gSystem->IgnoreSignal(kSigSegmentationViolation, true);
+  if (label < 0) {
+    Warning("kine_track", "label not set.");
+    return 0;
+  }
+  AliRunLoader* rl =  Alieve::Event::AssertRunLoader();
+  rl->LoadKinematics();
+  AliStack* stack = rl->Stack();
+  TParticle* p = stack->Particle(label);
+
+  if (create_mother | p->GetNDaughters())
+  {
+    if(cont == 0) {
+      cont =  
+       new TrackList(Form("%d kine_tracks %d", p->GetNDaughters(), label));
+
+      Reve::TrackRnrStyle* rnrStyle = cont->GetRnrStyle();
+      // !!! Watch the '-', apparently different sign convention then for ESD.
+      rnrStyle->SetMagField( - gAlice->Field()->SolenoidField() );
+      char tooltip[1000];
+      sprintf(tooltip,"%d, mother %d", p->GetNDaughters(), label);
+      cont->SetTitle(tooltip);  
+      cont->SelectByPt(0.2, 100);
+      rnrStyle->fColor = 8;  
+      rnrStyle->fMaxOrbs = 8;  
+      cont->SetEditPathMarks(kTRUE);
+      gReve->AddRenderElement(cont);
+    }
+   
+    if(create_mother){
+      Track* track = new Reve::Track(p, label, cont->GetRnrStyle());  
+      char form[1000];
+      sprintf(form,"%s [%d]", p->GetName(), label);
+      track->SetName(form);
+      gReve->AddRenderElement(cont, track);
+    }
+
+    if (p->GetNDaughters()) 
+    {
+      for (int d=p->GetFirstDaughter(); d>0 && d<=p->GetLastDaughter(); ++d) 
+      {        
+       TParticle* dp = stack->Particle(d);
+       Track* track = new Reve::Track(dp, d, cont->GetRnrStyle());  
+       char form[1000];
+       sprintf(form,"%s [%d]", dp->GetName(), d);
+       track->SetName(form);
+       gReve->AddRenderElement(cont, track);
+      }
+    }
+  }
+
+  // set path marks
+  if(cont->GetEditPathMarks()) {
+    Alieve::KineTools kt; 
+    rl->LoadTrackRefs();
+    kt.SetPathMarks(cont,stack, rl->TreeTR());
+  }
+
+  cont->UpdateItems(); // update list tree
+  cont->MakeTracks();
+  cont->MakeMarkers();
+
+  gReve->Redraw3D();
+  return cont;
+}