#if defined(__CINT__) && !defined(__MAKECINT__) { TString macroName; macroName += "test.C++"; gROOT->LoadMacro(macroName.Data()); test(); } #else #include "TStyle.h" #include "TList.h" #include "TH3.h" #include "TH2.h" #include "TH1.h" #include "TNtuple.h" #include "TCanvas.h" #include "TF1.h" #include "TFile.h" #include "TGraph.h" #include "TLatex.h" namespace { Double_t my_transfer_function(const Double_t *x, const Double_t * /*param*/) { if (*x < 200) // return 0.001; return 0.001; if (*x > 200 && *x < 400) // return 0.015; return 0.02; if (*x < 400 && *x < 600) // return 0.02; return 0.04; if (*x > 600 && *x < 800) // return 0.05; return 0.07; if (*x > 800 && *x < 1000) return 0.1; return 0.2; } } void test() { TFile* f = TFile::Open("test.root"); TH3F* hist1 = (TH3F*)(f->Get("hist_1")); TH3F* hist2 = (TH3F*)(f->Get("hist_2")); TH3F* hist3 = (TH3F*)(f->Get("hist_3")); TH3F* hist4 = (TH3F*)(f->Get("hist_4")); //Now, specify the transfer function. TList * lf1 = hist1->GetListOfFunctions(); if (lf1) { TF1 * tf1 = new TF1("TransferFunction", my_transfer_function); lf1->Add(tf1); } TList * lf2 = hist2->GetListOfFunctions(); if (lf2) { TF1 * tf2 = new TF1("TransferFunction", my_transfer_function); lf2->Add(tf2); } TList * lf3 = hist3->GetListOfFunctions(); if (lf3) { TF1 * tf3 = new TF1("TransferFunction", my_transfer_function); lf3->Add(tf3); } TList * lf4 = hist4->GetListOfFunctions(); if (lf4) { TF1 * tf4 = new TF1("TransferFunction", my_transfer_function); lf4->Add(tf4); } gStyle->SetCanvasPreferGL(1); gStyle->SetPalette(1); TCanvas* c1 = new TCanvas("c1","Power Distribution",800,800); c1->Divide(2,2); c1->cd(1); gPad->SetRightMargin(0.15); hist1->Draw("glcolz"); c1->cd(2); hist2->Draw("glcolz"); c1->cd(3); hist3->Draw("glcolz"); c1->cd(4); hist4->Draw("glcolz"); } #endif