#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) |
Description: Class to build readout maps from map templates and lists
Definition at line 42 of file DTCompactMapWriter.h.
void DTCompactMapWriter::appendROS | ( | std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > & | ros_m, |
std::map< DTROSChannelId, DTROBCardId, DTROSChannelCompare > & | ros_a | ||
) | [static, private] |
Definition at line 478 of file DTCompactMapWriter.cc.
References Association::map.
Referenced by fillReadOutMap().
{ std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare>:: const_iterator ros_iter = ros_a.begin(); std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare>:: const_iterator ros_iend = ros_a.end(); while ( ros_iter != ros_iend ) ros_m.insert( *ros_iter++ ); return; }
void DTCompactMapWriter::buildSteering | ( | std::istream & | jobDesc | ) | [static] |
Definition at line 245 of file DTCompactMapWriter.cc.
References fillReadOutMap(), fillROSMap(), fillTDCMap(), combine::key, Association::map, relativeConstraints::station, and TablePrint::write.
{ // template maps and lists, name and type std::string map_type( "dummy_string" ); std::string map_file( "dummy_string" ); std::string map_list( "dummy_string" ); // ros-rob and tdc-cell maps std::map<DTROBCardId, int, DTROBCardCompare> tdc_idm; std::map<DTROSChannelId,DTROBCardId,DTROSChannelCompare> ros_map; std::map<DTROSChannelId,DTROBCardId,DTROSChannelCompare> rob_map; int rob_count = 1; int ros_count = 1; // parse job description file and loop over map templates and lists bool jobEnd = false; int max_line_length = 1000; char* job_line = new char[max_line_length]; while ( jobDesc.getline( job_line, max_line_length ) ) { // parse job description line char* ptr_line = job_line; char* end_line = job_line + max_line_length; while( ptr_line < end_line ) { // get description command key // remove leading blanks while ( *ptr_line == ' ' ) ptr_line++; std::string key( ptr_line ); int off_blank = key.find( " " ); int off_equal = key.find( "=" ); if ( off_equal < 0 ) off_equal = max_line_length; if ( off_blank < 0 ) off_blank = key.length(); int ioff = ( off_blank < off_equal ? off_blank : off_equal ); key.erase( ioff++, key.length() ); // go to command value ptr_line += ++off_equal; // exit loop at end of description file if ( (jobEnd = ( key == "end" ) ) ) break; // get description command value while ( *ptr_line == ' ' ) ptr_line++; std::string val( ptr_line ); int off_value = val.find( " " ); if ( ( off_value > 0 ) && ( off_value < static_cast<int>( val.length() ) ) ) val.erase( off_value++, val.length() ); // go to next token ptr_line += off_value; // set type, template or list file name if ( key == "type" ) map_type = val; if ( key == "map" ) map_file = val; if ( key == "list" ) map_list = val; } if ( jobEnd ) break; // open map list file std::ifstream lfile( map_list.c_str() ); bool write; // store TDC maps if ( map_type == "TDC" ) { // loop over TDC map list for concerned wheels and sectors int station = 0; int wheel; int sector; write = true; while ( lfile >> wheel >> sector >> station ) fillTDCMap( map_file, wheel, sector, tdc_idm, station, rob_count, write ); ++rob_count; } // store ROS maps if ( map_type == "ROS" ) { // loop over ROS map list for concerned ddu, ros, wheel and sector int ddu; int ros; int wheel; int sector; write = true; while ( lfile >> ddu >> ros >> wheel >> sector ) fillROSMap( map_file, ddu, ros, wheel, sector, ros_map, rob_map, ros_count, write ); ++ros_count; } } delete job_line; // merge ROS and TDC maps fillReadOutMap( ros_count, tdc_idm, ros_map, rob_map ); return; }
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 | ||
) | [static, private] |
Definition at line 449 of file DTCompactMapWriter.cc.
References DTROSChannelId::channelId(), DTROSChannelId::dduId(), Association::map, and DTROSChannelId::rosId().
Referenced by fillReadOutMap().
{ std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare>:: const_iterator ros_iter = ros_m.begin(); std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare>:: const_iterator ros_iend = ros_m.end(); while ( ros_iter != ros_iend ) { const std::pair<DTROSChannelId,DTROBCardId>& rosLink = *ros_iter++; const DTROSChannelId& rosChannelId = rosLink.first; const DTROBCardId& robCardId = rosLink.second; if ( rosChannelId.dduId() != ddu_o ) continue; if ( rosChannelId.rosId() != ros_o ) continue; const DTROSChannelId rosChanNewId( ddu_f, ros_f, rosChannelId.channelId() ); ros_a.insert( std::pair<DTROSChannelId,DTROBCardId>( rosChanNewId, robCardId ) ); } return; }
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 | ||
) | [static, private] |
Definition at line 496 of file DTCompactMapWriter.cc.
References appendROS(), DTROSChannelId::channelId(), CastorDataFrameFilter_impl::check(), cloneROS(), gather_cfg::cout, DTROSChannelId::dduId(), DTMapElementIdentifiers::defaultIdValue, Association::map, DTROBCardId::robId(), DTROSChannelId::rosId(), DTMapElementIdentifiers::ROSMapIdOffset, DTROBCardId::sectorId(), relativeConstraints::station, DTROBCardId::stationId(), DTMapElementIdentifiers::TDCMapIdOffset, DTROBCardId::wheelId(), and TablePrint::write.
Referenced by buildSteering().
{ bool check = true; bool write = false; while ( check || write ) { // ROS board to sector connection map std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare>:: const_iterator ddu_iter = ddu_map.begin(); std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare>:: const_iterator ddu_iend = ddu_map.end(); // ROB card to TDC element map std::map<DTROBCardId, int, DTROBCardCompare>::const_iterator idt_iend = tdc_idm.end(); // ROS channel to ROB connection map std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare>:: const_iterator ros_iter = ros_map.begin(); std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare>:: const_iterator ros_iend = ros_map.end(); check = false; std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare> ros_app; // loop over ROS channels while ( ros_iter != ros_iend ) { // get ROS channel and ROB identifiers const std::pair<DTROSChannelId,DTROBCardId>& rosLink = *ros_iter++; const DTROSChannelId& rosChannelId = rosLink.first; const DTROSChannelId rosChanMapId( rosChannelId.dduId(), rosChannelId.rosId(), 0 ); const DTROBCardId& robCMapId = rosLink.second; ddu_iter = ddu_map.find( rosChanMapId ); int whdef = 0; int secdef = 0; int rosMapCk = 0; if ( ddu_iter != ddu_iend ) { const DTROBCardId& sector = ddu_iter->second; whdef = sector.wheelId(); secdef = sector.sectorId(); rosMapCk = sector.robId(); } else { std::cout << "DDU map " << rosChannelId.dduId() << " " << rosChannelId.rosId() << " 0 not found" << std::endl; continue; } int wheel = robCMapId. wheelId(); int sector = robCMapId. sectorId(); int station = robCMapId.stationId(); int rob = robCMapId. robId(); if ( wheel != DTMapElementIdentifiers::defaultIdValue ) whdef = wheel; if ( sector != DTMapElementIdentifiers::defaultIdValue ) secdef = sector; const DTROBCardId robCardId( whdef, secdef, station, rob ); std::map<DTROBCardId, int, DTROBCardCompare>::const_iterator idt_iter = tdc_idm.find( robCardId ); if ( idt_iter != idt_iend ) { int tdcMapId = idt_iter->second; ddu_iter = ddu_map.begin(); while ( ddu_iter != ddu_iend ) { const std::pair<DTROSChannelId,DTROBCardId>& dduLink = *ddu_iter++; const DTROSChannelId& ros_id = dduLink.first; const DTROBCardId& sec_id = dduLink.second; int whe_chk = sec_id.wheelId(); int sec_chk = sec_id.sectorId(); if ( wheel != DTMapElementIdentifiers::defaultIdValue ) whe_chk = wheel; if ( sector != DTMapElementIdentifiers::defaultIdValue ) sec_chk = sector; if ( rosMapCk != sec_id.robId() ) continue; DTROBCardId robCardId( whe_chk, sec_chk, station, rob ); idt_iter = tdc_idm.find( robCardId ); int tdcMapCk = idt_iter->second; if ( ( tdcMapId != tdcMapCk ) && ( !check ) ) { cloneROS( ros_map, ros_app, rosChannelId.dduId(), rosChannelId.rosId(), ros_id. dduId(), ros_id. rosId() ); tdcMapId = tdcMapCk; check = true; } if ( ( tdcMapId == tdcMapCk ) && check ) { std::map<DTROSChannelId, DTROBCardId, DTROSChannelCompare>::iterator ddu_inew = ddu_map.find( ros_id ); ddu_inew->second = DTROBCardId( sec_id.wheelId(), sec_id.sectorId(), sec_id.stationId(), ros_count ); } } if ( check ) { ros_count++; break; } if ( write ) std::cout << DTMapElementIdentifiers::ROSMapIdOffset << " " << rosMapCk << " " << rosChannelId.channelId() << " " << DTMapElementIdentifiers::defaultIdValue << " " << DTMapElementIdentifiers::defaultIdValue << " " << wheel << " " << station << " " << sector << " " << rob << " " << DTMapElementIdentifiers::TDCMapIdOffset << " " << tdcMapId << std::endl; } else { std::cout << "TDC map " << wheel << " " << sector << " " << station << " " << rob << " not found" << std::endl; } } appendROS( ros_map, ros_app ); if ( !write ) { write = !check; } else { ddu_iter = ddu_map.begin(); while ( ddu_iter != ddu_iend ) { const std::pair<DTROSChannelId,DTROBCardId>& dduLink = *ddu_iter++; const DTROSChannelId& ros_id = dduLink.first; const DTROBCardId& sec_id = dduLink.second; std::cout << ros_id.dduId() << " " << ros_id.rosId() << " " << DTMapElementIdentifiers::defaultIdValue << " " << DTMapElementIdentifiers::defaultIdValue << " " << DTMapElementIdentifiers::defaultIdValue << " " << sec_id.wheelId() << " " << DTMapElementIdentifiers::defaultIdValue << " " << sec_id.sectorId() << " " << DTMapElementIdentifiers::defaultIdValue << " " << DTMapElementIdentifiers::ROSMapIdOffset << " " << sec_id.robId() << std::endl; } write = false; } } return; }
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 | ||
) | [static, private] |
Definition at line 401 of file DTCompactMapWriter.cc.
References DTMapElementIdentifiers::defaultIdValue, compare_using_db::ifile, and relativeConstraints::station.
Referenced by buildSteering().
{ DTROSChannelId rosBoard( ddu, ros, 0 ); DTROBCardId sectorId( whdef, secdef, 0, map_count ); ddu_map.insert( std::pair<DTROSChannelId,DTROBCardId>( rosBoard, sectorId ) ); // template map file name std::ifstream ifile( map_file.c_str() ); // loop over ROS channels and ROBs int channel; int wheel; int sector; int station; int rob; DTROSChannelId rosChanMap( ddu, ros, 0 ); if ( !write ) return; while ( ifile >> channel >> wheel >> sector >> station >> rob ) { // set sector to default unless specified if ( !sector ) sector = DTMapElementIdentifiers::defaultIdValue; if ( ! wheel ) wheel = DTMapElementIdentifiers::defaultIdValue; // set ROS channel and ROB identifiers DTROSChannelId rosChannel( ddu, ros, channel ); DTROBCardId robCard( wheel, sector, station, rob ); // store ROS channel to ROB connection into map ros_map.insert( std::pair<DTROSChannelId,DTROBCardId>( rosChannel, robCard ) ); } write = false; return; }
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 | ||
) | [static, private] |
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().
{ // template map file name std::ifstream ifile( map_file.c_str() ); // get station number int station; int rob; station = stationId; ifile >> rob; DTROBCardId key( wheel, sector, station, rob ); tdc_idm.insert( std::pair<DTROBCardId,int>( key, map_count ) ); if ( !write ) return; // loop over TDC channels and cells int superlayer; int layer; int wire; int tdc; int channel; while ( ifile >> tdc >> channel >> superlayer >> layer >> wire ) { // set ROB card, TDC channel and cell identifiers DTTDCChannelId tdcChannel( tdc, channel ); DTPhysicalWireId physicalWire( superlayer, layer, wire ); // look for rob card connection map std::cout << DTMapElementIdentifiers::TDCMapIdOffset << " " << map_count << " " << rob << " " << tdc << " " << channel << " " << DTMapElementIdentifiers::defaultIdValue << " " << DTMapElementIdentifiers::defaultIdValue << " " << DTMapElementIdentifiers::defaultIdValue << " " << superlayer << " " << layer << " " << wire << std::endl; } write = false; return; }