test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TCaloParamsOnlineProd.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <fstream>
3 #include <stdexcept>
4 #include <sstream>
5 
13 
14 #include "xercesc/util/PlatformUtils.hpp"
15 using namespace XERCES_CPP_NAMESPACE;
16 
17 class L1TCaloParamsOnlineProd : public L1ConfigOnlineProdBaseExt<L1TCaloParamsO2ORcd,l1t::CaloParams> {
18 private:
19 public:
20  virtual std::shared_ptr<l1t::CaloParams> newObject(const std::string& objectKey, const L1TCaloParamsO2ORcd& record) override ;
21 
24 };
25 
26 bool
27 readCaloLayer1OnlineSettings(l1t::CaloParamsHelper& paramsHelper, std::map<std::string, l1t::Setting>& conf, std::map<std::string, l1t::Mask>& ) {
28  const char * expectedParams[] = {
29  "layer1ECalScaleFactors",
30  "layer1HCalScaleFactors",
31  "layer1HFScaleFactors",
32  "layer1ECalScaleETBins",
33  "layer1HCalScaleETBins",
34  "layer1HFScaleETBins"
35  };
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!";
39  return false;
40  }
41  }
42  // Layer 1 LUT specification
43  paramsHelper.setLayer1ECalScaleFactors((conf["layer1ECalScaleFactors"].getVector<double>()));
44  paramsHelper.setLayer1HCalScaleFactors((conf["layer1HCalScaleFactors"].getVector<double>()));
45  paramsHelper.setLayer1HFScaleFactors ((conf["layer1HFScaleFactors"] .getVector<double>()));
46  paramsHelper.setLayer1ECalScaleETBins(conf["layer1ECalScaleETBins"].getVector<int>());
47  paramsHelper.setLayer1HCalScaleETBins(conf["layer1HCalScaleETBins"].getVector<int>());
48  paramsHelper.setLayer1HFScaleETBins (conf["layer1HFScaleETBins"] .getVector<int>());
49 
50  return true;
51 }
52 
53 bool
54 readCaloLayer2OnlineSettings(l1t::CaloParamsHelper& paramsHelper, std::map<std::string, l1t::Setting>& conf, std::map<std::string, l1t::Mask>& ) {
55  const char * expectedParams[] = {
56  "leptonSeedThreshold",
57  "leptonTowerThreshold",
58  "pileUpTowerThreshold",
59  "jetSeedThreshold",
60  "jetMaxEta",
61  "HTMHT_maxJetEta",
62  "HT_jetThreshold",
63  "MHT_jetThreshold",
64  "jetEnergyCalibLUT",
65  "ETMET_maxTowerEta",
66  "ET_energyCalibLUT",
67  "ecalET_energyCalibLUT",
68  "METX_energyCalibLUT",
69  "METY_energyCalibLUT",
70  "egammaRelaxationThreshold",
71  "egammaMaxEta",
72  "egammaEnergyCalibLUT",
73  "egammaIsoLUT",
74  "tauMaxEta",
75  "tauEnergyCalibLUT",
76  "tauIsoLUT1",
77  "tauIsoLUT2",
78  "towerCountThreshold",
79  "towerCountMaxEta",
80  "ET_towerThreshold",
81  "MET_towerThreshold",
82  "jetBypassPileUpSub",
83  "egammaBypassCuts",
84  "egammaHOverECut_iEtaLT15",
85  "egammaHOverECut_iEtaGTEq15"
86  };
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!";
90  return false;
91  }
92  }
93  // Layer 2 params specification
94  paramsHelper.setEgSeedThreshold((conf["leptonSeedThreshold"].getValue<int>())/2);
95  paramsHelper.setTauSeedThreshold((conf["leptonSeedThreshold"].getValue<int>())/2);
96  paramsHelper.setEgNeighbourThreshold((conf["leptonTowerThreshold"].getValue<int>())/2);
97  paramsHelper.setTauNeighbourThreshold((conf["leptonTowerThreshold"].getValue<int>())/2);
98  paramsHelper.setJetSeedThreshold((conf["jetSeedThreshold"].getValue<int>())/2);
99  paramsHelper.setJetBypassPUS(conf["jetBypassPileUpSub"].getValue<unsigned>()); //these are bools in onlineDB
100  paramsHelper.setEgBypassEGVetos(conf["egammaBypassCuts"].getValue<unsigned>()); //these are bools in onlineDB
101  paramsHelper.setEgHOverEcutBarrel(conf["egammaHOverECut_iEtaLT15"].getValue<int>());
102  paramsHelper.setEgHOverEcutEndcap(conf["egammaHOverECut_iEtaGTEq15"].getValue<int>());
103 
104 
105  // Currently not used // paramsHelper.setEgPileupTowerThresh((conf["pileUpTowerThreshold"].getValue<int>()));
106  // Currently not used // paramsHelper.setTauPileupTowerThresh((conf["pileUpTowerThreshold"].getValue<int>()));
107  // Currently not used // paramsHelper.setJetMaxEta((conf["jetMaxEta"].getValue<int>()));
108 
109  std::vector<int> etSumEtaMax;
110  std::vector<int> etSumEtThresh;
111 
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>());
117 
118  etSumEtThresh.push_back(conf["ET_towerThreshold"].getValue<int>()); // ETT tower threshold
119  etSumEtThresh.push_back(conf["HT_jetThreshold"].getValue<int>());
120  etSumEtThresh.push_back(conf["MET_towerThreshold"].getValue<int>()); // ETM tower threshold
121  etSumEtThresh.push_back(conf["MHT_jetThreshold"].getValue<int>());
122  etSumEtThresh.push_back(conf["ET_towerThreshold"].getValue<int>());
123 
124  for (uint i=0; i<5; ++i) {
125  paramsHelper.setEtSumEtaMax(i, etSumEtaMax.at(i));
126  paramsHelper.setEtSumEtThreshold(i, etSumEtThresh.at(i));
127  }
128 
129  std::stringstream oss;
130 
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; // hardcode max bits for data
133  for(unsigned int i=0; i<jetEnergyCalibLUT.size(); i++) oss << i << " " << jetEnergyCalibLUT[i] << std::endl;
134 
135  std::istringstream iss1( oss.str() );
136  paramsHelper.setJetCalibrationLUT( l1t::LUT( (std::istream&)iss1 ) );
137  oss.str("");
138 
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; // hardcode max bits for data
141  for(unsigned int i=0; i<etSumEttPUSLUT.size(); i++) oss << i << " " << etSumEttPUSLUT[i] << std::endl;
142 
143  std::istringstream iss2( oss.str() );
144  paramsHelper.setEtSumEttPUSLUT( l1t::LUT( (std::istream&)iss2 ) );
145  oss.str("");
146 
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; // hardcode max bits for data
149  for(unsigned int i=0; i<etSumEcalSumPUTLUT.size(); i++) oss << i << " " << etSumEcalSumPUTLUT[i] << std::endl;
150 
151  std::istringstream iss3( oss.str() );
152  paramsHelper.setEtSumEcalSumPUSLUT( l1t::LUT( (std::istream&)iss3 ) );
153  oss.str("");
154 
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; // hardcode max bits for data
157  for(unsigned int i=0; i<etSumXPUSLUT.size(); i++) oss << i << " " << etSumXPUSLUT[i] << std::endl;
158 
159  std::istringstream iss4( oss.str() );
160  paramsHelper.setEtSumXPUSLUT( l1t::LUT( (std::istream&)iss4 ) );
161  oss.str("");
162 
163  paramsHelper.setEgMaxPtHOverE((conf["egammaRelaxationThreshold"].getValue<int>()));
164  paramsHelper.setEgEtaCut((conf["egammaMaxEta"].getValue<int>()));
165 
166 
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; // hardcode max bits for data
169  for(unsigned int i=0; i<egCalibrationLUT.size(); i++) oss << i << " " << egCalibrationLUT[i] << std::endl;
170 
171  std::istringstream iss5( oss.str() );
172  paramsHelper.setEgCalibrationLUT( l1t::LUT( (std::istream&)iss5 ) );
173  oss.str("");
174 
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; // hardcode max bits for data
177  for(unsigned int i=0; i<egIsolationLUT.size(); i++) oss << i << " " << egIsolationLUT[i] << std::endl;
178 
179  std::istringstream iss6( oss.str() );
180  paramsHelper.setEgIsolationLUT( l1t::LUT( (std::istream&)iss6 ) );
181  oss.str("");
182 
183  //std::cout<<"egammaIsoLUT: "<<std::endl;
184  //for(unsigned int i=0; i<paramsHelper.egIsolationLUT()->maxSize(); i++) std::cout << std::setprecision(14) << paramsHelper.egIsolationLUT()->data(i) <<", ";
185  //std::cout << std::endl;
186 
187  paramsHelper.setIsoTauEtaMax((conf["tauMaxEta"].getValue<int>()));
188 
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; // hardcode max bits for data
191  for(unsigned int i=0; i<tauCalibrationLUT.size(); i++) oss << i << " " << tauCalibrationLUT[i] << std::endl;
192 
193  std::istringstream iss7( oss.str() );
194  paramsHelper.setTauCalibrationLUT(l1t::LUT( (std::istream&)iss7 ));
195  oss.str("");
196 
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; // hardcode max bits for data
199  for(unsigned int i=0; i<tauIsolationLUT.size(); i++) oss << i << " " << tauIsolationLUT[i] << std::endl;
200 
201  std::istringstream iss8( oss.str() );
202  paramsHelper.setTauIsolationLUT( l1t::LUT((std::istream&)iss8 ) );
203  oss.str("");
204 
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; // hardcode max bits for data
207  for(unsigned int i=0; i<tauIsolationLUT2.size(); i++) oss << i << " " << tauIsolationLUT2[i] << std::endl;
208 
209  std::istringstream iss9( oss.str() );
210  paramsHelper.setTauIsolationLUT2( l1t::LUT( (std::istream&)iss9 ) );
211  oss.str("");
212 
213  return true;
214 }
215 
217 
218 std::shared_ptr<l1t::CaloParams> L1TCaloParamsOnlineProd::newObject(const std::string& objectKey, const L1TCaloParamsO2ORcd& record) {
219  using namespace edm::es;
220 
221  const L1TCaloStage2ParamsRcd& baseRcd = record.template getRecord< L1TCaloStage2ParamsRcd >() ;
222  edm::ESHandle< l1t::CaloParams > baseSettings ;
223  baseRcd.get( baseSettings ) ;
224 
225 
226  if( objectKey.empty() ){
227  edm::LogError( "L1-O2O: L1TCaloParamsOnlineProd" ) << "Key is empty, returning empty l1t::CaloParams";
228  throw std::runtime_error("Empty objectKey");
230  }
231 
232  std::string tscKey = objectKey.substr(0, objectKey.find(":") );
233  std::string rsKey = objectKey.substr( objectKey.find(":")+1, std::string::npos );
234 
235 
236  std::string stage2Schema = "CMS_TRG_L1_CONF" ;
237  edm::LogInfo( "L1-O2O: L1TCaloParamsOnlineProd" ) << "Producing L1TCaloParamsOnlineProd with TSC key =" << tscKey << " and RS key = " << rsKey ;
238 
239  // first, find keys for the algo and RS tables
240 
241  // ALGO
242  std::vector< std::string > queryStrings ;
243  queryStrings.push_back( "CALOL1_KEY" ) ;
244  queryStrings.push_back( "CALOL2_KEY" ) ;
245 
246  std::string calol1_conf_key, calol2_conf_key;
247 
248  // select CALOL1_KEY,CALOL2_KEY from CMS_TRG_L1_CONF.L1_TRG_CONF_KEYS where ID = tscKey ;
249  l1t::OMDSReader::QueryResults queryResult =
250  m_omdsReader.basicQuery( queryStrings,
251  stage2Schema,
252  "L1_TRG_CONF_KEYS",
253  "L1_TRG_CONF_KEYS.ID",
255  ) ;
256 
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");
261  }
262 
263  if( !queryResult.fillVariable( "CALOL1_KEY", calol1_conf_key) ) calol1_conf_key = "";
264  if( !queryResult.fillVariable( "CALOL2_KEY", calol2_conf_key) ) calol2_conf_key = "";
265 
266  // At this point we have two config keys; now query the payloads' keys for these config keys
267  std::string calol1_algo_key, calol2_algo_key;
268  queryStrings.clear();
269  queryStrings.push_back( "ALGO" );
270 
271  // query ALGO configurations
272  queryResult =
273  m_omdsReader.basicQuery( queryStrings,
274  stage2Schema,
275  "CALOL1_KEYS",
276  "CALOL1_KEYS.ID",
277  m_omdsReader.singleAttribute(calol1_conf_key)
278  ) ;
279 
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");
284  }
285 
286  if( !queryResult.fillVariable( "ALGO", calol1_algo_key ) ) calol1_algo_key = "";
287 
288  queryStrings.push_back( "HW" );
289 // No Layer2 for the moment
290  queryResult =
291  m_omdsReader.basicQuery( queryStrings,
292  stage2Schema,
293  "CALOL2_KEYS",
294  "CALOL2_KEYS.ID",
295  m_omdsReader.singleAttribute(calol2_conf_key)
296  ) ;
297 
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");
302  }
303 
304  std::string calol2_hw_key;
305  if( !queryResult.fillVariable( "ALGO", calol2_algo_key ) ) calol2_algo_key = "";
306  if( !queryResult.fillVariable( "HW", calol2_hw_key ) ) calol2_hw_key = "";
307 
308 
309  // Now querry the actual payloads
310  enum {kCONF=0, kRS, kHW, NUM_TYPES};
311  std::map<std::string,std::string> payloads[NUM_TYPES]; // associates key -> XML payload for a given type of payloads
312  std::string xmlPayload;
313 
314  queryStrings.clear();
315  queryStrings.push_back( "CONF" );
316 
317  // query CALOL1 ALGO configuration
318  queryResult =
319  m_omdsReader.basicQuery( queryStrings,
320  stage2Schema,
321  "CALOL1_ALGO",
322  "CALOL1_ALGO.ID",
323  m_omdsReader.singleAttribute(calol1_algo_key)
324  ) ;
325 
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");
330  }
331 
332  if( !queryResult.fillVariable( "CONF", xmlPayload ) ) xmlPayload = "";
333  // remember ALGO configuration
334  payloads[kCONF][calol1_algo_key.append("_L1")] = xmlPayload;
335 
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;
337 
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" );
345 
346  // No CALOL2 ALGO configuration for the moment
347  queryResult =
348  m_omdsReader.basicQuery( queryStrings,
349  stage2Schema,
350  "CALOL2_ALGO_KEYS",
351  "CALOL2_ALGO_KEYS.ID",
352  m_omdsReader.singleAttribute(calol2_algo_key)
353  ) ;
354 
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");
359  }
360 
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 = "";
367 
368  queryStrings.clear();
369  queryStrings.push_back( "CONF" );
370 
371  // query CALOL2 ALGO configuration
372  queryResult =
373  m_omdsReader.basicQuery( queryStrings,
374  stage2Schema,
375  "CALOL2_ALGO",
376  "CALOL2_ALGO.ID",
377  m_omdsReader.singleAttribute(calol2_demux_key)
378  ) ;
379 
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");
384  }
385 
386  if( !queryResult.fillVariable( "CONF", xmlPayload ) ) xmlPayload = "";
387  // remember ALGO configuration
388  payloads[kCONF][calol2_demux_key.append("_L2")] = xmlPayload;
389 
390  // query CALOL2 ALGO configuration
391  queryResult =
392  m_omdsReader.basicQuery( queryStrings,
393  stage2Schema,
394  "CALOL2_ALGO",
395  "CALOL2_ALGO.ID",
396  m_omdsReader.singleAttribute(calol2_mps_common_key)
397  ) ;
398 
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");
403  }
404 
405  if( !queryResult.fillVariable( "CONF", xmlPayload ) ) xmlPayload = "";
406  // remember ALGO configuration
407  payloads[kCONF][calol2_mps_common_key.append("_L2")] = xmlPayload;
408 
409  // query CALOL2 ALGO configuration
410  queryResult =
411  m_omdsReader.basicQuery( queryStrings,
412  stage2Schema,
413  "CALOL2_ALGO",
414  "CALOL2_ALGO.ID",
415  m_omdsReader.singleAttribute(calol2_mps_jet_key)
416  ) ;
417 
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");
422  }
423 
424  if( !queryResult.fillVariable( "CONF", xmlPayload ) ) xmlPayload = "";
425  // remember ALGO configuration
426  payloads[kCONF][calol2_mps_jet_key.append("_L2")] = xmlPayload;
427 
428  // query CALOL2 ALGO configuration
429  queryResult =
430  m_omdsReader.basicQuery( queryStrings,
431  stage2Schema,
432  "CALOL2_ALGO",
433  "CALOL2_ALGO.ID",
434  m_omdsReader.singleAttribute(calol2_mp_egamma_key)
435  ) ;
436 
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");
441  }
442 
443  if( !queryResult.fillVariable( "CONF", xmlPayload ) ) xmlPayload = "";
444  // remember ALGO configuration
445  payloads[kCONF][calol2_mp_egamma_key.append("_L2")] = xmlPayload;
446 
447  // query CALOL2 ALGO configuration
448  queryResult =
449  m_omdsReader.basicQuery( queryStrings,
450  stage2Schema,
451  "CALOL2_ALGO",
452  "CALOL2_ALGO.ID",
453  m_omdsReader.singleAttribute(calol2_mp_sum_key)
454  ) ;
455 
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");
460  }
461 
462  if( !queryResult.fillVariable( "CONF", xmlPayload ) ) xmlPayload = "";
463  // remember ALGO configuration
464  payloads[kCONF][calol2_mp_sum_key.append("_L2")] = xmlPayload;
465 
466  // query CALOL2 ALGO configuration
467  queryResult =
468  m_omdsReader.basicQuery( queryStrings,
469  stage2Schema,
470  "CALOL2_ALGO",
471  "CALOL2_ALGO.ID",
472  m_omdsReader.singleAttribute(calol2_mp_tau_key)
473  ) ;
474 
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");
479  }
480 
481  if( !queryResult.fillVariable( "CONF", xmlPayload ) ) xmlPayload = "";
482  // remember ALGO configuration
483  payloads[kCONF][calol2_mp_tau_key.append("_L2")] = xmlPayload;
484 
485  queryResult =
486  m_omdsReader.basicQuery( queryStrings,
487  stage2Schema,
488  "CALOL2_HW",
489  "CALOL2_HW.ID",
490  m_omdsReader.singleAttribute(calol2_hw_key)
491  ) ;
492 
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");
496  }
497 
498  if( !queryResult.fillVariable( "CONF", xmlPayload ) ) xmlPayload = "";
499  // remember HW configuration
500  payloads[kHW][calol2_hw_key] = xmlPayload;
501 
502  // for debugging purposes dump the configs to local files
503  for(auto &conf : payloads[kCONF]){
504  std::ofstream output(std::string("/tmp/").append(conf.first.substr(0,conf.first.find("/"))).append(".xml"));
505  output<<conf.second;
506  output.close();
507  }
508  for(auto &conf : payloads[kHW]){
509  std::ofstream output(std::string("/tmp/").append(conf.first.substr(0,conf.first.find("/"))).append(".xml"));
510  output<<conf.second;
511  output.close();
512  }
513 
514 
515  l1t::XmlConfigReader xmlReader1;
516  xmlReader1.readDOMFromString( payloads[kCONF][calol1_algo_key] );
517 
518  l1t::TrigSystem calol1;
519  calol1.addProcRole("processors", "processors");
520  xmlReader1.readRootElement( calol1, "calol1" );
521  calol1.setConfigured();
522 
523  std::map<std::string, l1t::Setting> calol1_conf = calol1.getSettings("processors");
524  std::map<std::string, l1t::Mask> calol1_rs ;//= calol1.getMasks ("processors");
525 
526  l1t::TrigSystem calol2;
527 // calol2.addProcRole("processors", "MainProcessor");
528 
529  l1t::XmlConfigReader xmlReader2;
530  xmlReader2.readDOMFromString( payloads[kHW].begin()->second );
531  xmlReader2.readRootElement( calol2, "calol2" );
532 
533  for(auto &conf : payloads[kCONF]){
534  if( conf.first.find("_L2") != std::string::npos ){
535  xmlReader2.readDOMFromString( conf.second );
536  xmlReader2.readRootElement( calol2, "calol2" );
537  }
538  }
539 
540 // calol2.setSystemId("calol2");
541  calol2.setConfigured();
542 
543  // Perhaps layer 2 has to look at settings for demux and mp separately? // => No demux settings required
544  std::map<std::string, l1t::Setting> calol2_conf = calol2.getSettings("MP1");
545  std::map<std::string, l1t::Mask> calol2_rs ;//= calol2.getMasks ("processors");
546 
547  l1t::CaloParamsHelper m_params_helper(*(baseSettings.product()));
548 
549  readCaloLayer1OnlineSettings(m_params_helper, calol1_conf, calol1_rs);
550  readCaloLayer2OnlineSettings(m_params_helper, calol2_conf, calol2_rs);
551 
552  std::shared_ptr< l1t::CaloParams > retval = std::make_shared< l1t::CaloParams >( m_params_helper ) ;
553  return retval;
554 }
555 
556 //define this as a plug-in
558 
void setEtSumEtaMax(unsigned isum, int eta)
int i
Definition: DBlmapReader.cc:9
void setLayer1HCalScaleETBins(const std::vector< int > params)
void setIsoTauEtaMax(int value)
void setEgNeighbourThreshold(double thresh)
const QueryResults singleAttribute(const T &data) const
Definition: OMDSReader.h:295
void setTauCalibrationLUT(const l1t::LUT &lut)
JetCorrectorParameters::Record record
Definition: classes.h:7
bool readCaloLayer1OnlineSettings(l1t::CaloParamsHelper &paramsHelper, 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)
virtual std::shared_ptr< l1t::CaloParams > newObject(const std::string &objectKey, const L1TCaloParamsO2ORcd &record) override
void setEtSumXPUSLUT(const l1t::LUT &lut)
void setEgCalibrationLUT(const l1t::LUT &lut)
L1TCaloParamsOnlineProd(const edm::ParameterSet &)
void setEtSumEttPUSLUT(const l1t::LUT &lut)
void setEgHOverEcutBarrel(int cut)
U second(std::pair< T, U > const &p)
void addProcRole(const std::string &processor, const std::string &role)
Definition: TrigSystem.cc:39
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="")
Definition: OMDSReader.cc:86
void setEtSumEtThreshold(unsigned isum, double thresh)
void setLayer1ECalScaleETBins(const std::vector< int > params)
void setTauSeedThreshold(double thresh)
void setEgEtaCut(int mask)
bool readCaloLayer2OnlineSettings(l1t::CaloParamsHelper &paramsHelper, std::map< std::string, l1t::Setting > &conf, std::map< std::string, l1t::Mask > &)
Definition: LUT.h:29
void setLayer1HCalScaleFactors(const std::vector< double > params)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
void setLayer1HFScaleFactors(const std::vector< double > params)
void setJetSeedThreshold(double thresh)
void setEgMaxPtHOverE(double thresh)
#define begin
Definition: vmac.h:30
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)
void setEtSumEcalSumPUSLUT(const l1t::LUT &lut)