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