]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTHOMERManager.cxx
set owner for tlist
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTHOMERManager.cxx
index d28b760f3fc7f88b214eaa52742d46e31de7fd36..18ad84efe8da307767e2da17db6ab2092ddeb114 100644 (file)
@@ -62,6 +62,7 @@ ClassImp(AliHLTHOMERManager)
   fSourceList(NULL),
   fNBlks(0),
   fEventID(),
+  fEventId(-1),
   fCurrentBlk(0),
   fAsyncBlockList(NULL),
   fBlockList(NULL),
@@ -127,7 +128,7 @@ AliHLTHOMERManager::~AliHLTHOMERManager() {
   fBlockList = NULL;
 
   if ( fAsyncBlockList ) {
-    fAsyncBlockList->Clear();
+    fAsyncBlockList->Delete();
     delete fAsyncBlockList;
   }
   fAsyncBlockList = NULL;
@@ -148,11 +149,11 @@ Int_t AliHLTHOMERManager::Initialize() {
   if ( fProxyHandler ) {
     iResult = fProxyHandler->Initialize();
     if (iResult)
-      HLTError(Form("Initialize of ProxyHandler failed."));
+      HLTError("Initialize of ProxyHandler failed.");
   
   } else {
     iResult = -1;
-    HLTError(Form("Creating of ProxyHandler failed."));
+    HLTError("Creating of ProxyHandler failed.");
   }
  
   // -- Initialize ReaderList
@@ -197,6 +198,12 @@ Int_t AliHLTHOMERManager::Initialize() {
 Int_t AliHLTHOMERManager::CreateSourcesList() {
   // see header file for class documentation
 
+  if (fProxyHandler == NULL)
+  {
+    HLTError("The object must first be initialised with a call to Initialize().");
+    return -1;
+  }
+
   Int_t iResult = 0;
 
   if ( fSourceList != NULL )
@@ -208,17 +215,17 @@ Int_t AliHLTHOMERManager::CreateSourcesList() {
 
   iResult = fProxyHandler->FillSourceList( fSourceList );
   if ( iResult < 0 ) {
-    HLTWarning(Form("There have been errors, while creating the sources list."));
+    HLTWarning("There have been errors, while creating the sources list.");
   }
   else if ( iResult > 0 ) {
-    HLTWarning(Form("No active services found."));
+    HLTWarning("No active services found.");
   }
   else if ( fSourceList->IsEmpty() ) {
-    HLTWarning(Form("No active services in the list."));
+    HLTWarning("No active services in the list.");
     iResult = 2;
   }
   else {
-     HLTInfo(Form("New sources list created."));
+     HLTInfo("New sources list created.");
 
     // -- New SourceList has been created 
     // --> All Sources are new --> State has changed
@@ -250,6 +257,12 @@ void AliHLTHOMERManager::SetSourceState( AliHLTHOMERSourceDesc * source, Bool_t
 Int_t AliHLTHOMERManager::ConnectHOMER( TString detector ){
   // see header file for class documentation
 
+  if (fReaderList == NULL or fSourceList == NULL)
+  {
+    HLTError("Must first create a source list with a call to CreateSourcesList().");
+    return -1;
+  }
+  
   Int_t iResult = 0;
 
   // HAck Jochen
@@ -258,13 +271,13 @@ Int_t AliHLTHOMERManager::ConnectHOMER( TString detector ){
 
   // -- Check if LibManager is present
   if ( ! fLibManager ) {
-    HLTError(Form("No LibManager present."));
+    HLTError("No LibManager present.");
     return -1;
   }
   
   // -- Check if already connected and state has not changed
   if ( fStateHasChanged == kFALSE && IsConnected() ) {
-    HLTInfo(Form("No need for reconnection."));
+    HLTInfo("No need for reconnection.");
     return 0;
   }
   
@@ -277,11 +290,16 @@ Int_t AliHLTHOMERManager::ConnectHOMER( TString detector ){
   // -- Create the Readoutlist
   UShort_t* sourcePorts = new UShort_t [fSourceList->GetEntries()];
   const Char_t ** sourceHostnames = new const Char_t* [fSourceList->GetEntries()];
+  for(Int_t i = 0; i < fSourceList->GetEntries(); i++) {
+   sourceHostnames[i] = "";
+  }
   UInt_t sourceCount = 0;
 
   CreateReadoutList( sourceHostnames, sourcePorts, sourceCount, detector );
   if ( sourceCount == 0 ) {
-    HLTError(Form("No sources selected, aborting."));
+    HLTError("No sources selected, aborting.");
+    delete [] sourcePorts;
+    delete [] sourceHostnames;
     return -2;
   }
 
@@ -299,7 +317,9 @@ Int_t AliHLTHOMERManager::ConnectHOMER( TString detector ){
     fReaderList->Add(dynamic_cast<TObject*>(fLibManager->OpenReader(sourceHostnames[idx], sourcePorts[idx])));
     AliHLTHOMERReader *reader = static_cast<AliHLTHOMERReader*>(fReaderList->Last());
     if ( !reader ) {
-      HLTError(Form("Adding reader failed, aborting"));
+      HLTError("Adding reader failed, aborting");
+      delete [] sourcePorts;
+      delete [] sourceHostnames;
       return -3;
     }
 
@@ -367,7 +387,7 @@ void AliHLTHOMERManager::DisconnectHOMER(){
   fStateHasChanged = kTRUE;
   fConnected = kFALSE;
   
-  HLTInfo(Form("Connection closed."));
+  HLTInfo("Connection closed.");
 
   return;
 }
@@ -383,7 +403,7 @@ Int_t AliHLTHOMERManager::ReconnectHOMER( TString detector="" ){
 
   iResult = ConnectHOMER(detector);
   if ( iResult ) {
-    HLTError(Form("Error reconnecting."));
+    HLTError("Error reconnecting.");
   }
 
   return iResult;
@@ -409,12 +429,12 @@ Int_t AliHLTHOMERManager::NextEvent(){
     return 55;//ConnectHOMER();
   }
   if ( !IsConnected() ) {
-    HLTWarning(Form( "Not connected yet." ));
+    HLTWarning("Not connected yet.");
     return -1;
   }
 
   // -- Reset asyncronous BlockList
-  fAsyncBlockList->Clear();
+  fAsyncBlockList->Delete();
 
   // ***
   // *** Loop over all readers and get new event data
@@ -479,12 +499,12 @@ Int_t AliHLTHOMERManager::NextEvent(){
     // -- Handle Blocks from current reader
     iResult = HandleBlocks();
     if ( iResult ) {
-      HLTError(Form("Handling of blocks failed."));
+      HLTError("Handling of blocks failed.");
     }
 
   } // while( (object = next()) ) {
 
-  return 0;  
+  return iResult;  
 }
 
 /* ---------------------------------------------------------------------------------
@@ -698,13 +718,6 @@ void AliHLTHOMERManager::AddToAsyncBlockList() {
     
 
     fAsyncBlockList->Add( block );
-
-    // -- Check sources list if block is requested
-    // if ( CheckIfRequested( block ) ) 
-    //   fAsyncBlockList->Add( block );
-    // else {
-    //   // XXX HACK Jochen
-    // }
  
   } while( GetNextBlk() );
 
@@ -715,7 +728,15 @@ void AliHLTHOMERManager::AddToBlockList() {
   // see header file for class documentation
   HLTInfo("Adding blocks to the synchroneous block list");
 
+  ULong_t eventID = static_cast<ULong64_t>(fCurrentReader->GetEventID());  
   
+  if ( fEventId == eventID ) {
+    HLTInfo(Form("Event 0x%016lX (%lu) already in buffer.", eventID, eventID));
+    return;
+  }
+
+  fEventId = eventID;
+
   GetFirstBlk();
   do {
 
@@ -728,7 +749,7 @@ void AliHLTHOMERManager::AddToBlockList() {
 }
 
 //__________________________________________________________________________________
-TList* AliHLTHOMERManager::GetBlockListEventBuffer( Int_t idx ) {
+TList* AliHLTHOMERManager::GetBlockListEventBuffer() {
   // see header file for class documentation
 
   if(fBlockList)
@@ -736,10 +757,6 @@ TList* AliHLTHOMERManager::GetBlockListEventBuffer( Int_t idx ) {
   else 
     return NULL;
 
-  if ( idx == -1 )
-    return NULL;
-  return reinterpret_cast<TList*>((*fEventBuffer)[idx]);
 
 }
 
@@ -765,6 +782,7 @@ Int_t AliHLTHOMERManager::HandleBlocks() {
     
   if ( IsSyncBlocks() ) {
     //AddBlockListToBuffer();
+    fBlockList->Clear();
     AddToBlockList();
   } else {
     AddToAsyncBlockList();
@@ -787,6 +805,11 @@ Bool_t AliHLTHOMERManager::IsSyncBlocks() {
       bResult = kTRUE;
       break;
     }
+
+    if ( !GetBlkType().CompareTo("GLOBTRIG")) {
+      bResult = kTRUE;
+      break;
+    }
     
     if ( !GetBlkType().CompareTo("ROOTTOBJ") ) {
       AliHLTHOMERBlockDesc blockDesc;
@@ -812,7 +835,7 @@ void* AliHLTHOMERManager::GetBlk( Int_t ndx ) {
   // Get pointer to current block in current event
    
   if ( !fCurrentReader || !IsConnected() ) {
-    HLTError(Form("Not connected yet."));
+    HLTError("Not connected yet.");
     return NULL;
   }
   if ( ndx < static_cast<Int_t>(fNBlks) )
@@ -826,7 +849,7 @@ ULong_t AliHLTHOMERManager::GetBlkSize( Int_t ndx ) {
   // see header file for class documentation
    
   if ( !fCurrentReader || !IsConnected() ) {
-    HLTError(Form("Not connected yet."));
+    HLTError("Not connected yet.");
     return 0;
   }
   
@@ -844,7 +867,7 @@ TString AliHLTHOMERManager::GetBlkOrigin( Int_t ndx ) {
 
   // -- Check for Connection
   if ( !fCurrentReader || ! IsConnected() ) {
-    HLTError(Form("Not connected yet."));
+    HLTError("Not connected yet.");
     return origin;
   }
 
@@ -880,7 +903,7 @@ TString AliHLTHOMERManager::GetBlkType( Int_t ndx ) {
 
   // -- Check for Connection
   if ( !fCurrentReader || ! IsConnected() ) {
-    HLTError(Form("Not connected yet."));
+    HLTError("Not connected yet.");
     return type;
   }
 
@@ -914,7 +937,7 @@ ULong_t AliHLTHOMERManager::GetBlkSpecification( Int_t ndx ) {
 
   // -- Check for Connection
   if ( !fCurrentReader || ! IsConnected() ) {
-    HLTError(Form("Not connected yet."));
+    HLTError("Not connected yet.");
     return 0;
   }
 
@@ -976,7 +999,7 @@ Bool_t AliHLTHOMERManager::CheckTriggerDecision() {
   Bool_t triggered = kFALSE;
 
   if ( !fCurrentReader || !IsConnected() ) {
-    HLTError(Form("Not connected yet."));
+    HLTError("Not connected yet.");
     return kFALSE;
   }
 
@@ -1002,7 +1025,7 @@ Bool_t AliHLTHOMERManager::CheckTriggerDecision() {
   } while( GetNextBlk() );
   
   if ( !foundTriggerBlock ) {
-    HLTError(Form("No trigger decision object found"));
+    HLTError("No trigger decision object found");
     return kFALSE;
   }