Multi-Dimensional Fits with pyhf: A Minimal Example Using Flattened 3D Histograms #2573
Unanswered
JieWu-GitHub
asked this question in
Ideas
Replies: 1 comment 3 replies
-
Hi @JieWu-GitHub, thanks a lot for sharing this!
Do you mean adding a property to the |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello pyhf community,
I’m Jie, and I work on LHCb data analysis in high-energy physics. I’d like to share a minimal example that demonstrates how to perform template fits with 3D histograms using two different approaches:
Since pyhf doesn’t natively support 3D fits, I’ve worked around this limitation by flattening 3D histograms into 1D arrays.
This example is based on a CERN HistFactory tutorial I found online, which focuses on fitting the observable RD* in the decay. The analysis involves 4 samples in a single channel, and the example compares the two approaches, yielding consistent results!
What’s in the Example:
You can find the full example, along with explanations and code, in my GitHub repository here:
https://github.com/JieWu-GitHub/ROOTHisfactory-pyhf-examples
Challenges and Suggestions from this minimal example:
Plotting with Large Numbers of Bins (Using cabinetry): One challenge I encountered was handling plots with a large number of bins, where overlapping lines made the plots hard to interpret. To address this, I adjusted the figure width, but for cases with thousands of bins, a better solution could be to automatically split the plots into sub-plots (e.g., one plot for every 100 bins). Additionally, I made projections along each axis (under physical meanings) to simplify the comparisons.
Normalization Factors: While using cabinetry, it would be very useful to add a normalize attribute in the Sample section. This feature would allow us to easily apply fixed normalization factors to each template. Currently, I need to load the original histograms and apply normalization manually.
Looking Ahead:
I’m currently migrating my analysis work from ROOT HistFactory to pyhf + cabinetry. I will continue refining this example and greatly appreciate any feedback or suggestions. I hope this example can be helpful to others facing similar challenges when working with multi-dimensional histograms in ROOT. The inability of pyhf to handle 3D histograms directly has been a significant hurdle for me, so I’m happy to share this minimal example and emphasise that consistent results are measured.
Looking forward to hearing your thoughts and feedback!
Best regards,
Jie
Beta Was this translation helpful? Give feedback.
All reactions