--- /dev/null
+// $Id$
+
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project *
+//* ALICE Experiment at CERN, All rights reserved. *
+//* *
+//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
+//* for The ALICE HLT 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 AliHLTSampleCalibrationComponent.cxx
+// @author Matthias Richter
+// @date 2010-04-26
+// @brief A sample calibration component for the HLT.
+// @ingroup alihlt_tutorial
+
+#if __GNUC__== 3
+using namespace std;
+#endif
+
+#include "AliHLTSampleCalibrationComponent.h"
+#include "AliHLTReadoutList.h"
+#include "AliLog.h"
+#include "TMap.h"
+#include "TObjString.h"
+#include "TH1S.h"
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTSampleCalibrationComponent)
+
+/** one global instance used for registration */
+AliHLTSampleCalibrationComponent gAliHLTSampleCalibrationComponent;
+
+AliHLTSampleCalibrationComponent::AliHLTSampleCalibrationComponent()
+ : AliHLTCalibrationProcessor()
+ , fOutputSize(1000)
+ , fHisto(NULL)
+ , fHistoRange(10000)
+{
+ // an example component which implements the ALICE HLT calibration
+ // processor interface
+ //
+ // see header file for class documentation
+ // or
+ // refer to README to build package
+ // or
+ // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+ //
+ // NOTE: all helper classes should be instantiated in DoInit()
+}
+
+AliHLTSampleCalibrationComponent::~AliHLTSampleCalibrationComponent()
+{
+ // destructor
+ //
+ // NOTE: implement proper cleanup in DoDeinit()
+}
+
+const char* AliHLTSampleCalibrationComponent::GetComponentID()
+{
+ // component property: id
+ return "SampleCalibration";
+}
+
+void AliHLTSampleCalibrationComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
+{
+ // component property: list of input data types
+ list.push_back(kAliHLTAnyDataType);
+}
+
+AliHLTComponentDataType AliHLTSampleCalibrationComponent::GetOutputDataType()
+{
+ // component property: output data type
+ return kAliHLTDataTypeFXSCalib|kAliHLTDataOriginSample;
+}
+
+void AliHLTSampleCalibrationComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+{
+ // component property: output size estimator
+ constBase = fOutputSize;
+ inputMultiplier = 0;
+}
+
+void AliHLTSampleCalibrationComponent::GetOCDBObjectDescription( TMap* const targetMap)
+{
+ // Get a list of OCDB object description.
+ // The list of objects is provided in a TMap
+ // - key: complete OCDB path, e.g. GRP/GRP/Data
+ // - value: short description why the object is needed
+ // Key and value objects created inside this class go into ownership of
+ // target TMap.
+ if (!targetMap) return;
+ targetMap->Add(new TObjString("HLT/ConfigSample/SampleCalibration"),
+ new TObjString("configuration object"));
+}
+
+AliHLTComponent* AliHLTSampleCalibrationComponent::Spawn()
+{
+ // Spawn function, return new class instance
+ return new AliHLTSampleCalibrationComponent;
+}
+
+int AliHLTSampleCalibrationComponent::DoInit( int argc, const char** argv )
+{
+ // see header file for class documentation
+ int iResult=0;
+
+ // init stage 1: default values for all data members
+
+ // init stage 2: read configuration object
+ // ScanConfigurationArgument() needs to be implemented
+ TString cdbPath="HLT/ConfigSample/";
+ cdbPath+=GetComponentID();
+ iResult=ConfigureFromCDBTObjString(cdbPath);
+
+ // init stage 3: read the component arguments
+ if (iResult>=0) {
+ iResult=ConfigureFromArgumentString(argc, argv);
+ }
+
+ if (iResult>=0) {
+ // implement the component initialization
+ fHisto=new TH1S("InputSize", "Input block size", 100, 0, fHistoRange);
+ fOutputSize+=EstimateObjectSize(fHisto);
+ }
+
+ if (iResult<0) {
+ // implement cleanup
+ }
+
+ return iResult;
+}
+
+int AliHLTSampleCalibrationComponent::ScanConfigurationArgument(int argc, const char** argv)
+{
+ // Scan configuration arguments
+ // Return the number of processed arguments
+ // -EPROTO if argument format error (e.g. number expected but not found)
+ //
+ // The AliHLTComponent base class implements a parsing loop for argument strings and
+ // arrays of strings which is invoked by ConfigureFromArgumentString/ConfigureFromCDBTObjString
+ // The component needs to implement ScanConfigurationArgument in order to decode the arguments.
+
+ int i=0;
+ TString argument=argv[i];
+
+ if (argument.IsNull()) return 0;
+
+ // -mandatory1 arg
+ if (argument.CompareTo("-mandatory1")==0) {
+ if (++i>=argc) return -EPROTO;
+ HLTInfo("got \'-mandatory1\' argument: %s", argv[i]);
+ return 2; // keyword + 1 argument
+ }
+
+ // -optional1 arg
+ if (argument.CompareTo("-optional1")==0) {
+ if (++i>=argc) return -EPROTO;
+ HLTInfo("got \'-optional1\' argument: %s", argv[i]);
+ return 2; // keyword + 1 argument
+ }
+
+ // -optional2
+ if (argument.CompareTo("-optional2")==0) {
+ HLTInfo("got \'-optional2\' argument");
+ return 1; // only keyword
+ }
+
+ return 0;
+}
+
+int AliHLTSampleCalibrationComponent::DoDeinit()
+{
+ // component cleanup, delete all instances of helper classes here
+ if (fHisto) delete fHisto;
+ fOutputSize=0;
+
+ return 0;
+}
+
+int AliHLTSampleCalibrationComponent::ProcessCalibration(const AliHLTComponentEventData& /*evtData*/,
+ AliHLTComponentTriggerData& /*trigData*/)
+{
+ // event processing function
+
+ // check if this is a data event, there are a couple of special events
+ // which should be ignored for normal processing
+ if (!IsDataEvent()) return 0;
+
+ // loop over input data blocks
+ for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeDDLRaw);
+ pBlock!=NULL; pBlock=GetNextInputBlock()) {
+ HLTInfo("block %s specification 0x%x size %d", DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize);
+ fHisto->Fill(pBlock->fSize);
+ }
+
+ // write the histogram out
+ // this should not be done for every event, however the call can be implemented
+ // like that and the publishing steered by the component argument
+ // '-pushback-period=...'
+ if (PushBack(fHisto, kAliHLTDataTypeHistogram)==-ENOSPC) {
+ // increase the output size estimator
+ // we add the size of the last object, there might be other blocks to
+ // be written in addition to the actual object
+ fOutputSize+=GetLastObjectSize();
+ }
+
+ return 0;
+}
+
+int AliHLTSampleCalibrationComponent::ShipDataToFXS( const AliHLTComponentEventData& evtData,
+ AliHLTComponentTriggerData& trigData)
+{
+ // prepare final result and ship to FXS
+
+ AliHLTReadoutList rdList(AliHLTReadoutList::kHLT);
+ PushToFXS(fHisto, "HLT", "TestHisto", rdList.Buffer());
+
+ return 0;
+}
+
+int AliHLTSampleCalibrationComponent::Reconfigure(const char* cdbEntry, const char* chainId)
+{
+ // reconfigure the component from the specified CDB entry, or default CDB entry
+ HLTInfo("reconfigure '%s' from entry %s", chainId, cdbEntry);
+
+ return 0;
+}
+
+int AliHLTSampleCalibrationComponent::ReadPreprocessorValues(const char* modules)
+{
+ // read the preprocessor values for the detectors in the modules list
+ int iResult=0;
+ TString detectors(modules!=NULL?modules:"");
+ HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());
+ return iResult;
+}
--- /dev/null
+//-*- Mode: C++ -*-
+// $Id$
+#ifndef ALIHLTSAMPLECALIBRATIONCOMPONENT_H
+#define ALIHLTSAMPLECALIBRATIONCOMPONENT_H
+
+//* This file is property of and copyright by the ALICE HLT Project *
+//* ALICE Experiment at CERN, All rights reserved. *
+//* See cxx source for full Copyright notice */
+
+// @file AliHLTSampleCalibrationComponent.h
+// @author Matthias Richter
+// @date 2010-04-26
+// @brief A sample calibration component for the HLT.
+//
+
+#include "AliHLTCalibrationProcessor.h"
+
+class TH1S;
+
+/**
+ * @class AliHLTSampleCalibrationComponent
+ * An HLT calibration component example.
+ * Component illustrates the basic functionality of a calibration component.
+ * Calibration components analyze data with respect to certain calibration
+ * issues and create calibration objects to be used in the reconstruction.
+ *
+ * <h2>General properties:</h2>
+ *
+ * Component ID: \b SampleCalibration <br>
+ * Library: \b libAliHLTSample.so <br>
+ * Input Data Types: @ref kAliHLTAnyDataType <br>
+ * Output Data Types: none <br>
+ *
+ * <h2>Mandatory arguments:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * <h2>Optional configuration arguments:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ *
+ * <h2>Default CDB entries:</h2>
+ * The component has just one default CDB entry in
+ * <tt>HLT/ConfigSample/SampleCalibration</tt>.
+ * It does not load any configuration from the global <tt>ConfigHLT</tt>
+ * folder.
+ * \li -TObjString object holding a string with the configuration parameters
+ * explained above
+ *
+ * <h2>Performance:</h2>
+ * The component does not any event data processing.
+ *
+ * <h2>Memory consumption:</h2>
+ * The component does not any event data processing.
+ *
+ * <h2>Output size:</h2>
+ * The component has no output data.
+ *
+ * The component implements the @ref alihltcomponent-high-level-interface.
+ * for data processing.
+ * Apart from the normal AliHLTComponent interface functions a calibration
+ * component needs to overload two functions from the AliHLTCalibrationProcessor:
+ * - ProcessCalibration() invoked in the normal event loop and can be used
+ * to accumulate data
+ * - ShipDataToFXS() invoked at EOD to ship the final result
+ *
+ * @ingroup alihlt_tutorial
+ */
+class AliHLTSampleCalibrationComponent : public AliHLTCalibrationProcessor {
+public:
+ AliHLTSampleCalibrationComponent();
+ virtual ~AliHLTSampleCalibrationComponent();
+
+ // AliHLTComponent interface functions
+ const char* GetComponentID();
+ void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
+ AliHLTComponentDataType GetOutputDataType();
+ virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
+ void GetOCDBObjectDescription( TMap* const targetArray);
+
+ // Spawn function, return new class instance
+ AliHLTComponent* Spawn();
+
+ protected:
+ // AliHLTComponent interface functions
+ int DoInit( int argc, const char** argv );
+ int DoDeinit();
+ int ProcessCalibration( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData);
+ int ShipDataToFXS( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData);
+ int ScanConfigurationArgument(int argc, const char** argv);
+ int Reconfigure(const char* cdbEntry, const char* chainId);
+ int ReadPreprocessorValues(const char* modules);
+
+ using AliHLTCalibrationProcessor::ProcessCalibration;
+ using AliHLTCalibrationProcessor::ShipDataToFXS;
+
+private:
+ /** copy constructor prohibited */
+ AliHLTSampleCalibrationComponent(const AliHLTSampleCalibrationComponent&);
+ /** assignment operator prohibited */
+ AliHLTSampleCalibrationComponent& operator=(const AliHLTSampleCalibrationComponent&);
+
+ /// output size estimator, updated during the event processing
+ int fOutputSize; //!transient
+
+ /// test histogram
+ TH1S* fHisto; //! transient
+ /// histogram range
+ int fHistoRange; //! transient
+
+ // version no 0 -> no streamer for member variables
+ ClassDef(AliHLTSampleCalibrationComponent, 0)
+};
+#endif
--- /dev/null
+// $Id$
+/**
+ * @file sampleCalibrationProcessor.C
+ * @brief Run the SampleCalibration component (AliHLTSampleCalibrationComponent)
+ *
+ * <pre>
+ * Usage: aliroot -b -q -l \
+ * sampleCalibrationProcessor.C'("file", "cdb", minEvent, maxEvent)'
+ *
+ * Examples:
+ * sampleCalibrationProcessor.C'("alien:///alice/data/2009/.../....root")'
+ * sampleCalibrationProcessor.C'("raw.root", "local://$PWD", minEvent, MaxEvent)'
+ *
+ * Defaults
+ * cdb="local://$ALICE_ROOT/OCDB" -> take local OCDB
+ * minEvent=-1 -> no lower event selection
+ * maxEvent=-1 -> no upper event selection
+ *
+ * </pre>
+ *
+ * An HLT chain is set up with one publisher for raw data which the calibration
+ * component subscribes to. The output of the component is directed to a
+ * ROOTFileWriter producing the file 'calibdata.root'. Another FileWriter
+ * writes the data block designated for storage in the FXS.
+ * The HLT chain is run in the context of AliReconstruction.
+ *
+ * The input file can be a file on the grid, indicated by the tag
+ * 'alien://'.
+ * If either the file or the OCDB is taken from the GRID, the macros
+ * connects to the Grid in the beginning.
+ * Note: You need a valid GRID token, use 'alien-token-init' of your
+ * alien installation.
+ *
+ * This example uses the local OCDB as default, but other locations can
+ * be specified, like e.g. "raw://".
+ *
+ * @author Matthias.Richter@ift.uib.no
+ * @ingroup alihlt_tutorial
+ */
+void sampleCalibrationProcessor(const char *filename,
+ const char *cdbURI,
+ int minEvent=-1,
+ int maxEvent=-1)
+{
+ // connect to the GRID if we use a file or OCDB from the GRID
+ TString struri=cdbURI;
+ TString strfile=filename;
+ if (struri.BeginsWith("raw://") ||
+ strfile.Contains("://") && !strfile.Contains("local://")) {
+ TGrid::Connect("alien");
+ }
+
+ // Set the CDB storage location
+ AliCDBManager * man = AliCDBManager::Instance();
+ man->SetDefaultStorage(cdbURI);
+ if (struri.BeginsWith("local://") && !gSystem->AccessPathName("GRP/GRP/Data")) {
+ // set specific storage for GRP entry according to the default simulation
+ man->SetSpecificStorage("GRP/GRP/Data", "local://$PWD");
+ } else if (struri.BeginsWith("local://") && !gSystem->AccessPathName("../GRP/GRP/Data")) {
+ // set specific storage for GRP entry according to the default simulation
+ man->SetSpecificStorage("GRP/GRP/Data", "local://$PWD/../");
+ }
+
+ // Reconstruction settings
+ AliReconstruction rec;
+
+ if (minEvent>=0 || maxEvent>minEvent) {
+ if (minEvent<0) minEvent=0;
+ if (maxEvent<minEvent) maxEvent=minEvent;
+ rec.SetEventRange(minEvent,maxEvent);
+ }
+
+ rec.SetRunReconstruction("HLT");
+
+ // QA options
+ rec.SetRunQA(":") ;
+
+ // AliReconstruction settings
+ rec.SetWriteESDfriend(kFALSE);
+ rec.SetInput(filename);
+
+ rec.SetRunPlaneEff(kFALSE);
+ rec.SetRunVertexFinder(kFALSE);
+
+ // switch off cleanESD
+ rec.SetCleanESD(kFALSE);
+
+ // setup the HLT chain
+ AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
+
+ // publisher for raw data
+ AliHLTConfiguration rawpub("rawpub", "AliRawReaderPublisher", "", "-minid 768 -maxid 983 -datatype 'DDL_RAW ' SMPL");
+
+ // the configuration of the calibration component
+ // send the produced object not more than once every 2 sec
+ AliHLTConfiguration smplcalib("smplcalib", "SampleCalibration", "rawpub", "-pushback-period=2");
+
+ // writer for data objects produced by the calibration component during
+ // ProcessCalibration,
+ AliHLTConfiguration eventwriter("eventwriter", "ROOTFileWriter", "smplcalib", "-datafile calibdata.root -concatenate-events -overwrite -write-all-events");
+
+ // filter the output of the smplcalib component and forward only the blocks
+ // of type 'FXS_CAL ' designated for storage by the FXSSubscriber
+ AliHLTConfiguration fxsfilter("fxsfilter", "BlockFilter", "smplcalib", "-typeid 'FXS_CAL ' ");
+ // write the block, a file like 'EOR_*HLT:FXS_CAL' will be written containing the
+ // binary data block of the FXS header and the streamed object
+ AliHLTConfiguration fxswriter("fxswriter", "FileWriter", "fxsfilter", "-write-all-events");
+
+ rec.SetOption("HLT", "loglevel=0x7c ignore-hltout libAliHLTUtil.so libAliHLTSample.so chains=fxswriter,eventwriter");
+
+ AliLog::Flush();
+ rec.Run();
+
+}
+
+void sampleCalibrationProcessor(const char *filename,
+ int minEvent=-1,
+ int maxEvent=-1)
+{
+ sampleCalibrationProcessor(filename, "local://$ALICE_ROOT/OCDB", minEvent, maxEvent);
+}
+
+void sampleCalibrationProcessor()
+{
+ cout << "sampleCalibrationProcessor: Run AliRoot reconstruction locally" << endl;
+ cout << " Usage: aliroot -b -q -l \\" << endl;
+ cout << " sampleCalibrationProcessor.C'(\"file\", \"cdb\", minEvent, maxEvent)'" << endl;
+ cout << "" << endl;
+ cout << " Examples:" << endl;
+ cout << " sampleCalibrationProcessor.C'(\"alien:///alice/data/2009/.../....root\")' " << endl;
+ cout << " sampleCalibrationProcessor.C'(\"raw.root\", \"local://$PWD\", minEvent, MaxEvent)'" << endl;
+ cout << "" << endl;
+ cout << " Defaults" << endl;
+ cout << " cdb=\"local://$ALICE_ROOT/OCDB\" -> take local OCDB " << endl;
+ cout << " minEvent=-1 -> no lower event selection" << endl;
+ cout << " maxEvent=-1 -> no upper event selection" << endl;
+}
# will be created from the names of the header files
CLASS_HDRS:= AliHLTSampleComponent1.h \
AliHLTSampleComponent2.h \
+ AliHLTSampleCalibrationComponent.h \
AliHLTSampleESDAnalysisComponent.h \
AliHLTSampleMonitoringComponent.h \
AliHLTAgentSample.h \