#include #include #include #include #include "TFile.h" #include "TTree.h" #include "TCut.h" #include "TROOT.h" #include "TBranch.h" #include "TH1.h" #include "TH2.h" #include "TCanvas.h" #include "TGaxis.h" #include "TImage.h" #include "TPaveStats.h" #include "TFormula.h" using namespace std; void example() { gROOT->Reset(); system("clear"); TH2F *h = NULL; TH1D *h_x = NULL; TH1D *h_y = NULL; TCanvas *c = NULL; TPad *pad_2D = NULL; TPad *pad_x = NULL; TPad *pad_y = NULL; TF2 *gaus2D = NULL; c = new TCanvas("c","",700,700); pad_2D = new TPad("","pad_2D",0.3,0.3,1,1); pad_2D->Draw(); pad_x = new TPad("Projection_X","pad_projection_X",1,0,0.3,0.3); pad_x->Draw(); pad_y = new TPad("Projection_Y","pad_projection_Y",0,1,0.3,0.3); pad_y->Draw(); c->Update(); gaus2D = new TF2("gaus2D","TMath::Gaus(x,3,.5)",0,6,0,6); h = new TH2F("h","test1",100,0,6,100,0,6); h->FillRandom("gaus2D",10000); pad_2D->cd(); h->Draw(); h_y = h->ProjectionY(); pad_x->cd(); h_y->Draw(); TImage *img=TImage::Create(); img->FromPad(pad_x); //img->Flip(90); pad_y->cd(); img->Draw("X"); pad_y->Modified(); pad_y->Update(); pad_x->Clear(); h_x = h->ProjectionX(); pad_x->cd(); h_x->Draw(); pad_x->Modified(); pad_x->Update(); c->Modified(); c->Update(); c->SaveAs("result.ps"); c->Close(); }