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