Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:22

0001 // -*- C++ -*-
0002 //
0003 // Package:    L1HfRingEtScaleOnlineProd
0004 // Class:      L1HfRingEtScaleOnlineProd
0005 //
0006 /**\class L1HfRingEtScaleOnlineProd L1HfRingEtScaleOnlineProd.h L1TriggerConfig/L1ScalesProducers/src/L1HfRingEtScaleOnlineProd.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Werner Man-Li Sun
0015 //         Created:  Tue Sep 16 22:43:22 CEST 2008
0016 //
0017 //
0018 
0019 // system include files
0020 
0021 // user include files
0022 #include "CondTools/L1Trigger/interface/L1ConfigOnlineProdBase.h"
0023 
0024 #include "CondFormats/L1TObjects/interface/L1CaloEtScale.h"
0025 #include "CondFormats/DataRecord/interface/L1HfRingEtScaleRcd.h"
0026 
0027 //
0028 // class declaration
0029 //
0030 
0031 class L1HfRingEtScaleOnlineProd : public L1ConfigOnlineProdBase<L1HfRingEtScaleRcd, L1CaloEtScale> {
0032 public:
0033   L1HfRingEtScaleOnlineProd(const edm::ParameterSet&);
0034   ~L1HfRingEtScaleOnlineProd() override;
0035 
0036   std::unique_ptr<L1CaloEtScale> newObject(const std::string& objectKey) override;
0037 
0038 private:
0039   // ----------member data ---------------------------
0040 };
0041 
0042 //
0043 // constants, enums and typedefs
0044 //
0045 
0046 //
0047 // static data member definitions
0048 //
0049 
0050 //
0051 // constructors and destructor
0052 //
0053 L1HfRingEtScaleOnlineProd::L1HfRingEtScaleOnlineProd(const edm::ParameterSet& iConfig)
0054     : L1ConfigOnlineProdBase<L1HfRingEtScaleRcd, L1CaloEtScale>(iConfig) {
0055   //the following line is needed to tell the framework what
0056   // data is being produced
0057 
0058   //now do what ever other initialization is needed
0059 }
0060 
0061 L1HfRingEtScaleOnlineProd::~L1HfRingEtScaleOnlineProd() {
0062   // do anything here that needs to be done at desctruction time
0063   // (e.g. close files, deallocate resources etc.)
0064 }
0065 
0066 std::unique_ptr<L1CaloEtScale> L1HfRingEtScaleOnlineProd::newObject(const std::string& objectKey) {
0067   // get scales keys
0068   l1t::OMDSReader::QueryResults scalesKeyResults = m_omdsReader.basicQuery("GCT_SCALES_KEY",
0069                                                                            "CMS_GCT",
0070                                                                            "GCT_PHYS_PARAMS",
0071                                                                            "GCT_PHYS_PARAMS.CONFIG_KEY",
0072                                                                            m_omdsReader.singleAttribute(objectKey));
0073 
0074   std::string scalesKey;
0075 
0076   if (scalesKeyResults.queryFailed()) {
0077     edm::LogError("L1-O2O") << "Problem with key for L1JetEtScaleRcd : GCT scales key query failed ";
0078   } else if (scalesKeyResults.numberRows() != 1) {
0079     edm::LogError("L1-O2O") << "Problem with key for L1JetEtScaleRcd : " << (scalesKeyResults.numberRows())
0080                             << " rows were returned when getting GCT scales key";
0081   } else {
0082     scalesKeyResults.fillVariable(scalesKey);
0083   }
0084 
0085   // get ring scale key
0086   l1t::OMDSReader::QueryResults hfRingScaleKeyResults =
0087       m_omdsReader.basicQuery("SC_HF_ET_SUM_FK", "CMS_GT", "L1T_SCALES", "L1T_SCALES.ID", scalesKeyResults);
0088 
0089   std::string hfRingScaleKey;
0090 
0091   if (hfRingScaleKeyResults.queryFailed()) {
0092     edm::LogError("L1-O2O") << "Problem with key for L1HfRingEtScaleRcd : HF ring Et scale key query failed ";
0093   } else if (hfRingScaleKeyResults.numberRows() != 1) {
0094     edm::LogError("L1-O2O") << "Problem with key for L1HfRingEtScaleRcd : " << (hfRingScaleKeyResults.numberRows())
0095                             << " rows were returned when getting HF ring Et scale key";
0096   } else {
0097     hfRingScaleKeyResults.fillVariable(hfRingScaleKey);
0098   }
0099 
0100   // get thresholds
0101   std::vector<std::string> queryStrings;
0102   queryStrings.push_back("E_GEV_BIN_LOW_0");
0103   queryStrings.push_back("E_GEV_BIN_LOW_1");
0104   queryStrings.push_back("E_GEV_BIN_LOW_2");
0105   queryStrings.push_back("E_GEV_BIN_LOW_3");
0106   queryStrings.push_back("E_GEV_BIN_LOW_4");
0107   queryStrings.push_back("E_GEV_BIN_LOW_5");
0108   queryStrings.push_back("E_GEV_BIN_LOW_6");
0109   queryStrings.push_back("E_GEV_BIN_LOW_7");
0110 
0111   l1t::OMDSReader::QueryResults scaleResults = m_omdsReader.basicQuery(
0112       queryStrings, "CMS_GT", "L1T_SCALE_HF_ET_SUM", "L1T_SCALE_HF_ET_SUM.ID", hfRingScaleKeyResults);
0113 
0114   std::vector<double> thresholds;
0115 
0116   if (scaleResults.queryFailed()) {
0117     edm::LogError("L1-O2O") << "Problem with L1HfRingEtScale key : scale query failed.";
0118   } else if (scaleResults.numberRows() != 1) {
0119     edm::LogError("L1-O2O") << "Problem with L1HfRingEtScale key : scale query failed.";
0120   } else {
0121     for (std::vector<std::string>::iterator thresh = queryStrings.begin(); thresh != queryStrings.end(); ++thresh) {
0122       float tempScale = 0.;
0123       scaleResults.fillVariable(*thresh, tempScale);
0124       thresholds.push_back(tempScale);
0125     }
0126   }
0127 
0128   // get region LSB
0129   double rgnEtLsb = 0.;
0130 
0131   l1t::OMDSReader::QueryResults lsbResults = m_omdsReader.basicQuery("GCT_RGN_ET_LSB",
0132                                                                      "CMS_GCT",
0133                                                                      "GCT_PHYS_PARAMS",
0134                                                                      "GCT_PHYS_PARAMS.CONFIG_KEY",
0135                                                                      m_omdsReader.singleAttribute(objectKey));
0136 
0137   if (lsbResults.queryFailed()) {
0138     edm::LogError("L1-O2O") << "Problem with L1JetEtScale key.";
0139   } else {
0140     lsbResults.fillVariable("GCT_RGN_ET_LSB", rgnEtLsb);
0141   }
0142 
0143   //~~~~~~~~~ Instantiate new L1HfRingEtScale object. ~~~~~~~~~
0144   return std::make_unique<L1CaloEtScale>(0xff, 0x7, rgnEtLsb, thresholds);
0145 }
0146 
0147 // ------------ method called to produce the data  ------------
0148 
0149 //define this as a plug-in
0150 DEFINE_FWK_EVENTSETUP_MODULE(L1HfRingEtScaleOnlineProd);