CMS 3D CMS Logo

DTConfigDBProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: DTTPGConfigProducers
4 // Class: DTConfigDBProducer
5 //
14 //
15 // Original Author: Sara Vanini
16 // Created: September 2008
17 //
18 //
19 // system include files
20 #include <memory>
21 #include <vector>
22 #include <iomanip>
23 #include <iostream>
24 
25 // user include files
33 
35 
38 
42 
49 
51 
52 using std::cout;
53 using std::endl;
54 using std::unique_ptr;
55 using std::vector;
56 
57 //
58 // class declaration
59 //
60 
62 public:
65 
67  ~DTConfigDBProducer() override;
68 
70  std::unique_ptr<DTConfigManager> produce(const DTConfigManagerRcd &);
71 
72 private:
74  void readDBPedestalsConfig(const DTConfigManagerRcd &iRecord, DTConfigManager &dttpgConfig);
75 
77  int readDTCCBConfig(const DTConfigManagerRcd &iRecord, DTConfigManager &dttpgConfig);
78 
80  void configFromCfg(DTConfigManager &dttpgConfig);
81 
84 
86  int checkDTCCBConfig(DTConfigManager &dttpgConfig);
87 
88  std::string mapEntryName(const DTChamberId &chambid) const;
89 
90  // ----------member data ---------------------------
92 
97 
98  // debug flags
99  bool m_debugDB;
104  bool m_debugTU;
105  bool m_debugSC;
108 
109  // general DB requests
110  bool m_UseT0;
111 
112  bool cfgConfig;
113 
115 
117 };
118 
119 //
120 // constructors and destructor
121 //
122 
124  // tell the framework what record is being produced
126 
127  cfgConfig = p.getParameter<bool>("cfgConfig");
128 
129  // get and store parameter set and config manager pointer
130  m_ps = p;
131 
132  // debug flags
133  m_debugDB = p.getParameter<bool>("debugDB");
134  m_debugBti = p.getParameter<int>("debugBti");
135  m_debugTraco = p.getParameter<int>("debugTraco");
136  m_debugTSP = p.getParameter<bool>("debugTSP");
137  m_debugTST = p.getParameter<bool>("debugTST");
138  m_debugTU = p.getParameter<bool>("debugTU");
139  m_debugSC = p.getParameter<bool>("debugSC");
140  m_debugLUTs = p.getParameter<bool>("debugLUTs");
141  m_debugPed = p.getParameter<bool>("debugPed");
142 
143  m_UseT0 = p.getParameter<bool>("UseT0"); // CB check for a better way to do it
144 
145  if (not cfgConfig) {
146  m_dttpgParamsToken = cc.consumes();
147  m_ccb_confToken = cc.consumes();
148  m_keyListToken = cc.consumes();
149  if (m_UseT0) {
150  m_t0iToken = cc.consumes();
151  }
152  }
153 }
154 
156 
157 //
158 // member functions
159 //
160 
161 std::unique_ptr<DTConfigManager> DTConfigDBProducer::produce(const DTConfigManagerRcd &iRecord) {
162  using namespace edm;
163 
164  std::unique_ptr<DTConfigManager> dtConfig = std::make_unique<DTConfigManager>();
165  DTConfigManager &dttpgConfig = *(dtConfig.get());
166 
167  // DB specific requests
168  bool tracoLutsFromDB = m_ps.getParameter<bool>("TracoLutsFromDB");
169  bool useBtiAcceptParam = m_ps.getParameter<bool>("UseBtiAcceptParam");
170 
171  // set specific DB requests
172  dttpgConfig.setLutFromDB(tracoLutsFromDB);
173  dttpgConfig.setUseAcceptParam(useBtiAcceptParam);
174 
175  // set debug
176  edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");
177  bool dttpgdebug = conf_ps.getUntrackedParameter<bool>("Debug");
178  dttpgConfig.setDTTPGDebug(dttpgdebug);
179 
180  int code;
181  if (cfgConfig) {
182  dttpgConfig.setLutFromDB(false);
183  configFromCfg(dttpgConfig);
184  code = 2;
185  } else {
186  code = readDTCCBConfig(iRecord, dttpgConfig);
187  readDBPedestalsConfig(iRecord, dttpgConfig);
188  // 110628 SV add config check
189  if (code != -1 && checkDTCCBConfig(dttpgConfig) > 0)
190  code = -1;
191  }
192  // cout << "DTConfigDBProducer::produce CODE " << code << endl;
193  if (code == -1) {
194  dttpgConfig.setCCBConfigValidity(false);
195  } else if (code == 2) {
196  LogVerbatim("DTTPG") << "DTConfigDBProducer::produce : Trivial : " << endl
197  << "configurations has been read from cfg" << endl;
198  } else if (code == 0) {
199  LogVerbatim("DTTPG") << "DTConfigDBProducer::produce : " << endl
200  << "Configurations successfully read from OMDS" << endl;
201  } else {
202  LogProblem("DTTPG") << "DTConfigDBProducer::produce : " << endl << "Wrong configuration return CODE" << endl;
203  }
204 
205  return dtConfig;
206 }
207 
209  const auto &dttpgParams = iRecord.get(m_dttpgParamsToken);
210 
211  DTConfigPedestals pedestals;
212  pedestals.setDebug(m_debugPed);
213 
214  if (m_UseT0) {
215  pedestals.setUseT0(true);
216  pedestals.setES(&dttpgParams, &iRecord.get(m_t0iToken));
217  // cout << "checkDTCCBConfig CODE is " << checkDTCCBConfig() << endl;
218 
219  } else {
220  pedestals.setUseT0(false);
221  pedestals.setES(&dttpgParams);
222  }
223 
224  dttpgConfig.setDTConfigPedestals(pedestals);
225 }
226 
228  // 110627 SV test if configuration from CCB has correct number of chips,
229  // return error code:
230  // check_cfg_code = 1 : NO correct BTI number
231  // check_cfg_code = 2 : NO correct TRACO number
232  // check_cfg_code = 3 : NO correct valid TSS number
233  // check_cfg_code = 4 : NO correct valid TSM number
234 
235  int check_cfg_code = 0;
236 
237  // do not take chambers from MuonGeometryRecord to avoid geometry dependency
238  for (int iwh = -2; iwh <= 2; iwh++) {
239  for (int ise = 1; ise <= 12; ise++) {
240  for (int ist = 1; ist <= 4; ist++) {
241  check_cfg_code = 0;
242  DTChamberId chid(iwh, ist, ise);
243 
244  // retrive number of configurated chip
245  int nbti = dttpgConfig.getDTConfigBtiMap(chid).size();
246  int ntraco = dttpgConfig.getDTConfigTracoMap(chid).size();
247  int ntss = dttpgConfig.getDTConfigTSPhi(chid)->nValidTSS();
248  int ntsm = dttpgConfig.getDTConfigTSPhi(chid)->nValidTSM();
249 
250  // check BTIs
251  if ((ist == 1 && nbti != 168) || (ist == 2 && nbti != 192) || (ist == 3 && nbti != 224) ||
252  (ist == 4 &&
253  (ise == 1 || ise == 2 || ise == 3 || ise == 5 || ise == 6 || ise == 7 || ise == 8 || ise == 12) &&
254  nbti != 192) ||
255  (ist == 4 && (ise == 9 || ise == 11) && nbti != 96) || (ist == 4 && ise == 10 && nbti != 128) ||
256  (ist == 4 && ise == 4 && nbti != 160)) {
257  check_cfg_code = 1;
258  return check_cfg_code;
259  }
260 
261  // check TRACOs
262  if ((ist == 1 && ntraco != 13) || (ist == 2 && ntraco != 16) || (ist == 3 && ntraco != 20) ||
263  (ist == 4 &&
264  (ise == 1 || ise == 2 || ise == 3 || ise == 5 || ise == 6 || ise == 7 || ise == 8 || ise == 12) &&
265  ntraco != 24) ||
266  (ist == 4 && (ise == 9 || ise == 11) && ntraco != 12) || (ist == 4 && ise == 10 && ntraco != 16) ||
267  (ist == 4 && ise == 4 && ntraco != 20)) {
268  check_cfg_code = 2;
269  return check_cfg_code;
270  }
271 
272  // check TSS
273  if ((ist == 1 && ntss != 4) || (ist == 2 && ntss != 4) || (ist == 3 && ntss != 5) ||
274  (ist == 4 &&
275  (ise == 1 || ise == 2 || ise == 3 || ise == 5 || ise == 6 || ise == 7 || ise == 8 || ise == 12) &&
276  ntss != 6) ||
277  (ist == 4 && (ise == 9 || ise == 11) && ntss != 3) || (ist == 4 && ise == 10 && ntss != 4) ||
278  (ist == 4 && ise == 4 && ntss != 5)) {
279  check_cfg_code = 3;
280  return check_cfg_code;
281  }
282 
283  // check TSM
284  if (ntsm != 1) {
285  check_cfg_code = 4;
286  return check_cfg_code;
287  }
288 
289  // if(check_cfg_code){
290  // cout << "nbti " << nbti << " ntraco " << ntraco << " ntss " << ntss
291  // << " ntsm " << ntsm << endl; cout << "Check: ch " << ist << " sec "
292  // << ise << " wh " << iwh << " == >check_cfg_code " << check_cfg_code
293  // << endl;
294  //}
295  } // end st loop
296  } // end sec loop
297 
298  // SV MB4 has two more chambers
299  for (int ise = 13; ise <= 14; ise++) {
300  DTChamberId chid(iwh, 4, ise);
301 
302  int nbti = dttpgConfig.getDTConfigBtiMap(chid).size();
303  int ntraco = dttpgConfig.getDTConfigTracoMap(chid).size();
304  int ntss = dttpgConfig.getDTConfigTSPhi(chid)->nValidTSS();
305  int ntsm = dttpgConfig.getDTConfigTSPhi(chid)->nValidTSM();
306 
307  if ((ise == 13 && nbti != 160) || (ise == 14 && nbti != 128)) {
308  check_cfg_code = 1;
309  return check_cfg_code;
310  }
311  if ((ise == 13 && ntraco != 20) || (ise == 14 && ntraco != 16)) {
312  check_cfg_code = 2;
313  return check_cfg_code;
314  }
315  if ((ise == 13 && ntss != 5) || (ise == 14 && ntss != 4)) {
316  check_cfg_code = 3;
317  return check_cfg_code;
318  }
319  if (ntsm != 1) {
320  check_cfg_code = 4;
321  return check_cfg_code;
322  }
323  // if(check_cfg_code){
324  // cout << "nbti " << nbti << " ntraco " << ntraco << " ntss " << ntss <<
325  // " ntsm " << ntsm << endl; cout << "Check: ch " << 4 << " sec " << ise
326  // << " wh " << iwh << " == >check_cfg_code " << check_cfg_code << endl;
327  //}
328  } // end sec 13 14
329 
330  } // end wh loop
331 
332  // cout << "CheckDTCCB: config OK! check_cfg_code = " << check_cfg_code <<
333  // endl;
334  return check_cfg_code;
335 }
336 
338  using namespace edm::eventsetup;
339 
340  // initialize CCB validity flag
341  dttpgConfig.setCCBConfigValidity(true);
342 
343  // get DTCCBConfigRcd from DTConfigManagerRcd (they are dependent records)
344  const auto &ccb_conf = iRecord.get(m_ccb_confToken);
345  int ndata = std::distance(ccb_conf.begin(), ccb_conf.end());
346 
347  const DTKeyedConfigListRcd &keyRecord = iRecord.getRecord<DTKeyedConfigListRcd>();
348 
349  if (m_debugDB) {
350  cout << ccb_conf.version() << endl;
351  cout << ndata << " data in the container" << endl;
352  }
353 
355  unsigned int currValidityStart = iov.first().eventID().run();
356  unsigned int currValidityEnd = iov.last().eventID().run();
357 
358  if (m_debugDB)
359  cout << "valid since run " << currValidityStart << " to run " << currValidityEnd << endl;
360 
361  // if there are no data in the container, configuration from cfg files...
362  if (ndata == 0) {
363  return -1;
364  }
365 
366  // get DTTPGMap for retrieving bti number and traco number
368 
369  // loop over chambers
370  DTCCBConfig::ccb_config_map configKeys(ccb_conf.configKeyMap());
371  DTCCBConfig::ccb_config_iterator iter = configKeys.begin();
372  DTCCBConfig::ccb_config_iterator iend = configKeys.end();
373 
374  // 110628 SV check that number of CCB is equal to total number of chambers
375  if (ccb_conf.configKeyMap().size() != 250) // check the number of chambers!!!
376  return -1;
377 
378  auto const &keyList = keyRecord.get(m_keyListToken);
379 
380  // read data from CCBConfig
381  while (iter != iend) {
382  // 110628 SV moved here from constructor, to check config consistency for
383  // EVERY chamber initialize flags to check if data are present in OMDS
384  flagDBBti = false;
385  flagDBTraco = false;
386  flagDBTSS = false;
387  flagDBTSM = false;
388  flagDBLUTS = false;
389 
390  // get chamber id
391  const DTCCBId &ccbId = iter->first;
392  if (m_debugDB)
393  cout << " Filling configuration for chamber : wh " << ccbId.wheelId << " st " << ccbId.stationId << " se "
394  << ccbId.sectorId << " -> " << endl;
395 
396  // get chamber type and id from ccbId
397  int mbtype = DTPosNegType::getCT(ccbId.wheelId, ccbId.sectorId, ccbId.stationId);
398  int posneg = DTPosNegType::getPN(ccbId.wheelId, ccbId.sectorId, ccbId.stationId);
399  if (m_debugDB)
400  cout << "Chamber type : " << mbtype << " posneg : " << posneg << endl;
401  DTChamberId chambid(ccbId.wheelId, ccbId.stationId, ccbId.sectorId);
402 
403  // get brick identifiers list
404  const std::vector<int> &ccbConf = iter->second;
405  std::vector<int>::const_iterator cfgIter = ccbConf.begin();
406  std::vector<int>::const_iterator cfgIend = ccbConf.end();
407 
408  // TSS-TSM buffers
409  unsigned short int tss_buffer[7][31];
410  unsigned short int tsm_buffer[9];
411  int ntss = 0;
412 
413  // loop over configuration bricks
414  while (cfgIter != cfgIend) {
415  // get brick identifier
416  int id = *cfgIter++;
417  if (m_debugDB)
418  cout << " BRICK " << id << endl;
419 
420  // create strings list
421  std::vector<std::string> list;
422 
423  cfgCache.getData(keyList, id, list);
424 
425  // loop over strings
426  std::vector<std::string>::const_iterator s_iter = list.begin();
427  std::vector<std::string>::const_iterator s_iend = list.end();
428  while (s_iter != s_iend) {
429  if (m_debugDB)
430  cout << " ----> " << *s_iter << endl;
431 
432  // copy string in unsigned int buffer
433  std::string str = *s_iter++;
434  unsigned short int buffer[100]; // 2 bytes
435  int c = 0;
436  const char *cstr = str.c_str();
437  const char *ptr = cstr + 2;
438  const char *end = cstr + str.length();
439  while (ptr < end) {
440  char c1 = *ptr++;
441  int i1 = 0;
442  if ((c1 >= '0') && (c1 <= '9'))
443  i1 = c1 - '0';
444  if ((c1 >= 'a') && (c1 <= 'f'))
445  i1 = 10 + c1 - 'a';
446  if ((c1 >= 'A') && (c1 <= 'F'))
447  i1 = 10 + c1 - 'A';
448  char c2 = *ptr++;
449  int i2 = 0;
450  if ((c2 >= '0') && (c2 <= '9'))
451  i2 = c2 - '0';
452  if ((c2 >= 'a') && (c2 <= 'f'))
453  i2 = 10 + c2 - 'a';
454  if ((c2 >= 'A') && (c2 <= 'F'))
455  i2 = 10 + c2 - 'A';
456  buffer[c] = (i1 * 16) + i2;
457  c++;
458  } // end loop over string
459 
460  // BTI configuration string
461  if (buffer[2] == 0x54) {
462  if (m_debugDB)
463  cout << "BTI STRING found in DB" << endl;
464 
465  // BTI configuration read for BTI
466  flagDBBti = true;
467 
468  // compute sl and bti number from board and chip
469  int brd = buffer[3]; // Board Nr.
470  int chip = buffer[4]; // Chip Nr.
471 
472  if (brd > 7) {
473  cout << "Not existing board ... " << brd << endl;
474  return -1; // Non-existing board
475  }
476  if (chip > 31) {
477  cout << "Not existing chip... " << chip << endl;
478  return -1; // Non existing chip
479  }
480 
481  // Is it Phi or Theta board?
482  bool ThetaSL, PhiSL;
483  PhiSL = false;
484  ThetaSL = false;
485  switch (mbtype) {
486  case 1: // mb1
487  if (brd == 6 || brd == 7) {
488  ThetaSL = true;
489  brd -= 6;
490  } else if ((brd < 3 && chip < 32) || (brd == 3 && chip < 8))
491  PhiSL = true;
492  break;
493  case 2: // mb2
494  if (brd == 6 || brd == 7) {
495  ThetaSL = true;
496  brd -= 6;
497  } else if (brd < 4 && chip < 32)
498  PhiSL = true;
499  break;
500  case 3: // mb3
501  if (brd == 6 || brd == 7) {
502  ThetaSL = true;
503  brd -= 6;
504  } else if (brd < 5 && chip < 32)
505  PhiSL = true;
506  break;
507  case 4: // mb4-s, mb4_8
508  if (brd < 6 && chip < 32)
509  PhiSL = true;
510  break;
511  case 5: // mb4-9
512  if (brd < 3 && chip < 32)
513  PhiSL = true;
514  break;
515  case 6: // mb4-4
516  if (brd < 5 && chip < 32)
517  PhiSL = true;
518  break;
519  case 7: // mb4-10
520  if (brd < 4 && chip < 32)
521  PhiSL = true;
522  break;
523  }
524  if (!PhiSL && !ThetaSL) {
525  cout << "MB type " << mbtype << endl;
526  cout << "Board " << brd << " chip " << chip << endl;
527  cout << "Not phi SL nor Theta SL" << endl;
528  return -1; // Not PhiSL nor ThetaSL
529  }
530 
531  // compute SL number and bti number
532  int isl = 0;
533  int ibti = 0;
534  if (PhiSL) {
535  if ((chip % 8) < 4)
536  isl = 1; // Phi1
537  else
538  isl = 3; // Phi2
539  ibti = brd * 16 + (int)(chip / 8) * 4 + (chip % 4);
540  } else if (ThetaSL) {
541  isl = 2; // Theta
542  if ((chip % 8) < 4)
543  ibti = brd * 32 + chip - 4 * (int)(chip / 8);
544  else
545  ibti = brd * 32 + chip + 12 - 4 * (int)(chip / 8);
546  }
547 
548  // BTI config constructor from strings
549  DTConfigBti bticonf(m_debugBti, buffer);
550 
551  dttpgConfig.setDTConfigBti(DTBtiId(chambid, isl, ibti + 1), bticonf);
552 
553  if (m_debugDB)
554  cout << "Filling BTI config for chamber : wh " << chambid.wheel() << ", st " << chambid.station() << ", se "
555  << chambid.sector() << "... sl " << isl << ", bti " << ibti + 1 << endl;
556  }
557 
558  // TRACO configuration string
559  if (buffer[2] == 0x15) {
560  if (m_debugDB)
561  cout << "TRACO STRING found in DB" << endl;
562  // TRACO configuration read from OMDS
563  flagDBTraco = true;
564 
565  // TRACO config constructor from strings
566  int traco_brd = buffer[3]; // Board Nr.;
567  int traco_chip = buffer[4]; // Chip Nr.;
568  int itraco = traco_brd * 4 + traco_chip + 1;
569  DTConfigTraco tracoconf(m_debugTraco, buffer);
570  dttpgConfig.setDTConfigTraco(DTTracoId(chambid, itraco), tracoconf);
571 
572  if (m_debugDB)
573  cout << "Filling TRACO config for chamber : wh " << chambid.wheel() << ", st " << chambid.station()
574  << ", se " << chambid.sector() << ", board " << traco_brd << ", chip " << traco_chip << ", traco "
575  << itraco << endl;
576  }
577 
578  // TSS configuration string
579  if (buffer[2] == 0x16) {
580  if (m_debugDB)
581  cout << "TSS STRING found in DB" << endl;
582  // TSS configuration read from OMDS
583  flagDBTSS = true;
584 
585  unsigned short int itss = buffer[3];
586  for (int i = 0; i < 31; i++)
587  tss_buffer[itss][i] = buffer[i];
588  ntss++;
589  }
590 
591  // TSM configuration string
592  if (buffer[2] == 0x17) {
593  if (m_debugDB)
594  cout << "TSM STRING found in DB" << endl;
595 
596  // TSM configuration read from OMDS
597  flagDBTSM = true;
598 
599  for (int i = 0; i < 9; i++)
600  tsm_buffer[i] = buffer[i];
601  }
602 
603  // LUT configuration string
604  if (buffer[2] == 0xA8) {
605  if (m_debugDB)
606  cout << "LUT STRING found in DB" << endl;
607 
608  // LUT parameters read from OMDS
609  flagDBLUTS = true;
610  DTConfigLUTs lutconf(m_debugLUTs, buffer);
611  // lutconf.setDebug(m_debugLUTs);
612  dttpgConfig.setDTConfigLUTs(chambid, lutconf);
613  }
614 
615  } // end string iteration
616  } // end brick iteration
617 
618  // TSS + TSM configurations are set in DTConfigTSPhi constructor
619  if (flagDBTSM && flagDBTSS) {
620  DTConfigTSPhi tsphiconf(m_debugTSP, tss_buffer, ntss, tsm_buffer);
621  dttpgConfig.setDTConfigTSPhi(chambid, tsphiconf);
622  }
623 
624  // get configuration for TSTheta, SC and TU from .cfg
625  edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");
626  edm::ParameterSet tups = conf_ps.getParameter<edm::ParameterSet>("TUParameters");
627 
628  // TSTheta configuration from .cfg
629  DTConfigTSTheta tsthetaconf(tups.getParameter<edm::ParameterSet>("TSThetaParameters"));
630  tsthetaconf.setDebug(m_debugTST);
631  dttpgConfig.setDTConfigTSTheta(chambid, tsthetaconf);
632 
633  // SC configuration from .cfg
634  DTConfigSectColl sectcollconf(conf_ps.getParameter<edm::ParameterSet>("SectCollParameters"));
635  sectcollconf.setDebug(m_debugSC);
636  dttpgConfig.setDTConfigSectColl(DTSectCollId(chambid.wheel(), chambid.sector()), sectcollconf);
637 
638  // TU configuration from .cfg
639  DTConfigTrigUnit trigunitconf(tups);
640  trigunitconf.setDebug(m_debugTU);
641  dttpgConfig.setDTConfigTrigUnit(chambid, trigunitconf);
642 
643  ++iter;
644 
645  // 110628 SV moved inside CCB loop to check for every chamber
646  // moved to exception handling no attempt to configure from cfg is DB is
647  // missing SV comment exception handling and activate flag in
648  // DTConfigManager
649  if (!flagDBBti || !flagDBTraco || !flagDBTSS || !flagDBTSM) {
650  return -1;
651  }
652  if (!flagDBLUTS && dttpgConfig.lutFromDB() == true) {
653  return -1;
654  }
655  } // end loop over CCB
656 
657  return 0;
658 }
659 
661  int iwh = chambid.wheel();
662  std::ostringstream os;
663  os << "wh";
664  if (iwh < 0) {
665  os << 'm' << -iwh;
666  } else {
667  os << iwh;
668  }
669  os << "st" << chambid.station() << "se" << chambid.sector();
670  return os.str();
671 }
672 
674  // ... but still set CCB validity flag to let the emulator run
675  dttpgConfig.setCCBConfigValidity(true);
676 
677  // create config classes&C.
678  edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");
680  bool dttpgdebug = conf_ps.getUntrackedParameter<bool>("Debug");
681  DTConfigSectColl sectcollconf(conf_ps.getParameter<edm::ParameterSet>("SectCollParameters"));
682  edm::ParameterSet tups = conf_ps.getParameter<edm::ParameterSet>("TUParameters");
683  DTConfigBti bticonf(tups.getParameter<edm::ParameterSet>("BtiParameters"));
684  DTConfigTraco tracoconf(tups.getParameter<edm::ParameterSet>("TracoParameters"));
685  DTConfigTSTheta tsthetaconf(tups.getParameter<edm::ParameterSet>("TSThetaParameters"));
686  DTConfigTSPhi tsphiconf(tups.getParameter<edm::ParameterSet>("TSPhiParameters"));
687  DTConfigTrigUnit trigunitconf(tups);
688  DTConfigLUTs lutconf(tups.getParameter<edm::ParameterSet>("LutParameters"));
689 
690  for (int iwh = -2; iwh <= 2; ++iwh) {
691  for (int ist = 1; ist <= 4; ++ist) {
692  for (int ise = 1; ise <= 12; ++ise) {
693  DTChamberId chambid(iwh, ist, ise);
694  vector<int> nmap = conf_map.getUntrackedParameter<vector<int>>(mapEntryName(chambid).c_str());
695 
696  if (dttpgdebug) {
697  cout << " Filling configuration for chamber : wh " << chambid.wheel() << ", st " << chambid.station()
698  << ", se " << chambid.sector() << endl;
699  }
700 
701  // fill the bti map
702  if (!flagDBBti) {
703  for (int isl = 1; isl <= 3; isl++) {
704  int ncell = nmap[isl - 1];
705  // cout << ncell <<" , ";
706  for (int ibti = 0; ibti < ncell; ibti++) {
707  dttpgConfig.setDTConfigBti(DTBtiId(chambid, isl, ibti + 1), bticonf);
708  if (dttpgdebug)
709  cout << "Filling BTI config for chamber : wh " << chambid.wheel() << ", st " << chambid.station()
710  << ", se " << chambid.sector() << "... sl " << isl << ", bti " << ibti + 1 << endl;
711  }
712  }
713  }
714 
715  // fill the traco map
716  if (!flagDBTraco) {
717  int ntraco = nmap[3];
718  // cout << ntraco << " }" << endl;
719  for (int itraco = 0; itraco < ntraco; itraco++) {
720  dttpgConfig.setDTConfigTraco(DTTracoId(chambid, itraco + 1), tracoconf);
721  if (dttpgdebug)
722  cout << "Filling TRACO config for chamber : wh " << chambid.wheel() << ", st " << chambid.station()
723  << ", se " << chambid.sector() << ", traco " << itraco + 1 << endl;
724  }
725  }
726 
727  // fill TS & TrigUnit
728  if (!flagDBTSS || !flagDBTSM) {
729  dttpgConfig.setDTConfigTSTheta(chambid, tsthetaconf);
730  dttpgConfig.setDTConfigTSPhi(chambid, tsphiconf);
731  dttpgConfig.setDTConfigTrigUnit(chambid, trigunitconf);
732  }
733  }
734  }
735  }
736 
737  for (int iwh = -2; iwh <= 2; ++iwh) {
738  for (int ise = 13; ise <= 14; ++ise) {
739  int ist = 4;
740  DTChamberId chambid(iwh, ist, ise);
741  vector<int> nmap = conf_map.getUntrackedParameter<vector<int>>(mapEntryName(chambid).c_str());
742 
743  if (dttpgdebug) {
744  cout << " Filling configuration for chamber : wh " << chambid.wheel() << ", st " << chambid.station() << ", se "
745  << chambid.sector() << endl;
746  }
747 
748  // fill the bti map
749  if (!flagDBBti) {
750  for (int isl = 1; isl <= 3; isl++) {
751  int ncell = nmap[isl - 1];
752  // cout << ncell <<" , ";
753  for (int ibti = 0; ibti < ncell; ibti++) {
754  dttpgConfig.setDTConfigBti(DTBtiId(chambid, isl, ibti + 1), bticonf);
755  if (dttpgdebug)
756  cout << "Filling BTI config for chamber : wh " << chambid.wheel() << ", st " << chambid.station()
757  << ", se " << chambid.sector() << "... sl " << isl << ", bti " << ibti + 1 << endl;
758  }
759  }
760  }
761 
762  // fill the traco map
763  if (!flagDBTraco) {
764  int ntraco = nmap[3];
765  // cout << ntraco << " }" << endl;
766  for (int itraco = 0; itraco < ntraco; itraco++) {
767  dttpgConfig.setDTConfigTraco(DTTracoId(chambid, itraco + 1), tracoconf);
768  if (dttpgdebug)
769  cout << "Filling TRACO config for chamber : wh " << chambid.wheel() << ", st " << chambid.station()
770  << ", se " << chambid.sector() << ", traco " << itraco + 1 << endl;
771  }
772  }
773 
774  // fill TS & TrigUnit
775  if (!flagDBTSS || !flagDBTSM) {
776  dttpgConfig.setDTConfigTSTheta(chambid, tsthetaconf);
777  dttpgConfig.setDTConfigTSPhi(chambid, tsphiconf);
778  dttpgConfig.setDTConfigTrigUnit(chambid, trigunitconf);
779  }
780  }
781  }
782 
783  // loop on Sector Collectors
784  for (int wh = -2; wh <= 2; wh++)
785  for (int se = 1; se <= 12; se++)
786  dttpgConfig.setDTConfigSectColl(DTSectCollId(wh, se), sectcollconf);
787 
788  // fake collection of pedestals
790 
791  return;
792 }
793 
795  DTTPGParameters *m_tpgParams = new DTTPGParameters();
796 
797  int counts = m_ps.getParameter<int>("bxOffset");
798  float fine = m_ps.getParameter<double>("finePhase");
799 
800  if (m_debugPed)
801  cout << "DTConfigTrivialProducer::buildPedestals()" << endl;
802 
803  // DTTPGParameters tpgParams;
804  for (int iwh = -2; iwh <= 2; ++iwh) {
805  for (int ist = 1; ist <= 4; ++ist) {
806  for (int ise = 1; ise <= 14; ++ise) {
807  if (ise > 12 && ist != 4)
808  continue;
809 
810  DTChamberId chId(iwh, ist, ise);
811  m_tpgParams->set(chId, counts, fine, DTTimeUnits::ns);
812  }
813  }
814  }
815 
816  DTConfigPedestals tpgPedestals;
817  tpgPedestals.setUseT0(false);
818  tpgPedestals.setES(m_tpgParams);
819 
820  return tpgPedestals;
821 }
822 
edm::eventsetup::DependentRecordImplementation::getRecord
const DepRecordT getRecord() const
Definition: DependentRecordImplementation.h:50
DTTPGParameters::set
int set(int wheelId, int stationId, int sectorId, int nc, float ph, DTTimeUnits::type unit)
Definition: DTTPGParameters.cc:123
DTConfigDBProducer::m_ccb_confToken
edm::ESGetToken< DTCCBConfig, DTCCBConfigRcd > m_ccb_confToken
Definition: DTConfigDBProducer.cc:95
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
DTCCBConfig::ccb_config_map
std::vector< std::pair< DTCCBId, std::vector< int > > > ccb_config_map
Definition: DTCCBConfig.h:71
mps_fire.i
i
Definition: mps_fire.py:428
DTTracoId
Definition: DTTracoId.h:34
DTCCBId
Definition: DTCCBConfig.h:37
MessageLogger.h
DTConfigSectColl
Definition: DTConfigSectColl.h:37
DTConfigDBProducer::configFromCfg
void configFromCfg(DTConfigManager &dttpgConfig)
SV for debugging purpose ONLY.
Definition: DTConfigDBProducer.cc:673
DTConfigTSPhi::nValidTSS
int nValidTSS() const
Number of correctly configured TSS.
Definition: DTConfigTSPhi.cc:439
ESHandle.h
DTConfigDBProducer::m_keyListToken
edm::ESGetToken< cond::persistency::KeyList, DTKeyedConfigListRcd > m_keyListToken
Definition: DTConfigDBProducer.cc:96
DTConfigTraco
Definition: DTConfigTraco.h:37
DTConfigManager::lutFromDB
bool lutFromDB() const
Lut from DB flag.
Definition: DTConfigManager.h:105
DTLayerId.h
DTConfigManager::setDTConfigLUTs
void setDTConfigLUTs(DTChamberId chambid, DTConfigLUTs conf)
Set DTConfigLUTs for desired chamber.
Definition: DTConfigManager.h:129
DTConfigDBProducer::m_debugTSP
bool m_debugTSP
Definition: DTConfigDBProducer.cc:102
edm
HLT enums.
Definition: AlignableModifier.h:19
DTPosNegType.h
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
DTKeyedConfigCache::getData
void getData(const cond::persistency::KeyList &keyList, int cfgId, std::vector< std::string > &list)
Definition: DTKeyedConfigCache.cc:115
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
edm::ValidityInterval
Definition: ValidityInterval.h:28
DTConfigDBProducer::produce
std::unique_ptr< DTConfigManager > produce(const DTConfigManagerRcd &)
ES produce method.
Definition: DTConfigDBProducer.cc:161
DTConfigManager::setDTConfigPedestals
void setDTConfigPedestals(DTConfigPedestals pedestals)
Set DTConfigPedestals configuration.
Definition: DTConfigManager.h:135
ESProducer.h
DTKeyedConfigListRcd.h
DTConfigDBProducer::m_debugTST
bool m_debugTST
Definition: DTConfigDBProducer.cc:103
edm::ValidityInterval::first
const IOVSyncValue & first() const
Definition: ValidityInterval.h:37
DTConfigDBProducer::m_UseT0
bool m_UseT0
Definition: DTConfigDBProducer.cc:110
DTConfigBti
Definition: DTConfigBti.h:36
DTConfigDBProducer::mapEntryName
std::string mapEntryName(const DTChamberId &chambid) const
Definition: DTConfigDBProducer.cc:660
DTConfigPedestals::setDebug
void setDebug(bool debug)
Set debug flag.
Definition: DTConfigPedestals.h:54
DTConfigManager.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
DTConfigPedestals::setES
void setES(DTTPGParameters const *tpgParams, DTT0 const *t0Params=nullptr)
Set parameters from ES.
Definition: DTConfigPedestals.cc:49
DTCCBId::wheelId
int wheelId
Definition: DTCCBConfig.h:42
DTConfigDBProducer::m_t0iToken
edm::ESGetToken< DTT0, DTT0Rcd > m_t0iToken
Definition: DTConfigDBProducer.cc:94
DTConfigDBProducer::m_debugBti
int m_debugBti
Definition: DTConfigDBProducer.cc:100
DTCCBConfigRcd
Definition: DTCCBConfigRcd.h:5
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
DTConfigDBProducer::m_debugSC
bool m_debugSC
Definition: DTConfigDBProducer.cc:105
DTConfigDBProducer
Definition: DTConfigDBProducer.cc:61
DTConfigManager::setDTConfigTSTheta
void setDTConfigTSTheta(DTChamberId chambid, DTConfigTSTheta conf)
Set DTConfigTSTheta for desired chip.
Definition: DTConfigManager.h:120
DTConfigManager::setDTConfigTSPhi
void setDTConfigTSPhi(DTChamberId chambid, DTConfigTSPhi conf)
Set DTConfigTSPhi for desired chip.
Definition: DTConfigManager.h:123
DTConfigManager::setDTConfigTrigUnit
void setDTConfigTrigUnit(DTChamberId chambid, DTConfigTrigUnit conf)
Set DTConfigTrigUnit for desired chamber.
Definition: DTConfigManager.h:126
DTConfigTrigUnit
Definition: DTConfigTrigUnit.h:36
DTConfigManager::setDTTPGDebug
void setDTTPGDebug(bool debug)
SetGlobalDebug flag.
Definition: DTConfigManager.h:138
DTConfigManager::setUseAcceptParam
void setUseAcceptParam(bool acceptparam)
Set the use of Bti acceptance parameters (LL,LH,CL,CH,RL,RH)
Definition: DTConfigManager.h:144
DTKeyedConfigCache
Definition: DTKeyedConfigCache.h:29
DTConfigPedestals::setUseT0
void setUseT0(bool useT0)
Set t0i subtraction.
Definition: DTConfigPedestals.h:51
edm::LogProblem
Log< level::Error, true > LogProblem
Definition: MessageLogger.h:131
DTTimeUnits::ns
Definition: DTTimeUnits.h:32
mps_fire.end
end
Definition: mps_fire.py:242
DTKeyedConfigListRcd
Definition: DTKeyedConfigListRcd.h:5
str
#define str(s)
Definition: TestProcessor.cc:52
DTSectCollId
Definition: DTSectCollId.h:18
DTConfigDBProducer::readDBPedestalsConfig
void readDBPedestalsConfig(const DTConfigManagerRcd &iRecord, DTConfigManager &dttpgConfig)
Read DTTPG pedestal configuration.
Definition: DTConfigDBProducer.cc:208
DTConfigManager::getDTConfigBtiMap
const std::map< DTBtiId, DTConfigBti > & getDTConfigBtiMap(DTChamberId) const
Get desired BTI configuration map for a given DTChamber.
Definition: DTConfigManager.cc:77
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:109
DTChamberId.h
DTConfigManager::setDTConfigTraco
void setDTConfigTraco(DTTracoId, DTConfigTraco)
Set DTConfigTraco for desired chip.
Definition: DTConfigManager.cc:183
DTConfigManagerRcd
Definition: DTConfigManagerRcd.h:31
edm::EventID::run
RunNumber_t run() const
Definition: EventID.h:38
DTConfigManager::setDTConfigBti
void setDTConfigBti(DTBtiId, DTConfigBti)
Set DTConfigBti for desired chip.
Definition: DTConfigManager.cc:178
DTConfigSectColl::setDebug
void setDebug(bool debug)
Set debug flag.
Definition: DTConfigSectColl.h:77
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTConfigManager::setLutFromDB
void setLutFromDB(bool lutFromDB)
Set lut from DB flag.
Definition: DTConfigManager.h:141
DTCCBId::stationId
int stationId
Definition: DTCCBConfig.h:43
DTPosNegType::getCT
static int getCT(int whe, int sec, int sta)
Definition: DTPosNegType.cc:90
edm::IOVSyncValue::eventID
const EventID & eventID() const
Definition: IOVSyncValue.h:40
edm::ParameterSet
Definition: ParameterSet.h:47
DTTPGParameters
Definition: DTTPGParameters.h:62
DTT0Rcd.h
DTConfigDBProducer::checkDTCCBConfig
int checkDTCCBConfig(DTConfigManager &dttpgConfig)
110629 SV function for CCB configuration check
Definition: DTConfigDBProducer.cc:227
DTKeyedConfig.h
DTPosNegType::getPN
static int getPN(int whe, int sec, int sta)
Definition: DTPosNegType.cc:81
DTConfigDBProducer::m_ps
edm::ParameterSet m_ps
Definition: DTConfigDBProducer.cc:91
createfilelist.int
int
Definition: createfilelist.py:10
DTConfigDBProducer::flagDBBti
bool flagDBBti
Definition: DTConfigDBProducer.cc:114
alignmentValidation.c1
c1
do drawing
Definition: alignmentValidation.py:1025
DTConfigDBProducer::m_debugDB
bool m_debugDB
Definition: DTConfigDBProducer.cc:99
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
DTConfigDBProducer::flagDBTSM
bool flagDBTSM
Definition: DTConfigDBProducer.cc:114
DTBtiId
Definition: DTBtiId.h:32
DTConfigDBProducer::~DTConfigDBProducer
~DTConfigDBProducer() override
Destructor.
Definition: DTConfigDBProducer.cc:155
DTConfigManager::setDTConfigSectColl
void setDTConfigSectColl(DTSectCollId sectcollid, DTConfigSectColl conf)
Set DTConfigSectColl for desired chip.
Definition: DTConfigManager.h:132
DTCCBId::sectorId
int sectorId
Definition: DTCCBConfig.h:44
DTConfigTSPhi
Definition: DTConfigTSPhi.h:36
cc
DTConfigManager
Definition: DTConfigManager.h:49
edm::ESGetToken< DTTPGParameters, DTTPGParametersRcd >
DTConfigDBProducer::m_dttpgParamsToken
edm::ESGetToken< DTTPGParameters, DTTPGParametersRcd > m_dttpgParamsToken
Definition: DTConfigDBProducer.cc:93
DTCCBConfigRcd.h
cms::cuda::device::unique_ptr
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
Definition: device_unique_ptr.h:33
DTConfigPedestals
Definition: DTConfigPedestals.h:36
DTConfigManager::getDTConfigTracoMap
const std::map< DTTracoId, DTConfigTraco > & getDTConfigTracoMap(DTChamberId) const
Get desired TRACO configuration map for a given DTChamber.
Definition: DTConfigManager.cc:106
DTTPGParametersRcd.h
DTConfigDBProducer::m_debugPed
bool m_debugPed
Definition: DTConfigDBProducer.cc:107
ModuleFactory.h
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
DTConfigDBProducer::m_debugTU
bool m_debugTU
Definition: DTConfigDBProducer.cc:104
DTConfigManagerRcd.h
DTConfigTSTheta
Definition: DTConfigTSTheta.h:35
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DTConfigDBProducer::cfgConfig
bool cfgConfig
Definition: DTConfigDBProducer.cc:112
DTConfigDBProducer::flagDBTraco
bool flagDBTraco
Definition: DTConfigDBProducer.cc:114
L1DTConfigParams_cff.DTTPGParameters
DTTPGParameters
Definition: L1DTConfigParams_cff.py:12
dqmiodumpmetadata.counts
counts
Definition: dqmiodumpmetadata.py:25
DTConfigDBProducer::DTConfigDBProducer
DTConfigDBProducer(const edm::ParameterSet &)
Constructor.
Definition: DTConfigDBProducer.cc:123
DTConfigManager::setCCBConfigValidity
void setCCBConfigValidity(bool CCBValid)
Set the flag for CCB configuration validity.
Definition: DTConfigManager.h:147
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
DTConfigDBProducer::m_debugLUTs
bool m_debugLUTs
Definition: DTConfigDBProducer.cc:106
Exception.h
DTConfigDBProducer::buildTrivialPedestals
DTConfigPedestals buildTrivialPedestals()
SV for debugging purpose ONLY.
Definition: DTConfigDBProducer.cc:794
DTConfigDBProducer::readDTCCBConfig
int readDTCCBConfig(const DTConfigManagerRcd &iRecord, DTConfigManager &dttpgConfig)
Read CCB string configuration.
Definition: DTConfigDBProducer.cc:337
edm::ESProducer
Definition: ESProducer.h:104
DTKeyedConfigCache.h
DTConfigTSPhi::nValidTSM
int nValidTSM() const
Number of correctly configured TSS.
Definition: DTConfigTSPhi.cc:447
DTConfigManager::getDTConfigTSPhi
const DTConfigTSPhi * getDTConfigTSPhi(DTChamberId) const
Get desired Trigger Server Phi configuration.
Definition: DTConfigManager.cc:127
DTChamberId
Definition: DTChamberId.h:14
ParameterSet.h
DTSuperLayerId.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
DTConfigLUTs
Definition: DTConfigLUTs.h:36
edm::eventsetup
Definition: ES_DDDetector.cc:16
DTConfigDBProducer::flagDBTSS
bool flagDBTSS
Definition: DTConfigDBProducer.cc:114
edm::eventsetup::EventSetupRecord::validityInterval
ValidityInterval validityInterval() const
Definition: EventSetupRecord.h:94
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7733
DTCCBConfig::ccb_config_iterator
ccb_config_map::const_iterator ccb_config_iterator
Definition: DTCCBConfig.h:72
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
DTConfigTrigUnit::setDebug
void setDebug(bool debug)
Set debug flag.
Definition: DTConfigTrigUnit.h:54
DTCCBConfig.h
DTConfigDBProducer::m_debugTraco
int m_debugTraco
Definition: DTConfigDBProducer.cc:101
DTConfigDBProducer::flagDBLUTS
bool flagDBLUTS
Definition: DTConfigDBProducer.cc:114
DTConfigDBProducer::cfgCache
DTKeyedConfigCache cfgCache
Definition: DTConfigDBProducer.cc:116