static void SkipComments(ifstream &input){ // Look ahead in the input stream int c; bool cont = true; bool comment = false; while(cont && !input.eof()){ c = input.peek(); // Skip spaces if(c == ' ' || c == '\t') input.get(); // Skip end-of-lines else if(c == '\n'){ input.get(); // If we were inside a comment, we just finished it. comment = false; } // Skip comments else if(c == '#' || comment){ input.get(); // We are entering a comment (starting with '#' and finishing // with the end of the line). comment = true; } // If the last character found cannot be skipped else cont = false; } } int QEBialkali(){ // qe normalized to 1 const float qe[54]={ 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1.00 ,4.00, 9.00,12.00,15.00,17.00,18.00,19.00,19.70 ,20.00,20.20,20.30,20.40,20.30,20.20,20.10,20.00 ,19.70,19.00,18.00,17.00,16.00,14.50,13.50,12.00 ,11.00,10.00,9.00, 7.00, 5.00, 4.00, 3.50, 3.00 ,2.50 ,2.00 ,1.70 ,1.00 ,0.70 ,0.40 ,0.20 ,0.10 , 0.08, 0.04, 0.02, 0.01, 0.00, 0.00}; for (int i=0;i<54;i++){ float lambda=(i*10+185); cerr << lambda << " " << qe[i]/100.<< endl; } return 0; } int MPPC_PDE(char *fname){ // QEBialkali(); // return; double *xx=new double[200]; double *yy=new double[200]; int nc; ifstream fin(fname); if (fin.is_open()){ while (! fin.eof() ) { SkipComments(fin); fin >> xx[nc] >> yy[nc]; if (fin.eof())break; // cout << "x:" << xx[nc] <<" y:" << yy[nc]<< endl; nc++; } fin.close(); } else { cerr << fname <<" cannot be opened! "<< endl; } for (int gc=0;gcEval(i)/100.; if (val<0) val=0; cout << i << " " << val<< endl; xx[nc] = i; yy[nc] = g->Eval(i); nc++; } TGraph *g1=new TGraph(nc,xx,yy); TCanvas *c= new TCanvas("c","c",600,600); g->Draw("AC*"); g1->Draw("L"); c->Modified(); c->Update(); return 0; }