#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 caloene() { float n=3; int a=8; int b=9; char myfilein[200]= "D:/si-500330.root"; char myplotout[200]="D:/si-500330_ene.pdf"; char cd0name[200]= "si-500330: Energy_{Lead glass}_{0}"; char cd1name[200]= "si-500330: Energy_{Lead glass}_{1}"; char cd2name[200]= "si-500330: Energy_{Lead glass}_{2}"; char cd3name[200]= "si-500330: Energy_{Lead glass}_{3}"; char cd4name[200]= "si-500330: Energy_{Lead glass}_{4}"; char cd5name[200]= "si-500330: Energy_{Lead glass}_{5}"; char cd10name[200]= "si-500330: Energy_{Versa}_{10}"; char cd11name[200]= "si-500330: Energy_{Versa}_{11}"; char cd12name[200]= "si-500330: Energy_{Horsa}_{12}"; char cd13name[200]= "si-500330: Energy_{Horsa}_{13}"; char cd14name[200]= "si-500330: Energy_{Horsa}_{14}"; char cd15name[200]= "si-500330: Energy_{Horsa}_{15}"; char cd16name[200]= "si-500330: Energy_{Versa}_{16}"; char cd17name[200]= "si-500330: Energy_{Versa}_{17}"; char cd18name[200]= "si-500330: Energy_{Versa}_{18}"; char cd19name[200]= "si-500330: Energy_{Versa}_{19}"; char cd20name[200]= "si-500330: Energy_{Versa}_{20}"; char cd21name[200]= "si-500330: Energy_{Versa}_{21}"; char cd22name[200]= "si-500330: Energy_{Versa}_{22}"; char cd23name[200]= "si-500330: Energy_{Versa}_{23}"; char canvtitle[200]= "si-500330"; char fobject[200]= "lemma"; char caloname0[200]= "Calo_EnDep[0]"; char caloname1[200]= "Calo_EnDep[1]"; char caloname2[200]= "Calo_EnDep[2]"; char caloname3[200]= "Calo_EnDep[3]"; char caloname4[200]= "Calo_EnDep[4]"; char caloname5[200]= "Calo_EnDep[5]"; char caloname10[200]= "Calo_EnDep[10]"; char caloname11[200]= "Calo_EnDep[11]"; char caloname12[200]= "Calo_EnDep[12]"; char caloname13[200]= "Calo_EnDep[13]"; char caloname14[200]= "Calo_EnDep[14]"; char caloname15[200]= "Calo_EnDep[15]"; char caloname16[200]= "Calo_EnDep[16]"; char caloname17[200]= "Calo_EnDep[17]"; char caloname18[200]= "Calo_EnDep[18]"; char caloname19[200]= "Calo_EnDep[19]"; char caloname20[200]= "Calo_EnDep[20]"; char caloname21[200]= "Calo_EnDep[21]"; char caloname22[200]= "Calo_EnDep[22]"; char caloname23[200]= "Calo_EnDep[23]"; char cdXname[200]= "Energy (MeV)"; char cdYname[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 (5,4); c->cd(1); t->SetLineColor(kBlue); t->Draw (caloname0); t->GetHistogram()->SetTitle(cd0name); TH1F *htemp0 = (TH1F*)gPad->GetPrimitive("htemp"); htemp0->GetXaxis()->SetTitle(cdXname); htemp0->GetYaxis()->SetTitle(cdYname); htemp0->GetYaxis()->SetTitleSize(10); htemp0->GetYaxis()->SetTitleFont(43); htemp0->GetYaxis()->SetTitleOffset(1); htemp0->GetYaxis()->SetLabelFont(43); htemp0->GetYaxis()->SetLabelSize(10); htemp0->GetXaxis()->SetTitleSize(10); htemp0->GetXaxis()->SetTitleFont(43); htemp0->GetXaxis()->SetTitleOffset(1); htemp0->GetXaxis()->SetLabelFont(43); htemp0->GetXaxis()->SetLabelSize(10); htemp0->Draw(); gPad->Update(); c->cd(2); t->SetLineColor(kBlue); t->Draw (caloname1); t->GetHistogram()->SetTitle(cd1name); TH1F *htemp1 = (TH1F*)gPad->GetPrimitive("htemp"); htemp1->GetXaxis()->SetTitle(cdXname); htemp1->GetYaxis()->SetTitle(cdYname); htemp1->GetYaxis()->SetTitleSize(10); htemp1->GetYaxis()->SetTitleFont(43); htemp1->GetYaxis()->SetTitleOffset(1); htemp1->GetYaxis()->SetLabelFont(43); htemp1->GetYaxis()->SetLabelSize(10); htemp1->GetXaxis()->SetTitleSize(10); htemp1->GetXaxis()->SetTitleFont(43); htemp1->GetXaxis()->SetTitleOffset(1); htemp1->GetXaxis()->SetLabelFont(43); htemp1->GetXaxis()->SetLabelSize(10); htemp1->Draw(); gPad->Update(); c->cd(3); t->SetLineColor(kBlue); t->Draw (caloname2); t->GetHistogram()->SetTitle(cd2name); TH1F *htemp2 = (TH1F*)gPad->GetPrimitive("htemp"); htemp2->GetXaxis()->SetTitle(cdXname); htemp2->GetYaxis()->SetTitle(cdYname); htemp2->GetYaxis()->SetTitleSize(10); htemp2->GetYaxis()->SetTitleFont(43); htemp2->GetYaxis()->SetTitleOffset(1); htemp2->GetYaxis()->SetLabelFont(43); htemp2->GetYaxis()->SetLabelSize(10); htemp2->GetXaxis()->SetTitleSize(10); htemp2->GetXaxis()->SetTitleFont(43); htemp2->GetXaxis()->SetTitleOffset(1); htemp2->GetXaxis()->SetLabelFont(43); htemp2->GetXaxis()->SetLabelSize(10); htemp2->Draw(); gPad->Update(); c->cd(4); t->SetLineColor(kBlue); t->Draw (caloname3); t->GetHistogram()->SetTitle(cd3name); TH1F *htemp3 = (TH1F*)gPad->GetPrimitive("htemp"); htemp3->GetXaxis()->SetTitle(cdXname); htemp3->GetYaxis()->SetTitle(cdYname); htemp3->GetYaxis()->SetTitleSize(10); htemp3->GetYaxis()->SetTitleFont(43); htemp3->GetYaxis()->SetTitleOffset(1); htemp3->GetYaxis()->SetLabelFont(43); htemp3->GetYaxis()->SetLabelSize(10); htemp3->GetXaxis()->SetTitleSize(10); htemp3->GetXaxis()->SetTitleFont(43); htemp3->GetXaxis()->SetTitleOffset(1); htemp3->GetXaxis()->SetLabelFont(43); htemp3->GetXaxis()->SetLabelSize(10); htemp3->Draw(); gPad->Update(); c->cd(5); t->SetLineColor(kBlue); t->Draw (caloname4); t->GetHistogram()->SetTitle(cd4name); TH1F *htemp4 = (TH1F*)gPad->GetPrimitive("htemp"); htemp4->GetXaxis()->SetTitle(cdXname); htemp4->GetYaxis()->SetTitle(cdYname); htemp4->GetYaxis()->SetTitleSize(10); htemp4->GetYaxis()->SetTitleFont(43); htemp4->GetYaxis()->SetTitleOffset(1); htemp4->GetYaxis()->SetLabelFont(43); htemp4->GetYaxis()->SetLabelSize(10); htemp4->GetXaxis()->SetTitleSize(10); htemp4->GetXaxis()->SetTitleFont(43); htemp4->GetXaxis()->SetTitleOffset(1); htemp4->GetXaxis()->SetLabelFont(43); htemp4->GetXaxis()->SetLabelSize(10); htemp4->Draw(); gPad->Update(); c->cd(6); t->SetLineColor(kBlue); t->Draw (caloname5); t->GetHistogram()->SetTitle(cd5name); TH1F *htemp5 = (TH1F*)gPad->GetPrimitive("htemp"); htemp5->GetXaxis()->SetTitle(cdXname); htemp5->GetYaxis()->SetTitle(cdYname); htemp5->GetYaxis()->SetTitleSize(10); htemp5->GetYaxis()->SetTitleFont(43); htemp5->GetYaxis()->SetTitleOffset(1); htemp5->GetYaxis()->SetLabelFont(43); htemp5->GetYaxis()->SetLabelSize(10); htemp5->GetXaxis()->SetTitleSize(10); htemp5->GetXaxis()->SetTitleFont(43); htemp5->GetXaxis()->SetTitleOffset(1); htemp5->GetXaxis()->SetLabelFont(43); htemp5->GetXaxis()->SetLabelSize(10); htemp5->Draw(); gPad->Update(); c->cd(7); t->SetLineColor(kBlue); t->Draw (caloname10); t->GetHistogram()->SetTitle(cd10name); TH1F *htemp10 = (TH1F*)gPad->GetPrimitive("htemp"); htemp10->GetXaxis()->SetTitle(cdXname); htemp10->GetYaxis()->SetTitle(cdYname); htemp10->GetYaxis()->SetTitleSize(10); htemp10->GetYaxis()->SetTitleFont(43); htemp10->GetYaxis()->SetTitleOffset(1); htemp10->GetYaxis()->SetLabelFont(43); htemp10->GetYaxis()->SetLabelSize(10); htemp10->GetXaxis()->SetTitleSize(10); htemp10->GetXaxis()->SetTitleFont(43); htemp10->GetXaxis()->SetTitleOffset(1); htemp10->GetXaxis()->SetLabelFont(43); htemp10->GetXaxis()->SetLabelSize(10); htemp10->Draw(); gPad->Update(); c->cd(8); t->SetLineColor(kBlue); t->Draw (caloname11); t->GetHistogram()->SetTitle(cd11name); TH1F *htemp11 = (TH1F*)gPad->GetPrimitive("htemp"); htemp11->GetXaxis()->SetTitle(cdXname); htemp11->GetYaxis()->SetTitle(cdYname); htemp11->GetYaxis()->SetTitleSize(10); htemp11->GetYaxis()->SetTitleFont(43); htemp11->GetYaxis()->SetTitleOffset(1); htemp11->GetYaxis()->SetLabelFont(43); htemp11->GetYaxis()->SetLabelSize(10); htemp11->GetXaxis()->SetTitleSize(10); htemp11->GetXaxis()->SetTitleFont(43); htemp11->GetXaxis()->SetTitleOffset(1); htemp11->GetXaxis()->SetLabelFont(43); htemp11->GetXaxis()->SetLabelSize(10); htemp11->Draw(); gPad->Update(); c->cd(9); t->SetLineColor(kBlue); t->Draw (caloname12); t->GetHistogram()->SetTitle(cd12name); TH1F *htemp12 = (TH1F*)gPad->GetPrimitive("htemp"); htemp12->GetXaxis()->SetTitle(cdXname); htemp12->GetYaxis()->SetTitle(cdYname); htemp12->GetYaxis()->SetTitleSize(10); htemp12->GetYaxis()->SetTitleFont(43); htemp12->GetYaxis()->SetTitleOffset(1); htemp12->GetYaxis()->SetLabelFont(43); htemp12->GetYaxis()->SetLabelSize(10); htemp12->GetXaxis()->SetTitleSize(10); htemp12->GetXaxis()->SetTitleFont(43); htemp12->GetXaxis()->SetTitleOffset(1); htemp12->GetXaxis()->SetLabelFont(43); htemp12->GetXaxis()->SetLabelSize(10); htemp12->Draw(); gPad->Update(); c->cd(10); t->SetLineColor(kBlue); t->Draw (caloname13); t->GetHistogram()->SetTitle(cd13name); TH1F *htemp13 = (TH1F*)gPad->GetPrimitive("htemp"); htemp13->GetXaxis()->SetTitle(cdXname); htemp13->GetYaxis()->SetTitle(cdYname); htemp13->GetYaxis()->SetTitleSize(10); htemp13->GetYaxis()->SetTitleFont(43); htemp13->GetYaxis()->SetTitleOffset(1); htemp13->GetYaxis()->SetLabelFont(43); htemp13->GetYaxis()->SetLabelSize(10); htemp13->GetXaxis()->SetTitleSize(10); htemp13->GetXaxis()->SetTitleFont(43); htemp13->GetXaxis()->SetTitleOffset(1); htemp13->GetXaxis()->SetLabelFont(43); htemp13->GetXaxis()->SetLabelSize(10); htemp13->Draw(); gPad->Update(); c->cd(11); t->SetLineColor(kBlue); t->Draw (caloname14); t->GetHistogram()->SetTitle(cd14name); TH1F *htemp14 = (TH1F*)gPad->GetPrimitive("htemp"); htemp14->GetXaxis()->SetTitle(cdXname); htemp14->GetYaxis()->SetTitle(cdYname); htemp14->GetYaxis()->SetTitleSize(10); htemp14->GetYaxis()->SetTitleFont(43); htemp14->GetYaxis()->SetTitleOffset(1); htemp14->GetYaxis()->SetLabelFont(43); htemp14->GetYaxis()->SetLabelSize(10); htemp14->GetXaxis()->SetTitleSize(10); htemp14->GetXaxis()->SetTitleFont(43); htemp14->GetXaxis()->SetTitleOffset(1); htemp14->GetXaxis()->SetLabelFont(43); htemp14->GetXaxis()->SetLabelSize(10); htemp14->Draw(); gPad->Update(); c->cd(12); t->SetLineColor(kBlue); t->Draw (caloname15); t->GetHistogram()->SetTitle(cd15name); TH1F *htemp15 = (TH1F*)gPad->GetPrimitive("htemp"); htemp15->GetXaxis()->SetTitle(cdXname); htemp15->GetYaxis()->SetTitle(cdYname); htemp15->GetYaxis()->SetTitleSize(10); htemp15->GetYaxis()->SetTitleFont(43); htemp15->GetYaxis()->SetTitleOffset(1); htemp15->GetYaxis()->SetLabelFont(43); htemp15->GetYaxis()->SetLabelSize(10); htemp15->GetXaxis()->SetTitleSize(10); htemp15->GetXaxis()->SetTitleFont(43); htemp15->GetXaxis()->SetTitleOffset(1); htemp15->GetXaxis()->SetLabelFont(43); htemp15->GetXaxis()->SetLabelSize(10); htemp15->Draw(); gPad->Update(); c->cd(13); t->SetLineColor(kBlue); t->Draw (caloname16); t->GetHistogram()->SetTitle(cd16name); TH1F *htemp16 = (TH1F*)gPad->GetPrimitive("htemp"); htemp16->GetXaxis()->SetTitle(cdXname); htemp16->GetYaxis()->SetTitle(cdYname); htemp16->GetYaxis()->SetTitleSize(10); htemp16->GetYaxis()->SetTitleFont(43); htemp16->GetYaxis()->SetTitleOffset(1); htemp16->GetYaxis()->SetLabelFont(43); htemp16->GetYaxis()->SetLabelSize(10); htemp16->GetXaxis()->SetTitleSize(10); htemp16->GetXaxis()->SetTitleFont(43); htemp16->GetXaxis()->SetTitleOffset(1); htemp16->GetXaxis()->SetLabelFont(43); htemp16->GetXaxis()->SetLabelSize(10); htemp0->Draw(); gPad->Update(); c->cd(14); t->SetLineColor(kBlue); t->Draw (caloname17); t->GetHistogram()->SetTitle(cd17name); TH1F *htemp17 = (TH1F*)gPad->GetPrimitive("htemp"); htemp17->GetXaxis()->SetTitle(cdXname); htemp17->GetYaxis()->SetTitle(cdYname); htemp17->GetYaxis()->SetTitleSize(10); htemp17->GetYaxis()->SetTitleFont(43); htemp17->GetYaxis()->SetTitleOffset(1); htemp17->GetYaxis()->SetLabelFont(43); htemp17->GetYaxis()->SetLabelSize(10); htemp17->GetXaxis()->SetTitleSize(10); htemp17->GetXaxis()->SetTitleFont(43); htemp17->GetXaxis()->SetTitleOffset(1); htemp17->GetXaxis()->SetLabelFont(43); htemp17->GetXaxis()->SetLabelSize(10); htemp17->Draw(); gPad->Update(); c->cd(15); t->SetLineColor(kBlue); t->Draw (caloname18); t->GetHistogram()->SetTitle(cd18name); TH1F *htemp18 = (TH1F*)gPad->GetPrimitive("htemp"); htemp18->GetXaxis()->SetTitle(cdXname); htemp18->GetYaxis()->SetTitle(cdYname); htemp18->GetYaxis()->SetTitleSize(10); htemp18->GetYaxis()->SetTitleFont(43); htemp18->GetYaxis()->SetTitleOffset(1); htemp18->GetYaxis()->SetLabelFont(43); htemp18->GetYaxis()->SetLabelSize(10); htemp18->GetXaxis()->SetTitleSize(10); htemp18->GetXaxis()->SetTitleOffset(1); htemp18->GetXaxis()->SetLabelFont(43); htemp18->GetXaxis()->SetLabelSize(10); htemp18->Draw(); gPad->Update(); c->cd(16); t->SetLineColor(kBlue); t->Draw (caloname19); t->GetHistogram()->SetTitle(cd19name); TH1F *htemp19 = (TH1F*)gPad->GetPrimitive("htemp"); htemp19->GetXaxis()->SetTitle(cdXname); htemp19->GetYaxis()->SetTitle(cdYname); htemp19->GetYaxis()->SetTitleSize(10); htemp19->GetYaxis()->SetTitleFont(43); htemp19->GetYaxis()->SetTitleOffset(1); htemp19->GetYaxis()->SetLabelFont(43); htemp19->GetYaxis()->SetLabelSize(10); htemp19->GetXaxis()->SetTitleSize(10); htemp19->GetXaxis()->SetTitleFont(43); htemp19->GetXaxis()->SetTitleOffset(1); htemp19->GetXaxis()->SetLabelFont(43); htemp19->GetXaxis()->SetLabelSize(10); htemp19->Draw(); gPad->Update(); c->cd(17); t->SetLineColor(kBlue); t->Draw (caloname20); t->GetHistogram()->SetTitle(cd20name); TH1F *htemp20 = (TH1F*)gPad->GetPrimitive("htemp"); htemp20->GetXaxis()->SetTitle(cdXname); htemp20->GetYaxis()->SetTitle(cdYname); htemp20->GetYaxis()->SetTitleSize(10); htemp20->GetYaxis()->SetTitleFont(43); htemp20->GetYaxis()->SetTitleOffset(1); htemp20->GetYaxis()->SetLabelFont(43); htemp20->GetYaxis()->SetLabelSize(10); htemp20->GetXaxis()->SetTitleSize(10); htemp20->GetXaxis()->SetTitleFont(43); htemp20->GetXaxis()->SetTitleOffset(1); htemp20->GetXaxis()->SetLabelFont(43); htemp20->GetXaxis()->SetLabelSize(10); htemp20->Draw(); gPad->Update(); c->cd(18); t->SetLineColor(kBlue); t->Draw (caloname21); t->GetHistogram()->SetTitle(cd21name); TH1F *htemp21 = (TH1F*)gPad->GetPrimitive("htemp"); htemp21->GetXaxis()->SetTitle(cdXname); htemp21->GetYaxis()->SetTitle(cdYname); htemp21->GetYaxis()->SetTitleSize(10); htemp2->GetYaxis()->SetTitleFont(43); htemp21->GetYaxis()->SetTitleOffset(1); htemp21->GetYaxis()->SetLabelFont(43); htemp21->GetYaxis()->SetLabelSize(10); htemp21->GetXaxis()->SetTitleSize(10); htemp21->GetXaxis()->SetTitleFont(43); htemp21->GetXaxis()->SetTitleOffset(1); htemp21->GetXaxis()->SetLabelFont(43); htemp21->GetXaxis()->SetLabelSize(10); htemp21->Draw(); gPad->Update(); c->cd(19); t->SetLineColor(kBlue); t->Draw (caloname22); t->GetHistogram()->SetTitle(cd22name); TH1F *htemp22 = (TH1F*)gPad->GetPrimitive("htemp"); htemp22->GetXaxis()->SetTitle(cdXname); htemp22->GetYaxis()->SetTitle(cdYname); htemp22->GetYaxis()->SetTitleSize(10); htemp22->GetYaxis()->SetTitleFont(43); htemp22->GetYaxis()->SetTitleOffset(1); htemp22->GetYaxis()->SetLabelFont(43); htemp22->GetYaxis()->SetLabelSize(10); htemp22->GetXaxis()->SetTitleSize(10); htemp22->GetXaxis()->SetTitleFont(43); htemp22->GetXaxis()->SetTitleOffset(1); htemp22->GetXaxis()->SetLabelFont(43); htemp22->GetXaxis()->SetLabelSize(10); htemp22->Draw(); gPad->Update(); c->cd(20); t->SetLineColor(kBlue); t->Draw (caloname23); t->GetHistogram()->SetTitle(cd23name); TH1F *htemp23 = (TH1F*)gPad->GetPrimitive("htemp"); htemp23->GetXaxis()->SetTitle(cdXname); htemp23->GetYaxis()->SetTitle(cdYname); htemp23->GetYaxis()->SetTitleSize(10); htemp23->GetYaxis()->SetTitleFont(43); htemp23->GetYaxis()->SetTitleOffset(1); htemp23->GetYaxis()->SetLabelFont(43); htemp23->GetYaxis()->SetLabelSize(10); htemp23->GetXaxis()->SetTitleSize(10); htemp23->GetXaxis()->SetTitleFont(43); htemp23->GetXaxis()->SetTitleOffset(1); htemp23->GetXaxis()->SetLabelFont(43); htemp23->GetXaxis()->SetLabelSize(10); htemp23->Draw(); gPad->Update(); c->Print(myplotout); delete c; gROOT->ProcessLine("gROOT->SetBatch(kFALSE)"); exit(); }