coding conventions
[u/mrichter/AliRoot.git] / HLT / pendolino / AliHLTPendolino.cxx
CommitLineData
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
47using namespace std;
48
49
50ClassImp(AliHLTPendolino)
ea6b7ed6 51
e58fb035 52
53/** Static string to define a local storage for the OCDB contact. */
2c669e9b 54const TString AliHLTPendolino::fgkLocalStorageDefine = "local://";
e58fb035 55
2c669e9b 56const char* AliHLTPendolino::fgkHLTInterfaceModule = "Pendolino-Core";
e58fb035 57
2c669e9b 58const TString AliHLTPendolino::fgkTaxiListBaseFolder = getenv("ALIHLT_T_HCDBDIR");
e58fb035 59//"/opt/T-HCDB/lists/lists-taxi/";
60
2c669e9b 61const TString AliHLTPendolino::fgkTaxiListFolderName = "lists/lists-taxi/";
e58fb035 62
2c669e9b 63const TString AliHLTPendolino::fgkTaxiListPendolino = "Pendolino.list";
e58fb035 64
2c669e9b 65const Int_t AliHLTPendolino::fgkMaxLineLength = 256;
e58fb035 66
2c669e9b 67const Int_t AliHLTPendolino::fgkHLTPendolinoException = -10;
e58fb035 68
2c669e9b 69const Int_t AliHLTPendolino::fgkHLTPendolinoBadCast = -9;
e58fb035 70
2c669e9b 71const Int_t AliHLTPendolino::fgkHLTPendolinoNotPredictProc = -8;
e58fb035 72
2c669e9b 73const Int_t AliHLTPendolino::fgkHLTPendolinoModuleNotExisting = -7;
e58fb035 74
2c669e9b 75const Int_t AliHLTPendolino::fgkHLTPendolinoNoDCS = -6;
e58fb035 76
77//const Int_t AliHLTPendolino::
78
79
80
8d6c34c9 81AliHLTPendolino::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),
2c669e9b 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
e58fb035 94 // C-tor of AliHLTPendolino
2c669e9b 95 fHCDBPath = fgkLocalStorageDefine + HCDBbase;
e58fb035 96 if (logger == 0) {
bf560255 97 fpLogger = new AliHLTPendolinoLoggerOStream();
98 fOwnLogger = kTRUE;
e58fb035 99 } else {
bf560255 100 fpLogger = logger;
101 fOwnLogger = kFALSE;
e58fb035 102 }
103}
104
105
106AliHLTPendolino::~AliHLTPendolino() {
107 // D-tor of AliHLTPendolino
108 // clean up registered PredicitonProcs
bf560255 109 TMapIter iter(&fPredictionProcessorMap, kIterForward);
e58fb035 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*>
bf560255 120 (fPredictionProcessorMap.GetValue(key));
e58fb035 121
122 if (aPredict == 0) {
2c669e9b 123 Log(fgkHLTInterfaceModule,
e58fb035 124 " *** ERROR, cannot delete registered processor '"
125 + detector + "'; does not seem to be a PredictionProcessor.");
126 continue;
127 }
2c669e9b 128 Log(fgkHLTInterfaceModule, " ### [DEBUG] deleting PredictProc '" +
e58fb035 129 detector + "'.");
130 delete aPredict;
131 } catch (std::bad_cast) {
132 // failed -> is not a AliHLTPredictionProcessorInterface implementation
133 // -> discarding call
2c669e9b 134 Log(fgkHLTInterfaceModule, " *** ERROR, cannot delete registered processor '"
e58fb035 135 + detector + "'; does not seem to be a PredictionProcessor..");
136 continue;
137
138 } catch (std::exception& e) {
2c669e9b 139 Log(fgkHLTInterfaceModule,
e58fb035 140 " *** Exception in call for deleting PrecitionProcessor '"
141 + detector + "'.");
142 continue;
143 }
144 }
2c669e9b 145 Log(fgkHLTInterfaceModule, " ### [DEBUG] Deleting of PredictionProcessors finished.");
e58fb035 146
147 // clean up logger
bf560255 148 if ((fOwnLogger) && (fpLogger != 0)) {
149 delete fpLogger;
e58fb035 150 }
151
152}
153
154
155// inherited virtual functions, maybe use them from base class
156Bool_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;
2c669e9b 164 AliCDBStorage* localHCDB = 0;
e58fb035 165
bf560255 166 startNumber = ((fRunNumber - validityStart) <= 0) ? 0 : (fRunNumber - validityStart);
167 endNumber = (validityInfinite) ? AliCDBRunRange::Infinity() : fRunNumber;
e58fb035 168
169 man = AliCDBManager::Instance();
170 if (man == 0) {
2c669e9b 171 Log(fgkHLTInterfaceModule, " *** ERROR cannot obtain a CDB Manager reference.");
e58fb035 172 return kFALSE;
173 }
174
175 // contact local storage (HCDB)
2c669e9b 176 localHCDB = man->GetStorage(fHCDBPath.Data());
177 if (localHCDB == 0) {
e58fb035 178 TString msg(" *** ERROR in initiating HCDB: ");
bf560255 179 msg += fHCDBPath;
2c669e9b 180 Log(fgkHLTInterfaceModule, msg.Data());
e58fb035 181 man->DestroyActiveStorages();
182 return kFALSE;
183 }
184
185 // taken from AliShuttle
186 if (! dynamic_cast<TObjString*> (metaData->GetProperty("RunUsed(TObjString)"))) {
bf560255 187 TObjString runUsed = Form("%d", fRunNumber);
e58fb035 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 ???
bf560255 194 AliCDBId entryID(path, startNumber, endNumber, fRunNumber, -1);
e58fb035 195
2c669e9b 196 if (localHCDB->Put(object, entryID, metaData)) {
e58fb035 197 retVal = kTRUE;
198 } else {
199 TString msg(" *** Unable to store DCS data to HCDB: ");
200 msg += entryID.ToString();
2c669e9b 201 Log(fgkHLTInterfaceModule, msg.Data());
e58fb035 202 }
203
204 man->DestroyActiveStorages();
205
206 return retVal;
207}
208
209
210Bool_t AliHLTPendolino::StoreReferenceData(const AliCDBPath& path,
bf560255 211 TObject* /*object*/, AliCDBMetaData* /*metaData*/) {
e58fb035 212 // Disabled Function inherited from interface
213 TString msg(" ~~~ PredictProc tries to store reference data to '"
214 + path.GetPath() + "'. Discarding call in Pendolino.");
2c669e9b 215 Log(fgkHLTInterfaceModule, msg.Data());
e58fb035 216
217 return kFALSE;
218}
219
220
221Bool_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.";
2c669e9b 231 Log(fgkHLTInterfaceModule, msg.Data());
e58fb035 232
233 return kFALSE;
234}
235
236
237Bool_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.";
2c669e9b 246 Log(fgkHLTInterfaceModule, msg.Data());
e58fb035 247
248 return kFALSE;
249}
250
251
252const 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.";
2c669e9b 262 Log(fgkHLTInterfaceModule, msg.Data());
e58fb035 263
264 return NULL;
265}
266
267const 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.";
2c669e9b 271 Log(fgkHLTInterfaceModule, msg.Data());
e58fb035 272
273 return NULL;
274}
275
b48d2542 276const 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.";
2c669e9b 280 Log(fgkHLTInterfaceModule, msg.Data());
b48d2542 281
282 return NULL;
283}
284
e58fb035 285
286TList* 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.";
2c669e9b 295 Log(fgkHLTInterfaceModule, msg.Data());
e58fb035 296
297 return NULL;
298}
299
300
301TList* 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.";
2c669e9b 310 Log(fgkHLTInterfaceModule, msg.Data());
e58fb035 311
312 return NULL;
313}
314
315
bf560255 316const char* AliHLTPendolino::GetRunParameter(const char* /*lbEntry*/) {
e58fb035 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
2c669e9b 323 Log(fgkHLTInterfaceModule,
e58fb035 324 " ### GetRunParameter are not defined, yet. Feature will be available soon.");
325 return NULL;
326}
327
328
329Bool_t AliHLTPendolino::GetHLTStatus() {
330 // getter for HLT status
331 // since this is the Pendolino -> always true
332 return kTRUE;
333}
334
335
336AliCDBEntry* 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;
2c669e9b 345 Log(fgkHLTInterfaceModule, msg.Data());
e58fb035 346 return NULL;
347 }
348
bf560255 349 AliCDBStorage *hcdb = man->GetStorage(fHCDBPath.Data());
e58fb035 350 if (hcdb == 0) {
351 TString msg(" *** ERROR, cannot acquire HCDB storage (");
bf560255 352 msg += fHCDBPath + ") for fetching data for Pendolino.";
2c669e9b 353 Log(fgkHLTInterfaceModule, msg.Data());
e58fb035 354 return NULL;
355 }
356
bf560255 357 entry = hcdb->Get(path, fRunNumber);
e58fb035 358
359 if (entry == 0) {
360 TString msg(" ~~~ WARNING: no valid entry for '");
361 msg += path.GetPath() + "' in HCDB for run number ";
bf560255 362 msg += fRunNumber;
2c669e9b 363 Log(fgkHLTInterfaceModule, msg.Data());
e58fb035 364 }
365
366 return entry;
367
368/*
369 AliCDBEntry* entry = 0;
370 try {
bf560255 371 entry = dynamic_cast<AliCDBEntry*> (hcdb->Get(path, fRunNumber));
e58fb035 372 } catch (std::bad_cast) {
373 TString msg(" *** ERROR, bad cast of HCDB entry (");
374 msg += path.GetPath() + ") after fetching from HCDB.";
2c669e9b 375 Log(fgkHLTInterfaceModule, msg.Data());
e58fb035 376 return NULL;
377 }
378 return entry;
379*/
380
381}
382
383
425695db 384Bool_t AliHLTPendolino::IncludeAliCDBEntryInList(const TString& entryPath) {
e58fb035 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
2c669e9b 392 filename = fgkTaxiListBaseFolder + "/" + fgkTaxiListFolderName +
393 fgkTaxiListPendolino;
394 Log(fgkHLTInterfaceModule, filename + " [DEBUG] filename");
e58fb035 395
396 infile.open(filename, ios_base::in);
397 if (infile.is_open()) {
2c669e9b 398 char line[fgkMaxLineLength];
e58fb035 399
400 while (!infile.eof()) {
2c669e9b 401 infile.getline(line, fgkMaxLineLength);
e58fb035 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.";
2c669e9b 406 Log(fgkHLTInterfaceModule, msg.Data());
e58fb035 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...";
2c669e9b 418 Log(fgkHLTInterfaceModule, msg.Data());
e58fb035 419 return kFALSE;
420 }
421// outfile.seekp(-1, ios::end);
422 outfile << endl;
bf560255 423 outfile << "#HLT (Pendolino) - Run: " << fRunNumber << ", Time: " <<
e58fb035 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.";
2c669e9b 430 Log(fgkHLTInterfaceModule, msg.Data());
e58fb035 431 bRet = kTRUE;
432
433 } else {
434 TString msg(" ~~~ Unable to open Pendolino list file '");
435 msg += filename + "' for Taxi. Creating new one.";
2c669e9b 436 Log(fgkHLTInterfaceModule, msg.Data());
e58fb035 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;
bf560255 445 outfile << "#HLT (Pendolino) - Run: " << fRunNumber << ", Time: " <<
e58fb035 446 ts.AsString() << endl;
447 outfile << entryPath.Data() << endl;
448 outfile.close();
449 bRet = kTRUE;
450
451 } else {
bf560255 452 msg=" *** Unable to create Pendolino list file '";
e58fb035 453 msg += filename + "' for Taxi. Continueing without list update...";
2c669e9b 454 Log(fgkHLTInterfaceModule, msg.Data());
e58fb035 455 }
456 }
457
458 return bRet;
459}
460
461
462void AliHLTPendolino::Log(const char* detector, const char* message) {
463 // logging function
bf560255 464 fpLogger->log(detector, message);
e58fb035 465 // refer data to a Pendolino Logger, which can take care of it
466}
467
468
469void AliHLTPendolino::RegisterPreprocessor(AliPreprocessor* preprocessor) {
470 // registers a PredictionProcessor
471 if (preprocessor == 0) {
2c669e9b 472 Log(fgkHLTInterfaceModule,
e58fb035 473 " *** ERROR: Cannot register NULL pointer as PredictionProcessor.");
474 return;
475 }
476
477 TString detector(preprocessor->GetName());
478
bf560255 479 if (fPredictionProcessorMap.GetValue(detector.Data())) {
2c669e9b 480 Log(fgkHLTInterfaceModule, " ~~~ Already registered PredictionProcessor '" +
e58fb035 481 detector + "'. Ignoring call.");
482 return;
483 }
484 // store as AliPreprocessor* and make cast to AliHLTPredictionProcessorInterface*
485 // later, when accesing them.
bf560255 486 fPredictionProcessorMap.Add(new TObjString(detector), preprocessor);
e58fb035 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()) {
2c669e9b 496 Log(fgkHLTInterfaceModule, " *** PredictionProcessor '" + detector +
e58fb035 497 "' not registered, because it will not process DCS values.");
498 return;
499 }
2c669e9b 500 Log(fgkHLTInterfaceModule, "Module Processes DCS values, Registering PredictionProc "
e58fb035 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) {
2c669e9b 506 // Log(fgkHLTInterfaceModule, " *** Invalid detector name: " + detector);
e58fb035 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
2c669e9b 527 Log(fgkHLTInterfaceModule, " *** Cannot register PredictionProcessor '" + detector +
e58fb035 528 "'. Does not implement the AliHLTPredictionProcessorInterface.");
529 return;
530 } catch (std::exception& e) {
2c669e9b 531 Log(fgkHLTInterfaceModule, " *** Exception in the registering of the PredictProc.");
e58fb035 532 }
533
bf560255 534 if (fPredictionProcessorMap.GetValue(detector.Data())) {
2c669e9b 535 Log(fgkHLTInterfaceModule, " ~~~ Already registered PredictionProcessor '" +
e58fb035 536 detector + "'. Ignoring call.");
537 return;
538 }
539
bf560255 540 fPredictionProcessorMap.Add(new TObjString(detector), predictProc);
e58fb035 541*/
542}
543
544
425695db 545UInt_t AliHLTPendolino::SetToPredictMaking() {
e58fb035 546 // switches prdiction making on in all registered PredictioProcessors
547 UInt_t retVal = 0;
548
549 // get an iterator for the map
bf560255 550 TMapIter iter(&fPredictionProcessorMap, kIterForward);
e58fb035 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*>
bf560255 561 (fPredictionProcessorMap.GetValue(key));
e58fb035 562
563 if (aPredict == 0) {
2c669e9b 564 Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '"
e58fb035 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 {
2c669e9b 574 Log(fgkHLTInterfaceModule, " *** PredictionProcessor '" + detector
e58fb035 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
2c669e9b 580 Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '"
e58fb035 581 + detector +
582 "'. Does not implement the AliHLTPredictionProcessorInterface.");
583 continue;
584
585 } catch (std::exception& e) {
2c669e9b 586 Log(fgkHLTInterfaceModule, " *** Exception in call for makePrediction of "
e58fb035 587 + detector + ".");
588 continue;
589 }
590 }
591 return retVal;
592}
593
594
595Int_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
bf560255 602 TObject* object = fPredictionProcessorMap.GetValue(detector.Data());
e58fb035 603
604 if (object == 0) {
2c669e9b 605 Log(fgkHLTInterfaceModule, " *** No PredictionProcessor for '" +
e58fb035 606 detector + "' registered.");
2c669e9b 607 return fgkHLTPendolinoModuleNotExisting;
e58fb035 608 }
609
610 aPredict = dynamic_cast<AliHLTPredictionProcessorInterface*> (object);
611
612 if (aPredict == 0) {
2c669e9b 613 Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '"
e58fb035 614 + detector +
615 "'. Does not implement the AliHLTPredictionProcessorInterface.");
2c669e9b 616 return fgkHLTPendolinoNotPredictProc;
e58fb035 617 }
618// detector = aPredict->GetName();
619
620 if (!((aPredict->ProcessDCS()) && (aPredict->makePrediction() == 0))) {
2c669e9b 621 Log(fgkHLTInterfaceModule, " *** PredictionProcessor '" + detector +
e58fb035 622 "' does not allow DCS processing or failed to init prediction making.");
2c669e9b 623 retVal = fgkHLTPendolinoNoDCS;
e58fb035 624 }
625
626 } catch (std::bad_cast) {
627 // failed -> is not a AliHLTPredictionProcessorInterface implementation
628 // -> discarding call
2c669e9b 629 Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '"
e58fb035 630 + detector +
631 "'. Does not implement the AliHLTPredictionProcessorInterface.");
2c669e9b 632 retVal = fgkHLTPendolinoBadCast;
e58fb035 633
634 } catch (std::exception& e) {
2c669e9b 635 Log(fgkHLTInterfaceModule, " *** Exception in call for makePrediction of "
e58fb035 636 + detector + ".");
2c669e9b 637 retVal = fgkHLTPendolinoException;
e58fb035 638 }
639
640 return retVal;
641}
642
643
425695db 644Int_t AliHLTPendolino::PrepareDCSValues(TString detector, TMap* DCSValues) {
e58fb035 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
bf560255 651 TObject* object = fPredictionProcessorMap.GetValue(detector.Data());
e58fb035 652
653 if (object == 0) {
2c669e9b 654 Log(fgkHLTInterfaceModule, " *** No PredictionProcessor for '" +
e58fb035 655 detector + "' registered.");
2c669e9b 656 return fgkHLTPendolinoModuleNotExisting;
e58fb035 657 }
658
659 aPredict = dynamic_cast<AliHLTPredictionProcessorInterface*> (object);
660
661 if (aPredict == 0) {
2c669e9b 662 Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '"
e58fb035 663 + detector +
664 "'. Does not implement the AliHLTPredictionProcessorInterface.");
2c669e9b 665 return fgkHLTPendolinoNotPredictProc;
e58fb035 666 }
667
668 retVal = aPredict->Process(DCSValues);
669
670
671 } catch (std::bad_cast) {
672 // failed -> is not a AliHLTPredictionProcessorInterface implementation
673 // -> discarding call
2c669e9b 674 Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '"
e58fb035 675 + detector +
676 "'. Does not implement the AliHLTPredictionProcessorInterface.");
2c669e9b 677 retVal = fgkHLTPendolinoBadCast;
e58fb035 678
679 } catch (std::exception& e) {
2c669e9b 680 Log(fgkHLTInterfaceModule, " *** Exception in call prepareDCSValues of "
e58fb035 681 + detector + ".");
2c669e9b 682 retVal = fgkHLTPendolinoException;
e58fb035 683 }
684
685 return retVal;
686}
687
425695db 688TMap* AliHLTPendolino::EmulateDCSMap(TString detector, TString aliasName) {
e58fb035 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
bf560255 695 TObject* object = fPredictionProcessorMap.GetValue(detector.Data());
e58fb035 696
697 if (object == 0) {
2c669e9b 698 Log(fgkHLTInterfaceModule, " *** No PredictionProcessor for '" +
e58fb035 699 detector + "' registered.");
700 return result;
701 }
702
703 aPredict = dynamic_cast<AliHLTPredictionProcessorInterface*> (object);
704
705 if (aPredict == 0) {
2c669e9b 706 Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '"
e58fb035 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
2c669e9b 718 Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '"
e58fb035 719 + detector +
720 "'. Does not implement the AliHLTPredictionProcessorInterface.");
721
722 } catch (std::exception& e) {
2c669e9b 723 Log(fgkHLTInterfaceModule, " *** Exception in call emulateDCSMap of "
e58fb035 724 + detector + ".");
725 }
726 return result;
727}
728
729
730Int_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
bf560255 738 TObject* object = fPredictionProcessorMap.GetValue(detector.Data());
e58fb035 739
740 if (object == 0) {
2c669e9b 741 Log(fgkHLTInterfaceModule, " *** No PredictionProcessor for '" +
e58fb035 742 detector + "' registered.");
2c669e9b 743 return fgkHLTPendolinoModuleNotExisting;
e58fb035 744 }
745
746 aPredict = dynamic_cast<AliHLTPredictionProcessorInterface*> (object);
747
748 if (aPredict == 0) {
2c669e9b 749 Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '"
e58fb035 750 + detector +
751 "'. Does not implement the AliHLTPredictionProcessorInterface.");
2c669e9b 752 return fgkHLTPendolinoNotPredictProc;
e58fb035 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
2c669e9b 761 Log(fgkHLTInterfaceModule, " *** Cannot use PredictionProcessor '"
e58fb035 762 + detector +
763 "'. Does not implement the AliHLTPredictionProcessorInterface.");
2c669e9b 764 retVal = fgkHLTPendolinoBadCast;
e58fb035 765
766 } catch (std::exception& e) {
2c669e9b 767 Log(fgkHLTInterfaceModule, " *** Exception in call prepareDCSValues of "
e58fb035 768 + detector + ".");
2c669e9b 769 retVal = fgkHLTPendolinoException;
e58fb035 770 }
771
772 return retVal;
773}
774
775
8aaabc08 776#ifdef SHUTTLE_PRE_REV29388_INTERFACE
777const UInt_t AliHLTPendolino::GetStartTimeDCSQuery()
778#else
779UInt_t AliHLTPendolino::GetStartTimeDCSQuery()
780#endif
781{
8d6c34c9 782 return fStartTime;
783}
784
8aaabc08 785#ifdef SHUTTLE_PRE_REV29388_INTERFACE
786const UInt_t AliHLTPendolino::GetEndTimeDCSQuery()
787#else
788UInt_t AliHLTPendolino::GetEndTimeDCSQuery()
789#endif
790{
8d6c34c9 791 return fEndTime;
792}
793
ea6b7ed6 794void AliHLTPendolino::Log(const char* name , const char* message, UInt_t level)
795{
2c669e9b 796 // overloaded function of the shuttle interface
797 // translate into HLT log message
ea6b7ed6 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}
8d6c34c9 809