Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Add NR cut to file loader #53

Merged
merged 11 commits into from
May 20, 2022
Merged

Add NR cut to file loader #53

merged 11 commits into from
May 20, 2022

Conversation

PavelKavrigin
Copy link
Contributor

Simple implementation of NR selections from ROOT files using a modified cut string. An additional parameter in the configuration ('nr_only') is used to turn on/off this cut. This PR can be used as a basis for other cuts or a modification of this cut.

Pavel Kavrigin and others added 4 commits December 22, 2021 02:18
@PavelKavrigin
Copy link
Contributor Author

PavelKavrigin commented Dec 22, 2021

Here's a basic test using 20 files with AmBe simulations. These are 'e_dep' histograms, with NR-only selection via cut string (first plot) and without the cut (second plot). The output of this branch is compared to the master branch of epix. NR selection in the master branch was done by selecting only 'recoil==0' rows from the output.

2021-12-22_EpixNRCutTrue
2021-12-22_EpixNRCutFalse

@PavelKavrigin PavelKavrigin changed the title Add NR cut while loading from ROOT file Add NR cut to file loader Dec 22, 2021
@zhut19
Copy link

zhut19 commented Mar 1, 2022

Hi @PavelKavrigin @ramirezdiego , it is better to keep the non-neutron / ion energy deposition in the same event, no?
So the nr selection cannot apply at the root to array level, but a bit trickier after that line.
Here is some example code I am trying:
mask = ((interactions['type'] == "neutron") & (interactions['edproc'] == "hadElastic")) | (interactions['edproc'] == "ionIoni")
interactions = interactions[ak.num(interactions[mask])['x'] > 0]

@ramirezdiego
Copy link
Collaborator

@zhut19 Agreed (and @PavelKavrigin too, as we discussed this fix last week again). The idea is to propagate this cut, but keep the entire event level information, rather than this step in particular.

@ramirezdiego
Copy link
Collaborator

@shenyangshi Do you think you can jump on this, following the syntax by Pavel and the above suggestion by @zhut19?

@shenyangshi
Copy link
Contributor

Hi @ramirezdiego, the NR selection is implemented. I select events with summed ER components smaller than 32kev and having NR components larger than 0kev. Here is the graph showing the NR components considering the ER effect or not.

image

@WenzDaniel
Copy link
Contributor

Just for the record: This means that we are removing events with an inelastic component a 40 keV and 100 keV. This might be important for any TPC based neutron-veto.

@PavelKavrigin
Copy link
Contributor Author

Is it safe to ignore the timing and the location of the energy depositions? There could be cases where NR and ER do not occur close to each other. We will throw away all of these events based on the total energy.

@shenyangshi
Copy link
Contributor

Maybe yes, as NR and ER particles are all nearly to the speed of light, so both NR and ER will contribute to the S1, but for S2 if the distance is far maybe one of them won't be in the same event window, but this kind of event won't be in the neutron band anyway.

@WenzDaniel
Copy link
Contributor

Based on how we build events the S2 should be within the event as long as the second interaction happens in the sensitive volume.

@WenzDaniel
Copy link
Contributor

In any case a suggestion. I think it is worthwhile to store a second epix file containing all "rejected events".

@ramirezdiego
Copy link
Collaborator

Just for the record: This means that we are removing events with an inelastic component a 40 keV and 100 keV. This might be important for any TPC based neutron-veto.

@WenzDaniel Not sure I get your comment. This cut should only be applied when we want to estimate the pure NR SS, so disabled by default.

@ramirezdiego
Copy link
Collaborator

@shenyangshi @PavelKavrigin If this is not adding a significan delay to the code, I would suggest that we always store the e_dep_er and e_dep_nr branches per event, and use the nr_cut flag to simply select events according to them (this can also help @WenzDaniel with his current checks, maybe?).

On the other side, if the output file can't be modified now (because this would require doing the same with WFSim), let's just leave these branches floating and fix that in future commits.

@ramirezdiego
Copy link
Collaborator

@shenyangshi Can you refresh my memory on the 32 keV upper bound for ERs? I was assuming we'd use a lower one. Anything to do with Kr83m?

@shenyangshi
Copy link
Contributor

No, it just comes to me that the ER energy in NR events is well above the NR energy scale, so selecting 10kev or 32kev wouldn't make a difference to the results. The upper bound for Ed_nr*Lindhard factor is around 32kev, so I selected this value.

Copy link
Collaborator

@ramirezdiego ramirezdiego left a comment

Choose a reason for hiding this comment

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

@shenyangshi Could you please add the NR cut as a keyword argument in bin/run_epix?

@shenyangshi
Copy link
Contributor

Sure, it's done, sorry I didn't notice this file before.

@shenyangshi
Copy link
Contributor

This NR cut essentially finds out NR events (labeled by g4id, shared by interactions within) that contain ER components (beta and gamma) smaller than 10kev.

For example, the following whole event is removed because there are two huge ER energy depositions:
image

But the following event is preserved because only NR is involved:
image

@ramirezdiego ramirezdiego merged commit 99519e4 into master May 20, 2022
@ramirezdiego ramirezdiego deleted the nrcut branch May 20, 2022 11:29
ramirezdiego added a commit that referenced this pull request Sep 29, 2022
* Harmonize with the latest WFSim/epix versions
* Fix.
* Fix.
* Added a draft of the nT macro-clustering based on Micha's study
* Fixed some calculation parameters, added a new example notebook
* Add NR filter before quanta generation (#53)
* New branch version.
* NR-only cut string.
* Fixed import of the NR cut config parameter
* Fixed version label
* nr cut with ER component smaller than 32kev
* nr cut
* field
* change er threshold
* add nr to bin run_epix
* Add NR cut info to README
* store_true for NR cut

Co-authored-by: Pavel Kavrigin <pkavrigin@dali-login1.rcc.local>
Co-authored-by: Shenyang Shi <ss6109@columbia.edu>
Co-authored-by: ramirezdiego <diego.ramirez@physik.uni-freiburg.de>

* Update HISTORY for release
* Bump version: 0.2.2 → 0.3.0
* Set arg defaults (#55)
* set nr_only cut default to false
* add error for invalid input format
* Save primary particle position (#56)
* Added x_pri, y_pri, z_pri to the output
* Debugged x_pri, y_pri, z_pri recording
* WFSim requirements

Co-authored-by: Diego Ramírez García <diego.ramirez@physik.uni-freiburg.de>

* Update HISTORY for release
* Bump version: 0.3.0 → 0.3.1
* Fix the notebook + fix cS2 calculation.
* First implementation of BBF quanta generator (#57)
* Added BBF yield quanta generation in epix
* Fix white space
* updated readme
* New intermediate results as defaults
* Nex/Ni ratio for NR is computed inside and does not need to be provided
* update nr parameters
* add back fixed parameters in BBF fitting
* Correct syntax

Co-authored-by: Zihao Xu <zihao.xu@columbia.edu>
Co-authored-by: Diego Ramírez García <diego.ramirez@physik.uni-freiburg.de>

* Update HISTORY for release
* Bump version: 0.3.1 → 0.3.2
* fix conflict with master
* removing import simualtor for merging with master
* adding simualator to init

Co-authored-by: Pavel Kavrigin <pkavrigin@dali-login1.rcc.local>
Co-authored-by: Shenyang Shi <ss6109@columbia.edu>
Co-authored-by: ramirezdiego <diego.ramirez@physik.uni-freiburg.de>
Co-authored-by: Andrii Terliuk <andrey.terlyuk@gmail.com>
Co-authored-by: Zihao Xu <zihao.xu@columbia.edu>
Co-authored-by: Giovanni Volta <gvolta@physik.uzh.ch>
ramirezdiego added a commit that referenced this pull request Mar 10, 2023
* Add NR filter before quanta generation (#53)

* New branch version.
* NR-only cut string.
* Fixed import of the NR cut config parameter
* Fixed version label
* nr cut with ER component smaller than 32kev
* nr cut
* field
* change er threshold
* add nr to bin run_epix
* Add NR cut info to README
* store_true for NR cut

Co-authored-by: Pavel Kavrigin <pkavrigin@dali-login1.rcc.local>
Co-authored-by: Shenyang Shi <ss6109@columbia.edu>
Co-authored-by: ramirezdiego <diego.ramirez@physik.uni-freiburg.de>

* Update HISTORY for release

* Bump version: 0.2.2 → 0.3.0

* Set arg defaults (#55)

* set nr_only cut default to false
* add error for invalid input format

* Save primary particle position (#56)

* Added x_pri, y_pri, z_pri to the output
* Debugged x_pri, y_pri, z_pri recording
* WFSim requirements

Co-authored-by: Diego Ramírez García <diego.ramirez@physik.uni-freiburg.de>

* Update HISTORY for release

* Bump version: 0.3.0 → 0.3.1

* First implementation of BBF quanta generator (#57)

* Added BBF yield quanta generation in epix
* Fix white space
* updated readme
* New intermediate results as defaults
* Nex/Ni ratio for NR is computed inside and does not need to be provided
* update nr parameters
* add back fixed parameters in BBF fitting
* Correct syntax

Co-authored-by: Zihao Xu <zihao.xu@columbia.edu>
Co-authored-by: Diego Ramírez García <diego.ramirez@physik.uni-freiburg.de>

* Update HISTORY for release

* Bump version: 0.3.1 → 0.3.2

* fix fast sim

* remove prints

* including Jaron ss-ms res

* commit berfore pull

* decision tree clustering working

* Specify not working numba in req. file (#62)

* fix loop for

* updated

* add prim position for materials and e dep from G4

* fixing bugs

* updates for the meeting

* a very bad example

* Update requirements.txt (#63)

* Bump version: 0.3.2 → 0.3.3

* Sync hystory

* Update python-publish.yml

* Add zenodo badge

* Set S2 clustering algorithm in the config

* New example notebook

---------

Co-authored-by: Pavel Kavrigin <68543201+PavelKavrigin@users.noreply.github.com>
Co-authored-by: Pavel Kavrigin <pkavrigin@dali-login1.rcc.local>
Co-authored-by: Shenyang Shi <ss6109@columbia.edu>
Co-authored-by: ramirezdiego <diego.ramirez@physik.uni-freiburg.de>
Co-authored-by: Andrii Terliuk <andrey.terlyuk@gmail.com>
Co-authored-by: Zihao Xu <zihao.xu@columbia.edu>
Co-authored-by: Jaron Grigat <jarongrigat@Jarons-MacBook-Air.fritz.box>
Co-authored-by: Joran R. Angevaare <joranangevaare@gmail.com>
Co-authored-by: Joran Angevaare <j.angevaare@nikhef.nl>
Co-authored-by: PavelKavrigin <pavel.kavrigin@gmail.com>
Co-authored-by: Pavel Kavrigin <pkavrigin@dali-login2.rcc.local>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants