]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/pendolino/AliHLTPendolino.h
New module TRIGGER (Chiara, Annalisa)
[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 #ifdef SHUTTLE_PRE_REV29388_INTERFACE
382                 virtual const UInt_t GetStartTimeDCSQuery();
383 #else
384                 virtual UInt_t GetStartTimeDCSQuery();
385 #endif
386
387                 /**
388                  * Function to get the end time of the DCS Archive DB request; in HLT
389                  * this is the same like the end time given in the Initialize() call
390                  * to the PredictionProcessors (NOTE: thsi is differnet to the
391                  * implementation in the Offline Shuttle - there the initial end time
392                  * is set to the end-of-data for the complete run.)
393                  */
394 #ifdef SHUTTLE_PRE_REV29388_INTERFACE
395                 virtual const UInt_t GetEndTimeDCSQuery();
396 #else
397                 virtual UInt_t GetEndTimeDCSQuery();
398 #endif
399                                 
400                 
401         protected:
402
403                 
404         private:
405         /**
406          * Function is required from interface, but is disbled in its
407          * implementation since additional refernce data will not be used by
408          * the DAs inside the HLT. Therefore always returns NULL.
409          * If this feature is lateron required by HLT, inherit from this class
410          * and overwrite this function with the required functionality.
411          *
412          * @return always NULL, since not used.
413          */
414         virtual TList* GetFileIDs(Int_t system, const char* detector,
415                 const char* source);
416
417         /**
418          * Function is required from interface, but is disbled in its
419          * implementation since additional refernce data will not be used by
420          * the DAs inside the HLT. Therefore always returns NULL.
421          * If this feature is lateron required by HLT, inherit from this class
422          * and overwrite this function with the required functionality.
423          *
424          * @return always NULL, since not used.
425          */
426         virtual TList* GetFileSources(Int_t system, const char* detector,
427                 const char* id = 0);
428
429         /**
430          * Function is required from interface, but is disbled in its
431          * implementation since additional refernce data will not be used by
432          * the DAs inside the HLT. Therefore always returns NULL.
433          * If this feature is lateron required by HLT, inherit from this class
434          * and overwrite this function with the required functionality.
435          *
436          * @return always NULL, since not used.
437          */
438         virtual const char* GetFile(Int_t system, const char* detector,
439                 const char* id, const char* source);
440
441         /**
442          * Function is required from interface, but is disbled in the Pendolino
443          * because at the moment there is no Trigger configuration available
444          * for Pendolino. At the moment it just return a NULL pointer and makes
445          * some log output.
446          *
447          * @return NULL pointer, since it should not be used.
448          */
449                 virtual const char* GetTriggerConfiguration();
450                 virtual const char* GetTriggerDetectorMask();
451
452                 /**
453                  * Disable the default constructor.
454                  */
455                 AliHLTPendolino();
456
457                 /** copy constructor prohibited */
458                 AliHLTPendolino(const AliHLTPendolino&);
459                 /** assignment operator prohibited */
460                 AliHLTPendolino& operator=(const AliHLTPendolino&);
461
462                 /**
463                  * Stores the current run type
464                  */
465                 TString fRunType;  // Stores the current run type
466
467                 /**
468                  * Stores the current run number
469                  */
470                 Int_t fRunNumber;  // Stores the current run number
471
472                 /**
473                  * Stores the HCDBpath
474                  */
475                 TString fHCDBPath;       // Stores the HCDBpath
476
477                 /**
478                  * Map that stores the all PredictionProcessors with their name
479                  * (detector)
480                  */
481                 TMap fPredictionProcessorMap;  // stores the all PredictionProcessors
482
483                 /**
484                  * Pointer to the used Pendolino logger
485                  */
486                 AliHLTPendolinoLogger* fpLogger; // Pointer to the used Pendolino logger
487
488                 /**
489                  * Indicates, if Logger is owned by Pendolino
490                  */
491                 Bool_t fOwnLogger;  //  Indicates, if Logger is owned by Pendolino
492
493                 /**
494                  * Stores the start time of the DCS Archive DB request
495                  */
496                 UInt_t fStartTime;
497
498                 /**
499                  * Stores the end time of the DCS Archive DB request
500                  */
501                 UInt_t fEndTime;
502                 
503                 ClassDef(AliHLTPendolino, 6);
504
505 };
506
507
508 inline const char* AliHLTPendolino::GetRunType() {
509         // getter for run type
510         return fRunType.Data();
511 }
512
513 inline Int_t AliHLTPendolino::GetRunNumber() {
514         // getter for run number
515         return fRunNumber;
516 }
517
518 inline Int_t AliHLTPendolino::getNumberOfPredictProc() {
519         // getter for number of registered PredictionProcessors
520         return fPredictionProcessorMap.GetSize();
521 }
522
523
524 #endif
525