-
Notifications
You must be signed in to change notification settings - Fork 85
Doc 4 CoinSorter #557
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
base: master
Are you sure you want to change the base?
Doc 4 CoinSorter #557
Changes from all commits
daf0414
a71fe86
2846b19
4c54f09
1e1a89b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,9 @@ | ||
| from . import digitizers, doseactors, miscactors, filters, arfactors, dynamicactors | ||
| from . import ( | ||
| digitizers, | ||
| doseactors, | ||
| miscactors, | ||
| filters, | ||
| arfactors, | ||
| dynamicactors, | ||
| coincidences, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,68 @@ | ||
| import awkward as ak | ||
| from tqdm import tqdm | ||
| from ..exception import fatal | ||
| from .base import ActorBase | ||
| from ..base import process_cls | ||
|
|
||
|
|
||
| class Coincidences(ActorBase): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add the class to init file: https://github.com/OpenGATE/opengate/blob/master/opengate/actors/__init__.py
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| """ | ||
| The Coincidence Sorter searches, into the singles list, for pairs of coincident singles. Whenever two or more singles are found within a coincidence window, these singles are grouped to form a Coincidence event. All singles open their own coincidence window, and a logical OR is made between all the individual singels to find coincidences. | ||
| For the moment Coincidence Sorter can be used only offline. It means that a user should do the simulation in two steps: 1) create system with needed digitizer chain in order to obtain singles within usual Gate simulation; 2) process the file containg the singles in order to obtain coincidecens. | ||
| Please, use test072 as an example of use. | ||
|
|
||
| Input: a ROOT File with singles with attributes : "EventID", "TotalEnergyDeposit", "PreStepUniqueVolumeID", "GlobalTime" | ||
| Output: a ROOT file with initial singles and sorted coincidecens | ||
|
|
||
| The term “good” means that a pair of singles are in coincidence and that the 2 singles are separated by a number of blocks greater than or equal to the minSecDiff parameter of the coincidence sorter. | ||
|
|
||
| Policies: | ||
| - keepAll: All "good" pairs are keeped | ||
| - removeMultiples: All multiple coincidences are discard | ||
|
|
||
| """ | ||
|
|
||
| user_info_defaults = { | ||
| "singles_tree": ( | ||
| [], | ||
| { | ||
| "doc": "The name of the singles input tree from the provided root file. ", | ||
| }, | ||
| ), | ||
| "time_window": ( | ||
| [], | ||
| { | ||
| "doc": "Time window where to sort the coincidences (in ns).", | ||
| }, | ||
| ), | ||
| "minSecDiff": ( | ||
| [], | ||
| { | ||
| "doc": "Option will be added soon.", | ||
| }, | ||
| ), | ||
| "policy": ( | ||
| "keepAll", | ||
| { | ||
| "doc": "The policy for tratement of multiple coincidences", | ||
| "allowed_values": ( | ||
| "keepAll", | ||
| "removeMultiples", | ||
| ), | ||
| }, | ||
| ), | ||
| } | ||
|
|
||
| def __init__(self, *args, **kwargs) -> None: | ||
| super().__init__(self, *args, **kwargs) | ||
|
|
||
| def initialize(self): | ||
| ActorBase.initialize(self) | ||
| if self.policy != "removeMultiples" and self.policy != "keepAll": | ||
| fatal( | ||
| f"Error, the policy for the Coincidence Sorter must be removeMultiples or " | ||
| f"keepAll, while is is '{self.policy}'" | ||
| ) | ||
|
|
||
|
|
||
| def coincidences_sorter( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe move all following functions into Coincidences class?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't manage to make it work. Keep it this way for the moment |
||
|
|
@@ -119,3 +181,6 @@ def remove_multiples(coincidences): | |
| ids = coincidences["EventID1"] | ||
| ids = [i for i in ids if ids.count(i) == 1] | ||
| return ids | ||
|
|
||
|
|
||
| process_cls(Coincidences) | ||
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 process_cls(...) at the end of the file
eg: https://github.com/OpenGATE/opengate/blob/master/opengate/actors/arfactors.py#L416
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.
Done