Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:30

0001 #include <cstdlib>
0002 #include <fstream>
0003 #include <iomanip>
0004 #include <iostream>
0005 #include <map>
0006 #include <string>
0007 #include <vector>
0008 
0009 std::vector<std::string> splitString (const std::string& fLine) {
0010   std::vector<std::string> result;
0011   int  start(0);
0012   bool empty(true);
0013   for (unsigned i = 0; i <= fLine.size (); i++) {
0014     if (fLine[i] == ' ' || i == fLine.size ()) {
0015       if (!empty) {
0016         std::string item(fLine, start, i-start);
0017         result.push_back(item);
0018         empty = true;
0019       }
0020       start = i+1;
0021     } else {
0022       if (empty) empty = false;
0023     }
0024   }
0025   return result;
0026 }
0027 
0028 void makeList(char* infile) {
0029 
0030   std::map<std::string,int> list;
0031   std::ifstream fInput(infile);
0032   if (!fInput.good()) {
0033     std::cout << "Cannot open file " << infile << std::endl;
0034   } else {
0035     char buffer [1024];
0036     unsigned int all(0), good(0);
0037     while (fInput.getline(buffer, 1024)) {
0038       ++all;
0039       std::vector<std::string> items = splitString (std::string(buffer));
0040       if (items.size() == 6 && items[0] == "Overlap") {
0041     ++good;
0042     std::map<std::string,int>::iterator itr = list.find(items[5]);
0043     if (itr == list.end()) {
0044       list[items[5]] = 0;
0045       itr = list.find(items[5]);
0046     }
0047     ++(itr->second);
0048       }
0049     }
0050     fInput.close();
0051     std::cout << "Reads total of " << all << " and " << good << " good records"
0052               << " from " << infile << std::endl;
0053   }
0054 
0055   std::cout << "\nFinds " << list.size() << " volumes with overlaps\n\n";
0056   for (std::map<std::string,int>::iterator itr = list.begin();
0057        itr != list.end(); ++ itr)
0058     std::cout << "Volume " << itr->first << " Kount " << itr->second << "\n";
0059 }
0060