Skip to content

Commit ce29754

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent f370bb1 commit ce29754

13 files changed

Lines changed: 14 additions & 49 deletions

File tree

‎fuse/common.py‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,13 @@ def full_array_to_numpy(array, dtype):
7777
def _sample_from_distribution(p, channel, spe_scaling_factor_distributions):
7878
"""Function to sample from a SPE scaling factor distribution for a given
7979
channel."""
80-
8180
indices = np.int64(p * 2000) + 1
8281
return spe_scaling_factor_distributions[channel, indices]
8382

8483

8584
@numba.njit()
8685
def sample_spe_scaling_factors(p, channel, spe_scaling_factor_distributions):
8786
"""Function to sample the spe scaling factors for multiple photons."""
88-
8987
result = []
9088
for i in range(len(p)):
9189
result.append(
@@ -269,7 +267,6 @@ def photon_gain_calculation(
269267
):
270268
"""Function to calculate the PMT gain a photon will be amplified with in
271269
the waveform simulation."""
272-
273270
# Sample if the photon is a double PE emission
274271
_photon_is_dpe = rng.binomial(n=1, p=p_double_pe_emision, size=len(_photon_channels)).astype(
275272
np.bool_
@@ -316,7 +313,6 @@ def build_photon_propagation_output(
316313

317314
def pmt_gains(to_pe, digitizer_voltage_range, digitizer_bits, pmt_circuit_load_resistor):
318315
"""Build PMT Gains from PMT gain model and digitizer parameters."""
319-
320316
adc_2_current = digitizer_voltage_range / 2 ** (digitizer_bits) / pmt_circuit_load_resistor
321317

322318
gains = np.divide(

‎fuse/context.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ def microphysics_context(
119119
extra_plugins=[],
120120
):
121121
"""Function to create a fuse microphysics simulation context."""
122-
123122
st = strax.Context(storage=output_folder, **common_opts)
124123
st.set_config(dict(check_raw_record_overlaps=True, **common_config))
125124

@@ -159,7 +158,6 @@ def xenonnt_fuse_full_chain_simulation(
159158
This context includes all the necessary configs and plugins for the
160159
simulation.
161160
"""
162-
163161
# Load config file
164162
if run_without_config_file:
165163
# Just a dummy name to avoid errors. We use this to setup context for the docs.
@@ -308,7 +306,6 @@ def public_config_context(
308306
clustering_method="dbscan",
309307
):
310308
"""Create a context for the use of fuse with public XENONnT configs."""
311-
312309
st = strax.Context(storage=output_folder, **straxen.contexts.common_opts)
313310
st.simulation_config_file = simulation_config_file
314311
st.config.update(dict(check_raw_record_overlaps=True, **straxen.contexts.common_config))

‎fuse/context_utils.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ def set_simulation_config_file(context, config_file_name):
7373
@URLConfig.register("pattern_map")
7474
def pattern_map(map_data, pmt_mask, method="WeightedNearestNeighbors"):
7575
"""Pattern map handling."""
76-
7776
if "compressed" in map_data:
7877
compressor, dtype, shape = map_data["compressed"]
7978
map_data["map"] = np.frombuffer(

‎fuse/plugins/detector_physics/delayed_electrons/photo_ionization_electrons.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ def ramdom_xy_position(n, radius, rng):
255255
# We should try to make it a general function in the future.
256256
def group_electrons_by_cluster_id(electrons):
257257
"""Function to group electrons by cluster_id."""
258-
259258
sort_index = stable_argsort(electrons["cluster_id"])
260259

261260
electrons_sorted = electrons[sort_index]

‎fuse/plugins/detector_physics/secondary_scintillation.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ def get_s2_light_yield(self, positions):
208208
positions: 2d array of positions (floats) returns array
209209
of floats (mean expectation)
210210
"""
211-
212211
if self.se_gain_from_map:
213212
sc_gain = self.se_gain_map(positions)
214213
else:
@@ -233,7 +232,6 @@ def get_s2_light_yield(self, positions):
233232

234233
def group_result_photons_by_cluster_id(result, cluster_id):
235234
"""Function to group result_photons by cluster_id."""
236-
237235
sort_index = stable_argsort(cluster_id)
238236

239237
cluster_id_sorted = cluster_id[sort_index]

‎fuse/plugins/micro_physics/cuts_and_selections/apply_selections.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
class SelectionMerger(FuseBasePlugin):
1919
"""Merge cuts/selections and stamp per-volume constants.
2020
21-
The selection logic is given as a string expression over boolean fields
22-
in the `clustered_interactions` data. The expression may use '&', '|', '~',
23-
and parentheses. For example, to select interactions in the fiducial volume
24-
and with energy between 1 and 10 keV, use:
25-
"volume_selection & energy_range_cut"
21+
The selection logic is given as a string expression over boolean
22+
fields in the `clustered_interactions` data. The expression may use
23+
'&', '|', '~', and parentheses. For example, to select interactions
24+
in the fiducial volume and with energy between 1 and 10 keV, use:
25+
"volume_selection & energy_range_cut"
2626
"""
2727

2828
__version__ = "1.0.0"

‎fuse/plugins/micro_physics/find_cluster.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ def find_cluster(interactions, cluster_size_space, cluster_size_time):
8181
8282
First interactions are clustered in time, then in space.
8383
"""
84-
8584
time_cluster = simple_1d_clustering(interactions["time"], cluster_size_time)
8685

8786
# Splitting into time cluster and apply space clustering space:
@@ -127,7 +126,6 @@ def simple_1d_clustering(data, scale):
127126
Returns:
128127
clusters_undo_sort (np.array): Cluster Labels
129128
"""
130-
131129
idx_sort = stable_argsort(data)
132130
idx_undo_sort = stable_argsort(idx_sort)
133131

‎fuse/plugins/micro_physics/input.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ def __init__(
256256

257257
def output_chunk(self):
258258
"""Function to return one chunk of data from the root or csv file."""
259-
260259
if self.file_type == "root":
261260
interactions, n_simulated_events, start, stop = self._load_root_file()
262261
elif self.file_type == "csv":
@@ -586,7 +585,6 @@ def _load_csv_file(self):
586585
start: Index of the first loaded interaction
587586
stop: Index of the last loaded interaction
588587
"""
589-
590588
self.log.debug("Load instructions from a csv file!")
591589

592590
df = pd.read_csv(self.file)
@@ -632,7 +630,6 @@ def _awkwardify_df(df):
632630
Returns:
633631
ak.Array(dictionary): awkward array
634632
"""
635-
636633
_, evt_offsets = np.unique(df["eventid"], return_counts=True)
637634

638635
dictionary = {

‎fuse/plugins/micro_physics/lineage_cluster.py‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ def compute(self, geant4_interactions):
9090
Returns:
9191
np.ndarray: An array of cluster IDs with corresponding time and endtime values.
9292
"""
93-
9493
self.log.debug(f"Building lineages for {len(geant4_interactions)} interactions")
9594

9695
if len(geant4_interactions) == 0:
@@ -288,10 +287,9 @@ def build_lineage_for_event(
288287
)
289288

290289
else:
291-
raise ValueError(
292-
"There is no last particle interaction but we have seen \
293-
this particle before.... Makes no sense.."
294-
)
290+
raise ValueError( \
291+
"There is no last particle interaction but we have seen \
292+
this particle before.... Makes no sense..")
295293

296294
tmp_result["main_cluster_type"] = main_cluster_type
297295

@@ -319,7 +317,6 @@ def get_particle(event_interactions, event_lineage, index, trackid_lookup):
319317
def get_last_particle_interaction(event_interactions, particle, particle_lineage):
320318
"""Returns the last (previous in time) interaction of the particle that is
321319
in the lineage."""
322-
323320
# Get all interactions for the given particle
324321
all_particle_interactions = event_interactions[
325322
event_interactions["trackid"] == particle["trackid"]
@@ -369,7 +366,6 @@ def get_parent(event_interactions, event_lineage, particle, parent_lookup):
369366

370367
def is_particle_in_lineage(lineage):
371368
"""Function to check if a particle is already in a lineage."""
372-
373369
# All particles in the lineage have not been added to a lineage yet
374370
if np.all(lineage["lineage_index"] == 0):
375371
return False
@@ -384,7 +380,6 @@ def num_there(s):
384380
def classify_lineage(particle_interaction, classify_ic_as_gamma, classify_phot_as_beta):
385381
"""Function to classify a new lineage based on the particle and its parent
386382
information."""
387-
388383
def classify_gamma(particle_interaction):
389384
if particle_interaction["edproc"] == "compt":
390385
return NEST_BETA
@@ -475,7 +470,6 @@ def is_lineage_broken(
475470
time_threshold,
476471
):
477472
"""Function to check if the lineage is broken."""
478-
479473
# second step of a decay. We want to split the lineage
480474
if (
481475
particle["creaproc"] == "RadioactiveDecayBase"
@@ -535,7 +529,6 @@ def is_lineage_broken(
535529
def get_element_and_mass(particle_type):
536530
"""Function to get the element and the mass number from the particle
537531
type."""
538-
539532
pattern_match = re.match(r"([a-z]+)([0-9]+)", particle_type, re.I)
540533

541534
if pattern_match:

‎fuse/plugins/micro_physics/yields.py‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,8 @@ def update_nest_width_parameters(self):
129129
if self.nest_width_parameters is not None:
130130
for key, value in self.nest_width_parameters.items():
131131
if key not in parameters_key_map:
132-
raise ValueError(
133-
f"Unknown NEST width parameter {key}.\
134-
Available parameters: {parameters_key_map.keys()}"
135-
)
132+
raise ValueError(f"Unknown NEST width parameter {key}.\
133+
Available parameters: {parameters_key_map.keys()}")
136134
self.log.debug(f"Updating NEST width parameter {key} to {value}")
137135
free_parameters[parameters_key_map[key]] = value
138136

@@ -183,15 +181,13 @@ def compute(self, interactions_in_roi):
183181

184182
def get_quanta(self, en, model, e_field, A, Z, create_s2, density):
185183
"""Function to get quanta for given parameters using NEST."""
186-
187184
yields_result = self.get_yields_from_NEST(en, model, e_field, A, Z, density)
188185

189186
return self.process_yields(yields_result, create_s2)
190187

191188
def get_yields_from_NEST(self, en, model, e_field, A, Z, density):
192189
"""Function which uses NEST to yield photons and electrons for a given
193190
set of parameters."""
194-
195191
# Fix for Kr83m events
196192
max_allowed_energy_difference = 1 # keV
197193
if model == 11:
@@ -218,10 +214,8 @@ def get_yields_from_NEST(self, en, model, e_field, A, Z, density):
218214
e_field = self.fix_gamma_yield_field
219215

220216
if e_field < 0:
221-
raise ValueError(
222-
f"Negative electric field {e_field} V/cm not allowed. \
223-
(no error will be raised by NEST)."
224-
)
217+
raise ValueError(f"Negative electric field {e_field} V/cm not allowed. \
218+
(no error will be raised by NEST).")
225219

226220
yields_result = self.nc.GetYields(
227221
interaction=nestpy.INTERACTION_TYPE(model),
@@ -238,7 +232,6 @@ def get_yields_from_NEST(self, en, model, e_field, A, Z, density):
238232

239233
def process_yields(self, yields_result, create_s2):
240234
"""Process the yields with NEST to get actual quanta."""
241-
242235
# Density argument is not used in function...
243236
event_quanta = self.nc.GetQuanta(
244237
yields_result, free_parameters=self.updated_nest_width_parameters

0 commit comments

Comments
 (0)