Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:42:14

0001 #include <iostream>
0002 #include <fstream>
0003 #include <vector>
0004 #include <iostream>
0005 #include <string>
0006 
0007 int main(){
0008 
0009   const int MAX_SIZE = 252288;
0010 
0011   int old_index;
0012   float old_slope, old_int, old_chi2;
0013   std::vector<int> old_index_id;
0014   std::vector<float> old_gains;
0015   std::vector<float> old_intercept;
0016   std::vector<float> old_chi;
0017 
0018   int new_index;
0019   float new_slope,new_int, new_chi2;
0020   std::vector<int> new_index_id;
0021   std::vector<float> new_gains;
0022   std::vector<float> new_intercept;
0023   std::vector<float> new_chi;
0024  
0025   std::vector<float> diff;
0026   std::vector<float> myoldgains;
0027 
0028   int counter,counter1;
0029   int old_nrlines=0;
0030   int new_nrlines=0;
0031 
0032   std::ifstream olddata; 
0033   olddata.open("goodGains2008_09_02.dat",std::ios::in); 
0034   if(!olddata) {
0035     std::cerr <<"Error: goodGains2008_09_02.dat -> no such file!"<< std::endl;
0036     exit(1);
0037   }
0038   
0039   while (!olddata.eof() ) { 
0040     olddata >> old_index >> old_slope ; 
0041     old_index_id.push_back(old_index);
0042     old_gains.push_back(old_slope);
0043     old_nrlines++;
0044   }
0045   olddata.close();
0046 
0047   std::ifstream newdata;
0048   std::ofstream myGainsFile("diffGainsOct_Aug109889.dat",std::ios::out);
0049   newdata.open("goodGains2009_08_07_run109889.dat",std::ios::in); 
0050   if(!newdata) {
0051     std::cerr <<"Error: goodGains2009_08_07_run109889.dat -> no such file!"<< std::endl;
0052     exit(1);
0053   }
0054   
0055   while (!newdata.eof() ) { 
0056     newdata >> new_index >> new_slope >> new_int >> new_chi2 ; 
0057     new_index_id.push_back(new_index);
0058     new_gains.push_back(new_slope);
0059     new_intercept.push_back(new_int);
0060     new_chi.push_back(new_chi2);
0061     new_nrlines++;
0062   }
0063   newdata.close();
0064   diff.resize(MAX_SIZE);
0065   myoldgains.resize(MAX_SIZE);
0066   
0067   for(int i=0; i<MAX_SIZE;++i){
0068     counter=old_index_id[i];  
0069     myoldgains[i]=old_gains[i];
0070 
0071     for (int k=0;k<new_index_id.size()-1;k++){
0072       counter1=new_index_id[k];
0073       if(counter == counter1){
0074     diff[k]=old_gains[i] - new_gains[k];
0075     //std::cout<<old_gains[i]<<" new_gains[k]"<<new_gains[k]<<std::endl;
0076     myGainsFile<<counter<<"  "<<diff[k]<<std::endl; 
0077       }
0078     }
0079   }
0080 }