14 #include "xercesc/util/PlatformUtils.hpp"
15 using namespace XERCES_CPP_NAMESPACE;
28 const char * expectedParams[] = {
29 "layer1ECalScaleFactors",
30 "layer1HCalScaleFactors",
31 "layer1HFScaleFactors",
32 "layer1ECalScaleETBins",
33 "layer1HCalScaleETBins",
36 for (
const auto param : expectedParams) {
37 if ( conf.find(param) == conf.end() ) {
38 std::cerr <<
"Unable to locate expected CaloLayer1 parameter: " << param <<
" in L1 settings payload!";
55 const char * expectedParams[] = {
56 "leptonSeedThreshold",
57 "leptonTowerThreshold",
58 "pileUpTowerThreshold",
67 "ecalET_energyCalibLUT",
68 "METX_energyCalibLUT",
69 "METY_energyCalibLUT",
70 "egammaRelaxationThreshold",
72 "egammaEnergyCalibLUT",
78 "towerCountThreshold",
84 "egammaHOverECut_iEtaLT15",
85 "egammaHOverECut_iEtaGTEq15"
87 for (
const auto param : expectedParams) {
88 if ( conf.find(param) == conf.end() ) {
89 std::cerr <<
"Unable to locate expected CaloLayer2 parameter: " << param <<
" in L1 settings payload!";
99 paramsHelper.
setJetBypassPUS(conf[
"jetBypassPileUpSub"].getValue<unsigned>());
109 std::vector<int> etSumEtaMax;
110 std::vector<int> etSumEtThresh;
112 etSumEtaMax.push_back(conf[
"ETMET_maxTowerEta"].getValue<int>());
113 etSumEtaMax.push_back(conf[
"HTMHT_maxJetEta"].getValue<int>());
114 etSumEtaMax.push_back(conf[
"ETMET_maxTowerEta"].getValue<int>());
115 etSumEtaMax.push_back(conf[
"HTMHT_maxJetEta"].getValue<int>());
116 etSumEtaMax.push_back(conf[
"towerCountMaxEta"].getValue<int>());
118 etSumEtThresh.push_back(conf[
"ET_towerThreshold"].getValue<int>());
119 etSumEtThresh.push_back(conf[
"HT_jetThreshold"].getValue<int>());
120 etSumEtThresh.push_back(conf[
"MET_towerThreshold"].getValue<int>());
121 etSumEtThresh.push_back(conf[
"MHT_jetThreshold"].getValue<int>());
122 etSumEtThresh.push_back(conf[
"ET_towerThreshold"].getValue<int>());
124 for (uint
i=0;
i<5; ++
i) {
129 std::stringstream oss;
131 std::vector<uint32_t> jetEnergyCalibLUT = conf[
"jetEnergyCalibLUT"].getVector<uint32_t>();
132 oss <<
"#<header> V1 "<< ( 32 - __builtin_clz( uint32_t(jetEnergyCalibLUT.size()-1) ) ) <<
" 63 </header> "<<std::endl;
133 for(
unsigned int i=0;
i<jetEnergyCalibLUT.size();
i++) oss <<
i <<
" " << jetEnergyCalibLUT[
i] << std::endl;
135 std::istringstream iss1( oss.str() );
139 std::vector<int> etSumEttPUSLUT = conf[
"ET_energyCalibLUT"].getVector<
int>();
140 oss <<
"#<header> V1 "<< ( 32 - __builtin_clz( uint32_t(etSumEttPUSLUT.size()-1) ) ) <<
" 63 </header> "<<std::endl;
141 for(
unsigned int i=0;
i<etSumEttPUSLUT.size();
i++) oss <<
i <<
" " << etSumEttPUSLUT[
i] << std::endl;
143 std::istringstream iss2( oss.str() );
147 std::vector<int> etSumEcalSumPUTLUT = conf[
"ecalET_energyCalibLUT"].getVector<
int>();
148 oss <<
"#<header> V1 "<< ( 32 - __builtin_clz( uint32_t(etSumEcalSumPUTLUT.size()-1) ) ) <<
" 63 </header> "<<std::endl;
149 for(
unsigned int i=0;
i<etSumEcalSumPUTLUT.size();
i++) oss <<
i <<
" " << etSumEcalSumPUTLUT[
i] << std::endl;
151 std::istringstream iss3( oss.str() );
155 std::vector<int> etSumXPUSLUT = conf[
"METX_energyCalibLUT"].getVector<
int>();
156 oss <<
"#<header> V1 "<< ( 32 - __builtin_clz( uint32_t(etSumXPUSLUT.size()-1) ) ) <<
" 63 </header> "<<std::endl;
157 for(
unsigned int i=0;
i<etSumXPUSLUT.size();
i++) oss <<
i <<
" " << etSumXPUSLUT[
i] << std::endl;
159 std::istringstream iss4( oss.str() );
163 paramsHelper.
setEgMaxPtHOverE((conf[
"egammaRelaxationThreshold"].getValue<int>()));
164 paramsHelper.
setEgEtaCut((conf[
"egammaMaxEta"].getValue<int>()));
167 std::vector<int> egCalibrationLUT = conf[
"egammaEnergyCalibLUT"].getVector<
int>();
168 oss <<
"#<header> V1 "<< ( 32 - __builtin_clz( uint32_t(egCalibrationLUT.size()-1) ) ) <<
" 63 </header> "<<std::endl;
169 for(
unsigned int i=0;
i<egCalibrationLUT.size();
i++) oss <<
i <<
" " << egCalibrationLUT[
i] << std::endl;
171 std::istringstream iss5( oss.str() );
175 std::vector<int> egIsolationLUT = conf[
"egammaIsoLUT"].getVector<
int>();
176 oss <<
"#<header> V1 "<< ( 32 - __builtin_clz( uint32_t(egIsolationLUT.size()-1) ) ) <<
" 63 </header> "<<std::endl;
177 for(
unsigned int i=0;
i<egIsolationLUT.size();
i++) oss <<
i <<
" " << egIsolationLUT[
i] << std::endl;
179 std::istringstream iss6( oss.str() );
189 std::vector<int> tauCalibrationLUT = conf[
"tauEnergyCalibLUT"].getVector<
int>();
190 oss <<
"#<header> V1 "<< ( 32 - __builtin_clz( uint32_t(tauCalibrationLUT.size()-1) ) ) <<
" 63 </header> "<<std::endl;
191 for(
unsigned int i=0;
i<tauCalibrationLUT.size();
i++) oss <<
i <<
" " << tauCalibrationLUT[
i] << std::endl;
193 std::istringstream iss7( oss.str() );
197 std::vector<int> tauIsolationLUT = conf[
"tauIsoLUT1"].getVector<
int>();
198 oss <<
"#<header> V1 "<< ( 32 - __builtin_clz( uint32_t(tauIsolationLUT.size()-1) ) ) <<
" 63 </header> "<<std::endl;
199 for(
unsigned int i=0;
i<tauIsolationLUT.size();
i++) oss <<
i <<
" " << tauIsolationLUT[
i] << std::endl;
201 std::istringstream iss8( oss.str() );
205 std::vector<int> tauIsolationLUT2 = conf[
"tauIsoLUT2"].getVector<
int>();
206 oss <<
"#<header> V1 "<< ( 32 - __builtin_clz( uint32_t(tauIsolationLUT2.size()-1) ) ) <<
" 63 </header> "<<std::endl;
207 for(
unsigned int i=0;
i<tauIsolationLUT2.size();
i++) oss <<
i <<
" " << tauIsolationLUT2[
i] << std::endl;
209 std::istringstream iss9( oss.str() );
219 using namespace edm::es;
223 baseRcd.get( baseSettings ) ;
226 if( objectKey.empty() ){
227 edm::LogError(
"L1-O2O: L1TCaloParamsOnlineProd" ) <<
"Key is empty, returning empty l1t::CaloParams";
228 throw std::runtime_error(
"Empty objectKey");
232 std::string tscKey = objectKey.substr(0, objectKey.find(
":") );
233 std::string rsKey = objectKey.substr( objectKey.find(
":")+1, std::string::npos );
237 edm::LogInfo(
"L1-O2O: L1TCaloParamsOnlineProd" ) <<
"Producing L1TCaloParamsOnlineProd with TSC key =" << tscKey <<
" and RS key = " << rsKey ;
242 std::vector< std::string > queryStrings ;
243 queryStrings.push_back(
"CALOL1_KEY" ) ;
244 queryStrings.push_back(
"CALOL2_KEY" ) ;
253 "L1_TRG_CONF_KEYS.ID",
257 if( queryResult.queryFailed() || queryResult.numberRows() != 1 ){
258 edm::LogError(
"L1-O2O" ) <<
"Cannot get L1_TRG_CONF_KEYS.{CALOL1_KEY,CALOL2_KEY} for ID = " << tscKey ;
259 throw std::runtime_error(
"Broken tscKey");
263 if( !queryResult.fillVariable(
"CALOL1_KEY", calol1_conf_key) ) calol1_conf_key =
"";
264 if( !queryResult.fillVariable(
"CALOL2_KEY", calol2_conf_key) ) calol2_conf_key =
"";
268 queryStrings.clear();
269 queryStrings.push_back(
"ALGO" );
280 if( queryResult.queryFailed() || queryResult.numberRows() != 1 ){
281 edm::LogError(
"L1-O2O: L1TCaloParamsOnlineProd" ) <<
"Cannot get CALOL1_KEYS.ALGO for ID="<<calol1_conf_key;
282 throw std::runtime_error(
"Broken key");
286 if( !queryResult.fillVariable(
"ALGO", calol1_algo_key ) ) calol1_algo_key =
"";
288 queryStrings.push_back(
"HW" );
298 if( queryResult.queryFailed() || queryResult.numberRows() != 1 ){
299 edm::LogError(
"L1-O2O: L1TCaloParamsOnlineProd" ) <<
"Cannot get CALOL2_KEYS.ALGO for ID="<<calol2_conf_key;
300 throw std::runtime_error(
"Broken key");
305 if( !queryResult.fillVariable(
"ALGO", calol2_algo_key ) ) calol2_algo_key =
"";
306 if( !queryResult.fillVariable(
"HW", calol2_hw_key ) ) calol2_hw_key =
"";
310 enum {kCONF=0, kRS, kHW, NUM_TYPES};
311 std::map<std::string,std::string>
payloads[NUM_TYPES];
314 queryStrings.clear();
315 queryStrings.push_back(
"CONF" );
326 if( queryResult.queryFailed() || queryResult.numberRows() != 1 ){
327 edm::LogError(
"L1-O2O: L1TCaloParamsOnlineProd" ) <<
"Cannot get CALOL1_ALGO.CONF for ID="<<calol1_algo_key;
328 throw std::runtime_error(
"Broken key");
332 if( !queryResult.fillVariable(
"CONF", xmlPayload ) ) xmlPayload =
"";
334 payloads[kCONF][calol1_algo_key.append(
"_L1")] = xmlPayload;
336 std::string calol2_demux_key, calol2_mps_common_key, calol2_mps_jet_key, calol2_mp_egamma_key, calol2_mp_sum_key, calol2_mp_tau_key;
338 queryStrings.clear();
339 queryStrings.push_back(
"DEMUX" );
340 queryStrings.push_back(
"MPS_COMMON" );
341 queryStrings.push_back(
"MPS_JET" );
342 queryStrings.push_back(
"MP_EGAMMA" );
343 queryStrings.push_back(
"MP_SUM" );
344 queryStrings.push_back(
"MP_TAU" );
351 "CALOL2_ALGO_KEYS.ID",
355 if( queryResult.queryFailed() || queryResult.numberRows() != 1 ){
356 edm::LogError(
"L1-O2O: L1TCaloParamsOnlineProd" ) <<
"Cannot get CALOL2_ALGO_KEYS.{DEMUX,MPS_COMMON,MPS_JET,MP_EGAMMA,MP_SUM,MP_TAU} for ID="<<calol2_algo_key;
357 throw std::runtime_error(
"Broken key");
361 if( !queryResult.fillVariable(
"DEMUX", calol2_demux_key ) ) calol2_demux_key =
"";
362 if( !queryResult.fillVariable(
"MPS_COMMON", calol2_mps_common_key ) ) calol2_mps_common_key =
"";
363 if( !queryResult.fillVariable(
"MPS_JET", calol2_mps_jet_key ) ) calol2_mps_jet_key =
"";
364 if( !queryResult.fillVariable(
"MP_EGAMMA", calol2_mp_egamma_key ) ) calol2_mp_egamma_key =
"";
365 if( !queryResult.fillVariable(
"MP_SUM", calol2_mp_sum_key ) ) calol2_mp_sum_key =
"";
366 if( !queryResult.fillVariable(
"MP_TAU", calol2_mp_tau_key ) ) calol2_mp_tau_key =
"";
368 queryStrings.clear();
369 queryStrings.push_back(
"CONF" );
380 if( queryResult.queryFailed() || queryResult.numberRows() != 1 ){
381 edm::LogError(
"L1-O2O: L1TCaloParamsOnlineProd" ) <<
"Cannot get CALOL2_ALGO.CONF for ID="<<calol2_demux_key;
382 throw std::runtime_error(
"Broken key");
386 if( !queryResult.fillVariable(
"CONF", xmlPayload ) ) xmlPayload =
"";
388 payloads[kCONF][calol2_demux_key.append(
"_L2")] = xmlPayload;
399 if( queryResult.queryFailed() || queryResult.numberRows() != 1 ){
400 edm::LogError(
"L1-O2O: L1TCaloParamsOnlineProd" ) <<
"Cannot get CALOL2_ALGO.CONF for ID="<<calol2_mps_common_key;
401 throw std::runtime_error(
"Broken key");
405 if( !queryResult.fillVariable(
"CONF", xmlPayload ) ) xmlPayload =
"";
407 payloads[kCONF][calol2_mps_common_key.append(
"_L2")] = xmlPayload;
418 if( queryResult.queryFailed() || queryResult.numberRows() != 1 ){
419 edm::LogError(
"L1-O2O: L1TCaloParamsOnlineProd" ) <<
"Cannot get CALOL2_ALGO.CONF for ID="<<calol2_mps_jet_key;
420 throw std::runtime_error(
"Broken key");
424 if( !queryResult.fillVariable(
"CONF", xmlPayload ) ) xmlPayload =
"";
426 payloads[kCONF][calol2_mps_jet_key.append(
"_L2")] = xmlPayload;
437 if( queryResult.queryFailed() || queryResult.numberRows() != 1 ){
438 edm::LogError(
"L1-O2O: L1TCaloParamsOnlineProd" ) <<
"Cannot get CALOL2_ALGO.CONF for ID="<<calol2_mp_egamma_key;
439 throw std::runtime_error(
"Broken key");
443 if( !queryResult.fillVariable(
"CONF", xmlPayload ) ) xmlPayload =
"";
445 payloads[kCONF][calol2_mp_egamma_key.append(
"_L2")] = xmlPayload;
456 if( queryResult.queryFailed() || queryResult.numberRows() != 1 ){
457 edm::LogError(
"L1-O2O: L1TCaloParamsOnlineProd" ) <<
"Cannot get CALOL2_ALGO.CONF for ID="<<calol2_mp_sum_key;
458 throw std::runtime_error(
"Broken key");
462 if( !queryResult.fillVariable(
"CONF", xmlPayload ) ) xmlPayload =
"";
464 payloads[kCONF][calol2_mp_sum_key.append(
"_L2")] = xmlPayload;
475 if( queryResult.queryFailed() || queryResult.numberRows() != 1 ){
476 edm::LogError(
"L1-O2O: L1TCaloParamsOnlineProd" ) <<
"Cannot get CALOL2_ALGO.CONF for ID="<<calol2_mp_tau_key;
477 throw std::runtime_error(
"Broken key");
481 if( !queryResult.fillVariable(
"CONF", xmlPayload ) ) xmlPayload =
"";
483 payloads[kCONF][calol2_mp_tau_key.append(
"_L2")] = xmlPayload;
493 if( queryResult.queryFailed() || queryResult.numberRows() != 1 ){
494 edm::LogError(
"L1-O2O: L1TCaloParamsOnlineProd" ) <<
"Cannot get CALOL2_HW.CONF for ID="<<calol2_hw_key;
495 throw std::runtime_error(
"Broken key");
498 if( !queryResult.fillVariable(
"CONF", xmlPayload ) ) xmlPayload =
"";
500 payloads[kHW][calol2_hw_key] = xmlPayload;
520 xmlReader1.readRootElement( calol1,
"calol1" );
521 calol1.setConfigured();
523 std::map<std::string, l1t::Setting> calol1_conf = calol1.getSettings(
"processors");
524 std::map<std::string, l1t::Mask> calol1_rs ;
531 xmlReader2.readRootElement( calol2,
"calol2" );
534 if( conf.first.find(
"_L2") != std::string::npos ){
535 xmlReader2.readDOMFromString( conf.second );
536 xmlReader2.readRootElement( calol2,
"calol2" );
541 calol2.setConfigured();
544 std::map<std::string, l1t::Setting> calol2_conf = calol2.getSettings(
"MP1");
545 std::map<std::string, l1t::Mask> calol2_rs ;
552 return boost::shared_ptr< l1t::CaloParams >(
new l1t::CaloParams ( m_params_helper ) ) ;
void setEtSumEtaMax(unsigned isum, int eta)
void setLayer1HCalScaleETBins(const std::vector< int > params)
void setIsoTauEtaMax(int value)
void setEgNeighbourThreshold(double thresh)
~L1TCaloParamsOnlineProd(void)
const QueryResults singleAttribute(const T &data) const
void setTauCalibrationLUT(const l1t::LUT &lut)
bool readCaloLayer1OnlineSettings(l1t::CaloParamsHelper ¶msHelper, std::map< std::string, l1t::Setting > &conf, std::map< std::string, l1t::Mask > &)
void setTauIsolationLUT(const l1t::LUT &lut)
void setJetCalibrationLUT(const l1t::LUT &lut)
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
void setTauNeighbourThreshold(double thresh)
void setEgHOverEcutEndcap(int cut)
void setEtSumXPUSLUT(const l1t::LUT &lut)
void setEgCalibrationLUT(const l1t::LUT &lut)
L1TCaloParamsOnlineProd(const edm::ParameterSet &)
void setEtSumEttPUSLUT(const l1t::LUT &lut)
l1t::OMDSReader m_omdsReader
void setEgHOverEcutBarrel(int cut)
U second(std::pair< T, U > const &p)
void addProcRole(const std::string &processor, const std::string &role)
void setEgBypassEGVetos(unsigned flag)
void setLayer1HFScaleETBins(const std::vector< int > params)
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="")
void setEtSumEtThreshold(unsigned isum, double thresh)
void setLayer1ECalScaleETBins(const std::vector< int > params)
void setTauSeedThreshold(double thresh)
tuple L1TCaloParamsOnlineProd
void setEgEtaCut(int mask)
bool readCaloLayer2OnlineSettings(l1t::CaloParamsHelper ¶msHelper, std::map< std::string, l1t::Setting > &conf, std::map< std::string, l1t::Mask > &)
void setLayer1HCalScaleFactors(const std::vector< double > params)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
void setLayer1HFScaleFactors(const std::vector< double > params)
void setJetSeedThreshold(double thresh)
void setEgMaxPtHOverE(double thresh)
void setEgIsolationLUT(const l1t::LUT &lut)
void setTauIsolationLUT2(const l1t::LUT &lut)
void setJetBypassPUS(unsigned flag)
void setEgSeedThreshold(double thresh)
void setLayer1ECalScaleFactors(const std::vector< double > params)
void readDOMFromString(const std::string &str, xercesc::DOMDocument *&doc)
virtual boost::shared_ptr< l1t::CaloParams > newObject(const std::string &objectKey, const L1TCaloParamsO2ORcd &record) override
void setEtSumEcalSumPUSLUT(const l1t::LUT &lut)