#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" #include "TLatex.h" void depenetxt() { double DepEne; //Released energy int entry=1; gSystem->mkdir(TString::Format("simulazione" ), kTRUE); TGaxis::SetMaxDigits(3); //FILE * infile=fopen("B1/B1-build/DepositedEnergyData.txt", "r"); FILE * infile=fopen("DepositedEnergyData.txt", "r"); FILE * outfile = fopen("out.txt", "w"); if(infile==NULL) { printf("Error opening file"); exit(1); } TCanvas *c0 = new TCanvas("c0","c0",1280,1024); //c0->SetRightMargin(0.21); c0->SetLogy(); TH1F *histo = new TH1F("histo","DepositedEnergy",2500,0.,2500); // while( fscanf(infile,"%lf",&DepEne)==1) { // std::cout << "entry = " << entry << "\t Dep Ene = " << DepEne << std::endl; entry=entry+1; histo->Fill(DepEne); } histo->SetTitle(""); gStyle->SetTitleFontSize(0.08); histo->GetXaxis()->SetTitle("Energy (keV)"); histo->GetYaxis()->SetTitle("Counts"); histo->GetYaxis()->SetTitleSize(40); histo->GetYaxis()->SetTitleFont(43); histo->GetYaxis()->SetTitleOffset(1); histo->GetYaxis()->SetLabelFont(43); histo->GetYaxis()->SetLabelSize(40); histo->GetXaxis()->SetTitleSize(40); histo->GetXaxis()->SetTitleFont(43); histo->GetXaxis()->SetTitleOffset(1.1); histo->GetXaxis()->SetLabelFont(43); histo->GetXaxis()->SetLabelSize(40); int binmax = histo->GetMaximumBin(); // histo->SetMinimum(1.e-1); //histo->SetMaximum(1.e2); histo->SetStats(0); histo->Draw(""); gPad->Update(); gPad->Update(); /*TPaveStats *statshisto = (TPaveStats*)histo->GetListOfFunctions()->FindObject("stats"); statshisto->SetTextColor(kBlue); statshisto->SetX1NDC(0.70); statshisto->SetX2NDC(0.85); statshisto->SetY1NDC(0.825); statshisto->SetY2NDC(0.975); statshisto->Draw();*/ gPad->Update(); for (int i=1; i<=binmax; i++) { fprintf(outfile,"%g %g \n",histo->GetBinCenter(i),histo->GetBinContent(i)); } c0->Print("simulazione/DepositedEnergytxt.png"); }