Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 //-------------------------------------------------
0002 //
0003 //   \class L1MuTriggerPtScaleOnlineProducer
0004 //
0005 //   Description:  A class to produce the L1 mu emulator scales record in the event setup
0006 //
0007 //
0008 //   Author :
0009 //   W. Sun (copied from L1MuTriggerScalesProducer)
0010 //
0011 //--------------------------------------------------
0012 #include "L1TriggerConfig/L1ScalesProducers/interface/L1MuTriggerPtScaleOnlineProducer.h"
0013 
0014 // #define DEBUG_PT_SCALE
0015 #ifdef DEBUG_PT_SCALE
0016 #include <iostream>
0017 #endif
0018 
0019 #include <sstream>
0020 
0021 using namespace std;
0022 
0023 L1MuTriggerPtScaleOnlineProducer::L1MuTriggerPtScaleOnlineProducer(const edm::ParameterSet& ps)
0024     : L1ConfigOnlineProdBase<L1MuTriggerPtScaleRcd, L1MuTriggerPtScale>(ps),
0025       m_signedPacking(ps.getParameter<bool>("signedPackingPt")),
0026       m_nbitsPacking(ps.getParameter<int>("nbitPackingPt")),
0027       m_nBins(ps.getParameter<int>("nbinsPt")) {}
0028 
0029 L1MuTriggerPtScaleOnlineProducer::~L1MuTriggerPtScaleOnlineProducer() {}
0030 
0031 //
0032 // member functions
0033 //
0034 
0035 // ------------ method called to produce the data  ------------
0036 std::unique_ptr<L1MuTriggerPtScale> L1MuTriggerPtScaleOnlineProducer::newObject(const std::string& objectKey) {
0037   // find Pt key from main scales key
0038   l1t::OMDSReader::QueryResults keysRecord = m_omdsReader.basicQuery(
0039       // SELECTed columns
0040       "SC_MUON_PT_FK",
0041       // schema name
0042       "CMS_GT",
0043       // table name
0044       "L1T_SCALES",
0045       // WHERE lhs
0046       "L1T_SCALES.ID",
0047       // WHERE rhs
0048       m_omdsReader.singleAttribute(objectKey));
0049 
0050   if (keysRecord.numberRows() != 1)  // check if query was successful
0051   {
0052     throw cond::Exception(
0053         "Problem finding L1MuTriggerScales associated "
0054         "with scales key " +
0055         objectKey);
0056   }
0057 
0058   /*
0059 SQL> describe cms_gt.l1t_scale_muon_pt;
0060  Name                                      Null?    Type
0061  ----------------------------------------- -------- ----------------------------
0062  ID                                        NOT NULL VARCHAR2(300)
0063  PT_GEV_BIN_LOW_0                                   NUMBER
0064  [...]
0065  PT_GEV_BIN_LOW_32                                  NUMBER
0066    */
0067 
0068   ScaleRecordHelper h("PT_GEV_BIN_LOW", m_nBins);
0069 
0070   vector<string> columns;
0071   h.pushColumnNames(columns);
0072 
0073   l1t::OMDSReader::QueryResults resultRecord = m_omdsReader.basicQuery(
0074       // SELECTed columns
0075       columns,
0076       // schema name
0077       "CMS_GT",
0078       // table name
0079       "L1T_SCALE_MUON_PT",
0080       // WHERE lhs
0081       "L1T_SCALE_MUON_PT.ID",
0082       // WHERE rhs
0083       keysRecord);
0084 
0085   if (resultRecord.numberRows() != 1) {
0086     throw cond::Exception("Couldn't find Pt scale record for scales key `" + objectKey + "'");
0087   }
0088 
0089   vector<double> scales;
0090   h.extractScales(resultRecord, scales);
0091 
0092   auto result = std::make_unique<L1MuTriggerPtScale>(m_nbitsPacking, m_signedPacking, m_nBins, scales);
0093 
0094 #ifdef DEBUG_PT_SCALE
0095   cout << "PT scale:" << endl << result->getPtScale()->print() << endl;
0096 #endif
0097 
0098   return result;
0099 }