Dear Rooters,
Sorry for this silly issue, I tried for quite long time and yet can’t figure out what is wrong with my code.
I can’t create a Profile plot of my TH2F hist. However I saved the my TH2F into a root file and can create the TProfile.
P.S: I am using ROOT 6.10/02. Mac OsX binary release.
Follow the lines:
void Plotter() {
TFile *f_model1 = TFile::Open("result_model1.root");
TTree * t_f0980 = (TTree*)f_model1->Get("f0980");
TTree * t_FCN = (TTree*)f_model1->Get("FCN");
TH2F * h2_f0980_mag_vs_FCN = new TH2F("h2_f0980_mag_vs_FCN","", 100, 0.46,0.56, 100, 449e3,447e3);
Double_t magnitude;
Double_t fcn;
t_f0980->SetBranchAddress("magnitude",&magnitude);
t_FCN->SetBranchAddress("FCN",&fcn);
for(unsigned int i=0;i<t_f0980->GetEntries();i++) {
t_f0980->GetEntry(i);
t_FCN->GetEntry(i);
h2_f0980_mag_vs_FCN->Fill(magnitude,fcn,1.0);
}
TCanvas *c1 = new TCanvas("c1","show profile",600,900);
c1->Divide(1,2);
c1->cd(1);
h2_f0980_mag_vs_FCN->Draw("colz");
//TFile *f = new TFile("test.root", "RECREATE"); ///but if I write into a root file I can create the Profile
//h2_f0980_mag_vs_FCN->Write();
//f->Close();
c1->cd(2);
TProfile * prof = h2_f0980_mag_vs_FCN->ProfileX();
prof->Draw(); // it is empty :frowning
}
result_model1.root (44.1 KB)