Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:15:06

0001 #ifndef hcal_ConfigurationDatabase_hh_included
0002 #define hcal_ConfigurationDatabase_hh_included 1
0003 
0004 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseException.hh"
0005 #include "xercesc/dom/DOMDocument.hpp"
0006 #include <cstdint>
0007 #include <map>
0008 #include <string>
0009 #include <vector>
0010 
0011 #ifdef HAVE_XDAQ
0012 #include "log4cplus/logger.h"
0013 #else
0014 #include "CaloOnlineTools/HcalOnlineDb/interface/xdaq_compat.h"  // Includes typedef for log4cplus::Logger
0015 #endif
0016 
0017 namespace hcal {
0018 
0019   class ConfigurationDatabaseImpl;
0020 
0021   /** \brief Access to large-block configuration information such as firmwares and lookup tables
0022 
0023   Multithread access is not allowed.  The locking must be handled externally.
0024     \ingroup hcalBase
0025    */
0026   class ConfigurationDatabase {
0027   public:
0028     ConfigurationDatabase(log4cplus::Logger logger);
0029 
0030     /** \brief Open the database, using the given accessor */
0031     void open(const std::string& accessor) noexcept(false);
0032 
0033     typedef xercesc::DOMDocument* ApplicationConfig;
0034 
0035     // General configuration (applications)
0036     /** \brief Get the application configuration for the given item
0037         \note User must release all DOMDocuments
0038      */
0039     ApplicationConfig getApplicationConfig(const std::string& tag,
0040                                            const std::string& classname,
0041                                            int instance) noexcept(false);
0042 
0043     // Get the configuration document (whole)
0044     std::string getConfigurationDocument(const std::string& tag) noexcept(false);
0045 
0046     // Firmware-related
0047     /** \brief Retrieve the checksum for a given firmware version */
0048     unsigned int getFirmwareChecksum(const std::string& board, unsigned int version) noexcept(false);
0049     /** \brief Retrieve the MCS file lines for a given firmware version */
0050     void getFirmwareMCS(const std::string& board,
0051                         unsigned int version,
0052                         std::vector<std::string>& mcsLines) noexcept(false);
0053 
0054     typedef enum FPGASelectionEnum { Bottom = 0, Top = 1 } FPGASelection;
0055 
0056     struct FPGAId {
0057       FPGAId() {}
0058       FPGAId(int cr, int sl, FPGASelection fp) : crate(cr), slot(sl), fpga(fp) {}
0059       bool operator<(const FPGAId& a) const;
0060       int crate;
0061       int slot;
0062       FPGASelection fpga;
0063     };
0064 
0065     typedef enum LUTTypeEnum { LinearizerLUT = 1, CompressionLUT = 2 } LUTType;
0066 
0067     // LUT-related
0068     struct LUTId : public FPGAId {
0069       LUTId() {}
0070       LUTId(int crate_, int slot_, FPGASelection fpga_, int fiberorslb_, int chan_, LUTType lt)
0071           : FPGAId(crate_, slot_, fpga_), fiber_slb(fiberorslb_), channel(chan_), lut_type(lt) {}
0072       bool operator<(const LUTId& a) const;
0073       int fiber_slb;  // fiber for linearizing, slb for compression
0074       int channel;    // fiberchan or slbchan
0075       LUTType lut_type;
0076     };
0077     typedef std::vector<unsigned int> LUT;
0078 
0079     /** \brief Retrieve the data for the requested LUTs (organized this way for better database efficiency)
0080     \param tag Tag name for this LUT setup
0081     \param crate Crate number
0082     \param slot Slot number
0083     \param LUTs Return map of the LUTs
0084      */
0085     void getLUTs(const std::string& tag, int crate, int slot, std::map<LUTId, LUT>& LUTs) noexcept(false);
0086 
0087     typedef std::vector<unsigned char> MD5Fingerprint;
0088 
0089     /** \brief Retrieve the LUT checksums for all LUTs
0090     \param tag Tag name for this LUT setup
0091     \param checksums Checksums (MD5)
0092     */
0093     void getLUTChecksums(const std::string& tag, std::map<LUTId, MD5Fingerprint>& checksums) noexcept(false);
0094 
0095     struct PatternId : public FPGAId {
0096       bool operator<(const PatternId& a) const;
0097       PatternId(int cr, int sl, FPGASelection f, int fib) : FPGAId(cr, sl, f), fiber(fib) {}
0098       int fiber;
0099     };
0100     typedef std::vector<unsigned int> HTRPattern;
0101 
0102     /** \brief Retrieve the data for the requested pattern ram
0103     \brief tag Tag name for this pattern ram set
0104     \param crate Crate number
0105     \param slot Slot number
0106     \param patterns Return map of the patterns
0107     */
0108     void getPatterns(const std::string& tag,
0109                      int crate,
0110                      int slot,
0111                      std::map<PatternId, HTRPattern>& patterns) noexcept(false);
0112 
0113     // ZS-related
0114     struct ZSChannelId : public FPGAId {
0115       ZSChannelId() {}
0116       ZSChannelId(int crate_, int slot_, FPGASelection fpga_, int fiber_, int chan_)
0117           : FPGAId(crate_, slot_, fpga_), fiber(fiber_), channel(chan_) {}
0118       bool operator<(const ZSChannelId& a) const;
0119       int fiber;
0120       int channel;
0121     };
0122 
0123     /** \brief Retrieve the zs thresholds for the specified slot
0124     \brief tag Tag name 
0125     \param crate Crate number
0126     \param slot Slot number
0127     \param patterns Return map of the thresholds
0128     */
0129     void getZSThresholds(const std::string& tag,
0130                          int crate,
0131                          int slot,
0132                          std::map<ZSChannelId, int>& thresholds) noexcept(false);
0133 
0134     struct HLXMasks {
0135       uint32_t occMask;
0136       uint32_t lhcMask;
0137       uint32_t sumEtMask;
0138     };
0139 
0140     /** \brief Retrieve the HLX masks for the given slot
0141     \brief tag Tag name 
0142     \param crate Crate number
0143     \param slot Slot number
0144     \param patterns Return map of the masks
0145     */
0146     void getHLXMasks(const std::string& tag, int crate, int slot, std::map<FPGAId, HLXMasks>& masks) noexcept(false);
0147 
0148     typedef enum RBXdatumTypeEnum {
0149       eRBXdelay = 1,
0150       eRBXpedestal = 2,
0151       eRBXttcrxPhase = 3,
0152       eRBXgolCurrent = 4,
0153       eRBXbroadcast = 5,
0154       eRBXqieResetDelay = 6,
0155       eRBXledData = 7,
0156       eRBXccaPatterns = 8
0157     } RBXdatumType;
0158     typedef enum LEDdatumTypeEnum {
0159       eLEDnotApplicable = 0,
0160       eLEDenable = 1,
0161       eLEDamplitude = 2,
0162       eLEDtiming_hb = 3,
0163       eLEDtiming_lb = 4
0164     } LEDdatumType;
0165     struct RBXdatumId {
0166       bool operator<(const RBXdatumId& a) const;
0167       RBXdatumId(LEDdatumType lt) : rm(0), card(0), qie_or_gol(0), dtype(eRBXledData), ltype(lt) {}
0168       RBXdatumId(int r, int c, int qg, RBXdatumType dt)
0169           : rm(r), card(c), qie_or_gol(qg), dtype(dt), ltype(eLEDnotApplicable) {}
0170       RBXdatumId(RBXdatumType dt) : rm(0), card(0), qie_or_gol(0), dtype(dt), ltype(eLEDnotApplicable) {}
0171       int rm;
0172       int card;
0173       int qie_or_gol;
0174       RBXdatumType dtype;
0175       LEDdatumType ltype;
0176     };
0177 
0178     typedef unsigned char RBXdatum;
0179 
0180     /** \brief Retrieve the data for the requested RBX
0181     \param tag Tag name for this RBX config
0182     \param rbx RBX name
0183     \param dtype Datum type
0184     \param RBXdata Return map of the data
0185      */
0186     void getRBXdata(const std::string& tag,
0187                     const std::string& rbx,
0188                     RBXdatumType dtype,
0189                     std::map<RBXdatumId, RBXdatum>& RBXdata) noexcept(false);
0190 
0191     typedef std::vector<unsigned char> RBXpattern;
0192 
0193     /** \brief Retrieve CCA patterns for the requested RBX
0194     \param tag Tag name for this RBX config
0195     \param rbx RBX name
0196     \param patterns Return map of the patterns
0197      */
0198     void getRBXpatterns(const std::string& tag,
0199                         const std::string& rbx,
0200                         std::map<RBXdatumId, RBXpattern>& patterns) noexcept(false);
0201 
0202     /** \brief Close the database */
0203     void close();
0204 
0205     /** \brief Retrieve the */
0206 
0207     /** \brief Access the implementation directly (when open) 
0208     \note For expert use only
0209     */
0210     ConfigurationDatabaseImpl* getImplementation() { return m_implementation; }
0211 
0212   private:
0213     std::vector<ConfigurationDatabaseImpl*> m_implementationOptions;
0214     ConfigurationDatabaseImpl* m_implementation;
0215     log4cplus::Logger m_logger;
0216   };
0217 
0218 }  // namespace hcal
0219 
0220 #endif  // hcal_ConfigurationDatabase_hh_included