1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
6 * Artur Szostak <artursz@iafrica.com> *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
20 /// @file AliHLTMUONProcessor.cxx
21 /// @author Artur Szostak <artursz@iafrica.com>
23 /// @brief Implementation of the abstract base dHLT processor component.
25 /// This component is the abstract base class of dHLT specific components.
26 /// It implements some common methods used by all the dHLT components.
29 #include "AliHLTMUONProcessor.h"
30 #include "AliCDBManager.h"
31 #include "AliCDBStorage.h"
32 #include "AliCDBEntry.h"
34 #include "AliMpDDLStore.h"
35 #include "AliMpDEStore.h"
37 #include "TObjString.h"
40 ClassImp(AliHLTMUONProcessor)
43 int AliHLTMUONProcessor::SetCDBPathAndRunNo(
44 const char* cdbPath, Int_t run, bool useDefault
47 /// Sets the CDB path and run number to read from.
48 /// \param cdbPath The CDB path to use. If set to NULL and the path has
49 /// not been set in the CDB manager then the default path
50 /// "local://$ALICE_ROOT" is used if the 'useDefault' flag is also true.
51 /// \param run The run number to use. If set to -1 and the run number has
52 /// not been set in the CDB manager then a value of zero is used if
53 /// the 'useDefault' flag is also true.
54 /// \param useDefault If set to true then a default CDB path and/or run number
55 /// is used if they have not been set and 'cdbPath' == NULL or
57 /// \return Zero if the object could be loaded. Otherwise an error code,
58 /// compatible with the HLT framework, is returned.
60 const char* defaultPath = "local://$ALICE_ROOT";
63 AliCDBManager* cdbManager = AliCDBManager::Instance();
64 if (cdbManager == NULL)
66 HLTError("CDB manager instance does not exist.");
70 // Setup the CDB path.
73 cdbManager->SetDefaultStorage(cdbPath);
75 else if (not cdbManager->IsDefaultStorageSet() and useDefault)
77 cdbManager->SetDefaultStorage(defaultPath);
80 // Now setup the run number.
83 cdbManager->SetRun(run);
87 if (useDefault) cdbManager->SetRun(defaultRun);
94 int AliHLTMUONProcessor::FetchMappingStores() const
96 /// Fetches the DDL and detector element store objects for MUON mapping.
97 /// \return Zero if the objects could be loaded. Otherwise an error code,
98 /// which is compatible with the HLT framework, is returned.
99 /// \note AliMpDDLStore::Instance() and AliMpDEStore::Instance() must be used
100 /// to fetch the objects after this method returns a code equal to zero.
102 Bool_t warn = kFALSE;
104 // Check if the objects are already loaded. If they are then exit early,
105 // otherwise we need to try load the objects.
106 if (AliMpDDLStore::Instance(warn) != NULL and AliMpDEStore::Instance(warn) != NULL)
109 AliCDBManager* cdbManager = AliCDBManager::Instance();
110 if (cdbManager == NULL)
112 HLTError("CDB manager instance does not exist.");
116 const char* cdbPathUsed = "unknown (not set)";
117 AliCDBStorage* store = cdbManager->GetDefaultStorage();
118 if (store != NULL) cdbPathUsed = store->GetURI().Data();
120 Int_t runUsed = cdbManager->GetRun();
122 // Now we can try load the DDL and DE store objects.
123 if (not AliMpCDB::LoadDDLStore(warn))
125 HLTError("Failed to load DDL or detector element store specified"
126 " for CDB path '%s' and run no. %d.",
132 if (AliMpDDLStore::Instance(warn) == NULL or AliMpDEStore::Instance(warn) == NULL)
134 HLTError("Could not find or load the DDL or detector element store instance.");
142 int AliHLTMUONProcessor::FetchTMapFromCDB(const char* pathToEntry, TMap*& map) const
144 /// Fetches a TMap object from the CDB.
145 /// [in] \param pathToEntry The relative path to the entry in the CDB to fetch.
146 /// [out] \param map This will be filled with the TMap object found if
147 /// a successful status code is returned. Otherwise it will be unchanged.
148 /// \return Zero if the object could be found. Otherwise an error code,
149 /// which is compatible with the HLT framework, is returned.
151 assert(AliCDBManager::Instance() != NULL);
153 AliCDBEntry* entry = AliCDBManager::Instance()->Get(pathToEntry);
156 HLTError("Could not get the CDB entry for \"%s\".", pathToEntry);
160 TObject* obj = entry->GetObject();
163 HLTError("Configuration object for \"%s\" is missing.", pathToEntry);
167 if (obj->IsA() != TMap::Class())
169 HLTError("Wrong type for configuration object in \"%s\". Found a %s but we need a TMap.",
170 pathToEntry, obj->ClassName()
174 map = dynamic_cast<TMap*>(obj);
180 int AliHLTMUONProcessor::GetValueFromTMap(
181 TMap* map, const char* paramName, TString& value,
182 const char* pathToEntry, const char* prettyName
185 /// Tries to find the string value associated with a certain parameter in a TMap.
186 /// [in] \param map The TMap object to search in.
187 /// [in] \param paramName The name of the parameter to search for.
188 /// [out] \param value Will be filled with the object found.
189 /// [in] \param pathToEntry The relative path to the entry in the CDB.
190 /// Used when printing error messages. If set to NULL then a string of
191 /// "(unknown)" is used. (default is NULL).
192 /// [in] \param prettyName Should be the name of the parameter which will
193 /// be used when printing error messages. If this is set to NULL then
194 /// the paramName will be used instead (default is NULL).
195 /// \return Zero if the object could be found. Otherwise an error code,
196 /// which is compatible with the HLT framework, is returned.
198 if (pathToEntry == NULL) pathToEntry = "(unknown)";
199 if (prettyName == NULL) prettyName = paramName;
201 TPair* pair = static_cast<TPair*>(map->FindObject(paramName));
204 HLTError("Configuration object for \"%s\" does not contain the %s value.",
205 pathToEntry, prettyName
209 TObject* valueObj = pair->Value();
210 if (valueObj->IsA() != TObjString::Class())
212 HLTError("The %s parameter found in configuration object \"%s\""
213 " is not a TObjString. Found an object of type %s instead.",
214 prettyName, pathToEntry, valueObj->ClassName()
218 value = dynamic_cast<TObjString*>(valueObj)->GetString();
224 int AliHLTMUONProcessor::GetIntFromTMap(
225 TMap* map, const char* paramName, Int_t& value,
226 const char* pathToEntry, const char* prettyName
229 /// Tries to find a certain parameter in the TMap object and convert it to
230 /// an integer value.
231 /// [in] \param map The TMap object to search in.
232 /// [in] \param paramName The name of the parameter to search for.
233 /// [out] \param value Will be filled with the integer value for the parameter,
234 /// if it was found and it was an integer value.
235 /// [in] \param pathToEntry The relative path to the entry in the CDB.
236 /// Used when printing error messages. If set to NULL then a string of
237 /// "(unknown)" is used. (default is NULL).
238 /// [in] \param prettyName Should be the name of the parameter which will
239 /// be used when printing error messages. If this is set to NULL then
240 /// the paramName will be used instead (default is NULL).
241 /// \return Zero if the object could be found and is valid. Otherwise an
242 /// error code, which is compatible with the HLT framework, is returned.
244 if (pathToEntry == NULL) pathToEntry = "(unknown)";
245 if (prettyName == NULL) prettyName = paramName;
248 int result = GetValueFromTMap(map, paramName, valueStr, pathToEntry, prettyName);
249 if (result != 0) return result;
251 if (not valueStr.IsDigit())
253 HLTError("The %s parameter found in configuration object \"%s\""
254 "is not a valid integer number string; found \"%s\".",
255 prettyName, pathToEntry, valueStr.Data()
259 value = valueStr.Atoi();
265 int AliHLTMUONProcessor::GetPositiveIntFromTMap(
266 TMap* map, const char* paramName, Int_t& value,
267 const char* pathToEntry, const char* prettyName
270 /// Tries to find a certain parameter in the TMap object and convert it to
271 /// a positive integer value.
272 /// [in] \param map The TMap object to search in.
273 /// [in] \param paramName The name of the parameter to search for.
274 /// [out] \param value Will be filled with the integer value for the parameter,
275 /// if it was found and it was a positive integer value.
276 /// [in] \param pathToEntry The relative path to the entry in the CDB.
277 /// Used when printing error messages. If set to NULL then a string of
278 /// "(unknown)" is used. (default is NULL).
279 /// [in] \param prettyName Should be the name of the parameter which will
280 /// be used when printing error messages. If this is set to NULL then
281 /// the paramName will be used instead (default is NULL).
282 /// \return Zero if the object could be found and is valid. Otherwise an
283 /// error code, which is compatible with the HLT framework, is returned.
285 if (pathToEntry == NULL) pathToEntry = "(unknown)";
286 if (prettyName == NULL) prettyName = paramName;
289 int result = GetValueFromTMap(map, paramName, valueStr, pathToEntry, prettyName);
290 if (result != 0) return result;
292 if (not valueStr.IsDigit())
294 HLTError("The %s parameter found in configuration object \"%s\""
295 "is not a valid integer number string; found \"%s\".",
296 prettyName, pathToEntry, valueStr.Data()
300 Int_t val = valueStr.Atoi();
303 HLTError("The %s parameter found in configuration object \"%s\""
304 "is not a positive integer number; found \"%d\".",
305 prettyName, pathToEntry, val
315 int AliHLTMUONProcessor::GetFloatFromTMap(
316 TMap* map, const char* paramName, Double_t& value,
317 const char* pathToEntry, const char* prettyName
320 /// Tries to find a certain parameter in the TMap object and convert it to
321 /// an floating point value.
322 /// [in] \param map The TMap object to search in.
323 /// [in] \param paramName The name of the parameter to search for.
324 /// [out] \param value Will be filled with the floating point value for the
325 /// parameter, if it was found and it was a floating point value.
326 /// [in] \param pathToEntry The relative path to the entry in the CDB.
327 /// Used when printing error messages. If set to NULL then a string of
328 /// "(unknown)" is used. (default is NULL).
329 /// [in] \param prettyName Should be the name of the parameter which will
330 /// be used when printing error messages. If this is set to NULL then
331 /// the paramName will be used instead (default is NULL).
332 /// \return Zero if the object could be found and is valid. Otherwise an
333 /// error code, which is compatible with the HLT framework, is returned.
335 if (pathToEntry == NULL) pathToEntry = "(unknown)";
336 if (prettyName == NULL) prettyName = paramName;
339 int result = GetValueFromTMap(map, paramName, valueStr, pathToEntry, prettyName);
340 if (result != 0) return result;
342 if (not valueStr.IsFloat())
344 HLTError("The %s parameter found in configuration object \"%s\""
345 "is not a valid floating point number string; found \"%s\".",
346 prettyName, pathToEntry, valueStr.Data()
350 value = valueStr.Atof();
356 int AliHLTMUONProcessor::GetPositiveFloatFromTMap(
357 TMap* map, const char* paramName, Double_t& value,
358 const char* pathToEntry, const char* prettyName
361 /// Tries to find a certain parameter in the TMap object and convert it to
362 /// an positive floating point value.
363 /// [in] \param map The TMap object to search in.
364 /// [in] \param paramName The name of the parameter to search for.
365 /// [out] \param value Will be filled with the floating point value for the
366 /// parameter, if it was found and it was a positive floating point value.
367 /// [in] \param pathToEntry The relative path to the entry in the CDB.
368 /// Used when printing error messages. If set to NULL then a string of
369 /// "(unknown)" is used. (default is NULL).
370 /// [in] \param prettyName Should be the name of the parameter which will
371 /// be used when printing error messages. If this is set to NULL then
372 /// the paramName will be used instead (default is NULL).
373 /// \return Zero if the object could be found and is valid. Otherwise an
374 /// error code, which is compatible with the HLT framework, is returned.
376 if (pathToEntry == NULL) pathToEntry = "(unknown)";
377 if (prettyName == NULL) prettyName = paramName;
380 int result = GetValueFromTMap(map, paramName, valueStr, pathToEntry, prettyName);
381 if (result != 0) return result;
383 if (not valueStr.IsFloat())
385 HLTError("The %s parameter found in configuration object \"%s\""
386 "is not a valid floating point number string; found \"%s\".",
387 prettyName, pathToEntry, valueStr.Data()
391 Double_t val = valueStr.Atof();
394 HLTError("The %s parameter found in configuration object \"%s\""
395 "is not a positive floating point number; found \"%d\".",
396 prettyName, pathToEntry, val