#include "TROOT.h" #include "TH1F.h" #include #include #include "TPad.h" #include "TGraph.h" #include "TCanvas.h" #include "TFile.h" #include #include #include #include "THStack.h" #include "Riostream.h" #include "TMath.h" #include "TF1.h" #include using namespace std; void code() { gROOT->Reset(); Int_t dimx_c=800; Int_t dimy_c=800; TH2D* hist=new TH2D("hist","",200,-100,100,200,-100,100); arbre->Project("hist"," : "); //there I would like to get informations of the X and Y Treeviewer functions. TCanvas *c = new TCanvas ("c","Projection",dimx_c,dimy_c); c->Update(); TPad * pad_graph2D = new TPad("","pad_graph2D",0.25,0.25,1,1); hist->SetTitle("Titre: Graphique 2D"); hist->GetXaxis()->SetTitle("Axe des X"); hist->GetYaxis()->SetTitle("Axe des Y"); pad_graph2D->Draw(); pad_graph2D->cd(); hist->Draw(); // --- X Projection --- c->cd(); TPad * pad_projx = new TPad("Projection_X","pad_projection_X",1,0,0.25,0.3); TH1D * projx = hist->ProjectionX(); projx->SetTitle("Projection selon x"); projx->GetXaxis()->SetTitle("Axe des X"); projx->GetYaxis()->CenterTitle(); projx->GetYaxis()->SetTitle("Axe des Y"); projx->SetLabelSize(0.06,"xy"); pad_projx->Draw(); pad_projx->cd(); pad_projx->Update(); projx->Draw(); pad_projx->RedrawAxis(); // --- Y Projection --- TH1D *projy = hist->ProjectionY(); projy->SetTitle("Projection selon y"); projy->GetXaxis()->SetTitle("Axe des X"); projy->GetYaxis()->CenterTitle(); projy->GetYaxis()->SetTitle("Axe des Y"); projy->SetLabelSize(0.06,"xy"); c->cd(); TPad *pad_projy = new TPad("Projection_Y","pad_projection_Y",0,1,0.3,0.25); pad_projy->Draw(); TCanvas *c_temp=new TCanvas ("c_temp","canevas_temporaire",dimx_c,dimy_c); c_temp->cd(); TPad * pad_projy_temp = new TPad("Pad_temporaire","pad_temporaire",1,0,0.25,0.3); pad_projy_temp->Draw(); pad_projy_temp->cd(); projy->Draw(); pad_projy_temp->Update(); TImage *img = TImage::Create(); img->FromPad(pad_projy_temp); img->Flip(90); pad_projy->cd(); img->Draw("x"); pad_projy->Update(); c_temp->Close(); }