diff --git a/allowed.mac b/allowed.mac index 445cc1947d745f5d7fda4f5ef6917371b8dd9a7d..237b8a343ed38c63c579fbeabb610cb5fc4401f9 100644 --- a/allowed.mac +++ b/allowed.mac @@ -28,4 +28,4 @@ /VK/output/openFile output/220517/allowed.root # run simulation -/run/beamOn 1000000 +/run/beamOn 20000000 diff --git a/analysis/VKAdd b/analysis/VKAdd index 935ff94cf130e8a5efac9ea0a4cb62c4f9d5baca..d66d47a8cb2877bef4af59c662b4663a8945693e 100755 Binary files a/analysis/VKAdd and b/analysis/VKAdd differ diff --git a/analysis/VKAnalysis.dox b/analysis/VKAnalysis.dox index 13ece24dbfe71b74171fa65ef1ec5612404fdc3b..69bdf4683c4c6d5302eb5d3e1f53b51bffa49863 100644 --- a/analysis/VKAnalysis.dox +++ b/analysis/VKAnalysis.dox @@ -753,7 +753,7 @@ WARN_LOGFILE = # spaces. # Note: If this tag is empty the current directory is searched. -INPUT = /home/oliskir/Desktop/F20-IGISOL/sim/VeikonKone/analysis/include/ +INPUT = /home/oliskir/Desktop/f20/VeikonKone/analysis/include/ # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/analysis/plot/CreateHisto.C b/analysis/plot/CreateHisto.C index 9080cede4aa0f374248fe764a1987f7fa59db2fa..c282a935fac07cf156645a29dbf84b7bb64f7d18 100644 --- a/analysis/plot/CreateHisto.C +++ b/analysis/plot/CreateHisto.C @@ -3,7 +3,7 @@ * This macro was used to generate histograms for test run May 2017. */ -void histo(double hours = 168, int binWidth = 100) // 168 hours = 7 days +void CreateHisto(double hours = 168, int binWidth = 100, double ROImin = 5600, double ROImax = 7000) // 168 hours = 7 days { // set some parameters Double_t backgrHours = 189.4; // runs 192-199 @@ -13,104 +13,101 @@ void histo(double hours = 168, int binWidth = 100) // 168 hours = 7 days Double_t branching = 1e-6; Double_t dtPileup = 1000; // ns - TString simdir = "../../output/220517/"; + TString simdir = "../output/220517/"; TString datadir = "/home/oliskir/Desktop/f20/data/sorted/"; const double emin = 0; const double emax = 1E4; const int bins = (emax - emin) / binWidth; - double sf, norm; - - // BACKGROUND - TChain * backgrChain = new TChain("data"); - chain->Add(datadir+"*0192*"); - chain->Add(datadir+"*0193*"); - chain->Add(datadir+"*0194*"); - chain->Add(datadir+"*0195*"); - chain->Add(datadir+"*0196*"); - chain->Add(datadir+"*0197*"); - chain->Add(datadir+"*0198*"); - chain->Add(datadir+"*0199*"); - TH1F * hBackgr = new TH1F("hBackgr", "hBackgr", bins, emin, emax); - TH1F * hBackgrVeto = new TH1F("hBackgrVeto", "hBackgrVeto", bins, emin, emax); - backgrChain -> Draw("EDepSignal >> hBackgr", "Z0 != 10"); - TCut veto("M1 <= 1 && E1 < 140 + 0.21*E0"); - backgrChain -> Draw("EDepSignal >> hBackgrVeto", "Z0 != 10" && veto); - sf = hours/backgrHours; - hBackgr->Scale(sf); + vector<string> fname = {"backgr", "allowed", "forbidden", "pileup", "summing"}; + vector<double> sf; + vector<TH1F*> hist, histVeto; - // ALLOWED - TFile *f = TFile::Open(simdir+"allowed.root"); - TTree *t = (TTree*)f -> Get("Detector"); - norm = ((TParameter<double>*)(t->GetUserInfo()->FindObject("NORMALIZATION")))->GetVal(); - sf = rate * seconds / norm; + // canvas + TCanvas * c1 = new TCanvas("c1"); - // FORBIDDEN - TFile *f = TFile::Open(simdir+"forbidden.root"); - TTree *t = (TTree*)f -> Get("Detector"); - norm = ((TParameter<double>*)(t->GetUserInfo()->FindObject("NORMALIZATION")))->GetVal(); - sf = rate * seconds / norm; - sf *= branching; - - // PILE-UP - TFile *f = TFile::Open(simdir+"pileup.root"); - TTree *t = (TTree*)f -> Get("Detector"); - norm = ((TParameter<double>*)(t->GetUserInfo()->FindObject("NORMALIZATION")))->GetVal(); - sf = rate * seconds / norm; - sf *= dtPileup * 1E-9 * rate; - - // SUMMING - TFile *f = TFile::Open(simdir+"summing.root"); - TTree *t = (TTree*)f -> Get("Detector"); - norm = ((TParameter<double>*)(t->GetUserInfo()->FindObject("NORMALIZATION")))->GetVal(); - sf = rate * seconds / norm; + int i = 0; + for (auto& fn : fname) { + // output histogram names + TString hn = fn; + TString hnV = hn + "Veto"; + + if (fn == "backgr") { + // add files + TChain * chain = new TChain("data"); + chain->Add(datadir+"*0192*"); + chain->Add(datadir+"*0193*"); + chain->Add(datadir+"*0194*"); + chain->Add(datadir+"*0195*"); + chain->Add(datadir+"*0196*"); + chain->Add(datadir+"*0197*"); + chain->Add(datadir+"*0198*"); + chain->Add(datadir+"*0199*"); + // histograms + hist.push_back(new TH1F(hn, hn, bins, emin, emax)); + histVeto.push_back(new TH1F(hnV, hnV, bins, emin, emax)); + // veto cut + TCut veto("M1 <= 1 && E1 < 140 + 0.21*E0"); + // draw + chain->Draw("E0>>"+hn, "Z0 != 10"); + chain->Draw("E0>>"+hnV, "Z0 != 10" && veto); + // scaling factor + sf.push_back(hours/backgrHours); + } + else { + TFile *f = TFile::Open(simdir+Form("%s.root", fn.c_str())); + TTree *t = (TTree*)f -> Get("Detector"); + // histograms + hist.push_back(new TH1F(hn, hn, bins, emin, emax)); + histVeto.push_back(new TH1F(hnV, hnV, bins, emin, emax)); + // veto cut + TCut veto = Form("EDepVeto < %.1f", vetoThres); + // draw + t->Draw("EDepSignal>>"+hn); + t->Draw("EDepSignal>>"+hnV, veto); + // scaling factor + double norm = ((TParameter<double>*)(t->GetUserInfo()->FindObject("NORMALIZATION")))->GetVal(); double x = rate * seconds / norm; + if (fn == "forbidden") x *= branching; + else if (fn == "pileup") x *= dtPileup * 1E-9 * rate; + sf.push_back(x); + } + + // scale + hist[i]->Scale(sf[i]); + histVeto[i]->Scale(sf[i]); + i++; + } - cout << "\n Scaling factor: " << sf << "\n" << endl; - - - // Now make some plots - // Canvas - TCanvas *canvas = new TCanvas("c1", "multipads", 900, 700); - canvas -> Clear(); + // print info - // energy in signal - TH1F *hSingles = new TH1F("hSingles", "hSingles", 300, 0., 15000.); - t -> Draw("EDepSignal >> hSingles"); - hSingles -> Scale(sf); - canvas->Update(); - if (wait) gPad->WaitPrimitive(); + cout << endl; + cout << " Name Scaling Counts_ROI" << endl; + cout << "---------------------------------" << endl; + for (int i = 0; i < hist.size(); i++) { + binx1 = hist[i]->GetXaxis()->FindBin(ROImin); + binx2 = hist[i]->GetXaxis()->FindBin(ROImax); + double y = hist[i]->Integral(binx1, binx2); + double yV = histVeto[i]->Integral(binx1, binx2); - // use veto shield - TH1F *hVetoed = new TH1F("hVetoed", "hVetoed", 300, 0., 15000.); - TCut veto = Form("EDepVeto < %.1f", vetoThres); - t -> Draw("EDepSignal >> hVetoed", veto); - hVetoed -> Scale(sf); - TH1F *hBackgr = (TH1F*)hSingles->Clone(); - hBackgr -> Scale(1.-vetoEfficiency); - hVetoed -> Add(hBackgr); - canvas->Update(); - - // "detach" the histograms from file and close file - hSingles -> SetDirectory(0); - hVetoed -> SetDirectory(0); - f->Close(); + cout << " " << fname[i] << " " << sf[i] << " " << Form("%.1f / %.1f",y,yV) << endl; + } + cout << "--------------------" << endl; - cout << " Counts between " << Form("%.2f",emin/1000.) << " MeV and "; - cout << Form("%.2f",emax/1000.) << " MeV:" << endl; - binx1 = hVetoed -> GetXaxis() -> FindBin(emin); - binx2 = hVetoed -> GetXaxis() -> FindBin(emax); - cout << " - w/o veto: " << hSingles -> Integral(binx1, binx2) << endl; - cout << " - with veto: " << hVetoed -> Integral(binx1, binx2) << endl << endl; + + // "detach" the histograms from file + for (auto& h : hist) h->SetDirectory(0); + for (auto& h : histVeto) h->SetDirectory(0); + // write histograms to new file - TString fname = source + "_his.root"; - TFile *fo = TFile::Open(fname, "recreate"); - hSingles -> Write(); - hVetoed -> Write(); + TString no = "his.root"; + TFile *fo = TFile::Open(no, "recreate"); + for (auto& h : hist) h->Write(); + for (auto& h : histVeto) h->Write(); fo -> Close(); - cout << " Histograms written to: " << fname << endl << endl; + cout << " Histograms written to: " << no << endl << endl; } diff --git a/analysis/plot/SuperimpMay2017.C b/analysis/plot/SuperimpMay2017.C index f9eb263d4e94ae5ab14cb90a86132027d96bead6..b8b8e9a07fa0db0e5f829c881b0e8555b42c99e5 100644 --- a/analysis/plot/SuperimpMay2017.C +++ b/analysis/plot/SuperimpMay2017.C @@ -1,25 +1,28 @@ /* - * This macro was used to draw the spectrum that appeared - * in the 2nd 20F proposal for IGISOL (submitted in Sep 2016). - * - * O Kirsebom, Sep/2016 + * Superimpose spectra created with CreateHisto.C + * May 2017. */ -void superimp(Bool_t wait = false) +void SuperimpMay2017(double xmin = 5000, double xmax = 7500, bool veto = true) { // output TString ofname = "vk.eps"; + // input + TString ifname = "his.root"; + // files - vector<TString> filename; - filename.push_back("forbidden_his.root"); - filename.push_back("allowed_his.root"); - filename.push_back("summing_his.root"); - filename.push_back("pileup_his.root"); - filename.push_back("muon_his_eff99.root"); - filename.push_back("muon_his_eff99.9.root"); + vector<TString> hname; + hname.push_back("forbidden"); + hname.push_back("allowed"); + hname.push_back("summing"); + hname.push_back("pileup"); + hname.push_back("backgr"); + if (veto) { + for (auto& hn : hname) hn += "Veto"; + } // line width vector<Int_t> lineWidth; @@ -28,7 +31,6 @@ void superimp(Bool_t wait = false) lineWidth.push_back(1); lineWidth.push_back(1); lineWidth.push_back(1); - lineWidth.push_back(1); // line colors vector<Int_t> lineColor; @@ -37,7 +39,6 @@ void superimp(Bool_t wait = false) lineColor.push_back(1); lineColor.push_back(1); lineColor.push_back(1); - lineColor.push_back(1); // line styles vector<Int_t> lineStyle; @@ -46,7 +47,6 @@ void superimp(Bool_t wait = false) lineStyle.push_back(1); lineStyle.push_back(1); lineStyle.push_back(2); - lineStyle.push_back(3); // fill colors vector<Int_t> fillColor; @@ -55,7 +55,6 @@ void superimp(Bool_t wait = false) fillColor.push_back(lineColor[2]); fillColor.push_back(lineColor[3]); fillColor.push_back(lineColor[4]); - fillColor.push_back(lineColor[5]); // fill styles vector<Int_t> fillStyle; @@ -64,20 +63,14 @@ void superimp(Bool_t wait = false) fillStyle.push_back(3004); fillStyle.push_back(3001); fillStyle.push_back(0); - fillStyle.push_back(0); // legends vector<TString> legend; legend.push_back("2^{+}#rightarrow 0^{+} (br = 1#times10^{-6})"); legend.push_back("2^{+}#rightarrow 2^{+}"); legend.push_back("#beta#gamma summing"); - legend.push_back("#beta#beta pile-up (#tau = 20 ns)"); - legend.push_back("Cosmic-ray #mu (#epsilon_{v} = 99%)"); - legend.push_back("Cosmic-ray #mu (#epsilon_{v} = 99.9%)"); - - // x axis - Double_t xmin = 5000.; - Double_t xmax = 7500.; + legend.push_back("#beta#beta pile-up (#tau = 1 #mus)"); + legend.push_back("CR background"); // y axis Double_t ymin = 0; @@ -104,7 +97,7 @@ void superimp(Bool_t wait = false) Int_t lw = 1; // default line width // Legend - Double_t xl1=.5, yl1=0.55, xl2=xl1+0.35, yl2=yl1+0.25; + Double_t xl1=.5, yl1=0.75, xl2=xl1+0.35, yl2=yl1+0.25; TLegend *leg = new TLegend(xl1, yl1, xl2, yl2); canvas->SetFrameBorderMode(0); @@ -118,43 +111,38 @@ void superimp(Bool_t wait = false) canvas->cd(1); canvas->cd(1)->SetBottomMargin(0.11); - canvas->cd(1)->SetTopMargin(0.15); + canvas->cd(1)->SetTopMargin(0.28); canvas->cd(1)->SetLeftMargin(0.15); canvas->cd(1)->SetTicks(1,1); canvas->cd(1)->SetLogy(1); - // loop over files - for (Int_t i=0; i<filename.size(); i++) { + TFile *f = TFile::Open(ifname); + + // loop over histograms + for (Int_t i=0; i<hname.size(); i++) { // get histogram - TFile *f = TFile::Open(filename[i]); - TH1F *hS = (TH1F*)gDirectory->Get("hSingles"); - TH1F *hV = (TH1F*)gDirectory->Get("hVetoed"); + TString hn = hname[i]; + TH1F *h = (TH1F*)gDirectory->Get(hn); - // change names - hS -> SetName(Form("hSingles_%i", i)); - hV -> SetName(Form("hVetoed_%i", i)); - // set line and fill properties - hV -> SetLineWidth(lineWidth[i]); - hV -> SetLineColor(lineColor[i]); - hV -> SetLineStyle(lineStyle[i]); - hV -> SetFillColorAlpha(fillColor[i], 0.60); // 60% transparency - hV -> SetFillStyle(fillStyle[i]); + h -> SetLineWidth(lineWidth[i]); + h -> SetLineColor(lineColor[i]); + h -> SetLineStyle(lineStyle[i]); + h -> SetFillColorAlpha(fillColor[i], 0.60); // 60% transparency + h -> SetFillStyle(fillStyle[i]); // draw - TString opt = ""; - if (i>0) opt = "same"; - hV -> Draw(opt); + TString opt = "hist"; + if (i>0) opt = "samehist"; + h -> Draw(opt); // update canvas canvas -> Update(); // "detach" the histograms from file and close file - hS -> SetDirectory(0); - hV -> SetDirectory(0); - f -> Close(); + h -> SetDirectory(0); // set log-y axis gPad -> SetLogy(logy); @@ -162,25 +150,22 @@ void superimp(Bool_t wait = false) // legend TString label = "l"; if (fillStyle[i] != 0) label = "f"; - leg -> AddEntry(hV, legend[i], label); + leg -> AddEntry(h, legend[i], label); leg -> SetTextSize(lsize); leg -> SetTextFont(rf); leg -> SetFillColor(0); leg -> Draw("same"); - // wait - if (wait) gPad->WaitPrimitive(); - // title - hV -> SetTitle("Veikon Kone GEANT4 simulation"); + h -> SetTitle("^{20}F #beta spectrum (GEANT4)"); // get rid of stats - hV -> SetStats(kFALSE); + h -> SetStats(kFALSE); // axes // X axis - TAxis * xax = hV -> GetXaxis(); + TAxis * xax = h -> GetXaxis(); xax->SetTitleColor(kBlack); xax->SetTitleFont(rf); xax->SetTitleSize(tsize); @@ -189,11 +174,11 @@ void superimp(Bool_t wait = false) TString s = Form("E (MeV)"); xax->SetTitle(s); xax->SetTitleOffset(1); - xax->SetLimits(0,15); // keV -> MeV + xax->SetLimits(xax->GetXmin()/1000, xax->GetXmax()/1000); // keV -> MeV xax->SetRangeUser(xmin/1000, xmax/1000); // Y axis - TAxis * yax = hV -> GetYaxis(); + TAxis * yax = h -> GetYaxis(); yax->SetTitleFont(rf); yax->SetLabelFont(rf); yax->SetTitleSize(tsize); @@ -202,14 +187,14 @@ void superimp(Bool_t wait = false) s = Form("Counts / 50 keV"); yax->SetTitle(s); yax->SetTitleOffset(1.0); - hV->SetMinimum(ymin); - hV->SetMaximum(ymax); + h->SetMinimum(ymin); + h->SetMaximum(ymax); } - Double_t xt = xmin + 0.7*(xmax-xmin); + Double_t xt = xmin + 0.0*(xmax-xmin); xt /= 1000; Double_t yt = 1.2*ymax; - TLatex *t1 = new TLatex(xt, yt, "1 week @ 40 kHz"); + TLatex *t1 = new TLatex(xt, yt, "1 week @ 30 kHz"); t1->SetTextSize(tsize); t1->SetTextAngle(0); t1->SetTextColor(1); @@ -246,7 +231,10 @@ void superimp(Bool_t wait = false) t1->Draw("same"); */ + f -> Close(); canvas -> Print(ofname); - + + TString fPng = "/home/oliskir/Desktop/F20Spectrum.png"; + canvas->Print(fPng); } diff --git a/gamma.mac b/gamma.mac index 62f1239b8b2a483bee5481816a508014e008348a..c187a8d1b4f3f2ab0bb2952bcf68a3efd135dd2c 100644 --- a/gamma.mac +++ b/gamma.mac @@ -25,6 +25,6 @@ /VK/output/openFile output/220517/gamma.root # run simulation -/run/beamOn 1000000 +/run/beamOn 5000000