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 // $Date: 2008/11/24 18:59:59 $
8 // $Revision: 1.1 $
9 //
10 // Author :
11 // W. Sun (copied from L1MuTriggerScalesProducer)
12 //
13 //--------------------------------------------------
15 
16 // #define DEBUG_PT_SCALE
17 #ifdef DEBUG_PT_SCALE
18 #include <iostream>
19 #endif
20 
21 #include <sstream>
22 
23 using namespace std;
24 
27  m_signedPacking(ps.getParameter<bool>("signedPackingPt")),
28  m_nbitsPacking(ps.getParameter<int>("nbitPackingPt")),
29  m_nBins(ps.getParameter<int>("nbinsPt"))
30 {
31 }
32 
34 
35 
36 //
37 // member functions
38 //
39 
40 // ------------ method called to produce the data ------------
41 boost::shared_ptr<L1MuTriggerPtScale>
43 {
44  using namespace edm::es;
45 
46  // find Pt key from main scales key
47  l1t::OMDSReader::QueryResults keysRecord =
49  // SELECTed columns
50  "SC_MUON_PT_FK",
51  // schema name
52  "CMS_GT",
53  // table name
54  "L1T_SCALES",
55  // WHERE lhs
56  "L1T_SCALES.ID",
57  // WHERE rhs
58  m_omdsReader.singleAttribute( objectKey ) );
59 
60  if( keysRecord.numberRows() != 1 ) // check if query was successful
61  {
62  throw cond::Exception("Problem finding L1MuTriggerScales associated "
63  "with scales key " + objectKey);
64  }
65 
66 
67  /*
68 SQL> describe cms_gt.l1t_scale_muon_pt;
69  Name Null? Type
70  ----------------------------------------- -------- ----------------------------
71  ID NOT NULL VARCHAR2(300)
72  PT_GEV_BIN_LOW_0 NUMBER
73  [...]
74  PT_GEV_BIN_LOW_32 NUMBER
75  */
76 
77  ScaleRecordHelper h("PT_GEV_BIN_LOW", m_nBins );
78 
79  vector<string> columns;
80  h.pushColumnNames(columns);
81 
82  l1t::OMDSReader::QueryResults resultRecord =
84  // SELECTed columns
85  columns,
86  // schema name
87  "CMS_GT",
88  // table name
89  "L1T_SCALE_MUON_PT",
90  // WHERE lhs
91  "L1T_SCALE_MUON_PT.ID",
92  // WHERE rhs
93  keysRecord);
94 
95  if(resultRecord.numberRows() != 1) {
96  throw cond::Exception("Couldn't find Pt scale record for scales key `"
97  + objectKey + "'") ;
98  }
99 
100  vector<double> scales;
101  h.extractScales(resultRecord, scales);
102 
103  boost::shared_ptr<L1MuTriggerPtScale> result( new L1MuTriggerPtScale(m_nbitsPacking, m_signedPacking, m_nBins, scales) );
104 
105 #ifdef DEBUG_PT_SCALE
106  cout << "PT scale:" << endl << result->getPtScale()->print() << endl;
107 #endif
108 
109 
110  return result ;
111 }
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:295
tuple result
Definition: query.py:137
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="") const
Definition: OMDSReader.cc:87
L1MuTriggerPtScaleOnlineProducer(const edm::ParameterSet &)
void pushColumnNames(std::vector< std::string > &columns)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
boost::shared_ptr< L1MuTriggerPtScale > newObject(const std::string &objectKey)
void extractScales(l1t::OMDSReader::QueryResults &record, std::vector< double > &destScales)
tuple cout
Definition: gather_cfg.py:121