From 5aebebf7016af142c5a0ae67db37b3559489c571 Mon Sep 17 00:00:00 2001 From: richterm Date: Fri, 25 Apr 2008 22:01:38 +0000 Subject: [PATCH] - tutorial and sample macros updated - added examples for the AliHLTRawReaderPublisherComponent - bugfix in the TPCOfflineClustererComponent: type caused wrong boundery check --- HLT/SampleLib/tutorial.c | 28 +++- .../AliHLTTPCOfflineClustererComponent.cxx | 6 +- HLT/exa/extract-ddlraw.C | 152 ++++++++++++++++++ HLT/exa/monitoring.C | 2 +- HLT/exa/publish-rawreader-data.C | 90 +++++++++++ HLT/exa/sample-component1.C | 2 +- 6 files changed, 268 insertions(+), 12 deletions(-) create mode 100644 HLT/exa/extract-ddlraw.C create mode 100644 HLT/exa/publish-rawreader-data.C diff --git a/HLT/SampleLib/tutorial.c b/HLT/SampleLib/tutorial.c index ee2d15914e3..d952cdfc4c9 100644 --- a/HLT/SampleLib/tutorial.c +++ b/HLT/SampleLib/tutorial.c @@ -60,9 +60,23 @@ You can run the following macro from the AliRoot promt. { AliHLTSystem gHLT; gHLT.LoadComponentLibraries("libAliHLTUtil.so libAliHLTSample.so"); + // The AliHLTFilePublisher (component Id \em 'FilePublisher' provides + // the given file (see AliHLTFilePublisher for more options) to the + // subsequent components in the chain. AliHLTConfiguration publisher("fp1", "FilePublisher", NULL, "-datafile some-data.dat"); + + // The AliHLTDummyComponent (Id \em 'Dummy') just forwards a certain + // fraction of the input to the output or just repeats the input data + // if percentage > 100 AliHLTConfiguration copy("cp", "Dummy", "fp1", "output_percentage 80"); + + // The AliHLTFileWriter (Id 'FileWriter') is a data sink. It writes + // all incoming data blocks to files. Several options available. AliHLTConfiguration sink1("sink1", "FileWriter", "cp", NULL); + + // here you specify the top most configuration of the chain. The + // configuration depends on all the parents. The task lisy is build + // according to that. gHLT.BuildTaskList("sink1"); gHLT.Run(); } @@ -78,20 +92,20 @@ directory. { AliHLTSystem gHLT; // load the component library - gHLT.LoadComponentLibraries("libAliHLTUtil.so libAliHLTTPC.so"); + gHLT.LoadComponentLibraries("libAliHLTUtil.so libAliHLTRCU.so libAliHLTTPC.so"); // data source components - AliHLTConfiguration fp0("fp0", "FilePublisher", NULL, "-datatype DDL_RWPK 'TPC ' -dataspec 0x00000000" + AliHLTConfiguration fp0("fp0", "FilePublisher", NULL, "-datatype 'DDL_RAW ' 'TPC ' -dataspec 0x00000000" "-datafile TPC_768.ddl"); - AliHLTConfiguration fp1("fp1", "FilePublisher", NULL, "-datatype DDL_RWPK 'TPC ' -dataspec 0x00000101" + AliHLTConfiguration fp1("fp1", "FilePublisher", NULL, "-datatype 'DDL_RAW ' 'TPC ' -dataspec 0x00000101" "-datafile TPC_769.ddl"); - AliHLTConfiguration fp2("fp2", "FilePublisher", NULL, "-datatype DDL_RWPK 'TPC ' -dataspec 0x00000202" + AliHLTConfiguration fp2("fp2", "FilePublisher", NULL, "-datatype 'DDL_RAW ' 'TPC ' -dataspec 0x00000202" "-datafile TPC_840.ddl"); - AliHLTConfiguration fp3("fp3", "FilePublisher", NULL, "-datatype DDL_RWPK 'TPC ' -dataspec 0x00000303" + AliHLTConfiguration fp3("fp3", "FilePublisher", NULL, "-datatype 'DDL_RAW ' 'TPC ' -dataspec 0x00000303" "-datafile TPC_841.ddl"); - AliHLTConfiguration fp4("fp4", "FilePublisher", NULL, "-datatype DDL_RWPK 'TPC ' -dataspec 0x00000404" + AliHLTConfiguration fp4("fp4", "FilePublisher", NULL, "-datatype 'DDL_RAW ' 'TPC ' -dataspec 0x00000404" "-datafile TPC_842.ddl"); - AliHLTConfiguration fp5("fp5", "FilePublisher", NULL, "-datatype DDL_RWPK 'TPC ' -dataspec 0x00000505" + AliHLTConfiguration fp5("fp5", "FilePublisher", NULL, "-datatype 'DDL_RAW ' 'TPC ' -dataspec 0x00000505" "-datafile TPC_843.ddl"); // cluster finders diff --git a/HLT/TPCLib/offline/AliHLTTPCOfflineClustererComponent.cxx b/HLT/TPCLib/offline/AliHLTTPCOfflineClustererComponent.cxx index 1df2e0a38de..0beb354d925 100644 --- a/HLT/TPCLib/offline/AliHLTTPCOfflineClustererComponent.cxx +++ b/HLT/TPCLib/offline/AliHLTTPCOfflineClustererComponent.cxx @@ -124,11 +124,11 @@ int AliHLTTPCOfflineClustererComponent::DoEvent( const AliHLTComponentEventData& int patch=AliHLTTPCDefinitions::GetMinPatchNr(pBlock->fSpecification); if (slice!=AliHLTTPCDefinitions::GetMaxSliceNr(pBlock->fSpecification) || patch!=AliHLTTPCDefinitions::GetMaxPatchNr(pBlock->fSpecification)) { - HLTError("ambiguous readout partition (specification 0x%80x), skipping input block", pBlock->fSpecification); + HLTError("ambiguous readout partition (specification 0x%08x), skipping input block", pBlock->fSpecification); break; } - if (slice<0 || slice>35 || patch<0 || slice>5) { - HLTError("invalid readout partition %d/%d (specification 0x%80x, skipping input block", slice, patch, pBlock->fSpecification); + if (slice<0 || slice>35 || patch<0 || patch>5) { + HLTError("invalid readout partition %d/%d (specification 0x%08x, skipping input block", slice, patch, pBlock->fSpecification); break; } diff --git a/HLT/exa/extract-ddlraw.C b/HLT/exa/extract-ddlraw.C new file mode 100644 index 00000000000..3860b18c5be --- /dev/null +++ b/HLT/exa/extract-ddlraw.C @@ -0,0 +1,152 @@ +// $Id$ +/** + * @file extract-ddlraw.C + * @brief Tool to extract DDL raw data. + * + * Usage: + *
+ *   aliroot -b -q 'extract-ddlraw.C("raw.root", 768, 769)' | tee extract-ddlraw.log
+ * 
+ * + * This macro is an example for the AliHLTRawReaderPublisherComponent. + * It extracts the DDL payload from an AliRawReader in a given equipment + * range. Input can be either a root file or the path to the directory + * containing the 'rawx' sub folders. + * + * A light-weight AliReconstruction-like setup creates the appropriate + * RawReader for the specified input and uses the standard AliHLTReconstructor + * to run a small HLT chain. The chain utilizes the AliRawReaderPublisher + * to extract the payload of the equipments and writes this to files. + * + * @note In this example the AliHLTRawReaderPublisherComponent does not set any data + * type nor specification for the published data blocks. Please remember + * to provide appropriate arguments via '-datatype' and '-dataspec' + * arguments (see AliHLTRawReaderPublisherComponent). + * + * @author Matthias.Richter@ift.uib.no + * @ingroup alihlt_tutorial + */ +void extract_ddlraw(const char* input, int iMinDDLno, int iMaxDDLno) +{ + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // + // some defaults + const char* baseName="RAW.ddl"; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // + // setup of the RawReader + if (!input) { + cerr << "invalid path" << endl; + cerr << "usage: aliroot -b -q 'extract-ddlraw.C(\"raw.root\", 768, 769)'" << endl; + return; + } + + AliRawReader* pRawReader=AliRawReader::Create(input); + if (!pRawReader) { + cout << "can not open RawReader for file " << input << endl; + return; + } + if (!pRawReader->NextEvent()) { + cerr << "no events available" << endl; + return; + } + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // + // setup of the HLT system + gSystem->Load("libHLTrec"); + AliHLTSystem* pHLT=AliHLTReconstructorBase::GetInstance(); + if (!pHLT) { + cerr << "fatal error: can not get HLT instance" << endl; + } + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // + // the configuration chain + // we show two possible configurations: + // 1. having one publisher for each ddl, the configurations are created + // in a loop + // 2. all in one publisher + // can be easily switched with the following + bool bAllInOne=false; + + TString writerInput; + TString arg; + + if (!bAllInOne) { + // create one publisher for each ddl + for (int ddlno=iMinDDLno; ddlno<=iMaxDDLno; ddlno++) { + TString arg, publisher; + + // raw data publisher components + arg.Form("-minid %d -skipempty", ddlno); + publisher.Form("DP_%d", ddlno); + // see AliHLTRawReaderPublisherComponent + AliHLTConfiguration pubconf(publisher.Data(), "AliRawReaderPublisher", NULL , arg.Data()); + + if (!writerInput.IsNull()) writerInput+=" "; + writerInput+=publisher; + } + } else { + // publish all ddls by the same component, this is much more + // effective as it avoids repeated parsing through the data + arg.Form("-minid %d -maxid %d -skipempty", iMinDDLno, iMaxDDLno); + // see AliHLTRawReaderPublisherComponent + AliHLTConfiguration pubconf("publisher", "AliRawReaderPublisher", NULL , arg.Data()); + if (!writerInput.IsNull()) writerInput+=" "; + writerInput+="publisher"; + } + + // the writer configuration is the same for both + arg.Form("-specfmt=_%%d -subdir=raw%%d -blcknofmt= -idfmt= -datafile %s", baseName); + // see AliHLTFileWriter + AliHLTConfiguration fwconf("sink1", "FileWriter" , writerInput.Data(), arg.Data()); + + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // + // the reconstructor setup + AliHLTReconstructor hltRec; + hltRec.SetOption("libAliHLTUtil.so loglevel=0x7c chains=sink1"); + if (hltRec.Init()<0) { + cerr << "initialization of reconstructor failed" << endl; + return; + } + + // this is just a dummy ESD to provide valid parameters to the + // reconstructor + AliESDEvent* pESD = new AliESDEvent; + pESD->CreateStdContent(); + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // + // the reconstruction loop + Int_t event=0; + UChar_t* pData=NULL; + pRawReader->RewindEvents(); + while (pRawReader->NextEvent()) { + cout << "=======================================================" << endl; + cout << "event " << event << endl; + cout << "-------------------------------------------------------" << endl; + pRawReader->Reset(); + hltRec.FillESD(pRawReader, NULL, pESD); + event++; + } + + delete pESD; +} + +void extract_ddlraw() +{ + cerr << "===============================================================" << endl; + cerr << "usage: aliroot -b -q 'extract-ddlraw.C(\"raw.root\", 768, 769)'" << endl << endl; + cerr << "please provide input, min and max equipment id" << endl; + cerr << "===============================================================" << endl; +} diff --git a/HLT/exa/monitoring.C b/HLT/exa/monitoring.C index ab13d1a106b..5d12143c81e 100644 --- a/HLT/exa/monitoring.C +++ b/HLT/exa/monitoring.C @@ -33,7 +33,7 @@ //log.SwitchAliLog(0); AliHLTSystem gHLT; - //gHLT.SetGlobalLoggingLevel(0x7c); + gHLT.SetGlobalLoggingLevel(0x7c); // load the component library gHLT.LoadComponentLibraries("libAliHLTUtil.so"); diff --git a/HLT/exa/publish-rawreader-data.C b/HLT/exa/publish-rawreader-data.C new file mode 100644 index 00000000000..2c9fab31a88 --- /dev/null +++ b/HLT/exa/publish-rawreader-data.C @@ -0,0 +1,90 @@ +// $Id$ +/** + * @file publish-rawreader-data.C + * @brief Publish data from the the RawReader provided by the AliReconstruction. + * + * Usage: + *
+ *   aliroot -b -q 'publish-rawreader-data.C("raw.root", 768, 769)' | tee publish-rawreader-data.log
+ * 
+ * + * This macro runs shows a use case of the AliHLTRawReaderPublisherComponent + * An HLT chain is run inside the AliReconstruction and the DDL payload is + * extracted from the AliRawReader in a given equipment range. + * Input can be either a root file or the path to the directory containing + * the 'rawx' sub folders. + * + * @author Matthias.Richter@ift.uib.no + */ + +const char* defaultInput="./"; +const int defaultMinId=768; +const int defaultMaxId=769; + +void publish_rawreader_data(const char* input, int iMinDDLno, int iMaxDDLno) +{ + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // + // some defaults + const char* baseName="RAW.ddl"; + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // + // setup of the reconstruction + if (!input) { + cerr << "invalid path" << endl; + cerr << "usage: aliroot -b -q 'publish-rawreader-data.C(\"raw.root\", 768, 769)'" << endl; + return; + } + + AliReconstruction rec; + rec.SetInput(input); + rec.SetOption("HLT", "libAliHLTUtil.so loglevel=0x7c chains=sink1"); + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // + // setup of the HLT system + gSystem->Load("libHLTrec"); + AliHLTSystem* pHLT=AliHLTReconstructorBase::GetInstance(); + if (!pHLT) { + cerr << "fatal error: can not get HLT instance" << endl; + } + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // + // the configuration chain + TString writerInput; + TString arg; + + arg.Form("-minid %d -maxid %d -skipempty", iMinDDLno, iMaxDDLno); + AliHLTConfiguration pubconf("publisher", "AliRawReaderPublisher", NULL , arg.Data()); + if (!writerInput.IsNull()) writerInput+=" "; + writerInput+="publisher"; + + // the writer configuration + arg.Form("-specfmt=_%%d -subdir=raw%%d -blocknofmt= -idfmt= -datafile %s", baseName); + AliHLTConfiguration fwconf("sink1", "FileWriter" , writerInput.Data(), arg.Data()); + + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////// + // + // the reconstruction loop + rec.SetRunLocalReconstruction("HLT"); + rec.SetRunReconstruction("HLT"); + rec.SetRunTracking(""); + rec.SetFillESD("HLT"); + rec.SetRunVertexFinder(kFALSE); + rec.SetLoadAlignFromCDB(0); + rec.Run(); +} + +void publish_rawreader_data() +{ + cout << "runnig from defaults: input " << defaultInput << " " << defaultMinId << "-" << defaultMaxId << endl; + publish_rawreader_data(defaultInput, defaultMinId, defaultMaxId); +} diff --git a/HLT/exa/sample-component1.C b/HLT/exa/sample-component1.C index 231bc107998..32ece7e9a82 100644 --- a/HLT/exa/sample-component1.C +++ b/HLT/exa/sample-component1.C @@ -82,7 +82,7 @@ //log.SwitchAliLog(0); AliHLTSystem gHLT; - //gHLT.SetGlobalLoggingLevel(0x7c); + gHLT.SetGlobalLoggingLevel(0x7c); // load the component library gHLT.LoadComponentLibraries("libAliHLTUtil.so"); -- 2.43.0