Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:    L1JetEtScaleOnlineProd
0004 // Class:      L1JetEtScaleOnlineProd
0005 //
0006 /**\class L1JetEtScaleOnlineProd L1JetEtScaleOnlineProd.h L1TriggerConfig/L1ScalesProducers/src/L1JetEtScaleOnlineProd.cc
0007 
0008  Description: Online producer for L1 jet Et scales
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/L1JetEtScaleRcd.h"
0026 
0027 //
0028 // class declaration
0029 //
0030 
0031 class L1JetEtScaleOnlineProd : public L1ConfigOnlineProdBase<L1JetEtScaleRcd, L1CaloEtScale> {
0032 public:
0033   L1JetEtScaleOnlineProd(const edm::ParameterSet&);
0034   ~L1JetEtScaleOnlineProd() 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 L1JetEtScaleOnlineProd::L1JetEtScaleOnlineProd(const edm::ParameterSet& iConfig)
0054     : L1ConfigOnlineProdBase<L1JetEtScaleRcd, 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 L1JetEtScaleOnlineProd::~L1JetEtScaleOnlineProd() {
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> L1JetEtScaleOnlineProd::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 jet scale key
0086   l1t::OMDSReader::QueryResults jetScaleKeyResults =
0087       m_omdsReader.basicQuery("SC_CENJET_ET_THRESHOLD_FK", "CMS_GT", "L1T_SCALES", "L1T_SCALES.ID", scalesKeyResults);
0088 
0089   std::string jetScaleKey;
0090 
0091   if (jetScaleKeyResults.queryFailed()) {
0092     edm::LogError("L1-O2O") << "Problem with key for L1GctJetEtScaleRcd : jet scale key query failed ";
0093   } else if (jetScaleKeyResults.numberRows() != 1) {
0094     edm::LogError("L1-O2O") << "Problem with key for L1GctJetEtScaleRcd : " << (jetScaleKeyResults.numberRows())
0095                             << " rows were returned when getting jet Et scale key";
0096   } else {
0097     jetScaleKeyResults.fillVariable(jetScaleKey);
0098   }
0099 
0100   // get thresholds
0101   std::vector<std::string> queryStrings;
0102   queryStrings.push_back("ET_GEV_BIN_LOW_0");
0103   queryStrings.push_back("ET_GEV_BIN_LOW_1");
0104   queryStrings.push_back("ET_GEV_BIN_LOW_2");
0105   queryStrings.push_back("ET_GEV_BIN_LOW_3");
0106   queryStrings.push_back("ET_GEV_BIN_LOW_4");
0107   queryStrings.push_back("ET_GEV_BIN_LOW_5");
0108   queryStrings.push_back("ET_GEV_BIN_LOW_6");
0109   queryStrings.push_back("ET_GEV_BIN_LOW_7");
0110   queryStrings.push_back("ET_GEV_BIN_LOW_8");
0111   queryStrings.push_back("ET_GEV_BIN_LOW_9");
0112   queryStrings.push_back("ET_GEV_BIN_LOW_10");
0113   queryStrings.push_back("ET_GEV_BIN_LOW_11");
0114   queryStrings.push_back("ET_GEV_BIN_LOW_12");
0115   queryStrings.push_back("ET_GEV_BIN_LOW_13");
0116   queryStrings.push_back("ET_GEV_BIN_LOW_14");
0117   queryStrings.push_back("ET_GEV_BIN_LOW_15");
0118   queryStrings.push_back("ET_GEV_BIN_LOW_16");
0119   queryStrings.push_back("ET_GEV_BIN_LOW_17");
0120   queryStrings.push_back("ET_GEV_BIN_LOW_18");
0121   queryStrings.push_back("ET_GEV_BIN_LOW_19");
0122   queryStrings.push_back("ET_GEV_BIN_LOW_20");
0123   queryStrings.push_back("ET_GEV_BIN_LOW_21");
0124   queryStrings.push_back("ET_GEV_BIN_LOW_22");
0125   queryStrings.push_back("ET_GEV_BIN_LOW_23");
0126   queryStrings.push_back("ET_GEV_BIN_LOW_24");
0127   queryStrings.push_back("ET_GEV_BIN_LOW_25");
0128   queryStrings.push_back("ET_GEV_BIN_LOW_26");
0129   queryStrings.push_back("ET_GEV_BIN_LOW_27");
0130   queryStrings.push_back("ET_GEV_BIN_LOW_28");
0131   queryStrings.push_back("ET_GEV_BIN_LOW_29");
0132   queryStrings.push_back("ET_GEV_BIN_LOW_30");
0133   queryStrings.push_back("ET_GEV_BIN_LOW_31");
0134   queryStrings.push_back("ET_GEV_BIN_LOW_32");
0135   queryStrings.push_back("ET_GEV_BIN_LOW_33");
0136   queryStrings.push_back("ET_GEV_BIN_LOW_34");
0137   queryStrings.push_back("ET_GEV_BIN_LOW_35");
0138   queryStrings.push_back("ET_GEV_BIN_LOW_36");
0139   queryStrings.push_back("ET_GEV_BIN_LOW_37");
0140   queryStrings.push_back("ET_GEV_BIN_LOW_38");
0141   queryStrings.push_back("ET_GEV_BIN_LOW_39");
0142   queryStrings.push_back("ET_GEV_BIN_LOW_40");
0143   queryStrings.push_back("ET_GEV_BIN_LOW_41");
0144   queryStrings.push_back("ET_GEV_BIN_LOW_42");
0145   queryStrings.push_back("ET_GEV_BIN_LOW_43");
0146   queryStrings.push_back("ET_GEV_BIN_LOW_44");
0147   queryStrings.push_back("ET_GEV_BIN_LOW_45");
0148   queryStrings.push_back("ET_GEV_BIN_LOW_46");
0149   queryStrings.push_back("ET_GEV_BIN_LOW_47");
0150   queryStrings.push_back("ET_GEV_BIN_LOW_48");
0151   queryStrings.push_back("ET_GEV_BIN_LOW_49");
0152   queryStrings.push_back("ET_GEV_BIN_LOW_50");
0153   queryStrings.push_back("ET_GEV_BIN_LOW_51");
0154   queryStrings.push_back("ET_GEV_BIN_LOW_52");
0155   queryStrings.push_back("ET_GEV_BIN_LOW_53");
0156   queryStrings.push_back("ET_GEV_BIN_LOW_54");
0157   queryStrings.push_back("ET_GEV_BIN_LOW_55");
0158   queryStrings.push_back("ET_GEV_BIN_LOW_56");
0159   queryStrings.push_back("ET_GEV_BIN_LOW_57");
0160   queryStrings.push_back("ET_GEV_BIN_LOW_58");
0161   queryStrings.push_back("ET_GEV_BIN_LOW_59");
0162   queryStrings.push_back("ET_GEV_BIN_LOW_60");
0163   queryStrings.push_back("ET_GEV_BIN_LOW_61");
0164   queryStrings.push_back("ET_GEV_BIN_LOW_62");
0165   queryStrings.push_back("ET_GEV_BIN_LOW_63");
0166 
0167   l1t::OMDSReader::QueryResults scaleResults = m_omdsReader.basicQuery(
0168       queryStrings, "CMS_GT", "L1T_SCALE_CALO_ET_THRESHOLD", "L1T_SCALE_CALO_ET_THRESHOLD.ID", jetScaleKeyResults);
0169 
0170   std::vector<double> thresholds;
0171 
0172   if (scaleResults.queryFailed() || scaleResults.numberRows() != 1)  // check query successful
0173   {
0174     edm::LogError("L1-O2O") << "Problem with L1JetEtScale key : when reading scale.";
0175   } else {
0176     for (std::vector<std::string>::iterator thresh = queryStrings.begin(); thresh != queryStrings.end(); ++thresh) {
0177       float tempScale = 0.0;
0178       scaleResults.fillVariable(*thresh, tempScale);
0179       thresholds.push_back(tempScale);
0180     }
0181   }
0182 
0183   // get region LSB
0184   double rgnEtLsb = 0.;
0185 
0186   l1t::OMDSReader::QueryResults lsbResults = m_omdsReader.basicQuery("GCT_RGN_ET_LSB",
0187                                                                      "CMS_GCT",
0188                                                                      "GCT_PHYS_PARAMS",
0189                                                                      "GCT_PHYS_PARAMS.CONFIG_KEY",
0190                                                                      m_omdsReader.singleAttribute(objectKey));
0191 
0192   if (lsbResults.queryFailed()) {
0193     edm::LogError("L1-O2O") << "Problem with L1JetEtScale key.";
0194   } else {
0195     lsbResults.fillVariable("GCT_RGN_ET_LSB", rgnEtLsb);
0196   }
0197 
0198   // return object
0199   return std::make_unique<L1CaloEtScale>(rgnEtLsb, thresholds);
0200 }
0201 
0202 // ------------ method called to produce the data  ------------
0203 
0204 //define this as a plug-in
0205 DEFINE_FWK_EVENTSETUP_MODULE(L1JetEtScaleOnlineProd);