-
Notifications
You must be signed in to change notification settings - Fork 0
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
SE treemaker #203
SE treemaker #203
Conversation
This is the treemaker to produce the minitrees necessary to create the single electron gain stability plot and the average single electron waveform shape.
Thanks @katrinamiller! There's some Codacy failure you can see below, likely due to code style. Before committing, you can find all Codacy errors with:
then if you understand all the errors and agree, can fix automatically with:
|
OK, I think I've fixed everything except an error Codacy is picking up on: "Unused variable 'class' ". Not sure what to do with this since I need this to define the minitrees. |
@katrinamiller Thanks! Since nhits_bounds and width_bounds is hard coded anyway, why not put them in IsolatedPeaks class directly? By doing that you will be able to avoid this problem. |
I think the original reason for coding it in this manner (this is actually @JelleAalbers code) is because a wider hit cut (10-35 hits) and no width cut is used to calculate the single electron gain. The rest of the parameters, which are extracted from the waveform simulation, use the stricter hit and width cut defined in the SingleElectrons class. Another option could be to eliminate the cuts inside the minitree completely & instead apply them in the python notebook. |
Thanks for posting the code Katrina. It looks like a mistake in codacy's parsing, since clearly there is no variable called |
hax/treemakers/se_treemaker.py
Outdated
from pax import units | ||
|
||
|
||
def yield_single_electrons(event, nhits_bounds, width_bounds): |
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.
Can you add a _ before the function since this is "private" to the treemaker? Or you can move it within the class.
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, add a docstring that explains what the function does
I told Codacy to ignore it. @katrinamiller if you can make the small changes I mentioned in the review, then we can force merge.... though I think I disabled it, but we'll figure it out. It's a fake problem |
If you add |
hax/treemakers/se_treemaker.py
Outdated
|
||
|
||
class IsolatedPeaks(hax.minitrees.MultipleRowExtractor): | ||
__version__ = '0.1.2' |
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.
Please add a docstring explaining what this class does. Title and few sentences describing it.
hax/treemakers/se_treemaker.py
Outdated
return results | ||
|
||
|
||
class SingleElectrons(IsolatedPeaks): |
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.
Please add a docstring explaining what this class does. Title and few sentences describing it.
hax/treemakers/se_treemaker.py
Outdated
from pax import units | ||
|
||
|
||
def yield_single_electrons(event, nhits_bounds, width_bounds): |
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, add a docstring that explains what the function does
hax/treemakers/se_treemaker.py
Outdated
@@ -0,0 +1,64 @@ | |||
import hax |
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.
Add a docstring above here to explain what is in this module. Also, the filename should be more explicit: single_electron.py
Responding to pull request comments
How's this different from peak_treemakers.py? |
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.
Move code to within peak_treemakers.py?
@katrinamiller If you check that this still works for you, then you (or somebody) can merge. |
The modified code works for me! Thanks |
@katrinamiller is this OK to go into standard production now? how does the file size compare to other minitrees, for example Rn220 run 14080 (in bytes):
|
Also, what treemaker name would we need to add to cax? |
@pdeperio this treemaker will make two minitrees - IsolatedPeaks & SingleElectrons. In my scratch directory, both of these combined take up ~ 8 MB of space per run (~6 MB and ~2 MB, respectively). As suggested above I believe I can make a small change to IsolatedPeaks and remove the SingleElectrons class (which differs from IsolatedPeaks only by applying cuts on number of hits and width) if we are concerned about space or redundancy. I can easily apply these cuts directly in a notebook after the minitrees are created. I don't think this would cause any issues, maybe @JelleAalbers can confirm this. |
6 MB is relatively large for a minitree (50% larger than corrections), but not a big worry I think. If we run out of space you could consider strengthening the isolation cut or setting a default n_hits cut (though maybe somebody at some point wants to look at multi-hit pileup). Would be nice if this tree were auto-produced by cax! Sure, you can remove SingleElectrons; it's basically IsolatedPeaks + a cut. You could also convert it to an in-memory minitree (have it load IsolatedPeaks, apply the cut, and return result), but that seems like a bit of work for something that analysts may want to try and customize anyway. |
Yeah, to make this treemaker more useful for other applications as well, I would suggest to add more variables, like rise_time, range_90p_area, area_fraction_top etc and make the hits bounds less tight. For eg, in my note to distinguish single electron S2s and S1 by ML, I add a few variables there and modified the hit bounds. Can @katrinamiller take a look and made some modification to this treemaker? We can always make the cut tighter later for various analysis. |
Good idea to add rise time and the 90% area width (area_fraction_top is already in). If we keep IsolatedPeaks, it has no cut on n_hits or width at all, so that should work for your analysis too. |
@JelleAalbers Yeah, it sounds like IsolatedPeaks treemaker is sufficient for both analysis and we don't need SingleElectron one as you pointed out. |
ok, so I'll wait for additional variables PR before adding |
This is the treemaker to produce the minitrees necessary to create the single electron gain stability plot and the average single electron waveform shape.