CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GctJetFinderParamsOnlineProd.cc
Go to the documentation of this file.
4 
5 class L1GctJetFinderParamsOnlineProd : public L1ConfigOnlineProdBase< L1GctJetFinderParamsRcd, L1GctJetFinderParams > {
6  public:
10 
11  virtual boost::shared_ptr< L1GctJetFinderParams > newObject( const std::string& objectKey ) ;
12  private:
13 };
14 
15 boost::shared_ptr< L1GctJetFinderParams >
16 L1GctJetFinderParamsOnlineProd::newObject( const std::string& objectKey )
17 {
18  // Execute SQL queries to get data from OMDS (using key) and make C++ object
19  // Example: SELECT A_PARAMETER FROM CMS_XXX.XXX_CONF WHERE XXX_CONF.XXX_KEY = objectKey
20 
21  // get parameters
22  std::vector< std::string > columns;
23  columns.push_back( "GCT_RGN_ET_LSB" );
24  columns.push_back( "GCT_HT_LSB" );
25  columns.push_back( "GCT_CJET_SEED_ET_THRESHOLD" );
26  columns.push_back( "GCT_TJET_SEED_ET_THRESHOLD" );
27  columns.push_back( "GCT_FJET_SEED_ET_THRESHOLD" );
28  columns.push_back( "GCT_HT_JET_ET_THRESHOLD" );
29  columns.push_back( "GCT_MHT_JET_ET_THRESHOLD" );
30  columns.push_back( "GCT_TAU_ISO_ET_THRESHOLD" );
31  columns.push_back( "GCT_CEN_JET_ETA_MAX" );
32  columns.push_back( "GCT_JET_CORR_KEY" );
33 
36  columns,
37  "CMS_GCT",
38  "GCT_PHYS_PARAMS",
39  "GCT_PHYS_PARAMS.CONFIG_KEY",
40  m_omdsReader.singleAttribute( objectKey ) ) ;
41 
42  if( results.queryFailed() ) // check if query was successful
43  {
44  edm::LogError( "L1-O2O" ) << "Problem with L1GctJetFinderParams key." ;
45  return boost::shared_ptr< L1GctJetFinderParams >() ;
46  }
47 
48  // fill values
49  double rgnEtLsb=0.;
50  double htLsb=0.;
51  double cJetSeed=0.;
52  double tJetSeed=0.;
53  double fJetSeed=0.;
54  double tauIsoEtThresh=0.;
55  double htJetEtThresh=0.;
56  double mhtJetEtThresh=0.;
57  short int etaBoundary=7;
58  int corrType=0;
59  std::vector< std::vector<double> > jetCorrCoeffs;
60  std::vector< std::vector<double> > tauCorrCoeffs;
61  bool convertToEnergy=false; // Not in OMDS
62  std::vector<double> energyConvCoeffs(11); // Not in OMDS
63  std::string jetCorrKey;
64 
65  results.fillVariable( "GCT_RGN_ET_LSB", rgnEtLsb );
66  results.fillVariable( "GCT_HT_LSB", htLsb );
67  results.fillVariable( "GCT_CJET_SEED_ET_THRESHOLD", cJetSeed );
68  results.fillVariable( "GCT_TJET_SEED_ET_THRESHOLD", tJetSeed );
69  results.fillVariable( "GCT_FJET_SEED_ET_THRESHOLD", fJetSeed );
70  results.fillVariable( "GCT_TAU_ISO_ET_THRESHOLD", tauIsoEtThresh );
71  results.fillVariable( "GCT_HT_JET_ET_THRESHOLD", htJetEtThresh );
72  results.fillVariable( "GCT_MHT_JET_ET_THRESHOLD", mhtJetEtThresh );
73  results.fillVariable( "GCT_CEN_JET_ETA_MAX", etaBoundary );
74  results.fillVariable( "GCT_JET_CORR_KEY", jetCorrKey );
75 
76  edm::LogInfo("L1-O2O") << "L1 jet corrections key : " << jetCorrKey << std::endl;
77 
78  // get jet corr coefficients
79  std::vector< std::string > jetCorrColumns;
80  jetCorrColumns.push_back( "GCT_JETCORR_TYPE" );
81  jetCorrColumns.push_back( "GCT_JETCORR_NETA_10" );
82  jetCorrColumns.push_back( "GCT_JETCORR_NETA_9" );
83  jetCorrColumns.push_back( "GCT_JETCORR_NETA_8" );
84  jetCorrColumns.push_back( "GCT_JETCORR_NETA_7" );
85  jetCorrColumns.push_back( "GCT_JETCORR_NETA_6" );
86  jetCorrColumns.push_back( "GCT_JETCORR_NETA_5" );
87  jetCorrColumns.push_back( "GCT_JETCORR_NETA_4" );
88  jetCorrColumns.push_back( "GCT_JETCORR_NETA_3" );
89  jetCorrColumns.push_back( "GCT_JETCORR_NETA_2" );
90  jetCorrColumns.push_back( "GCT_JETCORR_NETA_1" );
91  jetCorrColumns.push_back( "GCT_JETCORR_NETA_0" );
92  jetCorrColumns.push_back( "GCT_JETCORR_PETA_0" );
93  jetCorrColumns.push_back( "GCT_JETCORR_PETA_1" );
94  jetCorrColumns.push_back( "GCT_JETCORR_PETA_2" );
95  jetCorrColumns.push_back( "GCT_JETCORR_PETA_3" );
96  jetCorrColumns.push_back( "GCT_JETCORR_PETA_4" );
97  jetCorrColumns.push_back( "GCT_JETCORR_PETA_5" );
98  jetCorrColumns.push_back( "GCT_JETCORR_PETA_6" );
99  jetCorrColumns.push_back( "GCT_JETCORR_PETA_7" );
100  jetCorrColumns.push_back( "GCT_JETCORR_PETA_8" );
101  jetCorrColumns.push_back( "GCT_JETCORR_PETA_9" );
102  jetCorrColumns.push_back( "GCT_JETCORR_PETA_10" );
103 
104  l1t::OMDSReader::QueryResults jetCorrResults =
106  jetCorrColumns,
107  "CMS_GCT",
108  "GCT_JET_CORRECTIONS",
109  "GCT_JET_CORRECTIONS.CONFIG_KEY",
110  m_omdsReader.singleAttribute( jetCorrKey ) ) ;
111 
112  if( jetCorrResults.queryFailed() ) // check if query was successful
113  {
114  edm::LogError( "L1-O2O" ) << "Problem getting L1 jet corrections" ;
115  return boost::shared_ptr< L1GctJetFinderParams >() ;
116  }
117 
118  // fill jet corr type
119  jetCorrResults.fillVariable( "GCT_JETCORR_TYPE", corrType );
120 
121  edm::LogInfo("L1-O2O") << "L1 jet corrections type : " << corrType << std::endl;
122 
123  // get coefficients
124  for (unsigned i=0; i < L1GctJetFinderParams::NUMBER_ETA_VALUES; ++i) {
125 
126  // get corr key for eta value
127  std::stringstream etaCol;
128  etaCol << "GCT_JETCORR_NETA_" << std::dec << i;
129  std::string etaKey;
130  jetCorrResults.fillVariable( etaCol.str(), etaKey );
131 
132  std::vector< std::string > coeffColumns;
133  coeffColumns.push_back( "GCT_JETCORR_C0" );
134  coeffColumns.push_back( "GCT_JETCORR_C1" );
135  coeffColumns.push_back( "GCT_JETCORR_C2" );
136  coeffColumns.push_back( "GCT_JETCORR_C3" );
137  coeffColumns.push_back( "GCT_JETCORR_C4" );
138  coeffColumns.push_back( "GCT_JETCORR_C5" );
139  coeffColumns.push_back( "GCT_JETCORR_C6" );
140  coeffColumns.push_back( "GCT_JETCORR_C7" );
141  coeffColumns.push_back( "GCT_JETCORR_C8" );
142  coeffColumns.push_back( "GCT_JETCORR_C9" );
143  coeffColumns.push_back( "GCT_JETCORR_C10" );
144  coeffColumns.push_back( "GCT_JETCORR_C11" );
145  coeffColumns.push_back( "GCT_JETCORR_C12" );
146  coeffColumns.push_back( "GCT_JETCORR_C13" );
147  coeffColumns.push_back( "GCT_JETCORR_C14" );
148  coeffColumns.push_back( "GCT_JETCORR_C15" );
149  coeffColumns.push_back( "GCT_JETCORR_C16" );
150  coeffColumns.push_back( "GCT_JETCORR_C17" );
151  coeffColumns.push_back( "GCT_JETCORR_C18" );
152  coeffColumns.push_back( "GCT_JETCORR_C19" );
153 
154  l1t::OMDSReader::QueryResults jetCorrResults =
156  coeffColumns,
157  "CMS_GCT",
158  "GCT_JET_COEFFS",
159  "GCT_JET_COEFFS.CONFIG_KEY",
160  m_omdsReader.singleAttribute( etaKey ) ) ;
161 
162  if( results.queryFailed() ) // check if query was successful
163  {
164  edm::LogError( "L1-O2O" ) << "Problem getting L1 jet correction coefficients" ;
165  return boost::shared_ptr< L1GctJetFinderParams >() ;
166  }
167 
168  // fill coeffs - TODO
169  std::vector<double> coeffs;
170 
171  unsigned nCoeffs = 0;
172  if (corrType == 0) nCoeffs = 0;
173  else if (corrType == 2) nCoeffs=8; // ORCA style
174  else if (corrType == 3) nCoeffs=4; // Simple
175  else if (corrType == 4) nCoeffs=15; // piecewise-cubic
176  else if (corrType == 5) nCoeffs=6; // PF
177  else {
178  edm::LogError( "L1-O2O" ) << "Unsupported jet correction type : " << corrType ;
179  return boost::shared_ptr< L1GctJetFinderParams >() ;
180  }
181 
182  for (unsigned j=0; j< nCoeffs; ++j) {
183  std::stringstream coeffCol;
184  coeffCol << "GCT_JETCORR_C" << std::dec << j;
185  // int coeff;
186  double coeff;
187  jetCorrResults.fillVariable( coeffCol.str(), coeff );
188 
189  coeffs.push_back(coeff);
190  }
191 
192  jetCorrCoeffs.push_back(coeffs);
193 
194  // copy to tau coeffs
195  if (i < L1GctJetFinderParams::N_CENTRAL_ETA_VALUES) tauCorrCoeffs.push_back(coeffs);
196 
197  }
198 
199 
200 
201  return boost::shared_ptr< L1GctJetFinderParams >(
202  new L1GctJetFinderParams( rgnEtLsb,
203  htLsb,
204  cJetSeed,
205  fJetSeed,
206  tJetSeed,
207  tauIsoEtThresh,
208  htJetEtThresh,
209  mhtJetEtThresh,
210  etaBoundary,
211  corrType,
212  jetCorrCoeffs,
213  tauCorrCoeffs,
214  convertToEnergy,
215  energyConvCoeffs
216 
217  )
218  );
219 
220 }
221 
222 
int i
Definition: DBlmapReader.cc:9
static const unsigned N_CENTRAL_ETA_VALUES
Number of eta bins used in correction.
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="") const
Definition: OMDSReader.cc:87
virtual boost::shared_ptr< L1GctJetFinderParams > newObject(const std::string &objectKey)
int j
Definition: DBlmapReader.cc:9
static const unsigned NUMBER_ETA_VALUES
Number of eta bins used in correction.
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:56
L1GctJetFinderParamsOnlineProd(const edm::ParameterSet &iConfig)