#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" #include "TSystem.h" #include "TTree.h" #include "TTreePlayer.h" #include "TF1.h" #include "TCut.h" #include "TPaletteAxis.h" #include "stdio.h" #include "stdlib.h" #include "string.h" void scorelemma() { double R; //R coordinate double phi; //phi coordinate double z; //z coordinate double relen; //Released energy double relenq; //Released energy double ev; //Events double w; int n=3; int i=0; int c_YTitleSize=25; int c_YTitleFont=43; int c_YLabelFont=43; int c_YLabelSize=25; int c_XTitleSize=25; int c_XTitleFont=43; int c_XLabelFont=43; int c_XLabelSize=25; double c_XTitleOffsetTH3=2.; double c_YTitleOffsetTH3=2.; double c_ZTitleOffsetTH3=2.; float fillcolor=0.35; char dirin[50];//Directory where there is the input root file char dirout[50];//Main Directory where to save the output files char dirname[50]; char title[50]; char titleX[50]; char titleY[50]; char titleZ[50]; char titlecanv[50]; char informat[50]; char outformat[50]; char inname[50]; char scorname[50]; char volume[50]; sprintf(dirin, "C:/"); sprintf(dirout, "C:/"); sprintf(dirname, "scoring/"); sprintf(inname, "boxMesh_1"); //sprintf(inname, "boxMesh_2"); sprintf(informat, "txt"); sprintf(outformat, "pdf"); sprintf(scorname, "scoring"); sprintf(volume, "Target_1"); //sprintf(volume, "Target 2"); sprintf(title, "Released energy %s",volume); sprintf(titleX, "z"); sprintf(titleY, "#phi"); sprintf(titleZ, "R"); gSystem->mkdir(TString::Format("%s%s", dirout,dirname), kTRUE); TString outfolder=TString::Format("%s%s",dirout,dirname); TString myfile=TString::Format("%s%s.%s",dirin,inname,informat); TString cdname = TString::Format("%s",title); TString cdXname = TString::Format("%s",titleX); TString cdYname = TString::Format("%s",titleY); TString cdZname = TString::Format("%s",titleZ); TString canvtitle = TString::Format("%s",titlecanv); TString myplot = TString::Format("%s%s-%s.%s",outfolder.Data(), scorname, volume,outformat); TGaxis::SetMaxDigits(n); // FILE * infile=fopen(myfile, "r"); FILE * infile=fopen("C:/scoring/boxMesh_1.txt", "r"); if(infile==NULL) { printf("Error opening file"); exit(1); } TCanvas *c0 = new TCanvas("c0",canvtitle,1280,1024); TH3F *hscoring = new TH3F("hscoring","Released energy",100,0.,0.,100,0.,0.,100,0.,0.); //TH2F *hscoring = new TH2F("hscoring","Released energy",100,0.,0.,100,0.,0.); while( fscanf(infile,"%lf %lf %lf %lf %lf %lf",&z,&phi,&R,&relen,&relenq,&ev)!=NULL) { hscoring->Fill(R,phi,z,relen); //hscoring->Fill(R,relen); } hscoring->SetTitle(cdname); hscoring->GetXaxis()->SetTitle(cdXname); hscoring->GetYaxis()->SetTitle(cdYname); hscoring->GetZaxis()->SetTitle(cdZname); hscoring->GetYaxis()->SetTitleSize(c_YTitleSize); hscoring->GetYaxis()->SetTitleFont(c_YTitleFont); hscoring->GetYaxis()->SetTitleOffset(c_YTitleOffsetTH3); hscoring->GetYaxis()->SetLabelFont(c_YLabelFont); hscoring->GetYaxis()->SetLabelSize(c_YLabelSize); hscoring->GetXaxis()->SetTitleSize(c_XTitleSize); hscoring->GetXaxis()->SetTitleFont(c_XTitleFont); hscoring->GetXaxis()->SetTitleOffset(c_XTitleOffsetTH3); hscoring->GetXaxis()->SetLabelFont(c_XLabelFont); hscoring->GetXaxis()->SetLabelSize(c_XLabelSize); hscoring->GetZaxis()->SetTitleSize(c_XTitleSize); hscoring->GetZaxis()->SetTitleFont(c_XTitleFont); hscoring->GetZaxis()->SetTitleOffset(c_ZTitleOffsetTH3); hscoring->GetZaxis()->SetLabelFont(c_XLabelFont); hscoring->GetZaxis()->SetLabelSize(c_XLabelSize); hscoring->Draw("BOX2 Z"); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn /* TPaveStats *statshscoring = (TPaveStats*)hscoring->GetListOfFunctions()->FindObject("stats"); statshscoring->SetTextColor(kBlue); statshscoring->SetX1NDC(0.80); statshscoring->SetX2NDC(0.98); statshscoring->SetY1NDC(0.77); statshscoring->SetY2NDC(0.92); gPad->Update();*/ c0->Print(myplot); }