|
def | __init__ (self, input=None, *grl=None, flags=None, json=None, menu=None, file=None, period=None) |
|
def | save (self, path) |
|
def | chains (self, *triggerType=TriggerType.ALL) |
|
def | triggerInfo (self) |
|
def | runs (self) |
|
def | setRunRange (self, start=0, end=999999) |
|
def | getLowestUnprescaled (self, *triggerType=TriggerType.ALL, livefraction=1.0, runStart=0, runEnd=999999) |
|
def | getLowestUnprescaledByRun (self, *triggerType=TriggerType.ALL, livefraction=1.0, runStart=0, runEnd=999999) |
|
def | getLowestUnprescaledAnyRun (self, *triggerType=TriggerType.ALL, livefraction=1.0, runStart=0, runEnd=999999) |
|
def | getLiveFractions (self, *triggerType=TriggerType.ALL, runStart=0, runEnd=999999) |
|
def | getLowerUnprescaled (self, *chainName, triggerType=TriggerType.ALL, livefraction=1.0, runStart=0, runEnd=999999) |
|
--------------------------------------------------------------------------------------------------------------------
TriggerAPI helper class. Use the following import in your code:
from TriggerMenuMT.TriggerAPI import TriggerAPISession,TriggerType,TriggerPeriod
Examples of use:
================
Set of triggers of a given type that are unprescaled for an entire GRL:
s = TriggerAPISession("path/to/grl.xml") # can be a PathResolver path as well
triggers = s.getLowestUnprescaled(triggerType=TriggerType.el_single)
Dictionary of sets of triggers of a given type that are unprescaled, for each run in the GRL:
s = TriggerAPISession("path/to/grl.xml")
triggersByRun = s.getLowestUnprescaledByRun(triggerType=TriggerType.el_single)
Set of triggers that are unprescaled for all runs between two run numbers (inclusive), in a GRL:
s = TriggerAPISession("path/to/grl.xml")
triggers = s.getLowestUnprescaledByRun(triggerType=TriggerType.el_single,runStart=123456,runEnd=234567)
Other helpful methods are:
- Set of runs present in the session's GRL: s.runs()
- List of trigger types: [x.name for x in TriggerType]
- Dictionary of livefractions between given runs, key = trigger chain name:
liveFractions = s.getLiveFractions(triggerType=TriggerType.el_single,runStart=123456,runEnd=234567)
- Dictionary of chains (key is chain.name): s.chains()
- Set of triggers that are deemed to be of same type and lower threshold than a given trigger and unprescaled:
triggers = s.getLowerPrescaled(chainName="myChain")
Each method accepts an "additionalTriggerType" parameter that is used for multi-leg triggers of different type
(e.g. e-mu triggers).
Instead of passing a GRL you can pass a menu name ("menu_name") in the constructor, and the unprescaled
triggers will be the Primary|TagAndProbe triggers from the menu.
Saving a session
================
Sessions can be saved to json file and reloaded at a later time (to save requerying the database):
s.save("myDump.json")
s2 = TriggerAPISession(json="myDump.json") # reloads the session
--------------------------------------------------------------------------------------------------------------------
Definition at line 14 of file TriggerAPISession.py.
def python.TriggerAPI.TriggerAPISession.TriggerAPISession.__init__ |
( |
|
self, |
|
|
|
input = None , |
|
|
* |
grl = None , |
|
|
|
flags = None , |
|
|
|
json = None , |
|
|
|
menu = None , |
|
|
|
file = None , |
|
|
|
period = None |
|
) |
| |
--------------------------------------------------------------------------------------------------------------------
TriggerAPI helper class. Use the following import in your code:
from TriggerMenuMT.TriggerAPI import TriggerAPISession,TriggerType,TriggerPeriod
Examples of use:
================
Set of triggers of a given type that are unprescaled for an entire GRL:
s = TriggerAPISession("path/to/grl.xml") # can be a PathResolver path as well
triggers = s.getLowestUnprescaled(triggerType=TriggerType.el_single)
Dictionary of sets of triggers of a given type that are unprescaled, for each run in the GRL:
s = TriggerAPISession("path/to/grl.xml")
triggersByRun = s.getLowestUnprescaledByRun(triggerType=TriggerType.el_single)
Set of triggers that are unprescaled for all runs between two run numbers (inclusive), in a GRL:
s = TriggerAPISession("path/to/grl.xml")
triggers = s.getLowestUnprescaledByRun(triggerType=TriggerType.el_single,runStart=123456,runEnd=234567)
Other helpful methods are:
- Set of runs present in the session's GRL: s.runs()
- List of trigger types: [x.name for x in TriggerType]
- Dictionary of livefractions between given runs, key = trigger chain name:
liveFractions = s.getLiveFractions(triggerType=TriggerType.el_single,runStart=123456,runEnd=234567)
- Dictionary of chains (key is chain.name): s.chains()
- Set of triggers that are deemed to be of same type and lower threshold than a given trigger and unprescaled:
triggers = s.getLowerPrescaled(chainName="myChain")
Each method accepts an "additionalTriggerType" parameter that is used for multi-leg triggers of different type
(e.g. e-mu triggers).
Instead of passing a GRL you can pass a menu name ("menu_name") in the constructor, and the unprescaled
triggers will be the Primary|TagAndProbe triggers from the menu.
Saving a session
================
Sessions can be saved to json file and reloaded at a later time (to save requerying the database):
s.save("myDump.json")
s2 = TriggerAPISession(json="myDump.json") # reloads the session
--------------------------------------------------------------------------------------------------------------------
Specify one and only one of the following parameters to construct your API session:
:param input: If specified, will try to auto-infer which of the things below it is:
:param grl: Path to a GRL file, locatable by PathResolver
:param flags: flag container, used if reading triggers from the trigger menu (in the file or the release) - EXPERT OPTION
:param json: Path to a JSON file, locatable by PathResolver, containing a cache of TriggerAPI session
:param menu: Specify a menu to use, such as "Physics_pp_run3_v1". This is otherwise taken from flags
:param file: Specify a root file (AOD etc) from which the menu will be taken
:param period: Legacy option, can specify a TriggerPeriod and will load through the hardcoded GRLs (TriggerPeriodData)
Definition at line 67 of file TriggerAPISession.py.
67 def __init__(self, input=None, *, grl=None, flags=None, json=None, menu=None, file=None, period=None):
69 Specify one and only one of the following parameters to construct your API session:
71 :param input: If specified, will try to auto-infer which of the things below it is:
73 :param grl: Path to a GRL file, locatable by PathResolver
74 :param flags: flag container, used if reading triggers from the trigger menu (in the file or the release) - EXPERT OPTION
75 :param json: Path to a JSON file, locatable by PathResolver, containing a cache of TriggerAPI session
76 :param menu: Specify a menu to use, such as "Physics_pp_run3_v1". This is otherwise taken from flags
77 :param file: Specify a root file (AOD etc) from which the menu will be taken
78 :param period: Legacy option, can specify a TriggerPeriod and will load through the hardcoded GRLs (TriggerPeriodData)
85 if input.endswith(
".xml"):
86 log.info(
"Loading session for GRL:" + input)
88 elif input.endswith(
".json"):
89 log.info(
"Loading saved session from:" + input)
91 elif os.path.exists(input):
92 log.info(
"Loading session with menu from file:" + input)
95 log.info(
"Loading session for menu:" + input)
98 raise RuntimeError(
"Unsupported input type:" +
type(input).__name__)
103 self.customGRL =
None
106 self.cacheread =
True
109 self.dbQueries = SerializeAPI.load(json)
110 elif grl
is not None:
111 from PathResolver
import PathResolver
114 elif flags
is not None:
116 elif menu
is not None:
117 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
119 self.flags.Trigger.triggerMenuSetup = menu
121 elif file
is not None:
122 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
124 self.flags.Input.Files = [file]
126 elif period
is not None:
128 TriggerAPI._loadTriggerPeriod(period,reparse=
False)
129 if not TriggerAPI.dbQueries:
130 raise RuntimeError(
"Failed to load TriggerAPI information for period")
132 self.dbQueries = copy.deepcopy(TriggerAPI.dbQueries)
134 raise RuntimeError(
"Must specify one of: grl, flags, json, menu, period")
136 if self.flags
is not None or self.customGRL
is not None:
138 period = TriggerPeriod.future2e34
139 if self.flags
is not None:
140 TriggerAPI.setConfigFlags(self.flags)
142 TriggerAPI.setCustomGRL(self.customGRL)
143 period = TriggerPeriod.customGRL
144 TriggerAPI._loadTriggerPeriod(period,reparse=
False)
145 if not TriggerAPI.dbQueries:
146 raise RuntimeError(
"Failed to load TriggerAPI information")
148 self.dbQueries = copy.deepcopy(TriggerAPI.dbQueries)