47 channel_id( channel ) {
71 if ( idl. dduId() < idr. dduId() )
return true;
72 if ( idl. dduId() > idr. dduId() )
return false;
73 if ( idl. rosId() < idr. rosId() )
return true;
74 if ( idl. rosId() > idr. rosId() )
return false;
98 station_id( station ),
128 if ( idl. wheelId() < idr. wheelId() )
return true;
129 if ( idl. wheelId() > idr. wheelId() )
return false;
130 if ( idl. sectorId() < idr. sectorId() )
return true;
131 if ( idl. sectorId() > idr. sectorId() )
return false;
134 if ( idl. robId() < idr. robId() )
return true;
135 if ( idl. robId() > idr. robId() )
return false;
152 channel_id( channel ) {
173 if ( idl. tdcId() < idr. tdcId() )
return true;
174 if ( idl. tdcId() > idr. tdcId() )
return false;
194 superlayer_id( superlayer ),
223 if ( idl. layerId() < idr. layerId() )
return true;
224 if ( idl. layerId() > idr. layerId() )
return false;
225 if ( idl. cellId() < idr. cellId() )
return true;
226 if ( idl. cellId() > idr. cellId() )
return false;
255 std::map<DTROSChannelId,DTROBCardId,DTROSChannelCompare> ros_map;
256 std::map<DTROSChannelId,DTROBCardId,DTROSChannelCompare> rob_map;
263 int max_line_length = 1000;
264 char* job_line =
new char[max_line_length];
265 while ( jobDesc.getline( job_line, max_line_length ) ) {
267 char* ptr_line = job_line;
268 char* end_line = job_line + max_line_length;
269 while( ptr_line < end_line ) {
272 while ( *ptr_line ==
' ' ) 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() );
281 ptr_line += ++off_equal;
283 if ( (jobEnd = ( key ==
"end" ) ) )
break;
285 while ( *ptr_line ==
' ' ) 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() );
292 ptr_line += off_value;
294 if ( key ==
"type" ) map_type = val;
295 if ( key ==
"map" ) map_file = val;
296 if ( key ==
"list" ) map_list = val;
301 std::ifstream lfile( map_list.c_str() );
305 if ( map_type ==
"TDC" ) {
311 while ( lfile >> wheel
321 if ( map_type ==
"ROS" ) {
350 int wheel,
int sector,
355 int map_count,
bool&
write ) {
358 std::ifstream
ifile( map_file.c_str() );
366 tdc_idm.insert( std::pair<DTROBCardId,int>( key, map_count ) );
367 if ( !write )
return;
403 int whdef,
int secdef,
414 DTROBCardId sectorId( whdef, secdef, 0, map_count );
415 ddu_map.insert( std::pair<DTROSChannelId,DTROBCardId>( rosBoard,
419 std::ifstream
ifile( map_file.c_str() );
428 if ( !write )
return;
429 while (
ifile >> channel
439 DTROBCardId robCard( wheel, sector, station, rob );
441 ros_map.insert( std::pair<DTROSChannelId,DTROBCardId>( rosChannel,
455 int ddu_o,
int ros_o,
456 int ddu_f,
int ros_f ) {
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,
472 ros_a.insert( std::pair<DTROSChannelId,DTROBCardId>( rosChanNewId,
491 while ( ros_iter != ros_iend ) ros_m.insert( *ros_iter++ );
511 while ( check || write ) {
537 while ( ros_iter != ros_iend ) {
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 );
548 if ( ddu_iter != ddu_iend ) {
549 const DTROBCardId& sector = ddu_iter->second;
552 rosMapCk = sector.
robId();
556 << rosChannelId.
dduId() <<
" "
557 << rosChannelId.
rosId() <<
" 0 not found" << std::endl;
560 int wheel = robCMapId. wheelId();
561 int sector = robCMapId. sectorId();
562 int station = robCMapId.stationId();
563 int rob = robCMapId. robId();
566 const DTROBCardId robCardId( whdef, secdef, station, rob );
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();
584 if ( rosMapCk != sec_id.
robId() )
continue;
585 DTROBCardId robCardId( whe_chk, sec_chk,
587 idt_iter = tdc_idm.find( robCardId );
588 int tdcMapCk = idt_iter->second;
589 if ( ( tdcMapId != tdcMapCk ) && ( !check ) ) {
592 ros_id. dduId(), ros_id. rosId() );
596 if ( ( tdcMapId == tdcMapCk ) &&
check ) {
600 ddu_map.find( ros_id );
601 ddu_inew->second = DTROBCardId( sec_id.
wheelId(),
622 << tdcMapId << std::endl;
630 << rob <<
" not found" << std::endl;
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;
644 << ros_id.
rosId() <<
" "
653 << sec_id.
robId() << std::endl;
bool operator()(const DTROSChannelId &idl, const DTROSChannelId &idr) const
static int defaultIdValue
static int TDCMapIdOffset
bool operator()(const DTTDCChannelId &idl, const DTTDCChannelId &idr) const
static int ROSMapIdOffset
DTTDCChannelId(int tdc, int channel)
static void buildSteering(std::istream &jobDesc)
bool operator()(const DTPhysicalWireId &idl, const DTPhysicalWireId &idr) const
DTPhysicalWireId(int superlayer, int layer, int cell)
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)
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 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)
DTROSChannelId(int ddu, int ros, int channel)
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)
bool operator()(const DTROBCardId &idl, const DTROBCardId &idr) const
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)
static int ROBMapIdOffset
DTROBCardId(int wheel, int sector, int station, int rob)