Skip to content
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

Remove 1T related codes #1476

Merged
merged 14 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
[report]
omit =
straxen/storage/rucio_remote.py
straxen/legacy/plugins_1t/pax_interface.py
straxen/entry_points.py
straxen/daq_core.py
straxen/scripts/*.py
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ live_data
daq_test_data
strax_data
strax_test_data
from_fake_daq
from_eb
from_eb_finished
resource_cache
Expand Down
61 changes: 24 additions & 37 deletions docs/source/build_datastructure_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@
"""

data_kinds_header = """
XENON nT data kinds
XENONnT data kinds
====================
As explained in the
`demo <https://straxen.readthedocs.io/en/latest/tutorials/strax_demo.html>`_,
in straxen, we have **data types** and **data kinds**. The **data types** are
documented in `the datastructure <https://straxen.readthedocs.io/en/latest/reference/datastructure_nT.html>`_
documented in `the datastructure <https://straxen.readthedocs.io/en/latest/reference/datastructure.html>`_
page and are the type of data that one can load in straxen using
``st.get_array(<RUN_ID>, <DATA_TYPE>)`` or ``st.get_df(<RUN_ID>, <DATA_TYPE>)``.

Expand All @@ -97,7 +97,6 @@

When writing a plugin, the ``plugin.compute(self, <DATA KIND>)`` method takes the **data kind**.

nT data kinds
--------------------------------------------------------

.. raw:: html
Expand All @@ -108,10 +107,10 @@
"""

titles = {
"": "Straxen {xT} datastructure",
"_he": "Straxen {xT} datastructure for high energy channels",
"_nv": "Straxen {xT} datastructure for neutron veto",
"_mv": "Straxen {xT} datastructure for muon veto",
"": "Straxen datastructure",
"_he": "Straxen datastructure for high energy channels",
"_nv": "Straxen datastructure for neutron veto",
"_mv": "Straxen datastructure for muon veto",
}
tree_suffices = list(titles.keys())

Expand Down Expand Up @@ -144,44 +143,35 @@ def get_plugins_deps(st):
return plugins_by_deps


def get_context(is_nt):
def get_context():
"""Need to init a context without initializing the runs_db as that requires the appropriate
passwords.

:return: straxen context that mimics the xenonnt_online context without the rundb init

"""
if is_nt:
st = straxen.contexts.xenonnt_online(_database_init=False)
st.context_config["forbid_creation_of"] = straxen.daqreader.DAQReader.provides
else:
st = straxen.contexts.xenon1t_dali()
st.register_all(straxen.legacy.plugins_1t.x1t_cuts)
st.context_config["forbid_creation_of"] = straxen.daqreader.DAQReader.provides
st = straxen.contexts.xenonnt_online(_database_init=False)
st.context_config["forbid_creation_of"] = straxen.daqreader.DAQReader.provides
return st


def build_datastructure_doc(is_nt):
def build_datastructure_doc():
"""Build a dependency tree for all plugins."""
pd.set_option("display.max_colwidth", int(1e9))

st = get_context(is_nt)
one_tonne_or_n_tonne = "nT" if is_nt else "1T"
st = get_context()
# Too lazy to write proper graph sorter
# Make dictionary {total number of dependencies below -> list of plugins}

plugins_by_deps = get_plugins_deps(st)

# Make graph for each suffix ('' referring to TPC)
for suffix in tree_suffices:
title = titles[suffix].format(xT=one_tonne_or_n_tonne)
out = page_header.format(title=title, context="xenonnt_online" if is_nt else "xenon1t_dali")
if not is_nt and suffix != "":
# No NV/MV/HE for 1T
continue

print(f"------------ {one_tonne_or_n_tonne}{suffix} ------------")
os.makedirs(this_dir + f"/graphs{suffix}_{one_tonne_or_n_tonne}", exist_ok=True)
title = titles[suffix]
out = page_header.format(title=title, context="xenonnt_online")

print(f"------------ {suffix} ------------")
os.makedirs(this_dir + f"/graphs{suffix}", exist_ok=True)
for n_deps in list(reversed(sorted(list(plugins_by_deps[suffix].keys())))):
for this_data_type in plugins_by_deps[suffix][n_deps]:
this_plugin = st._get_plugins(targets=(this_data_type,), run_id="0")[this_data_type]
Expand All @@ -192,7 +182,7 @@ def build_datastructure_doc(is_nt):
add_deps_to_graph_tree(graph_tree, this_plugin, this_data_type)

# Where to save this node
fn = this_dir + f"/graphs{suffix}_{one_tonne_or_n_tonne}/" + this_data_type
fn = this_dir + f"/graphs{suffix}/" + this_data_type
graph_tree.render(fn)
with open(f"{fn}.svg", mode="r") as f:
svg = add_spaces(f.readlines()[5:])
Expand Down Expand Up @@ -225,15 +215,13 @@ def build_datastructure_doc(is_nt):
config_options=add_spaces(config_df.to_html(index=False)),
)

with open(
this_dir + f"/reference/datastructure{suffix}_{one_tonne_or_n_tonne}.rst", mode="w"
) as f:
with open(this_dir + f"/reference/datastructure{suffix}.rst", mode="w") as f:
f.write(out)

shutil.rmtree(this_dir + f"/graphs{suffix}_{one_tonne_or_n_tonne}")
shutil.rmtree(this_dir + f"/graphs{suffix}")


def tree_to_svg(graph_tree, save_as="data_kinds_nT"):
def tree_to_svg(graph_tree, save_as="data_kinds"):
# Where to save this node
graph_tree.render(save_as)
with open(f"{save_as}.svg", mode="r") as f:
Expand All @@ -246,7 +234,7 @@ def tree_to_svg(graph_tree, save_as="data_kinds_nT"):
def write_data_kind_dep_tree():
"""Work in progress to build a dependency tree of the datakinds."""
print("------------ data kinds ------------")
st = get_context(is_nt=True)
st = get_context()

def get_plugin(pov):
return st._get_plugins((pov,), "0")[pov]
Expand Down Expand Up @@ -285,7 +273,7 @@ def get_plugin(pov):
for d in tree[data_kind]:
graph_tree.edge(data_kind, d)

svg = tree_to_svg(graph_tree, save_as="data_kinds_nT")
svg = tree_to_svg(graph_tree, save_as="data_kinds")
output = data_kinds_header.format(svg=svg)

# Sort by largest first
Expand Down Expand Up @@ -334,13 +322,12 @@ def get_plugin(pov):
for d in data_types:
extra += f"\n - ``{d}``"
output = output.format(data_types=extra)
data_type = this_dir + f"/reference/data_kinds_nT.rst"
data_type = this_dir + f"/reference/data_kinds.rst"
with open(data_type, mode="w") as f:
f.write(output)
assert os.path.exists(data_type)


if __name__ == "__main__":
write_data_kind_dep_tree()
build_datastructure_doc(True)
build_datastructure_doc(False)
build_datastructure_doc()
2 changes: 1 addition & 1 deletion docs/source/cmt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In specific CMT is a class within `strax <https://github.com/AxFoundation/strax/

CMT in straxen
--------------
A customized CMT can be implemented given the experiment software, in the case of straxen, experiment specifics can be added to CMT. To set CMT accordingly to straxen a class `CorrectionsManagementService() <https://github.com/XENONnT/straxen/blob/master/straxen/corrections_services.py>`_ allows the user to query and retrieve information. This class uses the start time of a given run to find the corresponding information and version for a given correction. For every correction user must set the proper configuration in order to retrieve the information, the syntax is the following ``my_configuration = (“my_correction”, “version”, True)`` the first part correspond to the string of the correction, then the version, it can be either an ONLINE version or OFFLINE version and finally the boolean correspond to the detector configuration (1T or nT).
A customized CMT can be implemented given the experiment software, in the case of straxen, experiment specifics can be added to CMT. To set CMT accordingly to straxen a class `CorrectionsManagementService() <https://github.com/XENONnT/straxen/blob/master/straxen/corrections_services.py>`_ allows the user to query and retrieve information. This class uses the start time of a given run to find the corresponding information and version for a given correction. For every correction user must set the proper configuration in order to retrieve the information, the syntax is the following ``my_configuration = (“my_correction”, “version”, True)`` the first part correspond to the string of the correction, then the version, it can be either an ONLINE version or OFFLINE version and finally the boolean correspond to the detector configuration.
In the case of straxen there are several plug-ins that call CMT to retrieve information, in that case, the configuration option is set by the ``strax.option()`` and the information is retrieve in `set()` via the function `straxen.get_correction_from_cmt()` and example is shown below where the electron life time is retrieve for a particular run ID, using the ONLINE version for the detector configuration nT=True.


Expand Down
3 changes: 1 addition & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ def setup(app):
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
import build_datastructure_doc

build_datastructure_doc.build_datastructure_doc(True)
build_datastructure_doc.build_datastructure_doc(False)
build_datastructure_doc.build_datastructure_doc()
build_datastructure_doc.write_data_kind_dep_tree()
import build_context_doc

Expand Down
19 changes: 6 additions & 13 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ Straxen is the analysis framework for XENONnT, built on top of the generic `stra

.. toctree::
:maxdepth: 1
:caption: nT Datastructure
:caption: Datastructure

reference/datastructure_nT
reference/datastructure_he_nT
reference/datastructure_nv_nT
reference/datastructure_mv_nT
reference/data_kinds_nT
reference/datastructure
reference/datastructure_he
reference/datastructure_nv
reference/datastructure_mv
reference/data_kinds


.. toctree::
Expand Down Expand Up @@ -63,13 +63,6 @@ Straxen is the analysis framework for XENONnT, built on top of the generic `stra
reference/context


.. toctree::
:maxdepth: 1
:caption: 1T Datastructure

reference/datastructure_1T


.. toctree::
:maxdepth: 1
:caption: Reference
Expand Down
53 changes: 0 additions & 53 deletions docs/source/reference/straxen.legacy.plugins_1t.rst

This file was deleted.

45 changes: 0 additions & 45 deletions docs/source/reference/straxen.legacy.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/source/scripts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,6 @@ bootstrax [DAQ-only]
As the main DAQ processing script. This is discussed separately. It is only used for XENONnT.


fake_daq
------------------
Script that allows mimiming DAQ-processing by opening raw-records data.


microstrax
------------------
Mini strax interface that allows strax-data to be retrieved using HTTP requests
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ repository = "https://github.com/XENONnT/straxen"
[tool.poetry.scripts]
ajax = "straxen.scripts.ajax:main"
bootstrax = "straxen.scripts.bootstrax:main"
fake_daq = "straxen.scripts.fake_daq:main"
microstrax = "straxen.scripts.microstrax:main"
refresh_raw_records = "straxen.scripts.refresh_raw_records:main"
restrax = "straxen.scripts.restrax:main"
Expand Down
5 changes: 2 additions & 3 deletions straxen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
from .bokeh_utils import *
from .config.url_config import *

from . import legacy
from .legacy import *

from . import plugins
from .plugins import *

Expand All @@ -30,6 +27,8 @@

from . import config

from . import units

# Do not make all contexts directly available under straxen.
# Otherwise, we have straxen.demo() etc.
from . import contexts
Expand Down
Loading