17 #include "xercesc/util/PlatformUtils.hpp"
27 std::map<std::string, l1t::Parameter>& conf,
28 std::map<std::string, l1t::Mask>&);
30 std::map<std::string, l1t::Parameter>& conf,
31 std::map<std::string, l1t::Mask>&);
34 std::unique_ptr<const l1t::CaloParams> newObject(
const std::string& objectKey,
42 std::map<std::string, l1t::Parameter>& conf,
43 std::map<std::string, l1t::Mask>&) {
44 const char* expectedParams[] = {
45 "layer1ECalScaleFactors",
46 "layer1HCalScaleFactors",
47 "layer1HFScaleFactors",
48 "layer1ECalScaleETBins",
49 "layer1HCalScaleETBins",
57 for (
const auto param : expectedParams) {
58 if (conf.find(param) == conf.end()) {
60 <<
"Unable to locate expected CaloLayer1 parameter: " << param <<
" in L1 settings payload!";
72 if (conf.find(
"layer1ECalScalePhiBins") != conf.end())
74 conf[
"layer1ECalScalePhiBins"].getVector<
unsigned int>());
75 if (conf.find(
"layer1HCalScalePhiBins") != conf.end())
77 if (conf.find(
"layer1HFScalePhiBins") != conf.end())
79 if (conf.find(
"layer1SecondStageLUT") != conf.end())
86 std::map<std::string, l1t::Parameter>& conf,
87 std::map<std::string, l1t::Mask>&) {
88 const char* expectedParams[] = {
89 "leptonSeedThreshold",
90 "leptonTowerThreshold",
91 "pileUpTowerThreshold",
92 "egammaRelaxationThreshold",
97 "egammaBypassExtendedHOverE",
98 "egammaHOverECut_iEtaLT15",
99 "egammaHOverECut_iEtaGTEq15",
100 "egammaEnergyCalibLUT",
111 "jetBypassPileUpSub",
114 "towerCountThreshold",
117 "ecalET_towerThresholdLUT",
118 "ET_towerThresholdLUT",
119 "MET_towerThresholdLUT",
120 "ET_centralityLowerThresholds",
121 "ET_centralityUpperThresholds",
123 "ecalET_energyCalibLUT",
124 "MET_energyCalibLUT",
125 "METHF_energyCalibLUT",
130 for (
const auto param : expectedParams) {
131 if (conf.find(param) == conf.end()) {
133 <<
"Unable to locate expected CaloLayer2 parameter: " << param <<
" in L1 settings payload!";
144 paramsHelper.
setEgMaxPtHOverE((conf[
"egammaRelaxationThreshold"].getValue<int>()) / 2.);
145 paramsHelper.
setEgEtaCut((conf[
"egammaMaxEta"].getValue<int>()));
162 paramsHelper.
setJetBypassPUS(conf[
"jetBypassPileUpSub"].getValue<bool>());
167 std::vector<int> etSumEtThresh;
169 etSumEtaMax.push_back(conf[
"ETMET_maxTowerEta"].getValue<int>());
170 etSumEtaMax.push_back(conf[
"HTMHT_maxJetEta"].getValue<int>());
171 etSumEtaMax.push_back(conf[
"ETMET_maxTowerEta"].getValue<int>());
172 etSumEtaMax.push_back(conf[
"HTMHT_maxJetEta"].getValue<int>());
173 etSumEtaMax.push_back(conf[
"towerCountMaxEta"].getValue<int>());
175 etSumEtThresh.push_back(0);
176 etSumEtThresh.push_back(conf[
"HT_jetThreshold"].getValue<int>() / 2);
177 etSumEtThresh.push_back(0);
178 etSumEtThresh.push_back(conf[
"MHT_jetThreshold"].getValue<int>() / 2);
179 etSumEtThresh.push_back(conf[
"towerCountThreshold"].getValue<int>() / 2);
190 std::vector<double> etSumCentLowerValues;
191 std::vector<double> etSumCentUpperValues;
193 etSumCentLowerValues = conf[
"ET_centralityLowerThresholds"].getVector<
double>();
194 etSumCentUpperValues = conf[
"ET_centralityUpperThresholds"].getVector<
double>();
224 if (objectKey.empty()) {
225 edm::LogError(
"L1-O2O: L1TCaloParamsOnlineProd") <<
"Key is empty";
227 throw std::runtime_error(
"SummaryForFunctionManager: Calo | Faulty | Empty objectKey");
229 edm::LogError(
"L1-O2O: L1TCaloParamsOnlineProd") <<
"returning unmodified prototype of l1t::CaloParams";
230 return std::make_unique<const l1t::CaloParams>(baseSettings);
234 std::string tscKey = objectKey.substr(0, objectKey.find(
":"));
235 std::string rsKey = objectKey.substr(objectKey.find(
":") + 1, std::string::npos);
238 <<
"Producing L1TCaloParamsOnlineProd with TSC key = " << tscKey <<
" and RS key = " << rsKey;
242 std::string calol2_top_key, calol2_algo_key, calol2_hw_key;
244 std::map<std::string, std::string> calol2_algo_payloads;
246 std::map<std::string, std::string> topKeys =
250 calol1_top_key = topKeys[
"CALOL1_KEY"];
254 calol1_algo_payload =
259 calol2_top_key = topKeys[
"CALOL2_KEY"];
261 std::map<std::string, std::string> calol2_keys =
264 calol2_hw_key = calol2_keys[
"HW"];
268 calol2_algo_key = calol2_keys[
"ALGO"];
270 std::map<std::string, std::string> calol2_algo_keys =
276 for (
auto&
key : calol2_algo_keys)
277 calol2_algo_payloads[
key.second] =
281 }
catch (std::runtime_error&
e) {
284 throw std::runtime_error(
std::string(
"SummaryForFunctionManager: Calo | Faulty | ") +
e.what());
286 edm::LogError(
"L1-O2O: L1TCaloParamsOnlineProd") <<
"returning unmodified prototype of l1t::CaloParams";
287 return std::make_unique<const l1t::CaloParams>(baseSettings);
293 for (
auto& conf : calol2_algo_payloads) {
298 std::ofstream
output(
std::string(
"/tmp/").
append(calol2_hw_key.substr(0, calol2_hw_key.find(
"/"))).append(
".xml"));
299 output << calol2_hw_payload;
304 std::string(
"/tmp/").
append(calol1_algo_key.substr(0, calol1_algo_key.find(
"/"))).append(
".xml"));
305 output << calol1_algo_payload;
317 calol1.
addProcessor(
"processors",
"processors",
"-1",
"-1");
321 std::map<std::string, l1t::Parameter> calol1_conf = calol1.
getParameters(
"processors");
322 std::map<std::string, l1t::Mask> calol1_rs;
325 throw std::runtime_error(
"Parsing error for CaloLayer1");
327 }
catch (std::runtime_error&
e) {
330 throw std::runtime_error(
std::string(
"SummaryForFunctionManager: Calo | Faulty | ") +
e.what());
332 edm::LogError(
"L1-O2O: L1TCaloParamsOnlineProd") <<
"returning unmodified prototype of l1t::CaloParams";
333 return std::make_unique<const l1t::CaloParams>(baseSettings);
345 for (
auto& conf : calol2_algo_payloads) {
353 std::map<std::string, l1t::Parameter> calol2_conf = calol2.
getParameters(
"MP1");
354 std::map<std::string, l1t::Parameter> calol2_conf_demux = calol2.
getParameters(
"DEMUX");
355 calol2_conf.insert(calol2_conf_demux.begin(), calol2_conf_demux.end());
356 std::map<std::string, l1t::Mask> calol2_rs;
359 throw std::runtime_error(
"Parsing error for CaloLayer2");
361 }
catch (std::runtime_error&
e) {
364 throw std::runtime_error(
std::string(
"SummaryForFunctionManager: Calo | Faulty | ") +
e.what());
366 edm::LogError(
"L1-O2O: L1TCaloParamsOnlineProd") <<
"returning unmodified prototype of l1t::CaloParams";
367 return std::make_unique<const l1t::CaloParams>(baseSettings);
372 auto retval = std::make_unique<const l1t::CaloParams>(m_params_helper);
374 edm::LogInfo(
"L1-O2O: L1TCaloParamsOnlineProd") <<
"SummaryForFunctionManager: Calo | OK | All looks good";