X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=HLT%2FBASE%2FAliHLTHOMERManager.cxx;h=18ad84efe8da307767e2da17db6ab2092ddeb114;hb=4aa34abc7ea939c982bbf688bb209d6a5922f214;hp=264f22785cc5275725cecbef4dc0ca3f6f11e388;hpb=337918956bcf7bb0323238b33c5eb7c4395875ba;p=u%2Fmrichter%2FAliRoot.git diff --git a/HLT/BASE/AliHLTHOMERManager.cxx b/HLT/BASE/AliHLTHOMERManager.cxx index 264f22785cc..18ad84efe8d 100644 --- a/HLT/BASE/AliHLTHOMERManager.cxx +++ b/HLT/BASE/AliHLTHOMERManager.cxx @@ -1,5 +1,5 @@ //-*- 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. * @@ -62,17 +62,22 @@ ClassImp(AliHLTHOMERManager) 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 @@ -116,8 +121,14 @@ AliHLTHOMERManager::~AliHLTHOMERManager() { } fEventBuffer = NULL; + if(fBlockList) { + fBlockList->Clear(); + delete fBlockList; + } + fBlockList = NULL; + if ( fAsyncBlockList ) { - fAsyncBlockList->Clear(); + fAsyncBlockList->Delete(); delete fAsyncBlockList; } fAsyncBlockList = NULL; @@ -127,6 +138,8 @@ AliHLTHOMERManager::~AliHLTHOMERManager() { Int_t AliHLTHOMERManager::Initialize() { // see header file for class documentation + HLTInfo("Initializing"); + Int_t iResult = 0; // -- Initialize ProxyHandler @@ -136,11 +149,11 @@ Int_t AliHLTHOMERManager::Initialize() { 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 @@ -154,6 +167,12 @@ Int_t AliHLTHOMERManager::Initialize() { 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 ); @@ -179,8 +198,14 @@ 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 ) delete fSourceList; fSourceList = NULL; @@ -190,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 @@ -232,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 @@ -240,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; } @@ -259,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; } @@ -273,12 +309,17 @@ Int_t AliHLTHOMERManager::ConnectHOMER( TString detector ){ 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(fLibManager->OpenReader(sourceHostnames[idx], sourcePorts[idx]))); AliHLTHOMERReader *reader = static_cast(fReaderList->Last()); if ( !reader ) { - HLTError(Form("Adding reader failed, aborting")); + HLTError("Adding reader failed, aborting"); + delete [] sourcePorts; + delete [] sourceHostnames; return -3; } @@ -346,7 +387,7 @@ void AliHLTHOMERManager::DisconnectHOMER(){ fStateHasChanged = kTRUE; fConnected = kFALSE; - HLTInfo(Form("Connection closed.")); + HLTInfo("Connection closed."); return; } @@ -362,7 +403,7 @@ Int_t AliHLTHOMERManager::ReconnectHOMER( TString detector="" ){ iResult = ConnectHOMER(detector); if ( iResult ) { - HLTError(Form("Error reconnecting.")); + HLTError("Error reconnecting."); } return iResult; @@ -388,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 @@ -458,22 +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()) ) { - // -- 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; } /* --------------------------------------------------------------------------------- @@ -502,6 +533,8 @@ Int_t AliHLTHOMERManager::NavigateEventBufferBack() { 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; @@ -511,8 +544,12 @@ Int_t AliHLTHOMERManager::NavigateEventBufferFwd() { newIdx = 0; fCurrentBufferIdx = fNavigateBufferIdx = newIdx; + fNEventsAvailable -= 1; - return newIdx; + HLTInfo(Form("fNavigateBufferIdx: %d, fCurrentBufferIdx %d, fBufferTopIdx %d", fNavigateBufferIdx, fCurrentBufferIdx, fBufferTopIdx)); + + + return 0; } /////////////////////////////////////////////////////////////////////////////////// @@ -534,6 +571,9 @@ void AliHLTHOMERManager::CreateReadoutList( const char** sourceHostnames, UShort TIter next( fSourceList ); while ( ( source = dynamic_cast(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 @@ -584,21 +624,21 @@ void AliHLTHOMERManager::CreateReadoutList( const char** sourceHostnames, UShort //################################################################################## void AliHLTHOMERManager::AddBlockListToBuffer() { // see header file for class documentation - // -- Check if event is already in buffer ULong_t eventID = static_cast(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 { @@ -619,14 +659,17 @@ void AliHLTHOMERManager::AddBlockListToBuffer() { fBufferLowIdx = 0; } - fNavigateBufferIdx = fCurrentBufferIdx = fBufferTopIdx; // -- Fill EventID fEventID[fBufferTopIdx] = eventID; // -- Clear Buffer slot (reinterpret_cast((*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(); @@ -641,16 +684,21 @@ void AliHLTHOMERManager::AddBlockListToBuffer() { // -- Check sources list if block is requested if ( CheckIfRequested( block ) ) { (reinterpret_cast((*fEventBuffer)[fBufferTopIdx]))->Add( block ); + fBlockList->Add(block); } else { // XXX HACK Jochen (reinterpret_cast((*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; } @@ -662,46 +710,58 @@ void AliHLTHOMERManager::AddToAsyncBlockList() { 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(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((*fEventBuffer)[idx]); } -/* - * --------------------------------------------------------------------------------- - * Block Handling - private - * --------------------------------------------------------------------------------- - */ -//################################################################################## +//__________________________________________________________________________________ Int_t AliHLTHOMERManager::HandleBlocks() { // see header file for class documentation @@ -714,40 +774,24 @@ Int_t AliHLTHOMERManager::HandleBlocks() { // -- 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(tmp11); - *tmp12 = fCurrentReader->GetBlockDataType(ii); - void *tmp21 = tmp2; - ULong_t* tmp22 = static_cast(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 @@ -761,6 +805,11 @@ Bool_t AliHLTHOMERManager::IsSyncBlocks() { bResult = kTRUE; break; } + + if ( !GetBlkType().CompareTo("GLOBTRIG")) { + bResult = kTRUE; + break; + } if ( !GetBlkType().CompareTo("ROOTTOBJ") ) { AliHLTHOMERBlockDesc blockDesc; @@ -786,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(fNBlks) ) @@ -800,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; } @@ -818,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; } @@ -854,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; } @@ -888,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; } @@ -950,8 +999,8 @@ Bool_t AliHLTHOMERManager::CheckTriggerDecision() { Bool_t triggered = kFALSE; if ( !fCurrentReader || !IsConnected() ) { - HLTError(Form("Not connected yet.")); - return NULL; + HLTError("Not connected yet."); + return kFALSE; } AliHLTHOMERBlockDesc blockDesc; @@ -976,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; }