Added class TrackCounter; Track now inherits from TQObject and emits a Clicked()...
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 4 Dec 2006 11:26:36 +0000 (11:26 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 4 Dec 2006 11:26:36 +0000 (11:26 +0000)
EVE/Reve/Track.cxx
EVE/Reve/Track.h

index 2edcc20..4ee0be2 100644 (file)
@@ -234,6 +234,13 @@ void Track::ImportClusters()
   gROOT->ProcessLine(Form("clusters_from_label(%d);", fLabel));
 }
 
+/**************************************************************************/
+
+void Track::CtrlClicked(Reve::Track* track)
+{
+  Emit("CtrlClicked(Reve::Track*)", (Long_t)track);
+}
+
 
 /**************************************************************************/
 /**************************************************************************/
@@ -330,7 +337,7 @@ void TrackList::Paint(Option_t* option)
       TPolyMarker3D::Paint(option);
     }
     if(fRnrTracks) {
-      for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
+      for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
        if((*i)->GetRnrElement())
          (*i)->GetObject()->Paint(option);
       }
@@ -367,7 +374,7 @@ void TrackList::SetRnrTracks(Bool_t rnr)
 
 void TrackList::MakeTracks()
 {
-  for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
+  for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
     ((Track*)(*i))->MakeTrack();
   }
   gReve->Redraw3D();
@@ -377,7 +384,7 @@ void TrackList::MakeTracks()
 void TrackList::MakeMarkers()
 {
   Reset(fChildren.size());
-  for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
+  for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
     Track& t = *((Track*)(*i));
     if(t.GetN() > 0)
       SetNextPoint(t.fV.x, t.fV.y, t.fV.z);
@@ -392,7 +399,7 @@ void TrackList::SetWidth(Width_t w)
 {
   Width_t oldw = fRnrStyle->fWidth;
   fRnrStyle->fWidth = w;
-  for (lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
+  for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
     Track& t = *((Track*)(*i));
     if (t.GetLineWidth() == oldw)
       t.SetLineWidth(w);
@@ -452,7 +459,7 @@ void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt)
   Float_t maxptsq = max_pt*max_pt;
   Float_t ptsq;
 
-  for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
+  for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
     ptsq = ((Track*)(*i))->fP.Perp2();
     (*i)->SetRnrElement(ptsq >= minptsq && ptsq <= maxptsq);
   }
@@ -462,14 +469,128 @@ void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt)
 
 void TrackList::ImportHits()
 {
-  for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
+  for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
     ((Track*)(*i))->ImportHits();
   }
 }
 
 void TrackList::ImportClusters()
 {
-  for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
+  for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
     ((Track*)(*i))->ImportClusters();
   }
 }
+
+/**************************************************************************/
+/**************************************************************************/
+/**************************************************************************/
+
+#include "RGEditor.h"
+
+//______________________________________________________________________
+// TrackCounter
+//
+
+ClassImp(TrackCounter)
+
+TrackCounter::TrackCounter(const Text_t* name, const Text_t* title) :
+  RenderElement(),
+  TNamed(name, title),
+
+  fBadLineStyle (6),
+  fClickAction  (CA_ToggleTrack),
+  fAllTracks    (0),
+  fGoodTracks   (0),
+  fTrackLists   ()
+{
+  TQObject::Connect("Reve::Track", "CtrlClicked(Reve::Track*)",
+                   "Reve::TrackCounter", this, "DoTrackAction(Reve::Track*)");
+}
+
+TrackCounter::~TrackCounter()
+{
+  TQObject::Disconnect("Reve::Track", "DoTrackAction(Reve::Track*)");
+}
+
+/**************************************************************************/
+
+void TrackCounter::Reset()
+{
+  printf("TrackCounter::Reset()\n");
+  fAllTracks  = 0;
+  fGoodTracks = 0;
+  TIter next(&fTrackLists);
+  TrackList* tlist;
+  while ((tlist = dynamic_cast<TrackList*>(next())))
+    tlist->RemoveParent(this);
+  fTrackLists.Clear();
+}
+
+void TrackCounter::RegisterTracks(TrackList* tlist, Bool_t goodTracks)
+{
+  // printf("TrackCounter::RegisterTracks '%s', %s\n",
+  //   tlist->GetObject()->GetName(), goodTracks ? "good" : "bad");
+
+  tlist->AddParent(this);
+  fTrackLists.Add(tlist);
+
+  List_i i = tlist->BeginChildren();
+  while (i != tlist->EndChildren())
+  {
+    Track* t = dynamic_cast<Track*>(*i);
+    if (t != 0)
+    {
+      if (goodTracks)
+      {
+       ++fGoodTracks;
+      } else {
+       t->SetLineStyle(fBadLineStyle);
+      }
+      ++fAllTracks;
+    }
+    ++i;
+  }
+}
+
+void TrackCounter::DoTrackAction(Track* track)
+{
+  // !!!! No check done if ok.
+  // !!!! Should also override RemoveElementLocal
+  // !!!! But then ... should also sore local information if track is ok.
+
+  switch (fClickAction)
+  {
+
+    case CA_PrintTrackInfo:
+    {
+      printf("Track '%s'\n", track->GetObject()->GetName());
+      Vector &v = track->fV, &p = track->fP;
+      printf("  Vx=%f, Vy=%f, Vz=%f; Pt=%f, Pz=%f, phi=%f)\n",
+            v.x, v.y, v.z, p.Perp(), p.z, TMath::RadToDeg()*p.Phi());
+      printf("  <other information should be printed ... full AliESDtrack>\n");
+      break;
+    }
+
+    case CA_ToggleTrack:
+    {
+      if (track->GetLineStyle() == 1)
+      {
+       track->SetLineStyle(fBadLineStyle);
+       --fGoodTracks;
+      } else {
+       track->SetLineStyle(1);
+       ++fGoodTracks;
+      }
+      gReve->Redraw3D();
+
+      printf("TrackCounter::CountTrack All=%d, Good=%d, Bad=%d\n",
+            fAllTracks, fGoodTracks, fAllTracks-fGoodTracks);
+
+      if (gReve->GetEditor()->GetModel() == GetObject())
+       gReve->EditRenderElement(this);
+
+      break;
+    }
+
+  } // end switch fClickAction
+}
index f50ec3e..44118b3 100644 (file)
@@ -15,9 +15,10 @@ namespace Reve {
 class TrackRnrStyle;
 class TrackList;
 
-class Track : public Line
+class Track : public Line, public TQObject
 {
   friend class TrackList;
+  friend class TrackCounter;
 
   Track(const Track&);            // Not implemented
   Track& operator=(const Track&); // Not implemented
@@ -55,6 +56,10 @@ public:
   void ImportHits();     // *MENU*
   void ImportClusters(); // *MENU*
 
+  //--------------------------------
+
+  void CtrlClicked(Reve::Track*); // *SIGNAL*
+
   ClassDef(Track, 1);
 }; // endclass Track
 
@@ -71,7 +76,7 @@ public:
 // TrackList has Get/Set methods for RnrStlye and
 // TrackListEditor provides editor access to them.
 
-class TrackRnrStyle : public TObject 
+class TrackRnrStyle : public TObject
 {
 public:
   Color_t                  fColor;
@@ -185,6 +190,46 @@ public:
   ClassDef(TrackList, 1);
 };
 
+/**************************************************************************/
+// TrackCounter
+/**************************************************************************/
+
+class TrackCounter : public RenderElement, public TNamed
+{
+  friend class TrackCounterEditor;
+
+public:
+  enum ClickAction_e { CA_PrintTrackInfo, CA_ToggleTrack };
+
+private:
+  TrackCounter(const TrackCounter&);            // Not implemented
+  TrackCounter& operator=(const TrackCounter&); // Not implemented
+
+protected:
+  Int_t fBadLineStyle;
+  Int_t fClickAction;
+
+  Int_t fAllTracks;
+  Int_t fGoodTracks;
+
+  TList fTrackLists;
+
+public:
+  TrackCounter(const Text_t* name="TrackCounter", const Text_t* title="");
+  virtual ~TrackCounter();
+
+  void Reset();
+
+  void RegisterTracks(TrackList* tlist, Bool_t goodTracks);
+
+  void DoTrackAction(Track* track);
+
+  Int_t GetClickAction() const  { return fClickAction; }
+  void  SetClickAction(Int_t a) { fClickAction = a; }
+
+  ClassDef(TrackCounter, 1);
+}; // endclass TrackCounter
+
 
 } // namespace Reve