#include "fstream" #include "iostream" #include "TCanvas.h" #include "TLegend.h" #include "TH1D.h" #include "TGraph.h" #include "TAxis.h" #include "TPaveStats.h" #include "TLatex.h" #include "THStack.h" #include "TMultiGraph.h" #include "TLine.h" #include "TArrow.h" #include "math.h" using namespace std; int main() { //ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo // 1.2MeV fission fragment pulse amplitude spectrum //ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo TCanvas* c1=new TCanvas("1.2MeV Spectrum","1.2MeV Spectrum",900,600); c1->SetGrid(); ifstream ifile1("1.2MeV_PulseSpectrum.txt"); TMultiGraph* mgr1=new TMultiGraph(); TGraph* gr1=new TGraph("1.2MeV_PulseSpectrum.txt","%lg %lg"); gr1->SetLineColor(1); gr1->SetLineWidth(6); TGraph* gr2=new TGraph("FitData.txt","%lg %lg"); gr2->SetLineColor(2); gr2->SetLineWidth(10); TGraph* gr3=new TGraph(); double x,y; int start1=0; int startpoint1=0; while(gr1->GetPoint(startpoint1,x,y)!=-1) { if(x>=25.)gr3->SetPoint(start1,x,y); start1++; startpoint1++; } gr3->SetLineColor(5); gr3->SetFillStyle(1001); gr3->SetFillColor(5); TGraph* gr4=new TGraph(); int start2=0; int startpoint2=0; while(gr2->GetPoint(startpoint2,x,y)!=-1) { if(x<25.)gr4->SetPoint(start2,x,y); start2++; startpoint2++; } gr4->SetLineColor(3); gr4->SetFillStyle(1001); gr4->SetFillColor(3); /* for(int i=0;i<10;i++) { cout<GetPoint(i,x,y)<<" "<Add(gr1); mgr1->Add(gr2); mgr1->Add(gr3); mgr1->Add(gr4); mgr1->Draw("ALB"); mgr1->GetXaxis()->SetTitle("Channel"); mgr1->GetXaxis()->CenterTitle(); mgr1->GetXaxis()->SetTitleOffset(1.2); mgr1->GetXaxis()->SetRangeUser(0,300); mgr1->GetYaxis()->SetTitle("Counts"); mgr1->GetYaxis()->CenterTitle(); mgr1->GetYaxis()->SetTitleOffset(1.2); TLine* line1=new TLine(25,300,25,70); line1->SetLineColor(2); line1->SetLineWidth(3); line1->DrawClone("same"); TArrow* arrow1=new TArrow(25,65,25,60,0.05,"|>"); arrow1->SetArrowSize(0.01); arrow1->SetFillColor(2); arrow1->SetFillStyle(0); // arrow1->SetAngle(40); arrow1->SetLineWidth(2); arrow1->SetLineColor(2); arrow1->DrawClone(); TLatex* latex1=new TLatex(26,200,"25 channels"); latex1->SetTextSize(0.03); latex1->SetTextColor(2); latex1->SetTextFont(10); latex1->Draw(); c1->Print("1.2MeV Spectrum.pdf"); c1->Print("1.2MeV Spectrum.png"); c1->Print("1.2MeV Spectrum.svg"); /* TCanvas* c1=new TCanvas("Neutron Spectrum","Neutron Spectrum",900,600); double EnergyBorder1[53]{},Probability1[52]{}; ifstream ifile1("1.2MeV_PulseSpectrum.txt"); for(int i=0;i<52;i++) { ifile1>>EnergyBorder1[i]; ifile1>>Probability1[i]; } ifile1>>EnergyBorder1[52]; for(int i=0;i<52;i++) { Probability1[i]=Probability1[i]/log(EnergyBorder1[i+1]/EnergyBorder1[i]); } for(int i=0;i<52;i++) { cout<SetBinContent(i,Probability1[i-1]); hist1->SetLineColor(2); hist1->Draw(); // hist3->SetFillColor(2); hist1->GetXaxis()->SetTitle("Neutron Energy/MeV"); hist1->GetXaxis()->CenterTitle(); hist1->GetXaxis()->SetTitleOffset(1.2); // hist3->GetXaxis()->SetLimits(1e-2,20); // hist3->GetXaxis()->SetRangeUser(1e-10,20); hist1->GetXaxis()->SetRange(1,100); hist1->GetYaxis()->SetTitle("B_{E} #upoint E/s^{-1}"); hist1->GetYaxis()->CenterTitle(); hist1->GetYaxis()->SetTitleOffset(1.3); TH1* hist2=hist1->DrawCopy("same"); hist2->GetXaxis()->SetRangeUser(5,8); hist2->SetFillStyle(1001); hist2->SetFillColor(2); c1->Update(); c1->SetGrid(); c1->SetLogx(); // c1->SetLogy(); TPaveStats* pst1=(TPaveStats*)c1->GetPrimitive("stats"); pst1->SetTextColor(2); pst1->SetX1NDC(0.1); pst1->SetY1NDC(0.7); pst1->SetX2NDC(0.3); pst1->SetY2NDC(0.9); c1->Modified(); c1->Print("Am_Be.svg"); c1->Print("Am_Be.png"); c1->Print("Am_Be.pdf"); */ return 100000000; }