TH1D* hist = new TH1D("hist","Histogram",100,0,1); hist->FillRandom("gaus", 10000); TF1* gaussFit = hist->GetFunction("gaus");
TH1D* hist = new TH1D("hist","Histogram",50,0,10); hist->FillRandom("expo", 10000); TF1* exponentialFit = hist->GetFunction("expo"); Double_t integral = exponentialFit->Integral(2,8);This example creates a new TH1D object and fills it with random numbers from an exponential distribution. It then extracts the exponential function fit using GetFunction and calculates the definite integral of the function between the x-axis limits of 2 to 8, storing the result in the "integral" variable for further use. In both of these examples, the ROOT data analysis framework is used to generate and analyze simulated data sets. ROOT is an open-source project developed by CERN, the European Organization for Nuclear Research, and is freely available to the scientific community.