From d1662f64f6cbe104ac1cc000f968a7a0ab074497 Mon Sep 17 00:00:00 2001 From: richterm Date: Mon, 12 Apr 2010 21:35:39 +0000 Subject: [PATCH] adding prediction processor for the GRP, moving some functions to the PredictionProcessor base class for common use, deleting deprecated code in the PredictionProcessorHLT --- HLT/libHLTpendolino.pkg | 1 + .../AliHLTPredictionProcessorInterface.cxx | 43 ++++- .../AliHLTPredictionProcessorInterface.h | 32 +++- .../GRP/AliHLTPredictionProcessorGRP.cxx | 177 ++++++++++++++++++ .../GRP/AliHLTPredictionProcessorGRP.h | 134 +++++++++++++ .../HLT/AliHLTPredictionProcessorHLT.cxx | 81 +------- .../HLT/AliHLTPredictionProcessorHLT.h | 27 +-- 7 files changed, 382 insertions(+), 113 deletions(-) create mode 100644 HLT/pendolino/PredictionProcessor/GRP/AliHLTPredictionProcessorGRP.cxx create mode 100644 HLT/pendolino/PredictionProcessor/GRP/AliHLTPredictionProcessorGRP.h diff --git a/HLT/libHLTpendolino.pkg b/HLT/libHLTpendolino.pkg index 19584911ec5..14a5e819294 100644 --- a/HLT/libHLTpendolino.pkg +++ b/HLT/libHLTpendolino.pkg @@ -10,6 +10,7 @@ CLASS_HDRS:= AliHLTPendolino.h \ PredictionProcessor/AliHLTPendolinoLoggerDump.h \ PredictionProcessor/HLT/AliHLTPredicProcTempMonitor.h \ PredictionProcessor/HLT/AliHLTPredictionProcessorHLT.h \ + PredictionProcessor/GRP/AliHLTPredictionProcessorGRP.h \ PredictionProcessor/MUON/AliHLTPredictionProcessorMCH.h \ PredictionProcessor/MUON/AliHLTPredictionProcessorMTR.h \ PredictionProcessor/TPC/AliHLTDCSArray.h \ diff --git a/HLT/pendolino/PredictionProcessor/AliHLTPredictionProcessorInterface.cxx b/HLT/pendolino/PredictionProcessor/AliHLTPredictionProcessorInterface.cxx index d529e458ff8..6cd8c6c8b4c 100644 --- a/HLT/pendolino/PredictionProcessor/AliHLTPredictionProcessorInterface.cxx +++ b/HLT/pendolino/PredictionProcessor/AliHLTPredictionProcessorInterface.cxx @@ -24,15 +24,20 @@ #include "AliHLTPredictionProcessorInterface.h" #include "AliHLTPendolino.h" -//#include "AliShuttleInterface.h" +#include "TObjArray.h" +#include "AliDCSValue.h" ClassImp(AliHLTPredictionProcessorInterface) AliHLTPredictionProcessorInterface::AliHLTPredictionProcessorInterface( - const char* detector, AliHLTPendolino* pendolino) : - AliPreprocessor(detector, reinterpret_cast - (pendolino)), fpPend(pendolino) { + const char* detector, AliHLTPendolino* pendolino) + : AliPreprocessor(detector, reinterpret_cast(pendolino)) + , fpPend(pendolino) + , fPredict(kFALSE) + , fStartTime(0) + , fEndTime(0) +{ } @@ -44,6 +49,15 @@ Int_t AliHLTPredictionProcessorInterface::GetRunNumber() { return fpPend->GetRunNumber(); } +void AliHLTPredictionProcessorInterface::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) +{ + // initializes AliHLTPredictionProcessorHLT + if (GetRunNumber()!=run) { + Log(Form("run number argument %d differs from pendolino run number %d", run, GetRunNumber())); + } + fStartTime = startTime; + fEndTime = endTime; +} Bool_t AliHLTPredictionProcessorInterface::includeAliCDBEntryInList( const TString& entryPath) { @@ -51,5 +65,22 @@ Bool_t AliHLTPredictionProcessorInterface::includeAliCDBEntryInList( return fpPend->IncludeAliCDBEntryInList(entryPath); } - - +Bool_t AliHLTPredictionProcessorInterface::GetSensorValue(TMap* dcsAliasMap, + const char* stringId, Float_t *value) const +{ + // extracts the sensor value + // return last value read from sensor specified by stringId + + TObjArray* valueSet; + TPair* pair = (TPair*)dcsAliasMap->FindObject(stringId); + if (pair) { + valueSet = (TObjArray*)pair->Value(); + Int_t nentriesDCS = valueSet->GetEntriesFast() - 1; + if(nentriesDCS>=0){ + AliDCSValue *val = (AliDCSValue *)valueSet->At(nentriesDCS); + *value=val->GetFloat(); + return kTRUE; + } + } + return kFALSE; +} diff --git a/HLT/pendolino/PredictionProcessor/AliHLTPredictionProcessorInterface.h b/HLT/pendolino/PredictionProcessor/AliHLTPredictionProcessorInterface.h index debd73f9173..b19374d6354 100644 --- a/HLT/pendolino/PredictionProcessor/AliHLTPredictionProcessorInterface.h +++ b/HLT/pendolino/PredictionProcessor/AliHLTPredictionProcessorInterface.h @@ -89,7 +89,7 @@ class AliHLTPredictionProcessorInterface : public AliPreprocessor { * @param startTime start time of data * @param endTime end time of data */ -// virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime); + virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime); /** * Function called by the Pendolino for each participating subdetector @@ -124,6 +124,10 @@ class AliHLTPredictionProcessorInterface : public AliPreprocessor { * @return the current run number */ virtual Int_t GetRunNumber(); + + Bool_t IsPredicting() const {return fPredict;} + UInt_t StartTime() const {return fStartTime;} + UInt_t EndTime() const {return fEndTime;} /** * Function to let the Penolino add an request for an AliCDBEntry to the @@ -140,6 +144,16 @@ class AliHLTPredictionProcessorInterface : public AliPreprocessor { */ virtual Bool_t includeAliCDBEntryInList(const TString& entryPath); + /** + * Function to rertieve a sensor value from the DCS value map + * + * @param dcsAliasMap the retrieved DCS value map + * @param stringId the alias name of the desired sensor value + * @param value [return parameter] - the extracted sensor value + * + * @return true if sucessful, else false + */ + Bool_t GetSensorValue(TMap* dcsAliasMap,const char* stringId, Float_t * value) const; private: /** @@ -166,8 +180,22 @@ class AliHLTPredictionProcessorInterface : public AliPreprocessor { */ AliHLTPendolino* fpPend; // Stores pointer to Pendolino + /** + * Stores if prediction shall be made + */ + Bool_t fPredict; // flag for prediction making + + /** + * Stores the start time of the to process DCS data + */ + UInt_t fStartTime; // Stores the start time of the to process DCS data + + /** + * Stores the end time of the to process DCS data + */ + UInt_t fEndTime; // Stores the end time of the to process DCS data - ClassDef(AliHLTPredictionProcessorInterface, 6); + ClassDef(AliHLTPredictionProcessorInterface, 7); }; diff --git a/HLT/pendolino/PredictionProcessor/GRP/AliHLTPredictionProcessorGRP.cxx b/HLT/pendolino/PredictionProcessor/GRP/AliHLTPredictionProcessorGRP.cxx new file mode 100644 index 00000000000..00d32cb288c --- /dev/null +++ b/HLT/pendolino/PredictionProcessor/GRP/AliHLTPredictionProcessorGRP.cxx @@ -0,0 +1,177 @@ +// $Id$ + +//************************************************************************** +//* This file is property of and copyright by the ALICE HLT Project * +//* ALICE Experiment at CERN, All rights reserved. * +//* * +//* Primary Authors: Gaute Ovrebekk * +//* for The ALICE HLT Project. * +//* * +//* Permission to use, copy, modify and distribute this software and its * +//* documentation strictly for non-commercial purposes is hereby granted * +//* without fee, provided that the above copyright notice appears in all * +//* copies and that both the copyright notice and this permission notice * +//* appear in the supporting documentation. The authors make no claims * +//* about the suitability of this software for any purpose. It is * +//* provided "as is" without express or implied warranty. * +//************************************************************************** + +// @file AliHLTPredictionProcessorGRP.cxx +// @author Matthias Richter +// @date 2010-04-12 +// @brief Prediction processor for the GRP entry +// + +#include "AliHLTPredictionProcessorGRP.h" +#include +#include + +#include "AliGRPObject.h" +#include "AliCDBMetaData.h" + +//#include +//#include +//#include + + +ClassImp(AliHLTPredictionProcessorGRP) + +AliHLTPredictionProcessorGRP::AliHLTPredictionProcessorGRP(AliHLTPendolino* pendolino) + : AliHLTPredictionProcessorInterface("GRP", pendolino) +{ + // constructor + // see header file for class documentation + // or + // refer to README to build package + // or + // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt +} + + +AliHLTPredictionProcessorGRP::~AliHLTPredictionProcessorGRP() +{ + // destructor +} + + +UInt_t AliHLTPredictionProcessorGRP::makePrediction(Bool_t /*doPrediction*/) +{ + // switch for prediction making + + // not exactly clear what to do here, have to check the interface + return 0; +} + + +void AliHLTPredictionProcessorGRP::Initialize(Int_t run, UInt_t startTime, + UInt_t endTime) +{ + // initializes AliHLTPredictionProcessorGRP + AliHLTPredictionProcessorInterface::Initialize(run, startTime, endTime); + + TString msg("Initialized GRP PredictProc. Run: "); + msg += GetRunNumber(); + msg += ", start time: "; + msg += StartTime(); + msg += ", end time: "; + msg += EndTime(); + msg += "."; + Log(msg.Data()); +} + + +UInt_t AliHLTPredictionProcessorGRP::Process(TMap* dcsAliasMap) +{ + // processes the DCS value map + + if (!dcsAliasMap) return 9; + if (dcsAliasMap->GetEntries() == 0 ) return 9; + + Float_t l3Current=0.0; + Float_t l3Polarity=0.0; + Float_t dipoleCurrent=0.0; + Float_t dipolePolarity=0.0; + Float_t cavernAtmosPressure=0.0; + Float_t cavernAtmosPressure2=0.0; + Float_t surfaceAtmosPressure=0.0; + + Bool_t bRet = kTRUE; + const char* key=""; + + key="L3Current"; + if (!GetSensorValue(dcsAliasMap, key, &l3Current)) { + Log(Form("failed to extract %s from alias map", key)); + bRet=kFALSE; + } + + key="L3Polarity"; + if (!GetSensorValue(dcsAliasMap, key, &l3Polarity)) { + Log(Form("failed to extract %s from alias map", key)); + bRet=kFALSE; + } + + key="DipoleCurrent"; + if (!GetSensorValue(dcsAliasMap, key, &dipoleCurrent)) { + Log(Form("failed to extract %s from alias map", key)); + bRet=kFALSE; + } + + key="DipolePolarity"; + if (!GetSensorValue(dcsAliasMap, key, &dipolePolarity)) { + Log(Form("failed to extract %s from alias map", key)); + bRet=kFALSE; + } + + key="CavernAtmosPressure"; + if (!GetSensorValue(dcsAliasMap, key, &cavernAtmosPressure)) { + Log(Form("failed to extract %s from alias map", key)); + bRet=kFALSE; + } + + key="CavernAtmosPressure2"; + if (!GetSensorValue(dcsAliasMap, key, &cavernAtmosPressure2)) { + Log(Form("failed to extract %s from alias map", key)); + bRet=kFALSE; + } + + key="SurfaceAtmosPressure2"; + if (!GetSensorValue(dcsAliasMap, key, &surfaceAtmosPressure)) { + Log(Form("failed to extract %s from alias map", key)); + bRet=kFALSE; + } + + // generate GRP object + AliGRPObject* grpObj=new AliGRPObject; + float cmsEnergy=14000; + grpObj->SetBeamEnergy(cmsEnergy/0.120); // LHC convention + grpObj->SetBeamType("p-p"); + grpObj->SetL3Current(l3Current,(AliGRPObject::Stats)0); + grpObj->SetDipoleCurrent(dipoleCurrent,(AliGRPObject::Stats)0); + grpObj->SetL3Polarity(l3Polarity); + grpObj->SetDipolePolarity(dipolePolarity); + grpObj->SetPolarityConventionLHC(); // LHC convention +/+ current -> -/- field main components + // TODO: set also the pressure sensors, but first need to clarify how to use the AliDCSSensor + + UInt_t start=0; + AliCDBMetaData cdbMetaData; + cdbMetaData.SetResponsible("ALICE HLT"); + cdbMetaData.SetComment(Form("GRP entry for the magnetic field initialization of HLT components, produced by %s", ClassName())); + + if (Store("GRP", "Data", grpObj, &cdbMetaData, start, kTRUE)) { + } else { + Log(" *** Failed to store GRP object"); + return 7; + } + + return 0; +} + +TMap* AliHLTPredictionProcessorGRP::produceTestData(TString /*aliasName*/) +{ + // produces test data for AliHLTPredictionProcessorGRP + TMap* resultMap = 0; + + return resultMap; +} + + diff --git a/HLT/pendolino/PredictionProcessor/GRP/AliHLTPredictionProcessorGRP.h b/HLT/pendolino/PredictionProcessor/GRP/AliHLTPredictionProcessorGRP.h new file mode 100644 index 00000000000..88ac3c59c69 --- /dev/null +++ b/HLT/pendolino/PredictionProcessor/GRP/AliHLTPredictionProcessorGRP.h @@ -0,0 +1,134 @@ +//-*- Mode: C++ -*- +// $Id$ + +#ifndef ALIHLTPREDICTIONPROCESSORGRP_H +#define ALIHLTPREDICTIONPROCESSORGRP_H +//* This file is property of and copyright by the ALICE HLT Project * +//* ALICE Experiment at CERN, All rights reserved. * +//* See cxx source for full Copyright notice * + +// @file AliHLTPredictionProcessorGRP.cxx +// @author Matthias Richter +// @date 2010-04-12 +// @brief Prediction processor for the GRP entry +// + +#include "AliHLTPredictionProcessorInterface.h" + +/** + * Predition Processor for the GRP + * + */ +class AliHLTPredictionProcessorGRP : public AliHLTPredictionProcessorInterface +{ +public: + + /** + * Constructor for AliHLTPredictionProcessorGRP + * + * @param pendolino pointer to the hosting pendolino + */ + AliHLTPredictionProcessorGRP(AliHLTPendolino* pendolino); + + /// Destructor for AliHLTPredictionProcessorGRP + virtual ~AliHLTPredictionProcessorGRP(); + + /** + * Virtual function to force the Prediction Processor to implement + * a function to flag that prediction making is required. + * This function is called by the Pendolino before the fetched DCS data + * is handed in for (prediction) processing. + * + * @param doPrediction if true, prediction making shall be switched on, + * if false, switched off. + * + * @return 0 on success; a value greater than 0 refers to an error + */ + virtual UInt_t makePrediction(Bool_t doPrediction = true); + + /** + * Virtual function, implemented in the detector specific + * PredictionProcessors to initialize them. + * + * @param run run number + * @param startTime start time of data + * @param endTime end time of data + */ + virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime); + + /** + * Function called by the Pendolino for each participating subdetector + * producing the required condition settings. This includes the + * encoding of a prediction to the values due to the fact, that only + * data up to now can be fetched from DCS (the latest data can also be + * up to 2 min old until it is received on HLT side). To write the data + * to the HCDB, the detector specific implementation of this class has + * to call the appropriated storing function provided by the interface. + * + * @param dcsAliasMap the map containing aliases and corresponding DCS + * values and timestamps + * + * @return 0 on success; a value greater than 0 refers to an error + */ + virtual UInt_t Process(TMap* dcsAliasMap); + + /** + * Indicates if DCS data shall be processed. + * NOTE: should always return true, since it is used as prediction + * processor, which will only process DCS data + * + * @return true if DCS data can be processed, else false. Note: if false + * the Pendolino would stop, so make sure that it is true. + */ + virtual Bool_t ProcessDCS(); + + /** + * Function to let the PredictionProcessor produce dummy input data, + * that can be used in Pendolino tests, where no DCS Archieve DB is + * contacted. This function is called by the Pendolino, the result is + * given back to the PredictionProcessor via the Process(...) call. + * Since the DCSMaps requested from DCS are detector specific, the + * PredictionProcessor should know, how the maps look like, that it + * expects. + * NOTE: The clean - up (delete) of the TMap will be performed by the + * Pendolino after the usage. The PredictionProcessor has never to + * call delete on the returned TMap pointer. + * + * @param aliasName optional parameter, that can be given in order to + * create a DCSMap for dedicated aliases. For a general test + * this paramter should be empty. If more than one alias name + * shall be specified, they are separated by blanks " ". + * + * @return DCSMap containing dummy data for testing the Pendolino. + */ + virtual TMap* produceTestData(TString aliasName = ""); + + +protected: + +private: + /** + * Disabled Copy constructor + * (parent class is disabled so derived class does the same) + */ + AliHLTPredictionProcessorGRP(const AliHLTPredictionProcessorGRP& predictPro); + + /** + * Disabled Assignment operator + * (parent class is disabled so derived class does the same) + */ + AliHLTPredictionProcessorGRP& operator=(const AliHLTPredictionProcessorGRP& rhs); + + ClassDef(AliHLTPredictionProcessorGRP, 1); + +}; + + +inline Bool_t AliHLTPredictionProcessorGRP::ProcessDCS() { + // indicates if DCS values are processed; always true + return true; +} + +#endif + + diff --git a/HLT/pendolino/PredictionProcessor/HLT/AliHLTPredictionProcessorHLT.cxx b/HLT/pendolino/PredictionProcessor/HLT/AliHLTPredictionProcessorHLT.cxx index 7f9053d1b13..a88244cc5d3 100644 --- a/HLT/pendolino/PredictionProcessor/HLT/AliHLTPredictionProcessorHLT.cxx +++ b/HLT/pendolino/PredictionProcessor/HLT/AliHLTPredictionProcessorHLT.cxx @@ -31,22 +31,18 @@ #include #include -#include -#include - ClassImp(AliHLTPredictionProcessorHLT) AliHLTPredictionProcessorHLT::AliHLTPredictionProcessorHLT( const char* detector, AliHLTPendolino* pendolino) : AliHLTPredictionProcessorInterface(detector, pendolino), - fPredict(true), fRun(0), fStartTime(0), fEndTime(0), fBField("") { + fPredict(true), fRun(0), fStartTime(0), fEndTime(0) { // C-tor for AliHLTPredictionProcessorHLT // fPredict = false; // fRun = 0; // fStartTime = 0; // fEndTime = 0; -// fBField = 0; } @@ -94,90 +90,17 @@ UInt_t AliHLTPredictionProcessorHLT::Process(TMap* dcsAliasMap) { if (dcsAliasMap->GetEntries() == 0 ) return 9; UInt_t retVal = 0; - Int_t start = 0; - TString path2("ConfigHLT"); // "Config" - TString path3("SolenoidBz"); // "BField" - - UInt_t BFieldResult = ExtractBField(dcsAliasMap); - - if (BFieldResult != 0) { - Log(" *** Extraction of BField failed - no entry for HCDB!!"); - return 8; - } - - - //transform dcsAliasMap to ROOT object - TString comment("BField"); - AliCDBMetaData meta(this->GetName(), 0, "unknownAliRoot",comment.Data()); - - if (Store(path2.Data(),path3.Data(),(TObject*) &fBField,&meta,start,kTRUE)) { - Log(" +++ Successfully stored object ;-)"); - } else { - Log(" *** Storing of OBJECT failed!!"); - retVal = 7; - } + // there is currently no object to create return retVal; } -UInt_t AliHLTPredictionProcessorHLT::ExtractBField(TMap* dcsAliasMap){ - // extracts the b-field from DCS value map -// TString stringId = "dcs_magnet:Magnet/ALICESolenoid.Current"; // old name - TString stringId = "L3Current"; - - Float_t BField = 0; - Bool_t bRet = GetSensorValue(dcsAliasMap,stringId.Data(),&BField); - - if(bRet){ - // new - BField = BField/60000; // If we get field, take this away and change SensorValue - TString dummy("-solenoidBz "); - dummy += BField; - TObjString dummy2(dummy.Data()); - fBField = dummy2; - - Log(Form("BField set to %s",fBField.String().Data())); - return 0; - } - - return 1; - -} - -Bool_t AliHLTPredictionProcessorHLT::GetSensorValue(TMap* dcsAliasMap, - const char* stringId, Float_t *value) -{ - // extracts the sensor value - // return last value read from sensor specified by stringId - - TObjArray* valueSet; - TPair* pair = (TPair*)dcsAliasMap->FindObject(stringId); - if (pair) { - valueSet = (TObjArray*)pair->Value(); - Int_t nentriesDCS = valueSet->GetEntriesFast() - 1; - if(nentriesDCS>=0){ - AliDCSValue *val = (AliDCSValue *)valueSet->At(nentriesDCS); - //new - *value=val->GetFloat(); - return kTRUE; - } - } - return kFALSE; -} - TMap* AliHLTPredictionProcessorHLT::produceTestData(TString /*aliasName*/) { // produces test data for AliHLTPredictionProcessorHLT TMap* resultMap = 0; // here has to come real dummy data :-) resultMap = new TMap(); - TTimeStamp tt; - Float_t fval = 33.3; - TObjString* name = new TObjString("L3Current"); - AliDCSValue* val = new AliDCSValue(fval, tt.GetTime()); - TObjArray* arr = new TObjArray(); - arr->Add(val); - resultMap->Add(name, arr); return resultMap; } diff --git a/HLT/pendolino/PredictionProcessor/HLT/AliHLTPredictionProcessorHLT.h b/HLT/pendolino/PredictionProcessor/HLT/AliHLTPredictionProcessorHLT.h index 3c55bd0ea75..b0adbcf7573 100644 --- a/HLT/pendolino/PredictionProcessor/HLT/AliHLTPredictionProcessorHLT.h +++ b/HLT/pendolino/PredictionProcessor/HLT/AliHLTPredictionProcessorHLT.h @@ -153,32 +153,7 @@ class AliHLTPredictionProcessorHLT : public AliHLTPredictionProcessorInterface { */ UInt_t fEndTime; // Stores the end time of the to process DCS data - /** - * TObjstring which stores the B-field value - */ - TObjString fBField; // TObjstring which stores the B-field value - - /** - * Function to extract the B-field from the DCS value map - * - * @param dcsAliasMap the retrieved DCS value map - * - * @return 0 on sucess else an error code - */ - UInt_t ExtractBField(TMap* dcsAliasMap); - - /** - * Function to rertieve a sensor value from the DCS value map - * - * @param dcsAliasMap the retrieved DCS value map - * @param stringId the alias name of the desired sensor value - * @param value [return parameter] - the extracted sensor value - * - * @return true if sucessful, else false - */ - Bool_t GetSensorValue(TMap* dcsAliasMap,const char* stringId, Float_t * value); - - ClassDef(AliHLTPredictionProcessorHLT, 1); + ClassDef(AliHLTPredictionProcessorHLT, 2); }; -- 2.39.3