AliEveTrackCounter, AliEveTrackCounterEditor
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 7 Aug 2008 17:35:28 +0000 (17:35 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 7 Aug 2008 17:35:28 +0000 (17:35 +0000)
--------------------------------------------
Moved class TEveTrackCounter from ROOT to EveBase as it is ALICE
specific.

AliEveEventManager
------------------
Derive also from TQObject, emit NewEventLoaded signal.

AliEveEventManagerEditor
------------------------
Add new GUI class AliEveEventManagerWindow that provides event
naviagation in a horizontally shaped main window.

visscan_init.C
--------------
Embed AliEveEventManagerWindow in the bottom section of the ROOT
browser.

AliEveT0Module
--------------
Fix compilation warning.

12 files changed:
EVE/EveBase/AliEveEventManager.cxx
EVE/EveBase/AliEveEventManager.h
EVE/EveBase/AliEveEventManagerEditor.cxx
EVE/EveBase/AliEveEventManagerEditor.h
EVE/EveBase/AliEveTrackCounter.cxx [new file with mode: 0644]
EVE/EveBase/AliEveTrackCounter.h [new file with mode: 0644]
EVE/EveBase/AliEveTrackCounterEditor.cxx [new file with mode: 0644]
EVE/EveBase/AliEveTrackCounterEditor.h [new file with mode: 0644]
EVE/EveBase/LinkDef.h
EVE/EveDet/AliEveT0Module.cxx
EVE/macros/trackcount_init.C
EVE/macros/visscan_init.C

index 9a08ea5..f4f9853 100644 (file)
@@ -321,7 +321,7 @@ void AliEveEventManager::SetEvent(AliRunLoader *runLoader, AliRawReader *rawRead
   AfterNewEventLoaded();
 }
 
-Int_t AliEveEventManager::GetMaxEventId(Bool_t refreshESD) const
+Int_t AliEveEventManager::GetMaxEventId(Bool_t /*refreshESD*/) const
 {
   // Returns maximum available event id.
   // If raw-data is the only data-source this can not be known
@@ -332,15 +332,18 @@ Int_t AliEveEventManager::GetMaxEventId(Bool_t refreshESD) const
 
   static const TEveException kEH("AliEveEventManager::GetMaxEventId ");
 
-  if (fRunLoader)
+  if (fESDTree)
   {
-    return fRunLoader->GetNumberOfEvents() - 1;
+    // Refresh crashes with root-5.21.1-alice.
+    // Fixed by Philippe 5.8.2008 r25053, can be reactivated
+    // when we move to a newer root.
+    // if (refreshESD)
+    //   fESDTree->Refresh();
+    return fESDTree->GetEntries() - 1;
   }
-  else if (fESDTree)
+  else if (fRunLoader)
   {
-    if (refreshESD)
-      fESDTree->Refresh();
-    return fESDTree->GetEntries() - 1;
+    return fRunLoader->GetNumberOfEvents() - 1;
   }
   else if (fRawReader)
   {
@@ -457,6 +460,7 @@ void AliEveEventManager::GotoEvent(Int_t event)
   ElementChanged();
 
   AfterNewEventLoaded();
+  NewEventLoaded();
 }
 
 void AliEveEventManager::NextEvent()
@@ -471,8 +475,7 @@ void AliEveEventManager::NextEvent()
     DestroyElements();
 
     gSystem->ExitLoop();
-  }
-  else {
+  } else {
     if (fEventId < GetMaxEventId(kTRUE))
       GotoEvent(fEventId + 1);
     else
@@ -645,18 +648,28 @@ void AliEveEventManager::StartStopAutoLoadTimer()
 {
   // Create if needed and start
   // the automatic event loading timer
-  if (fAutoLoad) {
-    if (!fAutoLoadTimer) {
+  if (fAutoLoad)
+  {
+    if (!fAutoLoadTimer)
+    {
       fAutoLoadTimer = new TTimer;
       fAutoLoadTimer->Connect("Timeout()","AliEveEventManager",this,"NextEvent()");
     }
     fAutoLoadTimer->Start((Long_t)fAutoLoadTime*1000,kTRUE);
   }
-  else {
+  else
+  {
     if (fAutoLoadTimer) fAutoLoadTimer->Stop();
   }
 }
 
+void AliEveEventManager::NewEventLoaded()
+{
+  // Emit NewEventLoaded signal.
+
+  Emit("NewEventLoaded()");
+}
+
 const char* AliEveEventManager::GetEventInfo() const
 {
   // Dumps the event-header contents
index 267bc3d..91e8e4d 100644 (file)
@@ -11,6 +11,7 @@
 #define AliEveEventManager_H
 
 #include <TEveEventManager.h>
+#include <TQObject.h>
 
 class AliRunLoader;
 class AliESDEvent;
@@ -32,7 +33,8 @@ class TGeoManager;
 //
 
 
-class AliEveEventManager : public TEveEventManager
+class AliEveEventManager : public TEveEventManager,
+                           public TQObject
 {
 public:
   static void SetESDFileName(const Text_t* esd);
@@ -47,7 +49,7 @@ public:
 
   virtual void  Open();
   void          SetEvent(AliRunLoader *runLoader, AliRawReader *rawReader, AliESDEvent *esd);
-  virtual Int_t GetMaxEventId(Bool_t refreshESD=kFALSE) const;     
+  virtual Int_t GetMaxEventId(Bool_t refreshESD=kFALSE) const;
   virtual void  GotoEvent(Int_t event);
   virtual void  NextEvent();
   virtual void  PrevEvent();
@@ -80,6 +82,8 @@ public:
 
   void          StartStopAutoLoadTimer();
 
+  void          NewEventLoaded(); // *SIGNAL*
+
 protected:
   TString       fPath;                 // URL to event-data.
   Int_t         fEventId;              // Id of current event.
index 579fd2e..799286b 100644 (file)
@@ -178,3 +178,129 @@ void AliEveEventManagerEditor::DoRefresh()
   fM->Open();
   fM->GotoEvent(ev);
 }
+
+
+/******************************************************************************/
+// AliEveEventManagerWindow
+/******************************************************************************/
+
+//______________________________________________________________________________
+//
+// Horizontal GUI for AliEveEventManager, to be placed in the
+// bottom part of ROOT browser.
+
+ClassImp(AliEveEventManagerWindow)
+
+AliEveEventManagerWindow::AliEveEventManagerWindow() :
+  TGMainFrame(0, 400, 100, kVerticalFrame),
+  fFirstEvent(0),
+  fPrevEvent(0),
+  fNextEvent(0),
+  fLastEvent(0),
+  fEventId  (0),
+  fInfoLabel(0)
+{
+  // Constructor.
+
+  {
+    Int_t width = 50;
+
+    TGHorizontalFrame* f = new TGHorizontalFrame(this);
+    fFirstEvent = new TGTextButton(f, "First");
+    fFirstEvent->SetWidth(width);
+    fFirstEvent->ChangeOptions(fFirstEvent->GetOptions() | kFixedWidth);
+    f->AddFrame(fFirstEvent, new TGLayoutHints(kLHintsNormal, 2,2,0,0));
+    fFirstEvent->Connect("Clicked()",
+                         "AliEveEventManagerWindow", this, "DoFirstEvent()");
+    fPrevEvent = new TGTextButton(f, "Prev");
+    fPrevEvent->SetWidth(width);
+    fPrevEvent->ChangeOptions(fPrevEvent->GetOptions() | kFixedWidth);
+    f->AddFrame(fPrevEvent, new TGLayoutHints(kLHintsNormal, 2,2,0,0));
+    fPrevEvent->Connect("Clicked()",
+                       "AliEveEventManagerWindow", this, "DoPrevEvent()");
+
+    fEventId = new TGNumberEntry(f, 0, 5, -1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
+                                 TGNumberFormat::kNELLimitMinMax, 0, 10000);
+    f->AddFrame(fEventId, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
+    fEventId->Connect("ValueSet(Long_t)",
+                      "AliEveEventManagerWindow", this, "DoSetEvent()");
+    fInfoLabel = new TGLabel(f);
+    f->AddFrame(fInfoLabel, new TGLayoutHints(kLHintsNormal, 5, 10, 4, 0));
+
+    fNextEvent = new TGTextButton(f, "Next");
+    fNextEvent->SetWidth(width);
+    fNextEvent->ChangeOptions(fNextEvent->GetOptions() | kFixedWidth);
+    f->AddFrame(fNextEvent, new TGLayoutHints(kLHintsNormal, 2,2,0,0));
+    fNextEvent->Connect("Clicked()",
+                       "AliEveEventManagerWindow", this, "DoNextEvent()");
+    fLastEvent = new TGTextButton(f, "Last");
+    fLastEvent->SetWidth(width);
+    fLastEvent->ChangeOptions(fLastEvent->GetOptions() | kFixedWidth);
+    f->AddFrame(fLastEvent, new TGLayoutHints(kLHintsNormal, 2,2,0,0));
+    fLastEvent->Connect("Clicked()",
+                       "AliEveEventManagerWindow", this, "DoLastEvent()");
+    AddFrame(f, new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
+  }
+
+  gAliEveEvent->Connect("NewEventLoaded()",
+                        "AliEveEventManagerWindow", this, "Update()");
+  Update();
+
+  SetCleanup(kDeepCleanup);
+  Layout();
+  MapSubwindows();
+  MapWindow();
+}
+
+//______________________________________________________________________________
+AliEveEventManagerWindow::~AliEveEventManagerWindow()
+{
+  // Destructor.
+
+  gAliEveEvent->Disconnect("NewEventLoaded()", this);
+}
+
+//______________________________________________________________________________
+void AliEveEventManagerWindow::DoFirstEvent()
+{
+  // Load previous event
+  gAliEveEvent->GotoEvent(0);
+}
+
+//______________________________________________________________________________
+void AliEveEventManagerWindow::DoPrevEvent()
+{
+  // Load previous event
+  gAliEveEvent->PrevEvent();
+}
+
+//______________________________________________________________________________
+void AliEveEventManagerWindow::DoNextEvent()
+{
+  // Load next event
+  gAliEveEvent->NextEvent();
+}
+
+//______________________________________________________________________________
+void AliEveEventManagerWindow::DoLastEvent()
+{
+  // Load previous event
+  gAliEveEvent->GotoEvent(-1);
+}
+
+//______________________________________________________________________________
+void AliEveEventManagerWindow::DoSetEvent()
+{
+  // Set current event
+  gAliEveEvent->GotoEvent((Int_t) fEventId->GetNumber());
+}
+
+//______________________________________________________________________________
+void AliEveEventManagerWindow::Update()
+{
+  // Update current event, number of available events.
+
+  fEventId->SetNumber(gAliEveEvent->GetEventId());
+  fInfoLabel->SetText(Form("/ %d", gAliEveEvent->GetMaxEventId()));
+  Layout();
+}
index 70ecfc5..9100855 100644 (file)
 
 #include "TGedFrame.h"
 
-class TGCheckButton;
+class AliEveEventManager;
 class TEveGValuator;
+class TGCheckButton;
 class TGTextView;
-
-class AliEveEventManager;
+class TGNumberEntry;
+class TGLabel;
 
 //______________________________________________________________________________
 // Short description of AliEveEventManagerEditor
@@ -60,4 +61,36 @@ private:
    ClassDef(AliEveEventManagerEditor, 0); // GUI editor for AliEveEventManager.
 };
 
+
+class AliEveEventManagerWindow : public TGMainFrame
+{
+public:
+   AliEveEventManagerWindow();
+   virtual ~AliEveEventManagerWindow();
+
+   void DoFirstEvent();
+   void DoPrevEvent();
+   void DoNextEvent();
+   void DoLastEvent();
+
+   void DoSetEvent();
+
+   void Update();
+
+protected:
+   TGTextButton         *fFirstEvent;
+   TGTextButton         *fPrevEvent;
+   TGTextButton         *fNextEvent;
+   TGTextButton         *fLastEvent;
+
+   TGNumberEntry        *fEventId;
+   TGLabel              *fInfoLabel;
+
+private:
+   AliEveEventManagerWindow(const AliEveEventManagerWindow&);            // Not implemented
+   AliEveEventManagerWindow& operator=(const AliEveEventManagerWindow&); // Not implemented
+
+   ClassDef(AliEveEventManagerWindow, 0); // GUI window for AliEveEventManager.
+};
+
 #endif
diff --git a/EVE/EveBase/AliEveTrackCounter.cxx b/EVE/EveBase/AliEveTrackCounter.cxx
new file mode 100644 (file)
index 0000000..c507962
--- /dev/null
@@ -0,0 +1,199 @@
+// @(#)root/eve:$Id$
+// Author: Matevz Tadel 2007
+
+/**************************************************************************
+ * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
+ * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
+ * full copyright notice.                                                 *
+ **************************************************************************/
+
+#include "AliEveTrackCounter.h"
+
+#include "TEveManager.h"
+#include "TEveTrack.h"
+#include "TEveGedEditor.h"
+
+//==============================================================================
+// AliEveTrackCounter
+//==============================================================================
+
+//______________________________________________________________________________
+//
+// Provides event-based method for tagging of good / bad (or primary /
+// secondary) tracks. A report can be written into a text file.
+//
+// TEveTrack status is toggled by using secondary-selection / ctrl-click
+// functionality of the GL viewer.
+//
+// Some of the functionality is implemented in AliEveTrackCounterEditor
+// class.
+
+ClassImp(AliEveTrackCounter)
+
+//______________________________________________________________________________
+AliEveTrackCounter* AliEveTrackCounter::fgInstance = 0;
+
+//______________________________________________________________________________
+AliEveTrackCounter::AliEveTrackCounter(const Text_t* name, const Text_t* title) :
+   TEveElement(),
+   TNamed(name, title),
+
+   fBadLineStyle (6),
+   fClickAction  (kCA_ToggleTrack),
+   fAllTracks    (0),
+   fGoodTracks   (0),
+   fTrackLists   ()
+{
+   // Constructor.
+   // Connects to global signal "TEveTrack", "SecSelected(TEveTrack*)".
+
+   if (fgInstance == 0) fgInstance = this;
+   TQObject::Connect("TEveTrack", "SecSelected(TEveTrack*)",
+                     "AliEveTrackCounter", this, "DoTrackAction(TEveTrack*)");
+}
+
+//______________________________________________________________________________
+AliEveTrackCounter::~AliEveTrackCounter()
+{
+   // Destructor.
+   // Disconnect from the global track signals.
+
+   TQObject::Disconnect("TEveTrack", "DoTrackAction(TEveTrack*)");
+   if (fgInstance == this) fgInstance = 0;
+}
+
+/******************************************************************************/
+
+//______________________________________________________________________________
+void AliEveTrackCounter::Reset()
+{
+   // Reset internal track-counters and track-list.
+
+   printf("AliEveTrackCounter::Reset()\n");
+   fAllTracks  = 0;
+   fGoodTracks = 0;
+   TIter next(&fTrackLists);
+   TEveTrackList* tlist;
+   while ((tlist = dynamic_cast<TEveTrackList*>(next())))
+      tlist->DecDenyDestroy();
+   fTrackLists.Clear("nodelete");
+}
+
+//______________________________________________________________________________
+void AliEveTrackCounter::RegisterTracks(TEveTrackList* tlist, Bool_t goodTracks)
+{
+   // Register tracks from tlist and tlist itself.
+   // If goodTracks is true, they are considered as primary/good
+   // tracks.
+
+   tlist->IncDenyDestroy();
+   fTrackLists.Add(tlist);
+
+   List_i i = tlist->BeginChildren();
+   while (i != tlist->EndChildren())
+   {
+      TEveTrack* t = dynamic_cast<TEveTrack*>(*i);
+      if (t != 0)
+      {
+         if (goodTracks)
+         {
+            ++fGoodTracks;
+         } else {
+            t->SetLineStyle(fBadLineStyle);
+         }
+         ++fAllTracks;
+      }
+      ++i;
+   }
+}
+
+//______________________________________________________________________________
+void AliEveTrackCounter::DoTrackAction(TEveTrack* track)
+{
+   // Slot called when track is ctrl-clicked.
+   //
+   // No check is done if track actually belongs to one of the
+   // registered track-lists.
+   //
+   // Probably it would be safer to copy good/bad tracks into special
+   // sub-containers.
+   // In this case one should also override RemoveElementLocal.
+
+   static const TEveException eh("AliEveTrackCounter::DoTrackAction ");
+
+   switch (fClickAction)
+   {
+
+      case kCA_PrintTrackInfo:
+      {
+         printf("TEveTrack '%s'\n", track->GetObject(eh)->GetName());
+         const TEveVector &v = track->GetVertex();
+         const TEveVector &p = track->GetMomentum();;
+         printf("  Vx=%f, Vy=%f, Vz=%f; Pt=%f, Pz=%f, phi=%f)\n",
+                v.fX, v.fY, v.fZ, p.Perp(), p.fZ, TMath::RadToDeg()*p.Phi());
+         printf("  <other information should be printed ... full AliESDtrack>\n");
+         break;
+      }
+
+      case kCA_ToggleTrack:
+      {
+         if (track->GetLineStyle() == 1)
+         {
+            track->SetLineStyle(fBadLineStyle);
+            --fGoodTracks;
+         } else {
+            track->SetLineStyle(1);
+            ++fGoodTracks;
+         }
+         track->ElementChanged();
+         gEve->Redraw3D();
+
+         printf("AliEveTrackCounter::CountTrack All=%d, Good=%d, Bad=%d\n",
+                fAllTracks, fGoodTracks, fAllTracks-fGoodTracks);
+
+         if (gEve->GetEditor()->GetModel() == GetObject(eh))
+            gEve->EditElement(this);
+
+         break;
+      }
+
+   } // end switch fClickAction
+}
+
+/******************************************************************************/
+
+//______________________________________________________________________________
+void AliEveTrackCounter::OutputEventTracks(FILE* out)
+{
+   // Print good-track summary into a plain-text file by iteration
+   // through all registered track-lists.
+   // State of each track is determined by its line-style, it is
+   // considered a good track if it's line style is solid.
+
+   if (out == 0)
+   {
+      out = stdout;
+      fprintf(out, "AliEveTrackCounter::FinalizeEvent()\n");
+   }
+
+   fprintf(out, "Event = %d  Ntracks = %d\n", fEventId, fGoodTracks);
+
+   TIter tlists(&fTrackLists);
+   TEveTrackList* tlist;
+   Int_t cnt = 0;
+   while ((tlist = (TEveTrackList*) tlists()) != 0)
+   {
+      List_i i = tlist->BeginChildren();
+      while (i != tlist->EndChildren())
+      {
+         TEveTrack* t = dynamic_cast<TEveTrack*>(*i);
+         if (t != 0 && t->GetLineStyle() == 1)
+         {
+            ++cnt;
+            fprintf(out, " %2d: chg=%+2d  pt=%8.5f  eta=%+8.5f\n",
+                    cnt, t->GetCharge(), t->GetMomentum().Perp(), t->GetMomentum().Eta());
+         }
+         ++i;
+      }
+   }
+}
diff --git a/EVE/EveBase/AliEveTrackCounter.h b/EVE/EveBase/AliEveTrackCounter.h
new file mode 100644 (file)
index 0000000..32afbc1
--- /dev/null
@@ -0,0 +1,67 @@
+// @(#)root/eve:$Id$
+// Author: Matevz Tadel 2007
+
+/**************************************************************************
+ * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
+ * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
+ * full copyright notice.                                                 *
+ **************************************************************************/
+
+#ifndef AliEveTrackCounter_H
+#define AliEveTrackCounter_H
+
+#include "TEveElement.h"
+#include "TList.h"
+
+class TEveTrack;
+class TEveTrackList;
+
+//______________________________________________________________________________
+// Short description of AliEveTrackCounter
+//
+
+class AliEveTrackCounter :  public TEveElement, public TNamed
+{
+  friend class AliEveTrackCounterEditor;
+
+public:
+  enum EClickAction_e { kCA_PrintTrackInfo, kCA_ToggleTrack };
+
+  AliEveTrackCounter(const Text_t* name="AliEveTrackCounter", const Text_t* title="");
+  virtual ~AliEveTrackCounter();
+
+  Int_t GetEventId() const { return fEventId; }
+  void  SetEventId(Int_t id) { fEventId = id; }
+
+  void Reset();
+
+  void RegisterTracks(TEveTrackList* tlist, Bool_t goodTracks);
+
+  void DoTrackAction(TEveTrack* track);
+
+  Int_t GetClickAction() const  { return fClickAction; }
+  void  SetClickAction(Int_t a) { fClickAction = a; }
+
+  void OutputEventTracks(FILE* out=0);
+
+  static AliEveTrackCounter* fgInstance;
+
+protected:
+  Int_t fBadLineStyle;  // TEveLine-style used for secondary/bad tracks.
+  Int_t fClickAction;   // Action to take when a track is ctrl-clicked.
+
+  Int_t fEventId;       // Current event-id.
+
+  Int_t fAllTracks;     // Counter of all tracks.
+  Int_t fGoodTracks;    // Counter of good tracks.
+
+  TList fTrackLists;    // List of TrackLists registered for management.
+
+private:
+  AliEveTrackCounter(const AliEveTrackCounter&);            // Not implemented
+  AliEveTrackCounter& operator=(const AliEveTrackCounter&); // Not implemented
+
+  ClassDef(AliEveTrackCounter, 0); // Class for selection of good/primary tracks with basic processing functionality.
+};
+
+#endif
diff --git a/EVE/EveBase/AliEveTrackCounterEditor.cxx b/EVE/EveBase/AliEveTrackCounterEditor.cxx
new file mode 100644 (file)
index 0000000..61fb1e3
--- /dev/null
@@ -0,0 +1,286 @@
+// @(#)root/eve:$Id$
+// Author: Matevz Tadel 2007
+
+/**************************************************************************
+ * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
+ * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
+ * full copyright notice.                                                 *
+ **************************************************************************/
+
+#include "AliEveTrackCounterEditor.h"
+#include "AliEveTrackCounter.h"
+
+#include "TVirtualPad.h"
+#include "TColor.h"
+
+// Cleanup these includes:
+#include "TGLabel.h"
+#include "TGNumberEntry.h"
+#include "TGComboBox.h"
+#include "TGMsgBox.h"
+
+#include "TH1F.h"
+
+#include "TCanvas.h"
+#include "TEveManager.h"
+
+#include "TROOT.h"
+#include "TSystem.h" // File input/output for track-count status.
+
+//______________________________________________________________________________
+// GUI editor for AliEveTrackCounter.
+//
+
+ClassImp(AliEveTrackCounterEditor)
+
+//______________________________________________________________________________
+AliEveTrackCounterEditor::AliEveTrackCounterEditor(const TGWindow *p, Int_t width, Int_t height,
+                                               UInt_t options, Pixel_t back) :
+   TGedFrame(p, width, height, options | kVerticalFrame, back),
+   fM(0),
+   fClickAction (0),
+   fInfoLabel   (0),
+   fEventId     (0)
+{
+   // Constructor.
+
+   MakeTitle("AliEveTrackCounter");
+
+   Int_t labelW = 42;
+
+   { // ClickAction
+      TGHorizontalFrame* f = new TGHorizontalFrame(this);
+      TGLabel* lab = new TGLabel(f, "Click:");
+      f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 10, 1, 2));
+      fClickAction = new TGComboBox(f);
+      fClickAction->AddEntry("Print", 0);
+      fClickAction->AddEntry("Toggle", 1);
+      TGListBox* lb = fClickAction->GetListBox();
+      lb->Resize(lb->GetWidth(), 2*16);
+      fClickAction->Resize(70, 20);
+      fClickAction->Connect("Selected(Int_t)", "AliEveTrackCounterEditor", this,
+                            "DoClickAction(Int_t)");
+      f->AddFrame(fClickAction, new TGLayoutHints(kLHintsLeft, 1, 2, 1, 1));
+
+      AddFrame(f);
+   }
+
+   { // Status
+      TGHorizontalFrame* f = new TGHorizontalFrame(this);
+      TGLabel* lab = new TGLabel(f, "Status:");
+      f->AddFrame(lab, new TGLayoutHints(kLHintsLeft, 1, 5, 1, 2));
+
+      fInfoLabel = new TGLabel(f);
+      f->AddFrame(fInfoLabel, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 9, 1, 2));
+
+      AddFrame(f);
+   }
+
+   {
+      TGHorizontalFrame* f = new TGHorizontalFrame(this, 210, 20, kFixedWidth);
+
+      TGHorizontalFrame* g = new TGHorizontalFrame(f, labelW, 0, kFixedWidth);
+      TGLabel* l = new TGLabel(g, "Event:");
+      g->AddFrame(l, new TGLayoutHints(kLHintsLeft, 0,0,4,0));
+      f->AddFrame(g);
+
+      TGTextButton* b;
+
+      b = new TGTextButton(f, "Prev");
+      f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
+      b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoPrev()");
+
+      fEventId = new TGNumberEntry(f, 0, 3, -1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
+                                   TGNumberFormat::kNELLimitMinMax, 0, 10000);
+      f->AddFrame(fEventId, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
+      fEventId->Connect("ValueSet(Long_t)", "AliEveTrackCounterEditor", this, "DoSetEvent()");
+
+      b = new TGTextButton(f, "Next");
+      f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
+      b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoNext()");
+
+      AddFrame(f);
+   }
+
+   {
+      TGHorizontalFrame* f = new TGHorizontalFrame(this, 210, 20, kFixedWidth);
+
+      TGHorizontalFrame* g = new TGHorizontalFrame(f, labelW, 0, kFixedWidth);
+      TGLabel* l = new TGLabel(g, "Report:");
+      g->AddFrame(l, new TGLayoutHints(kLHintsLeft, 0,0,4,0));
+      f->AddFrame(g);
+
+      TGTextButton* b;
+
+      b = new TGTextButton(f, "Print");
+      f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
+      b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoPrintReport()");
+
+      b = new TGTextButton(f, "File");
+      f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
+      b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoFileReport()");
+
+      AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 4, 0));
+   }
+   {
+      TGHorizontalFrame* f = new TGHorizontalFrame(this, 210, 20, kFixedWidth);
+
+      TGHorizontalFrame* g = new TGHorizontalFrame(f, labelW, 0, kFixedWidth);
+      TGLabel* l = new TGLabel(g, "Histos:");
+      g->AddFrame(l, new TGLayoutHints(kLHintsLeft, 0,0,4,0));
+      f->AddFrame(g);
+
+      TGTextButton* b;
+
+      b = new TGTextButton(f, "Show");
+      f->AddFrame(b, new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 1, 1, 0, 0));
+      b->Connect("Clicked()", "AliEveTrackCounterEditor", this, "DoShowHistos()");
+
+      AddFrame(f, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
+   }
+
+}
+
+/******************************************************************************/
+
+//______________________________________________________________________________
+void AliEveTrackCounterEditor::SetModel(TObject* obj)
+{
+   // Set model object.
+
+   fM = dynamic_cast<AliEveTrackCounter*>(obj);
+
+   fClickAction->Select(fM->fClickAction, kFALSE);
+   fInfoLabel->SetText(Form("All: %3d; Primaries: %3d", fM->fAllTracks, fM->fGoodTracks));
+   fEventId->SetNumber(fM->GetEventId());
+}
+
+/******************************************************************************/
+
+//______________________________________________________________________________
+void AliEveTrackCounterEditor::DoPrev()
+{
+   // Slot for Prev.
+
+   TEveUtil::Macro("event_prev.C");
+   gEve->EditElement(fM);
+}
+
+//______________________________________________________________________________
+void AliEveTrackCounterEditor::DoNext()
+{
+   // Slot for Next.
+
+   TEveUtil::Macro("event_next.C");
+   gEve->EditElement(fM);
+}
+
+//______________________________________________________________________________
+void AliEveTrackCounterEditor::DoSetEvent()
+{
+   // Slot for SetEvent.
+
+   TEveUtil::LoadMacro("event_goto.C");
+   gROOT->ProcessLine(Form("event_goto(%d);", (Int_t) fEventId->GetNumber()));
+   gEve->EditElement(fM);
+}
+
+/******************************************************************************/
+
+//______________________________________________________________________________
+void AliEveTrackCounterEditor::DoPrintReport()
+{
+   // Slot for PrintReport.
+
+   fM->OutputEventTracks();
+}
+
+//______________________________________________________________________________
+void AliEveTrackCounterEditor::DoFileReport()
+{
+   // Slot for FileReport.
+
+   TString file(Form("ev-report-%03d.txt", fM->GetEventId()));
+   if (gSystem->AccessPathName(file) == kFALSE)
+   {
+      Int_t ret;
+      new TGMsgBox(fClient->GetRoot(), GetMainFrame(),
+                   "File Exist",
+                   Form("Event record for event %d already exist.\n Replace?", fM->GetEventId()),
+                   kMBIconQuestion, kMBYes | kMBNo, &ret);
+      if (ret == kMBNo)
+         return;
+   }
+   FILE* out = fopen(file, "w");
+   if (out) {
+      fM->OutputEventTracks(out);
+      fclose(out);
+   } else {
+      Error("AliEveTrackCounterEditor::DoFileReport",
+            "Can not open file '%s' for writing.", file.Data());
+   }
+}
+
+//______________________________________________________________________________
+void AliEveTrackCounterEditor::DoShowHistos()
+{
+  // Slot for ShowHistos.
+
+  TH1F* hcnt = new TH1F("cnt", "Primeries per event", 41, -0.5, 40.5);
+  TH1F* hchg = new TH1F("chg", "Primary charge",       3, -1.5,  1.5);
+  TH1F* hpt  = new TH1F("pt",  "pT distribution",     40,  0.0,  8.0);
+  TH1F* heta = new TH1F("eta", "eta distribution",    40, -1.0,  1.0);
+
+  Int_t nn; // fscanf return value
+
+  for (Int_t i=0; i<1000; ++i)
+  {
+    TString file(Form("ev-report-%03d.txt", i));
+    if (gSystem->AccessPathName(file) == kFALSE)
+    {
+      Int_t   ev, ntr;
+      FILE* f = fopen(file, "read");
+      nn = fscanf(f, "Event = %d  Ntracks = %d", &ev, &ntr);
+      if (nn != 2) { printf("SAFR1 %d\n", nn); fclose(f); return;  }
+      hcnt->Fill(ntr);
+      for (Int_t t=0; t<ntr; ++t)
+      {
+        Int_t   id, chg;
+        Float_t pt, eta;
+        nn = fscanf(f, "%d: chg=%d pt=%f eta=%f", &id, &chg, &pt, &eta);
+        if (nn != 4) { printf("SAFR2 %d\n", nn); fclose(f); return;  }
+        hchg->Fill(chg);
+        hpt ->Fill(pt);
+        heta->Fill(eta);
+      }
+      fclose(f);
+    }
+  }
+
+  TCanvas* c;
+  if (gPad == 0 || gPad->GetCanvas()->IsEditable() == kFALSE) {
+    c = new TCanvas("Scanwas", "Scanning Results", 800, 600);
+  } else {
+    c = gPad->GetCanvas();
+    c->Clear();
+  }
+  c->Divide(2, 2);
+
+  c->cd(1); hcnt->Draw();
+  c->cd(2); hchg->Draw();
+  c->cd(3); hpt ->Draw();
+  c->cd(4); heta->Draw();
+
+  c->Modified();
+  c->Update();
+}
+
+/******************************************************************************/
+
+//______________________________________________________________________________
+void AliEveTrackCounterEditor::DoClickAction(Int_t mode)
+{
+   // Slot for ClickAction.
+
+   fM->SetClickAction(mode);
+}
diff --git a/EVE/EveBase/AliEveTrackCounterEditor.h b/EVE/EveBase/AliEveTrackCounterEditor.h
new file mode 100644 (file)
index 0000000..9ea84ae
--- /dev/null
@@ -0,0 +1,59 @@
+// @(#)root/eve:$Id$
+// Author: Matevz Tadel 2007
+
+/**************************************************************************
+ * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
+ * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
+ * full copyright notice.                                                 *
+ **************************************************************************/
+
+#ifndef AliEveTrackCounterEditor_H
+#define AliEveTrackCounterEditor_H
+
+#include "TGedFrame.h"
+
+class TGComboBox;
+class TGLabel;
+class TGNumberEntry;
+
+class AliEveTrackCounter;
+
+//______________________________________________________________________________
+// Short description of AliEveTrackCounterEditor
+//
+
+class AliEveTrackCounterEditor : public TGedFrame
+{
+public:
+   AliEveTrackCounterEditor(const TGWindow* p=0, Int_t width=170, Int_t height=30,
+                            UInt_t options = kChildFrame, Pixel_t back=GetDefaultFrameBackground());
+   virtual ~AliEveTrackCounterEditor() {}
+
+   virtual void SetModel(TObject* obj);
+
+   void DoPrev();
+   void DoNext();
+   void DoSetEvent();
+
+   void DoPrintReport();
+   void DoFileReport();
+   void DoShowHistos();
+
+   void DoClickAction(Int_t);
+
+protected:
+   AliEveTrackCounter *fM; // Model object.
+
+   // Declare widgets
+   TGComboBox       *fClickAction;
+   TGLabel          *fInfoLabel;
+   TGNumberEntry    *fEventId;
+
+private:
+   AliEveTrackCounterEditor(const AliEveTrackCounterEditor&);            // Not implemented
+   AliEveTrackCounterEditor& operator=(const AliEveTrackCounterEditor&); // Not implemented
+
+   ClassDef(AliEveTrackCounterEditor, 0); // GUI editor for AliEveTrackCounter.
+};
+
+#endif
index 14a7a0b..8e088e7 100644 (file)
@@ -14,6 +14,7 @@
 // AliEveEventManager
 #pragma link C++ class AliEveEventManager+;
 #pragma link C++ class AliEveEventManagerEditor+;
+#pragma link C++ class AliEveEventManagerWindow+;
 
 #pragma link C++ global gAliEveEvent;
 
 
 #pragma link C++ class AliEveVSDCreator+;
 
+// AliEveTrackcounter
+#pragma link C++ class AliEveTrackCounter+;
+#pragma link C++ class AliEveTrackCounterEditor+;
+
 // AliEveTrackFitter
 #pragma link C++ class AliEveTrackFitter+;
 #pragma link C++ class AliEveTrackFitterEditor+;
index b10ab80..894b6e9 100644 (file)
@@ -97,7 +97,7 @@ void AliEveT0Module::LoadRaw(TString fileName, Int_t ievt)
     rawC->AddHexagon(x, y, r.Uniform(-0.1, 0.1), 1.0);
     rawC->QuadValue(start->GetData(i+25,0)-start->GetData(0,0));
   }
-    vertexT0->AddHexagon(0.0, 0.0, 0.0, 1.0);
+    vertexT0->AddHexagon(0, 0, 0, 1);
     vertexT0->QuadValue(zvertex);
 
   rawA->RefitPlex();
index d8facf8..ad6fe11 100644 (file)
@@ -38,7 +38,7 @@ void trackcount_init()
   gEve->AddToListTree(fitter, 1);
   gEve->AddElement(fitter, gEve->GetEventScene());
 
-  TEveTrackCounter* g_trkcnt = new TEveTrackCounter("Primary Counter");
+  AliEveTrackCounter* g_trkcnt = new AliEveTrackCounter("Primary Counter");
   gEve->AddToListTree(g_trkcnt, kFALSE);
 
   TEveProjectionManager* pm = new TEveProjectionManager(); 
@@ -87,7 +87,7 @@ void on_new_event()
   // First two have reasonable primaries (sigma-to-prim-vertex < 5).
   // Other three are almost certainly secondaries.
   Int_t count = 1;
-  TEveTrackCounter* g_trkcnt = TEveTrackCounter::fgInstance;
+  AliEveTrackCounter* g_trkcnt = AliEveTrackCounter::fgInstance;
   g_trkcnt->Reset();
   g_trkcnt->SetEventId(gAliEveEvent->GetEventId());
   TEveElement::List_i i = cont->BeginChildren();
index 4bea974..f8481a0 100644 (file)
@@ -24,6 +24,12 @@ void visscan_init()
   TEveUtil::LoadMacro("alieve_init.C");
   alieve_init(".", -1);
 
+  TEveBrowser* b = gEve->GetBrowser();
+  b->StartEmbedding(TRootBrowser::kBottom);
+  new AliEveEventManagerWindow;
+  b->StopEmbedding("EventCtrl");
+
+
   TEveUtil::LoadMacro("geom_gentle.C");
   if (gShowTRD) TEveUtil::LoadMacro("geom_gentle_trd.C");
 
@@ -52,7 +58,7 @@ void visscan_init()
   gEve->AddToListTree(fitter, 1);
   gEve->AddElement(fitter, gEve->GetEventScene());
 
-  TEveTrackCounter* g_trkcnt = new TEveTrackCounter("Primary Counter");
+  AliEveTrackCounter* g_trkcnt = new AliEveTrackCounter("Primary Counter");
   gEve->AddToListTree(g_trkcnt, kFALSE);
 
 
@@ -134,7 +140,7 @@ void on_new_event()
   // First two have reasonable primaries (sigma-to-prim-vertex < 5).
   // Other three are almost certainly secondaries.
   Int_t count = 1;
-  TEveTrackCounter* g_trkcnt = TEveTrackCounter::fgInstance;
+  AliEveTrackCounter* g_trkcnt = AliEveTrackCounter::fgInstance;
   g_trkcnt->Reset();
   g_trkcnt->SetEventId(gAliEveEvent->GetEventId());
   TEveElement::List_i i = cont->BeginChildren();