]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTCalibrationProcessor.cxx
correcting a typo in initialization
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTCalibrationProcessor.cxx
index ef504f233ba7e302db87afd612a45ac1ba148364..61f2c8e56eddb395b46e47911a0ca8732d01acbd 100644 (file)
@@ -1,3 +1,4 @@
+// $Id$
 /**************************************************************************
  * This file is property of and copyright by the ALICE HLT Project        * 
  * ALICE Experiment at CERN, All rights reserved.                         *
  * @date 
  * @brief  Base class of HLT calibration components.  */
 
+// 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 "AliHLTCalibrationProcessor.h"
 #include "AliHLTMemoryFile.h"
+#include "AliHLTReadoutList.h"
 
 #include <cstdlib>
 #include <cerrno>
@@ -66,9 +74,13 @@ AliHLTCalibrationProcessor::~AliHLTCalibrationProcessor() {
  * ######################## InitCalibration #####################
  */
 
-Int_t AliHLTCalibrationProcessor::DoInit( Int_t argc, const Char_t** argv ) {
+Int_t AliHLTCalibrationProcessor::DoInit( int argc, const char** argv ) {
   // see header file for class documentation
 
+  // TODO: revision of argument scan needed, adjust to the new base class
+  // methods for argument scan
+  // call the configuration from the default OCDB object before the argument
+  // scan to override in correct sequence
   Int_t iResult = 0;
   TString argument = "";
   TString parameter = "";
@@ -125,6 +137,9 @@ Int_t AliHLTCalibrationProcessor::DoInit( Int_t argc, const Char_t** argv ) {
     iResult = InitCalibration();
   }
 
+  // Reset the DDLNumberList
+  memset( fDDLNumber, 0, gkAliHLTFXSHeaderfDDLNumberSize);
+
   return iResult;
 }
 
@@ -140,7 +155,7 @@ Int_t AliHLTCalibrationProcessor::InitCalibration() {
 }
 
 
-Int_t AliHLTCalibrationProcessor::ScanArgument(Int_t argc, const Char_t** argv) {
+Int_t AliHLTCalibrationProcessor::ScanArgument(int argc, const char** argv) {
   // see header file for class documentation
   
   // there are no other arguments than the standard ones
@@ -193,32 +208,15 @@ Int_t AliHLTCalibrationProcessor::DoEvent( const AliHLTComponentEventData& evtDa
   // see header file for class documentation
 
   Int_t iResult = 0;
-  const AliHLTComponentBlockData* iter = NULL;
 
   const AliHLTComponentBlockData* blkSOR = NULL;
-  const AliHLTComponentBlockData* blkEOR = NULL;
-  const AliHLTComponentBlockData* blkDDL = NULL;
-
-  HLTInfo( "Event ID: %lu", evtData.fEventID );
-
-  // ---------------  START OF RUN -----------------
   blkSOR = GetFirstInputBlock( kAliHLTDataTypeSOR );
-  
-  // ----------------  END OF RUN ------------------
+  const AliHLTComponentBlockData* blkEOR = NULL;
   blkEOR = GetFirstInputBlock( kAliHLTDataTypeEOR );
-  
-  // --------------  GET DDLNumber -----------------
-  blkDDL = GetFirstInputBlock( kAliHLTDataTypeDDL );
-  
-  if ( blkDDL ) {
-    HLTInfo("DDLLIST block received, size: %u", iter->fSize );
-    //AliHLTEventDDL ddlList = ( AliHLTEventDDL* ) iter->fPtr;
-  }
-  
-  // ------------ decide which event type ----------
 
-  // - if event Type is not SOR or EOR -> process data
+  // ** if event Type is not SOR or EOR -> fill DDLNumber list and process data
   if ( ! blkEOR  && !blkSOR ) {
+    // ** ProcessData
     iResult = ProcessCalibration( evtData, blocks, trigData, outputPtr, size, outputBlocks );
     fEventCounter++; 
   }  
@@ -239,11 +237,11 @@ Int_t AliHLTCalibrationProcessor::DoEvent( const AliHLTComponentEventData& evtDa
  */
 
 Int_t AliHLTCalibrationProcessor::ProcessCalibration( const AliHLTComponentEventData& evtData,
-                                            const AliHLTComponentBlockData* blocks
-                                            AliHLTComponentTriggerData& trigData,
-                                            AliHLTUInt8_t* outputPtr
-                                            AliHLTUInt32_t& size,
-                                            vector<AliHLTComponentBlockData>& outputBlocks ) {
+                                                     const AliHLTComponentBlockData* /*blocks*/
+                                                     AliHLTComponentTriggerData& trigData,
+                                                     AliHLTUInt8_t* /*outputPtr*/
+                                                     AliHLTUInt32_t& /*size*/,
+                                                     vector<AliHLTComponentBlockData>& /*outputBlocks*/ ) {
   // see header file for class documentation
 
   // we just forward to the high level method, all other parameters already
@@ -251,8 +249,8 @@ Int_t AliHLTCalibrationProcessor::ProcessCalibration( const AliHLTComponentEvent
   return ProcessCalibration( evtData, trigData );
 }
 
-Int_t AliHLTCalibrationProcessor::ProcessCalibration( const AliHLTComponentEventData& evtData
-                                              AliHLTComponentTriggerData& trigData) {
+Int_t AliHLTCalibrationProcessor::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/
+                                                     AliHLTComponentTriggerData& /*trigData*/) {
   // see header file for class documentation
 
   HLTFatal( "no processing method implemented" );
@@ -264,11 +262,11 @@ Int_t AliHLTCalibrationProcessor::ProcessCalibration( const AliHLTComponentEvent
  */
 
 Int_t AliHLTCalibrationProcessor::ShipDataToFXS( const AliHLTComponentEventData& evtData,
-                                            const AliHLTComponentBlockData* blocks
-                                            AliHLTComponentTriggerData& trigData,
-                                            AliHLTUInt8_t* outputPtr
-                                            AliHLTUInt32_t& size,
-                                            vector<AliHLTComponentBlockData>& outputBlocks ) {
+                                                const AliHLTComponentBlockData* /*blocks*/
+                                                AliHLTComponentTriggerData& trigData,
+                                                AliHLTUInt8_t* /*outputPtr*/
+                                                AliHLTUInt32_t& /*size*/,
+                                                vector<AliHLTComponentBlockData>& /*outputBlocks*/ ) {
   // see header file for class documentation
 
   // we just forward to the high level method, all other parameters already
@@ -277,7 +275,8 @@ Int_t AliHLTCalibrationProcessor::ShipDataToFXS( const AliHLTComponentEventData&
 }
 
 
-Int_t AliHLTCalibrationProcessor::ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData) {
+Int_t AliHLTCalibrationProcessor::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, 
+                                                AliHLTComponentTriggerData& /*trigData*/) {
   // see header file for class documentation
 
   HLTFatal( "no processing method implemented" );
@@ -288,78 +287,96 @@ Int_t AliHLTCalibrationProcessor::ShipDataToFXS( const AliHLTComponentEventData&
  * ######################## CreateFXSHeader #####################
  */
 
-Int_t AliHLTCalibrationProcessor::CreateFXSHeader( AliHLTFXSHeader &pHeader, const char* pDetector, const char* pFileID, const char* pDDLNumber ) {
+Int_t AliHLTCalibrationProcessor::CreateFXSHeader( AliHLTFXSHeader &pHeader, const char* pDetector, const char* pFileID, const AliHLTReadoutList* pDDLList ) {
   // see header file for class documentation
 
   Int_t iResult = 0;
 
-  AliHLTUInt32_t runNumber = GetRunNo();         //  debug : 2176;  
-
-  HLTDebug( "RunNumber = %d", runNumber );
-
-  /* STILL TO BE DONE .. but interface fixed   */
-
-  //  if ( pDDLNumber  != "" ) {
-  char ddltmp[5] = "4444";
-  strncpy ( fDDLNumber, ddltmp, gkAliHLTFXSHeaderfDDLNumberSize );
-  //}
-  //else {
-  //strncpy ( fDDLNumber, pDDLNumber, gkAliHLTFXSHeaderfDDLNumberSize );
-  //}
-  
-  fDDLNumber[gkAliHLTFXSHeaderfDDLNumberSize] = 0;
-  
-  // -- Fill Header
-
-  // Fill header version
+  // ** Fill header version
   pHeader.fHeaderVersion = AliHLTCalibrationProcessor::fgkFXSProtocolHeaderVersion;
 
-  // Fill run number
-  pHeader.fRunNumber = runNumber;
+  // ** Fill run number
+  pHeader.fRunNumber = GetRunNo(); 
   
-  // Fill origin
+  // ** Fill origin
   HLTDebug( "FXS Header Detector  size max %i - actual %i .",gkAliHLTFXSHeaderfOriginSize, strlen( pDetector ) );
   strncpy ( pHeader.fOrigin, pDetector, gkAliHLTFXSHeaderfOriginSize ) ; 
 
   // To take care if fileIDs which are longer than gkAliHLTFXSHeaderfOriginSize, write one 0 is cheaper than an if.
-  pHeader.fOrigin[gkAliHLTFXSHeaderfOriginSize] = 0;
+  pHeader.fOrigin[gkAliHLTFXSHeaderfOriginSize-1] = 0;
 
-  // Fill file ID
-  HLTInfo( "FXS Header FileID size max %i - actual %i .",gkAliHLTFXSHeaderfFileIDSize, strlen( pFileID ) );
+  // ** Fill file ID
+  HLTDebug( "FXS Header FileID size max %i - actual %i .",gkAliHLTFXSHeaderfFileIDSize, strlen( pFileID ) );
   strncpy ( pHeader.fFileID, pFileID, gkAliHLTFXSHeaderfFileIDSize ) ; 
 
   // To take care if fileIDs which are longer than gkAliHLTFXSHeaderfFileIDSize, write one 0 is cheaper than an if.
-  pHeader.fFileID[gkAliHLTFXSHeaderfFileIDSize] = 0;
-
-  // Fill DDL number
-  HLTInfo( "FXS Header DDLNumber size max %i - actual %i .", gkAliHLTFXSHeaderfDDLNumberSize, strlen( pDDLNumber ) );
-  strncpy ( pHeader.fDDLNumber, fDDLNumber, gkAliHLTFXSHeaderfDDLNumberSize) ; 
+  pHeader.fFileID[gkAliHLTFXSHeaderfFileIDSize-1] = 0;
 
-  // To take care if DDLNumber which are longer than gkAliHLTFXSHeaderfDDLNumberSize, write one 0 is cheaper than an if.
-  pHeader.fDDLNumber[gkAliHLTFXSHeaderfDDLNumberSize] = 0;
+  // ** Fill DDL number
 
+  // -- if component provides list, convert to fDDLNumber
+  if ( pDDLList ) {
+    // use user list
+    
+    AliHLTReadoutList::EDetectorId detid = pDDLList->GetFirstUsedDetector();
+    Int_t wordNdx = AliHLTReadoutList::GetFirstWord(detid);
+    Int_t wordCount = AliHLTReadoutList::GetWordCount(detid);
+    
+    if (pDDLList->GetFirstUsedDetector(detid) != AliHLTReadoutList::kNoDetector or wordNdx < 0)
+    {
+      HLTError("DDLIDs for minimum of TWO detectors ( %s, %s ) set, this function works only for ONE detector.",
+          AliHLTReadoutList::DetectorIdToString(detid),
+          AliHLTReadoutList::DetectorIdToString(pDDLList->GetFirstUsedDetector(detid))
+        );
+      iResult = -1;
+    }
+    else
+    {
+      // check word for word 
+      for ( Int_t ndx = 0; ndx < wordCount; ndx++ ) {
+       AliHLTUInt32_t word = pDDLList->Buffer()->fList[wordNdx+ndx];
+       
+       // set only 4 bit into one Char_t
+       for ( Int_t charNdx = 0; charNdx < 8; charNdx++) {
+         fDDLNumber[(8*ndx)+charNdx] = (Char_t) word & 0x0000000F;
+         word = word >> 4;
+       }
+      }
+    }
+  } //   if ( pDDLList ) {
+
+  // -- fill header with ascii chars
+  for (Int_t ndx = 0; ndx < gkAliHLTFXSHeaderfDDLNumberSize; ndx++ ){
+    Int_t numberToChar = (Int_t) fDDLNumber[ndx];
+    // Get ASCII
+    if ( numberToChar > 9 ) numberToChar += 55;
+    else numberToChar += 48;
+    
+    pHeader.fDDLNumber[ndx] = (Char_t) numberToChar;
+  }
+  
   return iResult;
-}  // Int_t AliHLTCalibrationProcessor::CreateFXSHeader( AliHLTXSHeader &pHeader, const char* pDetector, const char* pFileID, const char* pDDLNumber ) {
+}  // Int_t AliHLTCalibrationProcessor::CreateFXSHeader( AliHLTXSHeader &pHeader, const char* pDetector, const char* pFileID, const AliHLTReadoutList* pDDLList ) {
 
 /*
  * ######################## PushToFXS #####################
  */
 
-Int_t AliHLTCalibrationProcessor::PushToFXS(TObject* pObject, const char* pDetector, const char* pFileID, const char* pDDLNumber ) {
+Int_t AliHLTCalibrationProcessor::PushToFXS(TObject* pObject, const char* pDetector, const char* pFileID, const AliHLTReadoutList* pDDLList ) {
   // see header file for class documentation
 
   Int_t iResult = 0;
   
   AliHLTFXSHeader pHeader;
 
-  CreateFXSHeader( pHeader, pDetector, pFileID, pDDLNumber );
+  CreateFXSHeader( pHeader, pDetector, pFileID, pDDLList );
   
   if ( pObject ) {
     
     AliHLTMemoryFile* pMemFile = CreateMemoryFile( kAliHLTDataTypeFXSCalib, kAliHLTVoidDataSpec );
     if ( pMemFile ) {
       
-      iResult = pMemFile->WriteHeader( (const char*) &pHeader, AliHLTCalibrationProcessor::fgkFXSProtocolHeaderSize );
+      iResult = pMemFile->WriteHeaderBuffer( (const char*) &pHeader, AliHLTCalibrationProcessor::fgkFXSProtocolHeaderSize );
 
       if ( iResult ) {
        HLTError( "Buffer size to small - for header!" ); 
@@ -384,19 +401,20 @@ Int_t AliHLTCalibrationProcessor::PushToFXS(TObject* pObject, const char* pDetec
 
   return iResult;
 
-} // Int_t AliHLTCalibrationProcessor::PushToFXS(TObject* pObject, const char* detector, const char* pFileID, const char* pDDLNumber ) {
+} // Int_t AliHLTCalibrationProcessor::PushToFXS(TObject* pObject, const char* detector, const char* pFileID, const AliHLTReadoutList* pDDLList ) {
 
-Int_t AliHLTCalibrationProcessor::PushToFXS( void* pBuffer, int iSize, const char* pDetector, const char* pFileID, const char* pDDLNumber ) {
+Int_t AliHLTCalibrationProcessor::PushToFXS( void* pBuffer, int iSize, const char* pDetector, const char* pFileID, const AliHLTReadoutList* pDDLList ) {
+  // see header file for class documentation
 
   Int_t iResult = 0;
   
   AliHLTFXSHeader pHeader;
 
-  CreateFXSHeader( pHeader, pDetector, pFileID, pDDLNumber );
+  CreateFXSHeader( pHeader, pDetector, pFileID, pDDLList );
   
   iResult = PushBack( pBuffer, iSize, kAliHLTDataTypeFXSCalib, kAliHLTVoidDataSpec, (void*) (&pHeader), AliHLTCalibrationProcessor::fgkFXSProtocolHeaderSize );
 
   return iResult;
 
-} // Int_t AliHLTCalibrationProcessor::PushToFXS(void* pBuffer, int iSize, const char* pDdetector, const char* pFileID, const char* pDDLNumber = "") {
+} // Int_t AliHLTCalibrationProcessor::PushToFXS(void* pBuffer, int iSize, const char* pDdetector, const char* pFileID, const AliHLTReadoutList* pDDLList ) {