// Create a histogram object TH2D hist("hist", "My histogram", 100, 0, 100, 100, 0, 100); // Fill the histogram with some data hist.Fill(10, 20); hist.Fill(30, 40); hist.Fill(50, 60); // Create a clone of the histogram TH2D* hist_clone = (TH2D*)hist.Clone();
// Create a histogram object TH2D hist("hist", "My histogram", 100, 0, 100, 100, 0, 100); // Fill the histogram with some data hist.Fill(10, 20); hist.Fill(30, 40); hist.Fill(50, 60); // Create a clone of the histogram TH2D* hist_clone = (TH2D*)hist.Clone(); // Modify the clone hist_clone->SetFillColor(2); // Draw the original histogram and the clone on the same canvas TCanvas c; hist.Draw(); hist_clone->Draw("SAME"); c.SaveAs("my_histogram.png");
// Create a histogram object TH2D hist("hist", "My histogram", 100, 0, 100, 100, 0, 100); // Fill the histogram with some data hist.Fill(10, 20); hist.Fill(30, 40); hist.Fill(50, 60); // Create a clone of the histogram TH2D* hist_clone = (TH2D*)hist.Clone(); // Do some analysis with the clone ... // Delete the clone when you are done with it delete hist_clone;The TH2D Clone function is part of the ROOT package library. ROOT is a set of C++ libraries and tools for scientific data analysis and visualization. It is widely used in particle physics research and other scientific fields.