-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.cpp
More file actions
56 lines (49 loc) · 1.55 KB
/
data.cpp
File metadata and controls
56 lines (49 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* Program: data.cpp
* Description: Runs evt2root on the files listed in runs.lst.
* See readme.md for general instructions.
* Developed by J. Lighthall Jul-Dec 2016
*/
//C and C++ libraries
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <cstdlib>
using namespace std;
int main() {
int list[99];
const char* fname="runs.lst"; //name of file with list of run numbers
ifstream infile(fname);
printf("Reading list file \"%s\"\n",fname);
printf(" The following runs will be converted\n");
int i=0;
while (infile >> list[i]) {
printf(" %d\n",list[i]);
i++;
}
char ans;
bool del=false;
cout << " Do you want to delete the .evt files after conversion? (y/n)" << endl << " ";
cin >> ans;
if (ans=='y')
del=true;
for(int j=0;j<i;j++) {
std::ofstream outfile("evt_files.lst"); //name of file referenced in evt2root_NSCL11.C
string str0 = "/home/splitpole/evt2root/data/"; //location of .evt files
outfile << "Output ROOT file: /home/splitpole/evt2root/root/" << list[j] << ".root" << endl;
outfile << "Data directory: "<< str0 << endl;
outfile << list[j] << endl;
system("root -l -q rootinput.C"); //name of file with ROOT command
string str1 = "rm -vf ";
str1+=str0;
str1+="run-";
string str2 = "-00.evt";
string str;
stringstream num;
num << list[j];
str=num.str();
string str3 = str1+str+str2;
if(del)
system(str3.c_str()); //use this line to delete the .evt files after conversion
}
}