CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
L1MuGMTParametersOnlineProducer.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // \class L1MuGMTParametersOnlineProducer
4 //
5 // Description: A class to produce the L1 GMT emulator Parameters record in the event setup
6 // by reading them from the online database.
7 //
8 //
9 // Author :
10 // Thomas Themel
11 //
12 //--------------------------------------------------
14 
17 
18 /* Define this to see debug output from the record parsing layer. */
19 //#define RECORDHELPER_DEBUG
20 
24 
25 using namespace std;
26 using coral::AttributeList;
27 
28 RH_ASSIGN_GROUP(L1MuGMTParameters, TGlobalTriggerGroup)
29 
30 
34 std::unique_ptr<L1MuGMTParameters> L1MuGMTParametersOnlineProducer::newObject(const std::string& objectKey) {
36 
37  // Copy data members from L1MuGMTParameters,
38  // and M-x replace-regexp RET .*m_\([a-z:_]*\) RET ADD_FIELD(helper, L1MuGMTParameters, \1) RET
39 
40  ADD_FIELD(helper, L1MuGMTParameters, EtaWeight_barrel);
41  ADD_FIELD(helper, L1MuGMTParameters, PhiWeight_barrel);
42  ADD_FIELD(helper, L1MuGMTParameters, EtaPhiThreshold_barrel);
43  ADD_FIELD(helper, L1MuGMTParameters, EtaWeight_endcap);
44  ADD_FIELD(helper, L1MuGMTParameters, PhiWeight_endcap);
45  ADD_FIELD(helper, L1MuGMTParameters, EtaPhiThreshold_endcap);
46  ADD_FIELD(helper, L1MuGMTParameters, EtaWeight_COU);
47  ADD_FIELD(helper, L1MuGMTParameters, PhiWeight_COU);
48  ADD_FIELD(helper, L1MuGMTParameters, EtaPhiThreshold_COU);
49  ADD_FIELD(helper, L1MuGMTParameters, CaloTrigger);
50  ADD_FIELD(helper, L1MuGMTParameters, IsolationCellSizeEta);
51  ADD_FIELD(helper, L1MuGMTParameters, IsolationCellSizePhi);
52  ADD_FIELD(helper, L1MuGMTParameters, DoOvlRpcAnd);
53  ADD_FIELD(helper, L1MuGMTParameters, PropagatePhi);
54  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodPhiBrl);
55  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodPhiFwd);
56  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodEtaBrl);
57  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodEtaFwd);
58  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodPtBrl);
59  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodPtFwd);
60  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodChargeBrl);
61  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodChargeFwd);
62  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodMIPBrl);
63  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodMIPFwd);
64  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodMIPSpecialUseANDBrl);
65  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodMIPSpecialUseANDFwd);
66  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodISOBrl);
67  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodISOFwd);
68  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodISOSpecialUseANDBrl);
69  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodISOSpecialUseANDFwd);
70  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodSRKBrl);
71  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodSRKFwd);
72  ADD_FIELD(helper, L1MuGMTParameters, HaloOverwritesMatchedBrl);
73  ADD_FIELD(helper, L1MuGMTParameters, HaloOverwritesMatchedFwd);
74  ADD_FIELD(helper, L1MuGMTParameters, SortRankOffsetBrl);
75  ADD_FIELD(helper, L1MuGMTParameters, SortRankOffsetFwd);
76  ADD_FIELD(helper, L1MuGMTParameters, CDLConfigWordDTCSC);
77  ADD_FIELD(helper, L1MuGMTParameters, CDLConfigWordCSCDT);
78  ADD_FIELD(helper, L1MuGMTParameters, CDLConfigWordbRPCCSC);
79  ADD_FIELD(helper, L1MuGMTParameters, CDLConfigWordfRPCDT);
80  ADD_FIELD(helper, L1MuGMTParameters, VersionSortRankEtaQLUT);
81  ADD_FIELD(helper, L1MuGMTParameters, VersionLUTs);
82 
83  auto ptrResult = std::make_unique<L1MuGMTParameters>();
84 
85  std::vector<std::string> resultColumns = helper.getColumnList();
86  resultColumns.push_back("CMSSW_VERSION");
87 
88  l1t::OMDSReader::QueryResults resultLines = m_omdsReader.basicQuery(
89  // SELECTed columns
90  resultColumns,
91  // schema name
92  "CMS_GMT",
93  // table name
94  "GMT_SOFTWARE_CONFIG",
95  // WHERE lhs
96  "GMT_SOFTWARE_CONFIG.KEY",
97  // WHERE rhs
98  m_omdsReader.singleAttribute(objectKey));
99 
100  if (resultLines.numberRows() == 1) {
101  const AttributeList& resultRecord = resultLines.attributeLists().front();
102  checkCMSSWVersion(resultRecord);
103  helper.extractRecord(resultRecord, *ptrResult);
104  return ptrResult;
105  }
106 
107  throw cond::Exception("Couldn't find GMT_SOFTWARE_CONFIG record for GMT key `" + objectKey + "'");
108 }
109 
110 void L1MuGMTParametersOnlineProducer::checkCMSSWVersion(const coral::AttributeList& configRecord) {
111  const coral::Attribute& version = configRecord["CMSSW_VERSION"];
112 
113  /* If the DB field is unset, take any. */
114  if (version.isNull()) {
115  edm::LogInfo("No CMSSW version set in database, accepting " PROJECT_VERSION);
116  return;
117  }
118 
119  /* Else make sure we have the correct version. */
120  const std::string& versionString = version.data<string>();
121 
122  /* PROJECT_VERSION is passed as a -D #define from scramv1 (eg CMSSW_2_1_0) */
123  if (versionString != PROJECT_VERSION) {
124  std::string errMsg =
125  "CMSSW version mismatch: Configuration requires " + versionString + ", but this is " + PROJECT_VERSION + "!";
126 
127  if (ignoreVersionMismatch_) {
128  edm::LogWarning(errMsg + " (will continue because ignoreVersionMismatch is set)");
129  } else {
130  throw cond::Exception(errMsg);
131  }
132  }
133 }
134 
137  ignoreVersionMismatch_ = ps.getParameter<bool>("ignoreVersionMismatch");
138 }
139 
141 
persistency::Exception Exception
Definition: Exception.h:25
virtual void extractRecord(const AttributeList &source, TOutput &dest)
Definition: RecordHelper.h:162
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
const std::vector< coral::AttributeList > & attributeLists() const
Definition: OMDSReader.h:58
#define RH_ASSIGN_GROUP(TOutput, TGroup)
Definition: RecordHelper.h:124
#define ADD_FIELD(HELPER, OUTPUT_NAME, FIELD_NAME)
Definition: RecordHelper.h:192
Log< level::Info, false > LogInfo
L1MuGMTParametersOnlineProducer(const edm::ParameterSet &)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
virtual std::vector< std::string > getColumnList()
Definition: RecordHelper.h:169
Log< level::Warning, false > LogWarning
void checkCMSSWVersion(const coral::AttributeList &configRecord)