#include #include #include #include #include #include "TH1F.h" #include "TF1.h" #include "TGraph.h" using namespace std; #define MAX 1 #define MIN -1 #define DATA 50 void RESET(double data_1[],double data_2[],int i){ for(int j=0;j "; cin>>input_name; ifstream myfile (input_name); TF1 *Fit_Landau=new TF1("Fit_Landau","-[0]*TMath::Landau(x,[1],[2])",MIN,MAX); TF1 *Int=new TF1("Integral","-[0]*TMath::Landau(x,[1],[2])",MIN,MAX); if(myfile.is_open()){ while(getline(myfile,line) && !myfile.eof()){ if(line.empty()) { TGraph *data=new TGraph(i,x,y); data->Draw("AP*"); Fit_Landau->SetParameters(y_min,0.01,0.01); data->Fit("Fit_Landau"); Cout++; Int->SetParameters(Fit_Landau->GetParameter(0),Fit_Landau->GetParameter(1),Fit_Landau->GetParameter(2)); sum+=Int->Integral(MIN,MAX); RESET(x,y,i); y_min=0.; i=0; }else{ istringstream iss(line); iss >> a >> b; if(fabs(a)>fabs(y_min)){ y_min=a; } y[i]=b; x[i]=a; i++; } } }else{ cout<< "File non aperto"<SetParameters(0.01,0.01,0.01); value->Fit("Fit_Landau"); Fit_Gauss->SetParameters(0.01,0.,0.01); value->Fit("Fit_Gauss"); Fit_Combinated->SetParameters(Fit_Gauss->GetParameter(0),Fit_Gauss->GetParameter(1),Fit_Gauss->GetParameter(2),Fit_Landau->GetParameter(0),Fit_Landau->GetParameter(1),Fit_Landau->GetParameter(2)); value->Fit("Fit_Combinated"); valore=Fit_Combinated->GetParameter(0); cout<<"il valore è dato da:"<Draw("AP*"); */ /* ifstream input("dati.dat",ios::in); TH1F *histo= new TH1F("histo","First_histo",1000,0.,MAX); while(!input.eof()){ double variable; input>>variable; histo->Fill(variable); } double valore; //std::ofstream oFile("Output_dat", std::ios_base::out | std::ios_base); */ /* (result.is_open()) ? result << "Parameter 0 = " << f->GetParameter(0) << " Parameter 1 = " << f->GetParameter(1) << " Integral = "<< f->Integral(- TMath::Infinity(),TMath::Infinity()) << '\n' : cout << "Unable to open output file"; */