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 {
29 }
30 
32 
33 
34 //
35 // member functions
36 //
37 
38 // ------------ method called to produce the data ------------
39 std::unique_ptr<L1MuTriggerPtScale>
41 {
42  // find Pt key from main scales key
43  l1t::OMDSReader::QueryResults keysRecord =
45  // SELECTed columns
46  "SC_MUON_PT_FK",
47  // schema name
48  "CMS_GT",
49  // table name
50  "L1T_SCALES",
51  // WHERE lhs
52  "L1T_SCALES.ID",
53  // WHERE rhs
54  m_omdsReader.singleAttribute( objectKey ) );
55 
56  if( keysRecord.numberRows() != 1 ) // check if query was successful
57  {
58  throw cond::Exception("Problem finding L1MuTriggerScales associated "
59  "with scales key " + objectKey);
60  }
61 
62 
63  /*
64 SQL> describe cms_gt.l1t_scale_muon_pt;
65  Name Null? Type
66  ----------------------------------------- -------- ----------------------------
67  ID NOT NULL VARCHAR2(300)
68  PT_GEV_BIN_LOW_0 NUMBER
69  [...]
70  PT_GEV_BIN_LOW_32 NUMBER
71  */
72 
73  ScaleRecordHelper h("PT_GEV_BIN_LOW", m_nBins );
74 
75  vector<string> columns;
76  h.pushColumnNames(columns);
77 
78  l1t::OMDSReader::QueryResults resultRecord =
80  // SELECTed columns
81  columns,
82  // schema name
83  "CMS_GT",
84  // table name
85  "L1T_SCALE_MUON_PT",
86  // WHERE lhs
87  "L1T_SCALE_MUON_PT.ID",
88  // WHERE rhs
89  keysRecord);
90 
91  if(resultRecord.numberRows() != 1) {
92  throw cond::Exception("Couldn't find Pt scale record for scales key `"
93  + objectKey + "'") ;
94  }
95 
96  vector<double> scales;
97  h.extractScales(resultRecord, scales);
98 
99  auto result = std::make_unique<L1MuTriggerPtScale>(m_nbitsPacking, m_signedPacking, m_nBins, scales);
100 
101 #ifdef DEBUG_PT_SCALE
102  cout << "PT scale:" << endl << result->getPtScale()->print() << endl;
103 #endif
104 
105 
106  return result ;
107 }
persistency::Exception Exception
Definition: Exception.h:25
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:295
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:86
L1MuTriggerPtScaleOnlineProducer(const edm::ParameterSet &)
void pushColumnNames(std::vector< std::string > &columns)
void extractScales(l1t::OMDSReader::QueryResults &record, std::vector< double > &destScales)
std::unique_ptr< L1MuTriggerPtScale > newObject(const std::string &objectKey) override