]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/pendolino/AliHLTPendolino.h
ef839267d49136dac9b798402d330d454833ee4b
[u/mrichter/AliRoot.git] / HLT / pendolino / AliHLTPendolino.h
1 //-*- Mode: C++ -*-
2 // $Id$
3
4 #ifndef ALI_HLT_PENDOLINO_H
5 #define ALI_HLT_PENDOLINO_H
6 //* This file is property of and copyright by the ALICE HLT Project        * 
7 //* ALICE Experiment at CERN, All rights reserved.                         *
8 //* See cxx source for full Copyright notice                               *
9
10 /** @file   AliHLTPendolino.h
11     @author Sebastian Bablok
12     @date   
13     @brief  
14 */
15
16 //#include <TObject.h>
17 #include <TString.h>
18 #include <TMap.h>
19
20
21 #include <AliShuttleInterface.h>
22
23 //#include "AliHLTPredictionProcessorInterface.h"
24
25 #ifdef SHUTTLE_PRE_REV29388_INTERFACE
26 #define CONST_PROPERTY const
27 #else
28 #define CONST_PROPERTY
29 #endif
30
31 class AliHLTPendolinoLogger;
32
33 /**
34  * Class that implements the AliShuttleInterface and provides the required
35  * features for the contacting the PredictionProcessor and storing the result
36  * to the HCDB
37  * 
38  * @author Sebastian Bablok
39  *
40  * @date 2007-10-22
41  */
42 class AliHLTPendolino : public AliShuttleInterface {
43         public:
44
45                 /**
46                  * Static string that defines the local storage indicator in path
47                  */  
48                 static const TString kLOCAL_STORAGE_DEFINE;  // defines the local storage
49
50                 /**
51                  * Static string defining the name of this inteface module.
52                  */
53                 static const char* kHLTInterfaceModule;  // defines the name of inteface module
54
55                 /**
56                  * Static value defining error value for a Pendolino exception.
57                  */ 
58                 static const Int_t kHLTPendolinoException;  // error value for a Pendolino exception
59
60                 /**
61                  * Static value defining error value for a bad cast
62                  */ 
63                 static const Int_t kHLTPendolinoBadCast;  // error value for a bad cast
64
65                 /**
66                  * Static value defining error value for handed in module is not 
67                  * implementing the PredictionProcessor interface.
68                  */ 
69                 static const Int_t kHLTPendolinoNotPredictProc;  //  error value for "not implementing the PredictionProcessor interface"
70
71                 /**
72                  * Static value defining error value for module not existing.
73                  */ 
74                 static const Int_t kHLTPendolinoModuleNotExisting;  // error value for module not existing
75
76                 /**
77                  * Static value defining error value for PredictionProc does not
78                  * process DCS values.
79                  */     
80                 static const Int_t kHLTPendolinoNoDCS; // error value for PredictionProc does not process DCS
81
82                 /**
83                  * Static string that defines the base folder for the Taxi list files.
84                  */ 
85                 static const TString kTaxiListBaseFolder;  // defines the base folder for the Taxi list files
86
87                 /**
88                  * Static string that defines list folder name for taxi list
89                  */
90                 static const TString kTaxiListFolderName; // defines list folder name for taxi list
91
92                 /**
93                  * Static string that defines the filename for the Taxi list required
94                  * by the Pendolino
95                  */  
96                 static const TString kTaxiListPendolino; // defines the filename for the Taxi list 
97
98                 /**
99                  * Static value that defines the max length of a line that can be read
100                  * when browsing through the list file
101                  */ 
102                 static const Int_t kMAX_LINE_LENGTH; // defines the max length of a line
103                 
104
105                 /**
106                  * Constructor for AliHLTPendolino.
107                  *
108                  * @param run the current run number
109                  * @param HCDBbase path to the HCDB base folder
110                  * @param runType the current run type
111                  * @param logger pointer to the desired logger; default is the command
112                  *                      line logger.
113                  * @param startTime start time of the DCS Archive DB request
114                  * @param endTime end time of the DCS Archive DB request
115                  */
116                 AliHLTPendolino(Int_t run, TString HCDBbase, TString runType = "TEST", 
117                                 AliHLTPendolinoLogger* logger = 0, UInt_t startTime = 0, 
118                                 UInt_t endTime = 0);
119
120                 /**
121                  * Destructor for
122                  */
123                 virtual ~AliHLTPendolino();
124
125                 /**
126                  * Function to store processed data in the HCDB
127                  *
128                  * @param path the storage path consisting of "detector/type/objectname"
129                  *                      where detector should be the detector name used by offline,
130                  *                      type is something like "CALIB" or "ALIGN", while 
131                  *                      objectname the name represents, by which it can be requested
132                  *                      from the HCDB.
133                  * @param object the object to store
134                  * @param metaData metaData to store
135                  * @param validityStart object is valid from current run number minus 
136                  *                      validityStart
137                  * @param validityInfinite if true, validity is set to infinity
138                  *
139                  * @return true on success, else false
140                  */
141                 virtual Bool_t Store(const AliCDBPath& path, TObject* object, 
142                                 AliCDBMetaData* metaData, Int_t validityStart = 0, 
143                                 Bool_t validityInfinite = kFALSE);
144                 /**
145                  * Function is required from interface, but is disbled in its 
146                  * implementation since additional refernce data will not be used by 
147                  * the DAs inside the HLT. Therefore always returns false
148                  *
149                  * @return always false, since function is disabled.
150                  */
151             virtual Bool_t StoreReferenceData(const AliCDBPath& path, 
152                                 TObject* object, AliCDBMetaData* metaData);
153                 /**
154                  * Function is required from interface, but is disbled in its
155          * implementation since additional reference data will not be used by
156          * the DAs inside the HLT. Therefore always returns false
157          *
158          * @return always false, since function is disabled.
159          */
160             virtual Bool_t StoreReferenceFile(const char* detector, 
161                                 const char* localFile, const char* gridFileName);
162
163                 /**
164                  * Function is required from interface, but is disbled in its
165                  * implementation since additional run meta data will only be stored
166                  * by the the GPR - Preprocessor of the Offline Shuttle.
167                  * 
168                  * @return always false, since function is disabled.
169                  */                  
170                 virtual Bool_t StoreRunMetadataFile(const char* localFile, 
171                                 const char* gridFileName);
172
173                 /**
174                  * Function is required from interface, but is disbled in its
175          * implementation since additional refernce data will not be used by
176          * the DAs inside the HLT. Therefore always returns NULL.
177                  * If this feature is lateron required by HLT, inherit from this class
178                  * and overwrite this function with the required functionality.
179          *
180          * @return always NULL, since not used.
181          */
182 //          virtual const char* GetFile(Int_t system, const char* detector, 
183 //                              const char* id, const char* source);  --> is private now
184             
185         /**
186          * Function is required from interface, but is disbled in its
187          * implementation since additional refernce data will not be used by
188          * the DAs inside the HLT. Therefore always returns NULL.
189          * If this feature is lateron required by HLT, inherit from this class
190          * and overwrite this function with the required functionality.
191          *
192          * @return always NULL, since not used.
193          */
194 //          virtual TList* GetFileSources(Int_t system, const char* detector, 
195 //                              const char* id = 0);  -> is priavte now
196                 
197         /**
198          * Function is required from interface, but is disbled in its
199          * implementation since additional refernce data will not be used by
200          * the DAs inside the HLT. Therefore always returns NULL.
201          * If this feature is lateron required by HLT, inherit from this class
202          * and overwrite this function with the required functionality.
203          *
204          * @return always NULL, since not used.
205          */
206 //          virtual TList* GetFileIDs(Int_t system, const char* detector, 
207 //                              const char* source);  -> is private now
208             
209                 /**
210                  * Retrieves current run parameter.
211                  * 
212                  * @param lbEntry name of the run parameter
213                  *
214                  * @return value of the run parameter
215                  */
216             virtual const char* GetRunParameter(const char* lbEntry);
217
218                 /**
219                  * Retrieves the current run type.              
220                  *
221                  * @return the current run type
222                  */
223                 virtual const char* GetRunType();
224                 
225                 /**
226                  * Returns the HLT status.
227                  * Since the Pendolino is part of the HLT, the function will always
228                  * return true
229                  *
230                  * @return always true - see above
231                  */
232             virtual Bool_t GetHLTStatus();
233
234                 /**
235                  * Retrieves a file from the OCDB, but does not uses the OCDB but the 
236                  * HCDB (local copy of the OCDB). - Since the HCDB only contains OCDB
237                  * objects, that are included in the list the Taxi uses for fetching 
238                  * the data from the OCDB, it can happen, that the corresponding 
239                  * AliCDBEntry is missing. 
240                  * TODO: Think of mechanism to automatically include the object in the
241                  * Taxi list.
242                  * 
243                  * @param detector the detectorname, to which the object belongs
244                  * @param path the path of the object
245                  *
246                  * @return pointer to the fetched HCDB entry
247                  */
248             virtual AliCDBEntry* GetFromOCDB(const char* detector, 
249                                 const AliCDBPath& path);
250             
251                 /**
252                  * Function to allow Pendolino and PredictionProcessor to make log 
253                  * entries.
254                  *
255                  * @param detector the detector, that wants to issue this message
256                  * @param message the log message
257                  */
258             virtual void Log(const char* detector, const char* message);
259
260                 /**
261                  * Function is required from interface, but is disbled in the Pendolino
262                  * because at the moment there is no Trigger configuration available 
263                  * for Pendolino. At the moment it just return a NULL pointer and makes
264                  * some log output.
265                  *
266                  * @return NULL pointer, since it should not be used.
267                  */
268 //              virtual const char* GetTriggerConfiguration(); --> is private now
269
270                 /**
271                  * Registers a preprocessor; actually it has to be a PredictionProcessor
272                  * since the Pendolino requires a PredictionProcessor. If the registered
273                  * preprocessor is not implementing a PredictionProcessor, a log entry
274                  * is made and the registration discarded.
275                  *
276                  * @param preprocessor the PredictionProcessor that shall be registered.
277                  *                      For more details please see above !!
278                  */ 
279                 virtual void RegisterPreprocessor(AliPreprocessor* preprocessor);
280 //                                      AliHLTPredictionProcessorInterface* preprocessor);
281
282                 /**
283                  * Function to get the current run number
284                  *
285                  * @return current run number
286                  */
287                 virtual Int_t GetRunNumber();
288
289                 /**
290                  * Function to enable prediction making in all registered 
291                  * PredictionProcessors, if they implement the required interface
292                  *          
293                  * @return number of PredictionProcessor, which has been switched to
294                  *                              prediction making (NOTE: the internal list may conatin 
295                  *                              more PredictionProcessors, but if switching on failed 
296                  *                              for one, this one is not counted.)
297                  */
298                 virtual UInt_t setToPredictMaking(); 
299
300                 /**
301                  * Function to get the number of registered PredictionProcessors
302                  *
303                  * @return number of registered PredictionProcessors
304                  */
305                 Int_t getNumberOfPredictProc();
306
307                 /**
308                  * Function to check if given PredtionProc allows for processing DCS
309                  * and enable prediction making
310                  *
311                  * @param detector the detector in whose PredictionProcessor the 
312                  *                      prediction making shall be enabled.
313                  *
314                  * @return 0 on success, else an error code is returned
315                  */
316                 virtual Int_t setToPredictMaking(TString detector);
317
318                 /**
319                  * Function to initlaize a dedicated Prediction Processor
320                  * 
321                  * @param detector the detector, whose PredictProc shall be initialized
322                  * @param run the current run number
323                  * @param startTime the start time of the fetched data
324                  * @param endTime the end time of the fetched data
325                  *
326                  * @return 0 on success, else an error code is returned
327                  */
328                 virtual Int_t initPredictProc(TString detector, Int_t run, 
329                                         UInt_t startTime, UInt_t endTime);
330
331                 /**
332                  * Function to hand in retrieved DCS values. These values are handed to
333                  * the corresponding PredictionProcessor of the according detector.
334                  * The PredictionProcessor should prepare the data inside and store 
335                  * them to the HCDB.
336                  *
337                  * @param detector the according detector, to whose PredictionProcessor
338                  *                      shall prepare the handed-in data
339                  * @param DCSValues pointer to the map containing the fetched DCS values
340                  *
341                  * @return 0 on success, else an error code is returned.
342                  */
343                 virtual Int_t prepareDCSValues(TString detector, TMap* DCSValues);
344
345                 /**
346                  * Function to retrieve dummy data for testing the Pendolino from a
347                  * given PredictionProcessor. The function called is handed further to
348                  * the corresponding PredictionProcessor.
349                  * NOTE: The returned TMap can be NULL, if no corresponding 
350                  * PredictionProcessor is registered.
351                  *
352                  * @param detector the according detector, from whom the 
353                  *                      PredictionProcessor shall produce the dummy data.
354                  * @param aliasName optional parameter to hand in a alias name for 
355                  *                      producing a DCSMap for the given alias.
356                  *
357                  * @return the DCSMap with the dummy data to test (given by the 
358                  *                      PredictionProcessor). NOTE: can be NULL, if no corresponding
359                  *                      PredictionProcessor is registered.
360                  */
361                 virtual TMap* emulateDCSMap(TString detector, TString aliasName = "");
362    
363                 /**
364                  * Function to add a entry request to the Taxi lists.
365                  *
366                  * @param entryPath the path entry, that shall be included in the 
367                  *                              list file.
368                  *
369                  * @return true, when successful included or entry already existing in 
370                  *                              list; else false.
371                  */
372                 virtual Bool_t includeAliCDBEntryInList(const TString& entryPath); 
373
374                 /**
375                  * Function to get the start time of the DCS Archive DB request; in HLT
376                  * this is the same like the start time given in the Initialize() call 
377                  * to the PredictionProcessors (NOTE: thsi is differnet to the 
378                  * implementation in the Offline Shuttle - there the initial start time
379                  * is set to the start-of-data for the complete run.)
380                  */
381                 virtual CONST_PROPERTY UInt_t GetStartTimeDCSQuery();
382
383                 /**
384                  * Function to get the end time of the DCS Archive DB request; in HLT
385                  * this is the same like the end time given in the Initialize() call
386                  * to the PredictionProcessors (NOTE: thsi is differnet to the
387                  * implementation in the Offline Shuttle - there the initial end time
388                  * is set to the end-of-data for the complete run.)
389                  */
390                 virtual CONST_PROPERTY UInt_t GetEndTimeDCSQuery();
391                                 
392                 
393         protected:
394
395                 
396         private:
397         /**
398          * Function is required from interface, but is disbled in its
399          * implementation since additional refernce data will not be used by
400          * the DAs inside the HLT. Therefore always returns NULL.
401          * If this feature is lateron required by HLT, inherit from this class
402          * and overwrite this function with the required functionality.
403          *
404          * @return always NULL, since not used.
405          */
406         virtual TList* GetFileIDs(Int_t system, const char* detector,
407                 const char* source);
408
409         /**
410          * Function is required from interface, but is disbled in its
411          * implementation since additional refernce data will not be used by
412          * the DAs inside the HLT. Therefore always returns NULL.
413          * If this feature is lateron required by HLT, inherit from this class
414          * and overwrite this function with the required functionality.
415          *
416          * @return always NULL, since not used.
417          */
418         virtual TList* GetFileSources(Int_t system, const char* detector,
419                 const char* id = 0);
420
421         /**
422          * Function is required from interface, but is disbled in its
423          * implementation since additional refernce data will not be used by
424          * the DAs inside the HLT. Therefore always returns NULL.
425          * If this feature is lateron required by HLT, inherit from this class
426          * and overwrite this function with the required functionality.
427          *
428          * @return always NULL, since not used.
429          */
430         virtual const char* GetFile(Int_t system, const char* detector,
431                 const char* id, const char* source);
432
433         /**
434          * Function is required from interface, but is disbled in the Pendolino
435          * because at the moment there is no Trigger configuration available
436          * for Pendolino. At the moment it just return a NULL pointer and makes
437          * some log output.
438          *
439          * @return NULL pointer, since it should not be used.
440          */
441                 virtual const char* GetTriggerConfiguration();
442
443                 /**
444                  * Disable the default constructor.
445                  */
446                 AliHLTPendolino();
447
448                 /** copy constructor prohibited */
449                 AliHLTPendolino(const AliHLTPendolino&);
450                 /** assignment operator prohibited */
451                 AliHLTPendolino& operator=(const AliHLTPendolino&);
452
453                 /**
454                  * Stores the current run type
455                  */
456                 TString fRunType;  // Stores the current run type
457
458                 /**
459                  * Stores the current run number
460                  */
461                 Int_t fRunNumber;  // Stores the current run number
462
463                 /**
464                  * Stores the HCDBpath
465                  */
466                 TString fHCDBPath;       // Stores the HCDBpath
467
468                 /**
469                  * Map that stores the all PredictionProcessors with their name
470                  * (detector)
471                  */
472                 TMap fPredictionProcessorMap;  // stores the all PredictionProcessors
473
474                 /**
475                  * Pointer to the used Pendolino logger
476                  */
477                 AliHLTPendolinoLogger* fpLogger; // Pointer to the used Pendolino logger
478
479                 /**
480                  * Indicates, if Logger is owned by Pendolino
481                  */
482                 Bool_t fOwnLogger;  //  Indicates, if Logger is owned by Pendolino
483
484                 /**
485                  * Stores the start time of the DCS Archive DB request
486                  */
487                 UInt_t fStartTime;
488
489                 /**
490                  * Stores the end time of the DCS Archive DB request
491                  */
492                 UInt_t fEndTime;
493                 
494                 ClassDef(AliHLTPendolino, 6);
495
496 };
497
498
499 inline const char* AliHLTPendolino::GetRunType() {
500         // getter for run type
501         return fRunType.Data();
502 }
503
504 inline Int_t AliHLTPendolino::GetRunNumber() {
505         // getter for run number
506         return fRunNumber;
507 }
508
509 inline Int_t AliHLTPendolino::getNumberOfPredictProc() {
510         // getter for number of registered PredictionProcessors
511         return fPredictionProcessorMap.GetSize();
512 }
513
514
515 #endif
516