Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:30:25

0001 #include <iostream>
0002 #include <fstream>
0003 #include <sstream>
0004 #include <string>
0005 #include <vector>
0006 #include <map>
0007 #include <bitset>
0008 
0009 int main(int argc, char** argv){
0010   std::bitset<4> a;
0011   a=1;
0012   std::cout <<a<<std::endl;
0013   a<<=1;
0014   std::cout <<a<<std::endl;
0015   a<<=2;
0016   a|=1;
0017   std::cout <<a<<std::endl;
0018 
0019   if(argc != 2) return -1;
0020   std::string filename=argv[1];
0021   std::ifstream inpf(filename.c_str());
0022   std::string buf;
0023   std::vector<std::string> lbname;
0024   bool lb=false;
0025   bool bx=true;
0026   int ilb=0;
0027   std::map<int, std::map<std::string,std::bitset<96> > > event;
0028   std::map<std::string, std::bitset<96> > lbdump;
0029   int ibx = -1;
0030   do{
0031     buf.clear();
0032     inpf >>buf;
0033     if (buf=="lb"){
0034       lb=true;
0035     } else if (lb){
0036       lb = false;
0037       lbname.push_back(buf);
0038     } else if (!buf.empty()){
0039       if (bx) {
0040     bx = false;
0041     ilb=0;
0042     std::stringstream os;
0043     os<<buf;
0044     os>>ibx;
0045     std::cout <<" bx = "<<ibx<<" |"<<buf<<"|"<<std::endl;
0046     lbdump.clear();
0047       }else{
0048     ilb++;
0049     if (ilb==lbname.size())   
0050       bx = true;
0051     unsigned long icont1,icont2,icont3,icont4;
0052     {
0053       std::stringstream os;
0054       os<<buf.substr(0,6);
0055       os>>std::hex>>icont1;   
0056     }
0057     {
0058       std::stringstream os;
0059       os<<buf.substr(6,6);
0060       os>>std::hex>>icont2;   
0061     }
0062     {
0063       std::stringstream os;
0064       os<<buf.substr(12,6);
0065       os>>std::hex>>icont3;   
0066     }
0067     {
0068       std::stringstream os;
0069       os<<buf.substr(18,6);
0070       os>>std::hex>>icont4;   
0071     }
0072 
0073     std::bitset<96> cont(icont1);
0074     cont <<=24;
0075     cont |= icont2;
0076     cont <<=24;
0077     cont |= icont3;
0078     cont <<=24;
0079     cont |= icont4;
0080 
0081     if (cont.count()>0){
0082       lbdump[lbname[ilb-1]]=cont;
0083       std::cout <<cont.count()<<" Content of "
0084             <<lbname[ilb-1]<<" = "<<buf<<std::endl;
0085       std::cout <<"Content of "<<lbname[ilb-1]<<" = "
0086             <<buf.substr(0,6)<<" "<<buf.substr(6,6)
0087             <<" "<<buf.substr(12,6)<<" "<<buf.substr(18,6)<<std::endl;
0088       std::cout <<"Content of "<<lbname[ilb-1]<<" = "<<std::hex
0089             <<icont1<<" "<<icont2<<" "<<icont3<<" "<<icont4
0090             <<std::dec<<std::endl;
0091       std::cout <<"Content of "<<lbname[ilb-1]<<" = "<<cont<<std::endl;
0092     }
0093     if (bx){
0094       if (lbdump.size()>0){
0095         std::cout <<"good bx "<<ibx<<std::endl;
0096         event[ibx]=lbdump;
0097       }
0098     }
0099       }
0100     }  
0101   }while(inpf.good() && !buf.empty());
0102 
0103 
0104   std::cout <<"done!"<<std::endl;
0105 
0106   for (std::map<int, std::map<std::string, std::bitset<96> > >::iterator ix=
0107      event.begin(); ix!=event.end();ix++){
0108 
0109     std::cout <<"Bunch Crossing "<<ix->first<<std::endl;
0110     for (std::map<std::string, std::bitset<96> >::iterator ib=
0111        ix->second.begin(); ib != ix->second.end(); ib++){
0112       if (ib->second.count()>0){
0113     std::cout <<"Board "<<ib->first<<std::endl;
0114     for (int i=0;i<96;i++){
0115       if (ib->second[i]>0){
0116         std::cout <<"channel = "<<i<<std::endl;
0117       }
0118     }
0119       }
0120     }
0121 
0122   }
0123        
0124 
0125   
0126   
0127 }