# Gaussian curves with predefined parameters

I am really new to ROOT and have been using the Gaussian fit function for histograms, but I was wondering if there is any way to
a) set certain parameters or center of this fit (for example, set a specific sigma value before calculating the fit
b) [More importantly] Graph an idealized gaussian with predetermined sigma, center, and amplitude on the same canvas as this histogram.

see example below

Rene

```void gex() { TH1F *h = new TH1F("h","test",100,-4,4); h->FillRandom("gaus",1000); TF1 *f1 = new TF1("f1","[0]*TMath::Gaus(x,[1],[2])",-4,4); f1->SetParameters(25,-0.3,0.5); f1->SetLineColor(kBlue); h->Draw(); f1->DrawCopy("same"); f1->SetLineColor(kRed); h->Fit(f1,"","same"); } ```

Thank you so much for your help!

When I added your code to my algorithm and ran it with real data (where I was trying to determine whether or not a significant peak existed in an area), the custom fit varied enough from the real fit that whenever I graphed the Tfunction on top of the histogram, the y scales did not fit, thus it had 2 y-axis scales. I tried to use "getYaxis"on the histogram, but I didn’t know how to assign these value to the y-axis scale on the Tgraph. It should be noted that I’m checking quite a few peaks, so I change the bin centers and content (over writing them). The fit declaration:
TF1 *f1 = new TF1(“f1”, “[0]*TMath::Gaus(x,[1],[2])”,lowbound, highbound);
Histogram declaration in loop:
TH1D h2(“h2”, “gauss1”, numbins2 , lowbound, highbound);

I attached a generated image to clarify the meaning of 2 y-axis scales. Thanks for the previous help and thank you in advance for any help/advice you can give.

Please provide the shortest possible RUNNING script such that we can understand what you mean in this message.

Rene