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