-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[Tut] Solve various problems #22828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dpiparo
wants to merge
1
commit into
root-project:master
Choose a base branch
from
dpiparo:roostatsTut
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+11
−11
Open
[Tut] Solve various problems #22828
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -33,8 +33,8 @@ | |||||
| # | ||||||
| # \author Lorenzo Moneta (C++ version), and P. P. (Python translation) | ||||||
|
|
||||||
| import ROOT | ||||||
| import os | ||||||
|
|
||||||
|
|
||||||
| # structure defining the options | ||||||
|
|
@@ -176,7 +176,7 @@ | |||||
|
|
||||||
| # RooStats.HypoTestInvTool.SetParameter(name, value): | ||||||
| # def SetParameter(self, name, value): | ||||||
| elif (type(name) is str) and (type(value) is bool): | ||||||
| elif (type(name) is str) and (type(value) is int): | ||||||
|
|
||||||
| # | ||||||
| # set integer parameters | ||||||
|
|
@@ -220,7 +220,7 @@ | |||||
|
|
||||||
| # RooStats.HypoTestInvTool.SetParameter(name, value): | ||||||
| # def SetParameter(self, name, value): | ||||||
| elif (type(name) is str) and (type(value) is (float or double)): | ||||||
| elif (type(name) is str) and (type(value) is float): | ||||||
|
|
||||||
| # | ||||||
| # set string parameters | ||||||
|
|
@@ -268,17 +268,17 @@ | |||||
| # ROOT.std::cout << "DEBUG : [ " << lowerLimit << " , " << upperLimit << " ] " << ROOT.std::endl; | ||||||
|
|
||||||
| if lowerLimit < upperLimit * (1.0 - 1.0e-4) and lowerLimit != 0: | ||||||
| print(f"The computed lower limit is: ", lowerLimit, " +/- ", llError) | ||||||
|
|
||||||
| print(f"The computed upper limit is: {upperLimit} +/- ", ulError) | ||||||
|
|
||||||
| # compute expected limit | ||||||
| print(f"Expected upper limits, using the B (alternate) model : ") | ||||||
| print(f" expected limit (median) ", r.GetExpectedUpperLimit(0)) | ||||||
| print(f" expected limit (-1 sig) ", r.GetExpectedUpperLimit(-1)) | ||||||
| print(f" expected limit (+1 sig) ", r.GetExpectedUpperLimit(1)) | ||||||
| print(f" expected limit (-2 sig) ", r.GetExpectedUpperLimit(-2)) | ||||||
| print(f" expected limit (+2 sig) ", r.GetExpectedUpperLimit(2)) | ||||||
|
|
||||||
| # detailed output | ||||||
| if self.mEnableDetOutput: | ||||||
|
|
@@ -310,11 +310,11 @@ | |||||
| ulDist = 0 | ||||||
| existULDist = not ROOT.gSystem.AccessPathName(uldistFile) | ||||||
| if existULDist: | ||||||
| fileULDist = TFile.Open(uldistFile) | ||||||
| if fileULDist: | ||||||
| ulDist = fileULDist.Get("RULDist") | ||||||
|
|
||||||
| fileOut = TFile(self.mResultFileName, "RECREATE") | ||||||
| r.Write() | ||||||
| if ulDist: | ||||||
| ulDist.Write() | ||||||
|
|
@@ -524,7 +524,7 @@ | |||||
| doFit = self.mInitialFit | ||||||
| if testStatType == 0 and self.mInitialFit == -1: | ||||||
| doFit = False # case of LEP test statistic | ||||||
| if type == 3 and self.mInitialFit == -1: | ||||||
| if Type == 3 and self.mInitialFit == -1: | ||||||
| doFit = False # case of Asymptoticcalculator with nominal Asimov | ||||||
| poihat = 0 | ||||||
|
|
||||||
|
|
@@ -765,7 +765,7 @@ | |||||
| hhc = HybridCalculator(hc) | ||||||
| assert hhc | ||||||
|
|
||||||
| hhc.SetToys(ntoys, ntoys / self.mNToysRatio) # can use less ntoys for b hypothesis | ||||||
| hhc.SetToys(ntoys, int(ntoys / self.mNToysRatio)) # can use less ntoys for b hypothesis | ||||||
|
|
||||||
| # remove global observables from ModelConfig (this is probably not needed anymore in 5.32) | ||||||
| bModel.SetGlobalObservables(RooArgSet()) | ||||||
|
|
@@ -813,11 +813,11 @@ | |||||
| nuisPdf.Print() | ||||||
|
|
||||||
| nuisParams = ( | ||||||
| ibModel.GetNuisanceParameters() | ||||||
| bModel.GetNuisanceParameters() | ||||||
| if (bModel.GetNuisanceParameters()) | ||||||
| else (sbModel.GetNuisanceParameters()) | ||||||
| ) | ||||||
| npnuisPdf.getObservables(nuisParams) | ||||||
| np = npnuisPdf.getObservables(nuisParams) | ||||||
| if np.getSize() == 0: | ||||||
| ROOT.Warning( | ||||||
| "StandardHypoTestInvDemo", | ||||||
|
|
@@ -827,21 +827,21 @@ | |||||
| hhc.ForcePriorNuisanceAlt(nuisPdf) | ||||||
| hhc.ForcePriorNuisanceNull(nuisPdf) | ||||||
|
|
||||||
| elif type == 2 or type == 3: | ||||||
| elif Type == 2 or Type == 3: | ||||||
| if testStatType == 3: | ||||||
| hc.SetOneSided(True) | ||||||
| if testStatType != 2 and testStatType != 3: | ||||||
| ROOT.Warning( | ||||||
| "StandardHypoTestInvDemo", | ||||||
| "Only the PL test statistic can be used with AsymptoticCalculator - use by default a two-sided PL", | ||||||
| ) | ||||||
| elif type == 0: | ||||||
| hc.SetToys(ntoys, ntoys / self.mNToysRatio) | ||||||
| elif Type == 0: | ||||||
| hc.SetToys(ntoys, int(ntoys / self.mNToysRatio)) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| # store also the fit information for each poi point used by calculator based on toys | ||||||
| if self.mEnableDetOutput: | ||||||
| hc.StoreFitInfo(True) | ||||||
| elif type == 1: | ||||||
| hc.SetToys(ntoys, ntoys / self.mNToysRatio) | ||||||
| elif Type == 1: | ||||||
| hc.SetToys(ntoys, int(ntoys / self.mNToysRatio)) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| # store also the fit information for each poi point used by calculator based on toys | ||||||
| # if (self.mEnableDetOutput): | ||||||
| # hc.StoreFitInfo(True) | ||||||
|
|
||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of converting the result to
int, I'd prefer integer division directly