Skip to content

Commit

Permalink
fix small problem, update notebook, grand-mother/collab-issues#32
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyjim committed Feb 20, 2024
1 parent 078aa90 commit 36f8db2
Show file tree
Hide file tree
Showing 5 changed files with 414 additions and 100 deletions.
490 changes: 398 additions & 92 deletions examples/basis/class_Handling3dTraces.ipynb

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion examples/dataio/ioroot_3dtraces.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ def main():
o_tevent = d_event.get_obj_handling3dtraces()
if args.info:
print(f"Nb events : {d_event.get_nb_events()}")
print("Idx\trun_nb\tevent_nb")
for idx, evt in enumerate(d_event.l_events):
print(f"{idx}\t{evt[1]}\t{evt[0]}")
print(f"Select event index: {d_event.idx_event}")
print("===================")
print(f"Nb DU : {d_event.get_du_count()}")
print(f"Size trace : {d_event.get_size_trace()}")
print("Idx\trun\tevent")

assert isinstance(o_tevent, Handling3dTraces)
if args.list_du:
print(f"Identifier DU : {o_tevent.idx2idt}")
Expand Down
10 changes: 9 additions & 1 deletion examples/grandlib_introduction_v2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"\n",
"## ioroot_3dtraces.py\n",
"\n",
"This event viewer script is available in directory `grand/examples/dataio` in PATH. We can see EField ROOT file and also Voltage ROOT file.\n",
"This event viewer script is available in directory `grand/examples/dataio` in PATH. We can see EField ROOT file and also Voltage ROOT file. Multi-event file is managed by option `--idx_evt`\n",
"\n",
"## Documentation\n",
"\n",
Expand Down Expand Up @@ -233,6 +233,14 @@
"\n",
"See notebook grand/examples/basis/class_Handling3dTraces.ipynb"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8cc6075e-9e49-42c0-a84e-9eac04c35605",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
4 changes: 1 addition & 3 deletions grand/basis/type_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
GRANDCS,
CartesianRepresentation,
)
#from grand.dataio import io_node as io # , ECEF, LTP


logger = getLogger(__name__)
Expand Down Expand Up @@ -81,6 +80,7 @@ def dump(self, node: io.DataNode):
node.write("frame", self.frame)
"""


@dataclass
class Voltage:
t: np.ndarray # [s]
Expand Down Expand Up @@ -120,5 +120,3 @@ def dump(self, node: io.DataNode):
node.write("t", self.t, dtype="f4")
node.write("V", self.V, dtype="f4")
"""


7 changes: 4 additions & 3 deletions grand/dataio/root_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@ def __init__(self, tt_event, f_name):
self.t_bin_size: Optional[float] = 0.5
self.du_id: Optional[None, np.ndarray, list] = None
self.du_count: Optional[None, int] = None
self.du_xyz: Optional[None, np.ndarray] = None
self.f_name: Optional[str] = ""
self.du_xyz: Optional[None, np.ndarray] = None
self.tag: Optional[str] = ""
#
self.f_name = f_name
self.tt_event = tt_event
self.l_events = self.tt_event.get_list_of_events()
self.traces = np.empty((0, 3, 0), dtype=np.float32)
self.idx_event = -1
data_dir = groot.DataDirectory(os.path.dirname(f_name))
data_dir = groot.DataDirectory(os.path.dirname(f_name))
self.tt_shower = data_dir.tshower
self.tt_run = data_dir.trun
logger.info(f"file trun: {self.tt_run.file_name}\nfile tshower: {self.tt_shower.file_name}")
Expand Down

0 comments on commit 36f8db2

Please sign in to comment.