]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTComponent.cxx
Minor cleanup of code.
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponent.cxx
index d705bc263cb0ec6104ae9adabc1e68ae01364126..ea786d1246ba33bb169f6d0f35e6d1035ba1b69d 100644 (file)
@@ -135,6 +135,7 @@ int AliHLTComponent::UnsetGlobalComponentHandler()
 int AliHLTComponent::Init( AliHLTComponentEnvironment* environ, void* environParam, int argc, const char** argv )
 {
   // see header file for function documentation
+  HLTLogKeyword(GetComponentID());
   int iResult=0;
   if (environ) {
     memcpy(&fEnvironment, environ, sizeof(AliHLTComponentEnvironment));
@@ -191,6 +192,7 @@ int AliHLTComponent::Init( AliHLTComponentEnvironment* environ, void* environPar
 int AliHLTComponent::Deinit()
 {
   // see header file for function documentation
+  HLTLogKeyword(GetComponentID());
   int iResult=0;
   iResult=DoDeinit();
   if (fpRunDesc) {
@@ -207,7 +209,7 @@ int AliHLTComponent::InitCDB(const char* cdbPath, AliHLTComponentHandler* pHandl
 {
   // see header file for function documentation
   int iResult=0;
-  if (cdbPath, pHandler) {
+  if (cdbPath && pHandler) {
   // I have to think about separating the library handling from the
   // component handler. Requiring the component hanlder here is not
   // the cleanest solution.
@@ -248,18 +250,28 @@ int AliHLTComponent::SetCDBRunNo(int runNo)
 int AliHLTComponent::DoInit( int /*argc*/, const char** /*argv*/)
 {
   // default implementation, childs can overload
+  HLTLogKeyword("dummy");
   return 0;
 }
 
 int AliHLTComponent::DoDeinit()
 {
   // default implementation, childs can overload
+  HLTLogKeyword("dummy");
   return 0;
 }
 
 int AliHLTComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/)
 {
   // default implementation, childs can overload
+  HLTLogKeyword("dummy");
+  return 0;
+}
+
+int AliHLTComponent::ReadPreprocessorValues(const char* /*modules*/)
+{
+  // default implementation, childs can overload
+  HLTLogKeyword("dummy");
   return 0;
 }
 
@@ -427,25 +439,26 @@ int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, AliHLTCom
   return iResult;
 }
 
-void AliHLTComponent::PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format) const
+void AliHLTComponent::PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format)
 {
   // see header file for function documentation
-  const char* fmt="publisher \'%s\'";
+  const char* fmt="\'%s\'";
   if (format) fmt=format;
-  HLTMessage(fmt, (DataType2Text(dt)).c_str());
-  HLTMessage("%x %x %x %x %x %x %x %x : %x %x %x %x", 
-            dt.fID[0],
-            dt.fID[1],
-            dt.fID[2],
-            dt.fID[3],
-            dt.fID[4],
-            dt.fID[5],
-            dt.fID[6],
-            dt.fID[7],
-            dt.fOrigin[0],
-            dt.fOrigin[1],
-            dt.fOrigin[2],
-            dt.fOrigin[3]);
+  AliHLTLogging::Message(NULL, kHLTLogNone, NULL , NULL, Form(fmt, (DataType2Text(dt)).c_str()));
+  AliHLTLogging::Message(NULL, kHLTLogNone, NULL , NULL, 
+                        Form("%x %x %x %x %x %x %x %x : %x %x %x %x", 
+                             dt.fID[0],
+                             dt.fID[1],
+                             dt.fID[2],
+                             dt.fID[3],
+                             dt.fID[4],
+                             dt.fID[5],
+                             dt.fID[6],
+                             dt.fID[7],
+                             dt.fOrigin[0],
+                             dt.fOrigin[1],
+                             dt.fOrigin[2],
+                             dt.fOrigin[3]));
 }
 
 void AliHLTComponent::FillBlockData( AliHLTComponentBlockData& blockData )
@@ -495,6 +508,16 @@ void AliHLTComponent::SetDataType(AliHLTComponentDataType& tgtdt, const char* id
   }
 }
 
+void AliHLTComponent::SetDataType(AliHLTComponentDataType& dt, AliHLTUInt64_t id, AliHLTUInt32_t origin)
+{
+  // see header file for function documentation
+  dt.fStructSize=sizeof(AliHLTComponentDataType);
+  assert(kAliHLTComponentDataTypefIDsize==sizeof(id));
+  assert(kAliHLTComponentDataTypefOriginSize==sizeof(origin));
+  memcpy(&dt.fID, &id, kAliHLTComponentDataTypefIDsize);
+  memcpy(&dt.fOrigin, &origin, kAliHLTComponentDataTypefOriginSize);
+}
+
 void AliHLTComponent::FillEventData(AliHLTComponentEventData& evtData)
 {
   // see header file for function documentation
@@ -629,7 +652,7 @@ TObject* AliHLTComponent::CreateInputObject(int idx, int bForce)
          }
          //} else {
                } else if (bForce!=0) {
-         HLTError("size missmatch: block size %d, indicated %d", fpInputBlocks[idx].fSize, firstWord+sizeof(AliHLTUInt32_t));
+         HLTError("size mismatch: block size %d, indicated %d", fpInputBlocks[idx].fSize, firstWord+sizeof(AliHLTUInt32_t));
        }
       } else {
        HLTFatal("block descriptor empty");
@@ -794,7 +817,7 @@ const AliHLTComponentBlockData* AliHLTComponent::GetInputBlock(int index)
 {
   // see header file for function documentation
   ALIHLTCOMPONENT_BASE_STOPWATCH();
-  assert( 0 <= index and index < fCurrentEventData.fBlockCnt );
+  assert( 0 <= index and index < (int)fCurrentEventData.fBlockCnt );
   return &fpInputBlocks[index];
 }
 
@@ -1106,6 +1129,7 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData,
                                   AliHLTComponentEventDoneData*& edd )
 {
   // see header file for function documentation
+  HLTLogKeyword(GetComponentID());
   ALIHLTCOMPONENT_BASE_STOPWATCH();
   int iResult=0;
   fCurrentEvent=evtData.fEventID;
@@ -1118,11 +1142,14 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData,
   fOutputBufferFilled=0;
   fOutputBlocks.clear();
 
+  bool bSkipDataProcessing=false;
   // find special events
   if (fpInputBlocks) {
     // first look for all special events and execute in the appropriate
     // sequence afterwords
+    AliHLTUInt32_t eventType=gkAliEventTypeUnknown;
     int indexComConfEvent=-1;
+    int indexUpdtDCSEvent=-1;
     int indexSOREvent=-1;
     int indexEOREvent=-1;
     for (unsigned int i=0; i<evtData.fBlockCnt && iResult>=0; i++) {
@@ -1135,6 +1162,12 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData,
        // this event is most likely deprecated
       } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeComConf) {
        indexComConfEvent=i;
+      } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeUpdtDCS) {
+       indexUpdtDCSEvent=i;
+      } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEvent) {
+       eventType=fpInputBlocks[i].fSpecification;
+       bSkipDataProcessing|=(fpInputBlocks[i].fSpecification==gkAliEventTypeConfiguration);
+       bSkipDataProcessing|=(fpInputBlocks[i].fSpecification==gkAliEventTypeReadPreprocessor);
       }
     }
     if (indexSOREvent>=0) {
@@ -1159,7 +1192,7 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData,
          AliHLTRunDesc rundesc;
          if ((iResult=CopyStruct(&rundesc, sizeof(AliHLTRunDesc), indexEOREvent, "AliHLTRunDesc", "SOR"))>0) {
            if (fpRunDesc->fRunNo!=rundesc.fRunNo) {
-             HLTWarning("run no missmatch: SOR %d, EOR %d", fpRunDesc->fRunNo, rundesc.fRunNo);
+             HLTWarning("run no mismatch: SOR %d, EOR %d", fpRunDesc->fRunNo, rundesc.fRunNo);
            } else {
              HLTDebug("EOR run no %d", fpRunDesc->fRunNo);
            }
@@ -1172,9 +1205,9 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData,
        HLTWarning("did not receive SOR, ignoring EOR");
       }
     }
-    if (indexComConfEvent>=0) {
+    if (indexComConfEvent>=0 || eventType==gkAliEventTypeConfiguration) {
       TString cdbEntry;
-      if (fpInputBlocks[indexComConfEvent].fPtr!=NULL && fpInputBlocks[indexComConfEvent].fSize>0) {
+      if (indexComConfEvent>=0 && fpInputBlocks[indexComConfEvent].fPtr!=NULL && fpInputBlocks[indexComConfEvent].fSize>0) {
        cdbEntry.Append(reinterpret_cast<const char*>(fpInputBlocks[indexComConfEvent].fPtr), fpInputBlocks[indexComConfEvent].fSize);
       }
       HLTDebug("received component configuration command: entry %s", cdbEntry.IsNull()?"none":cdbEntry.Data());
@@ -1183,6 +1216,17 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData,
        HLTWarning("reconfiguration of component %p (%s) failed with error code %d", this, GetComponentID(), tmpResult);
       }
     }
+    if (indexUpdtDCSEvent>=0 || eventType==gkAliEventTypeReadPreprocessor) {
+      TString modules;
+      if (fpInputBlocks[indexUpdtDCSEvent].fPtr!=NULL && fpInputBlocks[indexUpdtDCSEvent].fSize>0) {
+       modules.Append(reinterpret_cast<const char*>(fpInputBlocks[indexUpdtDCSEvent].fPtr), fpInputBlocks[indexUpdtDCSEvent].fSize);
+      }
+      HLTDebug("received preprocessor update command: detectors %s", modules.IsNull()?"ALL":modules.Data());
+      int tmpResult=ReadPreprocessorValues(modules[0]==0?"ALL":modules.Data());
+      if (tmpResult<0) {
+       HLTWarning("preprocessor update of component %p (%s) failed with error code %d", this, GetComponentID(), tmpResult);
+      }
+    }
   }
   
   AliHLTComponentBlockDataList blockData;
@@ -1190,7 +1234,7 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData,
     ALIHLTCOMPONENT_DA_STOPWATCH();
     iResult=DoProcessing(evtData, blocks, trigData, outputPtr, size, blockData, edd);
   } // end of the scope of the stopwatch guard
-  if (iResult>=0) {
+  if (iResult>=0 && !bSkipDataProcessing) {
     if (fOutputBlocks.size()>0) {
       //HLTDebug("got %d block(s) via high level interface", fOutputBlocks.size());
       
@@ -1224,12 +1268,12 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData,
       HLTFatal("component %s (%p): can not convert output block descriptor list", GetComponentID(), this);
     }
   }
-  if (iResult<0) {
+  if (iResult<0 || bSkipDataProcessing) {
     outputBlockCnt=0;
     outputBlocks=NULL;
   }
   CleanupInputObjects();
-  if (iResult>=0) {
+  if (iResult>=0 && !bSkipDataProcessing) {
     IncrementEventCounter();
   }
   return iResult;
@@ -1370,11 +1414,11 @@ int AliHLTComponent::CopyStruct(void* pStruct, unsigned int iStructSize, unsigne
       if (fpInputBlocks[iBlockNo].fPtr && fpInputBlocks[iBlockNo].fSize) {
        AliHLTUInt32_t copy=*((AliHLTUInt32_t*)fpInputBlocks[iBlockNo].fPtr);
        if (fpInputBlocks[iBlockNo].fSize!=copy) {
-         HLTWarning("%s event: missmatch of block size (%d) and structure size (%d)", eventname, fpInputBlocks[iBlockNo].fSize, copy);
+         HLTWarning("%s event: mismatch of block size (%d) and structure size (%d)", eventname, fpInputBlocks[iBlockNo].fSize, copy);
          if (copy>fpInputBlocks[iBlockNo].fSize) copy=fpInputBlocks[iBlockNo].fSize;
        }
        if (copy!=iStructSize) {
-         HLTWarning("%s event: missmatch in %s version (data type version %d)", eventname, structname, ALIHLT_DATA_TYPES_VERSION);
+         HLTWarning("%s event: mismatch in %s version (data type version %d)", eventname, structname, ALIHLT_DATA_TYPES_VERSION);
          if (copy>iStructSize) {
            copy=iStructSize;
          } else {