//-*- 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 and Svein Lindal
+ @author Jochen Thaeder,
+ @author Svein Lindal <slindal@fys.uio.no>
@date
- @brief Manager for HOMER online
+ @brief Manager for HOMER events
*/
#if __GNUC__>= 3
#endif
#include "unistd.h"
-//#include "TIter.h"
+
+#include "AliHLTTriggerDecision.h"
#include "AliEveHOMERManager.h"
#include "AliHLTHOMERBlockDesc.h"
-//#include <TEveElementList.h>
#include "AliHLTHOMERManager.h"
-#include "AliHLTTriggerDecision.h"
+#include "AliEveHOMERSourceList.h"
+
+#include "TTimer.h"
ClassImp(AliEveHOMERManager)
-/*
- * ---------------------------------------------------------------------------------
- * Constructor / Destructor
- * ---------------------------------------------------------------------------------
- */
-
-//##################################################################################
+//____________________________________________________________________________________
AliEveHOMERManager::AliEveHOMERManager() :
-AliHLTHOMERManager(),
- TEveElementList("Homer Manager"),
- fSrcList(NULL),
- fRetryCount(1),
- fRetrySleeptime(10000)
+TEveElementList("Homer Manager"),
+ AliHLTHOMERManager(),
+ fSrcList(NULL),
+ fRetryCount(1000),
+ fRetrySleeptime(15),
+ fSourceListTimer(NULL)
{
-
-
-// see header file for class documentation
- // or
- // refer to README to build package
- // or
- // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+ 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 before making attempt %d out of %d", fRetrySleeptime, retry, fRetryCount) ) ;
- }
- else if (iResult == 2) {
- HLTWarning( Form("Services List empty, sleeping %d s", fRetrySleeptime) ) ;
- }
- 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();
+
+}