#include #include #include #include using namespace std; class CSpectrum{ public: double R,I,Wmax; double Emax,I; static double mec2; public: double Subspec(); void Spec(); }; double CSpectrum::mec2=0.51; //function-----OK double Subspec(double W,double Wmax_,int Z_){ double mec2=0.51; double alpha=1/137.0359895; if(1-TMath::Power(alpha*Z_,2)>0){ double gamma=TMath::Power(1-TMath::Power(alpha*Z_,2),0.5); if(TMath::Power(W,2)-TMath::Power(mec2,2)>0){ double y=alpha*Z_*W*TMath::Power(TMath::Power(W,2)-TMath::Power(mec2,2),-0.5); double f; f=W*TMath::Power(Wmax_-W,2)*TMath::Power(TMath::Power(W,2)-TMath::Power(mec2,2),gamma-0.5)*TMath::Exp(TMath::Pi()*y)*TMath::Power(TMath::Abs(TMath::Gamma(y)),2); } } return f; } CSpectrum::Spec(){ TCanvas *c=new TCanvas(); ifstream fp1("Udata.dat"); int Inline =0; int n=Inline+1; std::string line; TF1 *f[4]; //read data-------OK while(getline(fp1, line)) { std::stringstream ss(line); ss >> Emax>> I; // cout<SetParameter(0,Wmax);// Wmax is OK f1->SetParameter(1,92); f1->SetLineColor(n+2); f1->Draw(); } if(Inline>=1){ cout<SetParameter(1,Wmax); f[n]->SetParameter(2,84); f[n]->SetLineColor(n+2); f[n]->Draw("same"); } Inline++; } }