BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
genRawScript.cpp File Reference
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 21 of file genRawScript.cpp.

21 {
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}