* default compression level for ROOT objects
*/
#define ALIHLTCOMPONENT_DEFAULT_OBJECT_COMPRESSION 5
+#define ALIHLTCOMPONENT_STATTIME_SCALER 1000000
/** ROOT macro for the implementation of ROOT specific class methods */
ClassImp(AliHLTComponent);
return SetGlobalComponentHandler(NULL,1);
}
-int AliHLTComponent::Init(const AliHLTAnalysisEnvironment* comenv, void* environParam, int argc, const char** argv )
+int AliHLTComponent::SetComponentEnvironment(const AliHLTAnalysisEnvironment* comenv, void* environParam)
{
// see header file for function documentation
- HLTLogKeyword(GetComponentID());
+ HLTLogKeyword(fChainId.c_str());
int iResult=0;
if (comenv) {
memset(&fEnvironment, 0, sizeof(AliHLTAnalysisEnvironment));
fEnvironment.fStructSize=sizeof(AliHLTAnalysisEnvironment);
fEnvironment.fParam=environParam;
}
+ return iResult;
+}
+
+int AliHLTComponent::Init(const AliHLTAnalysisEnvironment* comenv, void* environParam, int argc, const char** argv )
+{
+ // see header file for function documentation
+ HLTLogKeyword(fChainId.c_str());
+ int iResult=0;
+ if (comenv) {
+ SetComponentEnvironment(comenv, environParam);
+ }
fComponentArgs="";
const char** pArguments=NULL;
int iNofChildArgs=0;
if (argument.IsNull()) continue;
// benchmark
- if (argument.CompareTo("benchmark")==0) {
+ if (argument.CompareTo("-benchmark")==0) {
- // loglevel
- } else if (argument.CompareTo("loglevel")==0) {
- if ((bMissingParam=(++i>=argc))) break;
- TString parameter(argv[i]);
+ // -loglevel=
+ } else if (argument.BeginsWith("-loglevel=")) {
+ TString parameter=argument.ReplaceAll("-loglevel=", "");
parameter.Remove(TString::kLeading, ' '); // remove all blanks
if (parameter.BeginsWith("0x") &&
parameter.Replace(0,2,"",0).IsHex()) {
#if defined(__DEBUG) || defined(HLT_COMPONENT_STATISTICS)
// benchmarking stopwatch for the component statistics
fpBenchmark=new TStopwatch;
- if (fpBenchmark) {
- fpBenchmark->Start();
- }
#endif
return iResult;
int AliHLTComponent::Deinit()
{
// see header file for function documentation
- HLTLogKeyword(GetComponentID());
+ HLTLogKeyword(fChainId.c_str());
int iResult=0;
iResult=DoDeinit();
if (fpRunDesc) {
{
// see header file for function documentation
int iResult=0;
+ HLTInfo("Using CDB: %s", cdbPath);
if (pHandler) {
// I have to think about separating the library handling from the
- // component handler. Requiring the component hanlder here is not
+ // component handler. Requiring the component handler here is not
// the cleanest solution.
- // We presume the library already to be loaded
+ // We presume the library already to be loaded, which is the case
+ // because it is loaded in the initialization of the logging functionality
+ //
// find the symbol
AliHLTMiscInitCDB_t pFunc=(AliHLTMiscInitCDB_t)pHandler->FindSymbol(ALIHLTMISC_LIBRARY, ALIHLTMISC_INIT_CDB);
if (pFunc) {
AliHLTComponentDataTypeList itypes;
AliHLTComponentDataTypeList otypes;
otypes.push_back(GetOutputDataType());
- if (otypes[0]==kAliHLTMultipleDataType) {
+ if (MatchExactly(otypes[0],kAliHLTMultipleDataType)) {
otypes.clear();
int count=0;
if ((count=GetOutputDataTypes(otypes))>0) {
AliHLTComponentEventDoneData*& edd )
{
// see header file for function documentation
- HLTLogKeyword(GetComponentID());
+ HLTLogKeyword(fChainId.c_str());
ALIHLTCOMPONENT_BASE_STOPWATCH();
int iResult=0;
fCurrentEvent=evtData.fEventID;
#if defined(__DEBUG) || defined(HLT_COMPONENT_STATISTICS)
AliHLTComponentStatistics outputStat;
memset(&outputStat, 0, sizeof(AliHLTComponentStatistics));
+ outputStat.fStructSize=sizeof(AliHLTComponentStatistics);
outputStat.fId=fChainIdCrc;
- compStats.push_back(outputStat);
if (fpBenchmark) {
+ fpBenchmark->Stop();
+ outputStat.fComponentCycleTime=(AliHLTUInt32_t)(fpBenchmark->RealTime()*ALIHLTCOMPONENT_STATTIME_SCALER);
fpBenchmark->Reset();
fpBenchmark->Start();
}
+ compStats.push_back(outputStat);
#endif
// data processing is skipped
int iResult=0;
#if defined(__DEBUG) || 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].fTotalOutputSize=offset;
stats[0].fOutputBlockCount=blocks.size();
if (fpBenchmark) {
- stats[0].fTime=(AliHLTUInt32_t)(fpBenchmark->RealTime()*1000000);
- stats[0].fCTime=(AliHLTUInt32_t)(fpBenchmark->CpuTime()*1000000);
+ fpBenchmark->Stop();
+ stats[0].fTime=(AliHLTUInt32_t)(fpBenchmark->RealTime()*ALIHLTCOMPONENT_STATTIME_SCALER);
+ stats[0].fCTime=(AliHLTUInt32_t)(fpBenchmark->CpuTime()*ALIHLTCOMPONENT_STATTIME_SCALER);
+ fpBenchmark->Continue();
+ }
+ if (offset+stats.size()*sizeof(AliHLTComponentStatistics)>bufferSize) {
+ AliHLTUInt32_t removedLevel=0;
+ do {
+ // remove all entries of the level of the last entry
+ removedLevel=stats.back().fLevel;
+ AliHLTComponentStatisticsList::iterator element=stats.begin();
+ element++;
+ while (element!=stats.end()) {
+ if (element->fLevel<=removedLevel) {
+ element=stats.erase(element);
+ } else {
+ element++;
+ }
+ }
+ } while (stats.size()>1 &&
+ (offset+stats.size()*sizeof(AliHLTComponentStatistics)>bufferSize));
}
+ assert(stats.size()>0);
+ if (stats.size()==0) return 0;
+
if (offset+stats.size()*sizeof(AliHLTComponentStatistics)<=bufferSize) {
AliHLTComponentBlockData bd;
FillBlockData( bd );
return 1;
}
+
+int AliHLTComponent::LoggingVarargs(AliHLTComponentLogSeverity severity,
+ const char* originClass, const char* originFunc,
+ const char* file, int line, ... ) const
+{
+ // see header file for function documentation
+ int iResult=0;
+
+ va_list args;
+ va_start(args, line);
+
+ // logging function needs to be const in order to be called from const member functions
+ // 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): ",
+ fChainId[0]!=0?fChainId.c_str():nonconst->GetComponentID(),
+ nonconst->GetComponentID(), this);
+ iResult=SendMessage(severity, originClass, originFunc, file, line, AliHLTLogging::BuildLogString(NULL, args, true /*append*/));
+ va_end(args);
+
+ return iResult;
+}