]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/EveHLT/AliEveHOMERManager.cxx
Wrong forward declaration.
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveHOMERManager.cxx
index 55c02e8ce3b44b9a455696187e626a9f981fc1e1..5738b62854022625598b7fc929b4623eebb6fa62 100644 (file)
@@ -1,16 +1,18 @@
 //-*- Mode: C++ -*-
 
 // $Id$
-// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
+// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007              *
 // Author: Jochen Thaeder <thaeder@kip.uni-heidelberg.de>                *
+// Author: 2010 Svein Lindal <slindal@fys.uio.no>                        *
 //         for The ALICE HLT Project.                                    *
 
 
 
 /** @file   AliEveHOMERManager.cxx
-    @author Jochen Thaeder
+    @author Jochen Thaeder,  
+    @author Svein Lindal <slindal@fys.uio.no>
     @date
-    @brief  Manger for HOMER in offline
+    @brief  Manager for HOMER events
 */
 
 #if __GNUC__>= 3
 
 #include "unistd.h"
 
+#include "AliHLTTriggerDecision.h"
 #include "AliEveHOMERManager.h"
+#include "AliHLTHOMERBlockDesc.h"
+#include "AliHLTHOMERManager.h"
+#include "AliEveHOMERSourceList.h"
 
+#include "TTimer.h"
 
 ClassImp(AliEveHOMERManager)
   
-/*
- * ---------------------------------------------------------------------------------
- *                            Constructor / Destructor
- * ---------------------------------------------------------------------------------
- */
-  
-//##################################################################################
+//____________________________________________________________________________________
 AliEveHOMERManager::AliEveHOMERManager() :
+TEveElementList("Homer Manager"),
   AliHLTHOMERManager(), 
-  TEveElementList("Homer Manager"),
   fSrcList(NULL),
-  fRetryCount(1),
-  fRetrySleeptime(10) {
-  // see header file for class documentation
-  // or
-  // refer to README to build package
-  // or
-  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+  fRetryCount(1000),
+  fRetrySleeptime(15),
+  fSourceListTimer(NULL)
+{
+  fSourceListTimer = new TTimer();
+  fSourceListTimer->Connect("Timeout()", "AliEveHOMERManager", this, "CreateEveSourcesListLoop()");
 }
 
-//##################################################################################
+//____________________________________________________________________________________
 AliEveHOMERManager::~AliEveHOMERManager() {
- // see header file for class documentation 
-
 // see header file for class documentation 
+  
   if (fSrcList)
     delete fSrcList;
   fSrcList = NULL;
-}
+  
+  
 
-/*
- * ---------------------------------------------------------------------------------
- *                                 Source Handling
- * ---------------------------------------------------------------------------------
- */
 
-//##################################################################################
+}
+
+ //____________________________________________________________________________________
 Int_t AliEveHOMERManager::CreateEveSourcesList() {
   // see header file for class documentation
 
   DestroyElements();
 
   Int_t iResult = CreateSourcesList();
-  
+
   fStateHasChanged = kTRUE;
   
+  HLTDebug(Form("iResult XXX %d", iResult));
   if ( iResult )
     return iResult;
 
-  if (fSrcList)
-    delete fSrcList;
-  fSrcList = NULL;
+
+  HLTDebug(Form("iResult %d", iResult));
+  if (fSrcList) {
+    HLTInfo("delete source list");
+    DestroyElements();
+    //delete fSrcList;
+    fSrcList = NULL;
+    //fSrcList->Clear();
+    HLTInfo("cleared source list");
+  }
+
 
   // -- Create new AliEVE sources list 
-  fSrcList = new AliEveHOMERSourceList("HLT Sources");
-  fSrcList->SetManager(this);
-    
-  AddElement(fSrcList);
-  fSrcList->CreateByType();
+  if(!fSrcList){
+    HLTInfo("no source list");
+    fSrcList = new AliEveHOMERSourceList("HLT Sources");
+    fSrcList->SetManager(this);
+    AddElement(fSrcList);
+  }
+  
+  //HLTInfo(Form("createbytype", iResult));
+  fSrcList->CreateByDet();
+  
+  HLTDebug(Form("Done creating source list %d", iResult));    
     
   return iResult;
 }
 
-//##################################################################################
+///_______________________________________________________________
+void AliEveHOMERManager::StartEveSourceListLoop() {
+  HLTInfo("Starting source list timer");
+  fSourceListTimer->Start(5000); 
+}
+///_______________________________________________________________
+void AliEveHOMERManager::StopEveSourceListLoop() {
+  fSourceListTimer->Stop(); 
+}
+
+
+//________________________________________________________________###
 Int_t AliEveHOMERManager::CreateEveSourcesListLoop() {
   // see header file for class documentation
 
-  Int_t iResult = 0;
+  HLTInfo("Attempting to create source list");
+  Int_t iResult = CreateEveSourcesList();
 
-  for ( Int_t retry = 0; retry < fRetryCount ; retry++ ) {
-  
-    iResult = CreateEveSourcesList();
-    if (!iResult) 
-      break;
-    
-    else if (iResult == 1) {
-      HLTWarning( Form("Couldn't find active services, sleeping %d s", fRetryCount) ) ;
-    }   
-    else if (iResult == 2) {
-      HLTWarning( Form("Services List empty, sleeping %d s", fRetryCount) ) ;
-    }
-    else {
-      HLTError( Form("Other problem ... \n") ); 
-      return iResult;
-    } 
-    
-    sleep(fRetrySleeptime);
+  if (!iResult) {
+    HLTInfo("Source list successfully created.");
+    StopEveSourceListLoop();
+    HLTInfo("Conneting to sources");
+    return ConnectEVEtoHOMER();
   }
+  
 
-  if ( iResult ) {
-    HLTWarning( Form("Couldn't find active services.") );
-    return iResult;
+  else if (iResult == 1) {
+    HLTWarning( Form("Couldn't find active services,"));
+  
+  } else if (iResult == 2) {
+    HLTWarning( Form("Services List empty, sleeping %d s before making new attempt.", fRetrySleeptime) ) ;
+  
+  } else {
+    HLTError( Form("Other problem ... \n") ); 
   } 
   
   return iResult;
 }
 
-//##################################################################################
+//________________________________________________________________
 Int_t AliEveHOMERManager::ConnectEVEtoHOMER( TString detector ) {
   // see header file for class documentation
-
+  HLTInfo("");
   fStateHasChanged = fSrcList->GetSelectedSources();
-  
+  HLTInfo(Form("has state changed % d", fStateHasChanged));
   return ConnectHOMER(detector);
 }
+
+
+//________________________________________________________________
+Int_t AliEveHOMERManager::ReConnectHOMER( TString /*detector*/ ){
+  // see header file for class documentation
+  Int_t iResult = 0;
+  if (Connected()) DisconnectHOMER();
+  CreateEveSourcesListLoop();
+  return iResult;
+}
+
+//_____________________________________________________________________________________
+TList * AliEveHOMERManager::NextHOMEREvent() {
+  //See header file for documentation  
+  
+  if(!Connected()) {
+    HLTInfo("Homer is not connected, trying to reconnect!");
+    ReConnectHOMER();
+    return NULL;
+  }
+  
+  
+  if ( NextEvent() ) {
+    HLTInfo("Failed getting next event, trying to reconnect");
+    ReConnectHOMER();
+    return NULL;
+  }
+  
+  return GetBlockList();
+  
+}