Commit ed2053da authored by Keerthi Nakkalil's avatar Keerthi Nakkalil
Browse files

Time difference [ns] vs Injected voltage [mv] for a single pixel without the fit

parent c92e7321
void createfiles(int r, int c){
std::ifstream Energy_file("Energy_table.dat");
std::vector<double>Energy_e = {200,300,400,500,600,700,800,900,1000,1100,1200,
1300,1400,1500,1700,2200,2700,3200,4000,5000,6000,
7000,8000,9000,10000,11000,12000,13000,14000};
if (Energy_file.is_open()){
std::cout << "Energy_table.dat is opened..." << std::endl;
ofstream file125_125("125_125.txt", ios::ate);//ios::ate- delete the output file before running each time. Otherwise will land with weird error
std::string line_1,line_2;
int Ecol1,Ecol2,Ecol3, TPcol1,TPcol2,TPcol3;
int ctr_E = 0, ctr_TOA = 0;
double Ecol4[30] = {0}, tot,tot_var,toa[30] = {0},toa_var[30] = {0},toa_ref ;
while(getline(Energy_file,line_1)){
istringstream ss1(line_1);
ss1 >> Ecol1 >> Ecol2 >> Ecol3 >> Ecol4[ctr_E];
// std::cout << "Elements " << Ecol4[ctr_E] << " ctr " << ctr_E << std::endl;
ctr_E++;
}
for(int i= 0; i < Energy_e.size(); i++){
// cout <<"testing..."<<std::endl;
stringstream Sfile;
Sfile << Energy_e.at(i) << ".dat";
// std::cout << "Files : " << Sfile.str() << std::endl;
std::vector<std::string>File_names = {std::string("tp_dat_" + Sfile.str())};
for (int j = 0; j < File_names.size(); j++ ) {
std::ifstream Data_file(File_names.at(j));
if(Data_file.is_open()){
// std::cout << "The data file " << File_names.at(j) << " is opened ..." << std::endl;
while(getline(Data_file,line_2)){
// cout << " looking at each line ... " <<std::endl;
if(line_2.rfind("#", 0) == 0) {
continue;
}
//cout <<" ignoring lines which start with #"<<std::endl;
istringstream ss2(line_2);
ss2 >> TPcol1 >> TPcol2 >> TPcol3 >> tot >> tot_var >> toa[ctr_TOA] >> toa_var[ctr_TOA];
if (TPcol1==125){
// cout << " checking for row 125..."<<std::endl;
if (TPcol2==125){
// cout << " Checking for row 125 and col 125 ..."<<std::endl;
// std::cout << "Elements " << toa[ctr_TOA] << "\t" << toa_var[ctr_TOA] << std::endl;
ctr_TOA++;
}
}
}
}
else {
std::cout << "Unable to open " <<File_names.at(j) << " file ..." << std::endl;
}
}
}
for(int k = 0; k < 29; k++){
if(toa[k]!=0){
file125_125 << Ecol4[k] << "\t" << toa[k] << "\t" << sqrt(toa_var[k]) << std::endl;
}
}
cout << " Output file writen..."<<std::endl;
}
else{
std:: cout << "Unable to open Energy_table.dat file" <<std::endl;
}
}
void toa_calib(){
int row = 125, col = 125;
createfiles(row,col);
std::cout << " Done ..." <<std ::endl;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment