CMS 3D CMS Logo

L1MuTriggerScalesOnlineProducer.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // \class L1MuTriggerScalesOnlineProducer
4 //
5 // Description: A class to produce the L1 mu emulator scales record in the event setup
6 // from the OMDS database.
7 //
8 //
9 // Author :
10 // Thomas Themel
11 //
12 //--------------------------------------------------
15 #include <cmath>
16 
17 using namespace std;
18 
21  m_scales(ps.getParameter<int>("nbitPackingDTEta"),
22  ps.getParameter<bool>("signedPackingDTEta"),
23  ps.getParameter<int>("nbinsDTEta"),
24  ps.getParameter<double>("minDTEta"),
25  ps.getParameter<double>("maxDTEta"),
26  ps.getParameter<int>("offsetDTEta"),
27 
28  ps.getParameter<int>("nbitPackingCSCEta"),
29  ps.getParameter<int>("nbinsCSCEta"),
30  ps.getParameter<double>("minCSCEta"),
31  ps.getParameter<double>("maxCSCEta"),
32 
33  ps.getParameter<std::vector<double> >("scaleRPCEta"),
34  ps.getParameter<int>("nbitPackingBrlRPCEta"),
35  ps.getParameter<bool>("signedPackingBrlRPCEta"),
36  ps.getParameter<int>("nbinsBrlRPCEta"),
37  ps.getParameter<int>("offsetBrlRPCEta"),
38  ps.getParameter<int>("nbitPackingFwdRPCEta"),
39  ps.getParameter<bool>("signedPackingFwdRPCEta"),
40  ps.getParameter<int>("nbinsFwdRPCEta"),
41  ps.getParameter<int>("offsetFwdRPCEta"),
42  // Fields that should now be generated from OMDS:
43  // TODO: Adjust m_scales's definition to be a bit
44  // more accessible for the partial initialization.
45  //ps.getParameter<int>("nbitPackingGMTEta"),
46  0,
47  //ps.getParameter<int>("nbinsGMTEta"),
48  0,
49  //ps.getParameter<std::vector<double> >("scaleGMTEta"),
50  std::vector<double>(1),
51  //ps.getParameter<int>("nbitPackingPhi"),
52  0,
53  //ps.getParameter<bool>("signedPackingPhi"),
54  false,
55  //ps.getParameter<int>("nbinsPhi"),
56  0,
57  //ps.getParameter<double>("minPhi"),
58  0,
59  //ps.getParameter<double>("maxPhi")
60  0),
61  /* Metadata that's not yet in the database. */
62  m_nbitPackingPhi(ps.getParameter<int>("nbitPackingPhi")),
63  m_nbitPackingEta(ps.getParameter<int>("nbitPackingGMTEta")),
64  m_nbinsEta(ps.getParameter<int>("nbinsGMTEta")),
65  m_signedPackingPhi(ps.getParameter<bool>("signedPackingPhi")) {}
66 
68 
69 //
70 // member functions
71 //
72 
74 public:
75  static L1MuBinnedScale* makeBinnedScale(l1t::OMDSReader::QueryResults& record, int nBits, bool signedPacking) {
76  short nbins = 0;
77  record.fillVariable(BinsColumn, nbins);
78  float lowMark = 0.;
79  record.fillVariable(LowMarkColumn, lowMark);
80  float step = 0.;
81  record.fillVariable(StepColumn, step);
82 
83  return new L1MuBinnedScale(nBits, signedPacking, nbins, deg2rad(lowMark), deg2rad(lowMark + nbins * step));
84  }
85 
86  static void pushColumnNames(vector<string>& columns) {
87  columns.push_back(BinsColumn);
88  columns.push_back(LowMarkColumn);
89  columns.push_back(StepColumn);
90  }
91 
92  static double deg2rad(double deg) { return deg * M_PI / 180.0; }
93  static double rad2deg(double rad) { return rad / M_PI * 180.0; }
94 
95  static const string BinsColumn;
96  static const string LowMarkColumn;
97  static const string StepColumn;
98 };
99 
100 const string PhiScaleHelper::BinsColumn = "PHI_BINS";
101 const string PhiScaleHelper::LowMarkColumn = "PHI_DEG_BIN_LOW_0";
102 const string PhiScaleHelper::StepColumn = "PHI_DEG_BIN_STEP";
103 
104 // ------------ method called to produce the data ------------
105 std::unique_ptr<L1MuTriggerScales> L1MuTriggerScalesOnlineProducer::newObject(const std::string& objectKey) {
106  // The key we get from the O2O subsystem is the CMS_GMT.L1T_SCALES key,
107  // but the eta/phi scales have their own subtables, so let's find
108  // out.
109  vector<string> foreignKeys;
110 
111  const std::string etaKeyColumn("SC_MUON_ETA_FK");
112  const std::string phiKeyColumn("SC_MUON_PHI_FK");
113 
114  foreignKeys.push_back(etaKeyColumn);
115  foreignKeys.push_back(phiKeyColumn);
116 
118  // SELECTed columns
119  foreignKeys,
120  // schema name
121  "CMS_GT",
122  // table name
123  "L1T_SCALES",
124  // WHERE lhs
125  "L1T_SCALES.ID",
126  // WHERE rhs
127  m_omdsReader.singleAttribute(objectKey));
128 
129  if (keysRecord.numberRows() != 1) // check if query was successful
130  {
131  throw cond::Exception(
132  "Problem finding L1MuTriggerScales associated "
133  "with scales key `" +
134  objectKey + "'");
135  }
136 
137  std::string etaKeyValue;
138  std::string phiKeyValue;
139  keysRecord.fillVariable(etaKeyColumn, etaKeyValue);
140  keysRecord.fillVariable(phiKeyColumn, phiKeyValue);
141 
142  vector<string> columns;
143 
144  // get the eta scales from the database
145  ScaleRecordHelper etaHelper("ETA_BIN_LOW", m_nbinsEta);
146  etaHelper.pushColumnNames(columns);
147 
149  // SELECTed columns
150  columns,
151  // schema name
152  "CMS_GT",
153  // table name
154  "L1T_SCALE_MUON_ETA",
155  // WHERE lhs
156  "L1T_SCALE_MUON_ETA.ID",
157  // WHERE rhs
158  m_omdsReader.singleAttribute(etaKeyValue));
159 
160  vector<double> etaScales;
161  etaHelper.extractScales(etaRecord, etaScales);
162 
163  unique_ptr<L1MuSymmetricBinnedScale> ptrEtaScale(
165  m_scales.setGMTEtaScale(*ptrEtaScale);
166 
167  columns.clear();
168 
169  // get the phi scales from the database
170  PhiScaleHelper phiHelper;
171 
173  // SELECTed columns
174  columns,
175  // schema name
176  "CMS_GT",
177  // table name
178  "L1T_SCALE_MUON_PHI",
179  // WHERE lhs
180  "L1T_SCALE_MUON_PHI.ID",
181  // WHERE rhs
182  m_omdsReader.singleAttribute(phiKeyValue));
183 
184  unique_ptr<L1MuBinnedScale> ptrPhiScale(phiHelper.makeBinnedScale(phiRecord, m_nbitPackingPhi, m_signedPackingPhi));
185 
186  m_scales.setPhiScale(*ptrPhiScale);
187 
188  return std::make_unique<L1MuTriggerScales>(m_scales);
189 }
l1t::OMDSReader::QueryResults
Definition: OMDSReader.h:49
PhiScaleHelper::makeBinnedScale
static L1MuBinnedScale * makeBinnedScale(l1t::OMDSReader::QueryResults &record, int nBits, bool signedPacking)
Definition: L1MuTriggerScalesOnlineProducer.cc:75
electrons_cff.bool
bool
Definition: electrons_cff.py:393
L1MuTriggerScalesOnlineProducer::~L1MuTriggerScalesOnlineProducer
~L1MuTriggerScalesOnlineProducer() override
Definition: L1MuTriggerScalesOnlineProducer.cc:67
funct::false
false
Definition: Factorize.h:29
step
step
Definition: StallMonitor.cc:94
L1ConfigOnlineProdBase< L1MuTriggerScalesRcd, L1MuTriggerScales >::m_omdsReader
l1t::OMDSReader m_omdsReader
Definition: L1ConfigOnlineProdBase.h:65
PhiScaleHelper::LowMarkColumn
static const string LowMarkColumn
Definition: L1MuTriggerScalesOnlineProducer.cc:96
L1MuTriggerScalesOnlineProducer::m_scales
L1MuTriggerScales m_scales
Definition: L1MuTriggerScalesOnlineProducer.h:43
L1MuTriggerScales::setGMTEtaScale
void setGMTEtaScale(const L1MuSymmetricBinnedScale &scale)
set the GMT eta scale
Definition: L1MuTriggerScales.h:172
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
PhiScaleHelper::BinsColumn
static const string BinsColumn
Definition: L1MuTriggerScalesOnlineProducer.cc:95
L1MuTriggerScalesOnlineProducer.h
l1t::OMDSReader::singleAttribute
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:259
L1ConfigOnlineProdBase
Definition: L1ConfigOnlineProdBase.h:52
PhiScaleHelper::pushColumnNames
static void pushColumnNames(vector< string > &columns)
Definition: L1MuTriggerScalesOnlineProducer.cc:86
L1MuTriggerScalesOnlineProducer::L1MuTriggerScalesOnlineProducer
L1MuTriggerScalesOnlineProducer(const edm::ParameterSet &)
Definition: L1MuTriggerScalesOnlineProducer.cc:19
L1MuTriggerScalesOnlineProducer::m_nbitPackingEta
unsigned int m_nbitPackingEta
Definition: L1MuTriggerScalesOnlineProducer.h:45
l1t::OMDSReader::QueryResults::fillVariable
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:274
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
ScaleRecordHelper
Definition: ScaleRecordHelper.h:21
L1MuTriggerScales::setPhiScale
void setPhiScale(const L1MuBinnedScale &scale)
set the phi scale
Definition: L1MuTriggerScales.h:178
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L1MuTriggerScalesOnlineProducer::m_nbitPackingPhi
unsigned int m_nbitPackingPhi
Definition: L1MuTriggerScalesOnlineProducer.h:44
edm::ParameterSet
Definition: ParameterSet.h:47
L1MuTriggerScalesOnlineProducer::m_signedPackingPhi
bool m_signedPackingPhi
Definition: L1MuTriggerScalesOnlineProducer.h:47
L1MuTriggerScalesOnlineProducer::newObject
std::unique_ptr< L1MuTriggerScales > newObject(const std::string &objectKey) override
Definition: L1MuTriggerScalesOnlineProducer.cc:105
createfilelist.int
int
Definition: createfilelist.py:10
PhiScaleHelper::rad2deg
static double rad2deg(double rad)
Definition: L1MuTriggerScalesOnlineProducer.cc:93
l1t::OMDSReader::QueryResults::numberRows
int numberRows() const
Definition: OMDSReader.h:60
cond::Exception
persistency::Exception Exception
Definition: Exception.h:25
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
PhiScaleHelper
Definition: L1MuTriggerScalesOnlineProducer.cc:73
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
l1t::OMDSReader::basicQuery
const QueryResults basicQuery(const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &tableName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="")
Definition: OMDSReader.cc:75
L1MuTriggerScales
Definition: L1MuTriggerScales.h:33
L1MuBinnedScale
Definition: L1MuScale.h:93
L1MuTriggerScalesRcd
Definition: L1MuTriggerScalesRcd.h:12
L1MuTriggerScalesOnlineProducer::m_nbinsEta
unsigned int m_nbinsEta
Definition: L1MuTriggerScalesOnlineProducer.h:46
L1MuSymmetricBinnedScale
Definition: L1MuScale.h:236
std
Definition: JetResolutionObject.h:76
mps_check.columns
columns
Definition: mps_check.py:244
ScaleRecordHelper::pushColumnNames
void pushColumnNames(std::vector< std::string > &columns)
Definition: ScaleRecordHelper.cc:26
ScaleRecordHelper::extractScales
void extractScales(l1t::OMDSReader::QueryResults &record, std::vector< double > &destScales)
Definition: ScaleRecordHelper.cc:11
PhiScaleHelper::StepColumn
static const string StepColumn
Definition: L1MuTriggerScalesOnlineProducer.cc:97
PhiScaleHelper::deg2rad
static double deg2rad(double deg)
Definition: L1MuTriggerScalesOnlineProducer.cc:92
ScaleRecordHelper.h