From 3cde846dd47c1c9526cf3da55b0b689885e2b3f6 Mon Sep 17 00:00:00 2001 From: richterm Date: Tue, 6 Feb 2007 15:31:11 +0000 Subject: [PATCH] - improvements in AliHLTFilePublisher/Writer - small fix in component handler to pipe log messages during registration of standard components into right log channel - the ProcessEvent method is now a method of the component base class, the actual processing method to implement is DoProcessing - new standard component AliHLTRootFileWriterComponent added - TPCLib: AliHLTTPCEsdWriterComponent added, conversion of AliHLTTPCTrack to AliTPCtrack implemented (not finished) - small fixes in stand-alone build system (libAliHLTPHOS.pkg, *LinkDef.h) --- HLT/BASE/AliHLTComponent.cxx | 45 +++++- HLT/BASE/AliHLTComponent.h | 43 ++++- HLT/BASE/AliHLTComponentHandler.cxx | 18 +++ HLT/BASE/AliHLTComponentHandler.h | 2 + HLT/BASE/AliHLTDataSink.cxx | 2 +- HLT/BASE/AliHLTDataSink.h | 2 +- HLT/BASE/AliHLTDataSource.cxx | 2 +- HLT/BASE/AliHLTDataSource.h | 2 +- HLT/BASE/AliHLTDataTypes.h | 1 + HLT/BASE/AliHLTFilePublisher.cxx | 11 +- HLT/BASE/AliHLTFilePublisher.h | 16 +- HLT/BASE/AliHLTFileWriter.cxx | 134 +++++++++++++--- HLT/BASE/AliHLTFileWriter.h | 118 ++++++++++++-- HLT/BASE/AliHLTLogging.cxx | 13 +- HLT/BASE/AliHLTLogging.h | 6 +- HLT/BASE/AliHLTProcessor.cxx | 2 +- HLT/BASE/AliHLTProcessor.h | 2 +- HLT/BASE/AliHLTRootFileWriterComponent.cxx | 91 +++++++++++ HLT/BASE/AliHLTRootFileWriterComponent.h | 97 ++++++++++++ .../AliHLT_C_Component_WrapperInterface.cxx | 8 +- HLT/BASE/HLTbaseLinkDef.h | 1 + HLT/ChangeLog | 15 +- HLT/Makefile.am | 1 + HLT/PHOS/Makefile.am | 2 + HLT/TPCLib/AliHLTTPCEsdWriterComponent.cxx | 148 ++++++++++++++++++ HLT/TPCLib/AliHLTTPCEsdWriterComponent.h | 100 ++++++++++++ HLT/TPCLib/AliHLTTPCGlobalMergerComponent.h | 4 +- HLT/TPCLib/AliHLTTPCPad.cxx | 22 +-- HLT/TPCLib/AliHLTTPCTrack.cxx | 90 +++++++++-- HLT/TPCLib/AliHLTTPCTrack.h | 52 +++++- HLT/TPCLib/AliHLTTPCTrackArray.cxx | 12 +- HLT/TPCLib/AliHLTTPCTrackArray.h | 4 +- HLT/TPCLib/Makefile.am | 6 +- HLT/libHLTbase.pkg | 2 + HLT/make.dict | 2 +- 35 files changed, 970 insertions(+), 106 deletions(-) create mode 100644 HLT/BASE/AliHLTRootFileWriterComponent.cxx create mode 100644 HLT/BASE/AliHLTRootFileWriterComponent.h create mode 100644 HLT/TPCLib/AliHLTTPCEsdWriterComponent.cxx create mode 100644 HLT/TPCLib/AliHLTTPCEsdWriterComponent.h diff --git a/HLT/BASE/AliHLTComponent.cxx b/HLT/BASE/AliHLTComponent.cxx index d7b31e325c3..4677cacbfd5 100644 --- a/HLT/BASE/AliHLTComponent.cxx +++ b/HLT/BASE/AliHLTComponent.cxx @@ -36,7 +36,8 @@ ClassImp(AliHLTComponent) AliHLTComponent::AliHLTComponent() : fEnvironment(), - fCurrentEvent(0) + fCurrentEvent(0), + fEventCount(-1) { memset(&fEnvironment, 0, sizeof(AliHLTComponentEnvironment)); if (fpComponentHandler) @@ -71,6 +72,7 @@ int AliHLTComponent::Init( AliHLTComponentEnvironment* environ, void* environ_pa fEnvironment.fParam=environ_param; } iResult=DoInit(argc, argv); + if (iResult>=0) fEventCount=0; return iResult; } @@ -104,12 +106,21 @@ void AliHLTComponent::DataType2Text( const AliHLTComponentDataType& type, char o string AliHLTComponent::DataType2Text( const AliHLTComponentDataType& type ) { string out(""); + if (type==kAliHLTVoidDataType) { out="VOID:VOID"; } else { - out.append(type.fOrigin, kAliHLTComponentDataTypefOriginSize); + // some gymnastics in order to avoid a '0' which is part of either or both + // ID and origin terminating the whole string. Unfortunately, string doesn't + // stop appending at the '0' if the number of elements to append was + // explicitely specified + string tmp(""); + tmp.append(type.fOrigin, kAliHLTComponentDataTypefOriginSize); + out.append(tmp.c_str()); out.append(":"); - out.append(type.fID, kAliHLTComponentDataTypefIDsize); + tmp=""; + tmp.append(type.fID, kAliHLTComponentDataTypefIDsize); + out.append(tmp.c_str()); } return out; } @@ -237,6 +248,32 @@ void AliHLTComponent::PrintComponentDataTypeInfo(const AliHLTComponentDataType& else msg+="\\0"; } msg+="\""; - HLTMessage(msg.Data()); + AliHLTLogging::Message(NULL, kHLTLogNone, NULL , NULL, msg.Data()); } +int AliHLTComponent::GetEventCount() +{ + return fEventCount; +} + +int AliHLTComponent::IncrementEventCounter() +{ + if (fEventCount>=0) fEventCount++; + return fEventCount; +} + +int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, + const AliHLTComponentBlockData* blocks, + AliHLTComponentTriggerData& trigData, + AliHLTUInt8_t* outputPtr, + AliHLTUInt32_t& size, + AliHLTUInt32_t& outputBlockCnt, + AliHLTComponentBlockData*& outputBlocks, + AliHLTComponentEventDoneData*& edd ) +{ + int iResult=0; + fCurrentEvent=evtData.fEventID; + iResult=DoProcessing(evtData, blocks, trigData, outputPtr, size, outputBlockCnt, outputBlocks, edd); + IncrementEventCounter(); + return iResult; +} diff --git a/HLT/BASE/AliHLTComponent.h b/HLT/BASE/AliHLTComponent.h index 710db3f8912..4712f0f31be 100644 --- a/HLT/BASE/AliHLTComponent.h +++ b/HLT/BASE/AliHLTComponent.h @@ -94,6 +94,28 @@ class AliHLTComponent : public AliHLTLogging { /** * Processing of one event. + * The method is the entrance of the event processing. The parameters are + * cached for uses with the high-level interface and the DoProcessing + * implementation is called. + * + * @param evtData + * @param blocks + * @param trigData + * @param outputPtr + * @param size + * @param outputBlockCnt out: size of the output block array, set by the component + * @param outputBlocks out: the output block array is allocated internally + * @param edd + * @return neg. error code if failed + */ + int ProcessEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, + AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, + AliHLTUInt32_t& size, AliHLTUInt32_t& outputBlockCnt, + AliHLTComponentBlockData*& outputBlocks, + AliHLTComponentEventDoneData*& edd ); + + /** + * Internal processing of one event. * The method is pure virtual and implemented by the child classes * - @ref AliHLTProcessor * - @ref AliHLTDataSource @@ -109,7 +131,7 @@ class AliHLTComponent : public AliHLTLogging { * @param edd * @return neg. error code if failed */ - virtual int ProcessEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, + virtual int DoProcessing( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, AliHLTUInt32_t& outputBlockCnt, AliHLTComponentBlockData*& outputBlocks, @@ -293,7 +315,21 @@ class AliHLTComponent : public AliHLTLogging { */ void DataType2Text(const AliHLTComponentDataType& type, char output[kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2]); + /** + * Get event number. + * @return value of the internal event counter + */ + int GetEventCount(); + private: + /** + * Increment the internal event counter. + * To be used by the friend classes AliHLTProcessor, AliHLTDataSource + * and AliHLTDataSink. + * @return new value of the internal event counter + */ + int IncrementEventCounter(); + /** The global component handler instance */ static AliHLTComponentHandler* fpComponentHandler; /** The environment where the component is running in */ @@ -305,6 +341,9 @@ class AliHLTComponent : public AliHLTLogging { */ AliHLTEventID_t fCurrentEvent; - ClassDef(AliHLTComponent, 0) + /** internal event no */ + int fEventCount; + + ClassDef(AliHLTComponent, 1) }; #endif diff --git a/HLT/BASE/AliHLTComponentHandler.cxx b/HLT/BASE/AliHLTComponentHandler.cxx index 8d3796444fd..b840d469e4a 100644 --- a/HLT/BASE/AliHLTComponentHandler.cxx +++ b/HLT/BASE/AliHLTComponentHandler.cxx @@ -40,6 +40,7 @@ using namespace std; // the standard components #include "AliHLTFilePublisher.h" #include "AliHLTFileWriter.h" +#include "AliHLTRootFileWriterComponent.h" /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTComponentHandler) @@ -56,6 +57,22 @@ AliHLTComponentHandler::AliHLTComponentHandler() AddStandardComponents(); } +AliHLTComponentHandler::AliHLTComponentHandler(AliHLTComponentEnvironment* pEnv) + : + fComponentList(), + fScheduleList(), + fLibraryList(), + fEnvironment(), + fStandardList() +{ + if (pEnv) { + memcpy(&fEnvironment, pEnv, sizeof(AliHLTComponentEnvironment)); + AliHLTLogging::Init(pEnv->fLoggingFunc); + } else + memset(&fEnvironment, 0, sizeof(AliHLTComponentEnvironment)); + AddStandardComponents(); +} + AliHLTComponentHandler::~AliHLTComponentHandler() { UnloadLibraries(); @@ -274,6 +291,7 @@ int AliHLTComponentHandler::AddStandardComponents() AliHLTComponent::SetGlobalComponentHandler(this); fStandardList.push_back(new AliHLTFilePublisher); fStandardList.push_back(new AliHLTFileWriter); + fStandardList.push_back(new AliHLTRootFileWriterComponent); AliHLTComponent::UnsetGlobalComponentHandler(); iResult=RegisterScheduledComponents(); return iResult; diff --git a/HLT/BASE/AliHLTComponentHandler.h b/HLT/BASE/AliHLTComponentHandler.h index 1cdd33f41c0..4be1c12632a 100644 --- a/HLT/BASE/AliHLTComponentHandler.h +++ b/HLT/BASE/AliHLTComponentHandler.h @@ -35,6 +35,8 @@ class AliHLTComponentHandler : public AliHLTLogging { public: /** standard constructor */ AliHLTComponentHandler(); + /** constructor */ + AliHLTComponentHandler(AliHLTComponentEnvironment* pEnv); /** destructor */ virtual ~AliHLTComponentHandler(); diff --git a/HLT/BASE/AliHLTDataSink.cxx b/HLT/BASE/AliHLTDataSink.cxx index 1896275d25b..65acccb3de3 100644 --- a/HLT/BASE/AliHLTDataSink.cxx +++ b/HLT/BASE/AliHLTDataSink.cxx @@ -52,7 +52,7 @@ void AliHLTDataSink::GetOutputDataSize( unsigned long& constBase, double& inputM inputMultiplier=0; } -int AliHLTDataSink::ProcessEvent( const AliHLTComponentEventData& evtData, +int AliHLTDataSink::DoProcessing( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, diff --git a/HLT/BASE/AliHLTDataSink.h b/HLT/BASE/AliHLTDataSink.h index 42cf4701efd..e5ebad5bb05 100644 --- a/HLT/BASE/AliHLTDataSink.h +++ b/HLT/BASE/AliHLTDataSink.h @@ -43,7 +43,7 @@ class AliHLTDataSink : public AliHLTComponent { * preparation of data structures. The call is redirected to DumpEvent. * @return neg. error code if failed */ - int ProcessEvent( const AliHLTComponentEventData& evtData, + int DoProcessing( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, diff --git a/HLT/BASE/AliHLTDataSource.cxx b/HLT/BASE/AliHLTDataSource.cxx index 2ad38bf1287..c605d278f06 100644 --- a/HLT/BASE/AliHLTDataSource.cxx +++ b/HLT/BASE/AliHLTDataSource.cxx @@ -43,7 +43,7 @@ void AliHLTDataSource::GetInputDataTypes( vector& list) } -int AliHLTDataSource::ProcessEvent( const AliHLTComponentEventData& evtData, +int AliHLTDataSource::DoProcessing( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, diff --git a/HLT/BASE/AliHLTDataSource.h b/HLT/BASE/AliHLTDataSource.h index 723c5037668..70e0d23cd5c 100644 --- a/HLT/BASE/AliHLTDataSource.h +++ b/HLT/BASE/AliHLTDataSource.h @@ -42,7 +42,7 @@ class AliHLTDataSource : public AliHLTComponent { * preparation of data structures. The call is redirected to GetEvent. * @return neg. error code if failed */ - int ProcessEvent( const AliHLTComponentEventData& evtData, + int DoProcessing( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, diff --git a/HLT/BASE/AliHLTDataTypes.h b/HLT/BASE/AliHLTDataTypes.h index e71d5f92db7..99ad43ca5c8 100644 --- a/HLT/BASE/AliHLTDataTypes.h +++ b/HLT/BASE/AliHLTDataTypes.h @@ -36,6 +36,7 @@ extern "C" { AliHLTUInt32_t fBlockCnt; }; + const AliHLTEventID_t kAliHLTVoidEventID=~(AliHLTEventID_t)0; struct AliHLTComponentShmData { AliHLTUInt32_t fStructSize; diff --git a/HLT/BASE/AliHLTFilePublisher.cxx b/HLT/BASE/AliHLTFilePublisher.cxx index a883b2d0670..8cab1dbbc38 100644 --- a/HLT/BASE/AliHLTFilePublisher.cxx +++ b/HLT/BASE/AliHLTFilePublisher.cxx @@ -104,6 +104,7 @@ int AliHLTFilePublisher::DoInit( int argc, const char** argv ) int bMissingParam=0; for (int i=0; i=0; i++) { argument=argv[i]; + if (argument.IsNull()) continue; // -datafile if (argument.CompareTo("-datafile")==0) { @@ -124,21 +125,23 @@ int AliHLTFilePublisher::DoInit( int argc, const char** argv ) } else if (argument.CompareTo("-datatype")==0) { if ((bMissingParam=(++i>=argc))) break; memcpy(&fDataType.fID, argv[i], TMath::Min(kAliHLTComponentDataTypefIDsize, (Int_t)strlen(argv[i]))); + if ((bMissingParam=(++i>=argc))) break; + memcpy(&fDataType.fOrigin, argv[i], TMath::Min(kAliHLTComponentDataTypefOriginSize, (Int_t)strlen(argv[i]))); // -dataspec } else if (argument.CompareTo("-dataspec")==0) { if ((bMissingParam=(++i>=argc))) break; TString parameter(argv[i]); + parameter.Remove(TString::kLeading, ' '); // remove all blanks if (parameter.IsDigit()) { fSpecification=(AliHLTUInt32_t)parameter.Atoi(); + } else if (parameter.BeginsWith("0x") && + parameter.Replace(0,2,"",0).IsHex()) { + sscanf(parameter.Data(),"%x", &fSpecification); } else { HLTError("wrong parameter for argument %s, number expected", argument.Data()); iResult=-EINVAL; } - // -dataorigin - } else if (argument.CompareTo("-dataorigin")==0) { - if ((bMissingParam=(++i>=argc))) break; - memcpy(&fDataType.fOrigin, argv[i], TMath::Min(kAliHLTComponentDataTypefOriginSize,(Int_t)strlen(argv[i]))); } else { if ((iResult=ScanArgument(argc-i, &argv[i]))==-EINVAL) { HLTError("unknown argument %s", argument.Data()); diff --git a/HLT/BASE/AliHLTFilePublisher.h b/HLT/BASE/AliHLTFilePublisher.h index 382ed48dac5..0759b08dedd 100644 --- a/HLT/BASE/AliHLTFilePublisher.h +++ b/HLT/BASE/AliHLTFilePublisher.h @@ -19,18 +19,24 @@ * @class AliHLTFilePublisher * An HLT data source component which publishes data from one or a sequence * of files.
+ * * Mandatory arguments:
* * \li -datafile filename - * \li -datafilelist file pattern - * \li -datatype data type - * \li -dataspec specification - * \li -dataorigin origin + * \li -datafilelist file pattern
+ * not yet implemented + * \li -datatype datatype dataorigin
+ * data type ID and origin, e.g. -datatype CLUSTERS TPC + * \li -dataspec specification
+ * data specification treated as decimal number or hex number if + * prepended by '0x' * * Optional arguments:
* * The component needs at least one argument \em -datafile or \em -datafilelist. - * Both can occur multiple times. + * Both can occur multiple times. The \em -datatype and \em -dataspec + * parameters are valid for all files until the next occurrence of + * \em -datatype/spec * @ingroup alihlt_component */ class AliHLTFilePublisher : public AliHLTDataSource { diff --git a/HLT/BASE/AliHLTFileWriter.cxx b/HLT/BASE/AliHLTFileWriter.cxx index 3dd484e17e1..b6795d945fd 100644 --- a/HLT/BASE/AliHLTFileWriter.cxx +++ b/HLT/BASE/AliHLTFileWriter.cxx @@ -25,6 +25,7 @@ using namespace std; #endif #include "AliHLTFileWriter.h" +#include #include #include #include @@ -35,18 +36,20 @@ ClassImp(AliHLTFileWriter) AliHLTFileWriter::AliHLTFileWriter() : fBaseName(""), + fExtension(""), fDirectory(""), - fEnumeration(""), - fbSeparate(0) + fCurrentFileName(""), + fMode(0) { } AliHLTFileWriter::AliHLTFileWriter(const AliHLTFileWriter&) : fBaseName(""), + fExtension(""), fDirectory(""), - fEnumeration(""), - fbSeparate(0) + fCurrentFileName(""), + fMode(0) { HLTFatal("copy constructor untested"); } @@ -86,11 +89,25 @@ int AliHLTFileWriter::DoInit( int argc, const char** argv ) int bMissingParam=0; for (int i=0; i=0; i++) { argument=argv[i]; + if (argument.IsNull()) continue; // -basename if (argument.CompareTo("-datafile")==0) { if ((bMissingParam=(++i>=argc))) break; fBaseName=argv[i]; + TObjArray* pTokens=fBaseName.Tokenize("."); + if (pTokens) { + int iEntries=pTokens->GetEntries(); + if (iEntries>1) { + int i=0; + fBaseName=((TObjString*)pTokens->At(i++))->GetString(); + while (iAt(i++))->GetString(); + } + fExtension=((TObjString*)pTokens->At(i))->GetString(); + } + delete pTokens; + } // -directory } else if (argument.CompareTo("-directory")==0) { @@ -98,18 +115,16 @@ int AliHLTFileWriter::DoInit( int argc, const char** argv ) fDirectory=argv[i]; // -enumeration - } else if (argument.CompareTo("-enumeration")==0) { - if ((bMissingParam=(++i>=argc))) break; - fEnumeration=argv[i]; + } else if (argument.CompareTo("-enumerate")==0) { + SetMode(kEnumerate); - // -separate - } else if (argument.CompareTo("-enumeration")==0) { - if ((bMissingParam=(++i>=argc))) break; - TString parameter(argv[i]); - fbSeparate=parameter.Atoi(); - if (fbSeparate < 0 || fbSeparate > 1) { - HLTError("invalid parameter for argument %s", argument.Data()); - } + // -concatenate-blocks + } else if (argument.CompareTo("-concatenate-blocks")==0) { + SetMode(kConcatenateBlocks); + + // -concatenate-events + } else if (argument.CompareTo("-concatenate-events")==0) { + SetMode(kConcatenateEvents); } else { if ((iResult=ScanArgument(argc-i, &argv[i]))==-EINVAL) { @@ -128,9 +143,18 @@ int AliHLTFileWriter::DoInit( int argc, const char** argv ) HLTError("missing parameter for argument %s", argument.Data()); iResult=-EINVAL; } + if (iResult>=0) { + iResult=InitWriter(); + } + return iResult; } +int AliHLTFileWriter::InitWriter() +{ + return 0; // note: this doesn't mean 'error' +} + int AliHLTFileWriter::ScanArgument(int argc, const char** argv) { // there are no other arguments than the standard ones @@ -139,24 +163,49 @@ int AliHLTFileWriter::ScanArgument(int argc, const char** argv) int AliHLTFileWriter::DoDeinit() { - int iResult=0; + HLTDebug(""); + int iResult=CloseWriter(); + ClearMode(kEnumerate); return iResult; } +int AliHLTFileWriter::CloseWriter() +{ + return 0; // note: this doesn't mean 'error' +} + int AliHLTFileWriter::DumpEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData ) { int iResult=0; + if (CheckMode(kConcatenateEvents)==0) { + // reset the current file name in order to open a new file + // for the first block. If events are concatenated, the current + // file name stays in order to be opended in append mode. + fCurrentFileName=""; + } for (int n=0; n<(int)evtData.fBlockCnt; n++ ) { //HLTDebug("block %d out of %d", n, evtData.fBlockCnt); TString filename; + HLTDebug("dataspec 0x%x", blocks[n].fSpecification); iResult=BuildFileName(evtData.fEventID, n, blocks[n].fDataType, filename); + ios::openmode filemode=(ios::openmode)0; + if (fCurrentFileName.CompareTo(filename)==0) { + // append to the file + filemode=ios::app; + } else { + // store the file for the next block + fCurrentFileName=filename; + } if (iResult>=0) { - ofstream dump(filename.Data()); + ofstream dump(filename.Data(), filemode); if (dump.good()) { dump.write((const char*)blocks[n].fPtr, blocks[n].fSize); HLTDebug("wrote %d byte(s) to file %s", blocks[n].fSize, filename.Data()); + } else { + HLTError("can not open file %s for writing", filename.Data()); + iResult=-EBADF; } dump.close(); } @@ -168,7 +217,54 @@ int AliHLTFileWriter::BuildFileName(const AliHLTEventID_t eventID, const int blo { int iResult=0; //HLTDebug("build file name for event %d block %d", eventID, blockID); - filename.Form("event_%#08x_0x%x_", eventID, blockID); - filename+=AliHLTComponent::DataType2Text(dataType).data(); + filename=""; + if (!fDirectory.IsNull()) { + filename+=fDirectory; + if (!fDirectory.EndsWith("/")) + filename+="/"; + } + if (!fBaseName.IsNull()) + filename+=fBaseName; + else + filename+="event"; + if (!CheckMode(kConcatenateEvents)) { + if (!CheckMode(kEnumerate)) { + if (eventID!=kAliHLTVoidEventID) { + filename+=Form("_0x%08x", eventID); + } + } else { + filename+=Form("_%d", GetEventCount()); + } + } + if (blockID>=0 && !CheckMode(kConcatenateBlocks)) { + filename+=Form("_0x%x", blockID); + if (dataType!=kAliHLTVoidDataType) { + filename+="_"; + filename+=AliHLTComponent::DataType2Text(dataType).data(); + } + } + if (!fExtension.IsNull()) + filename+="." + fExtension; + filename.ReplaceAll(" ", ""); return iResult; } + +int AliHLTFileWriter::SetMode(Short_t mode) +{ + fMode|=mode; + //HLTDebug("mode set to 0x%x", fMode); + return fMode; +} + +int AliHLTFileWriter::ClearMode(Short_t mode) +{ + fMode&=~mode; + //HLTDebug("mode set to 0x%x", fMode); + return fMode; +} + +int AliHLTFileWriter::CheckMode(Short_t mode) +{ + //HLTDebug("check mode 0x%x for flag 0x%x: %d", fMode, mode, (fMode&mode)!=0); + return (fMode&mode)!=0; +} diff --git a/HLT/BASE/AliHLTFileWriter.h b/HLT/BASE/AliHLTFileWriter.h index 4aacf183382..83e1fc5411b 100644 --- a/HLT/BASE/AliHLTFileWriter.h +++ b/HLT/BASE/AliHLTFileWriter.h @@ -9,7 +9,6 @@ @author Matthias Richter @date @brief An HLT file dump (data sink) component. - @note The class is used in Offline (AliRoot) context */ #include "AliHLTDataSink.h" @@ -17,8 +16,39 @@ /** * @class AliHLTFileWriter - * An HLT data sink component which writes data to file(s) + * An HLT data sink component which writes data to file(s). * + * Mandatory arguments:
+ * + * + * Optional arguments:
+ * + * \li -datafile filename
+ * file name base + * \li -directory directory
+ * target directory + * \li -enumerate
+ * don't use the event number but an event counter beginning from 0 + * \li -concatenate-blocks
+ * concatenate all blocks of one event into one file, this skips + * the block no, and the block data type in the file name + * \li -concatenate-events
+ * concatenate all events into one file, this skips the event no, + * the block no, and the block data type in the file name. Currently, + * this implies the -concatenate-blocks option. + * + * The file name is built from the basename, the event number, the block + * number and the data type in the format: + *
+ * basename_eventno_blockno_dt
+ * 
+ * If the basename was not given, \em 'event' ist used instead. A file + * extension after the last dot is separated from the basename and appended + * to the final name. + * + * The class can be used as a base class for file writers. Additional + * argument scan can be implemented in @ref ScanArgument which is called + * for each unknown argument. * @ingroup alihlt_component */ class AliHLTFileWriter : public AliHLTDataSink { @@ -32,9 +62,9 @@ class AliHLTFileWriter : public AliHLTDataSink { /** destructor */ virtual ~AliHLTFileWriter(); - const char* GetComponentID(); - void GetInputDataTypes( vector& list); - AliHLTComponent* Spawn(); + virtual const char* GetComponentID(); + virtual void GetInputDataTypes( vector& list); + virtual AliHLTComponent* Spawn(); protected: /** @@ -47,13 +77,28 @@ class AliHLTFileWriter : public AliHLTDataSink { */ int DoDeinit(); + /** + * Init the writer. + * The DoInit function is not available for child classes. InitWriter is the + * corresponding function for classes derived from AliHLTFileWriter. + */ + virtual int InitWriter(); + + /** + * Init the writer. + * The DoDeinit function is not available for child classes. CloseWriter is the + * corresponding function for classes derived from AliHLTFileWriter. + */ + virtual int CloseWriter(); + /** * Data processing method for the component. + * The function can be overloaded by other file writer components. * @param evtData event data structure * @param blocks input data block descriptors * @param trigData trigger data structure */ - int DumpEvent( const AliHLTComponentEventData& evtData, + virtual int DumpEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData ); @@ -61,7 +106,8 @@ class AliHLTFileWriter : public AliHLTDataSink { * Scan one argument and adjacent parameters. * Can be overloaded by child classes in order to add additional arguments * beyond the standard arguments of the file publisher. The method is called - * whenever a non-standard argument is recognized. + * whenever a non-standard argument is recognized. Make sure to return + * -EPROTO if the argument is not recognized be the child. * @param argc size of the argument array * @param argv agument array for component initialization * @return number of processed members of the argv
@@ -70,28 +116,70 @@ class AliHLTFileWriter : public AliHLTDataSink { */ virtual int ScanArgument(int argc, const char** argv); - private: /** * Build file name from eventID data type and the specified directory and basename. * @param eventID [in] the ID of the event * @param blockID [in] the ID of the current block + * no block string appended if -1 * @param dataType [in] the data type of the data block + * no type string appanded if @ref kAliHLTVoidDataType * @param filename [out] string to receive the file name */ int BuildFileName(const AliHLTEventID_t eventID, const int blockID, const AliHLTComponentDataType& dataType, TString& filename); + /** + * Set a mode flag. + * @return current mode flags + */ + int SetMode(Short_t mode); + + /** + * Clear a mode flag. + * @return current mode flags + */ + int ClearMode(Short_t mode); + + /** + * Check a mode flag. + * @return 1 if flag is set, 0 if not + */ + int CheckMode(Short_t mode); + + /** + * Working modes of the writer + * @internal + */ + enum TWriterMode { + /** + * flag to indicate whether to write each incoming block to separate files + * or all blocks of one event to one file. set = concatenate (one file). + */ + kConcatenateBlocks = 0x1, + + /** + * flag to indicate whether to concatenate incoming blocks of the same type + * for all events to one file. If also @ref kConcatenateBlocks is set, + * or all blocks of all events are written to the same file. + */ + kConcatenateEvents = 0x2, + + /** event enumeration flag */ + kEnumerate = 0x4 + }; + + private: /** the basename of the output file */ TString fBaseName; + /** the extension of the output file */ + TString fExtension; /** target directory */ TString fDirectory; /** enumeration format string */ - TString fEnumeration; - /** - * flag to indicate whether to write each incoming block to separate files - * or all blocks of one event to one file. - */ - Int_t fbSeparate; + TString fCurrentFileName; + + /** mode specifier, see @ref TWriterMode */ + Short_t fMode; - ClassDef(AliHLTFileWriter, 0) + ClassDef(AliHLTFileWriter, 1) }; #endif diff --git a/HLT/BASE/AliHLTLogging.cxx b/HLT/BASE/AliHLTLogging.cxx index 1410577de8f..066babaf030 100644 --- a/HLT/BASE/AliHLTLogging.cxx +++ b/HLT/BASE/AliHLTLogging.cxx @@ -28,6 +28,7 @@ using namespace std; #include "AliHLTStdIncludes.h" #include "AliHLTLogging.h" +#include "TString.h" // global logging buffer #define LOG_BUFFER_SIZE 100 @@ -105,10 +106,14 @@ int AliHLTLogging::Message(void *param, AliHLTComponentLogSeverity severity, con default: break; } - cout << "HLT Log " << strSeverity << ": " << origin << " " << message; - if (strcmp(keyword, HLT_DEFAULT_LOG_KEYWORD)!=0) - cout << " (" << keyword << ")"; - cout << endl; + TString out="HLT Log "; + out+=strSeverity; + if (origin) {out+=": "; out+=origin;} + out+=" "; out+=message; + if (keyword!=NULL && strcmp(keyword, HLT_DEFAULT_LOG_KEYWORD)!=0) { + out+=" ("; out+=keyword; out +=")"; + } + cout << out.Data() << endl; return iResult; } diff --git a/HLT/BASE/AliHLTLogging.h b/HLT/BASE/AliHLTLogging.h index 4985880bd94..c461d05e360 100644 --- a/HLT/BASE/AliHLTLogging.h +++ b/HLT/BASE/AliHLTLogging.h @@ -104,10 +104,10 @@ private: static AliHLTComponentLogSeverity fGlobalLogFilter; AliHLTComponentLogSeverity fLocalLogFilter; static AliHLTfctLogging fLoggingFunc; - const char* fpDefaultKeyword; - const char* fpCurrentKeyword; + const char* fpDefaultKeyword; //! + const char* fpCurrentKeyword; //! - ClassDef(AliHLTLogging, 0) + ClassDef(AliHLTLogging, 1) }; /* the class AliHLTKeyword is a simple helper class used by the HLTLogKeyword macro diff --git a/HLT/BASE/AliHLTProcessor.cxx b/HLT/BASE/AliHLTProcessor.cxx index 09d0601eb3b..a2619a93e48 100644 --- a/HLT/BASE/AliHLTProcessor.cxx +++ b/HLT/BASE/AliHLTProcessor.cxx @@ -53,7 +53,7 @@ int AliHLTProcessor::Deinit() return iResult; } -int AliHLTProcessor::ProcessEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, +int AliHLTProcessor::DoProcessing( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, AliHLTUInt32_t& outputBlockCnt, AliHLTComponentBlockData*& outputBlocks, diff --git a/HLT/BASE/AliHLTProcessor.h b/HLT/BASE/AliHLTProcessor.h index 89efb58b339..99e2262eefb 100644 --- a/HLT/BASE/AliHLTProcessor.h +++ b/HLT/BASE/AliHLTProcessor.h @@ -46,7 +46,7 @@ class AliHLTProcessor : public AliHLTComponent { * preparation of data structures. The call is redirected to DoEvent. * @return neg. error code if failed */ - int ProcessEvent( const AliHLTComponentEventData& evtData, + int DoProcessing( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, diff --git a/HLT/BASE/AliHLTRootFileWriterComponent.cxx b/HLT/BASE/AliHLTRootFileWriterComponent.cxx new file mode 100644 index 00000000000..4ca28d0847c --- /dev/null +++ b/HLT/BASE/AliHLTRootFileWriterComponent.cxx @@ -0,0 +1,91 @@ +// @(#) $Id$ + +/** @file AliHLTRootFileWriterComponent.cxx + @author Matthias Richter + @date + @brief Base class for writer components to store data in a ROOT file + + */ + +#include "AliHLTRootFileWriterComponent.h" +#include "TFile.h" +#include "TString.h" + +/** ROOT macro for the implementation of ROOT specific class methods */ +ClassImp(AliHLTRootFileWriterComponent) + +AliHLTRootFileWriterComponent::AliHLTRootFileWriterComponent() + : + fEventID(kAliHLTVoidEventID), + fCurrentFile(NULL) +{ + // all blocks of one event go into the same file + SetMode(kConcatenateBlocks); +} + +AliHLTRootFileWriterComponent::~AliHLTRootFileWriterComponent() +{ +} + +int AliHLTRootFileWriterComponent::DumpEvent( const AliHLTComponentEventData& evtData, + const AliHLTComponentBlockData* blocks, + AliHLTComponentTriggerData& trigData ) +{ + int iResult=0; + // this function will be implemented in conjunction with the high-level + // component interface + HLTWarning("not yet implemented"); + return iResult; +} + +int AliHLTRootFileWriterComponent::ScanArgument(int argc, const char** argv) +{ + // no other arguments known + int iResult=-EPROTO; + return iResult; +} + +int AliHLTRootFileWriterComponent::WriteObject(const AliHLTEventID_t eventID, TObject *pOb) +{ + int iResult=0; + if (pOb) { + HLTDebug("write object %p (%s)", pOb, pOb->GetName()); + if (CheckMode(kConcatenateEvents) && eventID != fEventID && + fCurrentFile!=NULL && eventID!=kAliHLTVoidEventID) { + TFile* pFile=fCurrentFile; fCurrentFile=NULL; + pFile->Close(); delete pFile; + } + if (fCurrentFile==NULL) { + fCurrentFile=OpenFile(eventID, 0); + if (fCurrentFile) fEventID=eventID; + } + if (fCurrentFile) { + fCurrentFile->cd(); + pOb->Write(); + } else { + iResult=-EBADF; + } + } + return iResult; +} + +TFile* AliHLTRootFileWriterComponent::OpenFile(const AliHLTEventID_t eventID, const int blockID, const char* option) +{ + TFile* pFile=NULL; + TString filename(""); + if ((BuildFileName(eventID, blockID, kAliHLTVoidDataType, filename))>=0 && filename.IsNull()==0) { + pFile=new TFile(filename, option); + if (pFile) { + if (pFile->IsZombie()) { + delete pFile; + pFile=NULL; + HLTError("can not open ROOT file %s", filename.Data()); + } + } else { + HLTFatal("memory allocation failed"); + } + } else { + HLTError("failed to build a new file name for event %#8x", eventID); + } + return pFile; +} diff --git a/HLT/BASE/AliHLTRootFileWriterComponent.h b/HLT/BASE/AliHLTRootFileWriterComponent.h new file mode 100644 index 00000000000..cccca968347 --- /dev/null +++ b/HLT/BASE/AliHLTRootFileWriterComponent.h @@ -0,0 +1,97 @@ +// @(#) $Id$ + +#ifndef ALIHLTROOTFILEWRITERCOMPONENT_H +#define ALIHLTROOTFILEWRITERCOMPONENT_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/** @file AliHLTRootFileWriterComponent.h + @author Matthias Richter + @date + @brief Base class for writer components to store data in a ROOT file + + */ +#include "AliHLTFileWriter.h" +#include "TObject.h" + +class TFile; + +/** + * @class AliHLTRootFileWriterComponent + * @see AliHLTFileWriter for parameters + */ +class AliHLTRootFileWriterComponent : public AliHLTFileWriter +{ + public: + /** standard constructor */ + AliHLTRootFileWriterComponent(); + /** destructor */ + ~AliHLTRootFileWriterComponent(); + + /** + * The id of the component. + * @return component id (string) + */ + virtual const char* GetComponentID() {return "ROOTFileWriter";}; + + /** + * Spawn function. + * @return new class instance + */ + virtual AliHLTComponent* Spawn() {return new AliHLTRootFileWriterComponent;} + + protected: + /** + * Data processing method for the component. + * The function can be overloaded by specific ROOT file writer + * components. + * @param evtData event data structure + * @param blocks input data block descriptors + * @param trigData trigger data structure + */ + virtual int DumpEvent( const AliHLTComponentEventData& evtData, + const AliHLTComponentBlockData* blocks, + AliHLTComponentTriggerData& trigData ); + + /** + * Scan one argument and adjacent parameters. + * \b IMPORTANT: if overloaded by child class, call this function + * as the default from the cutomized switch, e.g. + *
+   * 
+ * @param argc size of the argument array + * @param argv agument array for component initialization + * @return number of processed members of the argv
+ * -EINVAL unknown argument
+ * -EPROTO parameter for argument missing
+ */ + virtual int ScanArgument(int argc, const char** argv); + + /** + * Write ROOT object to current file. + * @param eventID ID of the current event + * @param pOb pointer to ROOT object + * @return neg. error code if failed + */ + int WriteObject(const AliHLTEventID_t eventID, TObject *pOb); + + /** + * Open a ROOT file. + * The function calls @ref AliHLTFileWriter::BuildFileName in order to + * create a file name and opens it as a root file. + * @param eventID ID of the current event + * @param blockID ID of the current block + * @param option option as specified in TFile + * @return pointer to TFile object, the called has to clean-up the object after use. + */ + TFile* OpenFile(const AliHLTEventID_t eventID, const int blockID=-1, const char* option="recreate"); + + /** the event ID associated with the current file */ + AliHLTEventID_t fEventID; + + /** the name of the current file */ + TFile* fCurrentFile; //! transient value + + ClassDef(AliHLTRootFileWriterComponent, 0) +}; +#endif diff --git a/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx b/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx index 14a5191298d..87e14b68155 100644 --- a/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx +++ b/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx @@ -40,10 +40,9 @@ int AliHLT_C_Component_InitSystem( AliHLTComponentEnvironment* environ ) { return EINPROGRESS; } - gComponentHandler_C = new AliHLTComponentHandler(); + gComponentHandler_C = new AliHLTComponentHandler(environ); if ( !gComponentHandler_C ) return EFAULT; - gComponentHandler_C->SetEnvironment( environ ); gComponentHandler_C->AnnounceVersion(); return 0; } @@ -86,7 +85,10 @@ void AliHLT_C_DestroyComponent( AliHLTComponentHandle handle ) { if ( !handle ) return; - delete reinterpret_cast( handle ); + + AliHLTComponent* pComp=reinterpret_cast( handle ); + pComp->Deinit(); + delete pComp; } int AliHLT_C_ProcessEvent( AliHLTComponentHandle handle, const AliHLTComponent_EventData* evtData, const AliHLTComponent_BlockData* blocks, diff --git a/HLT/BASE/HLTbaseLinkDef.h b/HLT/BASE/HLTbaseLinkDef.h index 03ababd55d0..fef323bff31 100644 --- a/HLT/BASE/HLTbaseLinkDef.h +++ b/HLT/BASE/HLTbaseLinkDef.h @@ -19,6 +19,7 @@ #pragma link C++ class AliHLTDataSink; #pragma link C++ class AliHLTFilePublisher; #pragma link C++ class AliHLTFileWriter; +#pragma link C++ class AliHLTRootFileWriterComponent; #endif diff --git a/HLT/ChangeLog b/HLT/ChangeLog index ceedd744537..b54f636db99 100644 --- a/HLT/ChangeLog +++ b/HLT/ChangeLog @@ -1,11 +1,22 @@ +2007-02-05 + - improvements in AliHLTFilePublisher/Writer + - small fix in component handler to pipe log messages during registration + of standard components into right log channel + - the ProcessEvent method is now a method of the component base class, + the actual processing method to implement is DoProcessing + - new standard component AliHLTRootFileWriterComponent added + - TPCLib: AliHLTTPCEsdWriterComponent added, conversion of AliHLTTPCTrack + to AliTPCtrack implemented (not finished) + - small fixes in stand-alone build system (libAliHLTPHOS.pkg, *LinkDef.h) + 2007-01-19 - AliHLTFileWriter added, handling of standard components in libHLT added to ComponentHandler - several fixes in the HLT offline framework 2007-01-05 - changes according to coding conventions and documentation - - AliHLTTPCDigitReaderRaw: HAVE_TPC_MAPPING dependend implementation - fixed in order to make class definition independend + - AliHLTTPCDigitReaderRaw: HAVE_TPC_MAPPING dependent implementation + fixed in order to make class definition independent - helper functions for data structure handling added - libHLTbase.pkg and libAliHLTSample.pkg included to the stand-alone build system diff --git a/HLT/Makefile.am b/HLT/Makefile.am index f668da6545e..ee1cfa69f88 100644 --- a/HLT/Makefile.am +++ b/HLT/Makefile.am @@ -22,6 +22,7 @@ SUBDIRS = BASE \ EXTRA_DIST = libHLTbase.pkg \ libAliHLTSample.pkg \ + libAliHLTPHOS.pkg \ hlt.conf DIST_SUBDIRS = $(SUBDIRS) diff --git a/HLT/PHOS/Makefile.am b/HLT/PHOS/Makefile.am index 7645506b9c6..5a67662f624 100644 --- a/HLT/PHOS/Makefile.am +++ b/HLT/PHOS/Makefile.am @@ -3,6 +3,8 @@ MODULE = AliHLTPHOS +EXTRA_DIST = AliHLTPHOSLinkDef.h + AM_CPPFLAGS = @ALIROOT_CPPFLAGS@ \ -I$(top_srcdir)/BASE diff --git a/HLT/TPCLib/AliHLTTPCEsdWriterComponent.cxx b/HLT/TPCLib/AliHLTTPCEsdWriterComponent.cxx new file mode 100644 index 00000000000..9e2f09e1c0d --- /dev/null +++ b/HLT/TPCLib/AliHLTTPCEsdWriterComponent.cxx @@ -0,0 +1,148 @@ +// @(#) $Id$ + +/** @file AliHLTTPCEsdWriterComponent.cxx + @author Matthias Richter + @date + @brief Writer component to store tracks of the HLT TPC conformal + mapping tracker in the AliESD format + + */ +#include "AliHLTTPCEsdWriterComponent.h" +#include "AliESD.h" +#include "TTree.h" +#include "AliHLTTPCTrack.h" +#include "AliHLTTPCTrackArray.h" +#include "AliHLTTPCTrackletDataFormat.h" +#include "AliHLTTPCDefinitions.h" + +/** global instance for component registration */ +AliHLTTPCEsdWriterComponent gTPCEsdWriter; + +/** ROOT macro for the implementation of ROOT specific class methods */ +ClassImp(AliHLTTPCEsdWriterComponent) + +AliHLTTPCEsdWriterComponent::AliHLTTPCEsdWriterComponent() + : + fTree(NULL), + fESD(NULL) +{ +} + +AliHLTTPCEsdWriterComponent::~AliHLTTPCEsdWriterComponent() +{ +} + +int AliHLTTPCEsdWriterComponent::InitWriter() +{ + int iResult=0; + fESD = new AliESD; + if (fESD) { + fTree = new TTree("esdTree", "Tree with HLT ESD objects"); + if (fTree) { + fTree->Branch("ESD", "AliESD", &fESD); + } + delete fESD; + fESD=NULL; + } + if (fTree==NULL) { + iResult=-ENOMEM; + } + return iResult; +} + +int AliHLTTPCEsdWriterComponent::CloseWriter() +{ + int iResult=0; + if (fTree) { + WriteObject(kAliHLTVoidEventID, fTree); + TTree* pTree=fTree; + fTree=NULL; + delete pTree; + } else { + HLTWarning("not initialized"); + } + AliHLTRootFileWriterComponent::CloseWriter(); +} + +int AliHLTTPCEsdWriterComponent::DumpEvent( const AliHLTComponentEventData& evtData, + const AliHLTComponentBlockData* blocks, + AliHLTComponentTriggerData& trigData ) +{ + int iResult=0; + TTree* pTree=fTree; + if (pTree) { + fESD = new AliESD; + if (fESD) { + AliESD* pESD=fESD; + + const AliHLTComponentBlockData* iter = NULL; + AliHLTTPCTrackArray* tracks=NULL; + AliHLTTPCTrackletData* inPtr=NULL; + + for (int ndx=0; ndx=0; ndx++) { + iter = blocks+ndx; + if ( iter->fDataType == AliHLTTPCDefinitions::gkTrackSegmentsDataType ) { + if (tracks==NULL) { + tracks=new AliHLTTPCTrackArray; + if (tracks) { + inPtr=(AliHLTTPCTrackletData*)iter->fPtr; + HLTDebug("reading block %d: %d tracklets", ndx, inPtr->fTrackletCnt); + tracks->FillTracks(inPtr->fTrackletCnt, inPtr->fTracklets); + if ((iResult=Tracks2ESD(tracks, pESD))>=0) { + pTree->Fill(); + } + } else { + iResult=-ENOMEM; + } + } else { + HLTWarning("can not process more than one track segment data block, " + "please put a track merger in between"); + break; // don't print the warning again + } + } + } + + + fESD=NULL; + delete pESD; + } else { + iResult=-ENOMEM; + } + } + return iResult; +} + +int AliHLTTPCEsdWriterComponent::ScanArgument(int argc, const char** argv) +{ + int iResult=AliHLTRootFileWriterComponent::ScanArgument(argc, argv); + return iResult; +} + +int AliHLTTPCEsdWriterComponent::Tracks2ESD(AliHLTTPCTrackArray* pTracks, AliESD* pESD) +{ + int iResult=0; + if (pTracks && pESD) { + HLTDebug("converting %d tracks from track array", pTracks->GetNTracks()); + for (int i=0; iGetNTracks() && iResult>=0; i++) { + AliHLTTPCTrack* pTrack=(*pTracks)[i]; + if (pTrack) { + int iLocal=pTrack->Convert2AliKalmanTrack(); + if (iLocal>=0) { + AliESDtrack iotrack; + iotrack.UpdateTrackParams(pTrack,AliESDtrack::kTPCin); + iotrack.SetTPCPoints(pTrack->GetPoints()); + pESD->AddTrack(&iotrack); + } else { + HLTError("conversion to AliKalmanTrack failed for track %d of %d", i, pTracks->GetNTracks()); + } + } else { + HLTError("internal missmatch in array"); + iResult=-EFAULT; + } + } + + } else { + iResult=-EINVAL; + } + return iResult; +} diff --git a/HLT/TPCLib/AliHLTTPCEsdWriterComponent.h b/HLT/TPCLib/AliHLTTPCEsdWriterComponent.h new file mode 100644 index 00000000000..84b9b381823 --- /dev/null +++ b/HLT/TPCLib/AliHLTTPCEsdWriterComponent.h @@ -0,0 +1,100 @@ +// @(#) $Id$ + +#ifndef ALIHLTTPCESDWRITERCOMPONENT_H +#define ALIHLTTPCESDWRITERCOMPONENT_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/** @file AliHLTTPCEsdWriterComponent.h + @author Matthias Richter + @date + @brief Writer component to store tracks of the HLT TPC conformal + mapping tracker in the AliESD format + + */ +#include "AliHLTRootFileWriterComponent.h" + +// forward declarations +class TTree; +class AliESD; +class AliHLTTPCTrackArray; + +/** + * @class AliHLTRootFileWriterComponent + * @see AliHLTFileWriter for parameters + */ +class AliHLTTPCEsdWriterComponent : public AliHLTRootFileWriterComponent +{ + public: + /** standard constructor */ + AliHLTTPCEsdWriterComponent(); + /** destructor */ + ~AliHLTTPCEsdWriterComponent(); + + /** + * The id of the component. + * @return component id (string) + */ + const char* GetComponentID() {return "TPCEsdWriter";}; + + /** + * Spawn function. + * @return new class instance + */ + AliHLTComponent* Spawn() {return new AliHLTTPCEsdWriterComponent;} + + protected: + /** + * Data processing method for the component. + * The function can be overloaded by specific ROOT file writer + * components. + * @param evtData event data structure + * @param blocks input data block descriptors + * @param trigData trigger data structure + */ + virtual int DumpEvent( const AliHLTComponentEventData& evtData, + const AliHLTComponentBlockData* blocks, + AliHLTComponentTriggerData& trigData ); + + /** + * Scan one argument and adjacent parameters. + * @param argc size of the argument array + * @param argv agument array for component initialization + * @return number of processed members of the argv
+ * -EINVAL unknown argument
+ * -EPROTO parameter for argument missing
+ */ + int ScanArgument(int argc, const char** argv); + + private: + /** + * Init the writer. + * The DoInit function is not available for this child class. InitWriter is the + * corresponding function for classes derived from AliHLTFileWriter. + */ + int InitWriter(); + + /** + * Init the writer. + * The DoDeinit function is not available for this child class. CloseWriter is the + * corresponding function for classes derived from AliHLTFileWriter. + */ + int CloseWriter(); + + /** + * Covert tracks to AliTPCtracks (AliKalmanTracks) and add them to ESD. + * @param pTracks array of tracks + * @param pESD pointer to ESD + * @return neg. error code if failed + */ + int Tracks2ESD(AliHLTTPCTrackArray* pTracks, AliESD* pESD); + + /** the ESD tree */ + TTree* fTree; //! transient value + + /** the ESD */ + AliESD* fESD; //! transient value + + ClassDef(AliHLTTPCEsdWriterComponent, 0) +}; +#endif diff --git a/HLT/TPCLib/AliHLTTPCGlobalMergerComponent.h b/HLT/TPCLib/AliHLTTPCGlobalMergerComponent.h index 97722c95ba1..f855cf6e87c 100644 --- a/HLT/TPCLib/AliHLTTPCGlobalMergerComponent.h +++ b/HLT/TPCLib/AliHLTTPCGlobalMergerComponent.h @@ -47,8 +47,8 @@ class AliHLTTPCGlobalMergerComponent : public AliHLTProcessor private: - AliHLTTPCGlobalMerger* fGlobalMerger; - AliHLTTPCVertex* fVertex; + AliHLTTPCGlobalMerger* fGlobalMerger; //! + AliHLTTPCVertex* fVertex; //! struct SliceData { diff --git a/HLT/TPCLib/AliHLTTPCPad.cxx b/HLT/TPCLib/AliHLTTPCPad.cxx index 43fb9f76265..8dfa69a2b05 100644 --- a/HLT/TPCLib/AliHLTTPCPad.cxx +++ b/HLT/TPCLib/AliHLTTPCPad.cxx @@ -163,12 +163,12 @@ Int_t AliHLTTPCPad::CalculateBaseLine(Int_t reqMinCount) if (fpRawData[i]>=0) AddBaseLineValue(i, fpRawData[i]); if (fCount>0 && fCount>=reqMinCount && fCount>=fTotal/2) { fAverage=fSum/fCount; - HLTDebug("new average %d", fAverage); + //HLTDebug("new average %d", fAverage); } else { - HLTDebug("baseline re-eveluation skipped because of to few " - "contributing bins: total=%d, contributing=%d, req=%d" - "\ndata might be already zero suppressed" - , fTotal, fCount, reqMinCount); +// HLTDebug("baseline re-eveluation skipped because of to few " +// "contributing bins: total=%d, contributing=%d, req=%d" +// "\ndata might be already zero suppressed" +// , fTotal, fCount, reqMinCount); iResult=-ENODATA; } fCount=0;fSum=-1; @@ -188,9 +188,9 @@ Int_t AliHLTTPCPad::CalculateBaseLine(Int_t reqMinCount) fAverage=avBackup; } } else { - HLTDebug("baseline calculation skipped because of to few contributing " - "bins: total=%d, contributing=%d, required=%d \ndata might be " - "already zero suppressed", fTotal, fCount, reqMinCount); +// HLTDebug("baseline calculation skipped because of to few contributing " +// "bins: total=%d, contributing=%d, required=%d \ndata might be " +// "already zero suppressed", fTotal, fCount, reqMinCount); } return iResult; @@ -249,9 +249,9 @@ Int_t AliHLTTPCPad::AddBaseLineValue(Int_t bin, AliHLTTPCSignal_t value) fBLMinBin=bin; } } else { - HLTDebug("ignoring value %d (bin %d) for base line calculation " - "(current average is %d)", - value, bin, fAverage); +// HLTDebug("ignoring value %d (bin %d) for base line calculation " +// "(current average is %d)", +// value, bin, fAverage); } } return iResult; diff --git a/HLT/TPCLib/AliHLTTPCTrack.cxx b/HLT/TPCLib/AliHLTTPCTrack.cxx index ddea52d63ff..37cc91cd408 100644 --- a/HLT/TPCLib/AliHLTTPCTrack.cxx +++ b/HLT/TPCLib/AliHLTTPCTrack.cxx @@ -1,8 +1,27 @@ // @(#) $Id$ // Original: AliHLTTrack.cxx,v 1.32 2005/06/14 10:55:21 cvetan -// Author: Anders Vestbo , Uli Frankenfeld -//*-- Copyright © ALICE HLT Group +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Authors: Matthias Richter * + * Timm Steinbeck * + * for The ALICE Off-line 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 AliHLTTPCTrack.cxx + @author Anders Vestbo, Uli Frankenfeld, Matthias Richter + @date + @brief HLT TPC track implementation (conformal mapping) */ + #include "AliHLTTPCLogging.h" #include "AliHLTTPCTrack.h" @@ -14,18 +33,6 @@ using namespace std; #endif -/** \class AliHLTTPCTrack -//
-//_____________________________________________________________
-// AliHLTTPCTrack
-//
-// Track base class
-//Begin_Html
-//
-//End_Html
-
-*/ - ClassImp(AliHLTTPCTrack) @@ -64,7 +71,7 @@ AliHLTTPCTrack::AliHLTTPCTrack() fPointPsi=0; } -void AliHLTTPCTrack::Set(AliHLTTPCTrack *tpt) +void AliHLTTPCTrack::Copy(AliHLTTPCTrack *tpt) { //setter SetRowRange(tpt->GetFirstRow(),tpt->GetLastRow()); @@ -618,3 +625,56 @@ void AliHLTTPCTrack::Print() const // END ################################################# MODIFIY JMT } + +int AliHLTTPCTrack::Convert2AliKalmanTrack() +{ + int iResult=0; + // The method has been copied from AliHLTHoughKalmanTrack and adapted + // to the TPC conformal mapping track parametrization + + SetChi2(0.); + SetNumberOfClusters(GetLastRow()-GetFirstRow()); + SetLabel(GetMCid()); + SetFakeRatio(0.); + SetMass(0.13957); // just a guess + + fdEdx=0; + Double_t alpha = fmod((GetSector()+0.5)*(2*TMath::Pi()/18),2*TMath::Pi()); + if (alpha < -TMath::Pi()) alpha += 2*TMath::Pi(); + else if (alpha >= TMath::Pi()) alpha -= 2*TMath::Pi(); + + Double_t xhit=GetFirstPointX(); + Double_t yhit=GetFirstPointY(); + Double_t zhit=GetFirstPointZ(); + Double_t psi = GetPsi(); + Double_t kappa = GetKappa(); + Double_t radius = GetRadius(); + Double_t centerx = GetCenterX(); + + Double_t tanl = GetTgl(); + + Double_t cnv=1.; + // TODO: think about how to get the magnetic field + //Double_t cnv=1./(GetBz()*kB2C); + + //covariance matrix + Double_t cov[15]={ + 0., + 0., 0., + 0., 0., 0., + 0., 0., 0., 0., + 0., 0., 0., 0., 0. + }; + + Double_t xx[5]; + xx[0] = yhit; + xx[1] = zhit; + xx[2] = (xhit-centerx)/radius; + xx[3] = tanl; + xx[4] = kappa*cnv; + // the Set function was not available in earlier versions, check required in + // configure.ac + //Set(xhit,alpha,xx,cov); + + return iResult; +} diff --git a/HLT/TPCLib/AliHLTTPCTrack.h b/HLT/TPCLib/AliHLTTPCTrack.h index bc766a8f764..5e3fa751e9c 100644 --- a/HLT/TPCLib/AliHLTTPCTrack.h +++ b/HLT/TPCLib/AliHLTTPCTrack.h @@ -1,20 +1,57 @@ +// XEmacs -*-C++-*- // @(#) $Id$ // Original: AliHLTTrack.h,v 1.18 2005/03/31 04:48:58 cvetan + #ifndef ALIHLTTPCTRACK_H #define ALIHLTTPCTRACK_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/** @file AliHLTTPCTrack.h + @author Anders Vestbo, Uli Frankenfeld, Matthias Richter + @date + @brief HLT TPC track base class (conformal mapping) +*/ + +#include "AliTPCtrack.h" + class AliHLTTPCVertex; class AliHLTTPCSpacePointData; -class AliHLTTPCTrack { +/** + * @class AliHLTTPCTrack + * This class implements the representation of a TPC track, used by the + * HLT conformal mapping track finder.
+ * It was originally separated from the offline TPC track class, but in + * order to adjust the output format to the offline ESD, AliHLTTPCTrack + * now inherits from AliHLTtrack. + */ +class AliHLTTPCTrack : public AliTPCtrack { public: AliHLTTPCTrack(); virtual ~AliHLTTPCTrack(); - virtual void Set(AliHLTTPCTrack* track); + /** + * Copy track parameters. + * @param track pointer to source track + */ + virtual void Copy(AliHLTTPCTrack* track); + + /** + * Compare two tracks by the number of hits + * @return 0 if equal number of hits, + * 1 if this > track + * -1 if this < track + */ virtual Int_t Compare(const AliHLTTPCTrack *track) const; + + /** + * Fit the assigned spacepoints to a helix. + * The function sets teh track parameters. + */ virtual void CalculateHelix(); Bool_t CalculateReferencePoint(Double_t angle,Double_t radius=132);//Calculate Reference Point @@ -109,6 +146,15 @@ class AliHLTTPCTrack { void SetCharge(Int_t f) {fQ = f;} void ComesFromMainVertex(Bool_t f) {fFromMainVertex = f;} + /** + * Convert all track parameters to the format of AliKalmanTrack + * The AliKalmanTrack class implements the track parametrization for offline ITS, TPC + * and TRD tracking. The function calculates and sets the parameters of the + * parent class (Note: AliHLTTPCTrack inherits from AliTPCtrack and thus + * AliKalmanTrack). + */ + int Convert2AliKalmanTrack(); + private: Int_t fNHits; //Number of hits @@ -154,6 +200,6 @@ class AliHLTTPCTrack { Bool_t IsPoint(Bool_t ispoint) {fIsPoint = ispoint;return fIsPoint;} - ClassDef(AliHLTTPCTrack,1) //Base track class + ClassDef(AliHLTTPCTrack,2) //Base track class }; #endif diff --git a/HLT/TPCLib/AliHLTTPCTrackArray.cxx b/HLT/TPCLib/AliHLTTPCTrackArray.cxx index 4e8d79a4f9b..11a0620bfa7 100644 --- a/HLT/TPCLib/AliHLTTPCTrackArray.cxx +++ b/HLT/TPCLib/AliHLTTPCTrackArray.cxx @@ -433,7 +433,7 @@ void AliHLTTPCTrackArray::AddLast(AliHLTTPCTrack *track) { //add track to last position AliHLTTPCTrack *tpt = NextTrack(); - tpt->Set(track); + tpt->Copy(track); } @@ -454,7 +454,7 @@ void AliHLTTPCTrackArray::AddTracks(AliHLTTPCTrackArray *newtrack,Bool_t remove_ if(remove_old) newtrack->Remove(i); AliHLTTPCTrack *track = NextTrack(); - track->Set(tpt); + track->Copy(tpt); if(slice>=0) track->Rotate(slice); //Rotate track to global coordinates /* @@ -465,7 +465,7 @@ void AliHLTTPCTrackArray::AddTracks(AliHLTTPCTrackArray *newtrack,Bool_t remove_ else #endif track = NextTrack(); - track->Set(tpt); + track->Copy(tpt); */ } } @@ -570,4 +570,8 @@ Int_t AliHLTTPCTrackArray::TrackCompare(AliHLTTPCTrack *a, AliHLTTPCTrack *b) co */ } - +AliHLTTPCTrack* AliHLTTPCTrackArray::operator[](int index) +{ + if (index $@ @echo '//!!! DO NOT EDIT THIS FILE !!!' >> $@ @echo '//add further class definitions to the CLASS_HDRS variable in Makefile.am' >> $@ -- 2.39.3