CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 boost::shared_ptr<L1MuTriggerPtScale>
41 {
42  using namespace edm::es;
43 
44  // find Pt key from main scales key
45  l1t::OMDSReader::QueryResults keysRecord =
47  // SELECTed columns
48  "SC_MUON_PT_FK",
49  // schema name
50  "CMS_GT",
51  // table name
52  "L1T_SCALES",
53  // WHERE lhs
54  "L1T_SCALES.ID",
55  // WHERE rhs
56  m_omdsReader.singleAttribute( objectKey ) );
57 
58  if( keysRecord.numberRows() != 1 ) // check if query was successful
59  {
60  throw cond::Exception("Problem finding L1MuTriggerScales associated "
61  "with scales key " + objectKey);
62  }
63 
64 
65  /*
66 SQL> describe cms_gt.l1t_scale_muon_pt;
67  Name Null? Type
68  ----------------------------------------- -------- ----------------------------
69  ID NOT NULL VARCHAR2(300)
70  PT_GEV_BIN_LOW_0 NUMBER
71  [...]
72  PT_GEV_BIN_LOW_32 NUMBER
73  */
74 
75  ScaleRecordHelper h("PT_GEV_BIN_LOW", m_nBins );
76 
77  vector<string> columns;
79 
80  l1t::OMDSReader::QueryResults resultRecord =
82  // SELECTed columns
83  columns,
84  // schema name
85  "CMS_GT",
86  // table name
87  "L1T_SCALE_MUON_PT",
88  // WHERE lhs
89  "L1T_SCALE_MUON_PT.ID",
90  // WHERE rhs
91  keysRecord);
92 
93  if(resultRecord.numberRows() != 1) {
94  throw cond::Exception("Couldn't find Pt scale record for scales key `"
95  + objectKey + "'") ;
96  }
97 
98  vector<double> scales;
99  h.extractScales(resultRecord, scales);
100 
101  boost::shared_ptr<L1MuTriggerPtScale> result( new L1MuTriggerPtScale(m_nbitsPacking, m_signedPacking, m_nBins, scales) );
102 
103 #ifdef DEBUG_PT_SCALE
104  cout << "PT scale:" << endl << result->getPtScale()->print() << endl;
105 #endif
106 
107 
108  return result ;
109 }
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:296
tuple result
Definition: mps_fire.py:83
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)
boost::shared_ptr< L1MuTriggerPtScale > newObject(const std::string &objectKey)
void extractScales(l1t::OMDSReader::QueryResults &record, std::vector< double > &destScales)
tuple columns
Definition: mps_check.py:210
tuple cout
Definition: gather_cfg.py:145