import ROOT
Welcome to JupyROOT 6.07/07
Let's write in C++ the functions we will use to represent the interference figure. They will be JIT-ted: this will be more performant than a Python interpreted version.
%%cpp -d
auto pi = TMath::Pi();
double single(double *x, double *par){return pow(sin(pi*par[0]*x[0])/(pi*par[0]*x[0]),2);};
double nslit0(double *x, double *par){return pow(sin(pi*par[1]*x[0])/sin(pi*x[0]),2);};
double nslit(double *x, double *par){return single(x,par) * nslit0(x,par);};
We now write a ROOT function in Python wrapping the C++ function we created above. The number of points drawn is increased in order to visualize a smooth curve.
interfTF1 = ROOT.TF1("Slits interference",ROOT.nslit,-5.001,5.,2)
interfTF1.SetNpx(1000)
c = ROOT.TCanvas("c","c",1024,768)
def interFunction(Distances_Ratio, Number_Of_Slits):
interfTF1.SetParameters(Distances_Ratio,Number_Of_Slits)
interfTF1.Draw()
c.Draw()
The parameters with which one can play are two:
%jsroot on
interFunction(0.5, 3);