-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add sources and example notebook for 1D CES inference #161
base: main
Are you sure you want to change the base?
Conversation
…d missing import statement
…l bug in CESTemplateSource class
The one
The one problem I might see with that is that we want the source classes to be fully fledged bluesky sources also so that part kinda has to stay? |
Yes -- my idea is to try to use as much of the source functionality as possible in the simulator. At least right now I don't see the reason (yet) why so much of the functionality of the sources is rewritten in the simulator. |
for more information, see https://pre-commit.ci
Hi @hammannr thanks for the comments! I have done the following tasks:
And the following's are ongoing as I need to check if they affect any functions:
For those two points I'm not perfectly sure so further comments would be helpful:
|
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.
Hi, @yuema137 awesome to see this PR where we get a dedicated 1D source! Some comments added, I agree with Robert that we should remove specific CES-things to make this useful for any 1D analysis we make :)
notebooks/4_ces_inference.ipynb
Outdated
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.
I think here I'd put some pedagogical comments :)
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.
Also love the 2D likelihood surface :)!
from multihist import Hist1d | ||
from alea.ces_transformation import Transformation | ||
|
||
MINIMAL_ENERGY_RESOLUTION = 0.05 |
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.
I do not think this boundary is required-- for fits, it should be set in the config fit boundary, and the bins can be as fine as we'd like and still be valid. (and other 1D fits may have a different "natural" scale for the bins)
h = efficiency_transformation.apply_transformation(h) | ||
if smearing_transformation is not None: | ||
h = smearing_transformation.apply_transformation(h) | ||
if bias_transformation is not None: |
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.
I think the bias makes more sense to apply in true energy (i.e. before smearing) what do you think?
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.
Actually I think it's better to add in the smeared energy. Because the bias should in principle be caused by some area-dependent effect (like merging SEs and lone hits). So for example if a monoenergetic source produces two S2s, 1.1e4 and 1.2e4 separately, the biases would be slightly different for them even if the true energies are the same.
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.
In general the bias should be a function of true parameters (I agree if we had a measurement of "true quanta released" we could define our bias in terms of that, and the CES could be considered an approximation of that, but it is only an approximation)
alea/ces_source.py
Outdated
return h | ||
|
||
def _transform_histogram(self, h: Hist1d): | ||
# Only efficiency is applicable for flat source |
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.
Disagree-- you could have an efficiency defined in true energy and then a smearing on top, I think?
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.
Similar to bias, efficiency is applied after the smearing. The smearing in our detector is mainly due to the Poisson fluctuation during the production of n_e and n_gamma which is before any detector effects start to get involved. This is the main reason that we set the smearing as the first transformation
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.
IMO the efficiency should be the probability to detect an event given a certain initial recoil energy. This is what we use for WIMPs, and it is a well-defined probability (that does include the effects you list here as important inputs!).
I think attempting to apply efficiencies based on reconstructed variables on the basis that those reconstructed variables approximate (but does not give) the underlying number of quanta that are important for the probability to be detected
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.
Hi Knut, to clarify, the efficiency here is only projected in CES space. For S2 threshold and S1 efficiency, we get the CES projected values during the band fitting. For cut acceptance which is data-driven, the values are naturally only in CES. Defining everything in true energy is possible but the gain is limited. It will make every efficiency study entangled with the band fitting which is not necessary for lower or other studies performed in CES.
if bins.size <= 1: | ||
raise ValueError("bins must have at least 2 elements") | ||
bin_centers = 0.5 * (bins[1:] + bins[:-1]) | ||
data = stats.norm.pdf( |
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.
With coarse binning, I would propose instead defining the data as the difference of the CDF evaluated at the upper edge of the bin and evaluated at the lower edge of the bin
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Pull Request Test Coverage Report for Build 12290764765Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
for more information, see https://pre-commit.ci
Note: This PR doesn't affect existing functions in Alea but only adds 1D CES inference.
This is a refactored version of the inference developed for SR0. Featured improvements:
ces_source.py:
ces_transformation.py:
xe133_template.ii.h5
An example template (Hist1d)
unblind_ces_simple.yaml:
An example yaml config including:
4_ces_inference.ipynb
An example notebook showing how to build model based on example ymal config and do fittings
*Note: the rest of the changes are just auto formatting because of
black . && flake8