3 //**************************************************************************
4 //* This file is property of and copyright by the *
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
25 #include "AliHLTSampleCalibrationComponent.h"
26 #include "AliHLTReadoutList.h"
29 #include "TObjString.h"
34 /** ROOT macro for the implementation of ROOT specific class methods */
35 ClassImp(AliHLTSampleCalibrationComponent)
37 AliHLTSampleCalibrationComponent::AliHLTSampleCalibrationComponent()
38 : AliHLTCalibrationProcessor()
43 // an example component which implements the ALICE HLT calibration
44 // processor interface
46 // see header file for class documentation
48 // refer to README to build package
50 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
52 // NOTE: all helper classes should be instantiated in DoInit()
55 AliHLTSampleCalibrationComponent::~AliHLTSampleCalibrationComponent()
59 // NOTE: implement proper cleanup in DoDeinit()
62 const char* AliHLTSampleCalibrationComponent::GetComponentID()
64 // component property: id
65 return "SampleCalibration";
68 void AliHLTSampleCalibrationComponent::GetInputDataTypes( AliHLTComponentDataTypeList& list)
70 // component property: list of input data types
71 list.push_back(kAliHLTAnyDataType);
74 AliHLTComponentDataType AliHLTSampleCalibrationComponent::GetOutputDataType()
76 // component property: output data type
77 return kAliHLTDataTypeFXSCalib|kAliHLTDataOriginSample;
80 void AliHLTSampleCalibrationComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
82 // component property: output size estimator
83 constBase = fOutputSize;
87 void AliHLTSampleCalibrationComponent::GetOCDBObjectDescription( TMap* const targetMap)
89 // Get a list of OCDB object description.
90 // The list of objects is provided in a TMap
91 // - key: complete OCDB path, e.g. GRP/GRP/Data
92 // - value: short description why the object is needed
93 // Key and value objects created inside this class go into ownership of
95 if (!targetMap) return;
96 targetMap->Add(new TObjString("HLT/ConfigSample/SampleCalibration"),
97 new TObjString("configuration object"));
100 AliHLTComponent* AliHLTSampleCalibrationComponent::Spawn()
102 // Spawn function, return new class instance
103 return new AliHLTSampleCalibrationComponent;
106 int AliHLTSampleCalibrationComponent::DoInit( int argc, const char** argv )
108 // see header file for class documentation
111 // init stage 1: default values for all data members
113 // init stage 2: read configuration object
114 // ScanConfigurationArgument() needs to be implemented
115 TString cdbPath="HLT/ConfigSample/";
116 cdbPath+=GetComponentID();
117 iResult=ConfigureFromCDBTObjString(cdbPath);
119 // init stage 3: read the component arguments
121 iResult=ConfigureFromArgumentString(argc, argv);
125 // implement the component initialization
126 fHisto=new TH1S("InputSize", "Input block size", 100, 0, fHistoRange);
127 fOutputSize+=EstimateObjectSize(fHisto);
137 int AliHLTSampleCalibrationComponent::ScanConfigurationArgument(int argc, const char** argv)
139 // Scan configuration arguments
140 // Return the number of processed arguments
141 // -EPROTO if argument format error (e.g. number expected but not found)
143 // The AliHLTComponent base class implements a parsing loop for argument strings and
144 // arrays of strings which is invoked by ConfigureFromArgumentString/ConfigureFromCDBTObjString
145 // The component needs to implement ScanConfigurationArgument in order to decode the arguments.
148 TString argument=argv[i];
150 if (argument.IsNull()) return 0;
153 if (argument.CompareTo("-mandatory1")==0) {
154 if (++i>=argc) return -EPROTO;
155 HLTInfo("got \'-mandatory1\' argument: %s", argv[i]);
156 return 2; // keyword + 1 argument
160 if (argument.CompareTo("-optional1")==0) {
161 if (++i>=argc) return -EPROTO;
162 HLTInfo("got \'-optional1\' argument: %s", argv[i]);
163 return 2; // keyword + 1 argument
167 if (argument.CompareTo("-optional2")==0) {
168 HLTInfo("got \'-optional2\' argument");
169 return 1; // only keyword
175 int AliHLTSampleCalibrationComponent::DoDeinit()
177 // component cleanup, delete all instances of helper classes here
178 if (fHisto) delete fHisto;
184 int AliHLTSampleCalibrationComponent::ProcessCalibration(const AliHLTComponentEventData& /*evtData*/,
185 AliHLTComponentTriggerData& /*trigData*/)
187 // event processing function
189 // check if this is a data event, there are a couple of special events
190 // which should be ignored for normal processing
191 if (!IsDataEvent()) return 0;
193 // loop over input data blocks
194 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeDDLRaw);
195 pBlock!=NULL; pBlock=GetNextInputBlock()) {
196 HLTInfo("block %s specification 0x%x size %d", DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize);
197 fHisto->Fill(pBlock->fSize);
200 // write the histogram out
201 // this should not be done for every event, however the call can be implemented
202 // like that and the publishing steered by the component argument
203 // '-pushback-period=...'
204 if (PushBack(fHisto, kAliHLTDataTypeHistogram)==-ENOSPC) {
205 // increase the output size estimator
206 // we add the size of the last object, there might be other blocks to
207 // be written in addition to the actual object
208 fOutputSize+=GetLastObjectSize();
214 int AliHLTSampleCalibrationComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/,
215 AliHLTComponentTriggerData& /*trigData*/)
217 // prepare final result and ship to FXS
219 AliHLTReadoutList rdList(AliHLTReadoutList::kHLT);
220 PushToFXS(fHisto, "HLT", "TestHisto", &rdList);
225 int AliHLTSampleCalibrationComponent::Reconfigure(const char* cdbEntry, const char* chainId)
227 // reconfigure the component from the specified CDB entry, or default CDB entry
228 HLTInfo("reconfigure '%s' from entry %s", chainId, cdbEntry);
233 int AliHLTSampleCalibrationComponent::ReadPreprocessorValues(const char* modules)
235 // read the preprocessor values for the detectors in the modules list
237 TString detectors(modules!=NULL?modules:"");
238 HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data());