Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:07

0001 #ifndef L1GtConfigProducers_L1GtPsbSetupConfigOnlineProd_h
0002 #define L1GtConfigProducers_L1GtPsbSetupConfigOnlineProd_h
0003 
0004 /**
0005  * \class L1GtPsbSetupConfigOnlineProd
0006  *
0007  *
0008  * Description: online producer for L1GtPsbSetup.
0009  *
0010  * Implementation:
0011  *    <TODO: enter implementation details>
0012  *
0013  * \author: Vasile Mihai Ghete - HEPHY Vienna
0014  *
0015  *
0016  */
0017 
0018 // system include files
0019 #include <memory>
0020 #include <string>
0021 #include <vector>
0022 
0023 // user include files
0024 //   base class
0025 #include "CondTools/L1Trigger/interface/L1ConfigOnlineProdBase.h"
0026 
0027 #include "CondTools/L1Trigger/interface/OMDSReader.h"
0028 #include "CondFormats/L1TObjects/interface/L1GtPsbSetup.h"
0029 #include "CondFormats/DataRecord/interface/L1GtPsbSetupRcd.h"
0030 #include "CondFormats/L1TObjects/interface/L1GtPsbConfig.h"
0031 
0032 // forward declarations
0033 
0034 // class declaration
0035 class L1GtPsbSetupConfigOnlineProd : public L1ConfigOnlineProdBase<L1GtPsbSetupRcd, L1GtPsbSetup> {
0036 public:
0037   /// constructor
0038   L1GtPsbSetupConfigOnlineProd(const edm::ParameterSet&);
0039 
0040   /// destructor
0041   ~L1GtPsbSetupConfigOnlineProd() override;
0042 
0043   /// public methods
0044   std::unique_ptr<L1GtPsbSetup> newObject(const std::string& objectKey) override;
0045 
0046 private:
0047   /// A predicate to filter the column names of GT_SETUP for
0048   /// those that contain foreign keys to GT_PSB_SETUP.
0049   static bool notPsbColumnName(const std::string& columnName);
0050 
0051   /// Creates a new PSB object from a GT_PSB_SETUP entry and adds.
0052   void addPsbFromDb(const std::string& psbKey, std::vector<L1GtPsbConfig>& psbSetup);
0053 
0054   /// Creates a default valued PSB from an empty foreign key in the GT_SETUP table.
0055   void addDefaultPsb(const std::string& psbColumn, std::vector<L1GtPsbConfig>& psbSetup) const;
0056 
0057   /// Ensures that result contains exactly one line, returning false otherwise
0058   bool checkOneLineResult(const l1t::OMDSReader::QueryResults& result, const std::string& queryDescription) const;
0059 
0060   /// A wrapper for OMDSReader::QueryResults::fillVariable that throws an
0061   /// exception when the field it accesses was NULL.
0062   template <class T>
0063   void getRequiredValue(const l1t::OMDSReader::QueryResults& result, const std::string& colName, T& value) const {
0064     if (!result.fillVariable(colName, value)) {
0065       throw cms::Exception("NullValue") << "Required field " << colName << " is NULL in database!";
0066     }
0067   }
0068 
0069   /// A function to extract a vector of booleans from the GT database format (NUMBER(1)
0070   /// columns labeled prefix<nn>suffix).
0071   std::vector<bool> extractBoolVector(const l1t::OMDSReader::QueryResults& query,
0072                                       const std::string& prefix,
0073                                       const std::string& suffix,
0074                                       unsigned nColumns) const;
0075 
0076   /// Concatenates prefix, number and suffix into a string.
0077   std::string numberedColumnName(const std::string& prefix, unsigned number, const std::string& suffix) const;
0078 
0079   /// Special case for empty suffix
0080   std::string numberedColumnName(const std::string& prefix, unsigned number) const;
0081   unsigned numberFromString(const std::string& aString) const;
0082 };
0083 
0084 #endif