]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
AliEveEventManager
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 16 Jul 2008 17:28:40 +0000 (17:28 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 16 Jul 2008 17:28:40 +0000 (17:28 +0000)
------------------
- In GotoEvent() also accept negative indices, meaning event from the
  end of the file.
- In GotoEvent(), when ESD is the primary data-source, call Refresh()
  to get updated tree information.
- In EventNext/Prev() now cycle around the available event range.
- Add method Int_t GetMaxEventId().

event_first.C, event_last.C
---------------------------
New macros that navigate to first/last event.

EVE/EveBase/AliEveEventManager.cxx
EVE/EveBase/AliEveEventManager.h
EVE/alice-macros/event_first.C [new file with mode: 0644]
EVE/alice-macros/event_last.C [new file with mode: 0644]

index 2b92918a9e8b0291dd8d3ee14e6a75d31c888d8b..e1f250066c300cff02fef915a4f995a5b1027d57 100644 (file)
@@ -322,6 +322,37 @@ void AliEveEventManager::SetEvent(AliRunLoader *runLoader, AliRawReader *rawRead
   AfterNewEventLoaded();
 }
 
+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
+  // and 10,000,000 is returned.
+  // If neither data-source is initialised an exception is thrown.
+  // If refresh_esd is true and ESD is the primary event-data source
+  // its header is re-read from disk.
+
+  static const TEveException kEH("AliEveEventManager::GetMaxEventId ");
+
+  if (fRunLoader)
+  {
+    return fRunLoader->GetNumberOfEvents() - 1;
+  }
+  else if (fESDTree)
+  {
+    if (refreshESD)
+      fESDTree->Refresh();
+    return fESDTree->GetEntries() - 1;
+  }
+  else if (fRawReader)
+  {
+    return 10000000;
+  }
+  else
+  {
+    throw (kEH + "neither RunLoader, ESD nor Raw loaded.");
+  }
+}
+
 void AliEveEventManager::GotoEvent(Int_t event)
 {
   // Load data for specified event.
@@ -330,28 +361,46 @@ void AliEveEventManager::GotoEvent(Int_t event)
   // After successful loading of event, the virtual function
   // AfterNewEventLoaded() is called. This executes commands that
   // were registered via TEveEventManager::AddNewEventCommand().
+  //
+  // If event is negative, it is subtracted from the number of
+  // available events, thus passing -1 will load the last event.
+  // This is not supported when raw-data is the only data-source
+  // as the number of events is not known.
 
   static const TEveException kEH("AliEveEventManager::GotoEvent ");
 
-  if (event < 0) {
-    Error(kEH, "event must be non-negative.");
-    return;
-  }
-
   Int_t maxEvent = 0;
-  if (fRunLoader) {
+  if (fRunLoader)
+  {
     maxEvent = fRunLoader->GetNumberOfEvents() - 1;
-  } else if (fESDTree) {
+    if (event < 0)
+      event = fRunLoader->GetNumberOfEvents() + event;
+  }
+  else if (fESDTree)
+  {
+    fESDTree->Refresh();
     maxEvent = fESDTree->GetEntries() - 1;
-  } else if (fRawReader) {
+    if (event < 0)
+      event = fESDTree->GetEntries() + event;
+  }
+  else if (fRawReader)
+  {
     maxEvent = 10000000;
+    if (event < 0) {
+      Error(kEH, "negative event id passed for raw-data as source. Operation not supported.");
+      return;
+    }
     Info(kEH, "number of events unknown for raw-data, setting max-event id to 10M.");
-  } else {
+  }
+  else
+  {
     throw (kEH + "neither RunLoader, ESD nor Raw loaded.");
   }
   if (event < 0 || event > maxEvent)
+  {
     throw (kEH + Form("event %d not present, available range [%d, %d].",
                       event, 0, maxEvent));
+  }
 
   TEveManager::TRedrawDisabler rd(gEve);
   gEve->Redraw3D(kFALSE, kTRUE); // Enforce drop of all logicals.
@@ -404,6 +453,38 @@ void AliEveEventManager::GotoEvent(Int_t event)
   AfterNewEventLoaded();
 }
 
+void AliEveEventManager::NextEvent()
+{
+  // Loads next event
+  // either in automatic (online) or
+  // manual mode
+  
+  if (fIsOnline) {
+    if (fAutoLoadTimer) fAutoLoadTimer->Stop();
+
+    DestroyElements();
+
+    gSystem->ExitLoop();
+  }
+  else {
+    if (fEventId < GetMaxEventId(kTRUE))
+      GotoEvent(fEventId + 1);
+    else
+      GotoEvent(0);
+    StartStopAutoLoadTimer();
+  }
+}
+
+void AliEveEventManager::PrevEvent()
+{
+  // Loads previous event
+  // only in case of manual mode
+  if (!fIsOnline) {
+    GotoEvent(fEventId - 1);
+    StartStopAutoLoadTimer();
+  }
+}
+
 void AliEveEventManager::Close()
 {
   // Close the event files.
@@ -563,35 +644,6 @@ void AliEveEventManager::StartStopAutoLoadTimer()
   }
 }
 
-void AliEveEventManager::PrevEvent()
-{
-  // Loads previous event
-  // only in case of manual mode
-  if (!fIsOnline) {
-    GotoEvent(fEventId - 1);
-    StartStopAutoLoadTimer();
-  }
-}
-
-void AliEveEventManager::NextEvent()
-{
-  // Loads next event
-  // either in automatic (online) or
-  // manual mode
-  
-  if (fIsOnline) {
-    if (fAutoLoadTimer) fAutoLoadTimer->Stop();
-
-    DestroyElements();
-
-    gSystem->ExitLoop();
-  }
-  else {
-    GotoEvent(fEventId + 1);
-    StartStopAutoLoadTimer();
-  }
-}
-
 const char* AliEveEventManager::GetEventInfo() const
 {
   // Dumps the event-header contents
index e02bfcf2313117fb6ad6ae06f4c9af7dc4f8734e..267bc3db6bbcec405fef3268f064e5d1390fd668 100644 (file)
@@ -45,13 +45,14 @@ public:
   virtual ~AliEveEventManager();
 
 
-  virtual void Open();
-  void         SetEvent(AliRunLoader *runLoader, AliRawReader *rawReader, AliESDEvent *esd);
-           
-  virtual void GotoEvent(Int_t event);
-  virtual void NextEvent();
-  virtual void PrevEvent();
-  virtual void Close();
+  virtual void  Open();
+  void          SetEvent(AliRunLoader *runLoader, AliRawReader *rawReader, AliESDEvent *esd);
+  virtual Int_t GetMaxEventId(Bool_t refreshESD=kFALSE) const;     
+  virtual void  GotoEvent(Int_t event);
+  virtual void  NextEvent();
+  virtual void  PrevEvent();
+  virtual void  Close();
+
 
   Int_t         GetEventId()   const { return fEventId; }
   AliRunLoader* GetRunLoader() const { return fRunLoader; }
diff --git a/EVE/alice-macros/event_first.C b/EVE/alice-macros/event_first.C
new file mode 100644 (file)
index 0000000..615c4b7
--- /dev/null
@@ -0,0 +1,17 @@
+// $Id: event_goto.C 24485 2008-03-13 15:27:38Z mtadel $
+// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 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.                                                 *
+ **************************************************************************/
+
+void event_first()
+{
+  if (gAliEveEvent == 0) {
+    printf("AliEveEventManager is not initialized!\n");
+    return;
+  }
+  gAliEveEvent->GotoEvent(0);
+}
diff --git a/EVE/alice-macros/event_last.C b/EVE/alice-macros/event_last.C
new file mode 100644 (file)
index 0000000..53b55ee
--- /dev/null
@@ -0,0 +1,17 @@
+// $Id: event_goto.C 24485 2008-03-13 15:27:38Z mtadel $
+// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 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.                                                 *
+ **************************************************************************/
+
+void event_last()
+{
+  if (gAliEveEvent == 0) {
+    printf("AliEveEventManager is not initialized!\n");
+    return;
+  }
+  gAliEveEvent->GotoEvent(-1);
+}