#include "TClass.h"
#include "TStopwatch.h"
#include "AliHLTMemoryFile.h"
+#include "AliHLTMisc.h"
#include <cassert>
/** ROOT macro for the implementation of ROOT specific class methods */
fpStopwatches(new TObjArray(kSWTypeCount)),
fMemFiles(),
fpRunDesc(NULL),
- fpDDLList(NULL)
-
+ fpDDLList(NULL),
+ fCDBInitialized(false),
+ fChainId()
{
// see header file for class documentation
// or
fpRunDesc=NULL;
delete pRunDesc;
}
+ fEventCount=0;
return iResult;
}
-int AliHLTComponent::DoInit( int argc, const char** argv )
+int AliHLTComponent::InitCDB(const char* cdbPath)
{
- // see header file for function documentation
- if (argc==0 && argv==NULL) {
- // this is currently just to get rid of the warning "unused parameter"
+ int iResult=0;
+ // we presume the library already to be loaded
+ // find the symbol
+ AliHLTComponentHandler cHandler;
+ AliHLTMiscInitCDB_t pFunc=(AliHLTMiscInitCDB_t)cHandler.FindSymbol(ALIHLTMISC_LIBRARY, ALIHLTMISC_INIT_CDB);
+ if (pFunc) {
+ iResult=(*pFunc)(cdbPath);
+ fCDBInitialized=iResult>=0;
+ } else {
+ Message(NULL, kHLTLogError, "AliHLTComponent::InitCDB", "init CDB",
+ "can not find initialization function");
+ iResult=-ENOSYS;
}
- fEventCount=0;
+ return iResult;
+}
+
+int AliHLTComponent::SetCDBRunNo(int runNo)
+{
+ int iResult=0;
+ if (!fCDBInitialized) return iResult;
+ // we presume the library already to be loaded
+ // find the symbol
+ AliHLTComponentHandler cHandler;
+ AliHLTMiscSetCDBRunNo_t pFunc=(AliHLTMiscSetCDBRunNo_t)cHandler.FindSymbol(ALIHLTMISC_LIBRARY, ALIHLTMISC_SET_CDB_RUNNO);
+ if (pFunc) {
+ iResult=(*pFunc)(runNo);
+ } else {
+ Message(NULL, kHLTLogError, "AliHLTComponent::SetCDBRunNo", "init CDB",
+ "can not find initialization function");
+ iResult=-ENOSYS;
+ }
+ return iResult;
+}
+
+int AliHLTComponent::DoInit( int /*argc*/, const char** /*argv*/)
+{
+ // default implementation, childs can overload
return 0;
}
int AliHLTComponent::DoDeinit()
{
- // see header file for function documentation
- fEventCount=0;
+ // default implementation, childs can overload
+ return 0;
+}
+
+int AliHLTComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/)
+{
+ // default implementation, childs can overload
return 0;
}
// find special events
if (fpInputBlocks) {
+ // first look for all special events and execute in the appropriate
+ // sequence afterwords
+ int indexComConfEvent=-1;
+ int indexSOREvent=-1;
+ int indexEOREvent=-1;
for (unsigned int i=0; i<evtData.fBlockCnt && iResult>=0; i++) {
if (fpInputBlocks[i].fDataType==kAliHLTDataTypeSOR) {
- // start of run
- if (fpRunDesc==NULL) {
- fpRunDesc=new AliHLTRunDesc;
- if (fpRunDesc) {
- if ((iResult=CopyStruct(fpRunDesc, sizeof(AliHLTRunDesc), i, "AliHLTRunDesc", "SOR"))>0) {
- HLTDebug("set run decriptor, run no %d", fpRunDesc->fRunNo);
- }
- } else {
- iResult=-ENOMEM;
+ indexSOREvent=i;
+ } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEOR) {
+ indexEOREvent=i;
+ } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeDDL) {
+ // DDL list
+ // this event is most likely deprecated
+ } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeComConf) {
+ indexComConfEvent=i;
+ }
+ }
+ if (indexSOREvent>=0) {
+ // start of run
+ if (fpRunDesc==NULL) {
+ fpRunDesc=new AliHLTRunDesc;
+ if (fpRunDesc) {
+ if ((iResult=CopyStruct(fpRunDesc, sizeof(AliHLTRunDesc), indexSOREvent, "AliHLTRunDesc", "SOR"))>0) {
+ HLTDebug("set run decriptor, run no %d", fpRunDesc->fRunNo);
+ SetCDBRunNo(fpRunDesc->fRunNo);
}
} else {
- HLTWarning("already received SOR event run no %d, ignoring SOR", fpRunDesc->fRunNo);
+ iResult=-ENOMEM;
}
- } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEOR) {
- if (fpRunDesc!=NULL) {
- if (fpRunDesc) {
- AliHLTRunDesc rundesc;
- if ((iResult=CopyStruct(&rundesc, sizeof(AliHLTRunDesc), i, "AliHLTRunDesc", "SOR"))>0) {
- if (fpRunDesc->fRunNo!=rundesc.fRunNo) {
- HLTWarning("run no missmatch: SOR %d, EOR %d", fpRunDesc->fRunNo, rundesc.fRunNo);
- } else {
- HLTDebug("EOR run no %d", fpRunDesc->fRunNo);
- }
+ } else {
+ HLTWarning("already received SOR event run no %d, ignoring SOR", fpRunDesc->fRunNo);
+ }
+ }
+ if (indexEOREvent>=0) {
+ if (fpRunDesc!=NULL) {
+ if (fpRunDesc) {
+ 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);
+ } else {
+ HLTDebug("EOR run no %d", fpRunDesc->fRunNo);
}
- AliHLTRunDesc* pRunDesc=fpRunDesc;
- fpRunDesc=NULL;
- delete pRunDesc;
}
- } else {
- HLTWarning("did not receive SOR, ignoring EOR");
+ AliHLTRunDesc* pRunDesc=fpRunDesc;
+ fpRunDesc=NULL;
+ delete pRunDesc;
}
- // end of run
- } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeDDL) {
- // DDL list
+ } else {
+ HLTWarning("did not receive SOR, ignoring EOR");
+ }
+ }
+ if (indexComConfEvent>=0) {
+ TString cdbEntry;
+ if (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());
+ int tmpResult=Reconfigure(cdbEntry[0]==0?NULL:cdbEntry.Data(), fChainId.c_str());
+ if (tmpResult<0) {
+ HLTWarning("reconfiguration of component %p (%s) failed with error code %d", this, GetComponentID(), tmpResult);
}
}
}
AliHLTComponentBlockDataList& outputBlocks,
AliHLTComponentEventDoneData*& edd ) = 0;
+ /**
+ * Init the CDB.
+ * The function must not be called when running in AliRoot unless it it
+ * really wanted. The CDB path will be set to the specified path, which might
+ * override the path initialized at the beginning of the AliRoot reconstruction.
+ *
+ * The method is used from the external interface in order to set the correct
+ * path when running on-line.
+ */
+ int InitCDB(const char* cdbPath);
+
+ /**
+ * Set the run no for the CDB.
+ * The function must not be called when running in AliRoot unless it it
+ * really wanted. The CDB path will be set to the specified path, which might
+ * override the run no initialized at the beginning of the AliRoot reconstruction.
+ *
+ * The method is used from the external interface in order to set the correct
+ * path when running on-line.
+ */
+ int SetCDBRunNo(int runNo);
+
// Information member functions for registration.
/**
*/
virtual int DoDeinit();
+ /**
+ * Reconfigure the component.
+ * The method is called when an event of type @ref kAliHLTDataTypeComConf
+ * {COM_CONF:PRIV} is received by the component. If the event is sent as
+ * part of a normal event, the component configuration is called first.
+ *
+ * The CDB path parameter specifies the path in the CDB, i.e. without
+ * leading absolute path of the CDB location. The framework might alse
+ * provide the id of the component in the analysis chain.
+ *
+ * \b Note: The CDB will be initialized by the framework, either already set
+ * from AliRoot or from the wrapper interface during initialization.
+ *
+ * @param cdbEntry path of the cdbEntry
+ * @param chainId the id of the component in the analysis chain
+ * @note both parameters can be NULL, check before usage
+ */
+ virtual int Reconfigure(const char* cdbEntry, const char* chainId);
+
/**
* General memory allocation method.
* All memory which is going to be used 'outside' of the interface must
/** the current DDL list */
AliHLTEventDDL* fpDDLList; //! transient
- ClassDef(AliHLTComponent, 3)
+ /** indicates that the CDB has been initialized locally */
+ bool fCDBInitialized; //! transient
+
+ /** id of the component in the analysis chain */
+ string fChainId; //! transient
+
+ ClassDef(AliHLTComponent, 4)
};
#endif
--- /dev/null
+// @(#) $Id: AliHLTDynamicAliLog.cxx 23318 2008-01-14 12:43:28Z hristov $
+
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project *
+ * ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
+ * 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 AliHLTMisc.cxx
+ @author Matthias Richter
+ @date
+ @brief Miscellaneous methods for the HLT AliRoot integration
+*/
+
+#include "AliHLTMisc.h"
+#include "AliHLTLogging.h"
+#include "AliCDBManager.h"
+
+int AliHLTMiscInitCDB(const char* cdbpath)
+{
+ int iResult=0;
+ AliCDBManager* pCDB = AliCDBManager::Instance();
+ AliHLTLogging log;
+ if (!pCDB) {
+ log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance");
+ } else {
+ pCDB->SetRun(0); // This will be retrieved during the SOR event
+ pCDB->SetDefaultStorage(cdbpath);
+ log.Logging(kHLTLogDebug, "InitCDB", "CDB handling", "CDB instance 0x%x", pCDB);
+ }
+ return iResult;
+}
+
+int AliHLTMiscSetCDBRunNo(int runNo)
+{
+ int iResult=0;
+ AliCDBManager* pCDB = AliCDBManager::Instance();
+ AliHLTLogging log;
+ if (!pCDB) {
+ log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance");
+ } else {
+ pCDB->SetRun(runNo);
+ }
+ return iResult;
+}