CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/L1TriggerConfig/L1ScalesProducers/src/L1MuTriggerPtScaleOnlineProducer.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00003 //   \class L1MuTriggerPtScaleOnlineProducer
00004 //
00005 //   Description:  A class to produce the L1 mu emulator scales record in the event setup
00006 //
00007 //   $Date: 2008/11/24 18:59:59 $
00008 //   $Revision: 1.1 $
00009 //
00010 //   Author :
00011 //   W. Sun (copied from L1MuTriggerScalesProducer)
00012 //
00013 //--------------------------------------------------
00014 #include "L1TriggerConfig/L1ScalesProducers/interface/L1MuTriggerPtScaleOnlineProducer.h"
00015 
00016 // #define DEBUG_PT_SCALE
00017 #ifdef DEBUG_PT_SCALE
00018 #include <iostream>
00019 #endif
00020 
00021 #include <sstream>
00022 
00023 using namespace std;
00024 
00025 L1MuTriggerPtScaleOnlineProducer::L1MuTriggerPtScaleOnlineProducer(const edm::ParameterSet& ps)
00026   : L1ConfigOnlineProdBase<L1MuTriggerPtScaleRcd, L1MuTriggerPtScale>(ps),
00027     m_signedPacking(ps.getParameter<bool>("signedPackingPt")),
00028     m_nbitsPacking(ps.getParameter<int>("nbitPackingPt")),
00029     m_nBins(ps.getParameter<int>("nbinsPt"))
00030 {
00031 }
00032 
00033 L1MuTriggerPtScaleOnlineProducer::~L1MuTriggerPtScaleOnlineProducer() {}
00034 
00035 
00036 //
00037 // member functions
00038 //
00039 
00040 // ------------ method called to produce the data  ------------
00041 boost::shared_ptr<L1MuTriggerPtScale> 
00042 L1MuTriggerPtScaleOnlineProducer::newObject(const std::string& objectKey )
00043 {
00044    using namespace edm::es;
00045 
00046    // find Pt key from main scales key
00047    l1t::OMDSReader::QueryResults keysRecord = 
00048          m_omdsReader.basicQuery(
00049           // SELECTed columns
00050           "SC_MUON_PT_FK",
00051           // schema name
00052           "CMS_GT",
00053           // table name
00054           "L1T_SCALES",
00055           // WHERE lhs
00056           "L1T_SCALES.ID",
00057           // WHERE rhs
00058           m_omdsReader.singleAttribute( objectKey  ) );
00059 
00060    if( keysRecord.numberRows() != 1 ) // check if query was successful
00061    {
00062        throw cond::Exception("Problem finding L1MuTriggerScales associated "
00063                              "with scales key " + objectKey);
00064    }
00065 
00066 
00067    /*
00068 SQL> describe cms_gt.l1t_scale_muon_pt;
00069  Name                                      Null?    Type
00070  ----------------------------------------- -------- ----------------------------
00071  ID                                        NOT NULL VARCHAR2(300)
00072  PT_GEV_BIN_LOW_0                                   NUMBER
00073  [...]
00074  PT_GEV_BIN_LOW_32                                  NUMBER
00075    */
00076 
00077    ScaleRecordHelper h("PT_GEV_BIN_LOW", m_nBins );
00078 
00079    vector<string> columns;
00080    h.pushColumnNames(columns);
00081 
00082    l1t::OMDSReader::QueryResults resultRecord = 
00083        m_omdsReader.basicQuery(
00084            // SELECTed columns
00085            columns,
00086            // schema name
00087            "CMS_GT",
00088            // table name
00089            "L1T_SCALE_MUON_PT",
00090            // WHERE lhs
00091            "L1T_SCALE_MUON_PT.ID",
00092            // WHERE rhs
00093            keysRecord);
00094 
00095    if(resultRecord.numberRows() != 1) { 
00096        throw cond::Exception("Couldn't find Pt scale record for scales key `" 
00097                              + objectKey + "'") ;
00098    }
00099 
00100    vector<double> scales;
00101    h.extractScales(resultRecord, scales);
00102    
00103    boost::shared_ptr<L1MuTriggerPtScale> result( new L1MuTriggerPtScale(m_nbitsPacking, m_signedPacking, m_nBins, scales) );
00104    
00105 #ifdef DEBUG_PT_SCALE
00106    cout << "PT scale:" << endl << result->getPtScale()->print() << endl;
00107 #endif
00108 
00109 
00110    return result ;
00111 }