#include "TFile.h" #include "TCanvas.h" #include "TStyle.h" #include "TH1.h" #include "TH2.h" #include "TH3.h" #include "TGaxis.h" #include "TRandom.h" #include "TLegend.h" #include "TPaveStats.h" #include "TGraph.h" void calor() { float n=3; char myfilein[200]= "D:/si-500314.root"; char myplotout[200]="D:/si-500314.pdf"; char mytxtout[200]="D:/si-500314.txt"; char fobject[200]= "lemma"; char canvtitle[200]= "si-500314"; char hitsname[200]= "nhits"; char caloname[200]= "Calo_EnDep"; char cd1name[200]= "Hits"; char cd2name[200]= "Energy"; char cd1Xname[200]= "Hits"; char cd1Yname[200]= "#"; char cd2Xname[200]= "Energy"; char cd2Yname[200]= "#"; TFile *f = TFile::Open(myfilein); f->ls (); TGaxis::SetMaxDigits(n); if (f == 0) { printf("Error: cannot open the file!\n"); return; } TTree *t=0; f->GetObject(fobject,t); TCanvas *c = new TCanvas("c",canvtitle,1280,1024); c->Divide (2,1); c->cd(1); t->SetLineColor(kRed); t->Draw (hitsname); t->GetHistogram()->SetTitle(cd1name); //TH1F *htemp1 = (TH1F*)gPad->GetPrimitive(t); //htemp1->GetXaxis()->SetTitle(cd1Xname); //htemp1->GetYaxis()->SetTitle(cd1Yname); //htemp1->GetYaxis()->SetTitleSize(30); //htemp1->GetYaxis()->SetTitleFont(43); //htemp1->GetYaxis()->SetTitleOffset(1); //htemp1->GetYaxis()->SetLabelFont(43); //htemp1->GetYaxis()->SetLabelSize(30); //htemp1->GetXaxis()->SetTitleSize(30); //htemp1->GetXaxis()->SetTitleFont(43); //htemp1->GetXaxis()->SetTitleOffset(1); //htemp1->GetXaxis()->SetLabelFont(43); //htemp1->GetXaxis()->SetLabelSize(30); //htemp1->GetXaxis()->SetMinimum(0); //htemp1->Draw(); //gPad->Update(); c->cd(2); t->SetLineColor(kBlue); t->Draw (caloname); t->GetHistogram()->SetTitle(cd2name); //TH1F *htemp2 = (TH1F*)gPad->GetPrimitive(t); //htemp2->GetXaxis()->SetTitle(cd1Xname); //htemp2->GetYaxis()->SetTitle(cd1Yname); //htemp2->GetYaxis()->SetTitleSize(30); //htemp2->GetYaxis()->SetTitleFont(43); //htemp2->GetYaxis()->SetTitleOffset(1); //htemp2->GetYaxis()->SetLabelFont(43); //htemp2->GetYaxis()->SetLabelSize(30); //htemp2->GetXaxis()->SetTitleSize(30); //htemp2->GetXaxis()->SetTitleFont(43); //htemp2->GetXaxis()->SetTitleOffset(1); //htemp2->GetXaxis()->SetLabelFont(43); //htemp2->GetXaxis()->SetLabelSize(30); //htemp2->GetXaxis()->SetMinimum(0); //htemp2->Draw(); //gPad->Update(); c->Print(myplotout); delete c; gROOT->ProcessLine("gROOT->SetBatch(kFALSE)"); exit(); }