Added method SortPathMarksByTime().
[u/mrichter/AliRoot.git] / EVE / Reve / Track.cxx
index 772bae693ea48d3ed7a06b5010369f49aa5d36e6..2cf96d9baee28ba1657ad958bc9d55e96de32638 100644 (file)
@@ -122,9 +122,8 @@ void Track::Reset(Int_t n_points)
 
  /**************************************************************************/
 
-void Track::MakeTrack()
+void Track::MakeTrack( Bool_t recurse)
 {
-  
   TrackRnrStyle& RS((fRnrStyle != 0) ? *fRnrStyle : TrackRnrStyle::fgDefStyle);
 
   Float_t px = fP.x, py = fP.y, pz = fP.z;  
@@ -238,20 +237,44 @@ make_polyline:
   Reset(track_points.size());
   for(std::vector<MCVertex>::iterator i=track_points.begin(); i!=track_points.end(); ++i)
     SetNextPoint(i->x, i->y, i->z);
+
+  if(recurse) {
+    Track* t;
+    for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
+      t = dynamic_cast<Track*>(*i);
+      if(t)t->MakeTrack(recurse); 
+    }
+  }
 }
 
+/**************************************************************************/
+namespace {
+struct cmp_pathmark {
+  bool operator()(PathMark* const & a, PathMark* const & b)
+  { return a->time < b->time; }
+};
+}
+
+void Track::SortPathMarksByTime()
+{
+ sort(fPathMarks.begin(), fPathMarks.end(), cmp_pathmark());
+}
+
+
 /**************************************************************************/
 
 void Track::ImportHits()
 {
   Reve::LoadMacro("hits_from_label.C");
-  gROOT->ProcessLine(Form("hits_from_label(%d);", fLabel));
+  gROOT->ProcessLine(Form("hits_from_label(%d, (Reve::RenderElement*)%p);", 
+                         fLabel, this));
 }
 
 void Track::ImportClusters()
 {
   Reve::LoadMacro("clusters_from_label.C");
-  gROOT->ProcessLine(Form("clusters_from_label(%d);", fLabel));
+  gROOT->ProcessLine(Form("clusters_from_label(%d, (Reve::RenderElement*)%p);", 
+                         fLabel, this));
 }
 
 void Track::ImportClustersFromIndex()
@@ -262,18 +285,36 @@ void Track::ImportClustersFromIndex()
     throw(eH + "index not set.");
 
   Reve::LoadMacro("clusters_from_index.C");
-  gROOT->ProcessLine(Form("clusters_from_index(%d);", fIndex));
+  gROOT->ProcessLine(Form("clusters_from_index(%d, (Reve::RenderElement*)%p);", 
+                         fIndex, this));
 }
 
-void Track::ImportDaughters()
+/**************************************************************************/
+
+void Track::ImportKine()
 {
-  static const Exc_t eH("Track::ImportDaughters ");
+  static const Exc_t eH("Track::ImportKine ");
 
   if (fLabel < 0)
     throw(eH + "label not set.");
 
-  Reve::LoadMacro("daughters_from_label.C");
-  gROOT->ProcessLine(Form("daughters_from_label(%d);", fLabel));
+  Reve::LoadMacro("kine_tracks.C");
+  gROOT->ProcessLine(Form("kine_track(%d, kFALSE, kTRUE, (Reve::RenderElement*)%p);", 
+                         fLabel, this));
+
+}
+
+void Track::ImportKineWithArgs(Bool_t importMother, Bool_t importDaugters)
+{
+  static const Exc_t eH("Track::ImportKineWithArgs ");
+
+  if (fLabel < 0)
+    throw(eH + "label not set.");
+
+  Reve::LoadMacro("kine_tracks.C");
+  gROOT->ProcessLine(Form("kine_track(%d, %d, %d, (Reve::RenderElement*)%p);", 
+                          fLabel, importMother, importDaugters, this));
+
 }
 
 /**************************************************************************/
@@ -342,6 +383,9 @@ TrackRnrStyle::TrackRnrStyle() :
   fMinAng  (45),
   fDelta   (0.1),
 
+  fMinPt   (0.1),
+  fMaxPt   (10),
+
   fFitDaughters  (kTRUE),
   fFitReferences (kTRUE),
   fFitDecay      (kTRUE),
@@ -361,16 +405,16 @@ ClassImp(Reve::TrackList)
 
 void TrackList::Init()
 {
-  fMarkerStyle = 5;
-  fMarkerColor = 5;
-  // fMarker->SetMarkerSize(0.05);
+  fMarkerStyle = 2;
+  fMarkerColor = 4;
+  fMarkerSize  = 0.6;
 
   if (fRnrStyle== 0) fRnrStyle = new TrackRnrStyle;
   SetMainColorPtr(&fRnrStyle->fColor);
 }
 
 TrackList::TrackList(Int_t n_tracks, TrackRnrStyle* rs) :
-  RenderElementListBase(),
+  RenderElement(),
   TPolyMarker3D(n_tracks),
 
   fTitle(),
@@ -383,13 +427,14 @@ TrackList::TrackList(Int_t n_tracks, TrackRnrStyle* rs) :
 }
 
 TrackList::TrackList(const Text_t* name, Int_t n_tracks, TrackRnrStyle* rs) :
-  RenderElementListBase(),
+  RenderElement(),
   TPolyMarker3D(n_tracks),
   
   fTitle(),
 
-  fRnrStyle   (rs),
-  fRnrTracks  (kTRUE)
+  fRnrStyle      (rs),
+  fRnrTracks     (kTRUE),
+  fEditPathMarks (kFALSE)
 {
   Init();
   SetName(name);
@@ -408,13 +453,13 @@ void TrackList::Reset(Int_t n_tracks)
 
 void TrackList::Paint(Option_t* option)
 {
-  if(fRnrElement) {
+  if(fRnrSelf) {
     if(fRnrMarkers) {
       TPolyMarker3D::Paint(option);
     }
-    if(fRnrTracks) {
+    if(fRnrTracks && fRnrChildren) {
       for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
-       if((*i)->GetRnrElement())
+       if((*i)->GetRnrSelf())
          (*i)->GetObject()->Paint(option);
       }
     }
@@ -428,7 +473,7 @@ void TrackList::AddElement(RenderElement* el)
   static const Exc_t eH("TrackList::AddElement ");
   if (dynamic_cast<Track*>(el)  == 0)
     throw(eH + "new element not a Track.");
-  RenderElementListBase::AddElement(el);
+  RenderElement::AddElement(el);
 }
 
 /**************************************************************************/
@@ -553,13 +598,16 @@ void TrackList::SetRnrTracks(Bool_t rnr)
 
 void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt)
 {
+  fRnrStyle->fMinPt = min_pt;
+  fRnrStyle->fMaxPt = max_pt;
+
   Float_t minptsq = min_pt*min_pt;
   Float_t maxptsq = max_pt*max_pt;
   Float_t ptsq;
 
   for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
     ptsq = ((Track*)(*i))->fP.Perp2();
-    (*i)->SetRnrElement(ptsq >= minptsq && ptsq <= maxptsq);
+    (*i)->SetRnrSelf(ptsq >= minptsq && ptsq <= maxptsq);
   }
 }