#include "TSystem.h" #include "TROOT.h" #include "TFile.h" #include "TH1.h" #include "TH1D.h" #include "TH1F.h" #include "TCanvas.h" #include "TPad.h" #include "TProfile.h" #include "THistPainter.h" #include "TPaveStats.h" #include "THStack.h" #include "TList.h" #include "TDirectory.h" #include "THashTable.h" #include "TStyle.h" #include "TLegend.h" #include "TProfile.h" #include "TProfile2D.h" #include #include #include #include #include #include #include void read(){ TProfile* hprof = new TProfile("hprof", "prueba", 21, -10.5, 10.5); for(int j = 0; j < 30; j++){ for(int i = -10; i < 11; i++) hprof->Fill(i, i*i + i); for(int i = -10; i < 11; i++) hprof->Fill(i, -i*i + i); } int nBins = hprof->GetSize(); cout << "Number of bins of hprof without considering under and overflow = " << nBins - 2 << endl; TProfile* hprof2 = new TProfile("hprof2", "prueba2", 21, -10.5, 10.5); for(int bin = 0; i < nBins; i++){ hprof2->SetBinEntries(i, hprof->GetBinEntries(i)); hprof2->SetBinContent(i, hprof->GetBinContent(i)); hprof2->SetBinError(i, hprof->GetBinError(i)); } for(int i = 0; i < nBins;i++){ cout << "hprof2->GetBinEntries(bin=" << i << ") = " << hprof2->GetBinEntries(i) << endl; cout << "hprof2->GetBinContent(bin=" << i << ") = " << hprof2->GetBinContent(i) << endl; cout << "hprof2->GetBinError(bin=" << i << ") = " << hprof2->GetBinError(i) << "\n" << endl; cout << "hprof->GetBinEntries(bin=" << i << ") = " << hprof->GetBinEntries(i) << endl; cout << "hprof->GetBinContent(bin=" << i << ") = " << hprof->GetBinContent(i) << endl; cout << "hprof->GetBinError(bin=" << i << ") = " << hprof->GetBinError(i) << "\n" << endl; cout << "--------------------------------------------------------" << endl; } TCanvas* c_hprof = new TCanvas("c_hprof", "c_hprof",900,700); c_hprof->cd(); hprof->Draw(); TCanvas* c_hprof2 = new TCanvas("c_hprof2", "c_hprof2",900,700); c_hprof2->cd(); hprof2->Draw(); }