12 from importlib
import import_module
15 from basf2
import B2ERROR
17 from tabulate
import tabulate
22 (
"10000000",
"systematics",
"Random"),
24 (
"10600300",
"systematics",
"SystematicsTracking"),
25 (
"10600400",
"systematics",
"Resonance"),
26 (
"10600500",
"systematics",
"SystematicsRadMuMu"),
27 (
"10600600",
"systematics",
"SystematicsEELL"),
28 (
"10600700",
"systematics",
"SystematicsRadEE"),
29 (
"10620200",
"systematics",
"SystematicsLambda"),
30 (
"11640100",
"systematics",
"SystematicsPhiGamma"),
31 (
"10600800",
"systematics",
"SystematicsFourLeptonFromHLTFlag"),
32 (
"10600900",
"systematics",
"SystematicsRadMuMuFromHLTFlag"),
33 (
"10611000",
"systematics",
"SystematicsJpsi"),
34 (
"10611100",
"systematics",
"SystematicsKshort"),
35 (
"10601200",
"systematics",
"SystematicsBhabha"),
36 (
"10601300",
"systematics",
"SystematicsCombinedHadronic"),
37 (
"10601400",
"systematics",
"SystematicsCombinedLowMulti"),
38 (
"10601500",
"systematics",
"SystematicsDstar"),
41 (
"11110100",
"semileptonic",
"PRsemileptonicUntagged"),
42 (
"11130300",
"leptonic",
"LeptonicUntagged"),
43 (
"11130301",
"leptonic",
"dilepton"),
44 (
"11160200",
"semileptonic",
"SLUntagged"),
45 (
"11160201",
"semileptonic",
"B0toDstarl_Kpi_Kpipi0_Kpipipi"),
46 (
"11180100",
"fei",
"feiHadronicB0"),
47 (
"11180200",
"fei",
"feiHadronicBplus"),
48 (
"11180300",
"fei",
"feiSLB0"),
49 (
"11180400",
"fei",
"feiSLBplus"),
50 (
"11180500",
"fei",
"feiHadronic"),
51 (
"11180600",
"fei",
"feiSL"),
54 (
"12160100",
"ewp",
"BtoXgamma"),
55 (
"12160200",
"ewp",
"BtoXll"),
56 (
"12160300",
"ewp",
"BtoXll_LFV"),
57 (
"12160400",
"ewp",
"inclusiveBplusToKplusNuNu"),
60 (
"13160200",
"tdcpv",
"TDCPV_ccs"),
61 (
"13160300",
"tdcpv",
"TDCPV_qqs"),
64 (
"14120300",
"btocharm",
"BtoD0h_Kspi0"),
65 (
"14120400",
"btocharm",
"BtoD0h_Kspipipi0"),
68 (
"14120600",
"btocharm",
"B0toDpi_Kpipi"),
69 (
"14120601",
"btocharm",
"B0toDpi_Kspi"),
71 (
"14120700",
"btocharm",
"B0toDstarPi_D0pi_Kpi"),
74 (
"14120800",
"btocharm",
"B0toDstarPi_D0pi_Kpipipi_Kpipi0"),
75 (
"14121100",
"btocharm",
"B0toDrho_Kpipi"),
76 (
"14121101",
"btocharm",
"B0toDrho_Kspi"),
77 (
"14121200",
"btocharm",
"B0toDstarRho_D0pi_Kpi"),
78 (
"14121201",
"btocharm",
"B0toDstarRho_D0pi_Kpipipi_Kpipi0"),
79 (
"14140100",
"btocharm",
"BtoD0h_hh"),
80 (
"14140101",
"btocharm",
"BtoD0h_Kpi"),
82 (
"14140102",
"btocharm",
"BtoD0h_Kpipipi_Kpipi0"),
83 (
"14140200",
"btocharm",
"BtoD0h_Kshh"),
84 (
"14141000",
"btocharm",
"BtoD0rho_Kpi"),
85 (
"14141001",
"btocharm",
"BtoD0rho_Kpipipi_Kpipi0"),
86 (
"14141002",
"btocharm",
"B0toDD_Kpipi_Kspi"),
87 (
"14141003",
"btocharm",
"B0toDstarD"),
88 (
"14121300",
"btocharm",
"B0toD0Kpipi0_pi0"),
92 (
"15410300",
"quarkonium",
"InclusiveLambda"),
93 (
"15420100",
"quarkonium",
"BottomoniumEtabExclusive"),
94 (
"15440100",
"quarkonium",
"BottomoniumUpsilon"),
96 (
"16460200",
"quarkonium",
"CharmoniumPsi"),
99 (
"17230100",
"charm",
"XToD0_D0ToHpJm"),
102 (
"17230200",
"charm",
"XToD0_D0ToNeutrals"),
103 (
"17230300",
"charm",
"DstToD0Pi_D0ToRare"),
104 (
"17230400",
"charm",
"XToDp_DpToKsHp"),
105 (
"17230500",
"charm",
"XToDp_DpToHpHmJp"),
106 (
"17230600",
"charm",
"LambdacTopHpJm"),
107 (
"17240100",
"charm",
"DstToD0Pi_D0ToHpJm"),
109 (
"17240200",
"charm",
"DstToD0Pi_D0ToHpJmPi0"),
110 (
"17240300",
"charm",
"DstToD0Pi_D0ToHpHmPi0"),
112 (
"17240400",
"charm",
"DstToD0Pi_D0ToKsOmega"),
114 (
"17240500",
"charm",
"DstToD0Pi_D0ToHpJmEta"),
116 (
"17240600",
"charm",
"DstToD0Pi_D0ToNeutrals"),
117 (
"17240700",
"charm",
"DstToD0Pi_D0ToHpJmKs"),
119 (
"17240800",
"charm",
"EarlyData_DstToD0Pi_D0ToHpJmPi0"),
120 (
"17240900",
"charm",
"EarlyData_DstToD0Pi_D0ToHpHmPi0"),
121 (
"17241000",
"charm",
"DstToDpPi0_DpToHpPi0"),
122 (
"17241100",
"charm",
"DstToD0Pi_D0ToHpHmHpJm"),
123 (
"17241200",
"charm",
"DstToD0Pi_D0ToVGamma"),
126 (
"18020100",
"dark",
"SinglePhotonDark"),
127 (
"18020200",
"dark",
"GammaGammaControlKLMDark"),
128 (
"18020300",
"dark",
"ALP3Gamma"),
129 (
"18020400",
"dark",
"EGammaControlDark"),
130 (
"18000000",
"dark",
"InelasticDarkMatter"),
131 (
"18000001",
"dark",
"RadBhabhaV0Control"),
132 (
"18360100",
"taupair",
"TauLFV"),
133 (
"18520100",
"dark",
"DimuonPlusMissingEnergy"),
134 (
"18520200",
"dark",
"ElectronMuonPlusMissingEnergy"),
135 (
"18520300",
"dark",
"DielectronPlusMissingEnergy"),
136 (
"18520400",
"dark",
"LFVZpVisible"),
137 (
"18130100",
"dark",
"BtoKplusLLP"),
138 (
"18570600",
"taupair",
"TauGeneric"),
139 (
"18570700",
"taupair",
"TauThrust"),
140 (
"18530100",
"lowMulti",
"TwoTrackLeptonsForLuminosity"),
141 (
"18520500",
"lowMulti",
"LowMassTwoTrack"),
142 (
"18530200",
"lowMulti",
"SingleTagPseudoScalar"),
143 (
"18020500",
"dark",
"InelasticDarkMatterWithDarkHiggs"),
144 (
"18370100",
"dark",
"AA2uuuu"),
147 (
"19120100",
"btocharmless",
"BtoPi0Pi0"),
148 (
"19130201",
"btocharmless",
"BtoHadTracks"),
149 (
"19130300",
"btocharmless",
"BtoHad1Pi0"),
150 (
"19130310",
"btocharmless",
"BtoHad3Tracks1Pi0"),
151 (
"19120400",
"btocharmless",
"BtoRhopRhom"),
154 A list of all official registered skims and their skim code and parent module. Entries
155 must be of the form ``(code, module, name)``.
159 def _add_skim_registry_table(SkimRegistry):
161 Decorator to add a Sphinx table to the docstring of the skim registry.
163 Inserts table wherever '<TABLE>' is in the docstring.
166 df = pd.DataFrame(_RegisteredSkims, columns=[
"Skim code",
"Module",
"Skim name"])
167 df = df[[
"Module",
"Skim name",
"Skim code"]].sort_values(by=[
"Module",
"Skim code"])
168 table = tabulate(df, showindex=
"never", tablefmt=
"grid", headers=df.columns)
171 OriginalLines = table.split(
"\n")
172 header, OriginalLines, footer = OriginalLines[:2], OriginalLines[2:-1], OriginalLines[-1]
175 lines.append(
"\n ".join(header))
176 for BorderLine, TextLine
in zip(OriginalLines[::2], OriginalLines[1::2]):
177 segments = TextLine.split(
"|")
178 module = segments[1].lstrip().rstrip()
179 if CurrentModule == module:
180 segments[1] =
" " * len(segments[1])
181 BorderLine =
"|" +
" " * len(segments[1]) + BorderLine.lstrip(
"+").lstrip(
"-")
183 CurrentModule = module
184 lines.append(BorderLine)
185 lines.append(
"|".join(segments))
188 SkimRegistry.__doc__ = SkimRegistry.__doc__.replace(
"<TABLE>",
"\n ".join(lines))
193 @_add_skim_registry_table
196 Class containing information on all official registered skims. This class also
197 contains helper functions for getting information from the registry. For
198 convenience, an instance of this class is provided: `skim.registry.Registry`.
200 The table below lists all registered skims and their skim codes:
204 _registry = _RegisteredSkims
208 self.
_modules_modules = list({module
for _, module, _
in self.
_registry_registry})
213 """A list of all registered skim names."""
218 """A list of all registered skim codes."""
223 """A list of all registered skim modules."""
227 """Retrieve the skim module name from the registry which contains the given
231 SkimName (str): Name of the skim as it appears in the skim registry.
234 The name of the skim module which contains the skim.
236 lookup = {name: module
for _, module, name
in self.
_registry_registry}
238 return lookup[SkimName]
241 f
"Unrecognised skim name {SkimName}. "
242 "Please add your skim to the list in `skim/scripts/skim/registry.py`."
244 raise LookupError(SkimName)
247 """Retrieve a list of the skims listed in the registry as existing in
248 the given skim module.
251 SkimModule (str): The name of the module, *e.g.* ``btocharmless`` (not
252 ``skim.btocharmless`` or ``btocharmless.py``).
255 The skims listed in the registry as belonging to ``SkimModule``.
257 if SkimModule
not in self.
modulesmodules:
258 B2ERROR(f
"Unrecognised skim module {SkimModule}.")
259 raise LookupError(SkimModule)
261 ModuleLookup = {name: module
for _, module, name
in self.
_registry_registry}
263 module: [name
for name
in self.
namesnames
if ModuleLookup[name] == module]
264 for module
in self.
modulesmodules
266 return NameLookup[SkimModule]
269 """Get the skim class constructor for the given skim.
271 This is achieved by importing the module listed alongside the skim name in the
275 SkimName (str): Name of the skim to be found.
278 The class constructor for the given skim.
281 SkimModule = import_module(f
"skim.WGs.{ModuleName}")
282 return getattr(SkimModule, SkimName)
285 """Find the 8 digit skim code assigned to the skim with the provided name.
288 SkimName (str): Name of the corresponding skim as it appears in the skim registry.
291 8 digit skim code assigned to the given skim.
293 lookup = {name: code
for code, _, name
in self.
_registry_registry}
295 return lookup[SkimName]
298 f
"Unrecognised skim name {SkimName}. "
299 "Please add your skim to the list in `skim/scripts/skim/registry.py`."
301 raise LookupError(SkimName)
304 """Find the name of the skim which corresponds to the provided skim code.
306 This is useful to determine the skim script used to produce a specific uDST
307 file, given the 8-digit code name of the file itself.
310 SkimCode (str): 8 digit skim code assigned to some skim.
313 Name of the corresponding skim as it appears in the skim registry.
315 lookup = {code: name
for code, _, name
in self.
_registry_registry}
317 return lookup[SkimCode]
320 f
"Unrecognised skim code {SkimCode}. "
321 "Please add your skim to the list in `skim/scripts/skim/registry.py`."
323 raise LookupError(SkimCode)
328 An instance of `skim.registry.SkimRegistryClass`. Use this in your script to get
329 information from the registry.
331 >>> from skim.registry import Registry
332 >>> Registry.encode_skim_name("SinglePhotonDark")
def decode_skim_code(self, SkimCode)
def get_skims_in_module(self, SkimModule)
def encode_skim_name(self, SkimName)
def get_skim_module(self, SkimName)
def get_skim_function(self, SkimName)