ATLAS Offline Software
Loading...
Searching...
No Matches
TriggerLeg_DictHelpers Namespace Reference

Functions

 TriggerDict ()
 MapKeysDict (target_version)

Function Documentation

◆ MapKeysDict()

TriggerLeg_DictHelpers.MapKeysDict ( target_version)

Definition at line 37 of file TriggerLeg_DictHelpers.py.

37def MapKeysDict(target_version):
38
39 # Dictionary from TrigGlobalEfficiencyCorrection/MapKeys.cfg
40 # Key is year_leg
41 # Value is list of configs available
42
43 with open(find_datafile('TrigGlobalEfficiencyCorrection/MapKeys.cfg'), 'r') as file:
44 file_content = file.read()
45
46 # Split the content by lines
47 lines = file_content.strip().split('\n')
48
49 # Initialize an empty dictionary to hold the results
50 trigger_dict = {}
51
52 # Variables to keep track of the current version and if we are in the right version section
53 current_version = None
54 in_target_version = False
55
56 for line in lines:
57 # Remove leading and trailing whitespaces
58 line = line.strip()
59
60 # Skip empty lines and comment lines
61 if not line or line.startswith('#'):
62 continue
63
64 # Check for version lines
65 if line.startswith("[VERSION]"):
66 current_version = line.replace("[VERSION]", "").strip()
67 in_target_version = target_version in current_version
68 continue
69
70 # If we are in the target version section, parse the entries
71 if in_target_version:
72 parts = line.split()
73 if len(parts) < 3:
74 continue
75 key = f"{parts[0]}_{parts[1]}"
76 values = parts[2:]
77 trigger_dict[key] = values
78
79 return trigger_dict
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177

◆ TriggerDict()

TriggerLeg_DictHelpers.TriggerDict ( )

Definition at line 8 of file TriggerLeg_DictHelpers.py.

8def TriggerDict():
9
10 # Dictionary from TrigGlobalEfficiencyCorrection/Triggers.cfg
11 # Key is trigger chain (w/o HLT prefix)
12 # Value is empty for single leg trigger or list of legs
13
14 with open(find_datafile('TrigGlobalEfficiencyCorrection/Triggers.cfg'), 'r') as file:
15 file_content = file.read()
16
17 # Split the content by lines
18 lines = file_content.strip().split('\n')
19 # Initialize an empty dictionary to hold the results
20 trigger_dict = {}
21 # Loop through each line in the file content
22 for line in lines:
23 # Split the line by whitespace
24 parts = line.split()
25 if not parts:
26 continue
27 # The first element is the key, the rest are the values
28 key = parts[0]
29 if key.startswith('#'):
30 continue
31 values = parts[1:]
32 # Add to dictionary
33 trigger_dict[key] = values
34 return trigger_dict
35
36