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