Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:38

0001 #include <iostream>
0002 #include <fstream>
0003 #include <vector>
0004 #include <iostream>
0005 #include <string>
0006 
0007 using namespace std;
0008 
0009 int main(){
0010   float gainSlope, gainIntercept,chi2;
0011   int index,flag,flag1;
0012   int nrlines=0;
0013 
0014   std::vector<int>   index_id;
0015   std::vector<float> Slope;
0016   std::vector<float> Intercept;
0017   std::vector<float> gainChi2;
0018   
0019   std::ifstream dbdata; 
0020   dbdata.open("FileName",std::ios::in); 
0021   if(!dbdata) {
0022     std::cerr <<"Error: FileName -> no such file!"<< std::endl;
0023     exit(1);
0024   }
0025 
0026   while (!dbdata.eof() ) { 
0027     dbdata >> index >> gainSlope >> gainIntercept >>chi2 >>flag >>flag1; 
0028     index_id.push_back(index);
0029     Slope.push_back(gainSlope);
0030     Intercept.push_back(gainIntercept);
0031     gainChi2.push_back(chi2);
0032     nrlines++;
0033   }
0034   dbdata.close();
0035   std::ofstream myGainsFile("GoodVals_FileName",std::ios::out);
0036  
0037   for(int i=0; i<nrlines-1;++i){
0038     if (Slope[i]>6.0 && Slope[i]<11.0){
0039       myGainsFile<<index_id[i]<<"  "<<Slope[i]<<"  "<<Intercept[i]<<"  "<<gainChi2[i]<<std::endl;
0040       if (flag==1 || flag1==1){
0041   std::cout<<"Flag not 0: "<<index_id[i]<<" " <<flag<<"  "<<flag1<<std::endl;
0042       }
0043     }
0044   }
0045 }