Add class and function docs.
authoralja <alja@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 30 Jan 2008 16:52:43 +0000 (16:52 +0000)
committeralja <alja@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 30 Jan 2008 16:52:43 +0000 (16:52 +0000)
EVE/EveBase/AliEveKineTools.cxx
EVE/EveBase/AliEveKineTools.h
EVE/EveBase/AliEveTrackFitter.cxx
EVE/EveBase/AliEveTrackFitter.h
EVE/EveBase/AliEveTrackFitterEditor.cxx
EVE/EveBase/AliEveTrackFitterEditor.h

index 604d8aa6c07998d960a506ad590aa3409f495e57..4c1e5e167885316f762981187f9bd504d6e94062 100644 (file)
 #include <TEveTrack.h>
 #include <TEveElement.h>
 
-#include <algorithm>
 #include <map>
 
 //______________________________________________________________________________
 // AliEveKineTools
 //
+// Tools for import of kinematics. Preliminary version.
+//
 
 using namespace std;
 
 ClassImp(AliEveKineTools)
 
-AliEveKineTools::AliEveKineTools()
-{}
 
-/******************************************************************************/
+namespace {
+
+  typedef std::map<Int_t, TEveTrack*> TrackMap_t;
+
+  void MapTracks(TrackMap_t& map, TEveElement* cont, Bool_t recurse)
+  {
+    TEveElement::List_i i = cont->BeginChildren();
+    while (i != cont->EndChildren()) {
+      TEveTrack* track = dynamic_cast<TEveTrack*>(*i);
+      map[track->GetLabel()] = track;
+      if (recurse)
+        MapTracks(map, track, recurse);
+      ++i;
+    }
+  }
+}
+
+/**************************************************************************/
 
 void AliEveKineTools::SetDaughterPathMarks(TEveElement* cont, AliStack* stack, Bool_t recurse)
 {
   // Import daughters birth points.
 
   TEveElement::List_i  iter = cont->BeginChildren();
-
   while(iter != cont->EndChildren())
   {
     TEveTrack* track = dynamic_cast<TEveTrack*>(*iter);
@@ -64,39 +79,16 @@ void AliEveKineTools::SetDaughterPathMarks(TEveElement* cont, AliStack* stack, B
   }
 }
 
-/******************************************************************************/
-
-namespace {
-struct cmp_pathmark
-{
-  bool operator()(TEvePathMark* const & a, TEvePathMark* const & b)
-  { return a->fTime < b->fTime; }
-};
-
-void slurp_tracks(std::map<Int_t, TEveTrack*>& tracks, TEveElement* cont, Bool_t recurse)
-{
-  TEveElement::List_i citer = cont->BeginChildren();
-  while(citer != cont->EndChildren())
-  {
-    TEveTrack* track = dynamic_cast<TEveTrack*>(*citer);
-    tracks[track->GetLabel()] = track;
-    if (recurse)
-      slurp_tracks(tracks, track, recurse);
-    ++citer;
-  }
-}
-
-}
+/**************************************************************************/
 
 void AliEveKineTools::SetTrackReferences(TEveElement* cont, TTree* treeTR, Bool_t recurse)
 {
-  // set decay and reference points
+  // Set decay and track reference path-marks.
 
   static const TEveException eH("AliEveKineTools::ImportPathMarks");
 
-  // Fill map
-  std::map<Int_t, TEveTrack*> tracks;
-  slurp_tracks(tracks, cont, recurse);
+  TrackMap_t map;
+  MapTracks(map, cont, recurse);
 
   Int_t nPrimaries = (Int_t) treeTR->GetEntries();
   TIter next(treeTR->GetListOfBranches());
@@ -115,7 +107,7 @@ void AliEveKineTools::SetTrackReferences(TEveElement* cont, TTree* treeTR, Bool_
       el->GetEntry(iPrimPart);
 
       Int_t last_label = -1;
-      std::map<Int_t, TEveTrack*>::iterator iter = tracks.end();
+      TrackMap_t::iterator iter = map.end();
       Int_t Nent =  arr->GetEntriesFast();
       for (Int_t iTrackRef = 0; iTrackRef < Nent; iTrackRef++)
       {
@@ -127,11 +119,11 @@ void AliEveKineTools::SetTrackReferences(TEveElement* cont, TTree* treeTR, Bool_
                          iTrackRef, el->GetName()));
 
         if(label != last_label) {
-         iter = tracks.find(label);
+         iter = map.find(label);
          last_label = label;
        }
 
-       if (iter != tracks.end()) {
+       if (iter != map.end()) {
          TEvePathMark* pm = new TEvePathMark(isRef ? TEvePathMark::kReference : TEvePathMark::kDecay);
          pm->fV.Set(atr->X(),atr->Y(), atr->Z());
          pm->fP.Set(atr->Px(),atr->Py(), atr->Pz());
@@ -140,22 +132,24 @@ void AliEveKineTools::SetTrackReferences(TEveElement* cont, TTree* treeTR, Bool_
           track->AddPathMark(pm);
        }
       } // loop track refs
-    } // loop primaries, clones arrays
+    } // loop primaries in clones arrays
     delete arr;
   } // end loop through top branches
 }
 
-void AliEveKineTools::SortPathMarks(TEveElement* cont, Bool_t recurse)
+/**************************************************************************/
+
+void AliEveKineTools::SortPathMarks(TEveElement* el, Bool_t recurse)
 {
   // Sort path-marks for all tracks by time.
 
-  // Fill map
-  std::map<Int_t, TEveTrack*> tracks;
-  slurp_tracks(tracks, cont, recurse);
+  TEveTrack* track = dynamic_cast<TEveTrack*>(el);
+  if(track) track->SortPathMarksByTime();
 
-  // sort
-  for(std::map<Int_t, TEveTrack*>::iterator j=tracks.begin(); j!=tracks.end(); ++j)
-  {
-    j->second->SortPathMarksByTime();
+  TEveElement::List_i i = el->BeginChildren();
+  while (i != el->EndChildren() && recurse) {
+    track = dynamic_cast<TEveTrack*>(el);
+    if (track) track->SortPathMarksByTime();
+    i++;
   }
 }
index 6f35fcb4189fa7ef92adf61b88d5a18b701d2bd7..4d61e0f407f41200ec219c3d356990857f3bd85b 100644 (file)
@@ -7,9 +7,6 @@
  * full copyright notice.                                                 *
  **************************************************************************/
 
-// Tools for import of kinematics.
-// Preliminary/minimal solution.
-
 #ifndef ALIEVE_KineTools_H
 #define ALIEVE_KineTools_H
 
 class TTree;
 class AliStack;
 
-class TEveTrackList;
-
-
 class AliEveKineTools
 {
 private:
   AliEveKineTools(const AliEveKineTools&);            // Not implemented
   AliEveKineTools& operator=(const AliEveKineTools&); // Not implemented
 
-protected:
-  // data from TreeK
 public:
-  AliEveKineTools();
+  AliEveKineTools(){}
   virtual ~AliEveKineTools(){}
 
-  // data from TreeTR
   void SetDaughterPathMarks(TEveElement* cont, AliStack* stack, Bool_t recurse=kFALSE);
   void SetTrackReferences  (TEveElement* cont, TTree* treeTR=0, Bool_t recurse=kFALSE);
   void SortPathMarks       (TEveElement* cont, Bool_t recurse=kFALSE);
 
-  ClassDef(AliEveKineTools, 1);
-}; // endclass AliEveKineTools
+  ClassDef(AliEveKineTools, 1); // Tools for import of kinematics.
+};
 
 #endif
index 9249a0b047263f6c984bbf575f006783cb6abc83..aeeec3abfe1091b7f1d58f57f36fa65fe0685fe7 100644 (file)
 //______________________________________________________________________________
 // AliEveTrackFitter
 //
-// AliEveTrackFitter is an interface to helix fit. It creates a set of
-// points, listening to signal PointCtrlClicked() of any
-// TEvePointSet. Via editor it fits selected points and creates a
-// reconstructed track.
+// AliEveTrackFitter is an interface to TEvePointSet allowing AliRieman fit.
+// It builds a list of points by listening to selection signal of any object of type
+// TEvePointSet. After selection the list is feeded to AliRieman fitter,
+// which returns helix parameters visualized with TEveTrack.
 //
 
 ClassImp(AliEveTrackFitter)
@@ -37,29 +37,21 @@ ClassImp(AliEveTrackFitter)
 AliEveTrackFitter::AliEveTrackFitter(const Text_t* name, Int_t n_points) :
     TEvePointSet   (name, n_points),
 
-    fGraphSelected (0),
-    fGraphFitted   (0),
     fAlpha         (0),
     fRieman        (0),
+
     fConnected     (kFALSE),
+    fSPMap         (),
     fTrackList     (0),
-    fMapPS         ()
+
+    fGraphPicked   (0),
+    fGraphHelix    (0)
 {
   // Constructor.
 
   SetMarkerColor(3);
   SetOwnIds(kFALSE);
 
-  fGraphSelected = new TGraph();
-  fGraphSelected->SetName("Selected points");
-  fGraphSelected->SetMarkerColor(4);
-  fGraphSelected->SetMarkerStyle(4);
-  fGraphSelected->SetMarkerSize(2);
-
-  fGraphFitted = new TGraphErrors();
-  fGraphFitted->SetName("Fitted points");
-  fGraphFitted->SetMarkerColor(2);
-
   fTrackList = new TEveTrackList("Tracks");
   fTrackList->SetLineWidth(2);
   fTrackList->SetLineColor(8);
@@ -67,6 +59,16 @@ AliEveTrackFitter::AliEveTrackFitter(const Text_t* name, Int_t n_points) :
   fTrackList->GetPropagator()->SetEditPathMarks(kTRUE);
   gEve->AddElement(fTrackList, this);
   UpdateItems();
+
+  fGraphPicked = new TGraph();
+  fGraphPicked->SetName("Selected points");
+  fGraphPicked->SetMarkerColor(4);
+  fGraphPicked->SetMarkerStyle(4);
+  fGraphPicked->SetMarkerSize(2);
+
+  fGraphHelix = new TGraphErrors();
+  fGraphHelix->SetName("Fitted points");
+  fGraphHelix->SetMarkerColor(2);
 }
 
 AliEveTrackFitter::~AliEveTrackFitter()
@@ -74,40 +76,29 @@ AliEveTrackFitter::~AliEveTrackFitter()
   // Destructor.
 
   if(fRieman) delete fRieman;
+
   fTrackList->DecDenyDestroy();
   delete fTrackList;
 }
 
-/******************************************************************************/
-void AliEveTrackFitter::DestroyElements()
-{
-  // Virtual method of base class TEveElement.
-  // It preserves track list to have coomon track propagator attributes.
-
-  TEveElement::DestroyElements();
-  gEve->AddElement(fTrackList, this);
-  fTrackList->DestroyElements();
-  UpdateItems();
-}
-
 /******************************************************************************/
 void AliEveTrackFitter::Start()
 {
-  // Start selection of points.
+  // Clear existing point selection and maintain connection to the
+  // TEvePointSet signal.
 
   Reset();
   if(fConnected == kFALSE)
   {
     TQObject::Connect("TEvePointSet", "PointCtrlClicked(TEvePointSet*,Int_t)",
                      "AliEveTrackFitter", this, "AddFitPoint(TEvePointSet*,Int_t)");
-
     fConnected = kTRUE;
   }
 }
 
 void AliEveTrackFitter::Stop()
 {
-  // Stop selection of points.
+  // Stop adding points for the fit.
 
   if(fConnected)
   {
@@ -116,16 +107,25 @@ void AliEveTrackFitter::Stop()
   }
 }
 
+void AliEveTrackFitter::Reset(Int_t n, Int_t ids)
+{
+  // Reset selection.
+
+  if(fRieman) fRieman->Reset();
+  TEvePointSet::Reset(n, ids);
+  fSPMap.clear();
+}
+
 /******************************************************************************/
 
 void AliEveTrackFitter::AddFitPoint(TEvePointSet* ps, Int_t n)
 {
-  // Add/remove given point depending if exists in the fMapPS.
+  // Add or remove given point depending if exists in the map.
 
   Float_t x, y, z;
 
-  std::map<Point_t, Int_t>::iterator g = fMapPS.find(Point_t(ps, n));
-  if(g != fMapPS.end())
+  PointMap_t::iterator g = fSPMap.find(Point_t(ps, n));
+  if(g != fSPMap.end())
   {
     Int_t idx = g->second;
     if(idx != fLastPoint)
@@ -133,16 +133,17 @@ void AliEveTrackFitter::AddFitPoint(TEvePointSet* ps, Int_t n)
       GetPoint(fLastPoint, x, y, z);
       SetPoint(idx, x, y, z);
     }
-    fMapPS.erase(g);
+    fSPMap.erase(g);
     fLastPoint--;
   }
   else
   {
-    fMapPS[Point_t(ps, n)] = Size();
+    fSPMap[Point_t(ps, n)] = Size();
     ps->GetPoint(n, x, y, z);
     SetNextPoint(x, y, z);
     SetPointId(ps->GetPointId(n));
   }
+
   ResetBBox();
   ElementChanged(kTRUE, kTRUE);
 }
@@ -219,42 +220,48 @@ void AliEveTrackFitter::FitTrack()
 }
 
 
-void AliEveTrackFitter::Reset(Int_t n, Int_t ids)
+/******************************************************************************/
+void AliEveTrackFitter::DestroyElements()
 {
-  // Reset selection.
+  // Virtual method of base class TEveElement.
+  // Preserves TEveTrackPropagator object for fitted helices.
 
-  if(fRieman) fRieman->Reset();
-  TEvePointSet::Reset(n, ids);
-  fMapPS.clear();
+  TEveElement::DestroyElements();
+
+  gEve->AddElement(fTrackList, this);
+  fTrackList->DestroyElements();
+  UpdateItems();
 }
 
 /******************************************************************************/
-void AliEveTrackFitter::DrawRiemanGraph()
+void AliEveTrackFitter::DrawDebugGraph()
 {
-  // Draw graph of rieman fit.
+  // Draw graph of picked points and helix points.
 
-   static const TEveException eH("AliEveTrackFitter::DrawRiemanGraph ");
+  static const TEveException eH("AliEveTrackFitter::DrawRiemanGraph ");
 
   if(fRieman == 0)
     throw(eH + "fitter not set.");
 
   Int_t nR = fRieman->GetN();
-  fGraphSelected->Set(nR);
-  fGraphFitted->Set(nR);
+  fGraphPicked->Set(nR);
+  fGraphHelix->Set(nR);
 
-  Double_t* x =  fRieman->GetX();
-  Double_t* y =  fRieman->GetY();
+  Double_t* x  =  fRieman->GetX();
+  Double_t* y  =  fRieman->GetY();
   Double_t* sy =  fRieman->GetSy();
   for (Int_t i=0; i<nR; i++)
   {
-    fGraphSelected->SetPoint(i, x[i], y[i]);
-    fGraphFitted->SetPoint(i, x[i], fRieman->GetYat(x[i]));
-    fGraphFitted->SetPointError(i, 0.1, sy[i]);
+    fGraphPicked->SetPoint(i, x[i], y[i]);
+    fGraphHelix->SetPoint (i, x[i], fRieman->GetYat(x[i]));
+    fGraphHelix->SetPointError(i, 0.1, sy[i]); // now faked
   }
 
-  if (gPad) gPad->Clear();
-  fGraphSelected->Draw("AP");
-  fGraphFitted->Draw("SAME P");
+  if (gPad)
+    gPad->Clear();
+
+  fGraphPicked->Draw("AP");
+  fGraphHelix->Draw("SAME P");
   gPad->GetCanvas()->SetTitle(Form("AliRieman alpha: %f", fAlpha));
   gPad->Modified();
   gPad->Update();
index 3e93ccdc575283f14ea36c43427223d44d8ba07e..1a52b927c7cbf484bf043027f257fa28336908b2 100644 (file)
@@ -11,7 +11,6 @@
 #define ALIEVE_TrackFitter_H
 
 #include <TEvePointSet.h>
-#include <TQObject.h>
 #include <map>
 
 class TGraphErrors;
@@ -20,63 +19,66 @@ class AliRieman;
 
 class TEveTrackList;
 
-
 class AliEveTrackFitter : public TEvePointSet
 {
 private:
   AliEveTrackFitter(const AliEveTrackFitter&);            // Not implemented
   AliEveTrackFitter& operator=(const AliEveTrackFitter&); // Not implemented
 
-  TGraph       *fGraphSelected;  // graph of selected points
-  TGraphErrors *fGraphFitted;    // graph of fitted points
-
 protected:
+
   struct Point_t
   {
-    // inner structure to check duplicates
-    TEvePointSet   *fPS;   // selected pointset
-    Int_t           fIdx;  // location in the point set array
+    TEvePointSet   *fPS;   // point set
+    Int_t           fIdx;  // id in point set
 
-    Point_t(TEvePointSet* ps, Int_t i) : fPS(ps), fIdx(i) {}
+    Point_t(TEvePointSet* ps=0, Int_t i=0) : fPS(ps), fIdx(i) {}
     Point_t(const Point_t& p) : fPS(p.fPS), fIdx(p.fIdx)  {}
-    Point_t& operator=(const Point_t& p)
-    { fPS = p.fPS; fIdx = p.fIdx; return *this; }
 
-    bool operator<(const Point_t& o) const
-    { if (fPS != o.fPS) return fPS < o.fPS; return fIdx < o.fIdx; }
+    Point_t& operator=(const Point_t& p) {
+      fPS = p.fPS; fIdx = p.fIdx; return *this;
+    }
+
+    bool operator<(const Point_t& o) const {
+      if (fPS != o.fPS) return fPS < o.fPS;
+      return fIdx < o.fIdx;
+    }
   };
 
-  Float_t    fAlpha;                // transformation agle to local system (where x>>y)
-  AliRieman* fRieman;               // rieman fitter
+  typedef std::map<Point_t, Int_t>          PointMap_t;
+
+  Float_t            fAlpha;                // transformation angle to AliRieman local system (where x>>y)
+  AliRieman*         fRieman;               // rieman fitter
 
-  Bool_t     fConnected;            // object connected to pointset Ctrl-shift signal
+  Bool_t             fConnected;            // connection to the TEvePointSet signal
 
-  TEveTrackList* fTrackList;        // track list created with rieman fit
+  PointMap_t         fSPMap;                // map of selected points
+  TEveTrackList*     fTrackList;            // list of tracks removed in the destructor
 
-  std::map<Point_t, Int_t> fMapPS;  // map of selected points from different TEvePointSet
+  TGraph            *fGraphPicked;          // graph of selected points debug info
+  TGraphErrors      *fGraphHelix;           // graph of fitted points for debug info
 
 public:
-  AliEveTrackFitter(const Text_t* name, Int_t n_points=0);
+  AliEveTrackFitter(const Text_t* name = "TrackFitter", Int_t n_points=0);
   virtual ~AliEveTrackFitter();
 
-  virtual void AddFitPoint(TEvePointSet*,Int_t);  // slot for PointCtrlClicked() signal
-
-  virtual void DestroyElements();   // *MENU*
+  virtual void  AddFitPoint(TEvePointSet*,Int_t);  // slot for PointCtrlClicked() signal
 
-  virtual void Start();
-  virtual void Stop();
-  virtual void FitTrack();
-  virtual void Reset(Int_t n_points=0, Int_t n_int_ids=0);
+  virtual void  Start();
+  virtual void  Stop();
+  virtual void  FitTrack();
+  virtual void  Reset(Int_t n_points=0, Int_t n_int_ids=0);
 
   Bool_t        GetConnected(){ return fConnected; }
   AliRieman*    GetRieman(){ return fRieman; }
 
-  void          DrawRiemanGraph();
+  TGraph*       GetGraphPicked()   { return fGraphPicked; }
+  TGraphErrors* GetGraphHelix()    { return fGraphHelix; }
+  void          DrawDebugGraph();
 
-  TGraph*       GetGraphSelected() { return fGraphSelected; }
-  TGraphErrors* GetGraphFitted()   { return fGraphFitted; }
+  virtual void  DestroyElements();   // *MENU*
 
-  ClassDef(AliEveTrackFitter, 0); // Interface to AliRieman fit.
-}; // endclass AliEveTrackFitter
+  ClassDef(AliEveTrackFitter, 0); // Interface of TEvePointSet allowing helix fit.
+};
 
 #endif
index c9e33873941db16d1841c2ddd526bacddd9c3120..10dba9526a43ddb5cca6626000dde4159bc6c189 100644 (file)
@@ -20,7 +20,7 @@
 ClassImp(AliEveTrackFitterEditor)
 
 AliEveTrackFitterEditor::AliEveTrackFitterEditor(const TGWindow *p, Int_t width, Int_t height,
-            UInt_t options, Pixel_t back) :
+    UInt_t options, Pixel_t back) :
   TGedFrame(p, width, height, options | kVerticalFrame, back),
   fM(0),
   fFit(0),
@@ -34,7 +34,7 @@ AliEveTrackFitterEditor::AliEveTrackFitterEditor(const TGWindow *p, Int_t width,
   MakeTitle("AliEveTrackFitter");
 
   fStart = new TGTextButton(this, "Start");
-  AddFrame(fStart, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 4, 1, 1, 1));
+  AddFrame(fStart, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 4, 1, 3, 1));
   fStart->Connect("Clicked()",
                   "AliEveTrackFitterEditor", this, "DoStart()");
 
@@ -49,12 +49,12 @@ AliEveTrackFitterEditor::AliEveTrackFitterEditor(const TGWindow *p, Int_t width,
                   "AliEveTrackFitterEditor", this, "DoReset()");
 
   fStop = new TGTextButton(this, "Stop");
-  AddFrame(fStop, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 4, 1, 1, 1));
+  AddFrame(fStop, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 4, 1, 1, 4));
   fStop->Connect("Clicked()",
                  "AliEveTrackFitterEditor", this, "DoStop()");
 
-  fGraph = new TGTextButton(this, " RiemanGraph ");
-  AddFrame(fGraph, new TGLayoutHints(kLHintsLeft, 4, 2, 4, 1));
+  fGraph = new TGTextButton(this, "DebugGraph");
+  AddFrame(fGraph, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 4, 2, 4, 1));
   fGraph->Connect("Clicked()",
                  "AliEveTrackFitterEditor", this, "DoGraph()");
  }
@@ -80,6 +80,8 @@ void AliEveTrackFitterEditor::SetModel(TObject* obj)
   }
 }
 
+/**************************************************************************/
+
 void AliEveTrackFitterEditor::DoFit()
 {
   // Fit slot.
@@ -114,12 +116,10 @@ void AliEveTrackFitterEditor::DoStop()
   fStart->SetState(kButtonUp);
 }
 
-/******************************************************************************/
-
 void AliEveTrackFitterEditor::DoGraph()
 {
   // Draw graph slot.
 
-  fM->DrawRiemanGraph();
+  fM->DrawDebugGraph();
   Update();
 }
index df9dc53c03e47c70ee52431d7c5485967869b539..3de6027bd6e2f9fab757d40592635cec66238978 100644 (file)
@@ -28,11 +28,11 @@ private:
 protected:
   AliEveTrackFitter* fM; // fModel dynamic-casted to AliEveTrackFitterEditor
 
-  TGTextButton* fFit;   // button to fit selection
-  TGTextButton* fReset; // button to reset selection
-  TGTextButton* fStart; // button to connect to signal
-  TGTextButton* fStop;  // button to disconnect from signal
-  TGTextButton* fGraph; // button to draw graph
+  TGTextButton* fFit;    // button to fit selection
+  TGTextButton* fReset;  // button to reset selection
+  TGTextButton* fStart;  // button to connect to signal
+  TGTextButton* fStop;   // button to disconnect from signal
+  TGTextButton* fGraph;  // button to draw graph
 
 public:
   AliEveTrackFitterEditor(const TGWindow* p=0, Int_t width=170, Int_t height=30, UInt_t options = kChildFrame, Pixel_t back=GetDefaultFrameBackground());
@@ -47,6 +47,6 @@ public:
   void DoGraph();
 
   ClassDef(AliEveTrackFitterEditor, 0); // Editor for AliEveTrackFitter class.
-}; // endclass AliEveTrackFitterEditor
+};
 
 #endif