BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
genRawScript.cpp
Go to the documentation of this file.
1#include <iostream>
2#include <fstream>
3#include <iomanip>
4#include <cstring>
5#include <string>
6#include <vector>
7
8using namespace std;
9
10// int main(int argc, char* argv[]){
11// char runlist[200];
12// char rawlist[200];
13// if(argc > 2){
14// sscanf(argv[1], "%s", runlist);
15// sscanf(argv[2], "%s", rawlist);
16// } else {
17// cout << "too few arguments" << endl;
18// return 0;
19// }
20
21int main(){
22 char runlist[200];
23 char rawlist[200];
24 sprintf(runlist, "RunList.txt");
25 sprintf(rawlist, "rawFileList.txt");
26
27 string str;
28 vector<int> vRun;
29 vector<string> vRunFile;
30 ifstream frunlist(runlist);
31 while(frunlist >> str){
32 vRunFile.push_back(str);
33
34 string strtmp = str;
35 strtmp.erase(0,strtmp.find("_")+1);
36 strtmp.erase(strtmp.find("."),4);
37 int iRun;
38 sscanf(strtmp.c_str(), "%d", &iRun);
39 vRun.push_back(iRun);
40 // cout << "strtmp " << strtmp << ", " << iRun << endl;
41 }
42 frunlist.close();
43
44 vector<int> vRawRun;
45 vector<string> vRawFile;
46 vector<string> vRawFileInput;
47 ifstream frawlist(rawlist);
48 while(frawlist >> str){
49 vRawFile.push_back(str);
50
51 string strtmp = str;
52 string::size_type i1 = str.find("run_");
53 strtmp = str.substr(i1+4, 7);
54 int iRun;
55 sscanf(strtmp.c_str(), "%d", &iRun);
56 vRawRun.push_back(iRun);
57 // cout << "strtmp " << strtmp << ", " << iRun << endl;
58
59 string strtmp2 = str;
60 string::size_type i2 = str.find("All_");
61 strtmp2 = str.substr(0, i2+8);
62 string strtmp3 = strtmp2 + "*.raw";
63 vRawFileInput.push_back(strtmp3);
64 // cout << strtmp3 << endl;
65 }
66 frawlist.close();
67
68 ofstream fout("job.txt");
69 for(unsigned i=0; i<vRun.size(); i++){
70 int index = -1;
71 for(unsigned k=0; k<vRawRun.size(); k++){
72 // cout << "k " << k << " run " << vRun[i] << " rawrun " << vRawRun[k] << endl;
73 if(vRun[i] == vRawRun[k]){ index = k; break;}
74 }
75 if(index > -1){
76 fout << "raw_evt_filter.exe " << vRunFile[i] << " \"" << vRawFileInput[index] << "\"" << endl;
77 } else{
78 cout << "can not find raw file for " << vRunFile[i] << endl;
79 }
80 }
81 fout.close();
82
83 return 0;
84}
85
int main()