TH1F* hist1 = new TH1F("hist1", "Example Histogram", 100, 0, 100); // Create a TH1F histogram with 100 bins ranging from 0 to 100 TH1F* hist2 = (TH1F*)hist1->Clone(); // Create a copy of hist1 histogram with same binning and content
TH1F* hist1 = new TH1F("hist1", "Example Histogram", 100, 0, 100); // Create a TH1F histogram with 100 bins ranging from 0 to 100 TH1F* hist2 = new TH1F(*hist1); // Create a copy of hist1 histogram with same binning and content using copy constructorIn this example, a new TH1F histogram named "hist1" is created with 100 bins ranging from 0 to 100. Then, hist1 is cloned into a new histogram named "hist2" using the copy constructor with *hist1 as argument. Both examples demonstrate ways to create a copy of a TH1F histogram, where the Clone function is in package library ROOT.