]>
Commit | Line | Data |
---|---|---|
154cba94 | 1 | #ifndef ALIHLTMUONPROCESSOR_H |
2 | #define ALIHLTMUONPROCESSOR_H | |
3 | /* This file is property of and copyright by the ALICE HLT Project * | |
4 | * ALICE Experiment at CERN, All rights reserved. * | |
5 | * See cxx source for full Copyright notice */ | |
6 | ||
7 | /* $Id: $ */ | |
8 | ||
9 | /// | |
10 | /// @file AliHLTMUONProcessor.h | |
11 | /// @author Artur Szostak <artursz@iafrica.com> | |
dba14d7d | 12 | /// @date 19 May 2008 |
154cba94 | 13 | /// @brief Declaration of a common processor component abstract interface for dHLT components. |
14 | /// | |
15 | ||
16 | #include "AliHLTProcessor.h" | |
17 | #include "AliHLTMUONDataBlockReader.h" | |
18 | #include "AliHLTMUONUtils.h" | |
19 | ||
ffc1a6f6 | 20 | class TMap; |
17d68f2a | 21 | class AliMUONRecoParam; |
ffc1a6f6 | 22 | |
154cba94 | 23 | /** |
24 | * @class AliHLTMUONProcessor | |
25 | * This component class is an abstract base class for dHLT components. | |
26 | * Some common methods useful to all dHLT specific components are implemented | |
27 | * by this class. | |
dba14d7d | 28 | * |
29 | * @ingroup alihlt_dimuon_component | |
154cba94 | 30 | */ |
31 | class AliHLTMUONProcessor : public AliHLTProcessor | |
32 | { | |
33 | public: | |
34 | /// Default constructor. | |
35 | AliHLTMUONProcessor() : AliHLTProcessor() {} | |
dba14d7d | 36 | |
154cba94 | 37 | /// Default destructor. |
38 | virtual ~AliHLTMUONProcessor() {} | |
39 | ||
40 | protected: | |
41 | ||
42 | /** | |
43 | * Method to check the block structure and log appropriate error messages. | |
44 | * If a problem is found with the data block then an appropriate HLT error | |
45 | * message is logged and the method returns false. | |
46 | * \param block The lightweight block reader whose data block should be checked. | |
47 | * \param name A string containing a descriptive name of the data block | |
48 | * type. This name is used in the logged error messages. | |
dba14d7d | 49 | * \param checkHeader Indicates if the common data block header should be checked. |
154cba94 | 50 | * \returns true if the structure of the block looks OK and false otherwise. |
51 | * \note The BlockType should be a class deriving from AliHLTMUONDataBlockReader. | |
52 | */ | |
53 | template <class BlockType> | |
dba14d7d | 54 | bool BlockStructureOk( |
55 | const BlockType& block, const char* name, | |
56 | bool checkHeader = true | |
57 | ) const; | |
154cba94 | 58 | |
59 | /// Checks the structure of a trigger records data block. | |
dba14d7d | 60 | bool BlockStructureOk( |
61 | const AliHLTMUONTriggerRecordsBlockReader& block, | |
62 | bool checkHeader = true | |
63 | ) const | |
154cba94 | 64 | { |
dba14d7d | 65 | return BlockStructureOk(block, "trigger records", checkHeader); |
154cba94 | 66 | } |
67 | ||
68 | /// Checks the structure of a trigger records debug information data block. | |
dba14d7d | 69 | bool BlockStructureOk( |
70 | const AliHLTMUONTrigRecsDebugBlockReader& block, | |
71 | bool checkHeader = true | |
72 | ) const | |
154cba94 | 73 | { |
dba14d7d | 74 | return BlockStructureOk(block, "trigger records debug information", checkHeader); |
154cba94 | 75 | } |
76 | ||
77 | /// Checks the structure of a reconstructed hits data block. | |
dba14d7d | 78 | bool BlockStructureOk( |
79 | const AliHLTMUONRecHitsBlockReader& block, | |
80 | bool checkHeader = true | |
81 | ) const | |
154cba94 | 82 | { |
dba14d7d | 83 | return BlockStructureOk(block, "reconstructed hits", checkHeader); |
154cba94 | 84 | } |
85 | ||
86 | /// Checks the structure of a clusters data block. | |
dba14d7d | 87 | bool BlockStructureOk( |
88 | const AliHLTMUONClustersBlockReader& block, | |
89 | bool checkHeader = true | |
90 | ) const | |
154cba94 | 91 | { |
dba14d7d | 92 | return BlockStructureOk(block, "clusters", checkHeader); |
154cba94 | 93 | } |
94 | ||
95 | /// Checks the structure of a ADC channels data block. | |
dba14d7d | 96 | bool BlockStructureOk( |
97 | const AliHLTMUONChannelsBlockReader& block, | |
98 | bool checkHeader = true | |
99 | ) const | |
154cba94 | 100 | { |
dba14d7d | 101 | return BlockStructureOk(block, "channels", checkHeader); |
154cba94 | 102 | } |
103 | ||
104 | /// Checks the structure of a Manso tracks data block. | |
dba14d7d | 105 | bool BlockStructureOk( |
106 | const AliHLTMUONMansoTracksBlockReader& block, | |
107 | bool checkHeader = true | |
108 | ) const | |
154cba94 | 109 | { |
dba14d7d | 110 | return BlockStructureOk(block, "Manso tracks", checkHeader); |
154cba94 | 111 | } |
112 | ||
113 | /// Checks the structure of a Manso track candidates data block. | |
dba14d7d | 114 | bool BlockStructureOk( |
115 | const AliHLTMUONMansoCandidatesBlockReader& block, | |
116 | bool checkHeader = true | |
117 | ) const | |
154cba94 | 118 | { |
dba14d7d | 119 | return BlockStructureOk(block, "Manso track candidates", checkHeader); |
154cba94 | 120 | } |
121 | ||
122 | /// Checks the structure of a single track trigger decision data block. | |
dba14d7d | 123 | bool BlockStructureOk( |
124 | const AliHLTMUONSinglesDecisionBlockReader& block, | |
125 | bool checkHeader = true | |
126 | ) const | |
154cba94 | 127 | { |
dba14d7d | 128 | return BlockStructureOk(block, "singles decision", checkHeader); |
154cba94 | 129 | } |
130 | ||
131 | /// Checks the structure of a track pairs trigger decision data block. | |
dba14d7d | 132 | bool BlockStructureOk( |
133 | const AliHLTMUONPairsDecisionBlockReader& block, | |
134 | bool checkHeader = true | |
135 | ) const | |
154cba94 | 136 | { |
dba14d7d | 137 | return BlockStructureOk(block, "pairs decision", checkHeader); |
154cba94 | 138 | } |
139 | ||
dba14d7d | 140 | /** |
ffc1a6f6 | 141 | * Sets the CDB path and run number to read from. |
dba14d7d | 142 | * \param cdbPath The CDB path to use. If set to NULL and the path has |
143 | * not been set in the CDB manager then the default path | |
144 | * "local://$ALICE_ROOT" is used if the 'useDefault' flag is also true. | |
145 | * \param run The run number to use. If set to -1 and the run number has | |
146 | * not been set in the CDB manager then a value of zero is used if | |
147 | * the 'useDefault' flag is also true. | |
ffc1a6f6 | 148 | * \param useDefault If set to true then a default CDB path and/or run number |
dba14d7d | 149 | * is used if they have not been set and 'cdbPath' == NULL or |
ffc1a6f6 | 150 | * 'run' == -1. (false by default). |
151 | * \return Zero if the object could be loaded. Otherwise an error code, | |
152 | * compatible with the HLT framework, is returned. | |
153 | */ | |
154 | int SetCDBPathAndRunNo( | |
155 | const char* cdbPath, Int_t run, bool useDefault = false | |
156 | ) const; | |
157 | ||
158 | /** | |
159 | * Fetches the DDL and detector element store objects for MUON mapping. | |
160 | * \return Zero if the objects could be loaded. Otherwise an error code, | |
161 | * which is compatible with the HLT framework, is returned. | |
dba14d7d | 162 | * \note AliMpDDLStore::Instance() and AliMpDEStore::Instance() must be used |
163 | * to fetch the objects after this method returns a code equal to zero. | |
164 | */ | |
ffc1a6f6 | 165 | int FetchMappingStores() const; |
166 | ||
167 | /** | |
168 | * Fetches a TMap object from the CDB. | |
169 | * [in] \param pathToEntry The relative path to the entry in the CDB to fetch. | |
170 | * [out] \param map This will be filled with the TMap object found if | |
171 | * a successful status code is returned. Otherwise it will be unchanged. | |
172 | * \return Zero if the object could be found. Otherwise an error code, | |
173 | * which is compatible with the HLT framework, is returned. | |
174 | */ | |
175 | int FetchTMapFromCDB(const char* pathToEntry, TMap*& map) const; | |
176 | ||
177 | /** | |
178 | * Tries to find the string value associated with a certain parameter in a TMap. | |
179 | * [in] \param map The TMap object to search in. | |
180 | * [in] \param paramName The name of the parameter to search for. | |
181 | * [out] \param value Will be filled with the object found. | |
182 | * [in] \param prettyName Should be the name of the parameter which will | |
183 | * be used when printing error messages. If this is set to NULL then | |
184 | * the paramName will be used instead (default is NULL). | |
185 | * \return Zero if the object could be found. Otherwise an error code, | |
186 | * which is compatible with the HLT framework, is returned. | |
187 | */ | |
188 | int GetValueFromTMap( | |
189 | TMap* map, const char* paramName, TString& value, | |
190 | const char* pathToEntry = NULL, const char* prettyName = NULL | |
191 | ) const; | |
192 | ||
193 | /** | |
194 | * Tries to find a certain parameter in the TMap object and convert it to | |
195 | * an integer value. | |
196 | * [in] \param map The TMap object to search in. | |
197 | * [in] \param paramName The name of the parameter to search for. | |
198 | * [out] \param value Will be filled with the integer value for the parameter, | |
199 | * if it was found and it was an integer value. | |
200 | * [in] \param prettyName Should be the name of the parameter which will | |
201 | * be used when printing error messages. If this is set to NULL then | |
202 | * the paramName will be used instead (default is NULL). | |
203 | * \return Zero if the object could be found and is valid. Otherwise an | |
204 | * error code, which is compatible with the HLT framework, is returned. | |
205 | */ | |
206 | int GetIntFromTMap( | |
207 | TMap* map, const char* paramName, Int_t& value, | |
208 | const char* pathToEntry = NULL, const char* prettyName = NULL | |
209 | ) const; | |
210 | ||
211 | /** | |
212 | * Tries to find a certain parameter in the TMap object and convert it to | |
213 | * a positive integer value. | |
214 | * [in] \param map The TMap object to search in. | |
215 | * [in] \param paramName The name of the parameter to search for. | |
216 | * [out] \param value Will be filled with the integer value for the parameter, | |
217 | * if it was found and it was a positive integer value. | |
218 | * [in] \param prettyName Should be the name of the parameter which will | |
219 | * be used when printing error messages. If this is set to NULL then | |
220 | * the paramName will be used instead (default is NULL). | |
221 | * \return Zero if the object could be found and is valid. Otherwise an | |
222 | * error code, which is compatible with the HLT framework, is returned. | |
223 | */ | |
224 | int GetPositiveIntFromTMap( | |
225 | TMap* map, const char* paramName, Int_t& value, | |
226 | const char* pathToEntry = NULL, const char* prettyName = NULL | |
227 | ) const; | |
228 | ||
229 | /** | |
230 | * Tries to find a certain parameter in the TMap object and convert it to | |
231 | * an floating point value. | |
232 | * [in] \param map The TMap object to search in. | |
233 | * [in] \param paramName The name of the parameter to search for. | |
234 | * [out] \param value Will be filled with the floating point value for the | |
235 | * parameter, if it was found and it was a floating point value. | |
236 | * [in] \param prettyName Should be the name of the parameter which will | |
237 | * be used when printing error messages. If this is set to NULL then | |
238 | * the paramName will be used instead (default is NULL). | |
239 | * \return Zero if the object could be found and is valid. Otherwise an | |
240 | * error code, which is compatible with the HLT framework, is returned. | |
241 | */ | |
242 | int GetFloatFromTMap( | |
243 | TMap* map, const char* paramName, Double_t& value, | |
244 | const char* pathToEntry = NULL, const char* prettyName = NULL | |
245 | ) const; | |
246 | ||
247 | /** | |
248 | * Tries to find a certain parameter in the TMap object and convert it to | |
249 | * an positive floating point value. | |
250 | * [in] \param map The TMap object to search in. | |
251 | * [in] \param paramName The name of the parameter to search for. | |
252 | * [out] \param value Will be filled with the floating point value for the | |
253 | * parameter, if it was found and it was a positive floating point value. | |
254 | * [in] \param prettyName Should be the name of the parameter which will | |
255 | * be used when printing error messages. If this is set to NULL then | |
256 | * the paramName will be used instead (default is NULL). | |
257 | * \return Zero if the object could be found and is valid. Otherwise an | |
258 | * error code, which is compatible with the HLT framework, is returned. | |
259 | */ | |
260 | int GetPositiveFloatFromTMap( | |
261 | TMap* map, const char* paramName, Double_t& value, | |
262 | const char* pathToEntry = NULL, const char* prettyName = NULL | |
dba14d7d | 263 | ) const; |
264 | ||
17d68f2a | 265 | /** |
266 | * Fetches the reconstruction parameters object from the CDB for MUON. | |
267 | * [out] \param params This will be filled with the reconstruction | |
268 | * parameters object found if a successful status code is returned. | |
269 | * Otherwise it will be unchanged. | |
270 | * \return Zero if the object could be found. Otherwise an error code, | |
271 | * which is compatible with the HLT framework, is returned. | |
272 | */ | |
273 | int LoadRecoParamsFromCDB(AliMUONRecoParam*& params) const; | |
274 | ||
154cba94 | 275 | private: |
276 | ||
277 | // Do not allow copying of this class. | |
dba14d7d | 278 | /// Not implemented. |
154cba94 | 279 | AliHLTMUONProcessor(const AliHLTMUONProcessor& /*obj*/); |
dba14d7d | 280 | /// Not implemented. |
154cba94 | 281 | AliHLTMUONProcessor& operator = (const AliHLTMUONProcessor& /*obj*/); |
282 | ||
283 | ClassDef(AliHLTMUONProcessor, 0) // Abstract base class for dHLT specific components. | |
284 | }; | |
285 | ||
286 | //______________________________________________________________________________ | |
287 | ||
288 | template <class BlockType> | |
dba14d7d | 289 | bool AliHLTMUONProcessor::BlockStructureOk( |
290 | const BlockType& block, const char* name, bool checkHeader | |
291 | ) const | |
154cba94 | 292 | { |
293 | /// Performs basic checks to see if the input data block structure is OK, | |
294 | /// that it is not corrupt, too short etc... | |
295 | ||
296 | if (not block.BufferSizeOk()) | |
297 | { | |
298 | size_t headerSize = sizeof(typename BlockType::HeaderType); | |
299 | if (block.BufferSize() < headerSize) | |
300 | { | |
301 | HLTError("Received a %s data block with a size of %d bytes," | |
302 | " which is smaller than the minimum valid header size of %d bytes." | |
303 | " The block must be corrupt.", | |
304 | name, block.BufferSize(), headerSize | |
305 | ); | |
306 | return false; | |
307 | } | |
308 | ||
309 | size_t expectedWidth = sizeof(typename BlockType::ElementType); | |
310 | if (block.CommonBlockHeader().fRecordWidth != expectedWidth) | |
311 | { | |
312 | HLTError("Received a %s data block with a record" | |
313 | " width of %d bytes, but the expected value is %d bytes." | |
314 | " The block might be corrupt.", | |
315 | name, | |
316 | block.CommonBlockHeader().fRecordWidth, | |
317 | expectedWidth | |
318 | ); | |
319 | return false; | |
320 | } | |
321 | ||
322 | HLTError("Received a %s data block with a size of %d bytes," | |
323 | " but the block header claims the block should be %d bytes." | |
324 | " The block might be corrupt.", | |
325 | name, block.BufferSize(), block.BytesUsed() | |
326 | ); | |
327 | return false; | |
328 | } | |
329 | ||
dba14d7d | 330 | if (checkHeader) |
154cba94 | 331 | { |
dba14d7d | 332 | AliHLTMUONUtils::WhyNotValid reason; |
333 | if (not AliHLTMUONUtils::HeaderOk(block.BlockHeader(), &reason)) | |
334 | { | |
335 | HLTError("Received a %s data block which might be corrupt. %s", | |
336 | name, AliHLTMUONUtils::FailureReasonToMessage(reason) | |
337 | ); | |
338 | return false; | |
339 | } | |
154cba94 | 340 | } |
341 | ||
342 | return true; | |
343 | } | |
344 | ||
345 | #endif // ALIHLTMUONPROCESSOR_H |