#include #include #include #include #include using namespace std; int countlines(string filename) { ifstream in; in.open(filename.c_str()); int nlines=0; string s; while(!in.eof()){ getline(in,s,'\n'); nlines++; } return nlines-1; } void MakeGraph(const int n,double u1[n],double u2[n], bool Xaxis, bool Yaxis) { TCanvas *CoT = new TCanvas("CoT","CoT",1); CoT->SetGrid(1,1); TGraph *gr = new TGraph(n,u1,u2); if(Xaxis==true) gr->GetXaxis()->SetTitle("Time(s)"); else gr->GetXaxis()->SetTitle("Voltage(V)"); if(Yaxis==true) gr->GetYaxis()->SetTitle("Current(nA)"); else gr->GetYaxis()->SetTitle("Voltage(V)"); gr->GetXaxis()->SetTickLength(0); gr->GetYaxis()->SetTickLength(0.01); gr->GetYaxis()->SetTitleOffset(1.4); gr->SetMarkerColor(kBlue); gr->SetMarkerStyle(22); gr->SetMarkerSize(1); gr->SetTitle("Leakage Current over Time"); gr->Draw("ap"); } int readfile(string filename, int c1, int c2) { bool Xaxis = false; bool Yaxis = true; if(c1==1) Xaxis=true; if(c2>=2 && c2<=9) Yaxis=false; const int n = countlines(filename); cout << n << endl; double temp1, temp2,temp3, temp4, temp5, temp6, temp7, temp8, temp9, temp10, temp11, temp12, temp13, temp14, temp15, temp16, temp17; double var[n][17]; string str; int ii=0,jj=0; ifstream fin; fin.open(filename.c_str()); while(getline(fin,str,'\n')){ if(str.at(0)=='#') { ii++; continue; } } fin.close(); fin.open(filename.c_str()); for(int k=0;k<(ii+1);k++){ if(ii!=0)getline(fin,str,'\n'); } int i=0; while (fin >> temp1 >> temp2 >> temp3 >> temp4 >> temp5 >> temp6 >> temp7 >> temp8 >>temp9 >> temp10 >> temp11 >> temp12 >> temp13 >> temp14 >> temp15 >> temp16 >> temp17){ var[i][0] = temp1; var[i][1] = temp2; var[i][2] = temp3; var[i][3] = temp4; var[i][4] = temp5; var[i][5] = temp6; var[i][6] = temp7; var[i][7] = temp8; var[i][8] = temp9; var[i][9] = temp10; var[i][10] = temp11; var[i][11] = temp12; var[i][12] = temp13; var[i][13] = temp14; var[i][14] = temp15; var[i][15] = temp16; var[i][16] = temp17; i++; } fin.close(); const int n2; double time[n]; double cur[n]; bool rewrite = false; int jj=0; std::vector time2; std::vector cur2; for(int j=0;j