Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 //-------------------------------------------------
0002 //
0003 //   \class L1MuGMTParametersOnlineProducer
0004 //
0005 //   Description:  A class to produce the L1 GMT emulator Parameters record in the event setup
0006 //                 by reading them from the online database.
0007 //
0008 //
0009 //   Author :
0010 //   Thomas Themel
0011 //
0012 //--------------------------------------------------
0013 #include "L1TriggerConfig/GMTConfigProducers/interface/L1MuGMTParametersOnlineProducer.h"
0014 
0015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0016 #include "FWCore/Framework/interface/EventSetup.h"
0017 
0018 /* Define this to see debug output from the record parsing layer. */
0019 //#define RECORDHELPER_DEBUG
0020 
0021 #include "L1TriggerConfig/GMTConfigProducers/interface/RecordHelper.h"
0022 #include "L1TriggerConfig/GMTConfigProducers/interface/GTRecordGroup.h"
0023 #include "CondTools/L1Trigger/interface/Exception.h"
0024 
0025 using namespace std;
0026 using coral::AttributeList;
0027 
0028 RH_ASSIGN_GROUP(L1MuGMTParameters, TGlobalTriggerGroup)
0029 
0030 /** ------------ method called to produce the data  ------------
0031  *  Query the CMS_GMT.GMT_SOFTWARE_CONFIG table with a key determined by the "master" config table
0032  *  and return the matching record.
0033  */
0034 std::unique_ptr<L1MuGMTParameters> L1MuGMTParametersOnlineProducer::newObject(const std::string& objectKey) {
0035   RecordHelper<L1MuGMTParameters> helper;
0036 
0037   // Copy data members from L1MuGMTParameters,
0038   // and  M-x replace-regexp RET .*m_\([a-z:_]*\) RET ADD_FIELD(helper, L1MuGMTParameters, \1) RET
0039 
0040   ADD_FIELD(helper, L1MuGMTParameters, EtaWeight_barrel);
0041   ADD_FIELD(helper, L1MuGMTParameters, PhiWeight_barrel);
0042   ADD_FIELD(helper, L1MuGMTParameters, EtaPhiThreshold_barrel);
0043   ADD_FIELD(helper, L1MuGMTParameters, EtaWeight_endcap);
0044   ADD_FIELD(helper, L1MuGMTParameters, PhiWeight_endcap);
0045   ADD_FIELD(helper, L1MuGMTParameters, EtaPhiThreshold_endcap);
0046   ADD_FIELD(helper, L1MuGMTParameters, EtaWeight_COU);
0047   ADD_FIELD(helper, L1MuGMTParameters, PhiWeight_COU);
0048   ADD_FIELD(helper, L1MuGMTParameters, EtaPhiThreshold_COU);
0049   ADD_FIELD(helper, L1MuGMTParameters, CaloTrigger);
0050   ADD_FIELD(helper, L1MuGMTParameters, IsolationCellSizeEta);
0051   ADD_FIELD(helper, L1MuGMTParameters, IsolationCellSizePhi);
0052   ADD_FIELD(helper, L1MuGMTParameters, DoOvlRpcAnd);
0053   ADD_FIELD(helper, L1MuGMTParameters, PropagatePhi);
0054   ADD_FIELD(helper, L1MuGMTParameters, MergeMethodPhiBrl);
0055   ADD_FIELD(helper, L1MuGMTParameters, MergeMethodPhiFwd);
0056   ADD_FIELD(helper, L1MuGMTParameters, MergeMethodEtaBrl);
0057   ADD_FIELD(helper, L1MuGMTParameters, MergeMethodEtaFwd);
0058   ADD_FIELD(helper, L1MuGMTParameters, MergeMethodPtBrl);
0059   ADD_FIELD(helper, L1MuGMTParameters, MergeMethodPtFwd);
0060   ADD_FIELD(helper, L1MuGMTParameters, MergeMethodChargeBrl);
0061   ADD_FIELD(helper, L1MuGMTParameters, MergeMethodChargeFwd);
0062   ADD_FIELD(helper, L1MuGMTParameters, MergeMethodMIPBrl);
0063   ADD_FIELD(helper, L1MuGMTParameters, MergeMethodMIPFwd);
0064   ADD_FIELD(helper, L1MuGMTParameters, MergeMethodMIPSpecialUseANDBrl);
0065   ADD_FIELD(helper, L1MuGMTParameters, MergeMethodMIPSpecialUseANDFwd);
0066   ADD_FIELD(helper, L1MuGMTParameters, MergeMethodISOBrl);
0067   ADD_FIELD(helper, L1MuGMTParameters, MergeMethodISOFwd);
0068   ADD_FIELD(helper, L1MuGMTParameters, MergeMethodISOSpecialUseANDBrl);
0069   ADD_FIELD(helper, L1MuGMTParameters, MergeMethodISOSpecialUseANDFwd);
0070   ADD_FIELD(helper, L1MuGMTParameters, MergeMethodSRKBrl);
0071   ADD_FIELD(helper, L1MuGMTParameters, MergeMethodSRKFwd);
0072   ADD_FIELD(helper, L1MuGMTParameters, HaloOverwritesMatchedBrl);
0073   ADD_FIELD(helper, L1MuGMTParameters, HaloOverwritesMatchedFwd);
0074   ADD_FIELD(helper, L1MuGMTParameters, SortRankOffsetBrl);
0075   ADD_FIELD(helper, L1MuGMTParameters, SortRankOffsetFwd);
0076   ADD_FIELD(helper, L1MuGMTParameters, CDLConfigWordDTCSC);
0077   ADD_FIELD(helper, L1MuGMTParameters, CDLConfigWordCSCDT);
0078   ADD_FIELD(helper, L1MuGMTParameters, CDLConfigWordbRPCCSC);
0079   ADD_FIELD(helper, L1MuGMTParameters, CDLConfigWordfRPCDT);
0080   ADD_FIELD(helper, L1MuGMTParameters, VersionSortRankEtaQLUT);
0081   ADD_FIELD(helper, L1MuGMTParameters, VersionLUTs);
0082 
0083   auto ptrResult = std::make_unique<L1MuGMTParameters>();
0084 
0085   std::vector<std::string> resultColumns = helper.getColumnList();
0086   resultColumns.push_back("CMSSW_VERSION");
0087 
0088   l1t::OMDSReader::QueryResults resultLines = m_omdsReader.basicQuery(
0089       // SELECTed columns
0090       resultColumns,
0091       // schema name
0092       "CMS_GMT",
0093       // table name
0094       "GMT_SOFTWARE_CONFIG",
0095       // WHERE lhs
0096       "GMT_SOFTWARE_CONFIG.KEY",
0097       // WHERE rhs
0098       m_omdsReader.singleAttribute(objectKey));
0099 
0100   if (resultLines.numberRows() == 1) {
0101     const AttributeList& resultRecord = resultLines.attributeLists().front();
0102     checkCMSSWVersion(resultRecord);
0103     helper.extractRecord(resultRecord, *ptrResult);
0104     return ptrResult;
0105   }
0106 
0107   throw cond::Exception("Couldn't find GMT_SOFTWARE_CONFIG record for GMT key `" + objectKey + "'");
0108 }
0109 
0110 void L1MuGMTParametersOnlineProducer::checkCMSSWVersion(const coral::AttributeList& configRecord) {
0111   const coral::Attribute& version = configRecord["CMSSW_VERSION"];
0112 
0113   /* If the DB field is unset, take any. */
0114   if (version.isNull()) {
0115     edm::LogInfo("No CMSSW version set in database, accepting " PROJECT_VERSION);
0116     return;
0117   }
0118 
0119   /* Else make sure we have the correct  version. */
0120   const std::string& versionString = version.data<string>();
0121 
0122   /* PROJECT_VERSION is passed as a -D #define from scramv1 (eg CMSSW_2_1_0) */
0123   if (versionString != PROJECT_VERSION) {
0124     std::string errMsg =
0125         "CMSSW version mismatch: Configuration requires " + versionString + ", but this is " + PROJECT_VERSION + "!";
0126 
0127     if (ignoreVersionMismatch_) {
0128       edm::LogWarning(errMsg + " (will continue because ignoreVersionMismatch is set)");
0129     } else {
0130       throw cond::Exception(errMsg);
0131     }
0132   }
0133 }
0134 
0135 L1MuGMTParametersOnlineProducer::L1MuGMTParametersOnlineProducer(const edm::ParameterSet& ps)
0136     : L1ConfigOnlineProdBase<L1MuGMTParametersRcd, L1MuGMTParameters>(ps) {
0137   ignoreVersionMismatch_ = ps.getParameter<bool>("ignoreVersionMismatch");
0138 }
0139 
0140 L1MuGMTParametersOnlineProducer::~L1MuGMTParametersOnlineProducer() {}
0141 
0142 DEFINE_FWK_EVENTSETUP_MODULE(L1MuGMTParametersOnlineProducer);