TH1F* hist = new TH1F("hist", "Example Histogram", 10, 0, 10); hist->Fill(2); // fill bin 2 with a value hist->SetBinError(2, 0.5); // set the error of bin 2 to 0.5
// assuming we have a dataframe with a column named "data" TH1F* hist = new TH1F("hist", "Example Histogram", 10, 0, 10); for (int i = 0; i < df.size(); i++) { hist->Fill(df["data"][i]); // fill histogram with dataframe values hist->SetBinError(i, sqrt(hist->GetBinContent(i))); // set bin errors using Poisson error formula }In this example, we fill a histogram with values from a dataframe (assuming we have a column named "data"). We then use SetBinError to set the error of each bin using the Poisson error formula, which is the square root of the bin content. Package library: ROOT, a scientific software framework used in high-energy physics.