ATLAS Offline Software
Functions
ZdcInjPulserVoltageReader Namespace Reference

Functions

def load_voltage_steps (run_number, voltage_values, voltage_strings, file_path="/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/ZdcConditions/INJpulser_combined_2024.json")
 

Function Documentation

◆ load_voltage_steps()

def ZdcInjPulserVoltageReader.load_voltage_steps (   run_number,
  voltage_values,
  voltage_strings,
  file_path = "/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/ZdcConditions/INJpulser_combined_2024.json" 
)
Reads a JSON file, determines the correct voltage step configuration for a given run number, 
and fills two lists:
  - voltage_values: List of raw float values after applying ScaleFactor.
  - voltage_strings: List of string representations rounded to 5 decimal places in "X.XXXXX" format.

Args:
    run_number (int): The run number to find the voltage steps for.
    voltage_values (list): A list that will be filled with the raw scaled voltage steps as floats.
    voltage_strings (list): A list that will be filled with the formatted voltage steps as strings.
    file_path (str): The path to the JSON file. Defaults to the provided path.

Definition at line 9 of file ZdcInjPulserVoltageReader.py.

9 def load_voltage_steps(run_number, voltage_values, voltage_strings, file_path="/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/ZdcConditions/INJpulser_combined_2024.json"):
10  """Reads a JSON file, determines the correct voltage step configuration for a given run number,
11  and fills two lists:
12  - voltage_values: List of raw float values after applying ScaleFactor.
13  - voltage_strings: List of string representations rounded to 5 decimal places in "X.XXXXX" format.
14 
15  Args:
16  run_number (int): The run number to find the voltage steps for.
17  voltage_values (list): A list that will be filled with the raw scaled voltage steps as floats.
18  voltage_strings (list): A list that will be filled with the formatted voltage steps as strings.
19  file_path (str): The path to the JSON file. Defaults to the provided path.
20  """
21 
22  if not os.path.exists(file_path):
23  print(f"Error: File not found at {file_path}")
24  return
25 
26  # Load JSON file
27  with open(file_path, "r") as file:
28  data = json.load(file)
29 
30  # Determine the correct StepsConfig and ScaleFactor for the given run number
31  steps_config_name = None
32  scale_factor = None
33 
34  for run_range in data["RunRanges"]:
35  if run_range["First"] <= run_number < run_range["Last"]:
36  steps_config_name = run_range["StepsConfig"]
37  scale_factor = run_range["ScaleFactor"]
38  break
39 
40  if not steps_config_name or scale_factor is None:
41  print(f"Warning: No voltage step configuration found for run number {run_number}.")
42  return
43 
44  # Retrieve the voltage step configuration
45  step_config = data["StepConfigurations"].get(steps_config_name)
46  if not step_config:
47  print(f"Error: Step configuration '{steps_config_name}' not found in the JSON file.")
48  return
49 
50  # Clear the voltage lists
51  voltage_values.clear()
52  voltage_strings.clear()
53 
54  # Generate the voltage steps, apply ScaleFactor, and store in both lists
55  for step in step_config:
56  if "nStep" in step and "vStart" in step and "vStep" in step:
57  n_steps = step["nStep"]
58  v_start = step["vStart"]
59  v_step = step["vStep"]
60 
61  for i in range(n_steps):
62  voltage = (v_start + i * v_step) * scale_factor
63  voltage_values.append(voltage)
64  # voltage_strings.append(f"{round(voltage, 5):.5f}V")
65  voltage_strings.append(f"{int(voltage*1000000):d}muV")
66 
ZdcInjPulserVoltageReader.load_voltage_steps
def load_voltage_steps(run_number, voltage_values, voltage_strings, file_path="/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/ZdcConditions/INJpulser_combined_2024.json")
Definition: ZdcInjPulserVoltageReader.py:9
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:26
Trk::open
@ open
Definition: BinningType.h:40
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127