]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
* Added new Handler Classes for HOMER Proxy
authorjthaeder <jthaeder@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 5 Aug 2009 21:58:18 +0000 (21:58 +0000)
committerjthaeder <jthaeder@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 5 Aug 2009 21:58:18 +0000 (21:58 +0000)
** Base class AliHLTHOMERManager for use in EVE and in AMORE
** XmlRpc Handler class AliHLTHOMERProxyHandler for proxy communication

* Updated AliHLTHOMERBlock and AliHLTHOMERSource objects

* Added test macro : HLT/exa/HOMERManager.C

* Commented out relevant part in AliEveHOMER classes
** AliEveHOMERSrcTranslator and AliEveHOMERXMLHandler are scheduled to be removed
** AliEveHOMERManager has to be adapted to base class

17 files changed:
EVE/EveHLT/AliEveHOMERManager.cxx
EVE/EveHLT/AliEveHOMERManager.h
EVE/EveHLT/AliEveHOMERSourceMap.cxx
EVE/EveHLT/AliEveHOMERSrcTranslator.cxx
EVE/EveHLT/AliEveHOMERXMLHandler.cxx
HLT/BASE/AliHLTHOMERBlockDesc.cxx
HLT/BASE/AliHLTHOMERBlockDesc.h
HLT/BASE/AliHLTHOMERManager.cxx [new file with mode: 0644]
HLT/BASE/AliHLTHOMERManager.h [new file with mode: 0644]
HLT/BASE/AliHLTHOMERProxyHandler.cxx [new file with mode: 0644]
HLT/BASE/AliHLTHOMERProxyHandler.h [new file with mode: 0644]
HLT/BASE/AliHLTHOMERSourceDesc.cxx
HLT/BASE/AliHLTHOMERSourceDesc.h
HLT/BASE/HLTbaseLinkDef.h
HLT/CMake_libHLTbase.txt
HLT/exa/HOMERManager.C [new file with mode: 0644]
HLT/libHLTbase.pkg

index 9a3d72f7e939f03d1213bdf3baba70ae813e0ff0..2993f2b9134062937669a5c97de953b7e96420a5 100644 (file)
 
 #include "AliEveHOMERManager.h"
 
-#define use_aliroot
-#define use_root
-#define ROWHOUGHPARAMS
-#define use_reconstruction
-#define use_newio
-#define ROOTVERSION    "unchecked"
-#define ALIROOTVERSION "unchecked"
-#define __ROOT__
-#define USE_ALILOG
-#define LINUX
-
 #define EVE_DEBUG 1
 // -- -- -- -- -- -- -- 
 #include "AliHLTHOMERLibManager.h"
 #include "TObjArray.h"
 // -- -- -- -- -- -- -- 
 #include "AliLog.h"
-#include "AliTPCCalibPedestal.h"
-#include "AliTPCCalibPulser.h"
-#include "AliTPCCalibCE.h"
-#include "AliTPCPreprocessorOnline.h"
-#include "AliTPCCalROC.h"
 
 //______________________________________________________________________________
 //
@@ -77,8 +61,7 @@ AliEveHOMERManager::AliEveHOMERManager( TString xmlFile ) :
   fCurrentBlk(0),
   fConnected(kFALSE),
   fStateHasChanged(kTRUE),
-  fSrcList(NULL),
-  fTPCPre(NULL) {
+  fSrcList(NULL) {
   // This Class should handle the communication
   // from the HLT to AliEVE. The HLT sends data via 
   // the HOMER interface on several TCP ports of nodes 
@@ -118,11 +101,6 @@ AliEveHOMERManager::~AliEveHOMERManager() {
  if ( fSrcList != NULL )
     delete fSrcList;
   fSrcList = NULL;
-  
-  if ( fTPCPre != NULL )
-    delete fTPCPre;
-  fTPCPre = NULL;
-
 }
 
 /*
@@ -445,8 +423,9 @@ Int_t AliEveHOMERManager::NextEvent(){
 Int_t AliEveHOMERManager::CreateBlockList() {
   // Create a TList of blocks, which have been readout
 
-  Int_t iResult = 0;
 
+  Int_t iResult = 0;
+#if 0
   // -- Initialize block list
   if ( fBlockList != NULL )
     delete fBlockList;
@@ -476,7 +455,7 @@ Int_t AliEveHOMERManager::CreateBlockList() {
     iter = GetNextBlk();
 
   } // while ( iter != NULL ){
-
+#endif
   return iResult;
 }
 
@@ -622,12 +601,12 @@ ULong_t AliEveHOMERManager::GetBlkSpecification( Int_t ndx ) {
 }
 
 //##################################################################################
-Bool_t AliEveHOMERManager::CheckIfRequested( AliHLTHOMERBlockDesc * block ) {
+Bool_t AliEveHOMERManager::CheckIfRequested( AliHLTHOMERBlockDesc */* block*/ ) {
   // Checks if current Block should was requested
   // * return           returns kTRUE, if block should was requested
 
   Bool_t requested = kFALSE;
-
+#if 0
   AliHLTHOMERSourceDesc * source= NULL;
 
   // -- Read all sources and check if they should be read out
@@ -679,148 +658,7 @@ Bool_t AliEveHOMERManager::CheckIfRequested( AliHLTHOMERBlockDesc * block ) {
 
   }
 #endif
-
+#endif
   return requested;
 }
 
-/*
- * ---------------------------------------------------------------------------------
- *                            Test Realm ....
- * ---------------------------------------------------------------------------------
- */
-
-//##################################################################################
-void AliEveHOMERManager::DumpTPCCalib(TString objectName, Bool_t dumpToFile) {
-  // Still under testing ...
-
-  if ( fTPCPre != NULL )
-    delete fTPCPre;
-
-  fTPCPre = new AliTPCPreprocessorOnline();
-
-  TList* blockList = GetBlockList();
-
-  AliHLTHOMERBlockDesc *desc = 0;
-
-  TIter next(blockList);
-
-  while ( ( desc = (AliHLTHOMERBlockDesc*)next() ) ) {
-    if ( ! desc->IsTObject() )
-      continue;
-
-    Int_t sectorTPC = 0;
-
-    if ( desc->GetSubSubDetector().Atoi() <= 1 ) {
-      sectorTPC = desc->GetSubDetector().Atoi();
-    }
-    else {
-      sectorTPC = 36 + desc->GetSubDetector().Atoi();
-    }
-
-    if ( ! objectName.CompareTo( desc->GetClassName() ) ){
-
-      //
-      // AliTPCCalibPedestal
-      //
-
-      if ( ! objectName.CompareTo( "AliTPCCalibPedestal" ) ) {
-       AliTPCCalROC* calROC = NULL;
-
-       AliTPCCalibPedestal * cal = (AliTPCCalibPedestal*) desc->GetTObject();
-       if ( cal == NULL ) {
-         cout << "error 1" << endl;
-         continue;
-       }
-
-       cal->Analyse();
-
-       calROC = cal->GetCalRocRMS(sectorTPC);
-       if ( calROC == NULL ) {
-         cout << "error 2" << endl;
-         continue;
-       }
-
-       calROC->SetName(Form("RMS_ROC%d", sectorTPC));
-       fTPCPre->AddComponent((TObject*) calROC );
-
-       calROC = cal->GetCalRocPedestal(sectorTPC);
-       if ( calROC == NULL ) {
-         cout << "error 3" << endl;
-         continue;
-       }
-
-
-       calROC->SetName(Form("Pedestal_ROC%d", sectorTPC));
-       cout << "added" << endl;
-       fTPCPre->AddComponent((TObject*) calROC );
-      }
-
-      //
-      // AliTPCCalibPulser
-      //
-      /*
-      else if ( ! objectName.CompareTo( "AliTPCCalibPulser" ) ) {
-       AliTPCCalROC* calROC = NULL;
-
-       AliTPCCalibPulser * cal = (AliTPCCalibPulser*) desc->GetTObject();
-
-       cal->Analyse();
-
-       calROC = cal->GetCalRocT0(sectorTPC);
-       calROC->SetName(Form("T0_ROC%d", sectorTPC));
-       fTPCPre->AddComponent((TObject*) calROC );
-
-       calROC = cal->GetCalRocQ(sectorTPC);
-       calROC->SetName(Form("Q_ROC%d", sectorTPC));
-       fTPCPre->AddComponent((TObject*) calROC );
-
-       calROC = cal->GetCalRocRMS(sectorTPC);
-       calROC->SetName(Form("RMS_ROC%d", sectorTPC));
-       fTPCPre->AddComponent((TObject*) calROC );
-
-       calROC = cal->GetCalRocOutliers(sectorTPC);
-       calROC->SetName(Form("Outliers_ROC%d", sectorTPC));
-       fTPCPre->AddComponent((TObject*) calROC );
-      }
-
-*/
-      //
-      // AliTPCCalibCE
-      //
-      /*
-      else if ( ! objectName.CompareTo( "AliTPCCalibCE" ) ) {
-       AliTPCCalROC* calROC = NULL;
-
-       AliTPCCalibPulser * cal = (AliTPCCalibPulser*) desc->GetTObject();
-
-       cal->Analyse();
-
-       calROC = cal->GetCalRocT0(sectorTPC);
-       calROC->SetName(Form("T0_ROC%d", sectorTPC));
-       fTPCPre->AddComponent((TObject*) calROC );
-
-       calROC = cal->GetCalRocQ(sectorTPC);
-       calROC->SetName(Form("Q_ROC%d", sectorTPC));
-       fTPCPre->AddComponent((TObject*) calROC );
-
-       calROC = cal->GetCalRocRMS(sectorTPC);
-       calROC->SetName(Form("RMS_ROC%d", sectorTPC));
-       fTPCPre->AddComponent((TObject*) calROC );
-
-       calROC = cal->GetCalRocOutliers(sectorTPC);
-       calROC->SetName(Form("Outliers_ROC%d", sectorTPC));
-       fTPCPre->AddComponent((TObject*) calROC );
-      }
-      */
-    } // if ( ! objectName.CompareTo( desc->GetClassName() ) ) {
-
-  } // while ( ( desc = (AliHLTHOMERBlockDesc*)next() ) ) {
-
-  if ( dumpToFile ) {
-
-    fTPCPre->DumpToFile("pedestals.root");
-    cout << "DUMP" << endl;
-  }
-
-
-}
index d89f2d2fb9c21341df71a1868dbdac7d95a1d977..5052f50a2af496d611fa7cf08b1b3e4f5df0b11b 100644 (file)
@@ -99,15 +99,6 @@ public:
   /** Get pointer to block List */
   TList* GetBlockList() { return fBlockList; } // Get pointer to block List
   
-  /*
-   * ---------------------------------------------------------------------------------
-   *                            Test Realm ....
-   * ---------------------------------------------------------------------------------
-   */
-
-  /** Still under testing ... */
-  void DumpTPCCalib(TString objectName, Bool_t dumpToFile);
-
   ///////////////////////////////////////////////////////////////////////////////////
 
 protected:
@@ -222,9 +213,6 @@ private:
   // == sources ==
   AliEveHOMERSourceList* fSrcList;                // List of HOMER Sources
 
-  //-----------------------------------------------------------------------------------------
-  AliTPCPreprocessorOnline* fTPCPre;              // Preprocessor for TPC calibration.
-
   ClassDef(AliEveHOMERManager, 0); // Manage connections to HLT data-sources.
 };
 
index 98f7704044f714e82dc571b93601be6b5bd37bd5..c4882215a98453d61d7d1ad725dacaef00690463 100644 (file)
@@ -191,7 +191,7 @@ void AliEveHOMERSourceMapByType::FillMap(const TList* handles, Bool_t def_state)
     insert(srcid, srcst, def_state);
 
     srcid.fDet = h->GetDetector();
-    if (h->GetSubDetector().IsNull())
+    if (h->GetSubDetector() == 0)
     {
       srcst.fHandle = h;
       insert(srcid, srcst, def_state);
@@ -200,7 +200,7 @@ void AliEveHOMERSourceMapByType::FillMap(const TList* handles, Bool_t def_state)
     insert(srcid, srcst, def_state);
 
     srcid.fSDet = h->GetSubDetector();
-    if (h->GetSubSubDetector().IsNull())
+    if (h->GetSubSubDetector() == 0)
     {
       srcst.fHandle = h;
       insert(srcid, srcst, def_state);
index aac971bff17327749b2a6ac8431b4fee6c1ea9e1..52ecc9d0e24b10813ac6e25a6a2a6caf310d9dc6 100644 (file)
@@ -165,7 +165,7 @@ Int_t AliEveHOMERSrcTranslator::FillSourceDesc( AliHLTHOMERSourceDesc* source, T
 
   TMap * objectMap = (TMap*) fObjectMap->GetValue( detector );
 
-
+#if 0
 
   if ( ! objectMap->FindObject( name ) ) {
   cout << "DET..." << detector.Data() << endl;    
@@ -178,6 +178,7 @@ Int_t AliEveHOMERSrcTranslator::FillSourceDesc( AliHLTHOMERSourceDesc* source, T
     source->SetSourceName( name, srcObject->GetClassName() );
     source->SetSourceType( srcObject->GetSpecification(), srcObject->GetDataType() );
   }
+#endif
 
   return iResult;
 }
index 10b5fb589e05bfb0eaddb58081aea84ffec4268a..4a2386a989219b4935025b239b4294c15cc8f42b 100644 (file)
@@ -229,6 +229,7 @@ Int_t AliEveHOMERXMLHandler::AddSourceTDS( TXMLNode * xmlNode ) {
 
     TString xmlParent = attrNode->GetText();
 
+#if 0
     AliHLTHOMERSourceDesc * source = new AliHLTHOMERSourceDesc( hostname, port );
 
     if ( FillSourceInformation( xmlParent, source ) ) {
@@ -242,7 +243,7 @@ Int_t AliEveHOMERXMLHandler::AddSourceTDS( TXMLNode * xmlNode ) {
       AliInfo( Form("New Source added : %s", xmlParent.Data()) );
 #endif
     }
-
+#endif 
   } // while ( ( attrNode = prevNode->GetNextNode() ) ) {
 
   return iResult;
@@ -288,12 +289,12 @@ Int_t AliEveHOMERXMLHandler::FillSourceInformation( TString xmlParent, AliHLTHOM
   subSubDetector.Remove( TString::kLeading, '0' );
   
   // -- Set detector / subDetector / subSubDetector
-  source->SetDetectors( detector, subDetector, subSubDetector );  
+  //  source->SetDetectors( detector, subDetector, subSubDetector );  
 
   // -- Fill dataType / specification / className
   iResult = fSrcTranslator->FillSourceDesc( source, name );
 
-#if EVE_DEBUG
+#if 0
   AliInfo( Form("Set Source %s , Type %s, ClassName %s .", name.Data(), 
                source->GetDataType().Data(), source->GetClassName().Data()) );
   AliInfo( Form("    Detector %s , SubDetector : %s, SubSubDetector %s .",
index 3a3559c78d80f930cd5506dec8dcaf443bd3317f..293f612504457752f6b9d51a4f04313d36b72bb2 100644 (file)
@@ -30,6 +30,7 @@
 #endif
 
 #include "AliHLTHOMERBlockDesc.h"
+
 #include "AliHLTMessage.h"
 
 #include "TMath.h"
 
 ClassImp(AliHLTHOMERBlockDesc)
 
+/*
+ * ---------------------------------------------------------------------------------
+ *                            Constructor / Destructor 
+ * --------------------------------------------------------------------------------- 
+ */
+
 //##################################################################################
 AliHLTHOMERBlockDesc::AliHLTHOMERBlockDesc() :
   fData(NULL),
   fSize(0),
+  fBlockName(),
   fIsTObject(kFALSE),
   fIsRawData(kFALSE),
   fMessage(NULL),
   fTObject(NULL),
   fClassName(),
+  fDataType(),
   fDetector(),
-  fSubDetector(),
-  fSubSubDetector(),
   fSpecification(0),
-  fDataType(),
+  fSubDetector(0),
+  fSubSubDetector(0),
   fHasSubDetectorRange(kFALSE),
   fHasSubSubDetectorRange(kFALSE) {
   // see header file for class documentation
@@ -61,30 +69,6 @@ AliHLTHOMERBlockDesc::AliHLTHOMERBlockDesc() :
   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
 }
 
-//##################################################################################
-AliHLTHOMERBlockDesc::AliHLTHOMERBlockDesc( void * data, ULong_t size, TString origin, 
-                                           TString dataType, ULong_t specification ) :
-  fData(data),
-  fSize(size),
-  fIsTObject(kFALSE),
-  fIsRawData(kFALSE),
-  fMessage(NULL),
-  fTObject(NULL),
-  fClassName(),
-  fDetector(origin),
-  fSubDetector(),
-  fSubSubDetector(), 
-  fSpecification(specification),
-  fDataType(dataType),
-  fHasSubDetectorRange(kFALSE),
-  fHasSubSubDetectorRange(kFALSE) {
-  // see header file for class documentation
-  
-  // -- Set block parameters
-  SetBlockParameters();
-
-} 
-
 //##################################################################################
 AliHLTHOMERBlockDesc::~AliHLTHOMERBlockDesc() {
   // see header file for class documentation
@@ -95,6 +79,12 @@ AliHLTHOMERBlockDesc::~AliHLTHOMERBlockDesc() {
 
 }
 
+/*
+ * ---------------------------------------------------------------------------------
+ *                            Data Handling - Setter - public
+ * --------------------------------------------------------------------------------- 
+ */
+
 //##################################################################################
 void AliHLTHOMERBlockDesc::SetBlock( void * data, ULong_t size, TString origin, 
                                     TString dataType, ULong_t specification ) {
@@ -106,107 +96,111 @@ void AliHLTHOMERBlockDesc::SetBlock( void * data, ULong_t size, TString origin,
   fDataType = dataType;
   fSpecification = specification; 
 
+  fBlockName.Form("%s_%s%_%ul", fDetector.Data(), fDataType.Data(), fSpecification ); 
+
   // -- Set block parameters
   SetBlockParameters();
 
   return;
 }
 
+/*
+ * ---------------------------------------------------------------------------------
+ *                            Data Handling - private
+ * --------------------------------------------------------------------------------- 
+ */
+
 //##################################################################################
 void AliHLTHOMERBlockDesc::SetBlockParameters() {
   // see header file for class documentation
 
-  Int_t iError = 0;
-
-  // ---- SET CLASS NAME, DATA CONTENTS ----
-
-  // -- Check if block contains raw data
-  if ( ! CheckIfRawData() ) {
-
-    // -- Check if block contains TObject  
-    if ( ! CheckIfTObject() ) {
-
-      // -- Contains arbitrary data type
-      
-      // **** TPC ****
-      if ( ! fDetector.CompareTo("TPC") ) {
-       
-       if ( ! fDataType.CompareTo("CLUSTERS") )
-         fClassName = "AliHLTTPCSpacePoints";
-       else 
-         iError = 1;
-      }
-
-      // **** TRD ****
-      
-      else if ( ! fDetector.CompareTo("TRD") ) {
-       iError = 1;
-      }
+  Int_t iResult = 0;
 
-      // **** PHOS ****
-      
-      else if ( ! fDetector.CompareTo("PHOS") ) {
-       iError = 1;
-      }
-
-      // **** MUON ****
-      
-      else if ( ! fDetector.CompareTo("MUON") ) {
-       iError = 1;
-      }
-
-      // **** OTHER ****
-
-      else {
-       iError = 1;
-      }
-    }
-  } // if ( ! CheckIfRawData() ) {
-  
-  // -- Check if Data Type has been defined
-  if ( iError ) {
-    //AliError( Form("The data type %s for the detector %s has not been defined yet.", 
-    //            fDataType.Data(), fDetector.Data()) );
-  }
-  
   // ---- SET SPECIFICATIONS ----
-  // -- Convert Specification to "SubDetector/SubSubDetector"
+  // ----------------------------
 
   // **** TPC **** ( has special treatment )
-
   if ( ! fDetector.CompareTo("TPC") ) {
-
+    
     Int_t minPatch  = (fSpecification & 0x000000FF);
     Int_t maxPatch  = (fSpecification & 0x0000FF00) >> 8;
     Int_t minSector = (fSpecification & 0x00FF0000) >> 16 ;
     Int_t maxSector = (fSpecification & 0xFF000000) >> 24;
     
-    fSubDetector += minSector;
-    fSubSubDetector += minPatch;
-  
+    fSubDetector = minSector;
+    fSubSubDetector = minPatch;
+    
     // -- check for ranges
     if ( minSector != maxSector )
       fHasSubDetectorRange = kTRUE;
 
     if ( minPatch != maxPatch )
       fHasSubSubDetectorRange = kTRUE;
+    
   }
-  
   // **** OTHER DETECTORS ****
-  
   else {
-    
+      
     if ( fSpecification ) {
-      // find the max bin which is set to 1
-      fSubDetector += TMath::FloorNint( TMath::Log2(fSpecification) );
-
+       // find the max bin which is set to 1
+      fSubDetector = TMath::FloorNint( TMath::Log2(fSpecification) );
+      
       // -- check for ranges
-      if ( TMath::Log2(fSpecification) != ( (Double_t) TMath::FloorNint( TMath::Log2(fSpecification) ) ) )
+      if ( TMath::Log2(fSpecification) != 
+          static_cast<Double_t>(TMath::FloorNint(TMath::Log2(fSpecification))) )
        fHasSubDetectorRange = kTRUE;
-
     }
   }
 
+  // ---- SET CLASS NAME, DATA CONTENTS ----
+  // ---------------------------------------
+
+  // -- Check if block contains raw data
+  if ( CheckIfRawData() )
+    return;
+
+  // -- Check if block contains TObject  
+  if ( CheckIfTObject() )
+    return;
+
+  // -- Contains arbitrary data type
+      
+  // **** TPC ****
+  if ( ! fDetector.CompareTo("TPC") ) {
+    
+    if ( ! fDataType.CompareTo("CLUSTERS") )
+      fClassName = "AliHLTTPCSpacePoints";
+    else 
+      iResult = -1;
+  }
+
+  // **** TRD ****
+  else if ( ! fDetector.CompareTo("TRD") ) {
+    iResult = -1;
+  }
+  
+  // **** PHOS ****
+  else if ( ! fDetector.CompareTo("PHOS") ) {
+    iResult = -1;
+  }
+  
+  // **** MUON ****
+  else if ( ! fDetector.CompareTo("MUON") ) {
+    iResult = -1;
+  }
+  
+  // **** OTHER ****
+  else {
+    iResult = -1;
+  }
+  
+  // -- Check if classname has been defined
+  /*
+    if ( iResult < 0 ) {
+    HLTWarning( "The classname for data type %s for the detector %s has not been defined yet.", 
+    fDataType.Data(), fDetector.Data());
+    }
+  */
   return;
 }
   
index 129d946a985b6e7ead2a92e9559c2fa1948edb83..5222d0ad2222031b6dfdb220d07335eee8f155b2 100644 (file)
@@ -23,6 +23,8 @@ class AliHLTMessage;
 #include "TString.h"
 #include "TObject.h"
 
+//#include "AliHLTLogging.h"
+
 /**
  * @class AliHLTHOMERBlockDesc
  * This class contains the data which comes from 1 block, delivered via the 
@@ -33,7 +35,7 @@ class AliHLTMessage;
  * 
  * @ingroup alihlt_homer
  */
-class AliHLTHOMERBlockDesc : public TObject {
+class AliHLTHOMERBlockDesc : public TObject/*, public AliHLTLogging*/ {
 
 public:
 
@@ -46,15 +48,6 @@ public:
   /** standard constructor */
   AliHLTHOMERBlockDesc();       
 
-  /** Constructor, set block data 
-   * @param data           Pointer to data
-   * @param size           Size of data
-   * @param origin         Detector
-   * @param dataType       HLT data type  
-   * @param specification  HLT specification
-   */
-  AliHLTHOMERBlockDesc( void * data, ULong_t size, TString origin, TString dataType, ULong_t specification );  
-
   /** destructor */
   virtual ~AliHLTHOMERBlockDesc();
 
@@ -87,6 +80,11 @@ public:
   /** Returns Pointer to TObject */
   TObject* GetTObject()           { return fTObject;   }
 
+  /** Get class name of this block 
+   * @return           class name
+   */
+  TString GetClassName()          { return fClassName; }
+
   /*
    * ---------------------------------------------------------------------------------
    *                            Data Handling - Getter - public
@@ -108,6 +106,11 @@ public:
    */
   ULong_t GetSize()               { return fSize; }
 
+  /** Get name of this block
+   * @return           name
+   */
+  TString GetBlockName()          { return fBlockName; }
+
   /** Get detector of this block 
    * @return           Detector name
    */
@@ -123,30 +126,27 @@ public:
    */
   ULong_t GetSpecification()      { return fSpecification; }
 
-  /** Get class name of this block 
-   * @return           class name
-   */
-  TString GetClassName()          { return fClassName; }
-
   /** Get sub detector of this block 
    * @return           subdetector
    */
-  TString GetSubDetector()        { return fSubDetector; }
+  Int_t   GetSubDetector()        { return fSubDetector; }
 
   /** Get sub sub detector of this block
    * @return           subsubdetector
    */
-  TString GetSubSubDetector()     { return fSubSubDetector; }
+  Int_t   GetSubSubDetector()     { return fSubSubDetector; }
 
   /** Returns kTRUE if HLT specification indicates a subdetector range
    * @return           kTRUE if subdetector range
    */
-  Bool_t HasSubDetectorRange()    { return fHasSubDetectorRange; }
+  Bool_t  HasSubDetectorRange()   { return fHasSubDetectorRange; }
 
   /** Returns kTRUE if HLT specification indicates a subsubdetector range
    * @return           kTRUE if subsubdetector range
    */
-  Bool_t HasSubSubDetectorRange() { return fHasSubSubDetectorRange; }
+  Bool_t  HasSubSubDetectorRange(){ return fHasSubSubDetectorRange; }
+
+  ///////////////////////////////////////////////////////////////////////////////////
 
 private:
 
@@ -156,6 +156,12 @@ private:
   /** assignment operator prohibited */
   AliHLTHOMERBlockDesc& operator=(const AliHLTHOMERBlockDesc&);
 
+  /*
+   * ---------------------------------------------------------------------------------
+   *                            Data Handling - private
+   * --------------------------------------------------------------------------------- 
+   */
+
   /** Set all additional members*/
   void SetBlockParameters();
 
@@ -177,47 +183,69 @@ private:
    * --------------------------------------------------------------------------------- 
    */
 
+  // -- Block properties --
+  // ----------------------
+
   /** Pointer to data of the block */
-  void* fData;                      //! transient
+  void*   fData;                    //! transient
              
   /** Size of data */
   ULong_t fSize;                    // see above
 
+  /** Block Name */
+  TString fBlockName;               // see above
+
+  // -- Data flags --
+  // ----------------
+
   /** States if block contains a TObject */
   Bool_t fIsTObject;                // see above
 
   /** States if block contains a raw data */
   Bool_t fIsRawData;                // see above
 
+  // -- TObject properties --
+  // ------------------------
+
   /** AliHTMessage object containg a TObject */
   AliHLTMessage* fMessage;          //! transient
 
   /** TObject extracted out of @see AliHLTMessage */
-  TObject* fTObject;                //! transient
+  TObject*       fTObject;          //! transient
 
   /** Class Name of the block */
-  TString fClassName;               // see above
+  TString        fClassName;        // see above
+  
+  // -- Data Specifications --
+  // -------------------------
+
+  /** HLT DataType */
+  TString fDataType;                // see above 
 
   /** Detector Name, e.g. PHOS */
   TString fDetector;                // see above
 
-  /** SubDetector Name e.g. MODULE */
-  TString fSubDetector;             // see above
-
-  /** SubSubDetector Name e.g. PARTITION */
-  TString fSubSubDetector;          // see above
-
   /** HLT Specification */
   ULong_t fSpecification;           // see above
 
-  /** HLT DataType */
-  TString fDataType;                // see above 
+  // XXXXXXXXXXXXXXXXXXXXXXXX REMOVE IF NOT NEEDED XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+
+  // -- Sub Detector Specifications --
+  // ---------------------------------
+  
+  /** SubDetector Name e.g. MODULE */
+  Int_t   fSubDetector;             // see above
+
+  /** SubSubDetector Name e.g. PARTITION */
+  Int_t   fSubSubDetector;          // see above
 
   /** States id block has a subdetector range */
-  Bool_t fHasSubDetectorRange;      // see above
+  Bool_t  fHasSubDetectorRange;     // see above
 
   /** States id block has a subsubdetector range */
-  Bool_t fHasSubSubDetectorRange;   // see above
+  Bool_t  fHasSubSubDetectorRange;  // see above
+
+  // XXXXXXXXXXXXXXXXXXXXXXXX REMOVE IF NOT NEEDED XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
   ClassDef( AliHLTHOMERBlockDesc, 0 )
 };
diff --git a/HLT/BASE/AliHLTHOMERManager.cxx b/HLT/BASE/AliHLTHOMERManager.cxx
new file mode 100644 (file)
index 0000000..ba804b1
--- /dev/null
@@ -0,0 +1,615 @@
+//-*- Mode: C++ -*-
+// $Id: AliHLTHOMERManager.cxx  $
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//*                                                                        *
+//* Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de>        *
+//*                  for The ALICE HLT Project.                            *
+//*                                                                        *
+//* Permission to use, copy, modify and distribute this software and its   *
+//* documentation strictly for non-commercial purposes is hereby granted   *
+//* without fee, provided that the above copyright notice appears in all   *
+//* copies and that both the copyright notice and this permission notice   *
+//* appear in the supporting documentation. The authors make no claims     *
+//* about the suitability of this software for any purpose. It is          *
+//* provided "as is" without express or implied warranty.                  *
+//**************************************************************************
+
+/** @file   AliHLTHOMERManager.cxx
+    @author Jochen Thaeder
+    @date
+    @brief  Manger for HOMER in aliroot
+*/
+
+// see header file for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
+#if __GNUC__>= 3
+   using namespace std;
+#endif
+
+#define EVE_DEBUG 1
+
+#include "AliHLTHOMERManager.h"
+// -- -- -- -- -- -- -- 
+#include "AliHLTHOMERLibManager.h"
+#include "AliHLTHOMERSourceDesc.h"
+#include "AliHLTHOMERBlockDesc.h"
+
+ClassImp(AliHLTHOMERManager)
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                            Constructor / Destructor
+ * ---------------------------------------------------------------------------------
+ */
+
+//##################################################################################
+  AliHLTHOMERManager::AliHLTHOMERManager() :
+  fLibManager(new AliHLTHOMERLibManager),
+  fProxyHandler(NULL),
+  fReader(NULL),
+  fSourceList(NULL),
+  fBlockList(NULL),
+  fNBlks(0),
+  fEventID(0),
+  fCurrentBlk(0),
+  fConnected(kFALSE),
+  fStateHasChanged(kTRUE) {
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
+}
+
+//##################################################################################
+AliHLTHOMERManager::~AliHLTHOMERManager() {
+  // see header file for class documentation
+
+  if ( fLibManager ) {
+    if ( fReader )
+      fLibManager->DeleteReader(fReader);
+    delete fLibManager;
+    fLibManager = NULL;
+    fReader = NULL;
+  }
+
+  if ( fProxyHandler != NULL )
+    delete fProxyHandler;
+  fProxyHandler = NULL;
+
+  if ( fSourceList != NULL )
+    delete fSourceList;
+  fSourceList = NULL;
+
+  if ( fBlockList != NULL )
+    delete fBlockList;
+  fBlockList = NULL;
+}
+
+//##################################################################################
+Int_t AliHLTHOMERManager::Initialize() {
+  // see header file for class documentation
+
+  Int_t iResult = 0;
+
+  if ( !fProxyHandler )
+    fProxyHandler = new AliHLTHOMERProxyHandler();
+  
+  if ( fProxyHandler ) {
+    iResult = fProxyHandler->Initialize();
+    if (iResult)
+      HLTError("Initialize of ProxyHandler failed.");
+  }
+  else {
+    iResult = -1;
+    HLTError("Creating of ProxyHandler failed.");
+  }
+  return iResult;
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                                 Source Handling
+ * ---------------------------------------------------------------------------------
+ */
+
+//##################################################################################
+Int_t AliHLTHOMERManager::CreateSourcesList() {
+  // see header file for class documentation
+
+  Int_t iResult = 0;
+  
+  if ( fSourceList != NULL )
+    delete fSourceList;
+  fSourceList = NULL;
+
+  fSourceList = new TList();
+  fSourceList->SetOwner( kTRUE );
+
+  iResult = fProxyHandler->FillSourceList( fSourceList );
+  if ( iResult ) {
+    HLTWarning("There have been errors, while creating the sources list.");
+  }
+  else {
+    HLTInfo("New sources list created.");
+
+    // -- New SourceList has been created 
+    // --> All Sources are new --> State has changed
+    fStateHasChanged = kTRUE;
+  }
+
+  return iResult;
+}
+
+//##################################################################################
+void AliHLTHOMERManager::SetSourceState( AliHLTHOMERSourceDesc * source, Bool_t state ) {
+  // see header file for class documentation
+
+  if ( source->IsSelected() != state ) {
+    source->SetState( state );
+    fStateHasChanged = kTRUE;
+  }
+
+  return;
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                         Connection Handling -oublic
+ * ---------------------------------------------------------------------------------
+ */
+
+//##################################################################################
+Int_t AliHLTHOMERManager::ConnectHOMER(){
+  // see header file for class documentation
+
+  Int_t iResult = 0;
+
+  // -- Check if already connected and state has not changed
+  if ( fStateHasChanged == kFALSE && IsConnected() ) {
+    HLTInfo("No need for reconnection.");
+    return iResult;
+  }
+
+  // -- If already connected, disconnect before connect
+  if ( IsConnected() )
+    DisconnectHOMER();
+
+  // -- Create the Readoutlist
+  UShort_t* sourcePorts = new UShort_t [fSourceList->GetEntries()];
+  const char ** sourceHostnames = new const char* [fSourceList->GetEntries()];
+  UInt_t sourceCount = 0;
+
+  CreateReadoutList( sourceHostnames, sourcePorts, sourceCount );
+  if ( sourceCount == 0 ) {
+    HLTError("No sources selected, aborting.");
+    return -1;
+  }
+
+  // *** Connect to data sources
+  if ( !fReader && fLibManager )
+    fReader = fLibManager->OpenReader( sourceCount, sourceHostnames, sourcePorts );
+  else {
+    HLTError("No LibManager present.");
+    return -2;
+  }
+    
+  iResult = fReader->GetConnectionStatus();
+  if ( iResult ) {
+    // -- Connection failed
+
+    UInt_t ndx = fReader->GetErrorConnectionNdx();
+
+    if ( ndx < sourceCount ) {
+      HLTError("Error establishing connection to TCP source %s:%hu: %s (%d)",
+              sourceHostnames[ndx], sourcePorts[ndx], strerror(iResult), iResult);
+    }
+    else {
+      HLTError("Error establishing connection to unknown source with index %d: %s (%d)",
+              ndx, strerror(iResult), iResult);
+    }
+
+    if ( fReader )
+      fLibManager->DeleteReader( fReader );
+    fReader = NULL;
+  }
+  else {
+    // -- Connection ok - set reader
+    fConnected = kTRUE;
+
+    HLTInfo("Connection established.");
+  }
+
+  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;
+
+  fStateHasChanged = kTRUE;
+  fConnected = kFALSE;
+
+  HLTInfo("Connection closed.");
+
+  return;
+}
+
+//##################################################################################
+Int_t AliHLTHOMERManager::ReconnectHOMER(){
+  // see header file for class documentation
+  
+  Int_t iResult = 0;
+
+  if ( IsConnected() )
+    DisconnectHOMER();
+
+  iResult = ConnectHOMER();
+  if ( iResult ) {
+    HLTError("Error reconnecting.");
+  }
+
+  return iResult;
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                            Event Handling - public
+ * ---------------------------------------------------------------------------------
+ */
+
+
+//##################################################################################
+Int_t AliHLTHOMERManager::NextEvent(){
+  // see header file for class documentation
+
+  Int_t iResult = 0;
+  Int_t iRetryCount = 0;
+
+  if ( !fReader || ! IsConnected() ) {
+    HLTWarning( "Not connected yet." );
+    return -1;
+  }
+
+  //  fReader->SetEventRequestAdvanceTime( 20000000 /*timeout in us*/ );
+
+  // -- Read next event data and error handling for HOMER (error codes and empty blocks)
+  while( 1 ) {
+    
+    iResult = fReader->ReadNextEvent( 40000000 /*timeout in us*/);
+
+    if ( iResult == 111 || iResult == 32 || iResult == 6 ) {
+      HLTError("No Connection to source %d: %s (%d)", 
+              fReader->GetErrorConnectionNdx(), strerror(iResult), iResult);
+      return -iResult;
+    }
+    else if ( iResult == 110 ) {
+      HLTError("Timout occured, reading event from source %d: %s (%d)", 
+              fReader->GetErrorConnectionNdx(), strerror(iResult), iResult);
+      return -iResult;
+    }
+    else if ( iResult == 56) {
+      ++iRetryCount;
+
+      if ( iRetryCount >= 20 ) {
+       HLTError("Retry Failed: Error reading event from source %d: %s (%d)", 
+                fReader->GetErrorConnectionNdx(), strerror(iResult), iResult);
+       return -iResult;
+      }
+      else {
+       HLTError("Retry: Error reading event from source %d: %s (%d)", 
+                fReader->GetErrorConnectionNdx(), strerror(iResult), iResult);
+       continue;
+      }
+    }
+    else if ( iResult ) {
+      HLTError("General Error reading event from source %d: %s (%d)", 
+              fReader->GetErrorConnectionNdx(), strerror(iResult), iResult);
+      fConnected = kFALSE;
+      return -iResult;
+    }
+    else {
+      break;
+    }
+  } // while( 1 ) {
+
+  // -- Get blockCnt and eventID
+  fNBlks = static_cast<ULong_t>(fReader->GetBlockCnt());
+  fEventID = static_cast<ULong64_t>(fReader->GetEventID());
+  fCurrentBlk = 0;
+
+  HLTInfo("Event 0x%016LX (%Lu) with %lu blocks", fEventID, fEventID, 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 = fReader->GetBlockDataType( ii );
+    void *tmp21 = tmp2;
+    ULong_t* tmp22 = static_cast<ULong_t*>(tmp21);
+    *tmp22 = fReader->GetBlockDataOrigin( ii );
+    HLTInfo("Block %lu length: %lu - type: %s - origin: %s",
+           ii, fReader->GetBlockDataLength( ii ), tmp1, tmp2);
+  } // end for ( ULong_t ii = 0; ii < fNBlks; ii++ ) {
+#endif
+
+  // -- Create BlockList
+  HLTInfo("Create Block List");
+  CreateBlockList();
+
+  return iResult;
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                            Connection Handling - private
+ * ---------------------------------------------------------------------------------
+ */
+
+//##################################################################################
+void AliHLTHOMERManager::CreateReadoutList( const char** sourceHostnames, 
+                                           UShort_t *sourcePorts, UInt_t &sourceCount ){
+  // see header file for class documentation
+
+  AliHLTHOMERSourceDesc * source= NULL;
+
+  // -- Read all sources and check if they should be read out
+  TIter next( fSourceList );
+  while ( ( source = dynamic_cast<AliHLTHOMERSourceDesc*>(next()) ) ) {
+
+    if ( ! source->IsSelected() )
+      continue;
+    
+    Bool_t exists = kFALSE;
+    
+    // -- Loop over existing entries and check if entry is already in readout list
+    for ( UInt_t ii = 0; ii < sourceCount; ii++ ){
+      if ( !strcmp( sourceHostnames[ii], source->GetHostname().Data() ) 
+          && sourcePorts[ii] == source->GetPort() ) {
+       exists = kTRUE;
+       break;
+      }
+    }
+
+    // -- Add new entires to readout list
+    if ( ! exists ) {
+      sourcePorts[sourceCount] = source->GetPort();
+      sourceHostnames[sourceCount] = source->GetHostname().Data();
+      sourceCount++;
+    }
+
+  } // while ( ( source = (AliHLTHOMERSourceDesc*)next() ) ) {
+
+  fStateHasChanged = kFALSE;
+
+  return;
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                            Event Handling
+ * ---------------------------------------------------------------------------------
+ */
+
+
+//##################################################################################
+void AliHLTHOMERManager::CreateBlockList() {
+  // see header file for class documentation
+
+  // -- Initialize block list
+  if ( fBlockList != NULL )
+    delete fBlockList;
+  fBlockList = NULL;
+
+  fBlockList = new TList();
+  fBlockList->SetOwner(kTRUE);
+
+  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 ) )
+      fBlockList->Add( block );
+    else {
+      delete block;
+      block = NULL;
+    }
+  } while( GetNextBlk() );
+    
+  return;
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                            BlockHandling
+ * ---------------------------------------------------------------------------------
+ */
+
+//##################################################################################
+void* AliHLTHOMERManager::GetBlk( Int_t ndx ) {
+  // see header file for class documentation
+  // Get pointer to current block in current event
+   
+  if ( !fReader || !IsConnected() ) {
+    HLTError("Not connected yet.");
+    return NULL;
+  }
+  if ( ndx < static_cast<Int_t>(fNBlks) )
+    return  const_cast<void*> (fReader->GetBlockData(ndx));
+  else
+    return NULL;
+}
+
+//##################################################################################
+ULong_t AliHLTHOMERManager::GetBlkSize( Int_t ndx ) {
+  // see header file for class documentation
+   
+  if ( !fReader || !IsConnected() ) {
+    HLTError("Not connected yet.");
+    return 0;
+  }
+  
+  if ( ndx < static_cast<Int_t>(fNBlks) )
+    return static_cast<ULong_t> (fReader->GetBlockDataLength(ndx));
+  else
+    return 0;
+}
+
+//##################################################################################
+TString AliHLTHOMERManager::GetBlkOrigin( Int_t ndx ) {
+  // see header file for class documentation
+
+  TString origin = "";
+
+  // -- Check for Connection
+  if ( !fReader || ! IsConnected() ) {
+    HLTError("Not connected yet.");
+    return origin;
+  }
+
+  // -- Check block index
+  if ( ndx >= static_cast<Int_t>(fNBlks) ) {
+    HLTError("Block index %d out of range.", ndx );
+    return origin;
+  }
+
+  // -- Get origin
+  union{
+    UInt_t data;
+    Char_t array[4];
+  } reverseOrigin;
+
+  reverseOrigin.data = static_cast<UInt_t>(fReader->GetBlockDataOrigin(ndx));
+
+  // -- Reverse the order
+  for (Int_t ii = 3; ii >= 0; ii-- )
+    if ( reverseOrigin.array[ii] != ' ')
+      origin.Append( reverseOrigin.array[ii] );
+
+  origin.Remove( TString::kTrailing, ' ' );
+
+  return origin;
+}
+
+//##################################################################################
+TString AliHLTHOMERManager::GetBlkType( Int_t ndx ) {
+  // see header file for class documentation
+
+  TString type = "";
+
+  // -- Check for Connection
+  if ( !fReader || ! IsConnected() ) {
+    HLTError("Not connected yet.");
+    return type;
+  }
+
+  // -- Check block index
+  if ( ndx >= static_cast<Int_t>(fNBlks) ) {
+    HLTError("Block index %d out of range.", ndx );
+    return type;
+  }
+
+  // -- Get type
+  union{
+    ULong64_t data;
+    Char_t array[8];
+  } reverseType;
+
+  reverseType.data = static_cast<ULong64_t> (fReader->GetBlockDataType(ndx));
+
+  // -- Reverse the order
+  for (Int_t ii = 7; ii >= 0; ii-- )
+    if ( reverseType.array[ii] != ' ')
+      type.Append( reverseType.array[ii] );
+  
+  type.Remove( TString::kTrailing, ' ' );
+
+  return type;
+}
+
+//##################################################################################
+ULong_t AliHLTHOMERManager::GetBlkSpecification( Int_t ndx ) {
+  // see header file for class documentation
+
+  // -- Check for Connection
+  if ( !fReader || ! IsConnected() ) {
+    HLTError("Not connected yet.");
+    return 0;
+  }
+
+  // -- Check block index
+  if ( ndx >= static_cast<Int_t>(fNBlks) ) {
+    HLTError("Block index %d out of range.", ndx );
+    return 0;
+  }
+
+  return static_cast<ULong_t>(fReader->GetBlockDataSpec(ndx));
+}
+
+//##################################################################################
+Bool_t AliHLTHOMERManager::CheckIfRequested( AliHLTHOMERBlockDesc * block ) {
+  // see header file for class documentation
+
+  Bool_t requested = kFALSE;
+
+  AliHLTHOMERSourceDesc * source= NULL;
+
+  // -- Read all sources and check if they should be read out
+  TIter next( fSourceList );
+  while ( ( source = dynamic_cast<AliHLTHOMERSourceDesc*>(next()) ) ) {
+    
+    // -- Check if source is selected
+    if ( ! source->IsSelected() )
+      continue;
+
+    // -- Check if detector matches
+    if ( source->GetSourceName().CompareTo( block->GetBlockName() ) )
+      continue;
+
+    requested = kTRUE;
+    break;
+
+  } // while ( ( source = dynamic_cast<AliHLTHOMERSourceDesc*>(next()) ) ) {
+  
+#if EVE_DEBUG
+  if ( requested ) {
+    HLTInfo ("Block requested : %s", block->GetBlockName().Data()); 
+  }
+  else {
+    HLTInfo("Block NOT requested : %s", block->GetBlockName().Data()); 
+  }
+#endif
+
+  return requested;
+}
+
diff --git a/HLT/BASE/AliHLTHOMERManager.h b/HLT/BASE/AliHLTHOMERManager.h
new file mode 100644 (file)
index 0000000..e830611
--- /dev/null
@@ -0,0 +1,290 @@
+//-*- Mode: C++ -*-
+
+// $Id: AliHLTHOMERManager.h $
+
+#ifndef ALIEVEHOMERMANGER_H
+#define ALIEVEHOMERMANGER_H
+
+/* This file is property of and copyright by the ALICE HLT Project        * 
+ * ALICE Experiment at CERN, All rights reserved.                         *
+ * See cxx source for full Copyright notice     
+ */
+
+/** @file   AliHLTHOMERManager.h
+    @author Jochen Thaeder
+    @date
+    @brief  Manager for HOMER in aliroot
+*/
+
+
+#include "TString.h"
+#include "TList.h"
+
+#include "AliHLTHOMERSourceDesc.h"
+#include "AliHLTHOMERBlockDesc.h"
+#include "AliHLTHOMERReader.h"
+#include "AliHLTHOMERProxyHandler.h"
+
+#include "AliHLTLogging.h"
+
+class AliHLTHOMERLibManager;
+
+/**
+ * @class AliHLTHOMERManager
+ * This Class should handle the communication
+ * from the HLT to aliroot. The HLT sends data via 
+ * the HOMER interface on several TCP ports of nodes 
+ * in the CERN GPN and DCS network.
+ * All this communication is hidden from the user.
+ * 
+ * Right now, a xml file ( SCC1 ) is used to get the
+ * configuration, this will/ has to change to a proxy
+ * running on dedicated nodes.
+ *
+ * @ingroup alihlt_homer
+ */
+
+class AliHLTHOMERManager : public TObject, public AliHLTLogging {
+public:
+  
+  /*
+   * ---------------------------------------------------------------------------------
+   *                            Constructor / Destructor
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** default constructor */
+  AliHLTHOMERManager();
+
+  /** destructor */
+  virtual ~AliHLTHOMERManager();
+
+  /** Initialize 
+   *  @return 0 on success, <0 for failure
+   */
+  Int_t Initialize();
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                            Source Handling - public
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** Create Sources List from HOMER-Proxy 
+   *  @return 0 on success, <0 for failure
+   */
+  virtual Int_t CreateSourcesList();
+
+  /** Set state of a source 
+   *  @param source      Pointer to AliHLTHOMERSourceDesc object.
+   *  @param state       New (selected/not selected) state.
+   */
+  void   SetSourceState( AliHLTHOMERSourceDesc* source, Bool_t state);
+
+  /** Get pointer to source List */
+  TList* GetSourceList() { return fSourceList; }
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                            Connection Handling - public
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** Connect to HOMER sources, out of Readout List, 
+   *  which gets created when state has changed 
+   *  @return 0 on success, <0 for failure
+   */
+  Int_t ConnectHOMER();
+
+  /** Disconnect from HOMER sources */
+  void  DisconnectHOMER();
+
+  /** Reconnect from HOMER sources 
+   *  @return 0 on success, <0 for failure
+   */
+  Int_t ReconnectHOMER();
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                            Event Handling - public
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** Loads the next Event, after being connected 
+   *  @return 0 on success, <0 for failure
+   */
+  virtual Int_t NextEvent();
+
+  /** Get event ID */
+  ULong_t GetEventID() { return fEventID; }    // Get event ID
+
+  /** Get pointer to block List */
+  TList* GetBlockList() { return fBlockList; } // Get pointer to block List
+  
+  ///////////////////////////////////////////////////////////////////////////////////
+
+protected:
+
+  /** Dynamic loader manager for the HOMER library */
+  AliHLTHOMERLibManager* fLibManager;             //! transient
+
+  ///////////////////////////////////////////////////////////////////////////////////
+
+private:
+
+  /** copy constructor prohibited */
+  AliHLTHOMERManager(const AliHLTHOMERManager&);
+
+  /** assignment operator prohibited */
+  AliHLTHOMERManager& operator=(const AliHLTHOMERManager&);
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                            Connection Handling - private
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** Create a readout list for Hostname and ports 
+   *  @param socurceHostnames   Array of selected hostnames
+   *  @param socurcePorts       Array of selected ports
+   *  @param socurceCount       Number of selected hostname:port
+   */
+  void CreateReadoutList( const char** sourceHostnames, UShort_t* sourcePorts, 
+                         UInt_t &sourceCount);
+
+  /** Checks if already connected to HOMER sources */
+  Bool_t IsConnected() { return fConnected; }  
+  
+  /* ---------------------------------------------------------------------------------
+   *                            Event Handling - private
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** Create a TList of blocks, which have been readout */
+  void CreateBlockList();
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                            Block Handling - private
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** Get Number of blocks in current event */
+  ULong_t GetNBlks() { return fNBlks; }
+
+  // ----------------------------------------------------
+
+  /** Get pointer to block ndx in current event 
+   *  @param ndx        Block index
+   *  @return           returns pointer to blk, NULL if no block present
+   */
+  void* GetBlk( Int_t ndx );
+
+  /** Get pointer to current block in current event */
+  void* GetBlk() { return GetBlk(fCurrentBlk); }
+
+  /** Get first block in current event */
+  void* GetFirstBlk() { fCurrentBlk=0; return GetBlk(0); }
+
+  /** Get next block in current event */
+  void* GetNextBlk() { return GetBlk(++fCurrentBlk); }
+
+  // ----------------------------------------------------
+
+  /** Get size of block ndx 
+   *  @param ndx        Block index
+   *  @return           returns size blk, 0 otherwise
+   */
+  ULong_t GetBlkSize( Int_t ndx );
+
+  /** Get size of current block */ 
+  ULong_t GetBlkSize() { return GetBlkSize( fCurrentBlk ); }
+
+  // ---------------------------------------------------- 
+
+  /** Get origin of block ndx 
+   *  @param ndx        Block index
+   *  @return           origin of block
+   */
+  TString GetBlkOrigin( Int_t ndx );
+
+  /** Get origin of current block */
+  TString GetBlkOrigin(){ return GetBlkOrigin( fCurrentBlk ); }
+
+  // ----------------------------------------------------
+
+  /** Get type of block ndx 
+   *  @param ndx        Block index
+   *  @return           type of block
+   */
+  TString GetBlkType( Int_t ndx ); 
+
+  /** Get type of current block */
+  TString GetBlkType() { return GetBlkType( fCurrentBlk ); } 
+  
+  // ----------------------------------------------------
+  
+  /** Get specification of block ndx 
+   *  @param ndx        Block index
+   *  @return           specification of block
+   */
+  ULong_t GetBlkSpecification( Int_t ndx );
+
+  /** Get specification of current block */
+  ULong_t GetBlkSpecification() { return GetBlkSpecification( fCurrentBlk ); } 
+
+  // ----------------------------------------------------
+
+  /** Checks if current Block should was requested 
+   *  @return           returns kTRUE, if block should was requested
+   */
+  Bool_t CheckIfRequested( AliHLTHOMERBlockDesc* block );
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                            Members - private
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** Proxy Handler to get the list of sources */
+  AliHLTHOMERProxyHandler *fProxyHandler;            //! transient 
+
+  // == connection ==
+
+  /** Pointer to HOMER reader */
+  AliHLTHOMERReader* fReader;                        //! transient 
+
+  // == sources ==
+
+  /** List to HOMER sources */
+  TList    *fSourceList;                             //! transient
+  
+  // == blocks ==
+
+  /** List to HOMER blocks */
+  TList    *fBlockList;                              //! transient
+
+  // == events ==
+
+  /** Number of blockes in current event */
+  ULong_t   fNBlks;                                  //  see above
+
+  /** EventID of current event */
+  ULong64_t fEventID;                                //  see above
+
+  /** Current block in current event */
+  ULong_t   fCurrentBlk;                             //  see above
+
+  // == states ==
+  
+  /** Shows connection status */
+  Bool_t    fConnected;                              //  see above
+
+  /** Indicates, if a sources have changes, 
+   *  so that one has to reconnect. */
+  Bool_t    fStateHasChanged;                        //  see above
+
+  ClassDef(AliHLTHOMERManager, 0); // Manage connections to HLT data-sources.
+};
+
+#endif
diff --git a/HLT/BASE/AliHLTHOMERProxyHandler.cxx b/HLT/BASE/AliHLTHOMERProxyHandler.cxx
new file mode 100644 (file)
index 0000000..f030e2e
--- /dev/null
@@ -0,0 +1,396 @@
+//-*- Mode: C++ -*-
+// $Id: AliHLTHOMERProxyHandler.cxx  $
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//*                                                                        *
+//* Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de>        *
+//*                  for The ALICE HLT Project.                            *
+//*                                                                        *
+//* Permission to use, copy, modify and distribute this software and its   *
+//* documentation strictly for non-commercial purposes is hereby granted   *
+//* without fee, provided that the above copyright notice appears in all   *
+//* copies and that both the copyright notice and this permission notice   *
+//* appear in the supporting documentation. The authors make no claims     *
+//* about the suitability of this software for any purpose. It is          *
+//* provided "as is" without express or implied warranty.                  *
+//**************************************************************************
+
+/** @file   AliHLTHOMERProxyHandler.cxx
+    @author Jochen Thaeder
+    @date
+    @brief  HOMER proxy handler for HomerManger
+*/
+
+// see header file for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
+#if __GNUC__>= 3
+   using namespace std;
+#endif
+
+#include "TDOMParser.h"
+#include "TSocket.h"
+#include "TSystem.h"
+// -- -- -- -- -- -- -- 
+#include "AliHLTHOMERProxyHandler.h"
+
+ClassImp(AliHLTHOMERProxyHandler)
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                            Constructor / Destructor
+ * ---------------------------------------------------------------------------------
+ */
+
+//##################################################################################
+AliHLTHOMERProxyHandler::AliHLTHOMERProxyHandler() :
+  fRealm(kHLT),
+  fXmlRpcResponse(""),
+  fSourceList(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
+}
+
+//##################################################################################
+AliHLTHOMERProxyHandler::~AliHLTHOMERProxyHandler() {
+  // see header file for class documentation
+
+}
+
+//##################################################################################
+Int_t AliHLTHOMERProxyHandler::Initialize() {
+  // see header file for class documentation
+
+  Int_t iResult = 0 ;
+
+  IdentifyRealm();
+
+  return iResult;
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                             Source List - public
+ * ---------------------------------------------------------------------------------
+ */
+
+//##################################################################################
+Int_t AliHLTHOMERProxyHandler::FillSourceList(TList *srcList) {
+  // see header file for class documentation
+
+  Int_t iResult = 0;
+
+  fSourceList = srcList;
+
+  iResult = RequestXmlRpcResponse();
+
+  if (!iResult)
+    iResult = ProcessXmlRpcResponse();
+
+  if (iResult)
+    HLTError("Filling SourceList failed.");
+
+  return iResult;
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                        Realms - private
+ * ---------------------------------------------------------------------------------
+ */
+
+//##################################################################################
+const Char_t *AliHLTHOMERProxyHandler::fgkHOMERProxyNode[] = { 
+  "portal-dcs0.internal", 
+  "alihlt-dcs0.cern.ch",
+  "alihlt-vobox0.cern.ch",
+  "alihlt-gw0.kip.uni-heidelberg.de",
+  "portal-dcs1.internal", 
+  "alihlt-dcs1.cern.ch",
+  "alihlt-vobox1.cern.ch",
+  "alihlt-gw1.kip.uni-heidelberg.de"
+};
+
+//##################################################################################
+void AliHLTHOMERProxyHandler::IdentifyRealm() {
+  // see header file for class documentation
+
+  TString hostIP(gSystem->GetHostByName(gSystem->HostName()).GetHostAddress());
+
+  if ( hostIP.Contains("10.162.") )
+    fRealm = kHLT;
+  else if ( hostIP.Contains("10.160.") || hostIP.Contains("10.161.") )
+    fRealm = kACR;
+  else if ( hostIP.Contains("129.206.") )
+    fRealm = kKIP;
+  else 
+    fRealm = kGPN;
+  
+  return;
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                        Proxy Communication - private
+ * ---------------------------------------------------------------------------------
+ */
+
+//##################################################################################
+Int_t AliHLTHOMERProxyHandler::RequestXmlRpcResponse() {
+  // see header file for class documentation
+
+  Int_t iResult = 0;
+
+  // -- open socket
+  // ----------------
+
+  Int_t proxyPort = 19999;
+
+  TSocket *socket = new TSocket(fgkHOMERProxyNode[fRealm], proxyPort);
+  if ( ! socket->IsValid() ) {
+    HLTWarning("Failed to create socket to %s:%d,",fgkHOMERProxyNode[fRealm], proxyPort);
+    HLTWarning("trying %s:%d now.", fgkHOMERProxyNode[fRealm+kHOMERRealmsMax],proxyPort);
+
+    socket = new TSocket(fgkHOMERProxyNode[fRealm+kHOMERRealmsMax], proxyPort);
+    if ( ! socket->IsValid() ) {
+      HLTError("Failed to create socket to %s:%d and %s:%d.",
+              fgkHOMERProxyNode[fRealm], proxyPort,
+              fgkHOMERProxyNode[fRealm+kHOMERRealmsMax],proxyPort);
+      fRealm = -1;
+      return -1;
+    }
+    else
+      fRealm = fRealm+kHOMERRealmsMax;
+  }
+
+  // -- send request
+  // -----------------
+
+  Char_t reqMsg[] = "PUT / HTTP/1.1\r\n\
+User-Agent: curl/7.18.0 (x86_64-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1\r\n\
+Host: localhost:10000\r\n\
+Accept: */*\r\n\
+Content-type: text/xml\r\n\
+Content-Length: 68\r\n\
+\r\n<methodCall><methodName>getTcpDumpServices</methodName></methodCall>\r\n";
+
+  iResult = socket->SendRaw( reqMsg, strlen(reqMsg) );
+  if ( iResult < 1 || 
+       iResult !=  static_cast<Int_t>(strlen(reqMsg))) {
+    HLTError("Error sending! -- send length %d  -- msg length %d.", iResult, strlen(reqMsg) );
+    socket->Close();
+    return iResult;
+  }
+  
+  // -- receive answer
+  // -------------------
+
+  const Int_t bufferSize = 1024;
+  Char_t buffer[bufferSize];
+
+  Bool_t isXmlRpc = kFALSE;
+
+  fXmlRpcResponse = "";
+
+  // -- loop for getting full xmlRPC response
+  while(1) {
+
+    Int_t bufferLength = 0;
+    
+    // -- loop for reading until end of line
+    while (1) {
+
+      iResult = socket->RecvRaw(&buffer[bufferLength], 1);
+      if ( iResult < 0) {
+       HLTError("Error reading form socket.");
+       socket->Close();
+       return iResult;
+      }
+            
+      // -- Checking for  end of line
+      if ( buffer[bufferLength] == 10 ) {
+       buffer[bufferLength] = 0;
+       break;
+      }
+      
+      ++bufferLength;
+    }
+
+    TString bufferString(buffer);
+
+    // -- Checking for start of XML response
+    if ( bufferString.BeginsWith("<?xml") )
+      isXmlRpc = kTRUE;
+
+    // -- Append the xml response
+    if (isXmlRpc) {
+      fXmlRpcResponse.Append(bufferString);
+    }
+
+    // -- Checking for end of XML response
+    if( ! bufferString.CompareTo("</methodResponse>") ) 
+      break;
+  }
+  
+  // -- close socket
+  socket->Close();
+
+  return 0;
+}
+
+//##################################################################################
+Int_t AliHLTHOMERProxyHandler::ProcessXmlRpcResponse() {
+  // see header file for class documentation
+
+  Int_t iResult = 0;
+
+  // -- Parse XML RPC Response
+  // ---------------------------
+
+  TDOMParser xmlParser;
+  xmlParser.SetValidate(kFALSE);
+
+  HLTInfo("XMLResponse:\n %s",fXmlRpcResponse.Data());
+
+  iResult = xmlParser.ParseBuffer(fXmlRpcResponse.Data(), fXmlRpcResponse.Length());
+  if ( iResult < 0 ) {
+    HLTError("Parsing buffer with error: %s", 
+            xmlParser.GetParseCodeMessage(xmlParser.GetParseCode()) );
+    return iResult;
+  }
+
+  TXMLNode * node = xmlParser.GetXMLDocument()->GetRootNode()->
+    GetChildren()->GetChildren()->GetChildren()->GetChildren();
+  
+  if ( strcmp( node->GetNodeName(), "string" ) ) {
+    HLTError("No node 'string' in XmlRpcResponse.");
+    return -1;
+  }
+
+  // -- Parse Content
+  // ------------------
+
+  // -- Get Content
+  TString xmlContent(node->GetText() );
+
+  HLTInfo("XMLContent:\n %s",xmlContent.Data());
+
+  iResult = xmlParser.ParseBuffer(xmlContent.Data(), xmlContent.Length());
+  if ( iResult < 0 ) {
+    HLTError("Parsing buffer with error: %s", 
+            xmlParser.GetParseCodeMessage(xmlParser.GetParseCode()) );
+    return iResult;
+  }
+  
+
+  if ( !xmlParser.GetXMLDocument()->GetRootNode()->HasChildren() ) {
+    HLTInfo("No Services active.");
+    return 0;
+  }
+
+  // -- Loop over all service nodes
+  TXMLNode* serviceNode = xmlParser.GetXMLDocument()->GetRootNode()->GetChildren();
+  TXMLNode* prevServiceNode = NULL;
+  
+  do {
+    prevServiceNode = serviceNode;
+
+    // -- Add service to list
+    iResult = AddService( serviceNode->GetChildren() );
+       
+  } while ( ( serviceNode = prevServiceNode->GetNextNode() ) && !iResult );
+
+  return iResult;
+}
+
+/*
+ * ---------------------------------------------------------------------------------
+ *                            Source Resolving - private
+ * ---------------------------------------------------------------------------------
+ */
+
+//##################################################################################
+Int_t AliHLTHOMERProxyHandler::AddService(TXMLNode *innerNode) {
+  // see header file for class documentation
+
+  Int_t iResult = 0;
+
+  HLTInfo(">> New service");    
+
+  // -- Loop over all service properties and 
+  //    read them from the service tag
+  // -----------------------------------------
+
+  TString hostname          = "";
+  Int_t   port              = 0;
+  TString dataType          = "";
+  TString dataOrigin        = "";
+  TString dataSpecification = "";
+
+  TXMLNode* prevInnerNode = NULL;
+
+  do {
+    prevInnerNode = innerNode;
+    
+    if ( ! strcmp(innerNode->GetNodeName(), "text" ) )
+      continue;
+    
+    HLTInfo(" %s ++ %s", innerNode->GetNodeName(), innerNode->GetText() );
+    
+    // -- hostname
+    if ( ! strcmp( innerNode->GetNodeName(), "address") )
+      hostname = innerNode->GetText();
+    else if ( ! strcmp( innerNode->GetNodeName(), "port") ) {
+      TString portS(innerNode->GetText());
+      if ( portS.IsDigit() )
+       port = portS.Atoi();
+      else {
+       HLTError("Port %s is not a digit.", portS.Data());
+       iResult = -1;
+      }
+    }
+    else if ( ! strcmp( innerNode->GetNodeName(), "dataorigin") )
+      dataOrigin = innerNode->GetText();
+    else if ( ! strcmp( innerNode->GetNodeName(), "datatype") )
+      dataType = innerNode->GetText();
+    else if ( ! strcmp( innerNode->GetNodeName(), "dataspecification") )
+      dataSpecification = innerNode->GetText();    
+  
+  } while ( ( innerNode = prevInnerNode->GetNextNode() ) && !iResult );
+
+  // -- Check the service properties
+  // ---------------------------------
+
+  // -- Change hostame from service with proxy, if outside HLT
+  if ( fRealm != kHLT || fRealm != kHLT+kHOMERRealmsMax )
+    hostname = fgkHOMERProxyNode[fRealm];
+
+  // -- Check for completeness of the source properties
+  if ( hostname.IsNull() || !port || dataOrigin.IsNull() ||
+       dataType.IsNull() /*|| dataSpecification.IsNull()*/ ) {
+    HLTError("Service provides not all values:\n\thostname\t\t %s\n\tport\t\t\t %d\n\tdataorigin\t\t %s\n\tdatatype\t\t %s\n\tdataspecification\t %s", hostname.Data(),
+            port, dataOrigin.Data(), dataType.Data(), dataSpecification.Data());
+    return -2;
+  }
+
+  // -- Create new source
+  // ----------------------
+
+  AliHLTHOMERSourceDesc * source = new AliHLTHOMERSourceDesc();
+  source->SetService( hostname, port, dataType, dataOrigin, dataSpecification );
+
+  fSourceList->Add( source );
+
+  HLTInfo( "New Source added : %s", source->GetSourceName().Data());
+  
+  return iResult;
+}
+
+
diff --git a/HLT/BASE/AliHLTHOMERProxyHandler.h b/HLT/BASE/AliHLTHOMERProxyHandler.h
new file mode 100644 (file)
index 0000000..3e60b56
--- /dev/null
@@ -0,0 +1,144 @@
+//-*- Mode: C++ -*-
+
+// $Id: AliHLTHOMERProxyHandler.h $
+
+#ifndef ALIHLTHOMERPROXYHANDLER_H
+#define ALIHLTHOMERPROXYHANDLER_H
+
+/* This file is property of and copyright by the ALICE HLT Project        * 
+ * ALICE Experiment at CERN, All rights reserved.                         *
+ * See cxx source for full Copyright notice     
+ */
+
+/** @file   AliHLTHOMERProxyHandler.h
+    @author Jochen Thaeder
+    @date
+    @brief  HOMER proxy handler for HomerManger
+*/
+
+#include "TString.h"
+#include "TList.h"
+#include "TXMLNode.h" 
+// -- -- -- -- -- -- -- 
+#include "AliHLTHOMERSourceDesc.h"
+// -- -- -- -- -- -- -- 
+#include "AliHLTLogging.h"
+
+/**
+ * @class AliHLTHOMERProxyHandler
+ * This Class should handle the communication with the proxy
+ * and fill the source list.
+ *
+ * @ingroup alihlt_homer
+ */
+
+class AliHLTHOMERProxyHandler : public TObject, public AliHLTLogging
+{
+public:
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                            Constructor / Destructor
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** constructor */
+  AliHLTHOMERProxyHandler();
+
+  /** destructor */
+  virtual ~AliHLTHOMERProxyHandler();
+
+  /** Initialize 
+   *  @return 0 on success, <0 for failure
+   */
+  Int_t Initialize();
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                             Source List - public
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** Fill's source list, with entries */
+  Int_t FillSourceList(TList *srcList);
+
+  ///////////////////////////////////////////////////////////////////////////////////
+
+private:
+
+  /** copy constructor prohibited */
+  AliHLTHOMERProxyHandler(const AliHLTHOMERProxyHandler&);            // Not implemented.
+
+  /** assignment operator prohibited */
+  AliHLTHOMERProxyHandler& operator=(const AliHLTHOMERProxyHandler&); // Not implemented.
+
+  /*
+   * ---------------------------------------------------------------------------------
+   *                        Realms - private
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** Realms */
+  enum HOMERRealms_t { 
+    kHLT,            /**< HLT realm */
+    kACR,            /**< ACR realm */
+    kGPN,            /**< GPN realm */
+    kKIP,            /**< KIP realm */
+    kHOMERRealmsMax  /**< Number of enum entries */
+  };
+
+  /** Array of proxy nodes per realm */
+  static const Char_t *fgkHOMERProxyNode[];     
+
+  /** Indentifies the realm and sets it
+   *  @return 0 on success, <0 for failure
+   */
+  void IdentifyRealm();
+  
+  /*
+   * ---------------------------------------------------------------------------------
+   *                        Proxy Communication - private
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** Get xmlrpc response from the proxy 
+   *  @return 0 on success, <0 for failure
+   */
+  Int_t RequestXmlRpcResponse();
+
+  /** process xmlrpc response and fill the source list
+   *  @return 0 on success, <0 for failure
+   */
+  Int_t ProcessXmlRpcResponse();
+  
+  /*
+   * ---------------------------------------------------------------------------------
+   *                            Source Resolving - private
+   * ---------------------------------------------------------------------------------
+   */
+  
+  /** Add a new Service to list
+   *  @param xmlNode   Ptr to service node
+   *  @return          0 on sucess, <0 for failure
+   */
+  Int_t AddService(TXMLNode *innerNode);
+  
+  /*
+   * ---------------------------------------------------------------------------------
+   *                            Members - private
+   * ---------------------------------------------------------------------------------
+   */
+
+  /** Realm, which can be ACR, GPN, HLT, KIP */
+  Int_t       fRealm;                             // see above
+
+  /** xmlRPC response */
+  TString     fXmlRpcResponse;                    // see above
+
+  /** List to HOMER sources */
+  TList*      fSourceList;                        //! transient
+
+  ClassDef(AliHLTHOMERProxyHandler, 0); // Handles HLT xml sources.
+};
+
+#endif
index c6a5215cf21b53e3861bd4c4df1c791a9feb9454..ee27790f1039952617bf5ce27a848a549f8a5910 100644 (file)
@@ -37,15 +37,14 @@ ClassImp(AliHLTHOMERSourceDesc)
 //##################################################################################
 AliHLTHOMERSourceDesc::AliHLTHOMERSourceDesc() :
   fSelected( kFALSE ),
+  fSourceName(),
   fHostname(),
   fPort(),
-  fSourceName(),
-  fClassName(),
+  fDataType(),
   fDetector(),
-  fSubDetector(),
-  fSubSubDetector(),
   fSpecification(),
-  fDataType() {
+  fSubDetector(),
+  fSubSubDetector() {
   // see header file for class documentation
   // or
   // refer to README to build package
@@ -53,26 +52,37 @@ AliHLTHOMERSourceDesc::AliHLTHOMERSourceDesc() :
   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
 }
 
-
 //##################################################################################
-AliHLTHOMERSourceDesc::AliHLTHOMERSourceDesc( TString hostname, Int_t port ) :
-  fSelected( kFALSE ),
-  fHostname( hostname ),
-  fPort( port ),
-  fSourceName(),
-  fClassName(),
-  fDetector(),
-  fSubDetector(),
-  fSubSubDetector(), 
-  fSpecification(),
-  fDataType() {
+AliHLTHOMERSourceDesc::~AliHLTHOMERSourceDesc() {
   // see header file for class documentation
-
 }
 
+/*
+ * ---------------------------------------------------------------------------------
+ *                        Setter - public
+ * ---------------------------------------------------------------------------------
+ */
 
-//##################################################################################
-AliHLTHOMERSourceDesc::~AliHLTHOMERSourceDesc() {
+//#################################################################################
+void AliHLTHOMERSourceDesc::SetService( TString hostname, Int_t port, TString origin, 
+                                       TString type, TString /*spec*/ ) {
   // see header file for class documentation
-}
 
+  fSourceName.Form("%s_%s%_%ul", fDetector.Data(), fDataType.Data(), fSpecification); 
+
+  fHostname = hostname;
+  fPort = port;
+  
+  fDataType = type;
+  fDataType.Remove( TString::kTrailing, ' ' );
+  
+  fDetector = origin;
+  fDetector.Remove( TString::kTrailing, ' ' );
+  
+  // -- Temporary until Specification is set in service
+  fSpecification = 0;
+  fSubDetector = 0;
+  fSubSubDetector = 0;
+
+  return;
+}
index 275c2a6c67bcb817ddad3115f7a21fb51ff6e637..268c6d0e5992cd0819b7d0bc87c1d7107acb25d9 100644 (file)
@@ -41,18 +41,18 @@ class AliHLTHOMERSourceDesc : public TNamed {
 
 public:
 
-  /** standard constructor */
+  /**  constructor */
   AliHLTHOMERSourceDesc();       
 
-  /** constructor 
-   * @param hostname   hostname of the source
-   * @param port       port of the source
-   */
-  AliHLTHOMERSourceDesc( TString hostname, Int_t port );
-
   /** destructor */
   virtual ~AliHLTHOMERSourceDesc();
 
+  /*
+   * ---------------------------------------------------------------------------------
+   *                        Selection - public
+   * ---------------------------------------------------------------------------------
+   */
+
   // -- SELECTION --
 
   /** Set selection state
@@ -62,43 +62,36 @@ public:
 
   /** Checks if Source is selected to readout 
    * @return           returns state, either kTRUE or kFALSE
-  */
+   */
   Bool_t IsSelected()           { return fSelected; }
 
   /** Select this source */
   void Select()                 { fSelected = kTRUE; }
-
+  
   /** Deselect this source */
   void Deselect()               { fSelected = kFALSE; }
 
-  // -- SETTER --
-
-  /** Set node name of this source 
-   * @param hostname   hostname of the source
-   * @param port       port of the source
+  /*
+   * ---------------------------------------------------------------------------------
+   *                        Setter - public
+   * ---------------------------------------------------------------------------------
    */
-   void SetHostnamePort( TString hostname, Int_t port )   { fHostname = hostname; fPort = port; }
 
-  /** Set name/obj name of this source 
-   *  @param s1        source name
-   *  @param s2        source class name, default is ""
+  /** Set Service of this source 
+   *  @param hostname  hostname of the source
+   *  @param port      port of the source
+   *  @param origin    HLT data origin
+   *  @param type      HLT data type
+   *  @param spec      HLT data specification
    */
-  void SetSourceName( TString s1, TString s2="" )         { fSourceName = s1; fClassName = s2; }
+  void SetService( TString hostname, Int_t port, TString origin, 
+                  TString type, TString spec );
 
-  /** Set detector, sub detector and sub sub detector of this source 
-   *  @param s1        detector name
-   *  @param s2        subdetector name
-   *  @param s3        subsubdetector name
+  /*
+   * ---------------------------------------------------------------------------------
+   *                        Getter - public
+   * ---------------------------------------------------------------------------------
    */
-  void SetDetectors( TString s1, TString s2, TString s3 ) { fDetector = s1; fSubDetector = s2; fSubSubDetector = s3; }
-
-  /** Set HLT specification anf HLT data type of this source 
-   *  @param ul        HLT specification
-   *  @param s         HLT data type
-   */
-  void SetSourceType( ULong_t ul, TString s )             { fSpecification = ul, fDataType = s; }
-  // -- GETTER --
 
   /** Get node name of this source 
    * @return           hostname
@@ -108,18 +101,13 @@ public:
   /** Get node name of this source 
    * @return           port
    */
-  Int_t GetPort()             { return fPort; }
+  Int_t   GetPort()           { return fPort; }
 
   /** Get name of this source 
    * @return           name
    */
   TString GetSourceName()     { return fSourceName; }
 
-  /** Get object name of this source
-   * @return           class name
-   */
-  TString GetClassName()      { return fClassName; }
-
   /** Get detector of this source 
    * @return           detector
    */
@@ -128,12 +116,12 @@ public:
   /** Get sub detector of this source 
    * @return           subdetector
    */
-  TString GetSubDetector()    { return fSubDetector; }
+  Int_t   GetSubDetector()    { return fSubDetector; }
 
   /** Get sub sub detector of this source 
    * @return           subsubdetector
    */
-  TString GetSubSubDetector() { return fSubSubDetector; }
+  Int_t   GetSubSubDetector() { return fSubSubDetector; }
 
   /** Get HLT data type of this source
    * @return           HLT data type
@@ -145,45 +133,56 @@ public:
    */
   ULong_t GetSpecification()  { return fSpecification; }
 
+  ///////////////////////////////////////////////////////////////////////////////////
 
 private:
+
   /** copy constructor prohibited */
   AliHLTHOMERSourceDesc(const AliHLTHOMERSourceDesc&);
   
   /** assignment operator prohibited */
   AliHLTHOMERSourceDesc& operator=(const AliHLTHOMERSourceDesc&);
 
+  /*
+   * ---------------------------------------------------------------------------------
+   *                            Members - private
+   * ---------------------------------------------------------------------------------
+   */
+
   /** is selected to read out */
   Bool_t fSelected;             // see above
 
+  /** Name of Source */
+  TString fSourceName;          // see above
+
+  // -- Service Specifications --
+  // ----------------------------
+
   /** Name of HOMER Node */
   TString fHostname;            // see above
 
   /** Name of HOMER port */
   Int_t fPort;                  // see above
 
-  /** Name of Source */
-  TString fSourceName;          // see above
+  // -- Data Specifications --
+  // -------------------------
 
-  /** Object Name of Source */
-  TString fClassName;           // see above
+  /** HLT DataType */
+  TString fDataType;            // see above
 
   /** Detector Name, e.g. PHOS 
    *  corresponds to HLT origin
    */
   TString fDetector;            // see above
 
-  /** SubDetector Name e.g. MODULE */
-  TString fSubDetector;         // see above
-
-  /** SubSubDetector Name e.g. PARTITION */
-  TString fSubSubDetector;      // see above
-
   /** HLT Specification */
   ULong_t fSpecification;       // see above
 
-  /** HLT DataType */
-  TString fDataType;            // see above
+  /** SubDetector Name e.g. MODULE */
+  Int_t   fSubDetector;         // see above
+
+  /** SubSubDetector Name e.g. PARTITION */
+  Int_t   fSubSubDetector;      // see above
 
   ClassDef( AliHLTHOMERSourceDesc, 0 )
 };
index e2f2dc2df050efe5a1fdd914f679b31446ea7a94..1e9f1ed61e4eb4d88b17f5dfee301336dfb74fe3 100644 (file)
@@ -27,6 +27,8 @@
 #pragma link C++ class AliHLTModulePreprocessor+;
 #pragma link C++ class AliHLTShuttleInterface+;
 #pragma link C++ class AliHLTHOMERLibManager+;
+#pragma link C++ class AliHLTHOMERManager+;
+#pragma link C++ class AliHLTHOMERProxyHandler+;
 #pragma link C++ class AliHLTHOMERBlockDesc+;
 #pragma link C++ class AliHLTHOMERSourceDesc+;
 #pragma link C++ class AliHLTEsdManager+;
index 5889199b3d117c0bb209d16643d0ebf2955f993b..8cd548f7c7c4a4b493f89a664123777bc510f9ae 100644 (file)
@@ -25,6 +25,8 @@ BASE/AliHLTModuleAgent.cxx
 BASE/AliHLTModulePreprocessor.cxx
 BASE/AliHLTShuttleInterface.cxx
 BASE/AliHLTHOMERLibManager.cxx
+BASE/AliHLTHOMERManager.cxx
+BASE/AliHLTHOMERProxyHandler.cxx
 BASE/AliHLTHOMERBlockDesc.cxx
 BASE/AliHLTHOMERSourceDesc.cxx
 BASE/AliHLTEsdManager.cxx
diff --git a/HLT/exa/HOMERManager.C b/HLT/exa/HOMERManager.C
new file mode 100644 (file)
index 0000000..31f3167
--- /dev/null
@@ -0,0 +1,63 @@
+//-*- Mode: C++ -*-
+// $Id: HOMERManager.C  $
+/**
+ * @file HOMERManager.C
+ * @brief Sample macro for the use of the HOMERManager
+ *
+ * Usage:
+ * <pre>
+ *   aliroot -l HOMERManager.C 
+ * </pre>
+ *
+ * This macro illustrates the usage of the AliHLTHOMERManager in order
+ * to on-line read events outside the HLT.
+ *
+ * This macro can be run inside the
+ * <ul>
+ *    <li>DAQ/DCS(ACR) network</li>
+ *    <li>HLT network</li>
+ *    <li>CERN GPN network</li>
+ * </ul>
+ * 
+ * See AliHLTHOMERManager for detailed description.
+ *
+ * @author Jochen Thaeder 
+ * @ingroup alihlt_tutorial
+ * @ingroup alihlt_homer
+ */
+
+Int_t HOMERManager() {
+
+  Int_t iResult = 0;
+
+  // -- Create new hM object
+  AliHLTHOMERManager *hM = new AliHLTHOMERManager();
+
+  printf( "== INITIALIZE ==\n" );
+
+  iResult = hM->Initialize();
+  if (iResult) return iResult;
+
+  printf( "== CREATE SOURCE LIST ==\n" );
+
+  iResult = hM->CreateSourcesList();
+  if (iResult) return iResult; 
+
+  printf( "== CONNECT HOMER ==\n" );
+  
+  iResult = hM->ConnectHOMER();
+  if (iResult) return iResult;
+  
+  //  printf( "== NEXT EVENT ==\n" );
+  
+  iResult = hM->NextEvent();
+  if (iResult) return iResult;
+
+
+  // -- Destroy hM object
+  if (hM)
+    delete hM;
+  hM = NULL;
+
+  return iResult;;
+}
index 2f71242c8d71ec775a3cb1012b4323136c5ded06..af24a0a0a51ff0d147d208aa9100a9c2618b816d 100644 (file)
@@ -28,6 +28,8 @@ CLASS_HDRS:=          AliHLTComponent.h \
                AliHLTModulePreprocessor.h \
                AliHLTShuttleInterface.h \
                AliHLTHOMERLibManager.h \
+               AliHLTHOMERManager.h \
+               AliHLTHOMERProxyHandler.h \
                AliHLTHOMERBlockDesc.h \
                AliHLTHOMERSourceDesc.h \
                AliHLTEsdManager.h \