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

Save Geant4 primary position in truth #379

Merged
merged 2 commits into from
Jun 6, 2022
Merged
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
20 changes: 15 additions & 5 deletions wfsim/strax_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
(('Volume id giving the detector subvolume', 'vol_id'), np.int32),
(('Local field [ V / cm ]', 'local_field'), np.float64),
(('Number of excitons', 'n_excitons'), np.int32),
]
(('X position of the primary particle [cm]', 'x_pri'), np.float32),
(('Y position of the primary particle [cm]', 'y_pri'), np.float32),
(('Z position of the primary particle [cm]', 'z_pri'), np.float32),
]


optical_extra_dtype = [(('first optical input index', '_first'), np.int32),
Expand Down Expand Up @@ -138,6 +141,10 @@ def _rand_instructions(
inst['y'] = np.repeat(r * np.sin(t), 2)
inst['z'] = np.repeat(np.random.uniform(-tpc_length, 0, n_events), 2)

inst['x_pri'] = inst['x']
inst['y_pri'] = inst['y']
inst['z_pri'] = inst['z']

# Here we'll define our XENON-like detector
nest_calc = nestpy.NESTcalc(nestpy.VDetector())
nucleus_A = 131.293
Expand Down Expand Up @@ -265,6 +272,9 @@ def read_optical(config):
ins['x'] = events["xp_pri"].array(library="np").flatten()[mask] / 10.
ins['y'] = events["yp_pri"].array(library="np").flatten()[mask] / 10.
ins['z'] = events["zp_pri"].array(library="np").flatten()[mask] / 10.
ins['x_pri'] = np.zeros(n_events, np.int64)
ins['y_pri'] = np.zeros(n_events, np.int64)
ins['z_pri'] = np.zeros(n_events, np.int64)
ins['time'] = np.zeros(n_events, np.int64)
ins['event_number'] = np.arange(n_events)
ins['g4id'] = events['eventid'].array(library="np")[mask]
Expand Down Expand Up @@ -611,9 +621,9 @@ def check_instructions(self):
self.instructions = self.instructions[~m]

assert np.all(self.instructions['x']**2 + self.instructions['y']**2 < self.config['tpc_radius']**2), \
"Interation is outside the TPC"
"Interaction is outside the TPC (radius)"
assert np.all(self.instructions['z'] < 0.25), \
"Interation is outside the TPC"
"Interaction is outside the TPC (in Z)"
assert np.all(self.instructions['amp'] > 0), \
"Interaction has zero size"

Expand Down Expand Up @@ -788,9 +798,9 @@ def check_instructions(self):

assert np.all(self.instructions_epix['x']**2 + self.instructions_epix['y']**2 <
self.config['tpc_radius']**2), \
"Interation is outside the TPC"
"Interaction is outside the TPC (radius)"
assert np.all(self.instructions_epix['z'] < 0.25), \
"Interation is outside the TPC"
"Interaction is outside the TPC (in Z)"
assert np.all(self.instructions_epix['amp'] > 0), \
"Interaction has zero size"
assert all(self.instructions_epix['g4id'] >= self.config['entry_start'])
Expand Down