#include "TCanvas.h" #include "TBrowser.h" #include "TH2F.h" #include "TH1F.h" #include "TGraph.h" #include "TGraphErrors.h" #include "TMath.h" #include #include "TFrame.h" #include "TSystem.h" #include "TLegend.h" #include "TLegendEntry.h" #include "TFile.h" #include "TROOT.h" #include "TStyle.h" #include "TBox.h" #include "TRandom.h" #include "TObject.h" #include "TObjString.h" #include #include #include #include #include "TLine.h" #include "TTree.h" #include "TBrowser.h" #include "TF1.h" #include #include #include #include "TRandom.h" void plot(){ // replace this with name of your singles file TFile *f=new TFile("Single_Si29_ded.root","read"); TString histo, norm, protons; ///file with a list of the histogram names for one detector // format Zn_T_u3_C6D6_runxxxxxx Zn_A_u3_SILI_runxxxxxx Zn_h_info_C6D6_runxxxxxx ifstream inni("Si29_C6D64_HistList.dat"); TCanvas *c=new TCanvas(); /// replace this with the tof around a resonance, i.e. binlow is the start of the resonance, binhigh is the end of the resonance // you can choose any resonance, best is a large one which is usally at big tof values /// this will be different for Au and for Zn. float binlow=2250000; float binhigh=2400000; TLegend *legend = new TLegend(0.65, 0.38, 0.89, 0.89); legend->SetBorderSize(1); legend->SetFillColor(0); legend->SetTextSize(0.03); int count2=0; int count_protons=0; //// replace this with the number of lines in your file "list" int lines=59; float value[lines]; float value2[lines]; float valuesili[lines]; float valuepkup[lines]; float staterror[lines]; while(1){ inni>>histo>>norm>>protons; if ( ! inni ) break; char *s; if(count2==0) s="hist"; if(count2>0)s="hist same"; count2++; cout<Get(histo); //TH1F *hnorm=(TH1F*)f->Get(norm); TH1F *hpro=(TH1F*)f->Get(protons); int bin1=h->FindBin(binlow); //Ge70Bins int bin2=h->FindBin(binhigh); // this gives the total number of count in the resonance int counter2=h->Integral(bin1,bin2); value[count2-1]=float(counter2)/hpro->GetBinContent(4)*7E12; staterror[count2-1]=sqrt(float(counter2))/hpro->GetBinContent(4)*7E12; value2[count2-1]=float(counter2); valuesili[count2-1]=float(hpro->GetBinContent(4)/hpro->GetBinContent(8)); valuepkup[count2-1]=float(hpro->GetBinContent(4)/hpro->GetBinContent(7)); h->Scale(1/hpro->GetBinContent(4)*7E12); h->Rebin(50); h->SetLineColor(count2); h->DrawCopy(s); legend->AddEntry(h,histo, "l"); } float sum=0; float weight=0; float weightsum=0; for(int i=0;iDraw(); cout<<" "<SetBinContent(i+1,valuesili[i]); hprook->SetBinContent(i+1,valuepkup[i]); hsipk->SetBinContent(i+1,valuesili[i]/valuepkup[i]); hcounts->SetBinContent(i+1,value[i]); hcounts->SetBinError(i+1,staterror[i]); } TCanvas *c3=new TCanvas; c3->Divide(2,2); c3->cd(1); hprosi->Draw(); c3->cd(2); hprook->Draw(); c3->cd(3); hsipk->Draw(); c3->cd(4); hcounts->Draw(); TCanvas *c5=new TCanvas; hcounts->Draw(); } void plotau(){ // replace this with name of your singles file TFile *f=new TFile("Single_Au_ded.root","read"); TString histo, norm, protons; ///file with a list of the histogram names for one detector // format Zn_T_u3_C6D6_runxxxxxx Zn_A_u3_SILI_runxxxxxx Zn_h_info_C6D6_runxxxxxx ifstream inni("Au_C6D64_HistList.dat"); TCanvas *c=new TCanvas(); /// replace this with the tof around a resonance, i.e. binlow is the start of the resonance, binhigh is the end of the resonance // you can choose any resonance, best is a large one which is usally at big tof values /// this will be different for Au and for Zn. float binlow=12000000; float binhigh=14000000; TLegend *legend = new TLegend(0.65, 0.38, 0.89, 0.89); legend->SetBorderSize(1); legend->SetFillColor(0); legend->SetTextSize(0.03); int count2=0; int count_protons=0; //// replace this with the number of lines in your file "list" int lines=59; float value[lines]; float value2[lines]; float valuesili[lines]; float valuepkup[lines]; float staterror[lines]; while(1){ inni>>histo>>norm>>protons; if ( ! inni ) break; char *s; if(count2==0) s="hist"; if(count2>0)s="hist same"; count2++; cout<Get(histo); //TH1F *hnorm=(TH1F*)f->Get(norm); TH1F *hpro=(TH1F*)f->Get(protons); int bin1=h->FindBin(binlow); //Ge70Bins int bin2=h->FindBin(binhigh); // this gives the total number of count in the resonance int counter2=h->Integral(bin1,bin2); value[count2-1]=float(counter2)/hpro->GetBinContent(4)*7E12; staterror[count2-1]=sqrt(float(counter2))/hpro->GetBinContent(4)*7E12; value2[count2-1]=float(counter2); valuesili[count2-1]=float(hpro->GetBinContent(4)/hpro->GetBinContent(8)); valuepkup[count2-1]=float(hpro->GetBinContent(4)/hpro->GetBinContent(7)); h->Scale(1/hpro->GetBinContent(4)*7E12); h->Rebin(50); h->SetLineColor(count2); h->DrawCopy(s); legend->AddEntry(h,histo, "l"); } float sum=0; float weight=0; float weightsum=0; for(int i=0;iDraw(); cout<<" "<SetBinContent(i+1,valuesili[i]); hprook->SetBinContent(i+1,valuepkup[i]); hsipk->SetBinContent(i+1,valuesili[i]/valuepkup[i]); hcounts->SetBinContent(i+1,value[i]); hcounts->SetBinError(i+1,staterror[i]); } TCanvas *c3=new TCanvas; c3->Divide(2,2); c3->cd(1); hprosi->Draw(); c3->cd(2); hprook->Draw(); c3->cd(3); hsipk->Draw(); c3->cd(4); hcounts->Draw(); TCanvas *c5=new TCanvas; hcounts->Draw(); }