]>
Commit | Line | Data |
---|---|---|
8ef16e6a | 1 | // $Id$ |
2 | ||
3 | //************************************************************************** | |
0cfce653 | 4 | //* This file is property of and copyright by the * |
8ef16e6a | 5 | //* ALICE Experiment at CERN, All rights reserved. * |
6 | //* * | |
7 | //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * | |
8 | //* for The ALICE HLT Project. * | |
9 | //* * | |
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 | //************************************************************************** | |
18 | ||
19 | // @file AliHLTSampleCalibrationComponent.cxx | |
20 | // @author Matthias Richter | |
21 | // @date 2010-04-26 | |
22 | // @brief A sample calibration component for the HLT. | |
23 | // @ingroup alihlt_tutorial | |
24 | ||
8ef16e6a | 25 | #include "AliHLTSampleCalibrationComponent.h" |
26 | #include "AliHLTReadoutList.h" | |
27 | #include "AliLog.h" | |
28 | #include "TMap.h" | |
29 | #include "TObjString.h" | |
30 | #include "TH1S.h" | |
31 | ||
0cfce653 | 32 | using namespace std; |
33 | ||
8ef16e6a | 34 | /** ROOT macro for the implementation of ROOT specific class methods */ |
35 | ClassImp(AliHLTSampleCalibrationComponent) | |
36 | ||
8ef16e6a | 37 | AliHLTSampleCalibrationComponent::AliHLTSampleCalibrationComponent() |
38 | : AliHLTCalibrationProcessor() | |
39 | , fOutputSize(1000) | |
40 | , fHisto(NULL) | |
41 | , fHistoRange(10000) | |
42 | { | |
43 | // an example component which implements the ALICE HLT calibration | |
44 | // processor interface | |
45 | // | |
46 | // see header file for class documentation | |
47 | // or | |
48 | // refer to README to build package | |
49 | // or | |
50 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
51 | // | |
52 | // NOTE: all helper classes should be instantiated in DoInit() | |
53 | } | |
54 | ||
55 | AliHLTSampleCalibrationComponent::~AliHLTSampleCalibrationComponent() | |
56 | { | |
57 | // destructor | |
58 | // | |
59 | // NOTE: implement proper cleanup in DoDeinit() | |
60 | } | |
61 | ||
62 | const char* AliHLTSampleCalibrationComponent::GetComponentID() | |
63 | { | |
64 | // component property: id | |
65 | return "SampleCalibration"; | |
66 | } | |
67 | ||
0cfce653 | 68 | void AliHLTSampleCalibrationComponent::GetInputDataTypes( AliHLTComponentDataTypeList& list) |
8ef16e6a | 69 | { |
70 | // component property: list of input data types | |
71 | list.push_back(kAliHLTAnyDataType); | |
72 | } | |
73 | ||
74 | AliHLTComponentDataType AliHLTSampleCalibrationComponent::GetOutputDataType() | |
75 | { | |
76 | // component property: output data type | |
77 | return kAliHLTDataTypeFXSCalib|kAliHLTDataOriginSample; | |
78 | } | |
79 | ||
80 | void AliHLTSampleCalibrationComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
81 | { | |
82 | // component property: output size estimator | |
83 | constBase = fOutputSize; | |
84 | inputMultiplier = 0; | |
85 | } | |
86 | ||
87 | void AliHLTSampleCalibrationComponent::GetOCDBObjectDescription( TMap* const targetMap) | |
88 | { | |
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 | |
94 | // target TMap. | |
95 | if (!targetMap) return; | |
96 | targetMap->Add(new TObjString("HLT/ConfigSample/SampleCalibration"), | |
97 | new TObjString("configuration object")); | |
98 | } | |
99 | ||
100 | AliHLTComponent* AliHLTSampleCalibrationComponent::Spawn() | |
101 | { | |
102 | // Spawn function, return new class instance | |
103 | return new AliHLTSampleCalibrationComponent; | |
104 | } | |
105 | ||
106 | int AliHLTSampleCalibrationComponent::DoInit( int argc, const char** argv ) | |
107 | { | |
108 | // see header file for class documentation | |
109 | int iResult=0; | |
110 | ||
111 | // init stage 1: default values for all data members | |
112 | ||
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); | |
118 | ||
119 | // init stage 3: read the component arguments | |
120 | if (iResult>=0) { | |
121 | iResult=ConfigureFromArgumentString(argc, argv); | |
122 | } | |
123 | ||
124 | if (iResult>=0) { | |
125 | // implement the component initialization | |
126 | fHisto=new TH1S("InputSize", "Input block size", 100, 0, fHistoRange); | |
127 | fOutputSize+=EstimateObjectSize(fHisto); | |
128 | } | |
129 | ||
130 | if (iResult<0) { | |
131 | // implement cleanup | |
132 | } | |
133 | ||
134 | return iResult; | |
135 | } | |
136 | ||
137 | int AliHLTSampleCalibrationComponent::ScanConfigurationArgument(int argc, const char** argv) | |
138 | { | |
139 | // Scan configuration arguments | |
140 | // Return the number of processed arguments | |
141 | // -EPROTO if argument format error (e.g. number expected but not found) | |
142 | // | |
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. | |
146 | ||
147 | int i=0; | |
148 | TString argument=argv[i]; | |
149 | ||
150 | if (argument.IsNull()) return 0; | |
151 | ||
152 | // -mandatory1 arg | |
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 | |
157 | } | |
158 | ||
159 | // -optional1 arg | |
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 | |
164 | } | |
165 | ||
166 | // -optional2 | |
167 | if (argument.CompareTo("-optional2")==0) { | |
168 | HLTInfo("got \'-optional2\' argument"); | |
169 | return 1; // only keyword | |
170 | } | |
171 | ||
172 | return 0; | |
173 | } | |
174 | ||
175 | int AliHLTSampleCalibrationComponent::DoDeinit() | |
176 | { | |
177 | // component cleanup, delete all instances of helper classes here | |
178 | if (fHisto) delete fHisto; | |
179 | fOutputSize=0; | |
180 | ||
181 | return 0; | |
182 | } | |
183 | ||
184 | int AliHLTSampleCalibrationComponent::ProcessCalibration(const AliHLTComponentEventData& /*evtData*/, | |
185 | AliHLTComponentTriggerData& /*trigData*/) | |
186 | { | |
187 | // event processing function | |
188 | ||
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; | |
192 | ||
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); | |
198 | } | |
199 | ||
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(); | |
209 | } | |
210 | ||
211 | return 0; | |
212 | } | |
213 | ||
d7c72829 | 214 | int AliHLTSampleCalibrationComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, |
215 | AliHLTComponentTriggerData& /*trigData*/) | |
8ef16e6a | 216 | { |
217 | // prepare final result and ship to FXS | |
218 | ||
219 | AliHLTReadoutList rdList(AliHLTReadoutList::kHLT); | |
89413559 | 220 | PushToFXS(fHisto, "HLT", "TestHisto", &rdList); |
8ef16e6a | 221 | |
222 | return 0; | |
223 | } | |
224 | ||
225 | int AliHLTSampleCalibrationComponent::Reconfigure(const char* cdbEntry, const char* chainId) | |
226 | { | |
227 | // reconfigure the component from the specified CDB entry, or default CDB entry | |
228 | HLTInfo("reconfigure '%s' from entry %s", chainId, cdbEntry); | |
229 | ||
230 | return 0; | |
231 | } | |
232 | ||
233 | int AliHLTSampleCalibrationComponent::ReadPreprocessorValues(const char* modules) | |
234 | { | |
235 | // read the preprocessor values for the detectors in the modules list | |
236 | int iResult=0; | |
237 | TString detectors(modules!=NULL?modules:""); | |
238 | HLTInfo("read preprocessor values for detector(s): %s", detectors.IsNull()?"none":detectors.Data()); | |
239 | return iResult; | |
240 | } |