00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "CondTools/L1Trigger/interface/L1ConfigOnlineProdBase.h"
00025
00026 #include "CondFormats/L1TObjects/interface/L1RCTParameters.h"
00027 #include "CondFormats/DataRecord/interface/L1RCTParametersRcd.h"
00028
00029
00030
00031
00032
00033
00034
00035
00036 class L1RCTParametersOnlineProd :
00037 public L1ConfigOnlineProdBase< L1RCTParametersRcd, L1RCTParameters > {
00038 public:
00039 L1RCTParametersOnlineProd(const edm::ParameterSet&);
00040 ~L1RCTParametersOnlineProd();
00041
00042 virtual boost::shared_ptr< L1RCTParameters > newObject(
00043 const std::string& objectKey ) ;
00044
00045 void fillScaleFactors(
00046 const l1t::OMDSReader::QueryResults& results,
00047 std::vector< double >& output, int nfactor = 1 ) ;
00048
00049
00050
00051
00052
00053
00054 private:
00055
00056 };
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 L1RCTParametersOnlineProd::L1RCTParametersOnlineProd(
00070 const edm::ParameterSet& iConfig)
00071 : L1ConfigOnlineProdBase< L1RCTParametersRcd, L1RCTParameters >( iConfig )
00072 {
00073
00074
00075
00076
00077 }
00078
00079
00080 L1RCTParametersOnlineProd::~L1RCTParametersOnlineProd()
00081 {
00082
00083
00084
00085
00086 }
00087
00088 boost::shared_ptr< L1RCTParameters >
00089 L1RCTParametersOnlineProd::newObject( const std::string& objectKey )
00090 {
00091 using namespace edm::es;
00092
00093 std::string rctSchema = "CMS_RCT" ;
00094 const l1t::OMDSReader::QueryResults paremKeyResults =
00095 m_omdsReader.singleAttribute( objectKey ) ;
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 std::vector< std::string > queryStrings ;
00109 queryStrings.push_back( "EGAMMA_LSB" ) ;
00110 queryStrings.push_back( "JETMET_LSB" ) ;
00111 queryStrings.push_back( "E_MIN_FOR_FG_CUT" ) ;
00112 queryStrings.push_back( "E_MAX_FOR_FG_CUT" ) ;
00113 queryStrings.push_back( "H_OVER_E_CUT" ) ;
00114 queryStrings.push_back( "E_MIN_FOR_H_OVER_E_CUT" ) ;
00115 queryStrings.push_back( "E_MAX_FOR_H_OVER_E_CUT" ) ;
00116 queryStrings.push_back( "H_MIN_FOR_H_OVER_E_CUT" ) ;
00117 queryStrings.push_back( "E_ACTIVITY_CUT" ) ;
00118 queryStrings.push_back( "H_ACTIVITY_CUT" ) ;
00119 queryStrings.push_back( "EIC_ISOLATION_THRESHOLD" ) ;
00120 queryStrings.push_back( "JSC_QUIET_THRESHOLD_BARREL" ) ;
00121 queryStrings.push_back( "JSC_QUIET_THRESHOLD_ENDCAP" ) ;
00122 queryStrings.push_back( "NOISEVETOHB" ) ;
00123 queryStrings.push_back( "NOISEVETOHEPLUS" ) ;
00124 queryStrings.push_back( "NOISEVETOHEMINUS" ) ;
00125 queryStrings.push_back( "USECORR" );
00126 l1t::OMDSReader::QueryResults paremResults =
00127 m_omdsReader.basicQuery( queryStrings,
00128 rctSchema,
00129 "PAREM_CONF",
00130 "PAREM_CONF.PAREM_KEY",
00131 paremKeyResults ) ;
00132
00133 if( paremResults.queryFailed() ||
00134 paremResults.numberRows() != 1 )
00135 {
00136 edm::LogError( "L1-O2O" ) << "Problem with L1RCTParameters key." ;
00137 return boost::shared_ptr< L1RCTParameters >() ;
00138 }
00139
00140 double eGammaLSB, jetMETLSB, eMinForFGCut, eMaxForFGCut, hOeCut ;
00141 double eMinForHoECut, eMaxForHoECut, hMinForHoECut ;
00142 double eActivityCut, hActivityCut ;
00143 double jscQuietThreshBarrel, jscQuietThreshEndcap, eicIsolationThreshold ;
00144 bool noiseVetoHB, noiseVetoHEplus, noiseVetoHEminus, useCorr ;
00145
00146 paremResults.fillVariable( "EGAMMA_LSB", eGammaLSB ) ;
00147 paremResults.fillVariable( "JETMET_LSB", jetMETLSB ) ;
00148 paremResults.fillVariable( "E_MIN_FOR_FG_CUT", eMinForFGCut ) ;
00149 paremResults.fillVariable( "E_MAX_FOR_FG_CUT", eMaxForFGCut ) ;
00150 paremResults.fillVariable( "H_OVER_E_CUT", hOeCut ) ;
00151 paremResults.fillVariable( "E_MIN_FOR_H_OVER_E_CUT", eMinForHoECut ) ;
00152 paremResults.fillVariable( "E_MAX_FOR_H_OVER_E_CUT", eMaxForHoECut ) ;
00153 paremResults.fillVariable( "H_MIN_FOR_H_OVER_E_CUT", hMinForHoECut ) ;
00154 paremResults.fillVariable( "E_ACTIVITY_CUT", eActivityCut ) ;
00155 paremResults.fillVariable( "H_ACTIVITY_CUT", hActivityCut ) ;
00156 paremResults.fillVariable( "JSC_QUIET_THRESHOLD_BARREL",
00157 jscQuietThreshBarrel ) ;
00158 paremResults.fillVariable( "JSC_QUIET_THRESHOLD_ENDCAP",
00159 jscQuietThreshEndcap ) ;
00160 paremResults.fillVariable( "EIC_ISOLATION_THRESHOLD",
00161 eicIsolationThreshold ) ;
00162 paremResults.fillVariable( "NOISEVETOHB", noiseVetoHB ) ;
00163 paremResults.fillVariable( "NOISEVETOHEPLUS", noiseVetoHEplus ) ;
00164 paremResults.fillVariable( "NOISEVETOHEMINUS", noiseVetoHEminus ) ;
00165 paremResults.fillVariable( "USECORR", useCorr ) ;
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191 std::vector< std::string > scaleFactorQueryStrings ;
00192 scaleFactorQueryStrings.push_back( "SCALEFACTOR" ) ;
00193 scaleFactorQueryStrings.push_back( "FK_RCT_ETA" ) ;
00194
00195 l1t::OMDSReader::QueryResults egammaEcalResults =
00196 m_omdsReader.basicQuery(
00197 scaleFactorQueryStrings,
00198 rctSchema,
00199 "EGAMMA_ECAL_SCALEFACTOR",
00200 "EGAMMA_ECAL_SCALEFACTOR.FK_VERSION",
00201 m_omdsReader.basicQuery( "EGAMMA_ECAL",
00202 rctSchema,
00203 "PAREM_CONF",
00204 "PAREM_CONF.PAREM_KEY",
00205 paremKeyResults ) ) ;
00206
00207 if( egammaEcalResults.queryFailed() )
00208 {
00209 edm::LogError( "L1-O2O" ) << "Problem with EgammaEcal key." ;
00210 return boost::shared_ptr< L1RCTParameters >() ;
00211 }
00212
00213
00214 std::vector< double > egammaEcalScaleFactors ;
00215 fillScaleFactors( egammaEcalResults, egammaEcalScaleFactors ) ;
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225 l1t::OMDSReader::QueryResults egammaHcalResults =
00226 m_omdsReader.basicQuery(
00227 scaleFactorQueryStrings,
00228 rctSchema,
00229 "EGAMMA_HCAL_SCALEFACTOR",
00230 "EGAMMA_HCAL_SCALEFACTOR.FK_VERSION",
00231 m_omdsReader.basicQuery( "EGAMMA_HCAL",
00232 rctSchema,
00233 "PAREM_CONF",
00234 "PAREM_CONF.PAREM_KEY",
00235 paremKeyResults ) ) ;
00236
00237 if( egammaHcalResults.queryFailed() )
00238 {
00239 edm::LogError( "L1-O2O" ) << "Problem with EgammaHcal key." ;
00240 return boost::shared_ptr< L1RCTParameters >() ;
00241 }
00242
00243
00244 std::vector< double > egammaHcalScaleFactors ;
00245 fillScaleFactors( egammaHcalResults, egammaHcalScaleFactors ) ;
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255 l1t::OMDSReader::QueryResults jetmetEcalResults =
00256 m_omdsReader.basicQuery(
00257 scaleFactorQueryStrings,
00258 rctSchema,
00259 "JETMET_ECAL_SCALEFACTOR",
00260 "JETMET_ECAL_SCALEFACTOR.FK_VERSION",
00261 m_omdsReader.basicQuery( "JETMET_ECAL",
00262 rctSchema,
00263 "PAREM_CONF",
00264 "PAREM_CONF.PAREM_KEY",
00265 paremKeyResults ) ) ;
00266
00267 if( jetmetEcalResults.queryFailed() )
00268 {
00269 edm::LogError( "L1-O2O" ) << "Problem with JetmetEcal key." ;
00270 return boost::shared_ptr< L1RCTParameters >() ;
00271 }
00272
00273
00274 std::vector< double > jetmetEcalScaleFactors ;
00275 fillScaleFactors( jetmetEcalResults, jetmetEcalScaleFactors ) ;
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285 l1t::OMDSReader::QueryResults jetmetHcalResults =
00286 m_omdsReader.basicQuery(
00287 scaleFactorQueryStrings,
00288 rctSchema,
00289 "JETMET_HCAL_SCALEFACTOR",
00290 "JETMET_HCAL_SCALEFACTOR.FK_VERSION",
00291 m_omdsReader.basicQuery( "JETMET_HCAL",
00292 rctSchema,
00293 "PAREM_CONF",
00294 "PAREM_CONF.PAREM_KEY",
00295 paremKeyResults ) ) ;
00296
00297 if( jetmetHcalResults.queryFailed() )
00298 {
00299 edm::LogError( "L1-O2O" ) << "Problem with JetmetHcal key." ;
00300 return boost::shared_ptr< L1RCTParameters >() ;
00301 }
00302
00303
00304 std::vector< double > jetmetHcalScaleFactors ;
00305 fillScaleFactors( jetmetHcalResults, jetmetHcalScaleFactors ) ;
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317 std::vector< double > lowHoverE_smear, highHoverE_smear ;
00318 std::vector< double > hcalCalibScaleFactors,ecalCalibScaleFactors;
00319 std::vector< double > hcalCalibHighScaleFactors,crossTermsScaleFactors;
00320
00321 if(useCorr) {
00322
00323 std::vector< std::string > scaleFactorQuery3Strings ;
00324 scaleFactorQuery3Strings.push_back( "SCALEFACTOR" ) ;
00325 scaleFactorQuery3Strings.push_back( "SF2" ) ;
00326 scaleFactorQuery3Strings.push_back( "SF3" ) ;
00327 scaleFactorQuery3Strings.push_back( "FK_RCT_ETA" ) ;
00328
00329 l1t::OMDSReader::QueryResults hcalCalibResults =
00330 m_omdsReader.basicQuery(
00331 scaleFactorQuery3Strings,
00332 rctSchema,
00333 "HCAL_CALIB_FACTOR",
00334 "HCAL_CALIB_FACTOR.VERSION",
00335 m_omdsReader.basicQuery( "HCAL_CALIB_VERSION",
00336 rctSchema,
00337 "PAREM_CONF",
00338 "PAREM_CONF.PAREM_KEY",
00339 paremKeyResults ) ) ;
00340
00341 if( hcalCalibResults.queryFailed() ) {
00342
00343 edm::LogError( "L1-O2O" ) << "Problem with JetmetHcal key." ;
00344 return boost::shared_ptr< L1RCTParameters >() ;
00345 }
00346
00347
00348
00349 fillScaleFactors( hcalCalibResults, hcalCalibScaleFactors, 3 ) ;
00350
00351 l1t::OMDSReader::QueryResults hcalCalibHighResults =
00352 m_omdsReader.basicQuery(
00353 scaleFactorQuery3Strings,
00354 rctSchema,
00355 "HCAL_CALIB_HIGH_FACTOR",
00356 "HCAL_CALIB_HIGH_FACTOR.VERSION",
00357 m_omdsReader.basicQuery( "HCAL_CALIB_HIGH_VERSION",
00358 rctSchema,
00359 "PAREM_CONF",
00360 "PAREM_CONF.PAREM_KEY",
00361 paremKeyResults ) ) ;
00362
00363 if( hcalCalibHighResults.queryFailed() )
00364 {
00365 edm::LogError( "L1-O2O" ) << "Problem with hcalHigh key." ;
00366 return boost::shared_ptr< L1RCTParameters >() ;
00367 }
00368
00369
00370
00371 fillScaleFactors( hcalCalibHighResults, hcalCalibHighScaleFactors,3 ) ;
00372
00373 l1t::OMDSReader::QueryResults ecalCalibResults =
00374 m_omdsReader.basicQuery(
00375 scaleFactorQuery3Strings,
00376 rctSchema,
00377 "ECAL_CALIB_FACTOR",
00378 "ECAL_CALIB_FACTOR.VERSION",
00379 m_omdsReader.basicQuery( "ECAL_CALIB_VERSION",
00380 rctSchema,
00381 "PAREM_CONF",
00382 "PAREM_CONF.PAREM_KEY",
00383 paremKeyResults ) ) ;
00384
00385 if( ecalCalibResults.queryFailed() )
00386 {
00387 edm::LogError( "L1-O2O" ) << "Problem with ecal calib key." ;
00388 return boost::shared_ptr< L1RCTParameters >() ;
00389 }
00390
00391
00392 fillScaleFactors( ecalCalibResults, ecalCalibScaleFactors,3 ) ;
00393
00394
00395 std::vector< std::string > scaleFactorQuery6Strings ;
00396 scaleFactorQuery6Strings.push_back( "SCALEFACTOR" ) ;
00397 scaleFactorQuery6Strings.push_back( "SF2" ) ;
00398 scaleFactorQuery6Strings.push_back( "SF3" ) ;
00399 scaleFactorQuery6Strings.push_back( "SF4" ) ;
00400 scaleFactorQuery6Strings.push_back( "SF5" ) ;
00401 scaleFactorQuery6Strings.push_back( "SF6" ) ;
00402 scaleFactorQuery6Strings.push_back( "FK_RCT_ETA" ) ;
00403 l1t::OMDSReader::QueryResults crossTermResults =
00404 m_omdsReader.basicQuery(
00405 scaleFactorQuery6Strings,
00406 rctSchema,
00407 "CROSS_TERMS_FACTOR",
00408 "CROSS_TERMS_FACTOR.VERSION",
00409 m_omdsReader.basicQuery( "CROSS_TERMS_VERSION",
00410 rctSchema,
00411 "PAREM_CONF",
00412 "PAREM_CONF.PAREM_KEY",
00413 paremKeyResults ) ) ;
00414
00415 if( crossTermResults.queryFailed() )
00416 {
00417 edm::LogError( "L1-O2O" ) << "Problem with crossTerms key." ;
00418 return boost::shared_ptr< L1RCTParameters >() ;
00419 }
00420
00421 fillScaleFactors( crossTermResults, crossTermsScaleFactors,6 ) ;
00422
00423 l1t::OMDSReader::QueryResults hoveresmearhighResults =
00424 m_omdsReader.basicQuery(
00425 scaleFactorQueryStrings,
00426 rctSchema,
00427 "H_OVER_E_SMEAR_HIGH_FACTOR",
00428 "H_OVER_E_SMEAR_HIGH_FACTOR.FK_VERSION",
00429 m_omdsReader.basicQuery( "H_OVER_E_SMEAR_HIGH_VERSION",
00430 rctSchema,
00431 "PAREM_CONF",
00432 "PAREM_CONF.PAREM_KEY",
00433 paremKeyResults ) ) ;
00434
00435 if( hoveresmearhighResults.queryFailed() )
00436 {
00437 edm::LogError( "L1-O2O" ) << "Problem with low h over e smear key." ;
00438 return boost::shared_ptr< L1RCTParameters >() ;
00439 }
00440
00441
00442 fillScaleFactors( hoveresmearhighResults, highHoverE_smear ) ;
00443
00444
00445 l1t::OMDSReader::QueryResults hoveresmearlowResults =
00446 m_omdsReader.basicQuery(
00447 scaleFactorQueryStrings,
00448 rctSchema,
00449 "H_OVER_E_SMEAR_LOW_FACTOR",
00450 "H_OVER_E_SMEAR_LOW_FACTOR.FK_VERSION",
00451 m_omdsReader.basicQuery( "H_OVER_E_SMEAR_LOW_VERSION",
00452 rctSchema,
00453 "PAREM_CONF",
00454 "PAREM_CONF.PAREM_KEY",
00455 paremKeyResults ) ) ;
00456
00457 if( hoveresmearlowResults.queryFailed() )
00458 {
00459 edm::LogError( "L1-O2O" ) << "Problem with low h over e smear key." ;
00460 return boost::shared_ptr< L1RCTParameters >() ;
00461 }
00462
00463
00464 fillScaleFactors( hoveresmearlowResults, lowHoverE_smear ) ;
00465 }
00466
00467
00468
00469
00470
00471
00472 return boost::shared_ptr< L1RCTParameters >(
00473 new L1RCTParameters( eGammaLSB,
00474 jetMETLSB,
00475 eMinForFGCut,
00476 eMaxForFGCut,
00477 hOeCut,
00478 eMinForHoECut,
00479 eMaxForHoECut,
00480 hMinForHoECut,
00481 eActivityCut,
00482 hActivityCut,
00483 (unsigned int) eicIsolationThreshold,
00484 (int) jscQuietThreshBarrel,
00485 (int) jscQuietThreshEndcap,
00486 noiseVetoHB,
00487 noiseVetoHEplus,
00488 noiseVetoHEminus,
00489 useCorr,
00490 egammaEcalScaleFactors,
00491 egammaHcalScaleFactors,
00492 jetmetEcalScaleFactors,
00493 jetmetHcalScaleFactors,
00494 ecalCalibScaleFactors,
00495 hcalCalibScaleFactors,
00496 hcalCalibHighScaleFactors,
00497 crossTermsScaleFactors,
00498 lowHoverE_smear,
00499 highHoverE_smear
00500 ) ) ;
00501 }
00502
00503
00504
00505
00506
00507 void
00508 L1RCTParametersOnlineProd::fillScaleFactors(
00509 const l1t::OMDSReader::QueryResults& results,
00510 std::vector< double >& output, int nfactors )
00511 {
00512 if( (nfactors < 1) || (nfactors > 6)){
00513 edm::LogError( "L1-O2O" ) <<"invalid number of factors in scale factors fill";
00514 return;
00515 }
00516
00517 std::vector< std::string > scaleFactorQuery6Strings ;
00518 scaleFactorQuery6Strings.push_back( "SCALEFACTOR" ) ;
00519 scaleFactorQuery6Strings.push_back( "SF2" ) ;
00520 scaleFactorQuery6Strings.push_back( "SF3" ) ;
00521 scaleFactorQuery6Strings.push_back( "SF4" ) ;
00522 scaleFactorQuery6Strings.push_back( "SF5" ) ;
00523 scaleFactorQuery6Strings.push_back( "SF6" ) ;
00524
00525
00526
00527
00528 std::vector <double> sfTmp[100] ;
00529
00530
00531
00532
00533
00534
00535 short maxBin = 0 ;
00536 for( int i = 0 ; i < results.numberRows() ; ++i )
00537 {
00538 double sf[6] ;
00539 for(int nf = 0; nf < nfactors; nf++){
00540 results.fillVariableFromRow( scaleFactorQuery6Strings.at(nf), i, sf[nf] ) ;
00541 }
00542 short ieta ;
00543 results.fillVariableFromRow( "FK_RCT_ETA", i, ieta ) ;
00544
00545 for(int nf = 0; nf< nfactors; nf++)
00546
00547 sfTmp[ieta-1].push_back(sf[nf]);
00548
00549 if( ieta > maxBin )
00550 {
00551 maxBin = ieta ;
00552 }
00553 }
00554
00555
00556 for( short i = 0 ; i < maxBin ; ++i )
00557 {
00558 for( short nf = 0; nf < nfactors; nf++)
00559 output.push_back( sfTmp[ i ].at(nf) ) ;
00560
00561 }
00562 }
00563
00564
00565
00566
00567
00568 DEFINE_FWK_EVENTSETUP_MODULE(L1RCTParametersOnlineProd);