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