11void hist002_TH1_fillrandom_userfunc()
15 TFormula form1(
"form1",
"abs(sin(x)/x)");
18 double rangeMin = 0.0;
19 double rangeMax = 10.0;
20 TF1 sqroot(
"sqroot",
"x*gaus(0) + [3]*form1", rangeMin, rangeMax);
21 sqroot.SetLineColor(4);
22 sqroot.SetLineWidth(6);
24 double gausScale = 10.0;
25 double gausMean = 4.0;
27 double form1Scale = 20.0;
28 sqroot.SetParameters(gausScale, gausMean, gausVar, form1Scale);
32 TH1D h1d(
"h1d",
"Test random numbers", nBins, rangeMin, rangeMax);
35 h1d.FillRandom(
"sqroot", 10000);
38 auto myFile = std::unique_ptr<TFile>(
TFile::Open(
"fillrandom_userfunc.root",
"RECREATE"));
39 myFile->WriteObject(&form1, form1.GetName());
40 myFile->WriteObject(&sqroot, sqroot.GetName());
41 myFile->WriteObject(&h1d, h1d.GetName());
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
1-D histogram with a double per channel (see TH1 documentation)