3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Sebastian Bablok <Sebastian.Bablok@ift.uib.no> *
8 //* for The ALICE HLT Project. *
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 //**************************************************************************
19 /** @file AliHLTPredicProcTempMonitor.cxx
20 @author Sebastian Bablok
25 #include "AliHLTPredicProcTempMonitor.h"
27 #include <AliCDBMetaData.h>
28 #include <AliCDBEntry.h>
29 #include <AliDCSValue.h>
32 #include <TObjString.h>
33 #include <TObjArray.h>
35 #include <TTimeStamp.h>
38 ClassImp(AliHLTPredicProcTempMonitor)
41 const TString AliHLTPredicProcTempMonitor::kPath2("CalibMonitor");
43 const TString AliHLTPredicProcTempMonitor::kPath3("DCSTempMon");
45 const TString AliHLTPredicProcTempMonitor::kCreator("S. Bablok (HLT)");
47 const TString AliHLTPredicProcTempMonitor::kComment("Calib Object for monitoring DCS temperature values in HLT.");
49 const TString AliHLTPredicProcTempMonitor::kAliRootVersion("");
51 const UInt_t AliHLTPredicProcTempMonitor::kUnableToStoreObject = 7;
53 //const TString AliHLTPredicProcTempMonitor::kAmandaTempSensor = "TPC_PT_%d_TEMPERATURE";
56 AliHLTPredicProcTempMonitor::AliHLTPredicProcTempMonitor(
57 const char* detector, AliHLTPendolino* pendolino) :
58 AliHLTPredictionProcessorInterface(detector, pendolino),
59 fPredict(true), fRun(0), fStartTime(0), fEndTime(0), fBField("") {
60 // C-tor for AliHLTPredicProcTempMonitor
68 AliHLTPredicProcTempMonitor::~AliHLTPredicProcTempMonitor() {
69 // D-tor for AliHLTPredicProcTempMonitor
74 UInt_t AliHLTPredicProcTempMonitor::makePrediction(Bool_t doPrediction) {
75 // switch for prediction making in AliHLTPredicProcTempMonitor
76 Log("AliHLTPredicProcTempMonitor + B-Field extractor: prediction switched on");
77 fPredict = doPrediction;
82 void AliHLTPredicProcTempMonitor::Initialize(Int_t run, UInt_t startTime,
84 // initializes AliHLTPredicProcTempMonitor
86 fStartTime = startTime;
89 TString msg("Initialized HLT PredictionProcessor; Run: ");
91 msg += ", start time: ";
93 msg += ", end time: ";
100 UInt_t AliHLTPredicProcTempMonitor::Process(TMap* dcsAliasMap) {
101 // processes the DCS value map in AliHLTPredicProcTempMonitor
102 UInt_t beamPeriod = 0;
108 Bool_t infiniteValid = kFALSE;
111 //test GetFromOCDB() calls
112 AliCDBEntry* entry = GetFromOCDB(kPath2.Data(), kPath3.Data());
114 // No object in HCDB -> discarding old values
115 TString msg("No '" + kPath2 + "/" + kPath3 +
116 "' in HCDB, most likely first round, filling object now...");
118 tempMap = dcsAliasMap;
121 Log("Old data is already stored in HCDB, but now discarding that...");
122 tempMap = dcsAliasMap;
124 // If old data shall be included use lines below and uncomment lines above
126 Log("Adding new DCS value to old Temperature map...");
127 // Adding new DCS values to old Temperature map
128 tempMap = (TMap*) entry->GetObject();
130 TMapIter iter(dcsAliasMap); // iterator for values in TMap
133 while ((aKey = iter.Next())) {
134 tempMap->Add(aKey, dcsAliasMap->GetValue(aKey));
139 AliCDBMetaData meta(kCreator.Data(), beamPeriod, kAliRootVersion.Data(),
142 if (Store(kPath2.Data(), kPath3.Data(), (TObject*) tempMap, &meta, start,
144 TString msg(" +++ Successfully stored object '" + kPath2 + "/" + kPath3 +
148 TString msg(" *** Storing of object '" + kPath2 + "/" + kPath3 +
149 "' in HCDB failed.");
151 retVal = kUnableToStoreObject;
155 tempRet = ExtractBField(dcsAliasMap);
156 retVal = tempRet & retVal; // combine retvals
161 UInt_t AliHLTPredicProcTempMonitor::ExtractBField(TMap* dcsAliasMap) {
162 // extracts the B-field value from DCS value map
164 TString stringId = "L3Current"; // "dcs_magnet:Magnet/ALICESolenoid.Current";
167 Bool_t bRet = GetSensorValue(dcsAliasMap,stringId.Data(),&BField);
170 BField = BField / 60000; // If we get field, take this away and change SensorValue
171 TString dummy("-solenoidBZ ");
173 TObjString dummy2(dummy.Data());
175 Log(Form("BField set to %s", fBField.String().Data()));
180 TString path2("Config");
181 TString path3("BField");
184 TString comment("BField");
185 AliCDBMetaData meta(this->GetName(), 0, "unknownAliRoot", comment.Data());
187 if (Store(path2.Data(), path3.Data(), (TObject*) (&fBField), &meta, start,
189 Log(" +++ Successfully stored object ;-)");
191 Log(" *** Storing of OBJECT failed!!");
198 Bool_t AliHLTPredicProcTempMonitor::GetSensorValue(TMap* dcsAliasMap,
199 const char* stringId, Float_t *value) {
200 // retreives the sensor value
201 // return last value read from sensor specified by stringId
204 TPair* pair = (TPair*) (dcsAliasMap->FindObject(stringId));
206 valueSet = (TObjArray*) (pair->Value());
208 Int_t nentriesDCS = (valueSet->GetEntriesFast()) - 1;
209 if (nentriesDCS >= 0) {
210 AliDCSValue* val = (AliDCSValue*) (valueSet->At(nentriesDCS));
212 *value = val->GetFloat();
221 TMap* AliHLTPredicProcTempMonitor::produceTestData(TString /*aliasName*/) {
222 // produces test data for AliHLTPredicProcTempMonitor
225 // here has to come real dummy data :-)
226 resultMap = new TMap();
229 TObjString* name = new TObjString("L3Current");
230 AliDCSValue* val = new AliDCSValue(fval, tt.GetTime());
231 TObjArray* arr = new TObjArray();
233 resultMap->Add(name, arr);