Fill a 1D histogram with random values using predefined functions.
void hist001_TH1_fillrandom()
{
int nBins = 200;
double rangeMin = 0.0;
double rangeMax = 10.0;
TH1D h1d(
"h1d",
"Test random numbers", nBins, rangeMin, rangeMax);
h1d.FillRandom("gaus", 10000);
auto myfile = std::unique_ptr<TFile>(
TFile::Open(
"fillrandom.root",
"RECREATE"));
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)
- Date
- November 2024
- Author
- Giacomo Parolini
Definition in file hist001_TH1_fillrandom.C.