Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore minimal content in CaloOnlineTools/HcalOnlineDb for LUTs [91X] #18677

Merged
merged 3 commits into from May 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions CaloOnlineTools/HcalOnlineDb/BuildFile.xml
@@ -0,0 +1,21 @@
<use name="FWCore/Framework"/>
<use name="FWCore/Utilities"/>
<use name="FWCore/PluginManager"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/ServiceRegistry"/>
<use name="boost"/>
<use name="oracle"/>
<use name="DataFormats/Common"/>

<use name="xerces-c"/>
<use name="zlib"/>
<use name="DataFormats/HcalDetId"/>
<use name="CalibCalorimetry/CaloTPG"/>
<use name="CalibCalorimetry/HcalAlgos"/>
<use name="CalibCalorimetry/HcalTPGAlgos"/>
<use name="Geometry/CaloTopology"/>
<use name="CondTools/Hcal"/>
<use name="OnlineDB/Oracle"/>
<export>
<lib name="1"/>
</export>
213 changes: 213 additions & 0 deletions CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabase.hh
@@ -0,0 +1,213 @@
#ifndef hcal_ConfigurationDatabase_hh_included
#define hcal_ConfigurationDatabase_hh_included 1

#include <string>
#include <map>
#include <vector>
#include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseException.hh"
#include "xercesc/dom/DOMDocument.hpp"
#include <stdint.h>

#ifdef HAVE_XDAQ
#include "log4cplus/logger.h"
#else
#include "CaloOnlineTools/HcalOnlineDb/interface/xdaq_compat.h" // Includes typedef for log4cplus::Logger
#endif

namespace hcal {

class ConfigurationDatabaseImpl;

/** \brief Access to large-block configuration information such as firmwares and lookup tables

Multithread access is not allowed. The locking must be handled externally.
\ingroup hcalBase
*/
class ConfigurationDatabase {
public:
ConfigurationDatabase(log4cplus::Logger logger);

/** \brief Open the database, using the given accessor */
void open(const std::string& accessor) noexcept(false);

typedef xercesc::DOMDocument* ApplicationConfig;

// General configuration (applications)
/** \brief Get the application configuration for the given item
\note User must release all DOMDocuments
*/
ApplicationConfig getApplicationConfig(const std::string& tag, const std::string& classname, int instance) noexcept(false);

// Get the configuration document (whole)
std::string getConfigurationDocument(const std::string& tag) noexcept(false);

// Firmware-related
/** \brief Retrieve the checksum for a given firmware version */
unsigned int getFirmwareChecksum(const std::string& board, unsigned int version) noexcept(false);
/** \brief Retrieve the MCS file lines for a given firmware version */
void getFirmwareMCS(const std::string& board, unsigned int version, std::vector<std::string>& mcsLines) noexcept(false);

typedef enum FPGASelectionEnum {Bottom=0, Top=1} FPGASelection;

struct FPGAId {
FPGAId() { }
FPGAId(int cr, int sl, FPGASelection fp) : crate(cr), slot(sl), fpga(fp) { }
bool operator<(const FPGAId& a) const;
int crate;
int slot;
FPGASelection fpga;
};

typedef enum LUTTypeEnum { LinearizerLUT=1, CompressionLUT=2 } LUTType;

// LUT-related
struct LUTId : public FPGAId {
LUTId() { }
LUTId(int crate_, int slot_, FPGASelection fpga_, int fiberorslb_, int chan_, LUTType lt) : FPGAId(crate_,slot_,fpga_), fiber_slb(fiberorslb_), channel(chan_), lut_type(lt) { }
bool operator<(const LUTId& a) const;
int fiber_slb; // fiber for linearizing, slb for compression
int channel; // fiberchan or slbchan
LUTType lut_type;
};
typedef std::vector<unsigned int> LUT;

/** \brief Retrieve the data for the requested LUTs (organized this way for better database efficiency)
\param tag Tag name for this LUT setup
\param crate Crate number
\param slot Slot number
\param LUTs Return map of the LUTs
*/
void getLUTs(const std::string& tag, int crate, int slot, std::map<LUTId, LUT>& LUTs) noexcept(false);

typedef std::vector<unsigned char> MD5Fingerprint;

/** \brief Retrieve the LUT checksums for all LUTs
\param tag Tag name for this LUT setup
\param checksums Checksums (MD5)
*/
void getLUTChecksums(const std::string& tag, std::map<LUTId, MD5Fingerprint>& checksums) noexcept(false);

struct PatternId : public FPGAId {
bool operator<(const PatternId& a) const;
PatternId(int cr, int sl, FPGASelection f, int fib) : FPGAId(cr,sl,f),fiber(fib) { }
int fiber;
};
typedef std::vector<unsigned int> HTRPattern;

/** \brief Retrieve the data for the requested pattern ram
\brief tag Tag name for this pattern ram set
\param crate Crate number
\param slot Slot number
\param patterns Return map of the patterns
*/
void getPatterns(const std::string& tag, int crate, int slot, std::map<PatternId, HTRPattern>& patterns) noexcept(false);

// ZS-related
struct ZSChannelId : public FPGAId {
ZSChannelId() { }
ZSChannelId(int crate_, int slot_, FPGASelection fpga_, int fiber_, int chan_) : FPGAId(crate_,slot_,fpga_),fiber(fiber_),channel(chan_) { }
bool operator<(const ZSChannelId& a) const;
int fiber;
int channel;
};

/** \brief Retrieve the zs thresholds for the specified slot
\brief tag Tag name
\param crate Crate number
\param slot Slot number
\param patterns Return map of the thresholds
*/
void getZSThresholds(const std::string& tag, int crate, int slot, std::map<ZSChannelId, int>& thresholds) noexcept(false);

struct HLXMasks{
uint32_t occMask;
uint32_t lhcMask;
uint32_t sumEtMask;
};

/** \brief Retrieve the HLX masks for the given slot
\brief tag Tag name
\param crate Crate number
\param slot Slot number
\param patterns Return map of the masks
*/
void getHLXMasks(const std::string& tag, int crate, int slot, std::map<FPGAId, HLXMasks>& masks) noexcept(false);


typedef enum RBXdatumTypeEnum {
eRBXdelay=1,
eRBXpedestal=2,
eRBXttcrxPhase=3,
eRBXgolCurrent=4,
eRBXbroadcast=5,
eRBXqieResetDelay=6,
eRBXledData=7,
eRBXccaPatterns=8
} RBXdatumType;
typedef enum LEDdatumTypeEnum {
eLEDnotApplicable=0,
eLEDenable=1,
eLEDamplitude=2,
eLEDtiming_hb=3,
eLEDtiming_lb=4
} LEDdatumType;
struct RBXdatumId {
bool operator<(const RBXdatumId& a) const;
RBXdatumId(LEDdatumType lt) : rm(0),card(0),qie_or_gol(0),dtype(eRBXledData),ltype(lt) { }
RBXdatumId(int r, int c, int qg, RBXdatumType dt) :
rm(r),card(c),qie_or_gol(qg),dtype(dt),ltype(eLEDnotApplicable) { }
RBXdatumId(RBXdatumType dt) :
rm(0),card(0),qie_or_gol(0),dtype(dt),ltype(eLEDnotApplicable) { }
int rm;
int card;
int qie_or_gol;
RBXdatumType dtype;
LEDdatumType ltype;
};

typedef unsigned char RBXdatum;

/** \brief Retrieve the data for the requested RBX
\param tag Tag name for this RBX config
\param rbx RBX name
\param dtype Datum type
\param RBXdata Return map of the data
*/
void getRBXdata(const std::string& tag,
const std::string& rbx,
RBXdatumType dtype,
std::map<RBXdatumId, RBXdatum>& RBXdata) noexcept(false);

typedef std::vector<unsigned char> RBXpattern;

/** \brief Retrieve CCA patterns for the requested RBX
\param tag Tag name for this RBX config
\param rbx RBX name
\param patterns Return map of the patterns
*/
void getRBXpatterns(const std::string& tag,
const std::string& rbx,
std::map<RBXdatumId, RBXpattern>& patterns) noexcept(false);

/** \brief Close the database */
void close();

/** \brief Retrieve the */



/** \brief Access the implementation directly (when open)
\note For expert use only
*/
ConfigurationDatabaseImpl* getImplementation() { return m_implementation; }


private:
std::vector<ConfigurationDatabaseImpl*> m_implementationOptions;
ConfigurationDatabaseImpl* m_implementation;
log4cplus::Logger m_logger;
};

}

#endif // hcal_ConfigurationDatabase_hh_included
@@ -0,0 +1,25 @@
#ifndef hcal_ConfigurationDatabaseException_hh_included
#define hcal_ConfigurationDatabaseException_hh_included 1

#include "CaloOnlineTools/HcalOnlineDb/interface/Exception.hh"

namespace hcal {
namespace exception {

class ConfigurationDatabaseException: public Exception {
public:
ConfigurationDatabaseException( const std::string& name, const std::string& message, const std::string& module, int line, const std::string& function ):
Exception(name, message, module, line, function)
{}
#ifdef HAVE_XDAQ
ConfigurationDatabaseException( const std::string& name, const std::string& message, const std::string& module, int line, const std::string& function,
xcept::Exception& e ):
Exception(name, message, module, line, function, e)
{}
#endif
};

}
}

#endif // hcal_ConfigurationDatabaseException_hh_included
@@ -0,0 +1,68 @@
#ifndef hcal_ConfigurationDatabaseImpl_hh_included
#define hcal_ConfigurationDatabaseImpl_hh_included 1

#include <string>
#include <vector>
#include <map>
#include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseException.hh"
#include "CaloOnlineTools/HcalOnlineDb/interface/PluginManager.hh"
#include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabase.hh"

#ifdef HAVE_XDAQ
#include "log4cplus/logger.h"
#else
#include "CaloOnlineTools/HcalOnlineDb/interface/xdaq_compat.h" // Includes typedef for log4cplus::Logger
#endif

//OCCI include
#include "OnlineDB/Oracle/interface/Oracle.h"

namespace hcal {

/** \brief Implementation of an accessor to the configuration database.

Accessors look like:
method://[user@]host[:port]/[database]?KEY=VALUE,...
\ingroup hcalBase
*/
class ConfigurationDatabaseImpl : public hcal::Pluggable {
public:
ConfigurationDatabaseImpl();
/** \brief Set logger */
void setLogger(log4cplus::Logger logger) { m_logger=logger; }
/** \brief Static method to parse an accessor into various fields */
static void parseAccessor(const std::string& accessor, std::string& method, std::string& host, std::string& port, std::string& user, std::string& db, std::map<std::string,std::string>& params);
/** \brief Used by the Application to determine which implementation to use for a given accessor */
virtual bool canHandleMethod(const std::string& method) const = 0;
/** \brief Connect to the database using the given accessor */
virtual void connect(const std::string& accessor) noexcept(false) = 0;
/** \brief Disconnect from the database */
virtual void disconnect() = 0;

/* Various requests (default for all is to throw an exception indicating that no implementation is available. */
virtual std::vector<std::string> getValidTags() noexcept(false);
virtual ConfigurationDatabase::ApplicationConfig getApplicationConfig(const std::string& tag, const std::string& classname, int instance) noexcept(false);
virtual std::string getConfigurationDocument(const std::string& tag) noexcept(false);
/** \brief Retrieve the checksum for a given firmware version */
virtual unsigned int getFirmwareChecksum(const std::string& board, unsigned int version) noexcept(false);
/** \brief Retrieve the MCS file lines for a given firmware version */
virtual void getFirmwareMCS(const std::string& board, unsigned int version, std::vector<std::string>& mcsLines) noexcept(false);
virtual void getLUTs(const std::string& tag, int crate, int slot, std::map<ConfigurationDatabase::LUTId, ConfigurationDatabase::LUT >& LUTs) noexcept(false);
virtual void getLUTChecksums(const std::string& tag, std::map<ConfigurationDatabase::LUTId, ConfigurationDatabase::MD5Fingerprint>& checksums) noexcept(false);
virtual void getPatterns(const std::string& tag, int crate, int slot, std::map<ConfigurationDatabase::PatternId, ConfigurationDatabase::HTRPattern>& patterns) noexcept(false);
virtual void getZSThresholds(const std::string& tag, int crate, int slot, std::map<ConfigurationDatabase::ZSChannelId, int>& thresholds) noexcept(false);
virtual void getHLXMasks(const std::string& tag, int crate, int slot, std::map<ConfigurationDatabase::FPGAId, ConfigurationDatabase::HLXMasks>& masks) noexcept(false);
virtual void getRBXdata(const std::string& tag, const std::string& rbx, ConfigurationDatabase::RBXdatumType dtype, std::map<ConfigurationDatabase::RBXdatumId, ConfigurationDatabase::RBXdatum>& RBXdata) noexcept(false);
virtual void getRBXpatterns(const std::string& tag, const std::string& rbx, std::map<ConfigurationDatabase::RBXdatumId, ConfigurationDatabase::RBXpattern>& patterns) noexcept(false);

// added by Gena Kukartsev
virtual oracle::occi::Connection * getConnection( void );
virtual oracle::occi::Environment * getEnvironment( void );

protected:
log4cplus::Logger m_logger;
};

}

#endif // hcal_ConfigurationDatabaseImpl_hh_included