CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 42 of file DTCompactMapWriter.h.

Member Function Documentation

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

Definition at line 478 of file DTCompactMapWriter.cc.

References python.multivaluedict::map().

Referenced by fillReadOutMap().

483  {
484 
486  DTROBCardId,
487  DTROSChannelCompare>:: const_iterator ros_iter = ros_a.begin();
488  std::map<DTROSChannelId,
489  DTROBCardId,
490  DTROSChannelCompare>:: const_iterator ros_iend = ros_a.end();
491  while ( ros_iter != ros_iend ) ros_m.insert( *ros_iter++ );
492  return;
493 }
void DTCompactMapWriter::buildSteering ( std::istream &  jobDesc)
static

Definition at line 245 of file DTCompactMapWriter.cc.

References fillReadOutMap(), fillROSMap(), fillTDCMap(), combine::key, python.multivaluedict::map(), relativeConstraints::station, AlCaHLTBitMon_QueryRunRegistry::string, and TablePrint::write.

245  {
246  // template maps and lists, name and type
247  std::string map_type( "dummy_string" );
248  std::string map_file( "dummy_string" );
249  std::string map_list( "dummy_string" );
250 
251  // ros-rob and tdc-cell maps
253  int,
254  DTROBCardCompare> tdc_idm;
255  std::map<DTROSChannelId,DTROBCardId,DTROSChannelCompare> ros_map;
256  std::map<DTROSChannelId,DTROBCardId,DTROSChannelCompare> rob_map;
257 
258  int rob_count = 1;
259  int ros_count = 1;
260 
261  // parse job description file and loop over map templates and lists
262  bool jobEnd = false;
263  int max_line_length = 1000;
264  char* job_line = new char[max_line_length];
265  while ( jobDesc.getline( job_line, max_line_length ) ) {
266  // parse job description line
267  char* ptr_line = job_line;
268  char* end_line = job_line + max_line_length;
269  while( ptr_line < end_line ) {
270  // get description command key
271  // remove leading blanks
272  while ( *ptr_line == ' ' ) ptr_line++;
273  std::string key( ptr_line );
274  int off_blank = key.find( " " );
275  int off_equal = key.find( "=" );
276  if ( off_equal < 0 ) off_equal = max_line_length;
277  if ( off_blank < 0 ) off_blank = key.length();
278  int ioff = ( off_blank < off_equal ? off_blank : off_equal );
279  key.erase( ioff++, key.length() );
280  // go to command value
281  ptr_line += ++off_equal;
282  // exit loop at end of description file
283  if ( (jobEnd = ( key == "end" ) ) ) break;
284  // get description command value
285  while ( *ptr_line == ' ' ) ptr_line++;
286  std::string val( ptr_line );
287  int off_value = val.find( " " );
288  if ( ( off_value > 0 ) &&
289  ( off_value < static_cast<int>( val.length() ) ) )
290  val.erase( off_value++, val.length() );
291  // go to next token
292  ptr_line += off_value;
293  // set type, template or list file name
294  if ( key == "type" ) map_type = val;
295  if ( key == "map" ) map_file = val;
296  if ( key == "list" ) map_list = val;
297  }
298  if ( jobEnd ) break;
299 
300  // open map list file
301  std::ifstream lfile( map_list.c_str() );
302 
303  bool write;
304  // store TDC maps
305  if ( map_type == "TDC" ) {
306  // loop over TDC map list for concerned wheels and sectors
307  int station = 0;
308  int wheel;
309  int sector;
310  write = true;
311  while ( lfile >> wheel
312  >> sector
313  >> station ) fillTDCMap( map_file,
314  wheel, sector,
315  tdc_idm, station,
316  rob_count, write );
317  ++rob_count;
318  }
319 
320  // store ROS maps
321  if ( map_type == "ROS" ) {
322  // loop over ROS map list for concerned ddu, ros, wheel and sector
323  int ddu;
324  int ros;
325  int wheel;
326  int sector;
327  write = true;
328  while ( lfile >> ddu
329  >> ros
330  >> wheel
331  >> sector ) fillROSMap( map_file,
332  ddu, ros,
333  wheel, sector,
334  ros_map, rob_map,
335  ros_count, write );
336  ++ros_count;
337  }
338 
339  }
340  delete[] job_line;
341 
342  // merge ROS and TDC maps
343  fillReadOutMap( ros_count, tdc_idm, ros_map, rob_map );
344 
345  return;
346 
347 }
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)
list key
Definition: combine.py:13
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)
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 449 of file DTCompactMapWriter.cc.

References DTROSChannelId::channelId(), DTROSChannelId::dduId(), python.multivaluedict::map(), and DTROSChannelId::rosId().

Referenced by fillReadOutMap().

456  {
457 
459  DTROBCardId,
460  DTROSChannelCompare>:: const_iterator ros_iter = ros_m.begin();
461  std::map<DTROSChannelId,
462  DTROBCardId,
463  DTROSChannelCompare>:: const_iterator ros_iend = ros_m.end();
464  while ( ros_iter != ros_iend ) {
465  const std::pair<DTROSChannelId,DTROBCardId>& rosLink = *ros_iter++;
466  const DTROSChannelId& rosChannelId = rosLink.first;
467  const DTROBCardId& robCardId = rosLink.second;
468  if ( rosChannelId.dduId() != ddu_o ) continue;
469  if ( rosChannelId.rosId() != ros_o ) continue;
470  const DTROSChannelId rosChanNewId( ddu_f, ros_f,
471  rosChannelId.channelId() );
472  ros_a.insert( std::pair<DTROSChannelId,DTROBCardId>( rosChanNewId,
473  robCardId ) );
474  }
475  return;
476 }
int channelId() const
int rosId() const
int dduId() const
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 496 of file DTCompactMapWriter.cc.

References appendROS(), DTROSChannelId::channelId(), CastorDataFrameFilter_impl::check(), cloneROS(), gather_cfg::cout, DTROSChannelId::dduId(), DTMapElementIdentifiers::defaultIdValue, python.multivaluedict::map(), DTROBCardId::robId(), DTROSChannelId::rosId(), DTMapElementIdentifiers::ROSMapIdOffset, DTROBCardId::sectorId(), relativeConstraints::station, DTROBCardId::stationId(), DTMapElementIdentifiers::TDCMapIdOffset, DTROBCardId::wheelId(), and TablePrint::write.

Referenced by buildSteering().

506  {
507 
508  bool check = true;
509  bool write = false;
510 
511  while ( check || write ) {
512  // ROS board to sector connection map
514  DTROBCardId,
515  DTROSChannelCompare>:: const_iterator ddu_iter = ddu_map.begin();
516  std::map<DTROSChannelId,
517  DTROBCardId,
518  DTROSChannelCompare>:: const_iterator ddu_iend = ddu_map.end();
519  // ROB card to TDC element map
520  std::map<DTROBCardId,
521  int,
522  DTROBCardCompare>::const_iterator idt_iend = tdc_idm.end();
523  // ROS channel to ROB connection map
524  std::map<DTROSChannelId,
525  DTROBCardId,
526  DTROSChannelCompare>:: const_iterator ros_iter = ros_map.begin();
527  std::map<DTROSChannelId,
528  DTROBCardId,
529  DTROSChannelCompare>:: const_iterator ros_iend = ros_map.end();
530 
531  check = false;
532  std::map<DTROSChannelId,
533  DTROBCardId,
534  DTROSChannelCompare> ros_app;
535 
536  // loop over ROS channels
537  while ( ros_iter != ros_iend ) {
538  // get ROS channel and ROB identifiers
539  const std::pair<DTROSChannelId,DTROBCardId>& rosLink = *ros_iter++;
540  const DTROSChannelId& rosChannelId = rosLink.first;
541  const DTROSChannelId rosChanMapId( rosChannelId.dduId(),
542  rosChannelId.rosId(), 0 );
543  const DTROBCardId& robCMapId = rosLink.second;
544  ddu_iter = ddu_map.find( rosChanMapId );
545  int whdef = 0;
546  int secdef = 0;
547  int rosMapCk = 0;
548  if ( ddu_iter != ddu_iend ) {
549  const DTROBCardId& sector = ddu_iter->second;
550  whdef = sector.wheelId();
551  secdef = sector.sectorId();
552  rosMapCk = sector.robId();
553  }
554  else {
555  std::cout << "DDU map "
556  << rosChannelId.dduId() << " "
557  << rosChannelId.rosId() << " 0 not found" << std::endl;
558  continue;
559  }
560  int wheel = robCMapId. wheelId();
561  int sector = robCMapId. sectorId();
562  int station = robCMapId.stationId();
563  int rob = robCMapId. robId();
564  if ( wheel != DTMapElementIdentifiers::defaultIdValue ) whdef = wheel;
565  if ( sector != DTMapElementIdentifiers::defaultIdValue ) secdef = sector;
566  const DTROBCardId robCardId( whdef, secdef, station, rob );
567  std::map<DTROBCardId,
568  int,
569  DTROBCardCompare>::const_iterator idt_iter =
570  tdc_idm.find( robCardId );
571  if ( idt_iter != idt_iend ) {
572  int tdcMapId = idt_iter->second;
573  ddu_iter = ddu_map.begin();
574  while ( ddu_iter != ddu_iend ) {
575  const std::pair<DTROSChannelId,DTROBCardId>& dduLink = *ddu_iter++;
576  const DTROSChannelId& ros_id = dduLink.first;
577  const DTROBCardId& sec_id = dduLink.second;
578  int whe_chk = sec_id.wheelId();
579  int sec_chk = sec_id.sectorId();
581  whe_chk = wheel;
583  sec_chk = sector;
584  if ( rosMapCk != sec_id.robId() ) continue;
585  DTROBCardId robCardId( whe_chk, sec_chk,
586  station, rob );
587  idt_iter = tdc_idm.find( robCardId );
588  int tdcMapCk = idt_iter->second;
589  if ( ( tdcMapId != tdcMapCk ) && ( !check ) ) {
590  cloneROS( ros_map, ros_app,
591  rosChannelId.dduId(), rosChannelId.rosId(),
592  ros_id. dduId(), ros_id. rosId() );
593  tdcMapId = tdcMapCk;
594  check = true;
595  }
596  if ( ( tdcMapId == tdcMapCk ) && check ) {
597  std::map<DTROSChannelId,
598  DTROBCardId,
599  DTROSChannelCompare>::iterator ddu_inew =
600  ddu_map.find( ros_id );
601  ddu_inew->second = DTROBCardId( sec_id.wheelId(),
602  sec_id.sectorId(),
603  sec_id.stationId(),
604  ros_count );
605  }
606  }
607  if ( check ) {
608  ros_count++;
609  break;
610  }
611  if ( write )
613  << rosMapCk << " "
614  << rosChannelId.channelId() << " "
617  << wheel << " "
618  << station << " "
619  << sector << " "
620  << rob << " "
622  << tdcMapId << std::endl;
623 
624  }
625  else {
626  std::cout << "TDC map "
627  << wheel << " "
628  << sector << " "
629  << station << " "
630  << rob << " not found" << std::endl;
631  }
632  }
633  appendROS( ros_map, ros_app );
634  if ( !write ) {
635  write = !check;
636  }
637  else {
638  ddu_iter = ddu_map.begin();
639  while ( ddu_iter != ddu_iend ) {
640  const std::pair<DTROSChannelId,DTROBCardId>& dduLink = *ddu_iter++;
641  const DTROSChannelId& ros_id = dduLink.first;
642  const DTROBCardId& sec_id = dduLink.second;
643  std::cout << ros_id.dduId() << " "
644  << ros_id.rosId() << " "
648  << sec_id.wheelId() << " "
650  << sec_id.sectorId() << " "
653  << sec_id.robId() << std::endl;
654  }
655  write = false;
656  }
657  }
658 
659  return;
660 }
int channelId() const
int rosId() const
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
static void appendROS(std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &ros_m, std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > &ros_a)
int wheelId() const
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 robId() const
int dduId() const
int stationId() const
tuple cout
Definition: gather_cfg.py:121
int sectorId() const
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 401 of file DTCompactMapWriter.cc.

References DTMapElementIdentifiers::defaultIdValue, compare_using_db::ifile, and relativeConstraints::station.

Referenced by buildSteering().

411  {
412 
413  DTROSChannelId rosBoard( ddu, ros, 0 );
414  DTROBCardId sectorId( whdef, secdef, 0, map_count );
415  ddu_map.insert( std::pair<DTROSChannelId,DTROBCardId>( rosBoard,
416  sectorId ) );
417 
418  // template map file name
419  std::ifstream ifile( map_file.c_str() );
420 
421  // loop over ROS channels and ROBs
422  int channel;
423  int wheel;
424  int sector;
425  int station;
426  int rob;
427  DTROSChannelId rosChanMap( ddu, ros, 0 );
428  if ( !write ) return;
429  while ( ifile >> channel
430  >> wheel
431  >> sector
432  >> station
433  >> rob ) {
434  // set sector to default unless specified
435  if ( !sector ) sector = DTMapElementIdentifiers::defaultIdValue;
436  if ( ! wheel ) wheel = DTMapElementIdentifiers::defaultIdValue;
437  // set ROS channel and ROB identifiers
438  DTROSChannelId rosChannel( ddu, ros, channel );
439  DTROBCardId robCard( wheel, sector, station, rob );
440  // store ROS channel to ROB connection into map
441  ros_map.insert( std::pair<DTROSChannelId,DTROBCardId>( rosChannel,
442  robCard ) );
443  }
444  write = false;
445 
446  return;
447 }
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 349 of file DTCompactMapWriter.cc.

References gather_cfg::cout, DTMapElementIdentifiers::defaultIdValue, compare_using_db::ifile, combine::key, relativeConstraints::station, and DTMapElementIdentifiers::TDCMapIdOffset.

Referenced by buildSteering().

355  {
356 
357  // template map file name
358  std::ifstream ifile( map_file.c_str() );
359 
360  // get station number
361  int station;
362  int rob;
363  station = stationId;
364  ifile >> rob;
365  DTROBCardId key( wheel, sector, station, rob );
366  tdc_idm.insert( std::pair<DTROBCardId,int>( key, map_count ) );
367  if ( !write ) return;
368  // loop over TDC channels and cells
369  int superlayer;
370  int layer;
371  int wire;
372  int tdc;
373  int channel;
374  while ( ifile >> tdc
375  >> channel
376  >> superlayer
377  >> layer
378  >> wire ) {
379  // set ROB card, TDC channel and cell identifiers
380  DTTDCChannelId tdcChannel( tdc, channel );
381  DTPhysicalWireId physicalWire( superlayer, layer, wire );
382  // look for rob card connection map
384  << map_count << " "
385  << rob << " "
386  << tdc << " "
387  << channel << " "
391  << superlayer << " "
392  << layer << " "
393  << wire
394  << std::endl;
395 
396  }
397  write = false;
398  return;
399 }
list key
Definition: combine.py:13
tuple cout
Definition: gather_cfg.py:121