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: Haavard Helstrup *
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 AliHLTPredictionProcessorTPC.cxx
20 @author Haavard Helstrup
25 #include "AliHLTPredictionProcessorTPC.h"
29 #include "TObjArray.h"
34 #include "AliCDBEntry.h"
35 #include "AliCDBMetaData.h"
36 #include "AliDCSValue.h"
37 #include "AliTPCSensorTempArray.h"
39 ClassImp(AliHLTPredictionProcessorTPC)
41 const TString kAmandaTemp = "TPC_PT_%d_TEMPERATURE";
42 const Int_t kValCutTemp = 100; // discard temperatures > 100 degrees
43 const Int_t kDiffCutTemp = 5; // discard temperature differences > 5 degrees
45 //______________________________________________________________________________________________
47 AliHLTPredictionProcessorTPC::AliHLTPredictionProcessorTPC(
48 const char* detector, AliHLTPendolino* pendolino) :
49 AliHLTPredictionProcessorInterface(detector, pendolino),
61 //______________________________________________________________________________________________
63 AliHLTPredictionProcessorTPC::~AliHLTPredictionProcessorTPC()
66 if (fConfTreeTemp) delete fConfTreeTemp;
67 if (fTemp) delete fTemp;
70 //______________________________________________________________________________________________
72 UInt_t AliHLTPredictionProcessorTPC::makePrediction(Bool_t doPrediction) {
74 // Signal whether prediction making is required
76 fPredict = doPrediction; // own member indicating that prediction making is required
80 //______________________________________________________________________________________________
82 void AliHLTPredictionProcessorTPC::Initialize(Int_t run, UInt_t startTime,
85 // Initialise TPC prediction processor. Read config entry from HCDB
87 fRun = run; // storing locally the run number
88 fStartTime = startTime; // storing locally the start time
89 fEndTime = endTime; // storing locally the end time
92 AliCDBEntry* entry = GetFromOCDB("Config", "HLTTemperature");
93 if (entry) fConfTreeTemp = (TTree*) entry->GetObject();
94 if ( fConfTreeTemp==0 ) {
95 Log("AliHLTPredictionProcessorTPC: Temperature Config HCDB entry missing.\n");
101 //______________________________________________________________________________________________
103 UInt_t AliHLTPredictionProcessorTPC::Process(TMap* dcsAliasMap) {
105 // Event-by-event processing of the PredictionProcessorTPC
108 // test if configuration available and DCS map valid
110 if (!dcsAliasMap) return 9;
111 if (dcsAliasMap->GetEntries() == 0 ) return 9;
112 if (!fConfigOK) return 9;
115 // Extract values from DCS maps. Store updated entry to HCDB
119 TString path2("Calib"); // for the storage path in HCDB
120 TString path3("Temperature"); // for the storage path in HCDB
122 //get data from the HCDB
123 AliCDBEntry* entry = GetFromOCDB(path2.Data(), path3.Data());
125 entry->PrintMetaData(); // use the AliCDBEntry
126 fTemp = (AliTPCSensorTempArray*)entry->GetObject();
128 Log("Cannot retrieve HCDB entry. New AliTPCSensorTempArray generated");
129 UInt_t startTimeLocal = fStartTime-3600;
130 UInt_t endTimeLocal = fEndTime+1800;
131 fTemp = new AliTPCSensorTempArray(startTimeLocal, endTimeLocal, fConfTreeTemp, kAmandaTemp);
132 fTemp->SetValCut(kValCutTemp);
133 fTemp->SetDiffCut(kDiffCutTemp);
134 fTemp->ExtractDCS(dcsAliasMap);
137 // process temperatures
139 UInt_t tempResult = ExtractTemperature(dcsAliasMap);
141 //process dcsAliasMap to ROOT object
142 // and create AliCDBEntry
145 // create meta data entry for HCDB
146 TString comment("HLT temperatures");
147 AliCDBMetaData meta(this->GetName(), 666, "unknownAliRoot", comment.Data());
149 // store AliCDBEntry in HCDB
150 if (Store(path2.Data(), path3.Data(), fTemp, &meta, start, kTRUE)) {
151 Log(" +++ Successfully stored object ;-)");
153 Log(" *** Storing of OBJECT failed!!");
163 //______________________________________________________________________________________________
165 UInt_t AliHLTPredictionProcessorTPC::ExtractTemperature(TMap* dcsAliasMap)
167 // Extract temperature values from DCS maps, according to infoamtion from configuration tree
169 const Int_t error = 9;
170 Int_t nentries = fConfTreeTemp->GetEntries();
171 if (nentries<1) return error;
173 TMap *map = fTemp->ExtractDCS(dcsAliasMap,kTRUE);
175 fTemp->MakeSplineFitAddPoints(map);
177 Log("No temperature map extracted.\n");
183 //______________________________________________________________________________________________
185 TMap* AliHLTPredictionProcessorTPC::produceTestData(TString aliasName)
187 // produce dummy values for TPC temperature sensors
189 const Float_t defTemp = 22.0;
190 const Float_t tempVar = 2.0;
195 TObjArray* arr = new TObjArray();
197 resultMap = new TMap();
200 // loop through all sensors (extracted from OCDB config entry) if no input parameter is given
202 if (aliasName.Length() == 0 ) {
203 if (!fConfTreeTemp) return 0;
204 Int_t nentries = fConfTreeTemp->GetEntries();
205 if (nentries<1) return 0;
209 fConfTreeTemp->SetBranchAddress("ECha",&echa);
211 for (Int_t isensor=0; isensor<nentries; isensor++ ){
212 fConfTreeTemp->GetEntry(isensor);
213 stringId = Form(kAmandaString.Data(),echa);
214 tempDelta = (random.Rndm()-0.5)*tempVar;
215 temp = defTemp + tempDelta;
216 AliDCSValue* val = new AliDCSValue(temp, tt.GetTime());
217 TObjString* name = new TObjString(stringId);
219 resultMap->Add(name, arr);
223 // simulate value for given sensor if specified as parameter
225 tempDelta = (random.Rndm()-0.5)*tempVar;
226 temp = defTemp + tempDelta;
227 AliDCSValue* val = new AliDCSValue(temp, tt.GetTime());
228 TObjString* name = new TObjString(aliasName.Data());
230 resultMap->Add(name, arr);