CMS 3D CMS Logo

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 )
35 {
37 
38  // Copy data members from L1MuGMTParameters,
39  // and M-x replace-regexp RET .*m_\([a-z:_]*\) RET ADD_FIELD(helper, L1MuGMTParameters, \1) RET
40 
41  ADD_FIELD(helper, L1MuGMTParameters, EtaWeight_barrel);
42  ADD_FIELD(helper, L1MuGMTParameters, PhiWeight_barrel);
43  ADD_FIELD(helper, L1MuGMTParameters, EtaPhiThreshold_barrel);
44  ADD_FIELD(helper, L1MuGMTParameters, EtaWeight_endcap);
45  ADD_FIELD(helper, L1MuGMTParameters, PhiWeight_endcap);
46  ADD_FIELD(helper, L1MuGMTParameters, EtaPhiThreshold_endcap);
47  ADD_FIELD(helper, L1MuGMTParameters, EtaWeight_COU);
48  ADD_FIELD(helper, L1MuGMTParameters, PhiWeight_COU);
49  ADD_FIELD(helper, L1MuGMTParameters, EtaPhiThreshold_COU);
50  ADD_FIELD(helper, L1MuGMTParameters, CaloTrigger);
51  ADD_FIELD(helper, L1MuGMTParameters, IsolationCellSizeEta);
52  ADD_FIELD(helper, L1MuGMTParameters, IsolationCellSizePhi);
53  ADD_FIELD(helper, L1MuGMTParameters, DoOvlRpcAnd);
54  ADD_FIELD(helper, L1MuGMTParameters, PropagatePhi);
55  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodPhiBrl);
56  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodPhiFwd);
57  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodEtaBrl);
58  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodEtaFwd);
59  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodPtBrl);
60  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodPtFwd);
61  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodChargeBrl);
62  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodChargeFwd);
63  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodMIPBrl);
64  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodMIPFwd);
65  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodMIPSpecialUseANDBrl);
66  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodMIPSpecialUseANDFwd);
67  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodISOBrl);
68  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodISOFwd);
69  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodISOSpecialUseANDBrl);
70  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodISOSpecialUseANDFwd);
71  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodSRKBrl);
72  ADD_FIELD(helper, L1MuGMTParameters, MergeMethodSRKFwd);
73  ADD_FIELD(helper, L1MuGMTParameters, HaloOverwritesMatchedBrl);
74  ADD_FIELD(helper, L1MuGMTParameters, HaloOverwritesMatchedFwd);
75  ADD_FIELD(helper, L1MuGMTParameters, SortRankOffsetBrl);
76  ADD_FIELD(helper, L1MuGMTParameters, SortRankOffsetFwd);
77  ADD_FIELD(helper, L1MuGMTParameters, CDLConfigWordDTCSC);
78  ADD_FIELD(helper, L1MuGMTParameters, CDLConfigWordCSCDT);
79  ADD_FIELD(helper, L1MuGMTParameters, CDLConfigWordbRPCCSC);
80  ADD_FIELD(helper, L1MuGMTParameters, CDLConfigWordfRPCDT);
81  ADD_FIELD(helper, L1MuGMTParameters, VersionSortRankEtaQLUT);
82  ADD_FIELD(helper, L1MuGMTParameters, VersionLUTs);
83 
84  auto ptrResult = std::make_unique<L1MuGMTParameters>();
85 
86  std::vector<std::string> resultColumns = helper.getColumnList();
87  resultColumns.push_back("CMSSW_VERSION");
88 
89  l1t::OMDSReader::QueryResults resultLines =
90  m_omdsReader.basicQuery(
91  // SELECTed columns
92  resultColumns,
93  // schema name
94  "CMS_GMT",
95  // table name
96  "GMT_SOFTWARE_CONFIG",
97  // WHERE lhs
98  "GMT_SOFTWARE_CONFIG.KEY",
99  // WHERE rhs
100  m_omdsReader.singleAttribute(objectKey) );
101 
102  if(resultLines.numberRows() == 1) {
103  const AttributeList& resultRecord = resultLines.attributeLists().front();
104  checkCMSSWVersion(resultRecord);
105  helper.extractRecord(resultRecord, *ptrResult);
106  return ptrResult;
107  }
108 
109  throw cond::Exception("Couldn't find GMT_SOFTWARE_CONFIG record for GMT key `" + objectKey + "'") ;
110 }
111 
112 void L1MuGMTParametersOnlineProducer::checkCMSSWVersion(const coral::AttributeList& configRecord)
113 {
114  const coral::Attribute& version = configRecord["CMSSW_VERSION"];
115 
116  /* If the DB field is unset, take any. */
117  if(version.isNull()) {
118  edm::LogInfo("No CMSSW version set in database, accepting " PROJECT_VERSION);
119  return;
120  }
121 
122  /* Else make sure we have the correct version. */
123  const std::string& versionString = version.data<string>();
124 
125  /* PROJECT_VERSION is passed as a -D #define from scramv1 (eg CMSSW_2_1_0) */
126  if(versionString != PROJECT_VERSION) {
127  std::string errMsg = "CMSSW version mismatch: Configuration requires " +
128  versionString + ", but this is " + PROJECT_VERSION + "!";
129 
130  if(ignoreVersionMismatch_) {
131  edm::LogWarning(errMsg + " (will continue because ignoreVersionMismatch is set)");
132  } else {
133  throw cond::Exception(errMsg);
134  }
135  }
136 }
137 
140 {
141  ignoreVersionMismatch_ = ps.getParameter<bool>("ignoreVersionMismatch");
142 }
143 
144 
146 
persistency::Exception Exception
Definition: Exception.h:25
T getParameter(std::string const &) const
virtual void extractRecord(const AttributeList &source, TOutput &dest)
Definition: RecordHelper.h:168
Definition: helper.py:1
#define RH_ASSIGN_GROUP(TOutput, TGroup)
Definition: RecordHelper.h:129
const std::vector< coral::AttributeList > & attributeLists() const
Definition: OMDSReader.h:64
#define ADD_FIELD(HELPER, OUTPUT_NAME, FIELD_NAME)
Definition: RecordHelper.h:200
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
L1MuGMTParametersOnlineProducer(const edm::ParameterSet &)
virtual std::vector< std::string > getColumnList()
Definition: RecordHelper.h:176
void checkCMSSWVersion(const coral::AttributeList &configRecord)