3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* for The ALICE HLT Project. *
10 //* Permission to use, copy, modify and distribute this software and its *
11 //* documentation strictly for non-commercial purposes is hereby granted *
12 //* without fee, provided that the above copyright notice appears in all *
13 //* copies and that both the copyright notice and this permission notice *
14 //* appear in the supporting documentation. The authors make no claims *
15 //* about the suitability of this software for any purpose. It is *
16 //* provided "as is" without express or implied warranty. *
17 //**************************************************************************
19 // @file AliHLTSampleCalibrationComponent.cxx
20 // @author Matthias Richter
22 // @brief A sample calibration component for the HLT.
23 // @ingroup alihlt_tutorial
29 #include "AliHLTSampleCalibrationComponent.h"
30 #include "AliHLTReadoutList.h"
33 #include "TObjString.h"
36 /** ROOT macro for the implementation of ROOT specific class methods */
37 ClassImp(AliHLTSampleCalibrationComponent)
39 /** one global instance used for registration */
40 AliHLTSampleCalibrationComponent gAliHLTSampleCalibrationComponent;
42 AliHLTSampleCalibrationComponent::AliHLTSampleCalibrationComponent()
43 : AliHLTCalibrationProcessor()
48 // an example component which implements the ALICE HLT calibration
49 // processor interface
51 // see header file for class documentation
53 // refer to README to build package
55 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
57 // NOTE: all helper classes should be instantiated in DoInit()
60 AliHLTSampleCalibrationComponent::~AliHLTSampleCalibrationComponent()
64 // NOTE: implement proper cleanup in DoDeinit()
67 const char* AliHLTSampleCalibrationComponent::GetComponentID()
69 // component property: id
70 return "SampleCalibration";
73 void AliHLTSampleCalibrationComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
75 // component property: list of input data types
76 list.push_back(kAliHLTAnyDataType);
79 AliHLTComponentDataType AliHLTSampleCalibrationComponent::GetOutputDataType()
81 // component property: output data type
82 return kAliHLTDataTypeFXSCalib|kAliHLTDataOriginSample;
85 void AliHLTSampleCalibrationComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
87 // component property: output size estimator
88 constBase = fOutputSize;
92 void AliHLTSampleCalibrationComponent::GetOCDBObjectDescription( TMap* const targetMap)
94 // Get a list of OCDB object description.
95 // The list of objects is provided in a TMap
96 // - key: complete OCDB path, e.g. GRP/GRP/Data
97 // - value: short description why the object is needed
98 // Key and value objects created inside this class go into ownership of
100 if (!targetMap) return;
101 targetMap->Add(new TObjString("HLT/ConfigSample/SampleCalibration"),
102 new TObjString("configuration object"));
105 AliHLTComponent* AliHLTSampleCalibrationComponent::Spawn()
107 // Spawn function, return new class instance
108 return new AliHLTSampleCalibrationComponent;
111 int AliHLTSampleCalibrationComponent::DoInit( int argc, const char** argv )
113 // see header file for class documentation
116 // init stage 1: default values for all data members
118 // init stage 2: read configuration object
119 // ScanConfigurationArgument() needs to be implemented
120 TString cdbPath="HLT/ConfigSample/";
121 cdbPath+=GetComponentID();
122 iResult=ConfigureFromCDBTObjString(cdbPath);
124 // init stage 3: read the component arguments
126 iResult=ConfigureFromArgumentString(argc, argv);
130 // implement the component initialization
131 fHisto=new TH1S("InputSize", "Input block size", 100, 0, fHistoRange);
132 fOutputSize+=EstimateObjectSize(fHisto);
142 int AliHLTSampleCalibrationComponent::ScanConfigurationArgument(int argc, const char** argv)
144 // Scan configuration arguments
145 // Return the number of processed arguments
146 // -EPROTO if argument format error (e.g. number expected but not found)
148 // The AliHLTComponent base class implements a parsing loop for argument strings and
149 // arrays of strings which is invoked by ConfigureFromArgumentString/ConfigureFromCDBTObjString
150 // The component needs to implement ScanConfigurationArgument in order to decode the arguments.
153 TString argument=argv[i];
155 if (argument.IsNull()) return 0;
158 if (argument.CompareTo("-mandatory1")==0) {
159 if (++i>=argc) return -EPROTO;
160 HLTInfo("got \'-mandatory1\' argument: %s", argv[i]);
161 return 2; // keyword + 1 argument
165 if (argument.CompareTo("-optional1")==0) {
166 if (++i>=argc) return -EPROTO;
167 HLTInfo("got \'-optional1\' argument: %s", argv[i]);
168 return 2; // keyword + 1 argument
172 if (argument.CompareTo("-optional2")==0) {
173 HLTInfo("got \'-optional2\' argument");
174 return 1; // only keyword
180 int AliHLTSampleCalibrationComponent::DoDeinit()
182 // component cleanup, delete all instances of helper classes here
183 if (fHisto) delete fHisto;
189 int AliHLTSampleCalibrationComponent::ProcessCalibration(const AliHLTComponentEventData& /*evtData*/,
190 AliHLTComponentTriggerData& /*trigData*/)
192 // event processing function
194 // check if this is a data event, there are a couple of special events
195 // which should be ignored for normal processing
196 if (!IsDataEvent()) return 0;
198 // loop over input data blocks
199 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeDDLRaw);
200 pBlock!=NULL; pBlock=GetNextInputBlock()) {
201 HLTInfo("block %s specification 0x%x size %d", DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize);
202 fHisto->Fill(pBlock->fSize);
205 // write the histogram out
206 // this should not be done for every event, however the call can be implemented
207 // like that and the publishing steered by the component argument
208 // '-pushback-period=...'
209 if (PushBack(fHisto, kAliHLTDataTypeHistogram)==-ENOSPC) {
210 // increase the output size estimator
211 // we add the size of the last object, there might be other blocks to
212 // be written in addition to the actual object
213 fOutputSize+=GetLastObjectSize();
219 int AliHLTSampleCalibrationComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/,
220 AliHLTComponentTriggerData& /*trigData*/)
222 // prepare final result and ship to FXS
224 AliHLTReadoutList rdList(AliHLTReadoutList::kHLT);
225 PushToFXS(fHisto, "HLT", "TestHisto", &rdList);
230 int AliHLTSampleCalibrationComponent::Reconfigure(const char* cdbEntry, const char* chainId)
232 // reconfigure the component from the specified CDB entry, or default CDB entry
233 HLTInfo("reconfigure '%s' from entry %s", chainId, cdbEntry);
238 int AliHLTSampleCalibrationComponent::ReadPreprocessorValues(const char* modules)
240 // read the preprocessor values for the detectors in the modules list
242 TString detectors(modules!=NULL?modules:"");
243 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());