]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Original track's path marks were copied to the projected track in
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 6 Nov 2007 12:23:34 +0000 (12:23 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 6 Nov 2007 12:23:34 +0000 (12:23 +0000)
Track::SetTrackParams(). This caused duplication of track-lines
and occasional crashes during event navigation.
Comments, grayspace.

EVE/Reve/NLTTrack.cxx
EVE/Reve/NLTTrack.h
EVE/Reve/Track.cxx
EVE/Reve/Track.h

index acc055d579b1550266048a0df76b248aae0052d4..2ae6aee1f3ff554204355499d917247a3e20c733 100644 (file)
@@ -6,49 +6,51 @@
 
 using namespace Reve;
 
-//______________________________________________________________________
+//______________________________________________________________________________
 // NLTTrack
 //
 
 ClassImp(NLTTrack)
 
+//______________________________________________________________________________
 NLTTrack::NLTTrack() :
   Track     (),
   fOrigPnts(0),
   fProjection(0)
-{}
+{
+  // Default constructor.
+}
+
+//______________________________________________________________________________
+NLTTrack::~NLTTrack()
+{
+  // Destructor. Noop.
+}
 
-/**************************************************************************/
+/******************************************************************************/
+
+//______________________________________________________________________________
 void NLTTrack::SetProjection(NLTProjector* proj, NLTProjectable* model)
 {
   NLTProjected::SetProjection(proj, model);
   Track* origTrack = dynamic_cast<Track*>(fProjectable);
 
   SetTrackParams(*origTrack);
-
-  // unfortunately fPathMarks is a vector of PathMark pointers
-  PathMark* pm;
-  std::vector<PathMark*>& refs = origTrack->GetPathMarksRef();
-  for(std::vector<PathMark*>::iterator i=refs.begin(); i!=refs.end(); ++i)
-  {
-   pm = new PathMark();
-   pm->V = (*i)->V;
-   pm->P = (*i)->P;
-   pm->type = (*i)->type;
-   pm->time = (*i)->time;
-   fPathMarks.push_back(pm);
-  }
+  SetPathMarks  (*origTrack);
 }
 
-/**************************************************************************/
+/******************************************************************************/
+
+//______________________________________________________________________________
 void NLTTrack::UpdateProjection()
 {
   fProjection = fProjector->GetProjection();
-  MakeTrack(kFALSE); //NLTProjector makes recursive calls
+  MakeTrack(kFALSE); // NLTProjector makes recursive calls
 }
 
 //______________________________________________________________________________
-void  NLTTrack::GetBreakPoint(Int_t idx, Bool_t back,  Float_t& x, Float_t& y, Float_t& z)
+void NLTTrack::GetBreakPoint(Int_t idx, Bool_t back,
+                            Float_t& x, Float_t& y, Float_t& z)
 {
   Vector vL = fOrigPnts[idx];
   Vector vR = fOrigPnts[idx+1];
@@ -84,12 +86,16 @@ void  NLTTrack::GetBreakPoint(Int_t idx, Bool_t back,  Float_t& x, Float_t& y, F
 //______________________________________________________________________________
 Int_t  NLTTrack::GetBreakPointIdx(Int_t start)
 {
+  // Findex index of the last point that lies within the same
+  // segment of projected space.
+  // For example, rho-z projection separates upper and lower hemisphere
+  // and tracks break into two lines when crossing the y=0 plane.
+
   Int_t val = fLastPoint;
 
-  Vector v1; Vector v2;
-  if( Size() > 1 )
+  Vector v1, v2;
+  if (Size() > 1)
   {
-    Bool_t broken = kFALSE;
     Int_t i = start;
     while(i < fLastPoint)
     {
@@ -97,35 +103,40 @@ Int_t  NLTTrack::GetBreakPointIdx(Int_t start)
       GetPoint(i+1, v2.x, v2.y, v2.z);
       if(fProjection->AcceptSegment(v1, v2, fRnrStyle->fDelta) == kFALSE)
       {
-       broken = kTRUE;
+       val = i;
         break;
       }
       i++;
     }
-    if(broken) val = i;
   }
   // printf("BreakPoint IDX start:%d, BREAK %d,  total:%d \n", start, val, Size());
   return val;
 }
 
-/**************************************************************************/
+/******************************************************************************/
 
+//______________________________________________________________________________
 void NLTTrack::MakeTrack(Bool_t recurse)
 {
+  // Calculate the points of the track for drawing.
+  // Call base-class, project, find break-points and insert points
+  // required for full representation.
+
   Track::MakeTrack(recurse);
 
   fBreakPoints.clear();
-  if(Size() == 0) return; // it is possible to be outside the limits of MaxR, MaxZ ...
+  if(Size() == 0) return; // All points can be outside of MaxR / MaxZ limits.
 
-  // poject line points
+  // Project points, store originals (needed for break-points).
   Float_t *p = GetP();
-  fOrigPnts = new Vector[Size()];
+  fOrigPnts  = new Vector[Size()];
   for(Int_t i = 0; i < Size(); ++i, p+=3)
   {
     fOrigPnts[i].Set(p);
     fProjection->ProjectPoint(p[0], p[1], p[2]);
     p[2] = fDepth;
-  } 
+  }
+
   Float_t x, y, z;
   std::vector<Vector> vvec;
   Int_t bL = 0, bR = GetBreakPointIdx(0); 
@@ -133,7 +144,7 @@ void NLTTrack::MakeTrack(Bool_t recurse)
   {
     for(Int_t i=bL; i<=bR; i++)
     {
-      GetPoint(i, x, y,z);
+      GetPoint(i, x, y, z);
       vvec.push_back(Vector(x, y, z));
     }
     if (bR == fLastPoint)
@@ -146,14 +157,17 @@ void NLTTrack::MakeTrack(Bool_t recurse)
     bL = bR + 1;
     bR = GetBreakPointIdx(bL);
   }
-  fBreakPoints.push_back(fLastPoint+1); // enforce drawing to end of line
+  fBreakPoints.push_back(vvec.size()); // Mark the track-end for drawing.
+
   Reset(vvec.size());
   for (std::vector<Reve::Vector>::iterator i=vvec.begin(); i!=vvec.end(); ++i)
     SetNextPoint((*i).x, (*i).y, (*i).z); 
   delete [] fOrigPnts;
 }
 
-/**************************************************************************/
+/******************************************************************************/
+
+//______________________________________________________________________________
 void NLTTrack::PrintLineSegments()
 {
   printf("%s LineSegments:\n", GetName());
@@ -175,8 +189,9 @@ void NLTTrack::PrintLineSegments()
   }
 }
 
-/**************************************************************************/
+/******************************************************************************/
 
+//______________________________________________________________________________
 void NLTTrack::CtrlClicked(Reve::Track* /*track*/)
 {
   Track* t = dynamic_cast<Track*>(fProjectable);
@@ -184,19 +199,28 @@ void NLTTrack::CtrlClicked(Reve::Track* /*track*/)
     t->CtrlClicked(t);
 }
 
-//______________________________________________________________________
+
+/******************************************************************************/
+/******************************************************************************/
+
+
+//______________________________________________________________________________
 // NLTTrackList
 //
 
 ClassImp(NLTTrackList)
 
+//______________________________________________________________________________
 NLTTrackList::NLTTrackList() :
   TrackList    (),
   NLTProjected ()
 {
+  // Default constructor.
 }
 
-/**************************************************************************/
+/******************************************************************************/
+
+//______________________________________________________________________________
 void NLTTrackList::SetProjection(NLTProjector* proj, NLTProjectable* model)
 {
   NLTProjected::SetProjection(proj, model);
index 4218e1f7ac54eb0769faf2dc24ba63e52420b670..70177bc99623a097b3238d171a80590475a09ce0 100644 (file)
@@ -24,12 +24,12 @@ private:
   void               GetBreakPoint(Int_t N, Bool_t back, Float_t& x, Float_t& y, Float_t& z);
 
 protected:
-  std::vector<Int_t> fBreakPoints;
-  NLTProjection*     fProjection;
+  std::vector<Int_t>  fBreakPoints;
+  NLTProjection      *fProjection;
 
 public:
   NLTTrack();
-  virtual ~NLTTrack(){}
+  virtual ~NLTTrack();
 
   virtual void SetProjection(NLTProjector* proj, NLTProjectable* model);
 
index 5cc3bd729e4010a8d39fd3b0c5a560b8fa451440..138999c0edc427718090091cb793bda08bca7c8a 100644 (file)
 
 using namespace Reve;
 
-//______________________________________________________________________
+//______________________________________________________________________________
 // Track
 //
 
 ClassImp(Reve::Track)
 
+//______________________________________________________________________________
 Track::Track() :
   Line(),
 
@@ -41,6 +42,7 @@ Track::Track() :
   fRnrStyle(0)
 {}
 
+//______________________________________________________________________________
 Track::Track(TParticle* t, Int_t label, TrackRnrStyle* rs):
   Line(),
 
@@ -64,6 +66,7 @@ Track::Track(TParticle* t, Int_t label, TrackRnrStyle* rs):
   SetName(t->GetName());
 }
 
+//______________________________________________________________________________
 Track::Track(Reve::MCTrack* t, TrackRnrStyle* rs):
   Line(),
 
@@ -89,6 +92,7 @@ Track::Track(Reve::MCTrack* t, TrackRnrStyle* rs):
   SetName(t->GetName());
 }
 
+//______________________________________________________________________________
 Track::Track(Reve::RecTrack* t, TrackRnrStyle* rs) :
   Line(),
 
@@ -108,6 +112,7 @@ Track::Track(Reve::RecTrack* t, TrackRnrStyle* rs) :
   SetName(t->GetName());
 }
 
+//______________________________________________________________________________
 Track::~Track()
 {
   SetRnrStyle(0);
@@ -115,6 +120,7 @@ Track::~Track()
     delete *i;
 }
 
+//______________________________________________________________________________
 Track::Track(const Track& t) :
   Line(),
   TQObject(),
@@ -127,26 +133,32 @@ Track::Track(const Track& t) :
   fPathMarks(),
   fRnrStyle(0)
 {
-  SetRnrStyle(t.fRnrStyle);
+  // Copy constructor.
+
   SetMainColor(t.GetMainColor());
   // Line
-  fRnrLine = t.fRnrLine;
+  fRnrLine   = t.fRnrLine;
   fRnrPoints = t.fRnrPoints;
   // TLineAttrib
   fLineColor = t.fLineColor;
   fLineStyle = t.fLineStyle;
   fLineWidth = t.fLineWidth;
+  SetPathMarks(t);
+  SetRnrStyle (t.fRnrStyle);
 }
 
+//______________________________________________________________________________
 void Track::SetTrackParams(const Track& t)
 {
-  fV        = t.fV;
-  fP        = t.fP;
-  fBeta     = t.fBeta;
-  fCharge   = t.fCharge;
-  fLabel    = t.fLabel;
-  fIndex    = t.fIndex;
-  fPathMarks= t.fPathMarks;
+  // Copy track parameters from t.
+  // PathMarks are cleared.
+
+  fV         = t.fV;
+  fP         = t.fP;
+  fBeta      = t.fBeta;
+  fCharge    = t.fCharge;
+  fLabel     = t.fLabel;
+  fIndex     = t.fIndex;
 
   SetMainColor(t.GetMainColor());
   // Line
@@ -156,22 +168,25 @@ void Track::SetTrackParams(const Track& t)
   fLineColor = t.fLineColor;
   fLineStyle = t.fLineStyle;
   fLineWidth = t.fLineWidth;
-
+  fPathMarks.clear();
   SetRnrStyle(t.fRnrStyle);
 }
 
-/*
-void Track::Reset(Int_t n_points)
+//______________________________________________________________________________
+void Track::SetPathMarks(const Track& t)
 {
-  delete [] TPolyLine3D::fP; TPolyLine3D::fP = 0;
-  fN = n_points;
-  if(fN) TPolyLine3D::fP = new Float_t [3*fN];
-  memset(TPolyLine3D::fP, 0, 3*fN*sizeof(Float_t));
-  fLastPoint = -1;
+  // Copy path-marks from t.
+
+  const std::vector<PathMark*>& refs = t.GetPathMarksRef();
+  for(std::vector<PathMark*>::const_iterator i=refs.begin(); i!=refs.end(); ++i)
+  {
+    fPathMarks.push_back(new PathMark(**i));
+  }
 }
-*/
 
-/**************************************************************************/
+/******************************************************************************/
+
+//______________________________________________________________________________
 void Track::SetRnrStyle(TrackRnrStyle* rs)
 {
  if (fRnrStyle == rs) return;
@@ -180,7 +195,9 @@ void Track::SetRnrStyle(TrackRnrStyle* rs)
   if (fRnrStyle) rs->IncRefCount(this);
 }
 
-/**************************************************************************/
+/******************************************************************************/
+
+//______________________________________________________________________________
 void Track::SetAttLineAttMarker(TrackList* tl)
 {
   SetLineColor(tl->GetLineColor());
@@ -192,8 +209,9 @@ void Track::SetAttLineAttMarker(TrackList* tl)
   SetMarkerSize(tl->GetMarkerSize());
 }
 
-/**************************************************************************/
+/******************************************************************************/
 
+//______________________________________________________________________________
 void Track::MakeTrack(Bool_t recurse)
 {
   TrackRnrStyle& RS((fRnrStyle != 0) ? *fRnrStyle : TrackRnrStyle::fgDefStyle);
@@ -330,7 +348,7 @@ make_polyline:
     Reset(size);
     for(Int_t i=0; i<size; ++i)
     {
-      MCVertex& v = track_points[i];
+      const MCVertex& v = track_points[i];
       SetNextPoint(v.x, v.y, v.z);
     }
   }
@@ -343,16 +361,17 @@ make_polyline:
       if(t) t->MakeTrack(recurse); 
     }
   }
-  Emit("MakeTrack(Bool_t)", (Long_t)recurse);
 }
 
-/**************************************************************************/
+/******************************************************************************/
+
+//______________________________________________________________________________
 TClass* Track::ProjectedClass() const
 {
   return NLTTrack::Class();
 }
 
-/**************************************************************************/
+/******************************************************************************/
 
 namespace {
 
@@ -364,13 +383,15 @@ struct cmp_pathmark
 
 }
 
+//______________________________________________________________________________
 void Track::SortPathMarksByTime()
 {
   std::sort(fPathMarks.begin(), fPathMarks.end(), cmp_pathmark());
 }
 
-/**************************************************************************/
+/******************************************************************************/
 
+//______________________________________________________________________________
 void Track::ImportHits()
 {
   Reve::LoadMacro("hits_from_label.C");
@@ -378,6 +399,7 @@ void Track::ImportHits()
                          fLabel, this));
 }
 
+//______________________________________________________________________________
 void Track::ImportClusters()
 {
   Reve::LoadMacro("clusters_from_label.C");
@@ -385,6 +407,7 @@ void Track::ImportClusters()
                          fLabel, this));
 }
 
+//______________________________________________________________________________
 void Track::ImportClustersFromIndex()
 {
   static const Exc_t eH("Track::ImportClustersFromIndex ");
@@ -397,8 +420,9 @@ void Track::ImportClustersFromIndex()
                          fIndex, this));
 }
 
-/**************************************************************************/
+/******************************************************************************/
 
+//______________________________________________________________________________
 void Track::ImportKine()
 {
   static const Exc_t eH("Track::ImportKine ");
@@ -412,6 +436,7 @@ void Track::ImportKine()
 
 }
 
+//______________________________________________________________________________
 void Track::ImportKineWithArgs(Bool_t importMother, Bool_t importDaugters)
 {
   static const Exc_t eH("Track::ImportKineWithArgs ");
@@ -424,15 +449,16 @@ void Track::ImportKineWithArgs(Bool_t importMother, Bool_t importDaugters)
                           fLabel, importMother, importDaugters, this));
 }
 
-/**************************************************************************/
+/******************************************************************************/
 
+//______________________________________________________________________________
 void Track::PrintKineStack()
 {
   Reve::LoadMacro("print_kine_from_label.C");
   gROOT->ProcessLine(Form("print_kine_from_label(%d);", fLabel));
 }
 
-
+//______________________________________________________________________________
 void Track::PrintPathMarks()
 {
   static const Exc_t eH("Track::PrintPathMarks ");
@@ -455,13 +481,15 @@ void Track::PrintPathMarks()
   }
 }
 
-/**************************************************************************/
+/******************************************************************************/
 
+//______________________________________________________________________________
 void Track::CtrlClicked(Reve::Track* track)
 {
   Emit("CtrlClicked(Reve::Track*)", (Long_t)track);
 }
 
+//______________________________________________________________________________
 void Track::SetLineStyle(Style_t lstyle)
 {
   TAttLine::SetLineStyle(lstyle);
@@ -478,10 +506,12 @@ void Track::SetLineStyle(Style_t lstyle)
   }
 }
 
-/**************************************************************************/
-/**************************************************************************/
 
-//______________________________________________________________________
+/******************************************************************************/
+/******************************************************************************/
+
+
+//______________________________________________________________________________
 // TrackRnrStyle
 //
 
@@ -1070,7 +1100,7 @@ void TrackCounter::Reset()
   TrackList* tlist;
   while ((tlist = dynamic_cast<TrackList*>(next())))
     tlist->DecDenyDestroy();
-  fTrackLists.Clear();
+  fTrackLists.Clear("nodelete");
 }
 
 void TrackCounter::RegisterTracks(TrackList* tlist, Bool_t goodTracks)
index 55d1b235cb8f83717735f055db7d486b51213267..d91b0f3e25ad4293482bd3fcc94832b0b4908daa 100644 (file)
@@ -53,6 +53,7 @@ public:
 
   Track(const Track& t);
   virtual void SetTrackParams(const Track& t);
+  virtual void SetPathMarks  (const Track& t);
 
   virtual void MakeTrack(Bool_t recurse=kTRUE);
 
@@ -65,9 +66,10 @@ public:
   Int_t GetIndex() const    { return fIndex; }
   void  SetIndex(Int_t idx) { fIndex = idx;  }
 
-  void  AddPathMark(Reve::PathMark* pm) { fPathMarks.push_back(pm); }
-  vpPathMark_t& GetPathMarksRef(){return fPathMarks;}
-  void  SortPathMarksByTime();
+  void          AddPathMark(Reve::PathMark* pm) { fPathMarks.push_back(pm); }
+  vpPathMark_t& GetPathMarksRef()               { return fPathMarks; }
+  const vpPathMark_t& GetPathMarksRef() const   { return fPathMarks; }
+  void          SortPathMarksByTime();
 
   //--------------------------------