7 std::cout <<
"MODULE MAPPER YEAR " <<
year_ << std::endl;
264 else if (
year_ == 2016)
267 std::cout<<
"WARNING: ModuleMapper: using a mapping that might be wrong"<<std::endl;
501 std::cout <<
"ERROR: Module Mapper cannot be setup for this year " <<
year_ << std::endl;
507 std::map<std::string, std::map<int,int>> channel_map;
508 std::map<int,int> local_to_svtid_map;
509 int channel_index = 0;
510 for(
int feb=0; feb < 10; feb++){
511 std::string str_feb =
"F" + std::to_string(feb);
512 int max_channel = 640;
514 if (feb == 0 || feb == 1) max_channel = 512;
515 for(
int hybrid=0; hybrid < 4; hybrid++){
517 if( (feb == 2 || feb == 9) and hybrid > 1)
520 std::string str_hybrid =
"H" + std::to_string(hybrid);
521 for(
int channel=0; channel < max_channel; channel++){
522 int svtid = channel_index + channel;
523 local_to_svtid_map[channel] = svtid;
525 channel_map[str_feb + str_hybrid] = local_to_svtid_map ;
526 channel_index += max_channel;
533 std::map<int,int> channelMap = svtid_map[hwTag];
534 std::map<int,int>::iterator it = channelMap.find(channel);
535 if(it != channelMap.end()){
549 std::vector<std::string> hybrids;
550 for(
int i=0; i < 7; ++i){
552 hybrids.push_back(Form(
"L%iT_axial",i));
553 hybrids.push_back(Form(
"L%iT_stereo",i));
554 hybrids.push_back(Form(
"L%iB_stereo",i));
555 hybrids.push_back(Form(
"L%iB_axial",i));
558 hybrids.push_back(Form(
"L%iT_axial_ele",i));
559 hybrids.push_back(Form(
"L%iT_stereo_ele",i));
560 hybrids.push_back(Form(
"L%iT_axial_pos",i));
561 hybrids.push_back(Form(
"L%iT_stereo_pos",i));
562 hybrids.push_back(Form(
"L%iB_axial_ele",i));
563 hybrids.push_back(Form(
"L%iB_stereo_ele",i));
564 hybrids.push_back(Form(
"L%iB_axial_pos",i));
565 hybrids.push_back(Form(
"L%iB_stereo_pos",i));
584 std::map<std::string,std::map<std::string,std::vector<int>>> map;
585 for(
int feb = 0; feb < 10; feb++){
589 for(
int hybrid = 0; hybrid < 5; hybrid++){
590 std::string FH_code = std::to_string(feb) + std::to_string(hybrid);
591 std::map<std::string, std::vector<int>> apv_channels;
592 for(
int apv = 0; apv < napvs; apv++){
594 std::vector<int> channels;
662 for (
int i = a; i < b+1; i++){
663 channels.push_back(i);
667 apv_channels[std::to_string(apv)] = channels;
669 map[FH_code] = apv_channels;
678 std::map<std::string, std::vector<int>> readThresholds;
679 std::ifstream threshfile;
680 threshfile.open(filename);
682 std::cout <<
"ERROR! THRESHOLD FILE " << filename <<
" DOES NOT EXIST!" << std::endl;
683 std::cout <<
"FITTING WILL FAIL. PLEASE SPECIFY THE DATABASE THRESHOLD FILE ASSOCIATED WITH RUN" << std::endl;
687 while (getline (threshfile,row)) {
688 std::vector<int> thresholds;
689 std::string feb = row.substr(0,1);
690 std::string hyb = row.substr(2,1);
691 std::string apv = row.substr(4,1);
692 std::string data_string = row.substr(5);
693 std::stringstream lineStream(data_string);
696 while(lineStream >> std::hex >> value)
698 thresholds.push_back(value);
701 readThresholds[feb+hyb+apv] = thresholds;
711 std::pair<std::string, int> apv_chindex;
712 std::map<std::string, std::map<std::string,std::vector<int>>>::iterator it;
714 std::string FH = it->first;
715 std::string ifeb = (FH.substr(0,1));
716 std::string ihyb = (FH.substr(1,1));
717 if(ifeb == feb && ihyb == hybrid)
722 std::map<std::string, std::vector<int>> apv_map = it->second;
723 std::map<std::string, std::vector<int>>::iterator itb;
724 bool foundapv =
false;
725 for (itb = apv_map.begin(); itb != apv_map.end(); itb++){
726 std::string apv = itb->first;
727 std::vector<int> channels = itb->second;
730 for(
int i = 0; i < channels.size(); i++){
731 if(channels[i] == channel){
732 apv_chindex.first = apv;
733 apv_chindex.second = i;
750 std::pair<std::string,int> apv_channel =
findApvChannel(feb, hybrid, channel);
751 std::string apv = apv_channel.first;
752 int apvchannel = apv_channel.second;
753 int threshold =
thresholdsIn_[feb+hybrid+apv].at(apvchannel);
std::map< std::string, std::vector< int > > thresholdsIn_
description
std::pair< std::string, int > findApvChannel(std::string feb, std::string hybrid, int channel)
get APV channel number given feb, hybrid, and channel number
std::map< std::string, std::string > sw_to_hw
description
std::map< std::string, std::string > string_to_hw
description
std::map< std::string, std::string > hw_to_sw
description
std::map< std::string, std::string > hw_to_string
description
void ReadThresholdsFile(std::string filename)
Used to read svt channel DAQ threshold values from daq thresholds file.
int getSvtIDFromHWChannel(int channel, std::string hwTag, std::map< std::string, std::map< int, int > > svtid_map)
Return global svt id for channel by providing local channel number and F<n>H<m> of channel.
int getThresholdValue(std::string feb, std::string hybrid, int channel)
Get channel DAQ threshold.
std::map< std::string, std::string > string_to_sw
description
ModuleMapper(const int year=2019)
std::map< std::string, std::map< int, int > > buildChannelSvtIDMap()
Build global svt id map for all FebHybrid combinations.
std::vector< std::string > getHybridStrings()
Get the Hybrid Strings.
std::map< std::string, std::string > sw_to_string
description
std::map< std::string, std::map< std::string, std::vector< int > > > apvChannelMap_
description
void buildApvChannelMap()
Used to generate apv channel map and read in thresholds from database.