Skip to content
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

ToA lnL first functionas #63

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open

Conversation

tschiffer
Copy link

Started to inclued the possiblity to use the ToA information for the lnL

Comment on lines 97 to 125
var res = zeros[float](refLowT.size.int)
# walk over each bin and compute linear interpolation between
let Ediff = abs(lineEnergies[idx] - lineEnergies[idx+offset])
for i in 0 ..< bins.size:
res[i] = refLowT[i] * (1 - (abs(lineEnergies[idx] - energy)) / Ediff) +
refHighT[i] * (1 - (abs(lineEnergies[idx+offset] - energy)) / Ediff)
result = (bins, res)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Later we can refactor out this type of logic from both the regular and ToA versions of this proc into a morphImpl that takes only the reference data, line energies and returns the bins and result. That way we only have the two procedures to do the "data extraction" from the relevant sources and the actual interpolation logic is shared. But I can do that at a later time.

Comment on lines 111 to 148
var dfLoc = newDataFrame()
var lastBins = zeros[int](0)
result = newDataFrame()
for idx, E in energies:
let (bins, res) = morphToA(df, lineEnergies, E, offset = 1)

block Sanity:
# really the same bins in all Target/Filter combinations? Should be, but check!
if lastBins.size > 0:
doAssert bins == lastBins
lastBins = bins
let suffix = "_" & $idx
dfLoc["Hist" & $suffix] = res

dfLoc["Bins"] = lastBins
#echo dfLoc
result.add dfLoc
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly to the above procedure, the actual logic can also be refactored out into a common procedure for regular / ToA cases. Just needs an argument that hands the internal morphing procedure to call. Again, I can do that later.

@Vindaar
Copy link
Owner

Vindaar commented Dec 20, 2024

Looking good for your first lines of Nim code! 🥳

Added comments mainly for explanatory purposes.

The next steps would involve:

Once that is done, we can implement the ToA cut (as you proposed) first. Certainly simpler.

This would involve:

If this is done and you have added the ToA cut there, we'd need to do 2 other things (but we'll do that once the implementation is there and works):

  1. Add the information about how many events were vetoed by the ToA counter here: https://github.com/Vindaar/TimepixAnalysis/blob/master/Analysis/ingrid/likelihood.nim#L127-L140 (needs a counter in the many logic of course). Note that the settings which were used are automatically serialized in that writeInfos proc in the h5f.toH5(...) call.
  2. In downstream code handle the resulting efficiency penalty due to the ToA cut. But for that we first need that number of course (question is whether to estimate it based on a reference dataset or use a fixed number for the beginning). This is so that e.g. in a limit calculation we know the full efficiency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants