Fitting with two gaussian curves

Try also:

{
#if 1 /* 0 or 1 */
  TFile *f = TFile::Open("h.root");
  if ((!f) || f->IsZombie()) { delete f; return; } // just a precaution
  TH1F *h; f->GetObject("h", h);
  if (!h) { delete f; return; } // just a precaution
#else /* 0 or 1 */
  TH1F *h= new TH1F("h", "trkmm gaussian fit", 50, 4, 16);
  ((TF1*)gROOT->GetFunction("gaus"))->SetParameters(1., 8., 1.);
  h->FillRandom("gaus");
  ((TF1*)gROOT->GetFunction("gaus"))->SetParameters(1., 10., 1.);
  h->FillRandom("gaus");
#endif /* 0 or 1 */
  
  TF1 *g1 = new TF1 ("m1", "gaus", 4, 9);
  g1->SetLineColor(kRed);
  TF1 *g2 = new TF1 ("m2", "gaus", 8, 14);
  g2->SetLineColor(kGreen);
  TF1 *f1 = new TF1("double_gaus", "gaus(0) + gaus(3)", 4, 16);
  f1->SetParNames("Constant 1", "Mean 1", "Sigma 1",
                  "Constant 2", "Mean 2", "Sigma 2");
  f1->SetLineColor(kBlue);
  
  gStyle->SetOptFit(1);
  
  h->Fit(g1, "R");
  h->Fit(g2, "R");
  
  Double_t par[6];
  g1->GetParameters(&par[0]);
  g2->GetParameters(&par[3]);
  f1->SetParameters(par);
  
  h->Fit(f1, "R");
  // h->Fit(f1, "+", "e1", 4, 16);
  h->Draw("e1");
  
  g1->Draw("SAME");
  g2->Draw("SAME");
  f1->Draw("SAME");
  
  std::cout << std::endl; g1->Print();
  std::cout << std::endl; g2->Print();
  std::cout << std::endl; f1->Print();
}