-
Notifications
You must be signed in to change notification settings - Fork 9
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
Factories based on python decorations of the trees #151
Open
pieterdavid
wants to merge
14
commits into
cp3-llbb:master
Choose a base branch
from
pieterdavid:pyfactories
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.
Conversation
This file contains 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
and complete the example using those
This is huge, I think I'll need more than an example to work through it :D |
I understand... don't feel too obliged to have a look soon (and feel free to make suggestions for more examples or documentation that would help). The code is (meant to be) reasonably modular, so I can try to suggest an order to go through (or at least structure a bit).
|
it was in .gitignore so far... also modified to default to using the files, so this should work with only PyROOT (with one warning on the first import)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I am sorry, this one became quite big... it is what I ended up doing to generate plotters etc, replacing the string-formatting / template engine in the current version by python objects and modules.
I am pushing this mostly because @clacaputo asked about it, and because other people may also be interested in using this at some point - so there is no need to review and merge this quickly, we can first discuss a bit.
There is a fair amount of boilerplate code (some of it could be simplified, and some partially overlaps with existing modules), but it does bring some advantages:
If you want to have a look (or start reviewing), I would suggest to start with an example for H->ZA.
In practice one would split this over a few files, but I made this one self-contained to show what is needed to describe the tree structure and generate a plotter for a set of plots (running it with only the
-i
option will give an IPython shell to play around with a 'decorated' tree, it's in thetup
variable and you can get the C++ code for an expression withtoDraw
, e.g.toDraw(tup.hZA.lljj_deepCSV[0].J1.p4.Pt())
gives'jet_p4[hZA_jets[hZA_lljj_deepCSV[0].ijet1].idx].Pt()'
. I also added a first version of such a script for nanoAOD.The decorations are meant to be straightforward to use: they consist of placeholder or "stub" objects representing (groups of) branches, which support a number of operations (getting one branch, resolving a reference, arithmetic) such that expression trees can be constructed from them (a 1D histogram needs three expressions: a selection, a weight, and an x-axis variable, as before).
Any thoughts/feedback/criticism/suggestions (also on what to document better) welcome :-)