]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/pendolino/AliHLTPredictionProcessorDummy.cxx
adding more default configurations
[u/mrichter/AliRoot.git] / HLT / pendolino / AliHLTPredictionProcessorDummy.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   AliHLTPredictionProcessorDummy.cxx
20     @author Sebastian Bablok
21     @date   
22     @brief  
23 */
24
25 #include "AliHLTPredictionProcessorDummy.h"
26
27 #include <AliCDBMetaData.h>
28 #include <AliCDBEntry.h>
29
30 #include <TTimeStamp.h>
31 #include <TObjString.h>
32 #include <TObjArray.h>
33 #include <AliDCSValue.h>
34
35 ClassImp(AliHLTPredictionProcessorDummy)
36
37 AliHLTPredictionProcessorDummy::AliHLTPredictionProcessorDummy(
38                         const char* detector, AliHLTPendolino* pendolino) :
39                                 AliHLTPredictionProcessorInterface(detector, pendolino),
40                                  fPredict(false), fRun(0), fStartTime(0), fEndTime(0) {
41         // C-tor of AliHLTPredictionProcessorDummy
42 }
43
44
45 AliHLTPredictionProcessorDummy::~AliHLTPredictionProcessorDummy() {
46         // D-tor of AliHLTPredictionProcessorDummy
47
48 }
49
50
51 UInt_t AliHLTPredictionProcessorDummy::makePrediction(Bool_t doPrediction) {
52         // switches prediction making on or off
53         Log("Prediction switched on");
54         fPredict = doPrediction;
55         return 0;
56 }
57
58
59 void AliHLTPredictionProcessorDummy::Initialize(Int_t run, UInt_t startTime, 
60                         UInt_t endTime) {
61         // initializes AliHLTPredictionProcessorDummy
62         fRun = run;
63         fStartTime = startTime;
64         fEndTime = endTime;
65
66         TString msg("Initialized Dummy PredictProc. Run: ");
67         msg += fRun;
68         msg += ", start time: ";
69         msg += fStartTime;
70         msg += ", end time: ";
71         msg += fEndTime;
72         msg += ".";     
73         Log(msg.Data());
74
75         if (fPredict) {
76                 Log("Dummy PredictProc has prediction switched ON.");
77         } else {
78                 Log("Prediction is switched OFF.");
79         }
80 }
81
82
83 UInt_t AliHLTPredictionProcessorDummy::Process(TMap* dcsAliasMap) {
84         // processes the handed in DCS value map
85         UInt_t retVal = 0;
86         Int_t start = 0;
87         TString path2("Dummy");
88         TString path3("DCSValley");
89                 
90         //test GetFromOCDB() calls
91         AliCDBEntry* entry = GetFromOCDB("Calib", "LocalVdrift");
92         if (entry != 0) {
93                 TString msg("AliCDBEntry -> last storage: ");
94                 msg += entry->GetLastStorage();
95                 Log(msg.Data());
96                 entry->PrintMetaData();
97         } else {
98                 Log("Error. Cannot retrieve HCDB entry.");
99         }
100
101         entry = GetFromOCDB("Dummy", "DCSValley");
102         if (entry != 0) {
103                 TString msg("AliCDBEntry -> last storage: ");
104                 msg += entry->GetLastStorage();
105                 Log(msg.Data());
106                 entry->PrintMetaData();
107         } else {
108                 Log("Error. Cannot retrieve HCDB entry.");
109         }
110
111         // test call for non existing object
112     entry = GetFromOCDB("Nix", "Nada");
113     if (entry != 0) {
114         Log("Error: call should failed, but it does NOT!");
115     } else {
116         Log("Tested call for missing CDB entry -> succeeded!");
117                 if (!includeAliCDBEntryInList("TPC/Nix/Nada")) {
118             Log("Adding of AliCDBEntry request for 'TPC/Nix/Nada' failed!");
119         } else {
120             Log("Successfully added an AliCDBEntry request (TPC/Nix/Nada).");
121         }
122
123     }
124         
125         
126         //TODO test GetRunParameter() calls
127                 
128         if (GetHLTStatus()) {
129                 Log("HLT status is: ON");
130         } else {
131                 Log("ERROR. HLT is OFF.");
132                 retVal = 9;
133         }
134
135         TString runType("RunType is set to: ");
136         runType += GetRunType();
137         Log(runType.Data());
138
139         //transform dcsAliasMap to ROOT object 
140         TString comment("Beam it up");
141         if (fPredict) {
142                 comment += " with PREDICTION!";
143         }
144         if (fRun > 3) {
145                 start = 3;
146         }
147         AliCDBMetaData meta(this->GetName(), 666, "unknownAliRoot", 
148                         comment.Data());
149
150         if (Store(path2.Data(), path3.Data(), (TObject*) dcsAliasMap, &meta, start, 
151                         kTRUE)) {
152                 Log(" +++ Successfully stored object ;-)");
153         } else {
154                 Log(" *** Storing of OBJECT failed!!");
155                 retVal = 7;
156         }
157         
158         return retVal;
159 }
160
161 TMap* AliHLTPredictionProcessorDummy::produceTestData(TString /*aliasName*/) {
162         // generates test dummy data for AliHLTPredictionProcessorDummy
163         TMap* resultMap = 0;
164
165         // here has to come real dummy data :-)
166         resultMap = new TMap();
167         TTimeStamp tt;
168         Float_t fval = 33.3;
169         TObjString* name = new TObjString("DummyData");
170         AliDCSValue* val = new AliDCSValue(fval, tt.GetTime());
171         TObjArray* arr = new TObjArray();
172         arr->Add(val);
173         resultMap->Add(name, arr);
174         
175         return resultMap;
176 }
177