//* provided "as is" without express or implied warranty. *
//**************************************************************************
-/** @file AliHLTComponent.cxx
- @author Matthias Richter, Timm Steinbeck
- @date
- @brief Base class implementation for HLT components. */
+// @file AliHLTComponent.cxx
+// @author Matthias Richter, Timm Steinbeck
+// @date
+// @brief Base class implementation for HLT components. */
+// @note The class is both used in Online (PubSub) and Offline (AliRoot)
+// context
-#if __GNUC__>= 3
-using namespace std;
-#endif
//#include "AliHLTStdIncludes.h"
#include "AliHLTComponent.h"
#include "AliHLTComponentHandler.h"
#include "AliHLTMessage.h"
#include "AliHLTCTPData.h"
+#include "AliHLTErrorGuard.h"
+#include "AliHLTCDHWrapper.h"
#include "TString.h"
#include "TMath.h"
#include "TObjArray.h"
#include "TClass.h"
#include "TStopwatch.h"
#include "TFormula.h"
+#include "TUUID.h"
+#include "TMD5.h"
+#include "TRandom3.h"
#include "AliHLTMemoryFile.h"
#include "AliHLTMisc.h"
#include <cassert>
fpStopwatches(new TObjArray(kSWTypeCount)),
fMemFiles(),
fpRunDesc(NULL),
- fpDDLList(NULL),
- fCDBSetRunNoFunc(false),
+ fCDBSetRunNoFunc(NULL),
fChainId(),
fChainIdCrc(0),
fpBenchmark(NULL),
- fRequireSteeringBlocks(false),
+ fFlags(0),
fEventType(gkAliEventTypeUnknown),
fComponentArgs(),
fEventDoneData(NULL),
fCompressionLevel(ALIHLTCOMPONENT_DEFAULT_OBJECT_COMPRESSION)
, fLastObjectSize(0)
, fpCTPData(NULL)
+ , fPushbackPeriod(0)
+ , fLastPushBackTime(-1),
+ fEventModulo(-1)
{
// see header file for class documentation
// or
if (comenv) {
SetComponentEnvironment(comenv, environParam);
}
+ fPushbackPeriod=0;
+ fLastPushBackTime=-1;
+
fComponentArgs="";
const char** pArguments=NULL;
int iNofChildArgs=0;
} else {
HLTError("wrong parameter for argument -object-compression, number expected");
}
+ // -pushback-period=
+ } else if (argument.BeginsWith("-pushback-period=")) {
+ argument.ReplaceAll("-pushback-period=", "");
+ if (argument.IsDigit()) {
+ fPushbackPeriod=argument.Atoi();
+ } else {
+ HLTError("wrong parameter for argument -pushback-period, number expected");
+ }
+ // -event-modulo
+ } else if (argument.BeginsWith("-event-modulo=")) {
+ argument.ReplaceAll("-event-modulo=", "");
+ if (argument.IsDigit()) {
+ fEventModulo=argument.Atoi();
+ if (fEventModulo < 1)
+ {
+ fEventModulo = -1;
+ HLTError("number passed in -event-modulo must be a positive integer greater or equal to 1.");
+ }
+ } else {
+ HLTError("wrong parameter for argument -event-modulo, integer number expected");
+ }
+ // -disable-component-stat
+ } else if (argument.CompareTo("-disable-component-stat")==0) {
+ fFlags|=kDisableComponentStat;
} else {
pArguments[iNofChildArgs++]=argv[i];
}
HLTError("missing parameter for argument %s", argument.Data());
iResult=-EINVAL;
}
+ if (iResult>=0) {
+ iResult=CheckOCDBEntries();
+ }
if (iResult>=0) {
iResult=DoInit(iNofChildArgs, pArguments);
}
// explicitly
AliHLTComponentDataTypeList inputDt;
GetInputDataTypes(inputDt);
+ bool bRequireSteeringBlocks=false;
for (AliHLTComponentDataTypeList::iterator dt=inputDt.begin();
- dt!=inputDt.end() && !fRequireSteeringBlocks;
+ dt!=inputDt.end() && !bRequireSteeringBlocks;
dt++) {
- fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeSOR);
- fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeRunType);
- fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeEOR);
- fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeDDL);
- fRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeComponentStatistics);
+ bRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeSOR);
+ bRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeRunType);
+ bRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeEOR);
+ bRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeDDL);
+ bRequireSteeringBlocks|=MatchExactly(*dt,kAliHLTDataTypeComponentStatistics);
}
+ if (bRequireSteeringBlocks) fFlags|=kRequireSteeringBlocks;
}
if (pArguments) delete [] pArguments;
-#if defined(__DEBUG) || defined(HLT_COMPONENT_STATISTICS)
+#if defined(HLT_COMPONENT_STATISTICS)
// benchmarking stopwatch for the component statistics
fpBenchmark=new TStopwatch;
-#endif
+#endif // HLT_COMPONENT_STATISTICS
return iResult;
}
fpCTPData=NULL;
fEventCount=0;
+ fFlags=0;
return iResult;
}
TString descriptor=desc;
TObjArray* pTokens=descriptor.Tokenize(" ");
if (pTokens) {
- for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
- TString argument=((TObjString*)pTokens->At(i++))->GetString();
+ for (int i=0; i<pTokens->GetEntriesFast() && iResult>=0; i++) {
+ TString argument=pTokens->At(i++)->GetName();
if (!argument || argument.IsNull()) continue;
// chainid
HLTWarning("unknown component description %s", argument.Data());
}
}
+ delete pTokens;
}
return iResult;
int AliHLTComponent::ConfigureFromArgumentString(int argc, const char** argv)
{
- // see header file for function documentation
+ // Configure from an array of argument strings
+ // Function supports individual arguments in the argv array and arguments
+ // separated by blanks.
+ //
+ // Each argv entry can contain blanks, quotes and newlines. Newlines are interpreted
+ // as blanks. Enclosing quotes deactivate blank as delimiter.
+ // The separated arguments are stored in an array of strings, and the pointers to
+ // those strings in an array of pointers. The latter is used in the custom argument
+ // scan of the component.
+
int iResult=0;
- vector<const char*> array;
- TObjArray choppedArguments;
+ vector<string> stringarray; // array of argument copies
+ // array of pointers to the argument copies
+ // note: not necessarily in sync with the entries in stringarray
+ // can contain any pointer to valid arguments in arbitrary sequence
+ vector<const char*> ptrarray;
+
TString argument="";
int i=0;
for (i=0; i<argc && iResult>=0; i++) {
argument=argv[i];
+ if (argument.IsWhitespace()) continue;
+
+ // special handling for single component arguments ending with
+ // a sequence of blanks. All characters until the first occurence
+ // of a blank are removed. If the remainder contains only whitespaces
+ // the argument is a single argument, just having whitespaces at the end.
+ argument.Remove(0, argument.First(' '));
+ if (argument.IsWhitespace()) {
+ stringarray.push_back(argv[i]);
+ continue;
+ }
+
+ // outer loop checks for enclosing quotes
+ // extra blank to insert blank token before leading quotes, then
+ // quoted arguments are always the even ones
+ argument=" ";
+ argument+=argv[i];
+ // insert blank in consecutive quotes to correctly tokenize
+ argument.ReplaceAll("''", "' '");
+ // replace newlines by blanks
+ argument.ReplaceAll("\n", " ");
if (argument.IsNull()) continue;
+ TObjArray* pTokensQuote=argument.Tokenize("'");
+ if (pTokensQuote) {
+ if (pTokensQuote->GetEntriesFast()>0) {
+ for (int k=0; k<pTokensQuote->GetEntriesFast(); k++) {
+ argument=pTokensQuote->At(k)->GetName();
+ if (argument.IsWhitespace()) continue;
+ if (k%2) {
+ // every second entry is enclosed by quotes and thus
+ // one single argument
+ stringarray.push_back(argument.Data());
+ } else {
TObjArray* pTokens=argument.Tokenize(" ");
if (pTokens) {
if (pTokens->GetEntriesFast()>0) {
for (int n=0; n<pTokens->GetEntriesFast(); n++) {
- choppedArguments.AddLast(pTokens->At(n));
- TString data=((TObjString*)pTokens->At(n))->GetString();
- if (!data.IsNull()) {
- array.push_back(data.Data());
+ TString data=pTokens->At(n)->GetName();
+ if (!data.IsNull() && !data.IsWhitespace()) {
+ stringarray.push_back(data.Data());
}
}
- pTokens->SetOwner(kFALSE);
}
delete pTokens;
}
+ }
+ }
+ }
+ delete pTokensQuote;
+ }
+ }
+
+ // fill ptrarray; should be safe at this point
+ // since stringarray isn't modified any further
+ unsigned int idx;
+ for(idx=0; idx<stringarray.size(); ++idx) {
+ ptrarray.push_back(stringarray.at(idx).c_str());
}
- for (i=0; (unsigned)i<array.size() && iResult>=0;) {
- int result=ScanConfigurationArgument(array.size()-i, &array[i]);
+ for (i=0; (unsigned)i<ptrarray.size() && iResult>=0;) {
+ int result=ScanConfigurationArgument(ptrarray.size()-i, &ptrarray[i]);
if (result==0) {
- HLTWarning("unknown component argument %s", array[i]);
+ HLTWarning("unknown component argument %s", ptrarray[i]);
i++;
} else if (result>0) {
i+=result;
} else {
iResult=result;
if (iResult==-EINVAL) {
- HLTError("unknown argument %s", array[i]);
+ HLTError("unknown argument %s", ptrarray[i]);
} else if (iResult==-EPROTO) {
- HLTError("missing/wrong parameter for argument %s (%s)", array[i], (array.size()>(unsigned)i+1)?array[i+1]:"missing");
+ HLTError("missing/wrong parameter for argument %s (%s)", ptrarray[i], (ptrarray.size()>(unsigned)i+1)?ptrarray[i+1]:"missing");
} else {
- HLTError("scan of argument %s failed (%d)", array[i], iResult);
+ HLTError("scan of argument %s failed (%d)", ptrarray[i], iResult);
}
}
}
return iResult;
}
-int AliHLTComponent::ConfigureFromCDBTObjString(const char* entries)
+int AliHLTComponent::ConfigureFromCDBTObjString(const char* entries, const char* key)
{
- // see header file for function documentation
+ // load a list of OCDB objects and configure from the objects
+ // can either be a TObjString or a TMap with a TObjString:TObjString key-value pair
int iResult=0;
TString arguments;
TString confEntries=entries;
TObjArray* pTokens=confEntries.Tokenize(" ");
if (pTokens) {
for (int n=0; n<pTokens->GetEntriesFast(); n++) {
- const char* path=((TObjString*)pTokens->At(n))->GetString().Data();
+ const char* path=pTokens->At(n)->GetName();
const char* chainId=GetChainId();
- HLTInfo("configure from entry %s, chain id %s", path, (chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
- TObject* pOCDBObject = LoadAndExtractOCDBObject(path);
+ HLTInfo("configure from entry \"%s\"%s%s, chain id %s", path, key?" key ":"",key?key:"", (chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
+ TObject* pOCDBObject = LoadAndExtractOCDBObject(path, key);
if (pOCDBObject) {
TObjString* pString=dynamic_cast<TObjString*>(pOCDBObject);
+ if (!pString) {
+ TMap* pMap=dynamic_cast<TMap*>(pOCDBObject);
+ if (pMap) {
+ // this is the case where no key has been specified and the OCDB
+ // object is a TMap, search for the default key
+ TObject* pObject=pMap->GetValue("default");
+ if (pObject && (pString=dynamic_cast<TObjString*>(pObject))!=NULL) {
+ HLTInfo("using default key of TMap of configuration object \"%s\"", path);
+ } else {
+ HLTError("no default key available in TMap of configuration object \"%s\"", path);
+ iResult=-ENOENT;
+ break;
+ }
+ }
+ }
+
if (pString) {
- HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
- arguments+=pString->GetString().Data();
+ HLTInfo("received configuration object string: \'%s\'", pString->GetName());
+ arguments+=pString->GetName();
arguments+=" ";
} else {
- HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
+ HLTError("configuration object \"%s\"%s%s has wrong type, required TObjString", path, key?" key ":"",key?key:"");
iResult=-EINVAL;
}
} else {
return iResult;
}
-TObject* AliHLTComponent::LoadAndExtractOCDBObject(const char* path, int version, int subVersion)
+TObject* AliHLTComponent::LoadAndExtractOCDBObject(const char* path, const char* key) const
{
// see header file for function documentation
- AliCDBEntry* pEntry=AliHLTMisc::Instance().LoadOCDBEntry(path, GetRunNo(), version, subVersion);
+ AliCDBEntry* pEntry=AliHLTMisc::Instance().LoadOCDBEntry(path, GetRunNo());
if (!pEntry) return NULL;
- return AliHLTMisc::Instance().ExtractObject(pEntry);
+ TObject* pObject=AliHLTMisc::Instance().ExtractObject(pEntry);
+ TMap* pMap=dynamic_cast<TMap*>(pObject);
+ if (pMap && key) {
+ pObject=pMap->GetValue(key);
+ if (!pObject) {
+ pObject=pMap->GetValue("default");
+ if (pObject) {
+ HLTWarning("can not find object for key \"%s\" in TMap of configuration object \"%s\", using key \"default\"", key, path);
+ }
+ }
+ if (!pObject) {
+ HLTError("can not find object for key \"%s\" in TMap of configuration object \"%s\"", key, path);
+ return NULL;
+ }
+ }
+ return pObject;
}
int AliHLTComponent::DoInit( int /*argc*/, const char** /*argv*/)
return 0;
}
+void AliHLTComponent::GetOCDBObjectDescription( TMap* const /*targetArray*/)
+{
+ // default implementation, childs can overload
+ HLTLogKeyword("dummy");
+}
+
+int AliHLTComponent::CheckOCDBEntries(const TMap* const externList)
+{
+ // check the availability of the OCDB entry descriptions in the TMap
+ // key : complete OCDB path of the entry
+ // value : auxiliary object - short description
+ // if the external map was not provided the function invokes
+ // interface function GetOCDBObjectDescription() to retrieve the list.
+ int iResult=0;
+ if (externList) {
+ iResult=AliHLTMisc::Instance().CheckOCDBEntries(externList);
+ } else {
+ TMap* pMap=new TMap;
+ if (pMap) {
+ pMap->SetOwnerKeyValue(kTRUE);
+ GetOCDBObjectDescription(pMap);
+ iResult=AliHLTMisc::Instance().CheckOCDBEntries(pMap);
+ delete pMap;
+ pMap=NULL;
+ }
+ }
+
+ return iResult;
+}
+
void AliHLTComponent::DataType2Text( const AliHLTComponentDataType& type, char output[kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2] ) const
{
// see header file for function documentation
memset( output, 0, kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2 );
strncat( output, type.fOrigin, kAliHLTComponentDataTypefOriginSize );
- strcat( output, ":" );
+ strncat( output, ":", 1 );
strncat( output, type.fID, kAliHLTComponentDataTypefIDsize );
}
// see header file for function documentation
string out("");
+ // 'typeid' 'origin'
+ // aligned to 8 and 4 chars respectively, blocks enclosed in quotes and
+ // separated by blank e.g.
+ // 'DDL_RAW ' 'TPC '
+ if (mode==3) {
+ int i=0;
+ char tmp[8];
+ out+="'";
+ for (i=0; i<kAliHLTComponentDataTypefIDsize; i++) {
+ unsigned char* puc=(unsigned char*)type.fID;
+ if (puc[i]<32)
+ sprintf(tmp, "\\%x", type.fID[i]);
+ else
+ sprintf(tmp, "%c", type.fID[i]);
+ out+=tmp;
+ }
+ out+="' '";
+ for (i=0; i<kAliHLTComponentDataTypefOriginSize; i++) {
+ unsigned char* puc=(unsigned char*)type.fOrigin;
+ if ((puc[i])<32)
+ sprintf(tmp, "\\%x", type.fOrigin[i]);
+ else
+ sprintf(tmp, "%c", type.fOrigin[i]);
+ out+=tmp;
+ }
+ out+="'";
+ return out;
+ }
+
+ // origin typeid as numbers separated by colon e.g.
+ // aligned to 8 and 4 chars respectively, all characters separated by
+ // quotes, e.g.
+ // '84'80'67'32':'68'68'76'95'82'65'87'32'
if (mode==2) {
int i=0;
char tmp[8];
return out;
}
+ // origin typeid separated by colon e.g.
+ // aligned to 8 and 4 chars respectively, all characters separated by
+ // quotes, e.g.
+ // 'T'P'C' ':'D'D'L'_'R'A'W' '
if (mode==1) {
int i=0;
char tmp[8];
return out;
}
+ // origin typeid
+ // aligned to 8 and 4 chars respectively, separated by colon e.g.
+ // TPC :DDL_RAW
if (type==kAliHLTVoidDataType) {
out="VOID:VOID";
} else {
}
-int AliHLTComponent::GetEventDoneData( unsigned long size, AliHLTComponentEventDoneData** edd )
+int AliHLTComponent::GetEventDoneData( unsigned long size, AliHLTComponentEventDoneData** edd ) const
{
// see header file for function documentation
if (fEnvironment.fGetEventDoneDataFunc)
int AliHLTComponent::PushEventDoneData( AliHLTUInt32_t eddDataWord )
{
+ // see header file for function documentation
if (!fEventDoneData)
return -ENOMEM;
if (fEventDoneData->fDataSize+sizeof(AliHLTUInt32_t)>fEventDoneDataSize)
void AliHLTComponent::ReleaseEventDoneData()
{
- if (fEventDoneData)
+ // see header file for function documentation
+ if (fEventDoneData)
delete [] reinterpret_cast<AliHLTUInt8_t*>( fEventDoneData );
fEventDoneData = NULL;
fEventDoneDataSize = 0;
HLTWarning("component %s indicates multiple output data types but GetOutputDataTypes returns %d", GetComponentID(), count);
}
}
- ((AliHLTComponent*)pConsumer)->GetInputDataTypes(itypes);
+ pConsumer->GetInputDataTypes(itypes);
AliHLTComponentDataTypeList::iterator otype=otypes.begin();
for (;otype!=otypes.end();otype++) {
//PrintDataTypeContent((*otype), "publisher \'%s\'");
memset(&evtData, 0, sizeof(AliHLTComponentEventData));
evtData.fStructSize=sizeof(AliHLTComponentEventData);
evtData.fEventID=kAliHLTVoidEventID;
+ evtData.fEventCreation_s = kMaxUInt;
}
void AliHLTComponent::PrintComponentDataTypeInfo(const AliHLTComponentDataType& dt)
int iResult=0;
int idx=fCurrentInputBlock;
if (pBlock) {
- if (fpInputObjects==NULL || (idx=FindInputBlock(pBlock))>=0) {
+ if ((idx=FindInputBlock(pBlock))>=0) {
} else {
HLTError("unknown Block %p", pBlock);
iResult=-ENOENT;
return iSpec;
}
-int AliHLTComponent::PushBack(TObject* pObject, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec,
+int AliHLTComponent::PushBack(const TObject* pObject, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec,
void* pHeader, int headerSize)
{
// see header file for function documentation
ALIHLTCOMPONENT_BASE_STOPWATCH();
int iResult=0;
fLastObjectSize=0;
+ if (fPushbackPeriod>0) {
+ // suppress the output
+ TDatime time;
+ if (fLastPushBackTime<0 || (int)time.Get()-fLastPushBackTime<fPushbackPeriod) return 0;
+ }
if (pObject) {
AliHLTMessage msg(kMESS_OBJECT);
msg.SetCompressionLevel(fCompressionLevel);
return iResult;
}
-int AliHLTComponent::PushBack(TObject* pObject, const char* dtID, const char* dtOrigin, AliHLTUInt32_t spec,
+int AliHLTComponent::PushBack(const TObject* pObject, const char* dtID, const char* dtOrigin, AliHLTUInt32_t spec,
void* pHeader, int headerSize)
{
// see header file for function documentation
{
// see header file for function documentation
ALIHLTCOMPONENT_BASE_STOPWATCH();
+ if (fPushbackPeriod>0) {
+ // suppress the output
+ TDatime time;
+ if (fLastPushBackTime<0 || (int)time.Get()-fLastPushBackTime<fPushbackPeriod) return 0;
+ }
+
return InsertOutputBlock(pBuffer, iSize, dt, spec, pHeader, headerSize);
}
return iResult;
}
-int AliHLTComponent::EstimateObjectSize(TObject* pObject) const
+int AliHLTComponent::EstimateObjectSize(const TObject* pObject) const
{
// see header file for function documentation
- if (!pObject) return -EINVAL;
- AliHLTMessage msg(kMESS_OBJECT);
- msg.WriteObject(pObject);
- return msg.Length();
+ if (!pObject) return 0;
+
+ AliHLTMessage msg(kMESS_OBJECT);
+ msg.WriteObject(pObject);
+ return msg.Length();
}
AliHLTMemoryFile* AliHLTComponent::CreateMemoryFile(int capacity, const char* dtID,
fEventDoneData = newEDD;
fEventDoneDataSize = newSize;
}
- else {
+ else if (fEventDoneData) {
memcpy( reinterpret_cast<AliHLTUInt8_t*>(fEventDoneData->fData)+fEventDoneData->fDataSize, edd.fData, edd.fDataSize );
fEventDoneData->fDataSize += edd.fDataSize;
}
+ else {
+ HLTError("internal mismatch, fEventDoneData=%d but buffer is NULL", fEventDoneDataSize);
+ iResult=-EFAULT;
+ }
return iResult;
}
+namespace
+{
+ // helper function for std:sort, implements an operator<
+ bool SortComponentStatisticsById(const AliHLTComponentStatistics& a, const AliHLTComponentStatistics& b)
+ {
+ return a.fId<b.fId;
+ }
+
+ // helper function for std:sort
+ bool SortComponentStatisticsDescendingByLevel(const AliHLTComponentStatistics& a, const AliHLTComponentStatistics& b)
+ {
+ return a.fId>b.fId;
+ }
+
+ // helper class to define operator== between AliHLTComponentStatistics and AliHLTComponentStatistics.fId
+ class AliHLTComponentStatisticsId {
+ public:
+ AliHLTComponentStatisticsId(AliHLTUInt32_t id) : fId(id) {}
+ AliHLTComponentStatisticsId(const AliHLTComponentStatisticsId& src) : fId(src.fId) {}
+ AliHLTComponentStatisticsId& operator=(const AliHLTComponentStatisticsId& src) {
+ if (this==&src) return *this;
+ fId=src.fId; return *this;
+ }
+ bool operator==(const AliHLTComponentStatistics& a) const {return a.fId==fId;}
+ private:
+ AliHLTComponentStatisticsId();
+ AliHLTUInt32_t fId;
+ };
+
+ // operator for std::find of AliHLTComponentStatistics by id
+ bool operator==(const AliHLTComponentStatistics& a, const AliHLTComponentStatisticsId& b)
+ {
+ return b==a;
+ }
+
+ bool AliHLTComponentStatisticsCompareIds(const AliHLTComponentStatistics& a, const AliHLTComponentStatistics& b)
+ {
+ return a.fId==b.fId;
+ }
+
+ // helper class to define operator== between AliHLTComponentBlockData and AliHLTComponentBlockData.fSpecification
+ class AliHLTComponentBlockDataSpecification {
+ public:
+ AliHLTComponentBlockDataSpecification(AliHLTUInt32_t specification) : fSpecification(specification) {}
+ AliHLTComponentBlockDataSpecification(const AliHLTComponentBlockDataSpecification& src) : fSpecification(src.fSpecification) {}
+ AliHLTComponentBlockDataSpecification& operator=(const AliHLTComponentBlockDataSpecification& src) {
+ if (this==&src) return *this;
+ fSpecification=src.fSpecification; return *this;
+ }
+ bool operator==(const AliHLTComponentBlockData& bd) const {return bd.fSpecification==fSpecification;}
+ private:
+ AliHLTComponentBlockDataSpecification();
+ AliHLTUInt32_t fSpecification;
+ };
+
+ // operator for std::find of AliHLTComponentBlockData by specification
+ bool operator==(const AliHLTComponentBlockData& bd, const AliHLTComponentBlockDataSpecification& spec)
+ {
+ return spec==bd;
+ }
+
+ // operator for std::find
+ bool operator==(const AliHLTComponentBlockData& a, const AliHLTComponentBlockData& b)
+ {
+ if (!MatchExactly(a.fDataType,b.fDataType)) return false;
+ return a.fSpecification==b.fSpecification;
+ }
+
+} // end of namespace
+
int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData,
const AliHLTComponentBlockData* blocks,
AliHLTComponentTriggerData& trigData,
AliHLTComponentStatisticsList compStats;
bool bAddComponentTableEntry=false;
vector<AliHLTUInt32_t> parentComponentTables;
-#if defined(__DEBUG) || defined(HLT_COMPONENT_STATISTICS)
- AliHLTComponentStatistics outputStat;
- memset(&outputStat, 0, sizeof(AliHLTComponentStatistics));
- outputStat.fStructSize=sizeof(AliHLTComponentStatistics);
- outputStat.fId=fChainIdCrc;
- if (fpBenchmark) {
- fpBenchmark->Stop();
- outputStat.fComponentCycleTime=(AliHLTUInt32_t)(fpBenchmark->RealTime()*ALIHLTCOMPONENT_STATTIME_SCALER);
- fpBenchmark->Reset();
- fpBenchmark->Start();
+ int processingLevel=-1;
+#if defined(HLT_COMPONENT_STATISTICS)
+ if ((fFlags&kDisableComponentStat)==0) {
+ AliHLTComponentStatistics outputStat;
+ memset(&outputStat, 0, sizeof(AliHLTComponentStatistics));
+ outputStat.fStructSize=sizeof(AliHLTComponentStatistics);
+ outputStat.fId=fChainIdCrc;
+ if (fpBenchmark) {
+ fpBenchmark->Stop();
+ outputStat.fComponentCycleTime=(AliHLTUInt32_t)(fpBenchmark->RealTime()*ALIHLTCOMPONENT_STATTIME_SCALER);
+ fpBenchmark->Reset();
+ fpBenchmark->Start();
+ }
+ compStats.push_back(outputStat);
}
- compStats.push_back(outputStat);
-#endif
+#endif // HLT_COMPONENT_STATISTICS
// data processing is skipped
// - if there are only steering events in the block list.
indexUpdtDCSEvent=i;
} else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEvent) {
fEventType=fpInputBlocks[i].fSpecification;
+ if (fEventType != gkAliEventTypeConfiguration and
+ fEventType != gkAliEventTypeReadPreprocessor
+ )
+ {
+ // We can actually get the event type from the CDH if it is valid.
+ // Otherwise just use the specification of the input block.
+ AliHLTCDHWrapper cdh;
+ if (ExtractTriggerData(trigData, NULL, NULL, &cdh, NULL) == 0)
+ {
+ fEventType = ExtractEventTypeFromCDH(&cdh);
+ }
+ }
// skip always in case of gkAliEventTypeConfiguration
if (fpInputBlocks[i].fSpecification==gkAliEventTypeConfiguration) bSkipDataProcessing|=skipModeForce;
if (pStat && compStats[0].fLevel<=pStat->fLevel) {
compStats[0].fLevel=pStat->fLevel+1;
}
- compStats.push_back(*pStat);
+ if (find(compStats.begin(), compStats.end(), AliHLTComponentStatisticsId(pStat->fId))==compStats.end()) {
+ compStats.push_back(*pStat);
+ }
}
}
} else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeComponentTable) {
- forwardedBlocks.push_back(fpInputBlocks[i]);
+ AliHLTComponentBlockDataList::iterator element=forwardedBlocks.begin();
+ while ((element=find(element, forwardedBlocks.end(), AliHLTComponentBlockDataSpecification(fpInputBlocks[i].fSpecification)))!=forwardedBlocks.end()) {
+ if (element->fDataType==fpInputBlocks[i].fDataType) break;
+ // TODO: think about some more checks inclusing also the actual data buffers
+ // this has to handle multiplicity>1 in the online system, where all components
+ // send the information on SOR, because this event is broadcasted
+ }
+ if (element==forwardedBlocks.end()) {
+ forwardedBlocks.push_back(fpInputBlocks[i]);
+ }
parentComponentTables.push_back(fpInputBlocks[i].fSpecification);
+ if (fpInputBlocks[i].fSize>=sizeof(AliHLTComponentTableEntry)) {
+ const AliHLTComponentTableEntry* entry=reinterpret_cast<AliHLTComponentTableEntry*>(fpInputBlocks[i].fPtr);
+ if (entry->fStructSize==sizeof(AliHLTComponentTableEntry)) {
+ if (processingLevel<0 || processingLevel<=(int)entry->fLevel)
+ processingLevel=entry->fLevel+1;
+ }
+ }
} else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeECSParam) {
indexECSParamBlock=i;
} else {
if (indexSOREvent>=0) {
// start of run
bAddComponentTableEntry=true;
+ compStats.clear(); // no component statistics for SOR
if (fpRunDesc==NULL) {
fpRunDesc=new AliHLTRunDesc;
if (fpRunDesc) *fpRunDesc=kAliHLTVoidRunDesc;
}
}
if (indexEOREvent>=0) {
+ fLastPushBackTime=0; // always send at EOR
bAddComponentTableEntry=true;
+ compStats.clear(); // no component statistics for EOR
if (fpRunDesc!=NULL) {
if (fpRunDesc) {
AliHLTRunDesc rundesc;
HLTWarning("did not receive SOR, ignoring EOR");
}
}
- if (indexComConfEvent>=0 || fEventType==gkAliEventTypeConfiguration) {
+ if (fEventType==gkAliEventTypeConfiguration) {
+ if (indexComConfEvent>=0) {
TString cdbEntry;
if (indexComConfEvent>=0 && fpInputBlocks[indexComConfEvent].fPtr!=NULL && fpInputBlocks[indexComConfEvent].fSize>0) {
cdbEntry.Append(reinterpret_cast<const char*>(fpInputBlocks[indexComConfEvent].fPtr), fpInputBlocks[indexComConfEvent].fSize);
if (tmpResult<0) {
HLTWarning("reconfiguration of component %p (%s) failed with error code %d", this, GetComponentID(), tmpResult);
}
+ } else {
+ ALIHLTERRORGUARD(1, "incomplete Configure event, missing parameter data block");
+ }
}
- if (indexUpdtDCSEvent>=0 || fEventType==gkAliEventTypeReadPreprocessor) {
+ if (fEventType==gkAliEventTypeReadPreprocessor) {
+ if (indexUpdtDCSEvent>=0) {
TString modules;
if (fpInputBlocks[indexUpdtDCSEvent].fPtr!=NULL && fpInputBlocks[indexUpdtDCSEvent].fSize>0) {
modules.Append(reinterpret_cast<const char*>(fpInputBlocks[indexUpdtDCSEvent].fPtr), fpInputBlocks[indexUpdtDCSEvent].fSize);
if (tmpResult<0) {
HLTWarning("preprocessor update of component %p (%s) failed with error code %d", this, GetComponentID(), tmpResult);
}
+ } else {
+ ALIHLTERRORGUARD(1, "incomplete ReadPreprocessor event, missing parameter data block");
+ }
}
} else {
// processing function needs to be called if there are no input data
// data processing is not skipped if the component explicitly asks
// for the private blocks
- if (fRequireSteeringBlocks) bSkipDataProcessing=0;
+ if ((fFlags&kRequireSteeringBlocks)!=0) bSkipDataProcessing=0;
+
+ // data processing is not skipped for data sources
+ if (GetComponentType()==AliHLTComponent::kSource) bSkipDataProcessing=0;
if (fpCTPData) {
// set the active triggers for this event
// increment CTP trigger counters if available
if (IsDataEvent()) fpCTPData->Increment(trigData);
}
+
+ // Check if the event processing should be skipped because of the
+ // down scaling from the event modulo argument. Using a prime number
+ // as pre divisor to pseudo-randomise the event number to get a more
+ // uniform distribution.
+ if (fEventModulo > 1)
+ {
+ bSkipDataProcessing |= ( ((AliHLTUInt64_t(fCurrentEvent) / AliHLTUInt64_t(4789)) % AliHLTUInt64_t(fEventModulo)) != 0 );
+ }
AliHLTComponentBlockDataList blockData;
if (iResult>=0 && !bSkipDataProcessing)
// do not use ALIHLTCOMPONENT_DA_STOPWATCH(); macro
// in order to avoid 'shadowed variable' warning
AliHLTStopwatchGuard swguard2(fpStopwatches!=NULL?reinterpret_cast<TStopwatch*>(fpStopwatches->At((int)kSWDA)):NULL);
+ AliHLTMisc::AliOnlineGuard onlineGuard;
iResult=DoProcessing(evtData, blocks, trigData, outputPtr, size, blockData, edd);
} // end of the scope of the stopwatch guard
if (iResult>=0 && !bSkipDataProcessing) {
if (offset>0) fOutputBufferFilled+=offset;
}
if (bAddComponentTableEntry) {
- int offset=AddComponentTableEntry(fOutputBlocks, fpOutputBuffer, fOutputBufferSize, fOutputBufferFilled, parentComponentTables);
+ int offset=AddComponentTableEntry(fOutputBlocks, fpOutputBuffer, fOutputBufferSize, fOutputBufferFilled, parentComponentTables, processingLevel);
if (offset>0) size+=offset;
}
if (forwardedBlocks.size()>0) {
}
} else {
// Low Level interface
+ if (blockData.empty() && size!=0) {
+ // set the size to zero because there is no announced data
+ //HLTWarning("no output blocks added by component but output buffer filled %d of %d", size, fOutputBufferSize);
+ size=0;
+ }
+
if (compStats.size()>0) {
int offset=AddComponentStatistics(blockData, fpOutputBuffer, fOutputBufferSize, size, compStats);
if (offset>0) size+=offset;
}
if (bAddComponentTableEntry) {
- int offset=AddComponentTableEntry(blockData, fpOutputBuffer, fOutputBufferSize, size, parentComponentTables);
+ int offset=AddComponentTableEntry(blockData, fpOutputBuffer, fOutputBufferSize, size, parentComponentTables, processingLevel);
if (offset>0) size+=offset;
}
if (forwardedBlocks.size()>0) {
// reset the active triggers
if (fpCTPData) fpCTPData->SetTriggers(0);
+
+ // set the time for the pushback period
+ if (fPushbackPeriod>0) {
+ // suppress the output
+ TDatime time;
+ if (fLastPushBackTime<0) {
+ // choose a random offset at beginning to equalize traffic for multiple instances
+ // of the component
+ gRandom->SetSeed(fChainIdCrc);
+ fLastPushBackTime=time.Get();
+ fLastPushBackTime-=gRandom->Integer(fPushbackPeriod);
+ } else if ((int)time.Get()-fLastPushBackTime>=fPushbackPeriod) {
+ fLastPushBackTime=time.Get();
+ }
+ }
+
return iResult;
}
{
// see header file for function documentation
int iResult=0;
-#if defined(__DEBUG) || defined(HLT_COMPONENT_STATISTICS)
+ if ((fFlags&kDisableComponentStat)!=0) return 0;
+#if defined(HLT_COMPONENT_STATISTICS)
if (stats.size()==0) return -ENOENT;
// check if there is space for at least one entry
if (offset+sizeof(AliHLTComponentStatistics)>bufferSize) return 0;
stats[0].fCTime=(AliHLTUInt32_t)(fpBenchmark->CpuTime()*ALIHLTCOMPONENT_STATTIME_SCALER);
fpBenchmark->Continue();
}
+
+ sort(stats.begin(), stats.end(), SortComponentStatisticsDescendingByLevel);
+
+ // shrink the number of entries if the buffer is too small
if (offset+stats.size()*sizeof(AliHLTComponentStatistics)>bufferSize) {
+ unsigned originalSize=stats.size();
AliHLTUInt32_t removedLevel=0;
do {
// remove all entries of the level of the last entry
}
} while (stats.size()>1 &&
(offset+stats.size()*sizeof(AliHLTComponentStatistics)>bufferSize));
+ HLTWarning("too little space in output buffer to add block of %d statistics entries (size %d), available %d, removed %d entries",
+ originalSize, sizeof(AliHLTComponentStatistics), bufferSize-offset, originalSize-stats.size());
+ } else {
+ HLTDebug("adding block of %d statistics entries", stats.size());
}
assert(stats.size()>0);
if (stats.size()==0) return 0;
bd.fOffset = offset;
bd.fSize = stats.size()*sizeof(AliHLTComponentStatistics);
bd.fDataType = kAliHLTDataTypeComponentStatistics;
- bd.fSpecification = kAliHLTVoidDataSpec;
- unsigned int master=0;
- for (unsigned int i=1; i<blocks.size(); i++) {
- if (blocks[i].fSize>blocks[master].fSize &&
- !MatchExactly(blocks[i].fDataType, kAliHLTVoidDataType|kAliHLTDataOriginPrivate))
- master=i;
- }
- if (blocks.size()>0 && !MatchExactly(blocks[master].fDataType, kAliHLTVoidDataType|kAliHLTDataOriginPrivate)) {
- // take the data origin of the biggest block as specification
- // this is similar to the treatment in the HOMER interface. For traditional
- // reasons, the bytes are swapped there on a little endian architecture, so
- // we do it as well.
- memcpy(&bd.fSpecification, &blocks[master].fDataType.fOrigin, sizeof(bd.fSpecification));
-#ifdef R__BYTESWAP // set on little endian architectures
- bd.fSpecification=((bd.fSpecification & 0xFFULL) << 24) |
- ((bd.fSpecification & 0xFF00ULL) << 8) |
- ((bd.fSpecification & 0xFF0000ULL) >> 8) |
- ((bd.fSpecification & 0xFF000000ULL) >> 24);
-#endif
- }
+ bd.fSpecification = fChainIdCrc;
memcpy(buffer+offset, &(stats[0]), bd.fSize);
blocks.push_back(bd);
iResult=bd.fSize;
if (blocks.size() && buffer && bufferSize && offset && stats.size()) {
// get rid of warning
}
-#endif
+#endif // HLT_COMPONENT_STATISTICS
return iResult;
}
AliHLTUInt8_t* buffer,
AliHLTUInt32_t bufferSize,
AliHLTUInt32_t offset,
- const vector<AliHLTUInt32_t>& parents) const
+ const vector<AliHLTUInt32_t>& parents,
+ int processingLevel) const
{
// see header file for function documentation
int iResult=0;
-#if defined(__DEBUG) || defined(HLT_COMPONENT_STATISTICS)
+ if ((fFlags&kDisableComponentStat)!=0) return 0;
+#if defined(HLT_COMPONENT_STATISTICS)
// the payload consists of the AliHLTComponentTableEntry struct,
// followed by a an array of 32bit crc chain ids and the component
// description string
// write entry
AliHLTComponentTableEntry* pEntry=reinterpret_cast<AliHLTComponentTableEntry*>(pTgt);
pEntry->fStructSize=sizeof(AliHLTComponentTableEntry);
+ pEntry->fLevel=processingLevel>=0?processingLevel:0;
pEntry->fNofParents=parents.size();
pEntry->fSizeDescription=descriptionSize;
pTgt=pEntry->fBuffer;
iResult=bd.fSize;
}
#else
- if (blocks.size() && buffer && bufferSize && offset && parents.size()) {
+ if (blocks.size() && buffer && bufferSize && offset && parents.size() && processingLevel) {
// get rid of warning
}
- #endif
+#endif // HLT_COMPONENT_STATISTICS
return iResult;
}
//
}
-AliHLTComponent::AliHLTStopwatchGuard& AliHLTComponent::AliHLTStopwatchGuard::operator=(const AliHLTStopwatchGuard&)
+AliHLTComponent::AliHLTStopwatchGuard& AliHLTComponent::AliHLTStopwatchGuard::operator=(const AliHLTStopwatchGuard& other)
{
//
// assignment operator not for use
//
+ if (this==&other) return *this;
fpStopwatch=NULL;
fpPrec=NULL;
return *this;
fgpCurrent=fpPrec;
}
-int AliHLTComponent::AliHLTStopwatchGuard::Hold(TStopwatch* pSucc)
+int AliHLTComponent::AliHLTStopwatchGuard::Hold(const TStopwatch* pSucc)
{
// see header file for function documentation
if (fpStopwatch!=NULL && fpStopwatch!=pSucc) fpStopwatch->Stop();
return fpStopwatch!=pSucc?1:0;
}
-int AliHLTComponent::AliHLTStopwatchGuard::Resume(TStopwatch* pSucc)
+int AliHLTComponent::AliHLTStopwatchGuard::Resume(const TStopwatch* pSucc)
{
// see header file for function documentation
if (fpStopwatch!=NULL && fpStopwatch!=pSucc) fpStopwatch->Start(kFALSE);
if (pStopwatches==NULL) return -EINVAL;
int iResult=0;
- for (int i=0 ; i<(int)kSWTypeCount && pStopwatches->GetEntries(); i++)
+ for (int i=0 ; i<(int)kSWTypeCount && pStopwatches->GetEntriesFast(); i++)
SetStopwatch(pStopwatches->At(i), (AliHLTStopwatchType)i);
return iResult;
}
AliHLTUInt32_t AliHLTComponent::GetRunNo() const
{
// see header file for function documentation
- if (fpRunDesc==NULL) return kAliHLTVoidRunNo;
+
+ // 2010-02-11 OCDB is now the reliable source for the run number, it is
+ // initialized either by aliroot or the external interface depending
+ // on the environment. It turned out that the rundescriptor is not set
+ // in the aliroot mode, resulting in an invalid run number. However this
+ // did not cause problems until now. OCDB initialization has been revised
+ // already in 10/2009. This was a remnant.
+ // Have to check whether we get rid of the rundescriptor at some point.
+ if (fpRunDesc==NULL) return AliHLTMisc::Instance().GetCDBRunNo();
+ if (fpRunDesc->fRunNo!=(unsigned)AliHLTMisc::Instance().GetCDBRunNo()) {
+ HLTWarning("run number mismatch: ocdb %d run descriptor %d", AliHLTMisc::Instance().GetCDBRunNo(), fpRunDesc->fRunNo);
+ }
return fpRunDesc->fRunNo;
}
return fpRunDesc->fRunType;
}
+
AliHLTUInt32_t AliHLTComponent::GetTimeStamp() const
{
// see header file for function documentation
- if (fCurrentEventData.fEventCreation_s) {
+ if (fCurrentEventData.fEventCreation_s < kMaxUInt ) {
return fCurrentEventData.fEventCreation_s;
}
// using the actual UTC if the time stamp was not set by the framework
return GetEventId()&0xfff;
}
-bool AliHLTComponent::IsDataEvent(AliHLTUInt32_t* pTgt)
+bool AliHLTComponent::IsDataEvent(AliHLTUInt32_t* pTgt) const
{
// see header file for function documentation
if (pTgt) *pTgt=fEventType;
return (fEventType==gkAliEventTypeData ||
- fEventType==gkAliEventTypeDataReplay ||
- fEventType==gkAliEventTypeCalibration);
+ fEventType==gkAliEventTypeDataReplay);
}
int AliHLTComponent::CopyStruct(void* pStruct, unsigned int iStructSize, unsigned int iBlockNo,
return iResult;
}
-void AliHLTComponent::SetDDLBit(AliHLTEventDDL &list, Int_t ddlId, Bool_t state ) const
-{
- // see header file for function documentation
-
- // -- Detector offset
- Int_t ddlIdBase = TMath::FloorNint( (Double_t) ddlId / 256.0 );
-
- // -- Word Base = 1. word of detector ( TPC has 8 words, TOF 3 )
- Int_t wordBase = 0;
-
- if ( ddlIdBase <= 3 )
- wordBase = ddlIdBase;
- else if ( ddlIdBase > 3 && ddlIdBase < 5 )
- wordBase = ddlIdBase + 7;
- else
- wordBase = ddlIdBase + 9;
-
- // -- Bit index in Word
- Int_t bitIdx = ddlId % 32;
-
- // -- Index of word
- Int_t wordIdx = wordBase;
-
- // -- if TPC (3) or TOD (5) add word idx
- if ( ( ddlIdBase == 3 ) || ( ddlIdBase == 5 ) ) {
- wordIdx += TMath::FloorNint( (Double_t) ( ddlId - ( ddlIdBase * 256 ) ) / 32.0 );
- }
-
- // -- Set -- 'OR' word with bit mask;
- if ( state )
- list.fList[wordIdx] |= ( 0x00000001 << bitIdx );
- // -- Unset -- 'AND' word with bit mask;
- else
- list.fList[wordIdx] &= ( 0xFFFFFFFF ^ ( 0x00000001 << bitIdx ) );
-}
-
-Int_t AliHLTComponent::GetFirstUsedDDLWord(AliHLTEventDDL &list) const
-{
- // see header file for function documentation
-
- Int_t iResult = -1;
-
- for ( Int_t wordNdx = 0 ; wordNdx < gkAliHLTDDLListSize ; wordNdx++ ) {
-
- if ( list.fList[wordNdx] != 0 && iResult == -1 ) {
- // check for special cases TPC and TOF
- if ( wordNdx > 3 && wordNdx <= 10 ) {
- wordNdx = 10;
- iResult = 3;
- }
- else if ( wordNdx > 12 && wordNdx <= 14 ) {
- wordNdx = 14;
- iResult = 12;
- }
- else
- iResult = wordNdx;
- }
- else if ( list.fList[wordNdx] != 0 && iResult >= 0 ) {
- HLTError( "DDLIDs for minimum of TWO detectors ( %d, %d ) set, this function works only for ONE detector.", iResult, wordNdx );
- iResult = -1;
- break;
- }
- }
-
- return iResult;
-}
-
AliHLTUInt32_t AliHLTComponent::CalculateChecksum(const AliHLTUInt8_t* buffer, int size)
{
// see header file for function documentation
int AliHLTComponent::ExtractComponentTableEntry(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size,
string& retChainId, string& retCompId, string& retCompArgs,
- vector<AliHLTUInt32_t>& parents)
+ vector<AliHLTUInt32_t>& parents, int& level)
{
// see header file for function documentation
retChainId.clear();
retCompId.clear();
retCompArgs.clear();
parents.clear();
+ level=-1;
if (!pBuffer || size==0) return 0;
const AliHLTComponentTableEntry* pEntry=reinterpret_cast<const AliHLTComponentTableEntry*>(pBuffer);
if (size<8/* the initial size of the structure*/ ||
pEntry==NULL || pEntry->fStructSize<8) return -ENOMSG;
+
+ if (pEntry->fStructSize!=sizeof(AliHLTComponentTableEntry)) return -EBADF;
+ level=pEntry->fLevel;
const AliHLTUInt32_t* pParents=reinterpret_cast<const AliHLTUInt32_t*>(pEntry->fBuffer);
const AliHLTUInt8_t* pEnd=pBuffer+size;
TObjArray* pTokens=descriptor.Tokenize("{");
if (pTokens) {
int n=0;
- if (pTokens->GetEntries()>n) {
- retChainId=((TObjString*)pTokens->At(n++))->GetString();
+ if (pTokens->GetEntriesFast()>n) {
+ retChainId=pTokens->At(n++)->GetName();
}
- if (pTokens->GetEntries()>n) {
- compId=((TObjString*)pTokens->At(n++))->GetString();
+ if (pTokens->GetEntriesFast()>n) {
+ compId=pTokens->At(n++)->GetName();
}
delete pTokens;
}
if (!compId.IsNull() && (pTokens=compId.Tokenize(":"))!=NULL) {
int n=0;
- if (pTokens->GetEntries()>n) {
- compId=((TObjString*)pTokens->At(n++))->GetString();
+ if (pTokens->GetEntriesFast()>n) {
+ compId=pTokens->At(n++)->GetName();
}
- if (pTokens->GetEntries()>n) {
- compArgs=((TObjString*)pTokens->At(n++))->GetString();
+ if (pTokens->GetEntriesFast()>n) {
+ compArgs=pTokens->At(n++)->GetName();
}
delete pTokens;
}
return 1;
}
+int AliHLTComponent::ExtractTriggerData(
+ const AliHLTComponentTriggerData& trigData,
+ const AliHLTUInt8_t (**attributes)[gkAliHLTBlockDAttributeCount],
+ AliHLTUInt64_t* status,
+ AliHLTCDHWrapper* const cdh,
+ AliHLTReadoutList* readoutlist,
+ bool printErrors
+ )
+{
+ // see header file for function documentation
+
+ // Check that the trigger data structure is the correct size.
+ if (trigData.fStructSize != sizeof(AliHLTComponentTriggerData))
+ {
+ if (printErrors)
+ {
+ AliHLTLogging log;
+ log.LoggingVarargs(kHLTLogError, Class_Name(), FUNCTIONNAME(), __FILE__, __LINE__,
+ "Invalid trigger structure size: %d but expected %d.", trigData.fStructSize, sizeof(AliHLTComponentTriggerData)
+ );
+ }
+ return -ENOENT;
+ }
+
+ // Get the size of the AliHLTEventTriggerData structure without the readout list part.
+ // The way we do this here should also handle memory alignment correctly.
+ AliHLTEventTriggerData* dummy = NULL;
+ size_t sizeWithoutReadout = (char*)(&dummy->fReadoutList) - (char*)(dummy);
+
+ // Check that the trigger data pointer points to data of a size we can handle.
+ // Either it is the size of AliHLTEventTriggerData or the size of the old
+ // version of AliHLTEventTriggerData using AliHLTEventDDLV0.
+ if (trigData.fDataSize != sizeof(AliHLTEventTriggerData) and
+ trigData.fDataSize != sizeWithoutReadout + sizeof(AliHLTEventDDLV0)
+ )
+ {
+ if (printErrors)
+ {
+ AliHLTLogging log;
+ log.LoggingVarargs(kHLTLogError, Class_Name(), FUNCTIONNAME(), __FILE__, __LINE__,
+ "Invalid trigger data size: %d but expected %d.", trigData.fDataSize, sizeof(AliHLTEventTriggerData)
+ );
+ }
+ return -EBADF;
+ }
+
+ AliHLTEventTriggerData* evtData = reinterpret_cast<AliHLTEventTriggerData*>(trigData.fData);
+ assert(evtData != NULL);
+
+ // Check that the CDH has the right number of words.
+ if (cdh != NULL and evtData->fCommonHeaderWordCnt != gkAliHLTCommonHeaderCount)
+ {
+ if (printErrors)
+ {
+ AliHLTLogging log;
+ log.LoggingVarargs(kHLTLogError, Class_Name(), FUNCTIONNAME(), __FILE__, __LINE__,
+ "Common Data Header (CDH) has wrong number of data words: %d but expected %d",
+ evtData->fCommonHeaderWordCnt, gkAliHLTCommonHeaderCount
+ );
+ }
+ return -EBADMSG;
+ }
+
+ // Check that the readout list has the correct count of words. i.e. something we can handle,
+ if (readoutlist != NULL and
+ evtData->fReadoutList.fCount != (unsigned)gkAliHLTDDLListSizeV0 and
+ evtData->fReadoutList.fCount != (unsigned)gkAliHLTDDLListSizeV1
+ )
+ {
+ if (printErrors)
+ {
+ AliHLTLogging log;
+ log.LoggingVarargs(kHLTLogError, Class_Name(), FUNCTIONNAME(), __FILE__, __LINE__,
+ "Readout list structure has wrong number of data words: %d but expected %d",
+ evtData->fReadoutList.fCount, gkAliHLTDDLListSize
+ );
+ }
+ return -EPROTO;
+ }
+
+ if (attributes != NULL)
+ {
+ *attributes = &evtData->fAttributes;
+ }
+ if (status != NULL)
+ {
+ *status = evtData->fHLTStatus;
+ }
+ if (cdh != NULL)
+ {
+ *cdh = &(evtData->fCommonHeader[0]);
+ }
+ if (readoutlist != NULL)
+ {
+ *readoutlist = AliHLTReadoutList(evtData->fReadoutList);
+ }
+ return 0;
+}
+
+AliHLTUInt32_t AliHLTComponent::ExtractEventTypeFromCDH(const AliHLTCDHWrapper* const cdh)
+{
+ // see header file for function documentation
+ UChar_t l1msg = cdh->GetL1TriggerMessage();
+ if ((l1msg & 0x1) == 0x0) return gkAliEventTypeData;
+ // The L2SwC bit must be one if we got here, i.e. l1msg & 0x1 == 0x1.
+ if (((l1msg >> 2) & 0xF) == 0xE) return gkAliEventTypeStartOfRun;
+ if (((l1msg >> 2) & 0xF) == 0xF) return gkAliEventTypeEndOfRun;
+ // Check the C1T bit to see if this is a calibration event,
+ // if not then it must be some other software trigger event.
+ if (((l1msg >> 6) & 0x1) == 0x1) return gkAliEventTypeCalibration;
+ return gkAliEventTypeSoftware;
+}
+
int AliHLTComponent::LoggingVarargs(AliHLTComponentLogSeverity severity,
const char* originClass, const char* originFunc,
const char* file, int line, ... ) const
// without problems. But at this point we face the problem with virtual members which
// are not necessarily const.
AliHLTComponent* nonconst=const_cast<AliHLTComponent*>(this);
- AliHLTLogging::SetLogString("%s (%s, %p): ",
+ AliHLTLogging::SetLogString(this, ", %p", "%s (%s_pfmt_): ",
fChainId[0]!=0?fChainId.c_str():nonconst->GetComponentID(),
- nonconst->GetComponentID(), this);
+ nonconst->GetComponentID());
iResult=SendMessage(severity, originClass, originFunc, file, line, AliHLTLogging::BuildLogString(NULL, args, true /*append*/));
va_end(args);
return iResult;
}
+TUUID AliHLTComponent::GenerateGUID()
+{
+ // Generates a globally unique identifier.
+
+ // Start by creating a new UUID. We cannot use the one automatically generated
+ // by ROOT because the algorithm used will not guarantee unique IDs when generating
+ // these UUIDs at a high rate in parallel.
+ TUUID uuid;
+ // We then use the generated UUID to form part of the random number seeds which
+ // will be used to generate a proper random UUID. For good measure we use a MD5
+ // hash also. Note that we want to use the TUUID class because it will combine the
+ // host address information into the UUID. Using gSystem->GetHostByName() apparently
+ // can cause problems on Windows machines with a firewall, because it always tries
+ // to contact a DNS. The TUUID class handles this case appropriately.
+ union
+ {
+ UChar_t buf[16];
+ UShort_t word[8];
+ UInt_t dword[4];
+ };
+ uuid.GetUUID(buf);
+ TMD5 md5;
+ md5.Update(buf, sizeof(buf));
+ TMD5 md52 = md5;
+ md5.Final(buf);
+ dword[0] += gSystem->GetUid();
+ dword[1] += gSystem->GetGid();
+ dword[2] += gSystem->GetPid();
+ for (int i = 0; i < 4; ++i)
+ {
+ gRandom->SetSeed(dword[i]);
+ dword[i] = gRandom->Integer(0xFFFFFFFF);
+ }
+ md52.Update(buf, sizeof(buf));
+ md52.Final(buf);
+ // To keep to the standard we need to set the version and reserved bits.
+ word[3] = (word[3] & 0x0FFF) | 0x4000;
+ buf[8] = (buf[8] & 0x3F) | 0x80;
+
+ // Create the name of the new class and file.
+ char uuidstr[64];
+ sprintf(uuidstr, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ dword[0], word[2], word[3], buf[8], buf[9], buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]
+ );
+
+ uuid.SetUUID(uuidstr);
+ return uuid;
+}
+
int AliHLTComponent::ScanECSParam(const char* ecsParam)
{
// see header file for function documentation
// format of the parameter string from ECS
// <command>;<parameterkey>=<parametervalue>;<parameterkey>=<parametervalue>;...
// search for a subset of the parameterkeys
+ // RUN_TYPE=
+ // RUN_NUMBER=
+ // HLT_IN_DDL_LIST=
+ // CTP_TRIGGER_CLASS=
+ // DATA_FORMAT_VERSION=
+ // BEAM_TYPE=
+ // HLT_OUT_DDL_LIST=
+ // HLT_TRIGGER_CODE=
+ // DETECTOR_LIST=
+ // HLT_MODE=
+ // The command apears not to be sent by the online framework
int iResult=0;
TString string=ecsParam;
TObjArray* parameter=string.Tokenize(";");
if (parameter) {
- for (int i=0; i<parameter->GetEntries(); i++) {
- TString entry=((TObjString*)parameter->At(i))->GetString();
+ for (int i=0; i<parameter->GetEntriesFast(); i++) {
+ TString entry=parameter->At(i)->GetName();
HLTDebug("scanning ECS entry: %s", entry.Data());
TObjArray* entryParams=entry.Tokenize("=");
if (entryParams) {
- if (entryParams->GetEntries()>1) {
+ if (entryParams->GetEntriesFast()>1) {
if ((((TObjString*)entryParams->At(0))->GetString()).CompareTo("CTP_TRIGGER_CLASS")==0) {
- int result=InitCTPTriggerClasses((((TObjString*)entryParams->At(1))->GetString()).Data());
+ int result=InitCTPTriggerClasses(entryParams->At(1)->GetName());
if (iResult>=0 && result<0) iResult=result;
} else {
// TODO: scan the other parameters
return fpCTPData->EvaluateCTPTriggerClass(expression, trigData);
}
+
+int AliHLTComponent::CheckCTPTrigger(const char* name) const
+{
+ // see header file for function documentation
+ if (!fpCTPData) {
+ static bool bWarningThrown=false;
+ if (!bWarningThrown) HLTError("Trigger classes not initialized, use SetupCTPData from DoInit()");
+ bWarningThrown=true;
+ return false;
+ }
+
+ return fpCTPData->CheckTrigger(name);
+}
+
+Double_t AliHLTComponent::GetBz()
+{
+ // Returns Bz.
+ return AliHLTMisc::Instance().GetBz();
+}
+
+Double_t AliHLTComponent::GetBz(const Double_t *r)
+{
+ // Returns Bz (kG) at the point "r" .
+ return AliHLTMisc::Instance().GetBz(r);
+}
+
+void AliHLTComponent::GetBxByBz(const Double_t r[3], Double_t b[3])
+{
+ // Returns Bx, By and Bz (kG) at the point "r" .
+ AliHLTMisc::Instance().GetBxByBz(r, b);
+}