/************************************************************************
**
** ALICE HLT project
** Copyright (c) 2005
**
** This file is property of and copyright by the Experimental Nuclear
** Physics Group, Dep. of Physics and Technology
** University of Bergen, Norway, 2004
** This file has been written by Matthias Richter,
** Matthias.Richter@ift.uib.no
**
** 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 tutorial.c
@author Matthias Richter
@date
@brief HLT examples and tutorial. */
/**
@defgroup alihlt_tutorial HLT examples and tutorial
The HLT analysis components can be run either in the AliRoot
framework (simulation and/or reconstruction) or the HLT online
framework.
We think of the HLT as a 'black box' with data input and output. In
addition there is access to calibration data from OCDB (or the local
HLT copy HCDB). All components can only work on the data they get as
input. As the different detector algorithms/components will run in
separate processes and even on different machines, no data exchange
is possible via global data structures and variables.
HLT chains in the AliRoot framework are described by means of
AliHLTConfiguration.
-# @ref tut_hltsystem
-# @ref tut_load_libraries
-# @ref tut_dummy_chain
-# @ref tut_tpc_sector
-# @ref tut_simulation
-# @ref tut_reconstruction
-# @ref tut_module_agent
-# @ref tut_reconstruction_sample
-# @ref tut_reconstruction_custom
-# @ref tut_alirawreaderhlt
-# @ref tut_macros
@section tut_hltsystem Running Components in the HLT System
@subsection tut_load_libraries Library setup
Component libraries must be loader via the AliHLTComponentHandler
or AliHLTSystem::LoadComponentLibraries. You can run the following
macro from the AliRoot promt.
{ AliHLTSystem gHLT; gHLT.LoadComponentLibraries("libAliHLTUtil.so"); }
{ 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, "-datatype 'DUMMYDAT' 'SMPL' -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(); }@note You have to specify a real file name instead of \em some-data.dat
{ AliHLTSystem gHLT; // load the component library gHLT.LoadComponentLibraries("libAliHLTUtil.so libAliHLTRCU.so libAliHLTTPC.so"); // data source components AliHLTConfiguration fp0("fp0", "FilePublisher", NULL, "-datatype 'DDL_RAW ' 'TPC ' -dataspec 0x00000000 " "-datafile TPC_768.ddl"); AliHLTConfiguration fp1("fp1", "FilePublisher", NULL, "-datatype 'DDL_RAW ' 'TPC ' -dataspec 0x00000101 " "-datafile TPC_769.ddl"); AliHLTConfiguration fp2("fp2", "FilePublisher", NULL, "-datatype 'DDL_RAW ' 'TPC ' -dataspec 0x00000202 " "-datafile TPC_840.ddl"); AliHLTConfiguration fp3("fp3", "FilePublisher", NULL, "-datatype 'DDL_RAW ' 'TPC ' -dataspec 0x00000303 " "-datafile TPC_841.ddl"); AliHLTConfiguration fp4("fp4", "FilePublisher", NULL, "-datatype 'DDL_RAW ' 'TPC ' -dataspec 0x00000404 " "-datafile TPC_842.ddl"); AliHLTConfiguration fp5("fp5", "FilePublisher", NULL, "-datatype 'DDL_RAW ' 'TPC ' -dataspec 0x00000505 " "-datafile TPC_843.ddl"); // cluster finders AliHLTConfiguration cf0("cf0", "TPCClusterFinderPacked", "fp0", "pp-run rawreadermode 4 timebins 446"); AliHLTConfiguration cf1("cf1", "TPCClusterFinderPacked", "fp1", "pp-run rawreadermode 4 timebins 446"); AliHLTConfiguration cf2("cf2", "TPCClusterFinderPacked", "fp2", "pp-run rawreadermode 4 timebins 446"); AliHLTConfiguration cf3("cf3", "TPCClusterFinderPacked", "fp3", "pp-run rawreadermode 4 timebins 446"); AliHLTConfiguration cf4("cf4", "TPCClusterFinderPacked", "fp4", "pp-run rawreadermode 4 timebins 446"); AliHLTConfiguration cf5("cf5", "TPCClusterFinderPacked", "fp5", "pp-run rawreadermode 4 timebins 446"); // tracker AliHLTConfiguration tracker("tracker", "TPCSliceTracker", "cf0 cf1 cf2 cf3 cf4 cf5", "-pp-run -bfield 0.5"); // the data sink component AliHLTConfiguration writer("writer", "TPCEsdWriter", "tracker", "-datafile AliHLTTPCESDs.root"); gHLT.BuildTaskList("writer"); gHLT.Run(); }@section tut_reconstruction AliRoot reconstruction The integration into the AliRoot reconstruction works via the @ref AliHLTReconstructor plugin. The intention is to run HLT analysis chains in AliRoot in the same way as in the online framework, i.e. the full components are run also from the offline framework rather than just the algorithm hooked on by a special interface class. By this one achieves the highest possible compatibility. The AliRoot reconstruction consists mainly of three steps: -# local event reconstruction: this is usually the place for digit/raw data conversion to clusters/space points. All the events are processed at once. If HLT analysis chain are executed in the local event reconstruction, the chain must contain an output recorder as the ESD is filled on an event by event basis and the corresponding method called later. -# event reconstruction: this is the reconstruction on an event by event basis. Immediately after the reconstruction, the FillESD method is called. -# ESD fill: the reconstructed event is written to the ESD. Regarding the HLT, all analysis is supposed to run on-line on the HLT farm. Thus, only the processing of the HLTOUT data is necessary during the default reconstruction. However, it is possible to run HLT chains embedded into AliReconstruction mainly for the purpose of debugging and the development cycle. The actual chains to be run and the HLTOUT handlers to be applied depend on the HLT library modules which are loaded to the system. There is a default collection of libraries defined in AliHLTSystem::fgkHLTDefaultLibs. The default libraries are loaded if nothing else is specified. The libraries implement \em agents (AliHLTModuleAgent childs) describing the properties of a module. A specific library can be chosen like (provided you have a simulated event in the current directory):
{ AliReconstruction rec; // the reconstruction instance rec.SetRunLocalReconstruction("HLT"); // run local rec only for HLT rec.SetRunTracking(""); // switch off tracking rec.SetFillESD("HLT"); // rec.SetOption("HLT", "libAliHLTSample.so loglevel=0x7c"); rec.Run(); }@subsection tut_module_agent The Module Agent Each component library has to implement a module agent in order to be hooked up to the AliRoot reconstruction or simulation. The agent defines the features of the libraries and the configurations to be run during the different steps of the reconstruction. The agent - can register all components of the library. This is an alternative to the component registration via global objects (see @ref alihltcomponent-handling). - registers HLT configurations (see @ref AliHLTConfiguration) - specifies the configurations to be run - specifies additional component libraries required to run the configurations. - provides a preprocessor (see AliHLTModulePreprocessor / AliHLTPreprocessor) - provides handlers and handler descriptions for HLTOUT data blocks. Finally, one global object of the module agent has to be specified in the source code. All registration and integration into the HLT system is carried out automatically. @see @ref AliHLTModuleAgent for the interface description
{ AliReconstruction rec; // the reconstruction instance rec.SetInput("./"); // to be independent of galice.root rec.SetLoadAlignFromCDB(kFALSE); rec.SetFillTriggerESD(kFALSE); rec.SetRunQA(kFALSE); rec.SetRunVertexFinder(kFALSE); rec.SetRunLocalReconstruction("HLT"); // run local rec only for HLT rec.SetRunTracking(""); // switch off tracking rec.SetFillESD("HLT"); // rec.SetOption("HLT", "libAliHLTSample.so libAliHLTUtil.so " "config=$ALICE_ROOT/HLT/exa/conf-sample.C " "chains=sink"); //rec.SetEventRange(0,0); rec.Run(); }@see - conf-sample.C @section tut_simulation AliRoot simulation In order to simulate the behavior of HLT analysis chains and to include this functionality, HLT reconstruction can be embedded into AliRoot simulation. As a matter of fact, HLT always reconstructs data, HLT simulation means HLT reconstruction embedded into AliRoot. The HLT simulation is run at the last step of the AliSimulation, the setup to be run depends on the available plugins as described in section @ref tut_reconstruction. The options for the HLT simulation can be set with the AliSimulation::SetRunHLT function.
AliSimulation sim; ... sim.SetRunHLT("libAliHLTSample.so loglevel=0x7c");Options: - config=\em macro
class AliHLTSampleRawDataHandler : public AliHLTOUTHandlerEquId { public: // ... constructors and destructor // overloaded AliHLTOUTHandlerEquId::ProcessData(AliHLTOUT*) int ProcessData(AliHLTOUT* pData); };Alternatively the AliHLTOUTHandlerEquId can be used directly. It implements a default processing. -# Adjust module agent The module agent needs to provide the handler and the description of the handler and has to implement the following functions:
// see AliHLTAgentSample::GetHandlerDescription() int GetHandlerDescription(AliHLTComponentDataType, AliHLTUInt32_t, AliHLTOUTHandlerDesc&) const; // see AliHLTAgentSample::GetOutputHandler() AliHLTOUTHandler* GetOutputHandler(AliHLTComponentDataType, AliHLTUInt32_t); // see AliHLTAgentSample::DeleteOutputHandler() int DeleteOutputHandler(AliHLTOUTHandler*);-# Set the HLT input The AliReconstruction class handles the redirection transparently by use of the AliRawReaderHLT.
AliReconstruction rec; // .... rec.SetUseHLTData("ITSSDD");-# Run Run the reconstruction as normal @see - AliHLTReconstructor - AliRawReaderHLT - rec-from-hltout.C