CMS 3D CMS Logo

List of all members | Static Public Member Functions | Static Private Member Functions
DTCompactMapWriter Class Reference

#include <DTCompactMapWriter.h>

Static Public Member Functions

static void buildSteering (std::istream &jobDesc)
 

Static Private Member Functions

static void appendROS (std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &ros_m, std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &ros_a)
 
static void cloneROS (std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &ros_m, std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &ros_a, int ddu_o, int ros_o, int ddu_f, int ros_f)
 
static void fillReadOutMap (int ros_count, std::map< DTROBCardId, int, DTROBCardCompare > &tdc_idm, std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &ddu_map, std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &ros_map)
 
static void fillROSMap (const std::string &map_file, int ddu, int ros, int whdef, int secdef, std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &ddu_map, std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &ros_map, int map_count, bool &write)
 
static void fillTDCMap (const std::string &map_file, int wheel, int sector, std::map< DTROBCardId, int, DTROBCardCompare > &tdc_idm, int stationId, int map_count, bool &write)
 

Detailed Description

Description: Class to build readout maps from map templates and lists

Date
2009/03/19 12:00:00
Revision
1.1
Author
Paolo Ronchese INFN Padova

Definition at line 40 of file DTCompactMapWriter.h.

Member Function Documentation

◆ appendROS()

void DTCompactMapWriter::appendROS ( std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &  ros_m,
std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &  ros_a 
)
staticprivate

Definition at line 422 of file DTCompactMapWriter.cc.

Referenced by fillReadOutMap().

423  {
424  std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare>::const_iterator ros_iter = ros_a.begin();
425  std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare>::const_iterator ros_iend = ros_a.end();
426  while (ros_iter != ros_iend)
427  ros_m.insert(*ros_iter++);
428  return;
429 }

◆ buildSteering()

void DTCompactMapWriter::buildSteering ( std::istream &  jobDesc)
static

Definition at line 221 of file DTCompactMapWriter.cc.

References fillReadOutMap(), fillROSMap(), fillTDCMap(), crabWrapper::key, hgcalTBTopologyTester_cfi::sector, relativeConstraints::station, AlCaHLTBitMon_QueryRunRegistry::string, heppy_batch::val, makeMuonMisalignmentScenario::wheel, and writeEcalDQMStatus::write.

221  {
222  // template maps and lists, name and type
223  std::string map_type("dummy_string");
224  std::string map_file("dummy_string");
225  std::string map_list("dummy_string");
226 
227  // ros-rob and tdc-cell maps
228  std::map<DTROBCardId, int, DTROBCardCompare> tdc_idm;
229  std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare> ros_map;
230  std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare> rob_map;
231 
232  int rob_count = 1;
233  int ros_count = 1;
234 
235  // parse job description file and loop over map templates and lists
236  bool jobEnd = false;
237  int max_line_length = 1000;
238  char* job_line = new char[max_line_length];
239  while (jobDesc.getline(job_line, max_line_length)) {
240  // parse job description line
241  char* ptr_line = job_line;
242  char* end_line = job_line + max_line_length;
243  while (ptr_line < end_line) {
244  // get description command key
245  // remove leading blanks
246  while (*ptr_line == ' ')
247  ptr_line++;
248  std::string key(ptr_line);
249  int off_blank = key.find(' ');
250  int off_equal = key.find('=');
251  if (off_equal < 0)
252  off_equal = max_line_length;
253  if (off_blank < 0)
254  off_blank = key.length();
255  int ioff = (off_blank < off_equal ? off_blank : off_equal);
256  key.erase(ioff++, key.length());
257  // go to command value
258  ptr_line += ++off_equal;
259  // exit loop at end of description file
260  if ((jobEnd = (key == "end")))
261  break;
262  // get description command value
263  while (*ptr_line == ' ')
264  ptr_line++;
265  std::string val(ptr_line);
266  int off_value = val.find(' ');
267  if ((off_value > 0) && (off_value < static_cast<int>(val.length())))
268  val.erase(off_value++, val.length());
269  // go to next token
270  ptr_line += off_value;
271  // set type, template or list file name
272  if (key == "type")
273  map_type = val;
274  if (key == "map")
275  map_file = val;
276  if (key == "list")
277  map_list = val;
278  }
279  if (jobEnd)
280  break;
281 
282  // open map list file
283  std::ifstream lfile(map_list.c_str());
284 
285  bool write;
286  // store TDC maps
287  if (map_type == "TDC") {
288  // loop over TDC map list for concerned wheels and sectors
289  int station = 0;
290  int wheel;
291  int sector;
292  write = true;
293  while (lfile >> wheel >> sector >> station)
294  fillTDCMap(map_file, wheel, sector, tdc_idm, station, rob_count, write);
295  ++rob_count;
296  }
297 
298  // store ROS maps
299  if (map_type == "ROS") {
300  // loop over ROS map list for concerned ddu, ros, wheel and sector
301  int ddu;
302  int ros;
303  int wheel;
304  int sector;
305  write = true;
306  while (lfile >> ddu >> ros >> wheel >> sector)
307  fillROSMap(map_file, ddu, ros, wheel, sector, ros_map, rob_map, ros_count, write);
308  ++ros_count;
309  }
310  }
311  delete[] job_line;
312 
313  // merge ROS and TDC maps
314  fillReadOutMap(ros_count, tdc_idm, ros_map, rob_map);
315 
316  return;
317 }
static void fillROSMap(const std::string &map_file, int ddu, int ros, int whdef, int secdef, std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &ddu_map, std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &ros_map, int map_count, bool &write)
static void fillReadOutMap(int ros_count, std::map< DTROBCardId, int, DTROBCardCompare > &tdc_idm, std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &ddu_map, std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &ros_map)
static void fillTDCMap(const std::string &map_file, int wheel, int sector, std::map< DTROBCardId, int, DTROBCardCompare > &tdc_idm, int stationId, int map_count, bool &write)

◆ cloneROS()

void DTCompactMapWriter::cloneROS ( std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &  ros_m,
std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &  ros_a,
int  ddu_o,
int  ros_o,
int  ddu_f,
int  ros_f 
)
staticprivate

Definition at line 400 of file DTCompactMapWriter.cc.

References DTROSChannelId::channelId(), DTROSChannelId::dduId(), and DTROSChannelId::rosId().

Referenced by fillReadOutMap().

405  {
406  std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare>::const_iterator ros_iter = ros_m.begin();
407  std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare>::const_iterator ros_iend = ros_m.end();
408  while (ros_iter != ros_iend) {
409  const std::pair<DTROSChannelId, DTROBCardId>& rosLink = *ros_iter++;
410  const DTROSChannelId& rosChannelId = rosLink.first;
411  const DTROBCardId& robCardId = rosLink.second;
412  if (rosChannelId.dduId() != ddu_o)
413  continue;
414  if (rosChannelId.rosId() != ros_o)
415  continue;
416  const DTROSChannelId rosChanNewId(ddu_f, ros_f, rosChannelId.channelId());
417  ros_a.insert(std::pair<DTROSChannelId, DTROBCardId>(rosChanNewId, robCardId));
418  }
419  return;
420 }
int channelId() const

◆ fillReadOutMap()

void DTCompactMapWriter::fillReadOutMap ( int  ros_count,
std::map< DTROBCardId, int, DTROBCardCompare > &  tdc_idm,
std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &  ddu_map,
std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &  ros_map 
)
staticprivate

Definition at line 431 of file DTCompactMapWriter.cc.

References appendROS(), DTROSChannelId::channelId(), RPCNoise_example::check, cloneROS(), gather_cfg::cout, DTROSChannelId::dduId(), DTMapElementIdentifiers::defaultIdValue, DTROBCardId::robId(), DTROSChannelId::rosId(), DTMapElementIdentifiers::ROSMapIdOffset, hgcalTBTopologyTester_cfi::sector, DTROBCardId::sectorId(), relativeConstraints::station, DTROBCardId::stationId(), DTMapElementIdentifiers::TDCMapIdOffset, makeMuonMisalignmentScenario::wheel, DTROBCardId::wheelId(), and writeEcalDQMStatus::write.

Referenced by buildSteering().

434  {
435  bool check = true;
436  bool write = false;
437 
438  while (check || write) {
439  // ROS board to sector connection map
440  std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare>::const_iterator ddu_iter = ddu_map.begin();
441  std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare>::const_iterator ddu_iend = ddu_map.end();
442  // ROB card to TDC element map
443  std::map<DTROBCardId, int, DTROBCardCompare>::const_iterator idt_iend = tdc_idm.end();
444  // ROS channel to ROB connection map
445  std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare>::const_iterator ros_iter = ros_map.begin();
446  std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare>::const_iterator ros_iend = ros_map.end();
447 
448  check = false;
449  std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare> ros_app;
450 
451  // loop over ROS channels
452  while (ros_iter != ros_iend) {
453  // get ROS channel and ROB identifiers
454  const std::pair<DTROSChannelId, DTROBCardId>& rosLink = *ros_iter++;
455  const DTROSChannelId& rosChannelId = rosLink.first;
456  const DTROSChannelId rosChanMapId(rosChannelId.dduId(), rosChannelId.rosId(), 0);
457  const DTROBCardId& robCMapId = rosLink.second;
458  ddu_iter = ddu_map.find(rosChanMapId);
459  int whdef = 0;
460  int secdef = 0;
461  int rosMapCk = 0;
462  if (ddu_iter != ddu_iend) {
463  const DTROBCardId& sector = ddu_iter->second;
464  whdef = sector.wheelId();
465  secdef = sector.sectorId();
466  rosMapCk = sector.robId();
467  } else {
468  std::cout << "DDU map " << rosChannelId.dduId() << " " << rosChannelId.rosId() << " 0 not found" << std::endl;
469  continue;
470  }
471  int wheel = robCMapId.wheelId();
472  int sector = robCMapId.sectorId();
473  int station = robCMapId.stationId();
474  int rob = robCMapId.robId();
476  whdef = wheel;
478  secdef = sector;
479  const DTROBCardId robCardId(whdef, secdef, station, rob);
480  std::map<DTROBCardId, int, DTROBCardCompare>::const_iterator idt_iter = tdc_idm.find(robCardId);
481  if (idt_iter != idt_iend) {
482  int tdcMapId = idt_iter->second;
483  ddu_iter = ddu_map.begin();
484  while (ddu_iter != ddu_iend) {
485  const std::pair<DTROSChannelId, DTROBCardId>& dduLink = *ddu_iter++;
486  const DTROSChannelId& ros_id = dduLink.first;
487  const DTROBCardId& sec_id = dduLink.second;
488  int whe_chk = sec_id.wheelId();
489  int sec_chk = sec_id.sectorId();
491  whe_chk = wheel;
493  sec_chk = sector;
494  if (rosMapCk != sec_id.robId())
495  continue;
496  DTROBCardId robCardId(whe_chk, sec_chk, station, rob);
497  idt_iter = tdc_idm.find(robCardId);
498  int tdcMapCk = idt_iter->second;
499  if ((tdcMapId != tdcMapCk) && (!check)) {
500  cloneROS(ros_map, ros_app, rosChannelId.dduId(), rosChannelId.rosId(), ros_id.dduId(), ros_id.rosId());
501  tdcMapId = tdcMapCk;
502  check = true;
503  }
504  if ((tdcMapId == tdcMapCk) && check) {
505  std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare>::iterator ddu_inew = ddu_map.find(ros_id);
506  ddu_inew->second = DTROBCardId(sec_id.wheelId(), sec_id.sectorId(), sec_id.stationId(), ros_count);
507  }
508  }
509  if (check) {
510  ros_count++;
511  break;
512  }
513  if (write)
514  std::cout << DTMapElementIdentifiers::ROSMapIdOffset << " " << rosMapCk << " " << rosChannelId.channelId()
516  << " " << wheel << " " << station << " " << sector << " " << rob << " "
517  << DTMapElementIdentifiers::TDCMapIdOffset << " " << tdcMapId << std::endl;
518 
519  } else {
520  std::cout << "TDC map " << wheel << " " << sector << " " << station << " " << rob << " not found" << std::endl;
521  }
522  }
523  appendROS(ros_map, ros_app);
524  if (!write) {
525  write = !check;
526  } else {
527  ddu_iter = ddu_map.begin();
528  while (ddu_iter != ddu_iend) {
529  const std::pair<DTROSChannelId, DTROBCardId>& dduLink = *ddu_iter++;
530  const DTROSChannelId& ros_id = dduLink.first;
531  const DTROBCardId& sec_id = dduLink.second;
532  std::cout << ros_id.dduId() << " " << ros_id.rosId() << " " << DTMapElementIdentifiers::defaultIdValue << " "
534  << sec_id.wheelId() << " " << DTMapElementIdentifiers::defaultIdValue << " " << sec_id.sectorId()
536  << " " << sec_id.robId() << std::endl;
537  }
538  write = false;
539  }
540  }
541 
542  return;
543 }
int wheelId() const
int channelId() const
static void appendROS(std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &ros_m, std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &ros_a)
static void cloneROS(std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &ros_m, std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &ros_a, int ddu_o, int ros_o, int ddu_f, int ros_f)
int sectorId() const
int robId() const
int stationId() const

◆ fillROSMap()

void DTCompactMapWriter::fillROSMap ( const std::string &  map_file,
int  ddu,
int  ros,
int  whdef,
int  secdef,
std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &  ddu_map,
std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &  ros_map,
int  map_count,
bool &  write 
)
staticprivate

Definition at line 358 of file DTCompactMapWriter.cc.

References DTMapElementIdentifiers::defaultIdValue, compare_using_db::ifile, hgcalTBTopologyTester_cfi::sector, relativeConstraints::station, makeMuonMisalignmentScenario::wheel, and writeEcalDQMStatus::write.

Referenced by buildSteering().

366  {
367  DTROSChannelId rosBoard(ddu, ros, 0);
368  DTROBCardId sectorId(whdef, secdef, 0, map_count);
369  ddu_map.insert(std::pair<DTROSChannelId, DTROBCardId>(rosBoard, sectorId));
370 
371  // template map file name
372  std::ifstream ifile(map_file.c_str());
373 
374  // loop over ROS channels and ROBs
375  int channel;
376  int wheel;
377  int sector;
378  int station;
379  int rob;
380  DTROSChannelId rosChanMap(ddu, ros, 0);
381  if (!write)
382  return;
383  while (ifile >> channel >> wheel >> sector >> station >> rob) {
384  // set sector to default unless specified
385  if (!sector)
387  if (!wheel)
389  // set ROS channel and ROB identifiers
390  DTROSChannelId rosChannel(ddu, ros, channel);
391  DTROBCardId robCard(wheel, sector, station, rob);
392  // store ROS channel to ROB connection into map
393  ros_map.insert(std::pair<DTROSChannelId, DTROBCardId>(rosChannel, robCard));
394  }
395  write = false;
396 
397  return;
398 }

◆ fillTDCMap()

void DTCompactMapWriter::fillTDCMap ( const std::string &  map_file,
int  wheel,
int  sector,
std::map< DTROBCardId, int, DTROBCardCompare > &  tdc_idm,
int  stationId,
int  map_count,
bool &  write 
)
staticprivate

Definition at line 319 of file DTCompactMapWriter.cc.

References gather_cfg::cout, DTMapElementIdentifiers::defaultIdValue, compare_using_db::ifile, crabWrapper::key, pixelTopology::layer, hgcalTBTopologyTester_cfi::sector, relativeConstraints::station, DTMapElementIdentifiers::TDCMapIdOffset, makeMuonMisalignmentScenario::wheel, and writeEcalDQMStatus::write.

Referenced by buildSteering().

325  {
326  // template map file name
327  std::ifstream ifile(map_file.c_str());
328 
329  // get station number
330  int station;
331  int rob;
332  station = stationId;
333  ifile >> rob;
335  tdc_idm.insert(std::pair<DTROBCardId, int>(key, map_count));
336  if (!write)
337  return;
338  // loop over TDC channels and cells
339  int superlayer;
340  int layer;
341  int wire;
342  int tdc;
343  int channel;
344  while (ifile >> tdc >> channel >> superlayer >> layer >> wire) {
345  // set ROB card, TDC channel and cell identifiers
346  DTTDCChannelId tdcChannel(tdc, channel);
347  DTPhysicalWireId physicalWire(superlayer, layer, wire);
348  // look for rob card connection map
349  std::cout << DTMapElementIdentifiers::TDCMapIdOffset << " " << map_count << " " << rob << " " << tdc << " "
350  << channel << " " << DTMapElementIdentifiers::defaultIdValue << " "
352  << superlayer << " " << layer << " " << wire << std::endl;
353  }
354  write = false;
355  return;
356 }
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer