CMS 3D CMS Logo

L1MuTriggerPtScaleOnlineProducer.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // \class L1MuTriggerPtScaleOnlineProducer
4 //
5 // Description: A class to produce the L1 mu emulator scales record in the event setup
6 //
7 //
8 // Author :
9 // W. Sun (copied from L1MuTriggerScalesProducer)
10 //
11 //--------------------------------------------------
13 
14 // #define DEBUG_PT_SCALE
15 #ifdef DEBUG_PT_SCALE
16 #include <iostream>
17 #endif
18 
19 #include <sstream>
20 
21 using namespace std;
22 
25  m_signedPacking(ps.getParameter<bool>("signedPackingPt")),
26  m_nbitsPacking(ps.getParameter<int>("nbitPackingPt")),
27  m_nBins(ps.getParameter<int>("nbinsPt")) {}
28 
30 
31 //
32 // member functions
33 //
34 
35 // ------------ method called to produce the data ------------
36 std::unique_ptr<L1MuTriggerPtScale> L1MuTriggerPtScaleOnlineProducer::newObject(const std::string& objectKey) {
37  // find Pt key from main scales key
39  // SELECTed columns
40  "SC_MUON_PT_FK",
41  // schema name
42  "CMS_GT",
43  // table name
44  "L1T_SCALES",
45  // WHERE lhs
46  "L1T_SCALES.ID",
47  // WHERE rhs
49 
50  if (keysRecord.numberRows() != 1) // check if query was successful
51  {
52  throw cond::Exception(
53  "Problem finding L1MuTriggerScales associated "
54  "with scales key " +
55  objectKey);
56  }
57 
58  /*
59 SQL> describe cms_gt.l1t_scale_muon_pt;
60  Name Null? Type
61  ----------------------------------------- -------- ----------------------------
62  ID NOT NULL VARCHAR2(300)
63  PT_GEV_BIN_LOW_0 NUMBER
64  [...]
65  PT_GEV_BIN_LOW_32 NUMBER
66  */
67 
68  ScaleRecordHelper h("PT_GEV_BIN_LOW", m_nBins);
69 
70  vector<string> columns;
71  h.pushColumnNames(columns);
72 
74  // SELECTed columns
75  columns,
76  // schema name
77  "CMS_GT",
78  // table name
79  "L1T_SCALE_MUON_PT",
80  // WHERE lhs
81  "L1T_SCALE_MUON_PT.ID",
82  // WHERE rhs
83  keysRecord);
84 
85  if (resultRecord.numberRows() != 1) {
86  throw cond::Exception("Couldn't find Pt scale record for scales key `" + objectKey + "'");
87  }
88 
89  vector<double> scales;
90  h.extractScales(resultRecord, scales);
91 
92  auto result = std::make_unique<L1MuTriggerPtScale>(m_nbitsPacking, m_signedPacking, m_nBins, scales);
93 
94 #ifdef DEBUG_PT_SCALE
95  cout << "PT scale:" << endl << result->getPtScale()->print() << endl;
96 #endif
97 
98  return result;
99 }
persistency::Exception Exception
Definition: Exception.h:25
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:259
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
L1MuTriggerPtScaleOnlineProducer(const edm::ParameterSet &)
std::unique_ptr< L1MuTriggerPtScale > newObject(const std::string &objectKey) override
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4