//-*- Mode: C++ -*-
-// $Id: AliHLTHOMERManager.cxx $
+// $Id$
//**************************************************************************
//* This file is property of and copyright by the ALICE HLT Project *
//* ALICE Experiment at CERN, All rights reserved. *
using namespace std;
#endif
-#define EVE_DEBUG 1
+#define EVE_DEBUG 0
#include "AliHLTHOMERManager.h"
// -- -- -- -- -- -- --
#include "AliHLTHOMERSourceDesc.h"
#include "AliHLTHOMERBlockDesc.h"
// -- -- -- -- -- -- --
-#include "AliLog.h"
+#include "AliHLTGlobalTriggerDecision.h"
+#include "AliHLTTriggerDecision.h"
+//---------------------------
+
ClassImp(AliHLTHOMERManager)
/*
//##################################################################################
AliHLTHOMERManager::AliHLTHOMERManager() :
fLibManager(new AliHLTHOMERLibManager),
+ fStateHasChanged(kTRUE),
fProxyHandler(NULL),
- fReader(NULL),
+ fCurrentReader(NULL),
+ fReaderList(NULL),
fSourceList(NULL),
- fBlockList(NULL),
fNBlks(0),
- fEventID(0),
+ fEventID(),
+ fEventId(-1),
fCurrentBlk(0),
- fConnected(kFALSE),
- fStateHasChanged(kTRUE) {
+ fAsyncBlockList(NULL),
+ fBlockList(NULL),
+ fEventBuffer(NULL),
+ fBufferTopIdx(-1),
+ fBufferLowIdx(-1),
+ fCurrentBufferIdx(-1),
+ fNavigateBufferIdx(-1),
+ fNEventsAvailable(0),
+ fConnected(kFALSE),
+ fTriggerString("ALL"),
+ fNEventsNotTriggered(0),
+ fRetryNextEvent(kFALSE),
+ fIsBlockOwner(kTRUE)
+{
// see header file for class documentation
// or
// refer to README to build package
// see header file for class documentation
if ( fLibManager ) {
- if ( fReader )
- fLibManager->DeleteReader(fReader);
+
+ if ( fReaderList ) {
+ TIter next(fReaderList);
+ TObject * object = NULL;
+ while ( ( object = next()) )
+ fLibManager->DeleteReader(static_cast<AliHLTHOMERReader*>(object) );
+
+ fReaderList->Clear();
+ delete fReaderList;
+ }
+ fReaderList = NULL;
+
delete fLibManager;
- fLibManager = NULL;
- fReader = NULL;
- }
+ }
+ fLibManager = NULL;
if ( fProxyHandler != NULL )
delete fProxyHandler;
delete fSourceList;
fSourceList = NULL;
- if ( fBlockList != NULL )
+ if ( fEventBuffer ) {
+ fEventBuffer->Clear();
+ delete fEventBuffer;
+ }
+ fEventBuffer = NULL;
+
+ if(fBlockList) {
+ fBlockList->Clear();
delete fBlockList;
+ }
fBlockList = NULL;
+
+ if ( fAsyncBlockList ) {
+ fAsyncBlockList->Delete();
+ delete fAsyncBlockList;
+ }
+ fAsyncBlockList = NULL;
}
//##################################################################################
Int_t AliHLTHOMERManager::Initialize() {
// see header file for class documentation
+ HLTInfo("Initializing");
+
Int_t iResult = 0;
+ // -- Initialize ProxyHandler
if ( !fProxyHandler )
fProxyHandler = new AliHLTHOMERProxyHandler();
if ( fProxyHandler ) {
iResult = fProxyHandler->Initialize();
if (iResult)
- AliError(Form("Initialize of ProxyHandler failed."));
- }
- else {
+ HLTError("Initialize of ProxyHandler failed.");
+
+ } else {
iResult = -1;
- AliError(Form("Creating of ProxyHandler failed."));
+ HLTError("Creating of ProxyHandler failed.");
}
+ // -- Initialize ReaderList
+ // List ist not owner, as reader have to be created/deleted by the LibManager
+ if( !fReaderList )
+ fReaderList = new TList();
+
+ // -- Initialize asynchronous BlockList
+ if( !fAsyncBlockList ) {
+ fAsyncBlockList = new TList();
+ fAsyncBlockList->SetOwner(kTRUE);
+ }
+
+ //initialize normal block list
+ if( !fBlockList ) {
+ fBlockList = new TList();
+ fBlockList->SetOwner(kFALSE);
+ }
+
+ // -- Initialize Event Buffer and EventID array
+ if ( !fEventBuffer ) {
+ fEventBuffer = new TClonesArray( "TList", BUFFERSIZE );
+ }
+
+ for ( Int_t idx = 0; idx < BUFFERSIZE; ++idx ) {
+ new ((*fEventBuffer)[idx]) TList( );
+ (reinterpret_cast<TList*>((*fEventBuffer)[idx]))->SetOwner(kTRUE);
+
+ fEventID[idx] = 0;
+ }
+
return iResult;
}
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 )
delete fSourceList;
fSourceList = NULL;
iResult = fProxyHandler->FillSourceList( fSourceList );
if ( iResult < 0 ) {
- AliWarning(Form("There have been errors, while creating the sources list."));
+ HLTWarning("There have been errors, while creating the sources list.");
}
else if ( iResult > 0 ) {
- AliWarning(Form("No active services found."));
+ HLTWarning("No active services found.");
+ }
+ else if ( fSourceList->IsEmpty() ) {
+ HLTWarning("No active services in the list.");
+ iResult = 2;
}
else {
- AliInfo(Form("New sources list created."));
+ HLTInfo("New sources list created.");
// -- New SourceList has been created
// --> All Sources are new --> State has changed
/*
* ---------------------------------------------------------------------------------
- * Connection Handling -oublic
+ * Connection Handling - public
* ---------------------------------------------------------------------------------
*/
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
+ //----
+ detector="ALL";
+
+ // -- Check if LibManager is present
+ if ( ! fLibManager ) {
+ HLTError("No LibManager present.");
+ return -1;
+ }
+
// -- Check if already connected and state has not changed
if ( fStateHasChanged == kFALSE && IsConnected() ) {
- AliInfo(Form("No need for reconnection."));
- return iResult;
+ HLTInfo("No need for reconnection.");
+ return 0;
}
-
+
// -- If already connected, disconnect before connect
- if ( IsConnected() )
+ // or if ReaderList already filled
+ if ( IsConnected() || fReaderList->GetSize() != 0 ) {
+ HLTInfo(Form("IsConnected: %d fReaderList.Size: %d", IsConnected(), fReaderList->GetSize()));
DisconnectHOMER();
-
+ }
// -- Create the Readoutlist
UShort_t* sourcePorts = new UShort_t [fSourceList->GetEntries()];
- const char ** sourceHostnames = new const char* [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 ) {
- AliError(Form("No sources selected, aborting."));
- return -1;
+ HLTError("No sources selected, aborting.");
+ delete [] sourcePorts;
+ delete [] sourceHostnames;
+ return -2;
}
+ // ***
// *** Connect to data sources
- if ( !fReader && fLibManager )
- fReader = fLibManager->OpenReader( sourceCount, sourceHostnames, sourcePorts );
- else {
- AliError(Form("No LibManager present."));
- return -2;
- }
+ // ***
+
+ for (UInt_t idx = 0; idx < sourceCount; idx++) {
- iResult = fReader->GetConnectionStatus();
- if ( iResult ) {
- // -- Connection failed
-
- UInt_t ndx = fReader->GetErrorConnectionNdx();
+ if (sourcePorts[idx] > 60000)
+ continue;
- if ( ndx < sourceCount ) {
- AliError(Form("Error establishing connection to TCP source %s:%hu: %s (%d)",
- sourceHostnames[ndx], sourcePorts[ndx], strerror(iResult), iResult));
- }
- else {
- AliError(Form("Error establishing connection to unknown source with index %d: %s (%d)",
- ndx, strerror(iResult), iResult));
+ HLTInfo(Form("Adding source %d as %s : %d", idx, sourceHostnames[idx], sourcePorts[idx]));
+
+ fReaderList->Add(dynamic_cast<TObject*>(fLibManager->OpenReader(sourceHostnames[idx], sourcePorts[idx])));
+ AliHLTHOMERReader *reader = static_cast<AliHLTHOMERReader*>(fReaderList->Last());
+ if ( !reader ) {
+ HLTError("Adding reader failed, aborting");
+ delete [] sourcePorts;
+ delete [] sourceHostnames;
+ return -3;
}
- if ( fReader )
- fLibManager->DeleteReader( fReader );
- fReader = NULL;
- }
- else {
- // -- Connection ok - set reader
- fConnected = kTRUE;
+ if ( (iResult = reader->GetConnectionStatus()) ) {
- AliInfo(Form("Connection established."));
- }
+ // -- Connection to source failed
+
+ HLTError(Form("Error establishing connection to TCP source %s:%hu: %s (%d)",
+ sourceHostnames[idx], sourcePorts[idx], strerror(iResult), iResult));
+
+ if( !(TString(sourceHostnames[idx]).CompareTo("localhost")) ) {
+ HLTInfo("The failed connection is on localhost. is SSH tunnel up????? ");
+ HLTInfo(Form("Do: 'ssh -L %d:alihlt-vobox0.cern.ch:%d cernUser@lxplus.cern.ch -fN'",
+ sourcePorts[idx], sourcePorts[idx]));
+ }
+
+ // -- Remove reader
+ fReaderList->RemoveLast();
+
+ if ( reader )
+ fLibManager->DeleteReader( reader );
+ reader = NULL;
+
+ HLTInfo(Form("Removed source %d, %s : %d from sourceList", idx, sourceHostnames[idx], sourcePorts[idx]));
+
+ }
+ else {
+ // -- Connection succeded
+ fConnected = kTRUE;
+ HLTInfo(Form("Connection established to source %s on port %d", sourceHostnames[idx], sourcePorts[idx]));
+ }
+
+ } // for (Int_t idx = 0; idx < sourceCount; idx++) {
+
delete[] sourceHostnames;
delete[] sourcePorts;
return iResult;
+
}
//##################################################################################
void AliHLTHOMERManager::DisconnectHOMER(){
// see header file for class documentation
- if ( ! IsConnected() )
- return;
-
- if ( fReader )
- fLibManager->DeleteReader( fReader );
- fReader = NULL;
-
+ HLTInfo("Disconnecting");
+
+ if ( fReaderList && fLibManager ) {
+ HLTInfo("Deleting readerlist and libmanager");
+ TIter next(fReaderList);
+ TObject * object = NULL;
+ while ( ( object = next()) )
+ fLibManager->DeleteReader(static_cast<AliHLTHOMERReader*>(object) );
+
+
+ HLTInfo(Form("fReaderList size %d", fReaderList->GetSize()));
+ fReaderList->Clear();
+ HLTInfo(Form("fReaderList size %d", fReaderList->GetSize()));
+ delete fReaderList;
+ fReaderList = new TList ();
+ HLTInfo(Form("fReaderList size %d", fReaderList->GetSize()));
+ }
+
fStateHasChanged = kTRUE;
fConnected = kFALSE;
-
- AliInfo(Form("Connection closed."));
+
+ HLTInfo("Connection closed.");
return;
}
iResult = ConnectHOMER(detector);
if ( iResult ) {
- AliError(Form("Error reconnecting."));
+ HLTError("Error reconnecting.");
}
return iResult;
* ---------------------------------------------------------------------------------
*/
-
//##################################################################################
Int_t AliHLTHOMERManager::NextEvent(){
+
// see header file for class documentation
-
+
Int_t iResult = 0;
Int_t iRetryCount = 0;
-
- if ( !fReader || ! IsConnected() ) {
- AliWarning(Form( "Not connected yet." ));
+
+ if ( !IsConnected() || fStateHasChanged ) {
+ HLTInfo("Not connected or state has changed, returning to AliEveHOMERManager, which will deal with this situation");
+ // cout << "connectecd " << IsConnected() << "haschanged "<<fStateHasChanged << endl;
+ return 55;//ConnectHOMER();
+ }
+ if ( !IsConnected() ) {
+ HLTWarning("Not connected yet.");
return -1;
}
- // fReader->SetEventRequestAdvanceTime( 20000000 /*timeout in us*/ );
+ // -- Reset asyncronous BlockList
+ fAsyncBlockList->Delete();
- // -- Read next event data and error handling for HOMER (error codes and empty blocks)
- while( 1 ) {
+ // ***
+ // *** Loop over all readers and get new event data
+ // ***
+
+ TIter next(fReaderList);
+ TObject * object = NULL;
+
+ while( (object = next()) ) {
- iResult = fReader->ReadNextEvent( 40000000 /*timeout in us*/);
-
- if ( iResult == 111 || iResult == 32 || iResult == 6 ) {
- AliError(Form("No Connection to source %d: %s (%d)",
- fReader->GetErrorConnectionNdx(), strerror(iResult), iResult));
- return -iResult;
- }
- else if ( iResult == 110 ) {
- AliError(Form("Timout occured, reading event from source %d: %s (%d)",
- fReader->GetErrorConnectionNdx(), strerror(iResult), iResult));
- return -iResult;
- }
- else if ( iResult == 56) {
- ++iRetryCount;
-
- if ( iRetryCount >= 20 ) {
- AliError(Form("Retry Failed: Error reading event from source %d: %s (%d)",
- fReader->GetErrorConnectionNdx(), strerror(iResult), iResult));
- return -iResult;
+ fCurrentReader = static_cast<AliHLTHOMERReader*>(object);
+
+ // -- Read next event data and error handling for HOMER (error codes and empty blocks)
+ while ( 1 ) {
+
+ iResult = fCurrentReader->ReadNextEvent( 40000000 /*timeout in us*/);
+
+ if ( iResult == 111 || iResult == 32 || iResult == 6 ) {
+ HLTError(Form("No connection to source %d: %s (%d)",
+ fCurrentReader->GetErrorConnectionNdx(), strerror(iResult), iResult));
+ break;
+ }
+ else if ( iResult == 110 ) {
+ HLTError(Form("Timeout occured, reading event from source %d: %s (%d)",
+ fCurrentReader->GetErrorConnectionNdx(), strerror(iResult), iResult));
+ break;
+ }
+ else if ( iResult == 56 ) {
+ ++iRetryCount;
+
+ if ( iRetryCount >= 20 ) {
+ HLTError(Form("Retry Failed: Error reading event from source %d: %s (%d), returning",
+ fCurrentReader->GetErrorConnectionNdx(), strerror(iResult), iResult));
+ break;
+ }
+ else {
+ HLTError(Form("Retry: Error reading event from source %d: %s (%d), making another attempt (no %d out of 20)",
+ fCurrentReader->GetErrorConnectionNdx(), strerror(iResult), iResult, iRetryCount));
+ //break;
+ continue;
+ }
}
+ else if ( iResult ) {
+ HLTError(Form("General Error reading event from source %d: %s (%d), giving up",
+ fCurrentReader->GetErrorConnectionNdx(), strerror(iResult), iResult));
+ fConnected = kFALSE;
+ break;
+ }
else {
- AliError(Form("Retry: Error reading event from source %d: %s (%d)",
- fReader->GetErrorConnectionNdx(), strerror(iResult), iResult));
- continue;
+ HLTDebug("Successfully read out event from source");
+ break;
}
+
+ } // while( 1 ) {
+
+ // -- Check if event could be read
+ if ( iResult ) {
+ HLTInfo("Reading event from source failed");
+ continue;
}
- else if ( iResult ) {
- AliError(Form("General Error reading event from source %d: %s (%d)",
- fReader->GetErrorConnectionNdx(), strerror(iResult), iResult));
- fConnected = kFALSE;
- return -iResult;
- }
- else {
- break;
+
+ // -- Handle Blocks from current reader
+ iResult = HandleBlocks();
+ if ( iResult ) {
+ HLTError("Handling of blocks failed.");
}
- } // while( 1 ) {
- // -- Get blockCnt and eventID
- fNBlks = static_cast<ULong_t>(fReader->GetBlockCnt());
- fEventID = static_cast<ULong64_t>(fReader->GetEventID());
- fCurrentBlk = 0;
+ } // while( (object = next()) ) {
- AliInfo(Form("Event 0x%016LX (%Lu) with %lu blocks", fEventID, fEventID, fNBlks));
+ return iResult;
+}
-#if EVE_DEBUG
- // Loop for Debug only
- for ( ULong_t ii = 0; ii < fNBlks; ii++ ) {
- Char_t tmp1[9], tmp2[5];
- memset( tmp1, 0, 9 );
- memset( tmp2, 0, 5 );
- void *tmp11 = tmp1;
- ULong64_t* tmp12 = static_cast<ULong64_t*>(tmp11);
- *tmp12 = fReader->GetBlockDataType(ii);
- void *tmp21 = tmp2;
- ULong_t* tmp22 = static_cast<ULong_t*>(tmp21);
- *tmp22 = fReader->GetBlockDataOrigin(ii);
- AliInfo(Form( "Block %lu length: %lu - type: %s - origin: %s - spec 0x%08X",
- ii, fReader->GetBlockDataLength(ii), tmp1, tmp2, fReader->GetBlockDataSpec(ii) ));
- } // end for ( ULong_t ii = 0; ii < fNBlks; ii++ ) {
-#endif
+/* ---------------------------------------------------------------------------------
+ * Buffer Handling - public
+ * ---------------------------------------------------------------------------------
+ */
- // -- Create BlockList
- AliInfo(Form("Create Block List"));
- CreateBlockList();
+//##################################################################################
+Int_t AliHLTHOMERManager::NavigateEventBufferBack() {
+ // see header file for class documentation
- return iResult;
+ // -- reached the end of the buffer
+ if ( fNavigateBufferIdx == fBufferLowIdx )
+ return -1;
+
+ Int_t newIdx = fNavigateBufferIdx - 1;
+ if ( newIdx == -1 )
+ newIdx = BUFFERSIZE-1;
+
+ fCurrentBufferIdx = fNavigateBufferIdx = newIdx;
+
+ return newIdx;
}
+//##################################################################################
+Int_t AliHLTHOMERManager::NavigateEventBufferFwd() {
+ // see header file for class documentation
+
+ HLTInfo(Form("fNavigateBufferIdx: %d, fCurrentBufferIdx %d, fBufferTopIdx %d", fNavigateBufferIdx, fCurrentBufferIdx, fBufferTopIdx));
+
+ // -- reached the top of the buffer
+ if ( fNavigateBufferIdx == fBufferTopIdx )
+ return -1;
+
+ Int_t newIdx = fNavigateBufferIdx + 1;
+ if ( newIdx == BUFFERSIZE )
+ newIdx = 0;
+
+ fCurrentBufferIdx = fNavigateBufferIdx = newIdx;
+ fNEventsAvailable -= 1;
+
+ HLTInfo(Form("fNavigateBufferIdx: %d, fCurrentBufferIdx %d, fBufferTopIdx %d", fNavigateBufferIdx, fCurrentBufferIdx, fBufferTopIdx));
+
+
+ return 0;
+}
+
+ ///////////////////////////////////////////////////////////////////////////////////
+
/*
* ---------------------------------------------------------------------------------
* Connection Handling - private
TIter next( fSourceList );
while ( ( source = dynamic_cast<AliHLTHOMERSourceDesc*>(next()) ) ) {
- printf("DAT = %s\n",detector.Data());
+ ///Don't use sources from dev cluster
+ if(source->GetPort() > 60000) continue;
// -- If detector NO detector name given
if ( ! detector.CompareTo("ALL") ) {
// -- Continue if source is not selected
- if ( ! source->IsSelected() )
- continue;
+ // HACK Jochen
+ //if ( ! source->IsSelected() )
+ // continue;
}
// -- DetectorName given
else {
/*
* ---------------------------------------------------------------------------------
- * Event Handling
+ * Buffer Handling - private
* ---------------------------------------------------------------------------------
*/
-
//##################################################################################
-void AliHLTHOMERManager::CreateBlockList() {
+void AliHLTHOMERManager::AddBlockListToBuffer() {
// see header file for class documentation
+ // -- Check if event is already in buffer
+ ULong_t eventID = static_cast<ULong64_t>(fCurrentReader->GetEventID());
+
+ if ( fEventID[fBufferTopIdx] == eventID ) {
+ HLTInfo(Form("Event 0x%016lX (%lu) already in buffer.", eventID, eventID));
+ return;
+ }
- // -- Initialize block list
- if ( fBlockList != NULL )
- delete fBlockList;
- fBlockList = NULL;
+ // -- Check if event should be selected on basis of trigger string
+ if( fTriggerString.CompareTo("ALL") ){
+ if ( !CheckTriggerDecision() ) {
+ HLTInfo("Event not triggered");
+ return;
+ } else {
+ HLTInfo("Event triggered");
+ }
+ }
+ else {
+ HLTDebug("No trigger selection.");
+ }
+
+ // -- Set Top mark
+ ++fBufferTopIdx;
+ if ( fBufferTopIdx == BUFFERSIZE )
+ fBufferTopIdx = 0;
+
+ // -- Change the low mark if necessary
+ if ( fBufferLowIdx == -1 )
+ fBufferLowIdx = 0;
+ else if ( fBufferTopIdx == fBufferLowIdx ) {
+ ++fBufferLowIdx;
+ if ( fBufferLowIdx == BUFFERSIZE )
+ fBufferLowIdx = 0;
+ }
+
+
+ // -- Fill EventID
+ fEventID[fBufferTopIdx] = eventID;
+ // -- Clear Buffer slot
+ (reinterpret_cast<TList*>((*fEventBuffer)[fBufferTopIdx]))->Clear();
+ if(fBlockList->IsOwner()) HLTWarning("block list is owner!!");
+ HLTInfo(Form("fBlockList size %d", fBlockList->GetSize()));
+ //fBlockList->Clear();
fBlockList = new TList();
- fBlockList->SetOwner(kTRUE);
+ HLTInfo(Form("fBlockList size %d", fBlockList->GetSize()));
GetFirstBlk();
GetBlkType(), GetBlkSpecification() );
// -- Check sources list if block is requested
- if ( CheckIfRequested( block ) )
- fBlockList->Add( block );
+ if ( CheckIfRequested( block ) ) {
+ (reinterpret_cast<TList*>((*fEventBuffer)[fBufferTopIdx]))->Add( block );
+ fBlockList->Add(block);
+ }
else {
- delete block;
- block = NULL;
+ // XXX HACK Jochen
+ (reinterpret_cast<TList*>((*fEventBuffer)[fBufferTopIdx]))->Add( block );
+ fBlockList->Add(block);
+ // delete block;
+ // block = NULL;
}
} while( GetNextBlk() );
+
+ //We have one more event available
+ fNEventsAvailable++;
+ HLTInfo(Form("fNEventsAvailable %d", fNEventsAvailable));
+ return;
+}
+
+//##################################################################################
+void AliHLTHOMERManager::AddToAsyncBlockList() {
+ // see header file for class documentation
+
+ HLTInfo("Adding blocks to the asynchroneous block list");
+
+ GetFirstBlk();
+
+ do {
+ AliHLTHOMERBlockDesc * block = new AliHLTHOMERBlockDesc();
+ block->SetBlock( GetBlk(), GetBlkSize(), GetBlkOrigin(),
+ GetBlkType(), GetBlkSpecification() );
+
+
+ fAsyncBlockList->Add( block );
+
+ } while( GetNextBlk() );
+
return;
}
+//__________________________________________________________________________________
+void AliHLTHOMERManager::AddToBlockList() {
+ // see header file for class documentation
+ HLTInfo("Adding blocks to the synchroneous block list");
-/*
- * ---------------------------------------------------------------------------------
- * BlockHandling
- * ---------------------------------------------------------------------------------
- */
+ 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 {
+
+ AliHLTHOMERBlockDesc * block = new AliHLTHOMERBlockDesc();
+ block->SetBlock( GetBlk(), GetBlkSize(), GetBlkOrigin(),
+ GetBlkType(), GetBlkSpecification() );
+ fBlockList->Add( block );
+
+ } while( GetNextBlk() );
+}
+
+//__________________________________________________________________________________
+TList* AliHLTHOMERManager::GetBlockListEventBuffer() {
+ // see header file for class documentation
+
+ if(fBlockList)
+ return fBlockList;
+ else
+ return NULL;
+
+
+}
+
+
+//__________________________________________________________________________________
+Int_t AliHLTHOMERManager::HandleBlocks() {
+ // see header file for class documentation
+
+ Int_t iResult = 0;
+
+ // -- Get blockCnt and eventID
+ fNBlks = static_cast<ULong_t>(fCurrentReader->GetBlockCnt());
+ ULong_t eventID = static_cast<ULong64_t>(fCurrentReader->GetEventID());
+ fCurrentBlk = 0;
+
+ // -- Check if blocks present
+ if ( fNBlks == 0 ) {
+ HLTWarning(Form("Event 0x%016lX (%lu) with no blocks", eventID, eventID));
+ return -1;
+ }
+
+ HLTInfo(Form("Event 0x%016lX (%lu) with %lu blocks", eventID, eventID, fNBlks));
+
+ if ( IsSyncBlocks() ) {
+ //AddBlockListToBuffer();
+ fBlockList->Clear();
+ AddToBlockList();
+ } else {
+ AddToAsyncBlockList();
+ }
+
+ return iResult;
+}
+
+//__________________________________________________________________________________
+Bool_t AliHLTHOMERManager::IsSyncBlocks() {
+ // see header file for class documentation
+
+ Bool_t bResult = kFALSE;
+
+ GetFirstBlk();
+
+ do {
+
+ if ( !GetBlkType().CompareTo("ALIESDV0")) {
+ bResult = kTRUE;
+ break;
+ }
+
+ if ( !GetBlkType().CompareTo("GLOBTRIG")) {
+ bResult = kTRUE;
+ break;
+ }
+
+ if ( !GetBlkType().CompareTo("ROOTTOBJ") ) {
+ AliHLTHOMERBlockDesc blockDesc;
+
+ blockDesc.SetBlock( GetBlk(), GetBlkSize(), GetBlkOrigin(),
+ GetBlkType(), GetBlkSpecification() );
+ if ( !blockDesc.GetClassName().CompareTo("AliHLTGlobalTriggerDecision") ) {
+
+ bResult = kTRUE;
+ break;
+ }
+ }
+
+ } while( GetNextBlk() );
+
+
+ return bResult;
+}
//##################################################################################
void* AliHLTHOMERManager::GetBlk( Int_t ndx ) {
// see header file for class documentation
// Get pointer to current block in current event
- if ( !fReader || !IsConnected() ) {
- AliError(Form("Not connected yet."));
+ if ( !fCurrentReader || !IsConnected() ) {
+ HLTError("Not connected yet.");
return NULL;
}
if ( ndx < static_cast<Int_t>(fNBlks) )
- return const_cast<void*> (fReader->GetBlockData(ndx));
+ return const_cast<void*> (fCurrentReader->GetBlockData(ndx));
else
return NULL;
}
ULong_t AliHLTHOMERManager::GetBlkSize( Int_t ndx ) {
// see header file for class documentation
- if ( !fReader || !IsConnected() ) {
- AliError(Form("Not connected yet."));
+ if ( !fCurrentReader || !IsConnected() ) {
+ HLTError("Not connected yet.");
return 0;
}
if ( ndx < static_cast<Int_t>(fNBlks) )
- return static_cast<ULong_t> (fReader->GetBlockDataLength(ndx));
+ return static_cast<ULong_t> (fCurrentReader->GetBlockDataLength(ndx));
else
return 0;
}
TString origin = "";
// -- Check for Connection
- if ( !fReader || ! IsConnected() ) {
- AliError(Form("Not connected yet."));
+ if ( !fCurrentReader || ! IsConnected() ) {
+ HLTError("Not connected yet.");
return origin;
}
// -- Check block index
if ( ndx >= static_cast<Int_t>(fNBlks) ) {
- AliError(Form("Block index %d out of range.", ndx ));
+ HLTError(Form("Block index %d out of range.", ndx ));
return origin;
}
Char_t array[4];
} reverseOrigin;
- reverseOrigin.data = static_cast<UInt_t>(fReader->GetBlockDataOrigin(ndx));
+ reverseOrigin.data = static_cast<UInt_t>(fCurrentReader->GetBlockDataOrigin(ndx));
// -- Reverse the order
for (Int_t ii = 3; ii >= 0; ii-- )
TString type = "";
// -- Check for Connection
- if ( !fReader || ! IsConnected() ) {
- AliError(Form("Not connected yet."));
+ if ( !fCurrentReader || ! IsConnected() ) {
+ HLTError("Not connected yet.");
return type;
}
// -- Check block index
if ( ndx >= static_cast<Int_t>(fNBlks) ) {
- AliError(Form("Block index %d out of range.", ndx ));
+ HLTError(Form("Block index %d out of range.", ndx ));
return type;
}
Char_t array[8];
} reverseType;
- reverseType.data = static_cast<ULong64_t> (fReader->GetBlockDataType(ndx));
+ reverseType.data = static_cast<ULong64_t> (fCurrentReader->GetBlockDataType(ndx));
// -- Reverse the order
for (Int_t ii = 7; ii >= 0; ii-- )
// see header file for class documentation
// -- Check for Connection
- if ( !fReader || ! IsConnected() ) {
- AliError(Form("Not connected yet."));
+ if ( !fCurrentReader || ! IsConnected() ) {
+ HLTError("Not connected yet.");
return 0;
}
// -- Check block index
if ( ndx >= static_cast<Int_t>(fNBlks) ) {
- AliError(Form("Block index %d out of range.", ndx ));
+ HLTError(Form("Block index %d out of range.", ndx ));
return 0;
}
- return static_cast<ULong_t>(fReader->GetBlockDataSpec(ndx));
+ return static_cast<ULong_t>(fCurrentReader->GetBlockDataSpec(ndx));
}
//##################################################################################
TIter next( fSourceList );
while ( ( source = dynamic_cast<AliHLTHOMERSourceDesc*>(next()) ) ) {
-
-
// -- Check if source is selected
if ( ! source->IsSelected() )
continue;
- else
- AliError(Form("IS SELECTED"));
// -- Check if detector matches
if ( source->GetSourceName().CompareTo( block->GetBlockName() ) )
#if EVE_DEBUG
if ( requested ) {
- AliInfo(Form("Block requested : %s", block->GetBlockName().Data()));
+ HLTInfo(Form("Block requested : %s", block->GetBlockName().Data()));
}
else {
- AliInfo(Form("Block NOT requested : %s", block->GetBlockName().Data()));
+ HLTInfo(Form("Block NOT requested : %s", block->GetBlockName().Data()));
}
#endif
return requested;
}
+/* ---------------------------------------------------------------------------------
+ * Trigger Handling - private
+ * ---------------------------------------------------------------------------------
+ */
+
+//##################################################################################
+Bool_t AliHLTHOMERManager::CheckTriggerDecision() {
+ // see header file for class documentation
+
+ Bool_t triggered = kFALSE;
+
+ if ( !fCurrentReader || !IsConnected() ) {
+ HLTError("Not connected yet.");
+ return kFALSE;
+ }
+
+ AliHLTHOMERBlockDesc blockDesc;
+
+ GetFirstBlk();
+
+ // -- Fill block list
+ Bool_t foundTriggerBlock = kFALSE;
+
+ do {
+ if ( (GetBlkType().CompareTo("ROOTTOBJ") == 0) ) {
+ blockDesc.SetBlock( GetBlk(), GetBlkSize(), GetBlkOrigin(),
+ GetBlkType(), GetBlkSpecification() );
+
+ if ( ! blockDesc.GetClassName().CompareTo("AliHLTGlobalTriggerDecision") ) {
+
+ foundTriggerBlock = kTRUE;
+ break;
+ }
+
+ }
+ } while( GetNextBlk() );
+
+ if ( !foundTriggerBlock ) {
+ HLTError("No trigger decision object found");
+ return kFALSE;
+ }
+
+ // -- Get the global decision object
+ AliHLTGlobalTriggerDecision* globalDecision =
+ static_cast<AliHLTGlobalTriggerDecision*>(blockDesc.GetTObject());
+
+ if ( fTriggerString.CompareTo("HLTGlobalTrigger") == 0 ) {
+ triggered = globalDecision->EventTriggered();
+ }
+ else {
+
+ for (Int_t idx = 0; idx < globalDecision->NumberOfInputObjects(); idx++) {
+
+ const AliHLTTriggerDecision* triggerDecision =
+ reinterpret_cast<const AliHLTTriggerDecision*>(globalDecision->InputObject(idx));
+
+ if ( !(fTriggerString.CompareTo(triggerDecision->Description())) ) {
+ triggered = triggerDecision->EventTriggered();
+ break;
+ }
+ } // for (Int_t idx = 0; idx < globalDecision->NumberOfInputObjects(); idx++) {
+ }
+
+
+
+ if ( triggered ) {
+ fRetryNextEvent = kFALSE;
+ fNEventsNotTriggered = 0;
+ }
+ else {
+ fRetryNextEvent = kTRUE;
+ ++fNEventsNotTriggered;
+ }
+
+ return triggered;
+}