Skip to content

Commit

Permalink
update morpho; use python3 for tests; update syntax for pyroot
Browse files Browse the repository at this point in the history
  • Loading branch information
taliaweiss committed Jul 20, 2021
1 parent 46502e6 commit 4d8178a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def definePdf(self,wspace):
# Spectrum smearing
gauss = ROOT.RooGaussian("gauss","gauss",var,meanSmearing,widthSmearing)
smearedspectrum = pdffactory.GetSmearedPdf(ROOT.RealTritiumFrequencySpectrum)("smearedspectrum", 2, var, shapePdf, meanSmearing, widthSmearing,100000)
pdf = pdffactory.AddBackground(ROOT.RooAbsPdf)("pdf",var,smearedspectrum,NEvents,NBkgd)
pdf = pdffactory.AddBackground[ROOT.RooAbsPdf]("pdf",var,smearedspectrum,NEvents,NBkgd)


if "snr_efficiency" in self.options and self.options["snr_efficiency"]:
Expand Down Expand Up @@ -180,12 +180,12 @@ def definePdf(self,wspace):
# x is Frequency in channel in MHz: (@0*TMath::Power(10, -6)-cf)
channelEffFunc = ROOT.RooFormulaVar("channel_efficiency", "channel_efficiency", "c4 * TMath::Sqrt(1/(1 + 1*TMath::Power((@0*TMath::Power(10, -6)-cf)/c0, c1)))* TMath::Sqrt(1/(1 + TMath::Power((@0*TMath::Power(10, -6)-cf)/c2, c3)))", channel_eff_coeff)
superDistortedSpectrum = ROOT.RooEffProd("superDistortedSpectrum", "superDistortedSpectrum", distortedSpectrum, channelEffFunc)
pdf = pdffactory.AddBackground(ROOT.RooAbsPdf)("pdf",var,superDistortedSpectrum,NEvents,NBkgd)
pdf = pdffactory.AddBackground[ROOT.RooAbsPdf]("pdf",var,superDistortedSpectrum,NEvents,NBkgd)

else:
pdf = pdffactory.AddBackground(ROOT.RooAbsPdf)("pdf",var,distortedSpectrum,NEvents,NBkgd)
pdf = pdffactory.AddBackground[ROOT.RooAbsPdf]("pdf",var,distortedSpectrum,NEvents,NBkgd)
else:
pdf = pdffactory.AddBackground(ROOT.RooAbsPdf)("pdf",var,shapePdf,NEvents,NBkgd)
pdf = pdffactory.AddBackground[ROOT.RooAbsPdf]("pdf",var,shapePdf,NEvents,NBkgd)



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _GetNEvents_Window(self, KE, spectrum):
"meanSmearing_tmp", "meanSmearing_tmp", 0)
widthSmearing = ROOT.RooRealVar(
"widthSmearing_tmp", "widthSmearing_tmp", self.energy_resolution)
smearedspectrum = pdffactory.GetSmearedPdf(ROOT.RealTritiumSpectrum)(
smearedspectrum = pdffactory.GetSmearedPdf[ROOT.RealTritiumSpectrum](
"smearedspectrum_tmp", 2, KE, spectrum, meanSmearing, widthSmearing, 1000000)
fullSpectrumIntegral = spectrum.createIntegral(
ROOT.RooArgSet(KE), ROOT.RooFit.Range("FullRange"))
Expand Down Expand Up @@ -141,7 +141,7 @@ def _PrepareWorkspace(self):
widthSmearing = ROOT.RooRealVar(
"widthSmearing", "widthSmearing", self.energy_resolution, 0., 10*self.energy_resolution)
# KE.setBins(100000, "cache")
smearedspectrum = pdffactory.GetSmearedPdf(ROOT.RealTritiumSpectrum)(
smearedspectrum = pdffactory.GetSmearedPdf[ROOT.RealTritiumSpectrum](
"smearedspectrum", 2, KE, spectrum, meanSmearing, widthSmearing, 100000)

# Background
Expand Down Expand Up @@ -185,10 +185,10 @@ def _PrepareWorkspace(self):
NBkgd = ROOT.RooRealVar(
"NBkgd", "NBkgd", self.number_bkgd_window_to_generate, 0., 10*self.number_bkgd_window_to_generate)
if self.doSmearing:
totalSpectrum = pdffactory.AddBackground(ROOT.RooAbsPdf)(
totalSpectrum = pdffactory.AddBackground[ROOT.RooAbsPdf](
"totalSpectrum", KE, smearedspectrum, NEvents, NBkgd)
else:
totalSpectrum = pdffactory.AddBackground(ROOT.RooAbsPdf)(
totalSpectrum = pdffactory.AddBackground[ROOT.RooAbsPdf](
"totalSpectrum", KE, spectrum, NEvents, NBkgd)

# Save things in a Workspace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _GetNEvents_Window(self, KE, spectrum):
"meanSmearing_tmp", "meanSmearing_tmp", 0)
widthSmearing = ROOT.RooRealVar(
"widthSmearing_tmp", "widthSmearing_tmp", self.energy_resolution)
spectrum = pdffactory.GetSmearedPdf(ROOT.RealTritiumSpectrum)(
spectrum = pdffactory.GetSmearedPdf[ROOT.RealTritiumSpectrum](
"smearedspectrum_tmp", 2, KE, spectrum, meanSmearing, widthSmearing, 1000000)
fullSpectrumIntegral = spectrum.createIntegral(
ROOT.RooArgSet(KE), ROOT.RooFit.Range("FullRange"))
Expand Down Expand Up @@ -128,7 +128,7 @@ def definePdf(self, wspace):
meanSmearing = ROOT.RooRealVar("meanSmearing", "meanSmearing", 0.)
widthSmearing = ROOT.RooRealVar(
"widthSmearing", "widthSmearing", self.energy_resolution, 0., 10*self.energy_resolution)
smearedspectrum = pdffactory.GetSmearedPdf(ROOT.RealTritiumSpectrum)(
smearedspectrum = pdffactory.GetSmearedPdf[ROOT.RealTritiumSpectrum](
"smearedspectrum", 2, KE, spectrum, meanSmearing, widthSmearing, 100000)

# Calculate number of events and background
Expand Down Expand Up @@ -168,10 +168,10 @@ def definePdf(self, wspace):
NBkgd = ROOT.RooRealVar(
"NBkgd", "NBkgd", self.number_bkgd_window_to_generate, 0., 10*self.number_bkgd_window_to_generate)
if self.doSmearing:
pdf = pdffactory.AddBackground(ROOT.RooAbsPdf)(
pdf = pdffactory.AddBackground[ROOT.RooAbsPdf](
"pdf", KE, smearedspectrum, NEvents, NBkgd)
else:
pdf = pdffactory.AddBackground(ROOT.RooAbsPdf)(
pdf = pdffactory.AddBackground[ROOT.RooAbsPdf](
"pdf", KE, spectrum, NEvents, NBkgd)

getattr(wspace, 'import')(KE)
Expand Down
10 changes: 5 additions & 5 deletions tests/test.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

python IO_test.py
python Misc_test.py
python Tritium_test.py
python TritiumAndEfficiencyBinner_test.py
python Fake_data_generator_test.py
python3 IO_test.py
python3 Misc_test.py
python3 Tritium_test.py
python3 TritiumAndEfficiencyBinner_test.py
python3 Fake_data_generator_test.py

0 comments on commit 4d8178a

Please sign in to comment.