File indexing completed on 2023-03-17 10:42:16
0001 #include <iostream>
0002 #include <fstream>
0003 #include <vector>
0004 #include <iostream>
0005 #include <string>
0006 #include <math.h>
0007
0008
0009 using namespace std;
0010
0011 int main(){
0012 float leftslope,leftint,rightslope,rightint;
0013 int index,extra1,extra2;
0014 int nrlines1=0;
0015
0016 std::vector<int> index_id;
0017 std::vector<float> leftSlope;
0018 std::vector<float> leftInt;
0019 std::vector<float> leftChi2;
0020 std::vector<float> rightSlope;
0021 std::vector<float> rightInt;
0022
0023 std::ifstream newdata;
0024 newdata.open("FileName",std::ios::in);
0025
0026 if(!newdata) {
0027 std::cerr <<"FileName -> no such file!"<< std::endl;
0028 exit(1);
0029 }
0030
0031 while (!newdata.eof() ) {
0032 newdata >> index >> leftslope >> leftint >> rightslope >> rightint >> extra1 >> extra2;
0033 index_id.push_back(index);
0034 leftSlope.push_back(leftslope);
0035 leftInt.push_back(leftint);
0036 rightSlope.push_back(rightslope);
0037 rightInt.push_back(rightint);
0038 nrlines1++;
0039 }
0040 newdata.close();
0041
0042 std::ofstream myXtalkFile("GoodVals_FileName",std::ios::out);
0043 for(int i=0; i<nrlines1-1;++i){
0044 if (rightSlope[i]!=-999 && leftSlope[i]!=-999 && leftInt[i]!=-999 & rightInt[i]!=-999 && extra1 !=1){
0045 myXtalkFile<<index_id[i]<<" "<<leftSlope[i]<<" "<<leftInt[i]<<" "<<rightSlope[i]<<" "<<rightInt[i]<<std::endl;
0046 }
0047 if (extra1==1 || extra2==1){
0048 std::cout<<"Flag not 0: "<<index_id[i]<<" " <<extra1<<" "<<extra2<<std::endl;
0049 }
0050 }
0051 }