CMS 3D CMS Logo

L1HfRingEtScaleOnlineProd.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1HfRingEtScaleOnlineProd
4 // Class: L1HfRingEtScaleOnlineProd
5 //
13 //
14 // Original Author: Werner Man-Li Sun
15 // Created: Tue Sep 16 22:43:22 CEST 2008
16 //
17 //
18 
19 
20 // system include files
21 
22 // user include files
24 
27 
28 
29 //
30 // class declaration
31 //
32 
34  public L1ConfigOnlineProdBase< L1HfRingEtScaleRcd, L1CaloEtScale > {
35  public:
37  ~L1HfRingEtScaleOnlineProd() override;
38 
39  std::unique_ptr< L1CaloEtScale > newObject(
40  const std::string& objectKey ) override ;
41 
42 
43  private:
44  // ----------member data ---------------------------
45 };
46 
47 //
48 // constants, enums and typedefs
49 //
50 
51 //
52 // static data member definitions
53 //
54 
55 //
56 // constructors and destructor
57 //
59  const edm::ParameterSet& iConfig)
61 {
62  //the following line is needed to tell the framework what
63  // data is being produced
64 
65  //now do what ever other initialization is needed
66 }
67 
68 
70 {
71 
72  // do anything here that needs to be done at desctruction time
73  // (e.g. close files, deallocate resources etc.)
74 
75 }
76 
77 std::unique_ptr< L1CaloEtScale >
79 {
80  // get scales keys
81  l1t::OMDSReader::QueryResults scalesKeyResults =
83  "GCT_SCALES_KEY",
84  "CMS_GCT",
85  "GCT_PHYS_PARAMS",
86  "GCT_PHYS_PARAMS.CONFIG_KEY",
87  m_omdsReader.singleAttribute( objectKey ) );
88 
89  std::string scalesKey ;
90 
91  if( scalesKeyResults.queryFailed() ) {
92  edm::LogError("L1-O2O")
93  << "Problem with key for L1JetEtScaleRcd : GCT scales key query failed ";
94  }
95  else if( scalesKeyResults.numberRows() != 1 ) {
96  edm::LogError("L1-O2O")
97  << "Problem with key for L1JetEtScaleRcd : "
98  << (scalesKeyResults.numberRows()) << " rows were returned when getting GCT scales key";
99  }
100  else {
101  scalesKeyResults.fillVariable( scalesKey );
102  }
103 
104 
105  // get ring scale key
106  l1t::OMDSReader::QueryResults hfRingScaleKeyResults =
108  "SC_HF_ET_SUM_FK",
109  "CMS_GT",
110  "L1T_SCALES",
111  "L1T_SCALES.ID",
112  scalesKeyResults );
113 
114  std::string hfRingScaleKey ;
115 
116  if( hfRingScaleKeyResults.queryFailed() ) {
117  edm::LogError("L1-O2O")
118  << "Problem with key for L1HfRingEtScaleRcd : HF ring Et scale key query failed ";
119  }
120  else if( hfRingScaleKeyResults.numberRows() != 1 ) {
121  edm::LogError("L1-O2O")
122  << "Problem with key for L1HfRingEtScaleRcd : "
123  << (hfRingScaleKeyResults.numberRows()) << " rows were returned when getting HF ring Et scale key";
124  }
125  else {
126  hfRingScaleKeyResults.fillVariable( hfRingScaleKey ) ;
127  }
128 
129  // get thresholds
130  std::vector< std::string > queryStrings ;
131  queryStrings.push_back( "E_GEV_BIN_LOW_0");
132  queryStrings.push_back( "E_GEV_BIN_LOW_1");
133  queryStrings.push_back( "E_GEV_BIN_LOW_2");
134  queryStrings.push_back( "E_GEV_BIN_LOW_3");
135  queryStrings.push_back( "E_GEV_BIN_LOW_4");
136  queryStrings.push_back( "E_GEV_BIN_LOW_5");
137  queryStrings.push_back( "E_GEV_BIN_LOW_6");
138  queryStrings.push_back( "E_GEV_BIN_LOW_7");
139 
140  l1t::OMDSReader::QueryResults scaleResults =
141  m_omdsReader.basicQuery( queryStrings,
142  "CMS_GT",
143  "L1T_SCALE_HF_ET_SUM",
144  "L1T_SCALE_HF_ET_SUM.ID",
145  hfRingScaleKeyResults
146  );
147 
148  std::vector<double> thresholds;
149 
150  if( scaleResults.queryFailed() ) {
151  edm::LogError( "L1-O2O" ) << "Problem with L1HfRingEtScale key : scale query failed." ;
152  }
153  else if ( scaleResults.numberRows() != 1 ) {
154  edm::LogError( "L1-O2O" ) << "Problem with L1HfRingEtScale key : scale query failed." ;
155  }
156  else {
157  for( std::vector< std::string >::iterator thresh = queryStrings.begin();
158  thresh != queryStrings.end(); ++thresh) {
159  float tempScale = 0.;
160  scaleResults.fillVariable(*thresh,tempScale);
161  thresholds.push_back(tempScale);
162  }
163  }
164 
165  // get region LSB
166  double rgnEtLsb=0.;
167 
168  l1t::OMDSReader::QueryResults lsbResults =
169  m_omdsReader.basicQuery( "GCT_RGN_ET_LSB",
170  "CMS_GCT",
171  "GCT_PHYS_PARAMS",
172  "GCT_PHYS_PARAMS.CONFIG_KEY",
173  m_omdsReader.singleAttribute( objectKey ) ) ;
174 
175  if( lsbResults.queryFailed() ) {
176  edm::LogError( "L1-O2O" ) << "Problem with L1JetEtScale key." ;
177  }
178  else {
179  lsbResults.fillVariable( "GCT_RGN_ET_LSB", rgnEtLsb );
180  }
181 
182  //~~~~~~~~~ Instantiate new L1HfRingEtScale object. ~~~~~~~~~
183  return std::make_unique<L1CaloEtScale>(0xff, 0x7, rgnEtLsb, thresholds);
184 }
185 
186 
187 // ------------ method called to produce the data ------------
188 
189 
190 //define this as a plug-in
L1HfRingEtScaleOnlineProd(const edm::ParameterSet &)
bool fillVariable(const std::string &columnName, T &outputVariable) const
Definition: OMDSReader.h:311
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
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
std::unique_ptr< L1CaloEtScale > newObject(const std::string &objectKey) override