]>
Commit | Line | Data |
---|---|---|
e58fb035 | 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: Sebastian Bablok <Sebastian.Bablok@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 | ||
425695db | 19 | // @file AliHLTPendolino.cxx |
20 | // @author Sebastian Bablok | |
21 | // @date | |
22 | // @brief | |
2c669e9b | 23 | // @note maintained by Matthias.Richter@ift.uib.no |
e58fb035 | 24 | |
25 | #include "AliHLTPendolino.h" | |
26 | ||
27 | #include "AliHLTPredictionProcessorInterface.h" | |
28 | #include "AliHLTPendolinoLogger.h" | |
29 | #include "AliHLTPendolinoLoggerOStream.h" | |
ea6b7ed6 | 30 | #include "AliHLTLogging.h" |
e58fb035 | 31 | |
32 | #include <AliCDBPath.h> | |
33 | #include <AliCDBEntry.h> | |
34 | #include <AliCDBManager.h> | |
35 | #include <AliCDBStorage.h> | |
36 | #include <AliPreprocessor.h> | |
37 | #include <AliCDBId.h> | |
38 | ||
39 | #include <TObjString.h> | |
40 | #include <TTimeStamp.h> | |
41 | ||
42 | #include <fstream> | |
43 | #include <stdexcept> | |
a4763975 | 44 | #include <cstdlib> |
e58fb035 | 45 | |
46 | ||
47 | using namespace std; | |
48 | ||
e58fb035 | 49 | ClassImp(AliHLTPendolino) |
ea6b7ed6 | 50 | |
e58fb035 | 51 | |
52 | /** Static string to define a local storage for the OCDB contact. */ | |
2c669e9b | 53 | const TString AliHLTPendolino::fgkLocalStorageDefine = "local://"; |
e58fb035 | 54 | |
2c669e9b | 55 | const char* AliHLTPendolino::fgkHLTInterfaceModule = "Pendolino-Core"; |
e58fb035 | 56 | |
2c669e9b | 57 | const TString AliHLTPendolino::fgkTaxiListBaseFolder = getenv("ALIHLT_T_HCDBDIR"); |
e58fb035 | 58 | //"/opt/T-HCDB/lists/lists-taxi/"; |
59 | ||
2c669e9b | 60 | const TString AliHLTPendolino::fgkTaxiListFolderName = "lists/lists-taxi/"; |
e58fb035 | 61 | |
2c669e9b | 62 | const TString AliHLTPendolino::fgkTaxiListPendolino = "Pendolino.list"; |
e58fb035 | 63 | |
2c669e9b | 64 | const Int_t AliHLTPendolino::fgkMaxLineLength = 256; |
e58fb035 | 65 | |
2c669e9b | 66 | const Int_t AliHLTPendolino::fgkHLTPendolinoException = -10; |
e58fb035 | 67 | |
2c669e9b | 68 | const Int_t AliHLTPendolino::fgkHLTPendolinoBadCast = -9; |
e58fb035 | 69 | |
2c669e9b | 70 | const Int_t AliHLTPendolino::fgkHLTPendolinoNotPredictProc = -8; |
e58fb035 | 71 | |
2c669e9b | 72 | const Int_t AliHLTPendolino::fgkHLTPendolinoModuleNotExisting = -7; |
e58fb035 | 73 | |
2c669e9b | 74 | const Int_t AliHLTPendolino::fgkHLTPendolinoNoDCS = -6; |
e58fb035 | 75 | |
76 | //const Int_t AliHLTPendolino:: | |
77 | ||
78 | ||
79 | ||
8d6c34c9 | 80 | AliHLTPendolino::AliHLTPendolino(Int_t run, TString HCDBbase, TString runType, |
81 | AliHLTPendolinoLogger* logger, UInt_t startTime, UInt_t endTime) : | |
82 | fRunType(runType), fRunNumber(run), | |
bf560255 | 83 | fHCDBPath(""), fPredictionProcessorMap(), |
8d6c34c9 | 84 | fpLogger(0), fOwnLogger(kFALSE), |
2c669e9b | 85 | fStartTime(startTime), fEndTime(endTime) |
86 | { | |
87 | // see header file for class documentation | |
88 | // or | |
89 | // refer to README to build package | |
90 | // or | |
91 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
92 | ||
e58fb035 | 93 | // C-tor of AliHLTPendolino |
2c669e9b | 94 | fHCDBPath = fgkLocalStorageDefine + HCDBbase; |
e58fb035 | 95 | if (logger == 0) { |
bf560255 | 96 | fpLogger = new AliHLTPendolinoLoggerOStream(); |
97 | fOwnLogger = kTRUE; | |
e58fb035 | 98 | } else { |
bf560255 | 99 | fpLogger = logger; |
100 | fOwnLogger = kFALSE; | |
e58fb035 | 101 | } |
102 | } | |
103 | ||
104 | ||
105 | AliHLTPendolino::~AliHLTPendolino() { | |
106 | // D-tor of AliHLTPendolino | |
107 | // clean up registered PredicitonProcs | |
bf560255 | 108 | TMapIter iter(&fPredictionProcessorMap, kIterForward); |
e58fb035 | 109 | AliHLTPredictionProcessorInterface* aPredict; |
110 | TObject* key = 0; | |
111 | ||
112 | // get each key inside the map | |
113 | while ((key = iter.Next())) { | |
114 | TString detector = key->GetName(); | |
115 | ||
116 | try { | |
117 | // get value for the key | |
118 | aPredict = dynamic_cast<AliHLTPredictionProcessorInterface*> | |
bf560255 | 119 | (fPredictionProcessorMap.GetValue(key)); |
e58fb035 | 120 | |
121 | if (aPredict == 0) { | |
2c669e9b | 122 | Log(fgkHLTInterfaceModule, |
e58fb035 | 123 | " *** ERROR, cannot delete registered processor '" |
124 | + detector + "'; does not seem to be a PredictionProcessor."); | |
125 | continue; | |
126 | } | |
2c669e9b | 127 | Log(fgkHLTInterfaceModule, " ### [DEBUG] deleting PredictProc '" + |
e58fb035 | 128 | detector + "'."); |
129 | delete aPredict; | |
130 | } catch (std::bad_cast) { | |
131 | // failed -> is not a AliHLTPredictionProcessorInterface implementation | |
132 | // -> discarding call | |
2c669e9b | 133 | Log(fgkHLTInterfaceModule, " *** ERROR, cannot delete registered processor '" |
e58fb035 | 134 | + detector + "'; does not seem to be a PredictionProcessor.."); |
135 | continue; | |
136 | ||
137 | } catch (std::exception& e) { | |
2c669e9b | 138 | Log(fgkHLTInterfaceModule, |
e58fb035 | 139 | " *** Exception in call for deleting PrecitionProcessor '" |
140 | + detector + "'."); | |
141 | continue; | |
142 | } | |
143 | } | |
2c669e9b | 144 | Log(fgkHLTInterfaceModule, " ### [DEBUG] Deleting of PredictionProcessors finished."); |
e58fb035 | 145 | |
146 | // clean up logger | |
bf560255 | 147 | if ((fOwnLogger) && (fpLogger != 0)) { |
148 | delete fpLogger; | |
e58fb035 | 149 | } |
150 | ||
151 | } | |
152 | ||
153 | ||
154 | // inherited virtual functions, maybe use them from base class | |
155 | Bool_t AliHLTPendolino::Store(const AliCDBPath& path, TObject* object, | |
156 | AliCDBMetaData* metaData, Int_t validityStart, | |
157 | Bool_t validityInfinite) { | |
158 | // stores a entry in HCDB | |
159 | Bool_t retVal = kFALSE; | |
160 | Int_t startNumber = 0; | |
161 | Int_t endNumber = 0; | |
162 | AliCDBManager* man = 0; | |
2c669e9b | 163 | AliCDBStorage* localHCDB = 0; |
e58fb035 | 164 | |
bf560255 | 165 | startNumber = ((fRunNumber - validityStart) <= 0) ? 0 : (fRunNumber - validityStart); |
166 | endNumber = (validityInfinite) ? AliCDBRunRange::Infinity() : fRunNumber; | |
e58fb035 | 167 | |
168 | man = AliCDBManager::Instance(); | |
169 | if (man == 0) { | |
2c669e9b | 170 | Log(fgkHLTInterfaceModule, " *** ERROR cannot obtain a CDB Manager reference."); |
e58fb035 | 171 | return kFALSE; |
172 | } | |
173 | ||
174 | // contact local storage (HCDB) | |
2c669e9b | 175 | localHCDB = man->GetStorage(fHCDBPath.Data()); |
176 | if (localHCDB == 0) { | |
e58fb035 | 177 | TString msg(" *** ERROR in initiating HCDB: "); |
bf560255 | 178 | msg += fHCDBPath; |
2c669e9b | 179 | Log(fgkHLTInterfaceModule, msg.Data()); |
e58fb035 | 180 | man->DestroyActiveStorages(); |
181 | return kFALSE; | |
182 | } | |
183 | ||
184 | // taken from AliShuttle | |
185 | if (! dynamic_cast<TObjString*> (metaData->GetProperty("RunUsed(TObjString)"))) { | |
bf560255 | 186 | TObjString runUsed = Form("%d", fRunNumber); |
e58fb035 | 187 | metaData->SetProperty("RunUsed(TObjString)", runUsed.Clone()); |
188 | } | |
189 | ||
190 | ||
191 | // Version is set to current run, it will be used later to transfer data to Grid | |
192 | // Why using current run number as version number ??? | |
bf560255 | 193 | AliCDBId entryID(path, startNumber, endNumber, fRunNumber, -1); |
e58fb035 | 194 | |
2c669e9b | 195 | if (localHCDB->Put(object, entryID, metaData)) { |
e58fb035 | 196 | retVal = kTRUE; |
197 | } else { | |
198 | TString msg(" *** Unable to store DCS data to HCDB: "); | |
199 | msg += entryID.ToString(); | |
2c669e9b | 200 | Log(fgkHLTInterfaceModule, msg.Data()); |
e58fb035 | 201 | } |
202 | ||
203 | man->DestroyActiveStorages(); | |
204 | ||
205 | return retVal; | |
206 | } | |
207 | ||
208 | ||
209 | Bool_t AliHLTPendolino::StoreReferenceData(const AliCDBPath& path, | |
bf560255 | 210 | TObject* /*object*/, AliCDBMetaData* /*metaData*/) { |
e58fb035 | 211 | // Disabled Function inherited from interface |
212 | TString msg(" ~~~ PredictProc tries to store reference data to '" | |
213 | + path.GetPath() + "'. Discarding call in Pendolino."); | |
2c669e9b | 214 | Log(fgkHLTInterfaceModule, msg.Data()); |
e58fb035 | 215 | |
216 | return kFALSE; | |
217 | } | |
218 | ||
219 | ||
220 | Bool_t AliHLTPendolino::StoreReferenceFile(const char* detector, | |
221 | const char* localFile, const char* gridFileName) { | |
222 | // Disabled Function inherited from interface | |
223 | TString msg; | |
224 | TString det(detector); | |
225 | TString filename(localFile); | |
226 | TString gridname(gridFileName); | |
227 | msg = " ~~~ PredictProc (" + det + ") tries to store reference file (" + | |
228 | filename + ") to '" + gridname + | |
229 | "'. Discarding call in Pendolino."; | |
2c669e9b | 230 | Log(fgkHLTInterfaceModule, msg.Data()); |
e58fb035 | 231 | |
232 | return kFALSE; | |
233 | } | |
234 | ||
235 | ||
236 | Bool_t AliHLTPendolino::StoreRunMetadataFile(const char* localFile, | |
237 | const char* gridFileName) { | |
238 | // Disabled Function inherited from interface | |
239 | TString msg; | |
240 | ||
241 | TString filename(localFile); | |
242 | TString gridname(gridFileName); | |
243 | msg = " ~~~ PredictProc tries to store 'run meta data' file (" + | |
244 | filename + ") to '" + gridname + "'. Discarding call in Pendolino."; | |
2c669e9b | 245 | Log(fgkHLTInterfaceModule, msg.Data()); |
e58fb035 | 246 | |
247 | return kFALSE; | |
248 | } | |
249 | ||
250 | ||
251 | const char* AliHLTPendolino::GetFile(Int_t system, const char* detector, | |
252 | const char* id, const char* source) { | |
253 | // Disabled Function inherited from interface | |
254 | TString msg; | |
255 | TString det(detector); | |
256 | TString filename(id); | |
257 | TString src(source); | |
258 | TString from(GetSystemName(system)); | |
259 | msg = " ~~~ PredictProc (" + det + ") requests file (" + filename + ") from '" | |
260 | + src + "' at " + from + ". Discarding call in Pendolino."; | |
2c669e9b | 261 | Log(fgkHLTInterfaceModule, msg.Data()); |
e58fb035 | 262 | |
263 | return NULL; | |
264 | } | |
265 | ||
266 | const char* AliHLTPendolino::GetTriggerConfiguration() { | |
267 | // Disabled Function inherited from interface | |
268 | TString msg; | |
269 | msg = " ~~~ PredictProc tries to request Trigger configuration, this is disabled. Discarding call in Pendolino."; | |
2c669e9b | 270 | Log(fgkHLTInterfaceModule, msg.Data()); |
e58fb035 | 271 | |
272 | return NULL; | |
273 | } | |
274 | ||
b48d2542 | 275 | const char* AliHLTPendolino::GetTriggerDetectorMask() { |
276 | // Disabled Function inherited from interface | |
277 | TString msg; | |
278 | msg = " ~~~ PredictProc tries to request Trigger configuration, this is disabled. Discarding call in Pendolino."; | |
2c669e9b | 279 | Log(fgkHLTInterfaceModule, msg.Data()); |
b48d2542 | 280 | |
281 | return NULL; | |
282 | } | |
283 | ||
e58fb035 | 284 | |
285 | TList* AliHLTPendolino::GetFileSources(Int_t system, const char* detector, | |
286 | const char* id) { | |
287 | // Disabled Function inherited from interface | |
288 | TString msg; | |
289 | TString det(detector); | |
290 | TString filename(id); | |
291 | TString from(GetSystemName(system)); | |
292 | msg = " ~~~ PredictProc (" + det + ") requests file sources for (" + filename | |
293 | + ") from '" + from + ". Discarding call in Pendolino."; | |
2c669e9b | 294 | Log(fgkHLTInterfaceModule, msg.Data()); |
e58fb035 | 295 | |
296 | return NULL; | |
297 | } | |
298 | ||
299 | ||
300 | TList* AliHLTPendolino::GetFileIDs(Int_t system, const char* detector, | |
301 | const char* source) { | |
302 | // Disabled Function inherited from interface | |
303 | TString msg; | |
304 | TString det(detector); | |
305 | TString filename(source); | |
306 | TString from(GetSystemName(system)); | |
307 | msg = " ~~~ PredictProc (" + det + ") requests file IDs for (" + filename | |
308 | + ") from '" + from + ". Discarding call in Pendolino."; | |
2c669e9b | 309 | Log(fgkHLTInterfaceModule, msg.Data()); |
e58fb035 | 310 | |
311 | return NULL; | |
312 | } | |
313 | ||
314 | ||
bf560255 | 315 | const char* AliHLTPendolino::GetRunParameter(const char* /*lbEntry*/) { |
e58fb035 | 316 | // getter for run parameter |
317 | ||
318 | // TODO | |
319 | // maybe using a parameter file, where these settings are stored at start up by | |
320 | // the starting script and a dedicated class read and stores its content. | |
321 | ||
2c669e9b | 322 | Log(fgkHLTInterfaceModule, |
e58fb035 | 323 | " ### GetRunParameter are not defined, yet. Feature will be available soon."); |
324 | return NULL; | |
325 | } | |
326 | ||
327 | ||
328 | Bool_t AliHLTPendolino::GetHLTStatus() { | |
329 | // getter for HLT status | |
330 | // since this is the Pendolino -> always true | |
331 | return kTRUE; | |
332 | } | |
333 | ||
334 | ||
335 | AliCDBEntry* AliHLTPendolino::GetFromOCDB(const char* detector, | |
336 | const AliCDBPath& path) { | |
337 | // fetches entry from HCDB | |
338 | AliCDBManager *man = AliCDBManager::Instance(); | |
e58fb035 | 339 | |
340 | if (man == 0) { | |
341 | TString msg(" *** ERROR, cannot obtain a CDB Manager reference for: "); | |
342 | msg += detector; | |
2c669e9b | 343 | Log(fgkHLTInterfaceModule, msg.Data()); |
e58fb035 | 344 | return NULL; |
345 | } | |
346 | ||
bf560255 | 347 | AliCDBStorage *hcdb = man->GetStorage(fHCDBPath.Data()); |
e58fb035 | 348 | if (hcdb == 0) { |
349 | TString msg(" *** ERROR, cannot acquire HCDB storage ("); | |
bf560255 | 350 | msg += fHCDBPath + ") for fetching data for Pendolino."; |
2c669e9b | 351 | Log(fgkHLTInterfaceModule, msg.Data()); |
e58fb035 | 352 | return NULL; |
353 | } | |
354 | ||
18de5938 | 355 | if (hcdb->GetLatestVersion(path.GetPath(), fRunNumber)<0) { |
356 | return NULL; | |
e58fb035 | 357 | } |
358 | ||
18de5938 | 359 | return hcdb->Get(path, fRunNumber); |
360 | ||
e58fb035 | 361 | |
362 | /* | |
363 | AliCDBEntry* entry = 0; | |
364 | try { | |
bf560255 | 365 | entry = dynamic_cast<AliCDBEntry*> (hcdb->Get(path, fRunNumber)); |
e58fb035 | 366 | } catch (std::bad_cast) { |
367 | TString msg(" *** ERROR, bad cast of HCDB entry ("); | |
368 | msg += path.GetPath() + ") after fetching from HCDB."; | |
2c669e9b | 369 | Log(fgkHLTInterfaceModule, msg.Data()); |
e58fb035 | 370 | return NULL; |
371 | } | |
372 | return entry; | |
373 | */ | |
374 | ||
375 | } | |
376 | ||
377 | ||
425695db | 378 | Bool_t AliHLTPendolino::IncludeAliCDBEntryInList(const TString& entryPath) { |
e58fb035 | 379 | // includes entry in Taxi list (objects to be fetched from OCDB) |
380 | Bool_t bRet = kFALSE; | |
381 | ifstream infile; | |
382 | ofstream outfile; | |
383 | TString filename; | |
384 | TTimeStamp ts; | |
385 | ||
2c669e9b | 386 | filename = fgkTaxiListBaseFolder + "/" + fgkTaxiListFolderName + |
387 | fgkTaxiListPendolino; | |
388 | Log(fgkHLTInterfaceModule, filename + " [DEBUG] filename"); | |
e58fb035 | 389 | |
390 | infile.open(filename, ios_base::in); | |
391 | if (infile.is_open()) { | |
2c669e9b | 392 | char line[fgkMaxLineLength]; |
e58fb035 | 393 | |
394 | while (!infile.eof()) { | |
2c669e9b | 395 | infile.getline(line, fgkMaxLineLength); |
e58fb035 | 396 | if (strncmp(line, entryPath.Data(), entryPath.Length()) == 0) { |
397 | // entry already exists, leave function after proper clean up | |
398 | TString msg(" --- Entry '"); | |
399 | msg += entryPath + "' is already included in Taxi list file."; | |
2c669e9b | 400 | Log(fgkHLTInterfaceModule, msg.Data()); |
e58fb035 | 401 | infile.close(); |
402 | return kTRUE; | |
403 | } | |
404 | } | |
405 | infile.close(); | |
406 | ||
407 | // include entry to list | |
408 | outfile.open(filename, ios_base::out | ios_base::app); | |
409 | if (!outfile.is_open()) { | |
410 | TString msg(" *** Unable to create Pendolino list file '"); | |
411 | msg += filename + "' for Taxi. Continueing without list update..."; | |
2c669e9b | 412 | Log(fgkHLTInterfaceModule, msg.Data()); |
e58fb035 | 413 | return kFALSE; |
414 | } | |
415 | // outfile.seekp(-1, ios::end); | |
416 | outfile << endl; | |
bf560255 | 417 | outfile << "#HLT (Pendolino) - Run: " << fRunNumber << ", Time: " << |
e58fb035 | 418 | ts.AsString() << endl; |
419 | outfile << entryPath.Data() << endl; | |
420 | outfile.close(); | |
421 | ||
422 | TString msg(" +++ Included missing entry '"); | |
423 | msg += entryPath + "' in Taxi list file."; | |
2c669e9b | 424 | Log(fgkHLTInterfaceModule, msg.Data()); |
e58fb035 | 425 | bRet = kTRUE; |
426 | ||
427 | } else { | |
428 | TString msg(" ~~~ Unable to open Pendolino list file '"); | |
429 | msg += filename + "' for Taxi. Creating new one."; | |
2c669e9b | 430 | Log(fgkHLTInterfaceModule, msg.Data()); |
e58fb035 | 431 | outfile.open(filename, ios_base::out); |
432 | ||
433 | if (outfile.is_open()) { | |
434 | outfile << "# Automatic generated Taxi list." << endl; | |
435 | outfile << "# It contains the OCDB entries required by the Pendolino." | |
436 | << endl << "#" << endl; | |
437 | outfile << "# !!! DON'T EDIT THIS FILE (if you don't know what you are doing) !!!" | |
438 | << endl << endl; | |
bf560255 | 439 | outfile << "#HLT (Pendolino) - Run: " << fRunNumber << ", Time: " << |
e58fb035 | 440 | ts.AsString() << endl; |
441 | outfile << entryPath.Data() << endl; | |
442 | outfile.close(); | |
443 | bRet = kTRUE; | |
444 | ||
445 | } else { | |
bf560255 | 446 | msg=" *** Unable to create Pendolino list file '"; |
e58fb035 | 447 | msg += filename + "' for Taxi. Continueing without list update..."; |
2c669e9b | 448 | Log(fgkHLTInterfaceModule, msg.Data()); |
e58fb035 | 449 | } |
450 | } | |
451 | ||
452 | return bRet; | |
453 | } | |
454 | ||
455 | ||
456 | void AliHLTPendolino::Log(const char* detector, const char* message) { | |
457 | // logging function | |
8d3510ac | 458 | if (fpLogger) fpLogger->log(detector, message); |
e58fb035 | 459 | // refer data to a Pendolino Logger, which can take care of it |
460 | } | |
461 | ||
462 | ||
463 | void AliHLTPendolino::RegisterPreprocessor(AliPreprocessor* preprocessor) { | |
464 | // registers a PredictionProcessor | |
465 | if (preprocessor == 0) { | |
2c669e9b | 466 | Log(fgkHLTInterfaceModule, |
e58fb035 | 467 | " *** ERROR: Cannot register NULL pointer as PredictionProcessor."); |
468 | return; | |
469 | } | |
470 | ||
471 | TString detector(preprocessor->GetName()); | |
472 | ||
bf560255 | 473 | if (fPredictionProcessorMap.GetValue(detector.Data())) { |
2c669e9b | 474 | Log(fgkHLTInterfaceModule, " ~~~ Already registered PredictionProcessor '" + |
e58fb035 | 475 | detector + "'. Ignoring call."); |
476 | return; | |
477 | } | |
478 | // store as AliPreprocessor* and make cast to AliHLTPredictionProcessorInterface* | |
479 | // later, when accesing them. | |
bf560255 | 480 | fPredictionProcessorMap.Add(new TObjString(detector), preprocessor); |
e58fb035 | 481 | |
482 | /* | |
483 | TString detector(preprocessor->GetName()); | |
484 | AliHLTPredictionProcessorInterface* predictProc = 0; | |
485 | // UInt_t retVal = 0; | |
486 | ||
487 | // TODO move this in seperated call outside RegisterPreprocessor(..) | |
488 | // safety reason, since preprocessor is not completely generated yet | |
489 | if (!preprocessor->ProcessDCS()) { | |
2c669e9b | 490 | Log(fgkHLTInterfaceModule, " *** PredictionProcessor '" + detector + |
e58fb035 | 491 | "' not registered, because it will not process DCS values."); |
492 | return; | |
493 | } | |
2c669e9b | 494 | Log(fgkHLTInterfaceModule, "Module Processes DCS values, Registering PredictionProc " |
e58fb035 | 495 | + detector); |
496 | ||
497 | // don't use this check, if there are several PreProcs from one detector | |
498 | // they will have all have different names | |
499 | //if (GetDetPos(detector.Data()) < 0) { | |
2c669e9b | 500 | // Log(fgkHLTInterfaceModule, " *** Invalid detector name: " + detector); |
e58fb035 | 501 | //} |
502 | ||
503 | // Check if preprocessor is actually PredictionProcessor | |
504 | try { | |
505 | ||
506 | predictProc = reinterpret_cast<AliHLTPredictionProcessorInterface*> | |
507 | (preprocessor); | |
508 | // Don't use dynamic_cast or C-style cast, they only rename the pointer/object, | |
509 | // but don't import the extended members -> use reinterpret_cast. Maybe perform | |
510 | // dynamic_cast check in other function, which is not called inside a C-tor | |
511 | // of AliHLTPredictionProcessorInterface. | |
512 | ||
513 | // ATTENTION: Don't call any functions of AliHLTPredictionProcessorInterface here | |
514 | // the object has not been completely generated yet, only AliPreprocessor part | |
515 | // is available. Call of these function should be performed in seperate call outside | |
516 | // RegisterPreprocessor(..).) | |
517 | ||
518 | } catch (std::bad_cast) { | |
519 | // failed -> is not a AliHLTPredictionProcessorInterface implementation | |
520 | // -> discarding call | |
2c669e9b | 521 | Log(fgkHLTInterfaceModule, " *** Cannot register PredictionProcessor '" + detector + |
e58fb035 | 522 | "'. Does not implement the AliHLTPredictionProcessorInterface."); |
523 | return; | |
524 | } catch (std::exception& e) { | |
2c669e9b | 525 | Log(fgkHLTInterfaceModule, " *** Exception in the registering of the PredictProc."); |
e58fb035 | 526 | } |
527 | ||
bf560255 | 528 | if (fPredictionProcessorMap.GetValue(detector.Data())) { |
2c669e9b | 529 | Log(fgkHLTInterfaceModule, " ~~~ Already registered PredictionProcessor '" + |
e58fb035 | 530 | detector + "'. Ignoring call."); |
531 | return; | |
532 | } | |
533 | ||
bf560255 | 534 | fPredictionProcessorMap.Add(new TObjString(detector), predictProc); |
e58fb035 | 535 | */ |
536 | } | |
537 | ||
538 | ||
425695db | 539 | UInt_t AliHLTPendolino::SetToPredictMaking() { |
e58fb035 | 540 | // switches prdiction making on in all registered PredictioProcessors |
541 | UInt_t retVal = 0; | |
542 | ||
543 | // get an iterator for the map | |
bf560255 | 544 | TMapIter iter(&fPredictionProcessorMap, kIterForward); |
e58fb035 | 545 | AliHLTPredictionProcessorInterface* aPredict; |
546 | TObject* key = 0; | |
547 | ||
548 | // get each key inside the map | |
549 | while ((key = iter.Next())) { | |
550 | TString detector = key->GetName(); | |
551 | ||
552 | try { | |
553 | // get value for the key | |
554 | aPredict = dynamic_cast<AliHLTPredictionProcessorInterface*> | |
bf560255 | 555 | (fPredictionProcessorMap.GetValue(key)); |
e58fb035 | 556 | |
557 | if (aPredict == 0) { | |
2c669e9b | 558 | Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '" |
e58fb035 | 559 | + detector + |
560 | "'. Does not implement the AliHLTPredictionProcessorInterface."); | |
561 | continue; | |
562 | } | |
563 | // detector = aPredict->GetName(); | |
564 | ||
565 | if ((aPredict->ProcessDCS()) && (aPredict->makePrediction() == 0)) { | |
566 | retVal++; | |
567 | } else { | |
2c669e9b | 568 | Log(fgkHLTInterfaceModule, " *** PredictionProcessor '" + detector |
e58fb035 | 569 | + "' does not allow DCS processing or failed to init prediction making."); |
570 | } | |
571 | } catch (std::bad_cast) { | |
572 | // failed -> is not a AliHLTPredictionProcessorInterface implementation | |
573 | // -> discarding call | |
2c669e9b | 574 | Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '" |
e58fb035 | 575 | + detector + |
576 | "'. Does not implement the AliHLTPredictionProcessorInterface."); | |
577 | continue; | |
578 | ||
579 | } catch (std::exception& e) { | |
2c669e9b | 580 | Log(fgkHLTInterfaceModule, " *** Exception in call for makePrediction of " |
e58fb035 | 581 | + detector + "."); |
582 | continue; | |
583 | } | |
584 | } | |
585 | return retVal; | |
586 | } | |
587 | ||
588 | ||
589 | Int_t AliHLTPendolino::setToPredictMaking(TString detector) { | |
590 | // switches prediction making on in chosen PreditionProcessor | |
591 | Int_t retVal = 0; | |
592 | AliHLTPredictionProcessorInterface* aPredict = 0; | |
593 | ||
594 | try { | |
595 | // get the value for the key | |
bf560255 | 596 | TObject* object = fPredictionProcessorMap.GetValue(detector.Data()); |
e58fb035 | 597 | |
598 | if (object == 0) { | |
2c669e9b | 599 | Log(fgkHLTInterfaceModule, " *** No PredictionProcessor for '" + |
e58fb035 | 600 | detector + "' registered."); |
2c669e9b | 601 | return fgkHLTPendolinoModuleNotExisting; |
e58fb035 | 602 | } |
603 | ||
604 | aPredict = dynamic_cast<AliHLTPredictionProcessorInterface*> (object); | |
605 | ||
606 | if (aPredict == 0) { | |
2c669e9b | 607 | Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '" |
e58fb035 | 608 | + detector + |
609 | "'. Does not implement the AliHLTPredictionProcessorInterface."); | |
2c669e9b | 610 | return fgkHLTPendolinoNotPredictProc; |
e58fb035 | 611 | } |
612 | // detector = aPredict->GetName(); | |
613 | ||
614 | if (!((aPredict->ProcessDCS()) && (aPredict->makePrediction() == 0))) { | |
2c669e9b | 615 | Log(fgkHLTInterfaceModule, " *** PredictionProcessor '" + detector + |
e58fb035 | 616 | "' does not allow DCS processing or failed to init prediction making."); |
2c669e9b | 617 | retVal = fgkHLTPendolinoNoDCS; |
e58fb035 | 618 | } |
619 | ||
620 | } catch (std::bad_cast) { | |
621 | // failed -> is not a AliHLTPredictionProcessorInterface implementation | |
622 | // -> discarding call | |
2c669e9b | 623 | Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '" |
e58fb035 | 624 | + detector + |
625 | "'. Does not implement the AliHLTPredictionProcessorInterface."); | |
2c669e9b | 626 | retVal = fgkHLTPendolinoBadCast; |
e58fb035 | 627 | |
628 | } catch (std::exception& e) { | |
2c669e9b | 629 | Log(fgkHLTInterfaceModule, " *** Exception in call for makePrediction of " |
e58fb035 | 630 | + detector + "."); |
2c669e9b | 631 | retVal = fgkHLTPendolinoException; |
e58fb035 | 632 | } |
633 | ||
634 | return retVal; | |
635 | } | |
636 | ||
637 | ||
425695db | 638 | Int_t AliHLTPendolino::PrepareDCSValues(TString detector, TMap* DCSValues) { |
e58fb035 | 639 | // function to prepare retrieved DCS values |
640 | Int_t retVal = 0; | |
641 | AliHLTPredictionProcessorInterface* aPredict = 0; | |
642 | ||
643 | try { | |
644 | // get the value for the key | |
bf560255 | 645 | TObject* object = fPredictionProcessorMap.GetValue(detector.Data()); |
e58fb035 | 646 | |
647 | if (object == 0) { | |
2c669e9b | 648 | Log(fgkHLTInterfaceModule, " *** No PredictionProcessor for '" + |
e58fb035 | 649 | detector + "' registered."); |
2c669e9b | 650 | return fgkHLTPendolinoModuleNotExisting; |
e58fb035 | 651 | } |
652 | ||
653 | aPredict = dynamic_cast<AliHLTPredictionProcessorInterface*> (object); | |
654 | ||
655 | if (aPredict == 0) { | |
2c669e9b | 656 | Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '" |
e58fb035 | 657 | + detector + |
658 | "'. Does not implement the AliHLTPredictionProcessorInterface."); | |
2c669e9b | 659 | return fgkHLTPendolinoNotPredictProc; |
e58fb035 | 660 | } |
661 | ||
662 | retVal = aPredict->Process(DCSValues); | |
663 | ||
664 | ||
665 | } catch (std::bad_cast) { | |
666 | // failed -> is not a AliHLTPredictionProcessorInterface implementation | |
667 | // -> discarding call | |
2c669e9b | 668 | Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '" |
e58fb035 | 669 | + detector + |
670 | "'. Does not implement the AliHLTPredictionProcessorInterface."); | |
2c669e9b | 671 | retVal = fgkHLTPendolinoBadCast; |
e58fb035 | 672 | |
673 | } catch (std::exception& e) { | |
2c669e9b | 674 | Log(fgkHLTInterfaceModule, " *** Exception in call prepareDCSValues of " |
e58fb035 | 675 | + detector + "."); |
2c669e9b | 676 | retVal = fgkHLTPendolinoException; |
e58fb035 | 677 | } |
678 | ||
679 | return retVal; | |
680 | } | |
681 | ||
425695db | 682 | TMap* AliHLTPendolino::EmulateDCSMap(TString detector, TString aliasName) { |
e58fb035 | 683 | // function to generate test data of given PredictionProcessor |
684 | TMap* result = NULL; | |
685 | AliHLTPredictionProcessorInterface* aPredict = 0; | |
686 | ||
687 | try { | |
688 | // get the value for the key | |
bf560255 | 689 | TObject* object = fPredictionProcessorMap.GetValue(detector.Data()); |
e58fb035 | 690 | |
691 | if (object == 0) { | |
2c669e9b | 692 | Log(fgkHLTInterfaceModule, " *** No PredictionProcessor for '" + |
e58fb035 | 693 | detector + "' registered."); |
694 | return result; | |
695 | } | |
696 | ||
697 | aPredict = dynamic_cast<AliHLTPredictionProcessorInterface*> (object); | |
698 | ||
699 | if (aPredict == 0) { | |
2c669e9b | 700 | Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '" |
e58fb035 | 701 | + detector + |
702 | "'. Does not implement the AliHLTPredictionProcessorInterface."); | |
703 | return result; | |
704 | } | |
705 | ||
706 | result = aPredict->produceTestData(aliasName); | |
707 | ||
708 | ||
709 | } catch (std::bad_cast) { | |
710 | // failed -> is not a AliHLTPredictionProcessorInterface implementation | |
711 | // -> discarding call | |
2c669e9b | 712 | Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '" |
e58fb035 | 713 | + detector + |
714 | "'. Does not implement the AliHLTPredictionProcessorInterface."); | |
715 | ||
716 | } catch (std::exception& e) { | |
2c669e9b | 717 | Log(fgkHLTInterfaceModule, " *** Exception in call emulateDCSMap of " |
e58fb035 | 718 | + detector + "."); |
719 | } | |
720 | return result; | |
721 | } | |
722 | ||
723 | ||
724 | Int_t AliHLTPendolino::initPredictProc(TString detector, Int_t run, | |
725 | UInt_t startTime, UInt_t endTime) { | |
726 | // initializes given PredictionProcessor (defined by detector name) | |
727 | Int_t retVal = 0; | |
728 | AliHLTPredictionProcessorInterface* aPredict = 0; | |
729 | ||
730 | try { | |
731 | // get the value for the key | |
bf560255 | 732 | TObject* object = fPredictionProcessorMap.GetValue(detector.Data()); |
e58fb035 | 733 | |
734 | if (object == 0) { | |
2c669e9b | 735 | Log(fgkHLTInterfaceModule, " *** No PredictionProcessor for '" + |
e58fb035 | 736 | detector + "' registered."); |
2c669e9b | 737 | return fgkHLTPendolinoModuleNotExisting; |
e58fb035 | 738 | } |
739 | ||
740 | aPredict = dynamic_cast<AliHLTPredictionProcessorInterface*> (object); | |
741 | ||
742 | if (aPredict == 0) { | |
2c669e9b | 743 | Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '" |
e58fb035 | 744 | + detector + |
745 | "'. Does not implement the AliHLTPredictionProcessorInterface."); | |
2c669e9b | 746 | return fgkHLTPendolinoNotPredictProc; |
e58fb035 | 747 | } |
748 | ||
749 | // Initialize Prediction Processor | |
750 | aPredict->Initialize(run, startTime, endTime); | |
751 | ||
752 | } catch (std::bad_cast) { | |
753 | // failed -> is not a AliHLTPredictionProcessorInterface implementation | |
754 | // -> discarding call | |
2c669e9b | 755 | Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '" |
e58fb035 | 756 | + detector + |
757 | "'. Does not implement the AliHLTPredictionProcessorInterface."); | |
2c669e9b | 758 | retVal = fgkHLTPendolinoBadCast; |
e58fb035 | 759 | |
760 | } catch (std::exception& e) { | |
2c669e9b | 761 | Log(fgkHLTInterfaceModule, " *** Exception in call prepareDCSValues of " |
e58fb035 | 762 | + detector + "."); |
2c669e9b | 763 | retVal = fgkHLTPendolinoException; |
e58fb035 | 764 | } |
765 | ||
766 | return retVal; | |
767 | } | |
768 | ||
769 | ||
8aaabc08 | 770 | #ifdef SHUTTLE_PRE_REV29388_INTERFACE |
771 | const UInt_t AliHLTPendolino::GetStartTimeDCSQuery() | |
772 | #else | |
773 | UInt_t AliHLTPendolino::GetStartTimeDCSQuery() | |
774 | #endif | |
775 | { | |
8d6c34c9 | 776 | return fStartTime; |
777 | } | |
778 | ||
8aaabc08 | 779 | #ifdef SHUTTLE_PRE_REV29388_INTERFACE |
780 | const UInt_t AliHLTPendolino::GetEndTimeDCSQuery() | |
781 | #else | |
782 | UInt_t AliHLTPendolino::GetEndTimeDCSQuery() | |
783 | #endif | |
784 | { | |
8d6c34c9 | 785 | return fEndTime; |
786 | } | |
787 | ||
ea6b7ed6 | 788 | void AliHLTPendolino::Log(const char* name , const char* message, UInt_t level) |
789 | { | |
2c669e9b | 790 | // overloaded function of the shuttle interface |
791 | // translate into HLT log message | |
ea6b7ed6 | 792 | AliHLTLogging log; |
793 | AliHLTComponentLogSeverity severity=kHLTLogInfo; | |
794 | switch (level) { | |
795 | case 1: severity=kHLTLogBenchmark; break; | |
796 | case 2: severity=kHLTLogDebug; break; | |
797 | case 3: severity=kHLTLogInfo; break; | |
798 | case 4: severity=kHLTLogWarning; break; | |
799 | default: severity=kHLTLogError; | |
800 | } | |
801 | log.LoggingVarargs(severity, "AliHLTPendolino", name , __FILE__ , __LINE__ , message); | |
802 | } | |
8d6c34c9 | 803 | |
a92aa224 | 804 | // this global object is not for use, it just makes sure that |
805 | // AliHLTPendolino can be instantiated. In case of missing virtual | |
806 | // functions a compilation error will indicate potential problems in | |
807 | // the pendolino macros | |
808 | AliHLTPendolino gAliHLTPendolino(0,""); |