-
Notifications
You must be signed in to change notification settings - Fork 1
/
applyscaletocalibtable.cc
67 lines (57 loc) · 1.41 KB
/
applyscaletocalibtable.cc
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
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
if (argc<4)
{
std::cout << argv[0] << "<calibTable_in.dat> <calibTable_out.dat> <scale>"
<< std::endl;
return 0;
}
const char* filename = argv[1];
const char* filename_out = argv[2];
const double scale = atof(argv[3]);
std::cout << "Read file : " << filename << std::endl;
std::cout << "Write modifled file to : " << filename_out << std::endl;
std::cout << "Apply scale : " << scale << std::endl;
int idx, ix, iy, iz, fixed, nfits;
double c, cerr;
std::ifstream myfile;
myfile.open(filename);
std::ofstream myfile_out;
myfile_out.open(filename_out);
std::string line;
if (myfile.is_open()&&myfile_out.is_open())
{
int index=0;
while (getline(myfile,line))
{
std::stringstream sline(line);
sline >> idx
>> ix
>> iy
>> iz
>> c
>> cerr
>> fixed
>> nfits ;
myfile_out << index << " "
<< ix << " "
<< iy << " "
<< iz << " "
<< c*scale << " "
<< cerr*scale << " "
<< fixed << " "
<< nfits << " "
<< std::endl;
index++;
}
myfile.close();
myfile_out.close();
}
}