From Mikolaj: Implementation of event / trigger selection mechanism
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 11 Jun 2009 16:59:43 +0000 (16:59 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 11 Jun 2009 16:59:43 +0000 (16:59 +0000)
and GUI for AliEveEventManager.

EVE/EveBase/AliEveEventManager.cxx
EVE/EveBase/AliEveEventManager.h
EVE/EveBase/AliEveEventManagerEditor.cxx
EVE/EveBase/AliEveEventManagerEditor.h
EVE/EveBase/AliEveEventSelector.cxx [new file with mode: 0644]
EVE/EveBase/AliEveEventSelector.h [new file with mode: 0644]
EVE/EveBase/AliEveEventSelectorWindow.cxx [new file with mode: 0644]
EVE/EveBase/AliEveEventSelectorWindow.h [new file with mode: 0644]
EVE/EveBase/EveBaseLinkDef.h
EVE/macros/visscan_init.C

index 2f99cd7..23c4bbc 100644 (file)
@@ -8,6 +8,7 @@
  **************************************************************************/
 
 #include "AliEveEventManager.h"
+#include "AliEveEventSelector.h"
 #include "AliEveMacroExecutor.h"
 #include <TEveManager.h>
 #include <TEveViewer.h>
@@ -122,6 +123,8 @@ void AliEveEventManager::InitInternals()
   fTransientLists = new TEveElementList("Transient Lists", "Containers of transient elements.");
   fTransientLists->IncDenyDestroy();
   gEve->AddToListTree(fTransientLists, kFALSE);
+
+  fPEventSelector = new AliEveEventSelector(this);
 }
 
 AliEveEventManager::AliEveEventManager(const TString& name) :
@@ -135,8 +138,8 @@ AliEveEventManager::AliEveEventManager(const TString& name) :
   fRawReader (0),
   fAutoLoad  (kFALSE), fAutoLoadTime (5.),     fAutoLoadTimer(0),
   fIsOpen    (kFALSE), fHasEvent     (kFALSE), fExternalCtrl (kFALSE),
-  fSelectOnTriggerType(kFALSE), fTriggerType(""),
   fExecutor    (0), fTransients(0), fTransientLists(0),
+  fPEventSelector(0),
   fSubManagers (0),
   fAutoLoadTimerRunning(kFALSE)
 {
@@ -156,8 +159,8 @@ AliEveEventManager::AliEveEventManager(const TString& name, const TString& path,
   fRawReader (0),
   fAutoLoad  (kFALSE), fAutoLoadTime (5),      fAutoLoadTimer(0),
   fIsOpen    (kFALSE), fHasEvent     (kFALSE), fExternalCtrl (kFALSE),
-  fSelectOnTriggerType(kFALSE), fTriggerType(""),
   fExecutor    (0), fTransients(0), fTransientLists(0),
+  fPEventSelector(0),
   fSubManagers (0),
   fAutoLoadTimerRunning(kFALSE)
 {
@@ -781,16 +784,13 @@ void AliEveEventManager::NextEvent()
   }
   else
   {
-    Int_t nexteventbytrigger=0;
-    if (fSelectOnTriggerType)
+    Int_t nextevent=0;
+    if (fPEventSelector->FindNext(nextevent))
     {
-      if (FindNextByTrigger(nexteventbytrigger)) //if not found do nothing
-        GotoEvent(nexteventbytrigger);
+      GotoEvent(nextevent);
     }
-    else if (fEventId < GetMaxEventId(kTRUE))
-      GotoEvent(fEventId + 1);
-    else
-      GotoEvent(0);
+    //else 
+    //  GotoEvent(fEventId + 1);
   }
 }
 
@@ -808,14 +808,13 @@ void AliEveEventManager::PrevEvent()
   {
     throw (kEH + "Event-loop is under external control.");
   }
-  Int_t nexteventbytrigger=0;
-  if (fSelectOnTriggerType)
+  Int_t nextevent=0;
+  if (fPEventSelector->FindPrev(nextevent))
   {
-    if (FindPrevByTrigger(nexteventbytrigger))
-      GotoEvent(nexteventbytrigger);
+    GotoEvent(nextevent);
   }
-  else
-    GotoEvent(fEventId - 1);
+  //else
+  //  GotoEvent(fEventId - 1);
 }
 
 void AliEveEventManager::Close()
@@ -1188,80 +1187,6 @@ void AliEveEventManager::AutoLoadNextEvent()
     StartAutoLoadTimer();
 }
 
-
-//------------------------------------------------------------------------------
-// Event selection by trigger
-//------------------------------------------------------------------------------
-
-Bool_t AliEveEventManager::FindNextByTrigger(Int_t& event)
-{
-  // Find next event that matches the trigger.
-  // If a matching event is not found, we loop around and eventually
-  // end up at the same event.
-
-  static const TEveException kEH("AliEveEventManager::FindNextByTrigger ");
-
-  if (!fESDTree) return kFALSE;
-  TString firedtrclasses;
-  for (Int_t i = fEventId+1; i<GetMaxEventId(kTRUE)+1; i++)
-  {
-    if (fESDTree->GetEntry(i) <= 0)
-      throw (kEH + "failed getting required event from ESD.");
-    firedtrclasses = fESD->GetFiredTriggerClasses();
-    if (firedtrclasses.Contains(fTriggerType))
-    {
-      event=i;
-      return kTRUE;
-    }
-  }
-  for (Int_t i = 0; i<fEventId+1; i++)
-  {
-    if (fESDTree->GetEntry(i) <= 0)
-      throw (kEH + "failed getting required event from ESD.");
-    firedtrclasses = fESD->GetFiredTriggerClasses();
-    if (firedtrclasses.Contains(fTriggerType))
-    {
-      event=i;
-      return kTRUE;
-    }
-  }
-  return kFALSE;
-}
-
-Bool_t AliEveEventManager::FindPrevByTrigger(Int_t& event)
-{
-  // Find previous event that matches the trigger.
-
-  static const TEveException kEH("AliEveEventManager::FindPrevByTrigger ");
-
-  if (!fESDTree) return kFALSE;
-  TString firedtrclasses;
-  for (Int_t i = fEventId-1; i>=0; i--)
-  {
-    if (fESDTree->GetEntry(i) <= 0)
-      throw (kEH + "failed getting required event from ESD.");
-    firedtrclasses = fESD->GetFiredTriggerClasses();
-    if (firedtrclasses.Contains(fTriggerType))
-    {
-      event=i;
-      return kTRUE;
-    }
-  }
-  for (Int_t i = GetMaxEventId(kTRUE); i>fEventId-1; i--)
-  {
-    if (fESDTree->GetEntry(i) <= 0)
-      throw (kEH + "failed getting required event from ESD.");
-    firedtrclasses = fESD->GetFiredTriggerClasses();
-    if (firedtrclasses.Contains(fTriggerType))
-    {
-      event=i;
-      return kTRUE;
-    }
-  }
-  return kFALSE;
-}
-
-
 //------------------------------------------------------------------------------
 // Post event-loading functions
 //------------------------------------------------------------------------------
index 0e398a6..bf42774 100644 (file)
@@ -15,6 +15,7 @@
 #include <TObjArray.h>
 
 class AliEveMacroExecutor;
+class AliEveEventSelector;
 
 class AliRunLoader;
 class AliESDEvent;
@@ -62,9 +63,6 @@ public:
   virtual void  NextEvent();
   virtual void  PrevEvent();
   virtual void  Close();
-  Bool_t        FindNextByTrigger(Int_t& i);
-  Bool_t        FindPrevByTrigger(Int_t& i);
-
 
   Int_t         GetEventId()         const { return fEventId; }
   AliRunLoader* GetRunLoader()       const { return fRunLoader; }
@@ -77,6 +75,7 @@ public:
   TTree*        GetAODTree()         const { return fAODTree; }
   AliAODEvent*  GetAOD()             const { return fAOD;     }
   virtual const Text_t* GetTitle()   const { return fPath.Data(); }
+  AliEveEventSelector* GetEventSelector() const { return fPEventSelector; }
   TString       GetEventInfoHorizontal() const;
   TString       GetEventInfoVertical()   const;
 
@@ -111,11 +110,6 @@ public:
   void          SetAutoLoad(Bool_t autoLoad);
   void          AutoLoadNextEvent();
 
-  Bool_t        GetSelectOnTriggerType()     const { return fSelectOnTriggerType; }
-  TString       GetTriggerType()             const { return fTriggerType; }
-  void          SetTriggerType(const TString& triggertype) { fTriggerType = triggertype; }
-  void          SetSelectOnTriggerType(Bool_t sel)         { fSelectOnTriggerType = sel; }
-
   Bool_t        AreEventFilesOpened()    const { return fIsOpen;       }
   Bool_t        IsEventAvailable()       const { return fHasEvent;     }
   Bool_t        IsUnderExternalControl() const { return fExternalCtrl; }
@@ -150,14 +144,13 @@ protected:
   Bool_t        fHasEvent;              // Is an event available.
   Bool_t        fExternalCtrl;          // Are we under external event-loop.
 
-  Bool_t        fSelectOnTriggerType;   // Whether to select on trigger-type.
-  TString       fTriggerType;           // Trigger-type to select on.
-
   AliEveMacroExecutor *fExecutor;       // Executor for std macros
 
   TEveElementList     *fTransients;     // Container for additional transient (per event) elements.
   TEveElementList     *fTransientLists; // Container for lists of transient (per event) elements.
 
+  AliEveEventSelector* fPEventSelector; // Event filter
+
   TList        *fSubManagers;           // Dependent event-managers, used for event embedding.
 
   static TString  fgESDFileName;        // Name by which to open ESD.
index 3276c09..1cc682a 100644 (file)
@@ -103,7 +103,6 @@ AliEveEventManagerWindow::AliEveEventManagerWindow(AliEveEventManager* mgr) :
   fNextEvent    (0),
   fLastEvent    (0),
   fRefresh      (0),
-  fTrigger      (0),
   fEventId      (0),
   fInfoLabel    (0),
   fAutoLoad     (0),
@@ -158,14 +157,6 @@ AliEveEventManagerWindow::AliEveEventManagerWindow(AliEveEventManager* mgr) :
     fAutoLoadTime->SetToolTip("Automatic event loading time in seconds.");
     fAutoLoadTime->Connect("ValueSet(Double_t)", cls, this, "DoSetAutoLoadTime()");
 
-    MkLabel(f, "||", 0, 8, 8);
-
-    MkLabel(f, "TRG select:", 0, 0, 4, 4);
-    fTrigger = new TGComboBox(f);
-    f->AddFrame(fTrigger, new TGLayoutHints(kLHintsNormal));
-    fTrigger->Resize(75,20);
-    //fTrigger->EnableTextInput(kTRUE);
-    fTrigger->Connect("Selected(const char*)", cls, this, "DoSetTriggerType(const char*)");
   }
 
   fEventInfo = new TGTextView(this, 400, 600);
@@ -251,23 +242,6 @@ void AliEveEventManagerWindow::DoSetAutoLoadTime()
 }
 
 //______________________________________________________________________________
-void AliEveEventManagerWindow::DoSetTriggerType(const char* type)
-{
-  // Slot for setting trigger type.
-
-  TString typestr = type;
-  if (typestr=="")
-  {
-    fM->SetSelectOnTriggerType(kFALSE);
-  }
-  else
-  {
-    fM->SetTriggerType( typestr );
-    fM->SetSelectOnTriggerType(kTRUE);
-  }
-}
-
-//______________________________________________________________________________
 void AliEveEventManagerWindow::Update()
 {
   // Update current event, number of available events, list of active triggers
@@ -291,8 +265,6 @@ void AliEveEventManagerWindow::Update()
 
   fEventInfo->LoadBuffer(fM->GetEventInfoHorizontal());
 
-  SetupTriggerSelect();
-
   Layout();
 }
 
@@ -334,42 +306,3 @@ TGLabel* AliEveEventManagerWindow::MkLabel(TGCompositeFrame* p,
   return l;
 }
 
-void AliEveEventManagerWindow::SetupTriggerSelect()
-{
-  // Do nothing if already enabled.
-  if (fTrigger->GetNumberOfEntries() > 0)
-    return;
-
-  AliESDEvent* esd = fM->GetESD();
-  if (esd && fM->GetESDFile() != 0)
-  {
-    TString activetrg = esd->GetESDRun()->GetActiveTriggerClasses();  //Get list of active classes
-    TObjArray* activetrgarr = activetrg.Tokenize(" "); //break up the classes string, space as separator
-    Int_t entries = activetrgarr->GetEntries();  //how many triggerclasses
-    TString entry;  //to hold the triger class name
-    TObjString* entryobj;
-    if (entries == 0)
-    {
-      fTrigger->SetEnabled(kFALSE);  //no trigger classes
-    }
-    else
-    {
-      fTrigger->RemoveAll(); //some initial cleanup
-      fTrigger->SetEnabled(kTRUE);  //no trigger classes
-      fTrigger->AddEntry("",-1);  //first entry empty - select to not filter by trigger
-      for (Int_t i=0;i<entries;i++)
-      {
-       entryobj = (TObjString*)activetrgarr->At(i);
-       entry = entryobj->GetString();
-       fTrigger->AddEntry(entry.Data(), i);
-      }
-    }
-    fTrigger->Select(-1, kTRUE); //set default no filtering and emit
-    fTrigger->SetEnabled(kTRUE);
-  }
-  else
-  {
-    fTrigger->SetEnabled(kFALSE);
-  }
-}
-
index 5bca6ac..06e296f 100644 (file)
@@ -81,8 +81,6 @@ public:
   void DoSetAutoLoad();
   void DoSetAutoLoadTime();
 
-  void DoSetTriggerType(const char* type);
-
   void Update();
 
 protected:
@@ -94,8 +92,6 @@ protected:
   TGTextButton         *fLastEvent;    // Go to last event
   TGTextButton         *fRefresh;      // Refresh event-file state
 
-  TGComboBox           *fTrigger;
-
   TGNumberEntry        *fEventId;      // Display/edit current event id
   TGLabel              *fInfoLabel;    // Display last available event id
 
@@ -109,8 +105,6 @@ protected:
   TGLabel* MkLabel(TGCompositeFrame* p, const char* txt, Int_t width,
                   Int_t lo=0, Int_t ro=0, Int_t to=2, Int_t bo=0);
 
-  void SetupTriggerSelect();                //Sets up the trigger selection list
-
 private:
   AliEveEventManagerWindow(const AliEveEventManagerWindow&);            // Not implemented
   AliEveEventManagerWindow& operator=(const AliEveEventManagerWindow&); // Not implemented
diff --git a/EVE/EveBase/AliEveEventSelector.cxx b/EVE/EveBase/AliEveEventSelector.cxx
new file mode 100644 (file)
index 0000000..1b4df2f
--- /dev/null
@@ -0,0 +1,309 @@
+/**************************************************************************
+ * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
+ * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
+ * full copyright notice.                                                 *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////
+//
+//  Finds events according to specified criteria
+//
+//  origin: Mikolaj Krzewicki, mikolaj.krzewicki@cern.ch
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "AliEveEventSelector.h"
+#include "AliEveEventManager.h"
+#include "AliESD.h"
+#include "AliESDEvent.h"
+#include "AliESDRun.h"
+#include <TEntryList.h>
+#include <TDirectory.h>
+#include <TTree.h>
+#include <TObjArray.h>
+#include <TRegexp.h>
+#include <TROOT.h>
+
+ClassImp(AliEveEventSelector)
+
+//_____________________________________________________________________________
+AliEveEventSelector::AliEveEventSelector(AliEveEventManager* evman):
+  fPEventManager(evman),
+  fWrapAround(kTRUE),
+  fMaxEventId(fPEventManager->GetMaxEventId()),
+  fSelectOnString(kFALSE),
+  fString(""),
+  fPEntryList(NULL),
+  fEntryListId(0),
+  fSelectOnTriggerType(kFALSE),
+  fTriggerType(""),
+  fSelectOnTriggerString(kFALSE),
+  fTriggerSelectionString(""),
+  fTriggerMaskPatternString("trgmask"),
+  fSelectOnMultiplicity(kFALSE),
+  fMultiplicityLow(0),
+  fMultiplicityHigh(0)
+{
+  //ctor
+}
+
+//_____________________________________________________________________________
+void AliEveEventSelector::SetSelectionString( const TString& str )
+{
+  //selection string setter
+
+  TTree* pESDTree = fPEventManager->GetESDTree();
+  if (!pESDTree || fString==str) return;//don't waist time
+  fString = str;
+  if (str == "" ) return;//on reset don't recalculate
+  fMaxEventId = fPEventManager->GetMaxEventId();
+  pESDTree->Draw( ">>listofentries", fString, "entrylist");
+  fPEntryList = dynamic_cast<TEntryList*>(gDirectory->Get("listofentries"));
+}
+
+//_____________________________________________________________________________
+void AliEveEventSelector::SetSelectionString( const char* str )
+{
+  TString ts = str;
+  SetSelectionString(ts);
+}
+
+//_____________________________________________________________________________
+void AliEveEventSelector::SetTriggerType( const TString& type )
+{
+  fTriggerType = type;
+}
+
+//_____________________________________________________________________________
+void AliEveEventSelector::SetTriggerType( const char* type)
+{
+  TString ts = type;
+  SetTriggerType(ts);
+}
+
+//_____________________________________________________________________________
+void AliEveEventSelector::UpdateEntryList()
+{
+  //update the entrylist from file if file changed
+  TTree* pESDTree = fPEventManager->GetESDTree();
+  if (!pESDTree) return;
+  
+  Long64_t treesize = fPEventManager->GetMaxEventId();
+  if (treesize<=fMaxEventId) return; //nothing changed, do nothing
+  pESDTree->Draw(">>+fPEntryList", fString, "entrylist",
+      fMaxEventId, treesize-fMaxEventId );
+  fMaxEventId = treesize;
+}
+
+//_____________________________________________________________________________
+void AliEveEventSelector::Update()
+{
+  //refresh stuff
+
+  UpdateEntryList();
+}
+
+//_____________________________________________________________________________
+Bool_t AliEveEventSelector::FindNext( Int_t& output )
+{
+  //does the magick of selecting the next event
+
+  static const TEveException kEH("AliEveEventSelector::GetNext ");
+  
+  TTree* pESDTree = fPEventManager->GetESDTree();
+  if (!pESDTree) return kFALSE;
+  AliESDEvent* pESDEvent = fPEventManager->GetESD();
+  Int_t eventId = fPEventManager->GetEventId();
+  fMaxEventId = fPEventManager->GetMaxEventId();
+
+  if (!fSelectOnString)
+  {
+    // pure non-string
+    for (Int_t i = eventId+1; i<fMaxEventId+1; i++)
+    {
+      if (pESDTree->GetEntry(i) <= 0)
+        throw (kEH + "failed getting required event from ESD.");
+      if (CheckOtherSelection(pESDEvent))
+      {
+        output = i;
+        return kTRUE;
+      }
+    }
+    if (!fWrapAround) return kFALSE;
+    for (Int_t i = 0; i<eventId+1; i++)
+    {
+      if (pESDTree->GetEntry(i) <= 0)
+        throw (kEH + "failed getting required event from ESD.");
+      if (CheckOtherSelection(pESDEvent))
+      {
+        output = i;
+        return kTRUE;
+      }
+    }
+    return kFALSE;
+  }
+  else
+  {
+    //select using the entrylist
+    for (Long64_t i=fEntryListId+1; i<fPEntryList->GetN(); i++ )
+    {
+      Long64_t entry = fPEntryList->GetEntry(i);
+      if (pESDTree->GetEntry(entry) <= 0)
+        throw (kEH + "failed getting required event from ESD.");
+      if (CheckOtherSelection(pESDEvent))
+      {
+        output = entry;
+        fEntryListId = i;
+        return kTRUE;
+      }
+    }
+    if (!fWrapAround) return kFALSE;
+    for (Long64_t i=0; i<fEntryListId+1; i++ )
+    {
+      Long64_t entry = fPEntryList->GetEntry(i);
+      if (pESDTree->GetEntry(entry) <= 0)
+        throw (kEH + "failed getting required event from ESD.");
+      if (CheckOtherSelection(pESDEvent))
+      {
+        output = entry;
+        fEntryListId=i;
+        return kTRUE;
+      }
+    }
+    return kFALSE;
+  }
+  return kFALSE;
+
+}
+
+//_____________________________________________________________________________
+Bool_t AliEveEventSelector::FindPrev( Int_t& output )
+{
+  //does the magick of selecting the previous event
+
+  static const TEveException kEH("AliEveEventSelector::GetNext ");
+  
+  TTree* pESDTree = fPEventManager->GetESDTree();
+  if (!pESDTree) return kFALSE;
+  AliESDEvent* pESDEvent = fPEventManager->GetESD();
+  Int_t eventId = fPEventManager->GetEventId();
+  fMaxEventId = fPEventManager->GetMaxEventId();
+
+  if (!fSelectOnString)
+  {
+    // pure non-string
+    for (Int_t i = eventId-1; i>-1; i--)
+    {
+      if (pESDTree->GetEntry(i) <= 0)
+        throw (kEH + "failed getting required event from ESD.");
+      if (CheckOtherSelection(pESDEvent))
+      {
+        output = i;
+        return kTRUE;
+      }
+    }
+    if (!fWrapAround) return kFALSE;
+    for (Int_t i = fMaxEventId; i>eventId-1; i--)
+    {
+      if (pESDTree->GetEntry(i) <= 0)
+        throw (kEH + "failed getting required event from ESD.");
+      if (CheckOtherSelection(pESDEvent))
+      {
+        output = i;
+        return kTRUE;
+      }
+    }
+    return kFALSE;
+  }
+  else
+  {
+    //select using the entrylist
+    for (Long64_t i=fEntryListId-1; i>-1; i--)
+    {
+      Long64_t entry = fPEntryList->GetEntry(i);
+      if (pESDTree->GetEntry(entry) <= 0)
+        throw (kEH + "failed getting required event from ESD.");
+      if (CheckOtherSelection(pESDEvent))
+      {
+        output = entry;
+        fEntryListId = i;
+        return kTRUE;
+      }
+    }
+    if (!fWrapAround) return kFALSE;
+    for (Long64_t i=fPEntryList->GetN()-1; i>fEntryListId-1; i--)
+    {
+      Long64_t entry = fPEntryList->GetEntry(i);
+      if (pESDTree->GetEntry(entry) <= 0)
+        throw (kEH + "failed getting required event from ESD.");
+      if (CheckOtherSelection(pESDEvent))
+      {
+        output = entry;
+        fEntryListId=i;
+        return kTRUE;
+      }
+    }
+    return kFALSE;
+  }
+  return kFALSE;
+}
+
+//_____________________________________________________________________________
+Bool_t AliEveEventSelector::CheckOtherSelection( AliESDEvent* pESDEvent )
+{
+  //checks the event for any other hardcoded selection criteria
+  Bool_t ret=kTRUE;
+
+  //trigger stuff
+  if (fSelectOnTriggerType)
+  {
+    TString firedtrclasses = pESDEvent->GetFiredTriggerClasses();
+    printf(firedtrclasses.Data());
+    printf("\n");
+    printf(fTriggerType.Data());
+    printf("\n");
+    if (!(firedtrclasses.Contains(fTriggerType))) return kFALSE;
+    //if (!pESDEvent->IsTriggerClassFired(fTriggerType.Data())) return kFALSE;
+  }
+
+  if (fSelectOnMultiplicity)
+  {
+    Int_t mult = pESDEvent->GetNumberOfTracks();
+    Int_t mhigh = (fMultiplicityHigh==0)?100000000:fMultiplicityHigh;
+    if (mult<fMultiplicityLow || mult>mhigh) return kFALSE;
+  }
+
+  if (fSelectOnTriggerString)
+  {
+    ULong64_t triggermask = pESDEvent->GetTriggerMask();
+    TString triggermaskstr;
+    triggermaskstr += triggermask;
+    TString selstr(fTriggerSelectionString); //make copy
+    selstr.ReplaceAll(fTriggerMaskPatternString,triggermaskstr);
+    Int_t returncode;
+    Bool_t result = static_cast<Bool_t>(gROOT->ProcessLine(selstr,&returncode));
+    //if (!returncode) return kFALSE;
+    if (!result) return kFALSE;
+  }
+
+  return ret;
+}
+
+//_____________________________________________________________________________
+void AliEveEventSelector::SetTriggerSelectionString( TString str )
+{
+  const AliESDRun* run = fPEventManager->GetESD()->GetESDRun();
+  for (Int_t i=0; i<run->kNTriggerClasses; i++)
+  {
+    const char* name = run->GetTriggerClass(i);
+    if (name=="") continue;
+    TString valuestr("(");
+    valuestr += fTriggerMaskPatternString;
+    valuestr += "&";
+    valuestr += static_cast<ULong64_t>(1<<i);
+    valuestr += ")";
+    str.ReplaceAll(name,valuestr);
+  }//for i
+  fTriggerSelectionString = str;
+}
+
diff --git a/EVE/EveBase/AliEveEventSelector.h b/EVE/EveBase/AliEveEventSelector.h
new file mode 100644 (file)
index 0000000..5ea1bde
--- /dev/null
@@ -0,0 +1,99 @@
+/**************************************************************************
+ * 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 AliEveEventSelector_H
+#define AliEveEventSelector_H
+
+// AliEveEventSelector
+//
+// Event selector class
+//
+
+#include "AliEveEventManager.h"
+#include <TObject.h>
+#include <TString.h>
+
+class TTree;
+class TList;
+class AliESDEvent;
+class TEntryList;
+class AliEveEventManager;
+class TString;
+class TObjArray;
+
+class AliEveEventSelector : public TObject
+{
+public:
+  AliEveEventSelector(AliEveEventManager* evman);
+  void SetEventManager(AliEveEventManager* evman) { fPEventManager = evman; }
+  AliEveEventManager* GetEventManager() { return fPEventManager; }
+  TTree* GetESDTree() const { return fPEventManager->GetESDTree(); }
+
+  Bool_t         FindNext(Int_t& i);
+  Bool_t         FindPrev(Int_t& i);
+  
+  void SetSelectionString( const TString& str );
+  void SetSelectionString( const char* str );
+  TString GetSelectionString() {return fString;}
+  Bool_t GetSelectOnString() {return fSelectOnString;}
+  void SetSelectOnString( const Bool_t b = kTRUE ) {fSelectOnString = b;}
+  void SetWrapAround( const Bool_t b = kTRUE ) {fWrapAround = b;}
+  Bool_t GetWrapAround() const { return fWrapAround; }
+  void Update();
+
+  void SetSelectOnTriggerType( const Bool_t b = kTRUE ) {fSelectOnTriggerType = b;}
+  void SetTriggerType( const TString& type );
+  void SetTriggerType( const char* type );
+  TString GetTriggerType() const {return fTriggerType;}
+  Bool_t GetSelectOnTriggerType() {return fSelectOnTriggerType;}
+
+  void SetSelectOnTriggerString( const Bool_t b=kTRUE ) { fSelectOnTriggerString = b; }
+  void SetTriggerSelectionString( const TString m );
+  TString GetTriggerSelectionString() const { return fTriggerSelectionString; }
+  Bool_t GetSelectOnTriggerString() const { return fSelectOnTriggerString; }
+  void SetTriggerMaskPatternString( TString str) { fTriggerMaskPatternString = str; }
+  TString GetTriggerMaskPatternString() const { return fTriggerMaskPatternString; }
+
+  void SetSelectOnMultiplicity( const Bool_t b = kTRUE) { fSelectOnMultiplicity = b; }
+  Bool_t GetSelectOnMultiplicity() { return fSelectOnMultiplicity; }
+  void SetMultiplicityLow( const Int_t low ) { fMultiplicityLow = low; }
+  void SetMultiplicityHigh( const Int_t high ) { fMultiplicityHigh = high; }
+  Int_t GetMultiplicityLow() { return fMultiplicityLow; }
+  Int_t GetMultiplicityHigh() { return fMultiplicityHigh; }
+  
+protected:
+  void UpdateEntryList();
+  Bool_t CheckOtherSelection(AliESDEvent* ESD);
+  
+private:
+  AliEveEventSelector(const AliEveEventSelector&);
+  AliEveEventSelector& operator=(const AliEveEventSelector&);
+
+  AliEveEventManager *fPEventManager;
+  Bool_t fWrapAround;
+  Long64_t fMaxEventId;
+  
+  Bool_t fSelectOnString;
+  TString fString;
+  TEntryList* fPEntryList;
+  Int_t  fEntryListId;
+
+  Bool_t fSelectOnTriggerType;
+  TString fTriggerType;
+
+  Bool_t fSelectOnTriggerString;
+  TString fTriggerSelectionString;
+  TString fTriggerMaskPatternString;
+
+  Bool_t fSelectOnMultiplicity;
+  Int_t fMultiplicityLow;
+  Int_t fMultiplicityHigh;
+
+
+  ClassDef(AliEveEventSelector, 2); 
+};
+
+#endif
diff --git a/EVE/EveBase/AliEveEventSelectorWindow.cxx b/EVE/EveBase/AliEveEventSelectorWindow.cxx
new file mode 100644 (file)
index 0000000..75b7299
--- /dev/null
@@ -0,0 +1,267 @@
+/**************************************************************************
+ * 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 "AliEveEventSelectorWindow.h"
+#include "AliEveEventSelector.h"
+#include "AliEveEventManager.h"
+#include <TGTextEntry.h>
+#include <TGNumberEntry.h>
+#include <TRootEmbeddedCanvas.h>
+#include <TCanvas.h>
+#include <TGButton.h>
+#include <TGComboBox.h>
+#include <TGLabel.h>
+#include <TTree.h>
+#include <AliESDEvent.h>
+#include <AliESDRun.h>
+#include <TH1.h>
+#include <TDirectory.h>
+#include <TROOT.h>
+
+ClassImp(AliEveEventSelectorWindow)
+//______________________________________________________________________________
+AliEveEventSelectorWindow::AliEveEventSelectorWindow(const TGWindow *p, UInt_t w, UInt_t h,
+                                                     AliEveEventSelector* sel) :
+    TGMainFrame(p, w, h),
+    fPSelector(sel),
+    fPCanvas(NULL),
+    fPDrawFormula(NULL),
+    fPEntryFormula(NULL),
+    fPEntryLowerBound(NULL),
+    fPEntryHigherBound(NULL),
+    fPButtonTextDone(NULL),
+    fPComboBoxTrigger(NULL),
+    fPEntryTriggerSelection(NULL),
+    fPCheckTriggerSimple(NULL),
+    fPCheckTriggerString(NULL)
+{
+  //ctor
+
+  //the canvas
+  fPCanvas = new TRootEmbeddedCanvas(0,this);
+  Int_t wid = fPCanvas->GetCanvasWindowId();
+  TCanvas *myc = new TCanvas("MyCanvas", 10,10,wid);
+  fPCanvas->AdoptCanvas(myc);
+  AddFrame(fPCanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
+
+  //draw box frame
+  TGHorizontalFrame* hframedraw = new TGHorizontalFrame(this);
+  AddFrame(hframedraw, new TGLayoutHints((kLHintsExpandX), 5,5));
+
+  TGLabel* drawlabel = new TGLabel(hframedraw, "Draw expression:");
+  hframedraw->AddFrame(drawlabel, new TGLayoutHints((kLHintsLeft)));
+  fPDrawFormula = new TGTextEntry(hframedraw);
+  hframedraw->AddFrame(fPDrawFormula, new TGLayoutHints(kLHintsExpandX));
+  TGTextButton* buttondraw = new TGTextButton(hframedraw,"Draw");
+  buttondraw->Connect("Clicked()","AliEveEventSelectorWindow",
+                              this, "DoDrawHistogram()");
+  hframedraw->AddFrame(buttondraw, new TGLayoutHints(kLHintsLeft));
+  TGTextButton* buttonview = new TGTextButton(hframedraw,"Browse");
+  buttonview->Connect("Clicked()","TTree",fPSelector->GetESDTree(),"StartViewer()");
+  hframedraw->AddFrame(buttonview, new TGLayoutHints(kLHintsLeft));
+
+
+  //text selection frame
+  TGHorizontalFrame *hframetxtsel = new TGHorizontalFrame(this);
+  AddFrame(hframetxtsel, new TGLayoutHints((kLHintsExpandX), 5,5));
+
+  TGLabel* exprlabel = new TGLabel(hframetxtsel, "Expression:");
+  hframetxtsel->AddFrame(exprlabel, new TGLayoutHints(kLHintsLeft));
+
+  TGCheckButton* checktextsel = new TGCheckButton(hframetxtsel);
+  checktextsel->Connect("Toggled(Bool_t)", "AliEveEventSelector",
+                        fPSelector, "SetSelectOnString(Bool_t)");
+  hframetxtsel->AddFrame(checktextsel, new TGLayoutHints(kLHintsLeft));
+
+  fPEntryLowerBound = new TGNumberEntry(hframetxtsel);
+  hframetxtsel->AddFrame(fPEntryLowerBound, new TGLayoutHints(kLHintsLeft));
+  fPEntryFormula = new TGTextEntry(hframetxtsel);
+  hframetxtsel->AddFrame(fPEntryFormula, new TGLayoutHints(kLHintsExpandX));
+  fPEntryHigherBound = new TGNumberEntry(hframetxtsel);
+  hframetxtsel->AddFrame(fPEntryHigherBound, new TGLayoutHints(kLHintsLeft));
+  fPButtonTextDone = new TGTextButton(hframetxtsel,"Set");
+  fPButtonTextDone->Connect("Clicked()", "AliEveEventSelectorWindow",
+                            this, "DoSetSelectionString()");
+  hframetxtsel->AddFrame(fPButtonTextDone, new TGLayoutHints(kLHintsLeft));
+
+  //trigger cuts frame
+  TGHorizontalFrame* hframetrigger = new TGHorizontalFrame(this);
+  AddFrame(hframetrigger, new TGLayoutHints((kLHintsLeft), 5,5));
+
+  TGLabel* triglabel = new TGLabel(hframetrigger, "Trigger type:");
+  hframetrigger->AddFrame(triglabel, new TGLayoutHints(kLHintsLeft));
+  fPCheckTriggerSimple = new TGCheckButton(hframetrigger);
+  fPCheckTriggerSimple->Connect("Toggled(Bool_t)","AliEveEventSelector",
+                          fPSelector,"SetSelectOnTriggerType(Bool_t)");
+  hframetrigger->AddFrame(fPCheckTriggerSimple, new TGLayoutHints(kLHintsLeft));
+  fPComboBoxTrigger = new TGComboBox(hframetrigger);
+  fPComboBoxTrigger->Resize(100,20);
+  fPComboBoxTrigger->Connect("Selected(const char*)","AliEveEventSelectorWindow",
+                             this,"DoHandleTriggerFromComboBox(const char*)");
+  hframetrigger->AddFrame(fPComboBoxTrigger, new TGLayoutHints(kLHintsLeft));
+
+  TGLabel* labelfreetrig = new TGLabel(hframetrigger, "Trigger type expression:");
+  hframetrigger->AddFrame(labelfreetrig, new TGLayoutHints(kLHintsLeft));
+  fPCheckTriggerString = new TGCheckButton(hframetrigger);
+  hframetrigger->AddFrame(fPCheckTriggerString, new TGLayoutHints(kLHintsLeft));
+  fPCheckTriggerString->Connect("Toggled(Bool_t)","AliEveEventSelector",
+                           fPSelector,"SetSelectOnTriggerString(Bool_t)");
+  fPEntryTriggerSelection = new TGTextEntry(hframetrigger);
+  hframetrigger->AddFrame(fPEntryTriggerSelection, new TGLayoutHints(kLHintsExpandX));
+  TGTextButton* buttontrigsel = new TGTextButton(hframetrigger,"Set");
+  hframetrigger->AddFrame(buttontrigsel, new TGLayoutHints(kLHintsLeft));
+  buttontrigsel->Connect("Clicked()","AliEveEventSelectorWindow",
+                         this, "DoSetTriggerSelectionString()");
+
+  //multiplicity cuts frame
+  TGHorizontalFrame* hframemult = new TGHorizontalFrame(this);
+  AddFrame(hframemult, new TGLayoutHints((kLHintsLeft), 5,5));
+
+  TGLabel* multlabel = new TGLabel(hframemult, "Multiplicity:");
+  hframemult->AddFrame(multlabel, new TGLayoutHints(kLHintsLeft));
+  TGCheckButton* checkmult = new TGCheckButton(hframemult);
+  checkmult->Connect("Toggled(Bool_t)", "AliEveEventSelector",
+                      fPSelector,"SetSelectOnMultiplicity(Bool_t)");
+  hframemult->AddFrame(checkmult, new TGLayoutHints(kLHintsLeft));
+  fPEntryMultLow = new TGNumberEntry(hframemult);
+  hframemult->AddFrame(fPEntryMultLow, new TGLayoutHints(kLHintsLeft));
+  fPEntryMultHigh = new TGNumberEntry(hframemult);
+  hframemult->AddFrame(fPEntryMultHigh, new TGLayoutHints(kLHintsLeft));
+  TGTextButton* buttonmultset = new TGTextButton(hframemult,"Set");
+  hframemult->AddFrame(buttonmultset, new TGLayoutHints(kLHintsLeft));
+  buttonmultset->Connect("Clicked()","AliEveEventSelectorWindow",
+                         this, "DoSetMultiplicityRange()");
+
+  //wrap around
+  TGHorizontalFrame* hframewrap = new TGHorizontalFrame(this);
+  AddFrame(hframewrap, new TGLayoutHints((kLHintsLeft), 5,5));
+
+  TGLabel* wraplabel = new TGLabel(hframewrap, "Wrap around at the end.");
+  hframewrap->AddFrame(wraplabel, new TGLayoutHints(kLHintsLeft));
+  TGCheckButton* checkwraparound = new TGCheckButton(hframewrap);
+  hframewrap->AddFrame(checkwraparound, new TGLayoutHints(kLHintsLeft));
+  checkwraparound->Connect("Toggled(Bool_t)","AliEveEventSelector",
+                           fPSelector, "SetWrapAround(Bool_t)");
+
+  SetupTriggerSelect();
+  
+  //bookkeeping
+  SetWindowName("Event Selection");
+  MapSubwindows();
+
+  Resize(GetDefaultSize());
+  MapWindow();
+}
+
+//______________________________________________________________________________
+AliEveEventSelectorWindow::~AliEveEventSelectorWindow()
+{
+}
+
+//______________________________________________________________________________
+void AliEveEventSelectorWindow::SetupTriggerSelect()
+{   
+  // Do nothing if already enabled.
+  if (fPComboBoxTrigger->GetNumberOfEntries() > 0)
+    return;
+  AliEveEventManager* fM = fPSelector->GetEventManager();
+  AliESDEvent* esd = fM->GetESD();
+    
+  if (esd && fM->GetESDFile() != 0)
+  { 
+    TString activetrg = esd->GetESDRun()->GetActiveTriggerClasses();  //Get list of active classes
+    TObjArray* activetrgarr = activetrg.Tokenize(" "); //break up the classes string, space as separator
+    Int_t entries = activetrgarr->GetEntries();  //how many triggerclasses
+    TString entry;  //to hold the triger class name
+    TObjString* entryobj;
+    if (entries == 0)
+    {
+      fPComboBoxTrigger->SetEnabled(kFALSE);  //no trigger classes
+    }
+    else
+    {
+      fPComboBoxTrigger->RemoveAll(); //some initial cleanup
+      fPComboBoxTrigger->SetEnabled(kTRUE);  //no trigger classes
+      //fPComboBoxTrigger->AddEntry("",-1);  //first entry empty - select to not filter by trigger
+      for (Int_t i=0;i<entries;i++)
+      {
+        entryobj = (TObjString*)activetrgarr->At(i);
+        entry = entryobj->GetString();
+        fPComboBoxTrigger->AddEntry(entry.Data(), i);
+      }
+    }
+    fPComboBoxTrigger->Select(0, kTRUE); //set default no filtering and emit
+    fPComboBoxTrigger->SetEnabled(kTRUE);
+  } 
+  else
+  { 
+    fPComboBoxTrigger->SetEnabled(kFALSE);
+  } 
+} 
+
+//______________________________________________________________________________
+void AliEveEventSelectorWindow::DoSetSelectionString()
+{
+  TString str = fPEntryFormula->GetText();
+  TString s;
+  if (fPEntryLowerBound->GetNumber()==0&&fPEntryHigherBound->GetNumber()==0)
+  {
+    s = str;
+  }
+  else
+  {
+    s += "(";
+    s += str;
+    s += ")>";
+    s += fPEntryLowerBound->GetNumber();
+    s += "&&";
+    s += "(";
+    s += str;
+    s += ")<";
+    s += fPEntryHigherBound->GetNumber();
+  }
+  fPSelector->SetSelectionString(s);
+}
+
+//______________________________________________________________________________
+void AliEveEventSelectorWindow::DoDrawHistogram()
+{
+  TTree* tree = fPSelector->GetESDTree();
+  TString str = fPDrawFormula->GetText();
+  str += ">>selectionhist";
+  tree->Draw(str);
+  TH1* hist = dynamic_cast<TH1*>(gDirectory->Get("selectionhist"));
+  if (hist) hist->Draw();
+  TCanvas* canvas = fPCanvas->GetCanvas();
+  canvas->Update();
+}
+
+//______________________________________________________________________________
+void AliEveEventSelectorWindow::DoSetTriggerSelectionString()
+{
+  TString string = fPEntryTriggerSelection->GetText();
+  fPSelector->SetTriggerSelectionString(string);
+  fPEntryTriggerSelection->SetToolTipText(fPSelector->GetTriggerSelectionString());
+}
+
+//______________________________________________________________________________
+void AliEveEventSelectorWindow::DoHandleTriggerFromComboBox(const char* str)
+{
+  if (fPSelector->GetSelectOnTriggerString() && !fPSelector->GetSelectOnTriggerType())
+  {
+    fPEntryTriggerSelection->Insert(str);
+    fPEntryTriggerSelection->SetFocus();
+  }
+  if (fPSelector->GetSelectOnTriggerType())
+    fPSelector->SetTriggerType(str);
+}
+
+//______________________________________________________________________________
+void AliEveEventSelectorWindow::DoSetMultiplicityRange()
+{
+  fPSelector->SetMultiplicityLow(fPEntryMultLow->GetNumber());
+  fPSelector->SetMultiplicityHigh(fPEntryMultHigh->GetNumber());
+}
diff --git a/EVE/EveBase/AliEveEventSelectorWindow.h b/EVE/EveBase/AliEveEventSelectorWindow.h
new file mode 100644 (file)
index 0000000..f972a57
--- /dev/null
@@ -0,0 +1,68 @@
+/**************************************************************************
+ * 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 AliEveEventSelectorWindow_H
+#define AliEveEventSelectorWindow_H
+
+#include "TGedFrame.h"
+#include "TGComboBox.h"
+#include <TObjString.h>
+
+class AliEveEventManager;
+class AliEveEventSelector;
+class TGTextEntry;
+class TGNumberEntry;
+class TGCheckButton;
+class TGComboBox;
+class TRootEmbeddedCanvas;
+
+//==============================================================================
+// AliEveEventSelectorWindow
+//==============================================================================
+
+//______________________________________________________________________________
+// Short description of AliEveEventSelectorWindow
+//
+
+class AliEveEventSelectorWindow : public TGMainFrame
+{
+public:
+  AliEveEventSelectorWindow(const TGWindow *p, UInt_t w, UInt_t h, AliEveEventSelector* sel);
+  virtual ~AliEveEventSelectorWindow();
+  void SetEventSelector(AliEveEventSelector* sel) {fPSelector = sel;}
+  void DoSetSelectionString();
+  void DoSetTriggerSelectionString();
+  void DoHandleTriggerFromComboBox(const char* str);
+  void DoSetMultiplicityRange();
+  void DoDrawHistogram();
+  void SetupTriggerSelect();
+
+protected:
+
+private:
+  AliEveEventSelector* fPSelector;
+  TRootEmbeddedCanvas* fPCanvas;
+
+  TGTextEntry* fPDrawFormula;
+  TGTextEntry* fPEntryFormula;
+  TGNumberEntry* fPEntryLowerBound;
+  TGNumberEntry* fPEntryHigherBound;
+  TGTextButton* fPButtonTextDone;
+  
+  TGComboBox* fPComboBoxTrigger;
+  TGTextEntry* fPEntryTriggerSelection;
+  TGCheckButton* fPCheckTriggerSimple;
+  TGCheckButton* fPCheckTriggerString;
+  TGNumberEntry* fPEntryMultHigh;
+  TGNumberEntry* fPEntryMultLow;
+
+  AliEveEventSelectorWindow(const AliEveEventSelectorWindow&);
+  AliEveEventSelectorWindow& operator=(const AliEveEventSelectorWindow&);
+  
+  ClassDef(AliEveEventSelectorWindow, 1); // GUI window for AliEveEventSelector
+};
+
+#endif
index 2baf2ba..d0f5c21 100644 (file)
 #pragma link C++ class AliEveEventManagerEditor+;
 #pragma link C++ class AliEveEventManagerWindow+;
 
+// AliEveEventSelector
+#pragma link C++ class AliEveEventSelector+;
+#pragma link C++ class AliEveEventSelectorWindow+;
+
 // AliEveMacro and AliEveMacroExecutor
 #pragma link C++ class AliEveMacro+;
 #pragma link C++ class AliEveMacroEditor+;
index b65a9db..d2b2ade 100644 (file)
@@ -230,6 +230,12 @@ void visscan_init(Bool_t show_extra_geo=kFALSE)
   new AliQAHistViewer(gClient->GetRoot(), 600, 400, kTRUE);
   slot->StopEmbedding("QA histograms");
 
+  //event selection tab
+  slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
+  slot->StartEmbedding();
+  new AliEveEventSelectorWindow(gClient->GetRoot(), 600, 400, AliEveEventManager::GetMaster()->GetEventSelector());
+  slot->StopEmbedding("Selections");
+
   browser->GetTabRight()->SetTab(1);
 
   browser->StartEmbedding(TRootBrowser::kBottom);