TMath::Poisson function

Hello,
I’m trying to create a macro to generate a histogram using a Poisson function using a user defined mean. I can get the program to let the user define the mean, however when plugging the mean into the predefined function
"TMath::Poisson(x,mean)", it says that the parameter doesn’t exist. I cannot get the function to recognize the user defined mean as a numerical value. I’ve tried all the ways I could think of to fix the code and i feel that I’m missing just one small detail that’s keeping me from getting the macro to work correctly. Help is greatly appreciated. This is the code I’ve come up with that I keep coming back to because my changes do not work.

{
Double_t dr = 0.0;
cout << "Enter Mean " << endl;
cin >> dr;
cout << "Mean = " << dr << endl;
	
		TF1 *f1 = new TF1("f1","TMath::Poisson(x,dr)",0,200);
		TH1F *h1 = new TH1F("h1","Poisson",1000,0,200);
		h1->FillRandom("f1",1000);
		h1->Draw();
		
	return 0;
}

Everything works fine up to defining the function f1. Thanks for the help.

Hi,

if you want to mass the mean as a parameter to the TF1 do:

TF1 *f1 = new TF1("f1","TMath::Poisson(x,[0])",0,200);
f1->SetParameter(0,dr);

Lorenzo