Hello,
I am having issues graphing an integral of a TF1 function I created. Below is my source code:
#include <iostream>
#include "TF1.h"
#include "TGraph.h"
#include "Math/Integrator"
using namespace std;
void main()
{
TCanvas *c1 = new TCanvas("c1", "br");
TF1 *f1 = new TF1("Differential Cross Section of Compton Scattering for 5MeV Photons",myfunction,0,10,3);
f1->SetParameters(0.0794, 9.769, 5.0);
f1->SetParNames("electron radius squared","Incident Photon Energy/Rest Mass Energy of Electron", "Incident Photon Energy");
gPad -> SetLogy();
f1->Draw();
f1->GetHistogram()->GetYaxis()->SetTitle("d#sigma/dE_{k}(barns/MeV)");
f1->GetHistogram()->GetXaxis()->SetTitle("Kinetic Energy of Ejected Electron = E_{k}(MeV)");
c1->Modified();
TGraph *g = (TGraph*)f1->DrawIntegral();
}
Double_t myfunction(Double_t *x, Double_t *par)
{
const Double_t pi = TMath::Pi();
Float_t y = x[0];
Double_t f = (pi*par[0])/(par[1]*par[2])*(2-(2*y)/(par[1]*(par[2]-y))+(y*y)/((par[1]*par[1])*(par[2]-y)*(par[2]-y))+(y*y/(par[2]*(par[2]-y))));
return f;
}
When I run this macro I get this:
Warning: template pair duplicate definition /usr/local/root/cint/cint/stl/_pair.h:31:
Warning: template reverse_iterator duplicate definition /usr/local/root/cint/cint/stl/_iterator.h:269:
Warning: template vector duplicate definition /usr/local/root/cint/cint/stl/_vector.h:44:
^C
*** Break *** keyboard interrupt main.cpp:33:
^C
*** Break *** keyboard interrupt
Thank you in advance!
Natasha