//-*- 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. *
fSourceList(NULL),
fNBlks(0),
fEventID(),
+ fEventId(-1),
fCurrentBlk(0),
fAsyncBlockList(NULL),
- fEventBuffer(NULL),
+ fBlockList(NULL),
+ fEventBuffer(NULL),
fBufferTopIdx(-1),
fBufferLowIdx(-1),
fCurrentBufferIdx(-1),
fNavigateBufferIdx(-1),
+ fNEventsAvailable(0),
fConnected(kFALSE),
fTriggerString("ALL"),
fNEventsNotTriggered(0),
- fRetryNextEvent(kFALSE) {
+ fRetryNextEvent(kFALSE),
+ fIsBlockOwner(kTRUE)
+{
// see header file for class documentation
// or
// refer to README to build package
}
fEventBuffer = NULL;
+ if(fBlockList) {
+ fBlockList->Clear();
+ delete fBlockList;
+ }
+ fBlockList = NULL;
+
if ( fAsyncBlockList ) {
- fAsyncBlockList->Clear();
+ 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 ) {
iResult = fProxyHandler->Initialize();
if (iResult)
- HLTError(Form("Initialize of ProxyHandler failed."));
- }
- else {
+ HLTError("Initialize of ProxyHandler failed.");
+
+ } else {
iResult = -1;
- HLTError(Form("Creating of ProxyHandler failed."));
+ HLTError("Creating of ProxyHandler failed.");
}
// -- Initialize ReaderList
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 );
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 ) {
- 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
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
// -- 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;
}
// -- 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;
}
for (UInt_t idx = 0; idx < sourceCount; idx++) {
+ if (sourcePorts[idx] > 60000)
+ continue;
+
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(Form("Adding reader failed, aborting"));
+ HLTError("Adding reader failed, aborting");
+ delete [] sourcePorts;
+ delete [] sourceHostnames;
return -3;
}
fStateHasChanged = kTRUE;
fConnected = kFALSE;
- HLTInfo(Form("Connection closed."));
+ HLTInfo("Connection closed.");
return;
}
iResult = ConnectHOMER(detector);
if ( iResult ) {
- HLTError(Form("Error reconnecting."));
+ HLTError("Error reconnecting.");
}
return iResult;
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
// -- Handle Blocks from current reader
iResult = HandleBlocks();
if ( iResult ) {
- HLTError(Form("Handling of blocks failed."));
+ HLTError("Handling of blocks failed.");
}
} // while( (object = next()) ) {
- // -- Check if NextEvent should be recalled,
- // to catch the next event with a trigger
- if ( fRetryNextEvent ) {
- usleep(1000000);
- fRetryNextEvent = kFALSE;
-
- HLTInfo(Form("Checked trigger of %d events, without triggering", fNEventsNotTriggered));
- return NextEvent();
- }
- else
- return 0;
+ return iResult;
}
/* ---------------------------------------------------------------------------------
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;
newIdx = 0;
fCurrentBufferIdx = fNavigateBufferIdx = newIdx;
+ fNEventsAvailable -= 1;
- return newIdx;
+ HLTInfo(Form("fNavigateBufferIdx: %d, fCurrentBufferIdx %d, fBufferTopIdx %d", fNavigateBufferIdx, fCurrentBufferIdx, fBufferTopIdx));
+
+
+ return 0;
}
///////////////////////////////////////////////////////////////////////////////////
TIter next( fSourceList );
while ( ( source = dynamic_cast<AliHLTHOMERSourceDesc*>(next()) ) ) {
+ ///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
//##################################################################################
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));
+ HLTInfo(Form("Event 0x%016lX (%lu) already in buffer.", eventID, eventID));
return;
}
// -- Check if event should be selected on basis of trigger string
if( fTriggerString.CompareTo("ALL") ){
if ( !CheckTriggerDecision() ) {
- HLTInfo(Form("Event 0x%016LX (%Lu) is not triggered by %s.",
- eventID, eventID, fTriggerString.Data()));
+ HLTInfo("Event not triggered");
return;
+ } else {
+ HLTInfo("Event triggered");
}
}
else {
fBufferLowIdx = 0;
}
- fNavigateBufferIdx = fCurrentBufferIdx = fBufferTopIdx;
// -- 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();
+ HLTInfo(Form("fBlockList size %d", fBlockList->GetSize()));
GetFirstBlk();
// -- Check sources list if block is requested
if ( CheckIfRequested( block ) ) {
(reinterpret_cast<TList*>((*fEventBuffer)[fBufferTopIdx]))->Add( block );
+ fBlockList->Add(block);
}
else {
// 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;
}
GetFirstBlk();
- // -- Fill block list
do {
- // -- Create new block
AliHLTHOMERBlockDesc * block = new AliHLTHOMERBlockDesc();
block->SetBlock( GetBlk(), GetBlkSize(), GetBlkOrigin(),
GetBlkType(), GetBlkSpecification() );
- // -- Check sources list if block is requested
- if ( CheckIfRequested( block ) )
- fAsyncBlockList->Add( block );
- else {
- // XXX HACK Jochen
- fAsyncBlockList->Add( block );
- // delete block;
- // block = NULL;
- }
+
+ fAsyncBlockList->Add( block );
} while( GetNextBlk() );
return;
}
-//##################################################################################
-TList* AliHLTHOMERManager::GetBlockListEventBuffer( Int_t idx ) {
+//__________________________________________________________________________________
+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;
+ }
- if ( idx == -1 )
+ 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;
- return reinterpret_cast<TList*>((*fEventBuffer)[idx]);
}
-/*
- * ---------------------------------------------------------------------------------
- * Block Handling - private
- * ---------------------------------------------------------------------------------
- */
-//##################################################################################
+//__________________________________________________________________________________
Int_t AliHLTHOMERManager::HandleBlocks() {
// see header file for class documentation
// -- Check if blocks present
if ( fNBlks == 0 ) {
- HLTWarning(Form("Event 0x%016LX (%Lu) with no blocks", eventID, eventID));
+ 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 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 = fCurrentReader->GetBlockDataType(ii);
- void *tmp21 = tmp2;
- ULong_t* tmp22 = static_cast<ULong_t*>(tmp21);
- *tmp22 = fCurrentReader->GetBlockDataOrigin(ii);
- HLTInfo(Form( "Block %lu length: %lu - type: %s - origin: %s - spec 0x%08X",
- ii, fCurrentReader->GetBlockDataLength(ii), tmp1, tmp2, fCurrentReader->GetBlockDataSpec(ii) ));
- } // end for ( ULong_t ii = 0; ii < fNBlks; ii++ ) {
-#endif
+ HLTInfo(Form("Event 0x%016lX (%lu) with %lu blocks", eventID, eventID, fNBlks));
- // -- Check if blocks are from syncronous source
+ if ( IsSyncBlocks() ) {
+ //AddBlockListToBuffer();
+ fBlockList->Clear();
+ AddToBlockList();
+ } else {
+ AddToAsyncBlockList();
+ }
- if ( IsSyncBlocks() )
- AddBlockListToBuffer();
- else
- AddToAsyncBlockList();
-
return iResult;
}
-//##################################################################################
+//__________________________________________________________________________________
Bool_t AliHLTHOMERManager::IsSyncBlocks() {
// see header file for class documentation
bResult = kTRUE;
break;
}
+
+ if ( !GetBlkType().CompareTo("GLOBTRIG")) {
+ bResult = kTRUE;
+ break;
+ }
if ( !GetBlkType().CompareTo("ROOTTOBJ") ) {
AliHLTHOMERBlockDesc blockDesc;
// 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) )
// see header file for class documentation
if ( !fCurrentReader || !IsConnected() ) {
- HLTError(Form("Not connected yet."));
+ HLTError("Not connected yet.");
return 0;
}
// -- Check for Connection
if ( !fCurrentReader || ! IsConnected() ) {
- HLTError(Form("Not connected yet."));
+ HLTError("Not connected yet.");
return origin;
}
// -- Check for Connection
if ( !fCurrentReader || ! IsConnected() ) {
- HLTError(Form("Not connected yet."));
+ HLTError("Not connected yet.");
return type;
}
// -- Check for Connection
if ( !fCurrentReader || ! IsConnected() ) {
- HLTError(Form("Not connected yet."));
+ HLTError("Not connected yet.");
return 0;
}
Bool_t triggered = kFALSE;
if ( !fCurrentReader || !IsConnected() ) {
- HLTError(Form("Not connected yet."));
- return NULL;
+ HLTError("Not connected yet.");
+ return kFALSE;
}
AliHLTHOMERBlockDesc blockDesc;
} while( GetNextBlk() );
if ( !foundTriggerBlock ) {
- HLTError(Form("No trigger decision object found"));
+ HLTError("No trigger decision object found");
return kFALSE;
}