12 This module defines the uDST (user-defined data summary table) file format.
13 A uDST contains all dataobjects from mdst plus Particles and ParticleLists.
15 .. seealso:: :ref:`mdst`
21 from modularAnalysis
import removeParticlesNotInLists
26 path, filename, particleLists=None, additionalBranches=None, dataDescription=None, mc=True,
29 Save uDST (user-defined Data Summary Tables) = MDST + Particles + ParticleLists
30 The charge-conjugate lists of those given in particleLists are also stored.
31 Additional Store Arrays and Relations to be stored can be specified via additionalBranches
34 See also: `mdst.add_mdst_output`
37 that this does not reduce the amount of Particle objects saved,
38 see `udst.add_skimmed_udst_output` for a function that does.
40 :param basf2.Path path: Path to add the output modules to.
41 :param str filename: Name of the output file.
42 :param list(str) particleLists: Names of the particle lists to write out.
43 :param list(str) additionalBranches: datastore arrays/objects to write to the output
44 file in addition to mdst and particle information
45 :param dict dataDescription: Additional data descriptions to add to the output
46 file. For example {"mcEventType":"mixed"}
47 :param bool mc: Save Monte Carlo quantities? (MCParticles and corresponding relations)
50 if particleLists
is None:
52 if additionalBranches
is None:
53 additionalBranches = []
56 plSet = set(particleLists)
57 for List
in particleLists:
58 name, label = List.split(
":")
65 "ParticlesToMCParticles",
66 "ParticlesToPIDLikelihoods",
67 "ParticleExtraInfoMap",
76 if dataDescription
is None:
79 dataDescription.update(dataLevel=
"udst")
85 additionalBranches=partBranches,
86 dataDescription=dataDescription,
90 def add_skimmed_udst_output(
93 skimParticleLists=None,
94 outputParticleLists=None,
95 additionalBranches=None,
101 Create a new path for events that contain a non-empty particle list specified via skimParticleLists.
102 Write the accepted events as a udst file, saving only particles from skimParticleLists
103 and from outputParticleLists.
104 Additional Store Arrays and Relations to be stored can be specified via additionalBranches
107 :param basf2.Path path: Path to add the skim output to.
108 :param str skimDecayMode: Name of the skim. If no outputFile is given this is
109 also the name of the output filename. This name will be added to the
110 FileMetaData as an extra data description "skimDecayMode"
111 :param list(str) skimParticleLists: Names of the particle lists to skim for.
112 An event will be accepted if at least one of the particle lists is not empty
113 :param list(str) outputParticleLists: Names of the particle lists to store in
114 the output in addition to the ones in skimParticleLists
115 :param list(str) additionalBranches: datastore arrays/objects to write to the output
116 file in addition to mdst and particle information
117 :param str outputFile: Name of the output file if different from the skim name
118 :param dict dataDescription: Additional data descriptions to add to the output
119 file. For example {"mcEventType":"mixed"}
120 :param bool mc: Save Monte Carlo quantities? (MCParticles and corresponding relations)
123 if skimParticleLists
is None:
124 skimParticleLists = []
125 if outputParticleLists
is None:
126 outputParticleLists = []
127 if additionalBranches
is None:
128 additionalBranches = []
130 if outputFile
is None:
131 outputFile = skimDecayMode
134 if not outputFile.endswith(
".udst.root"):
135 outputFile +=
".udst.root"
137 skimfilter = basf2.register_module(
"SkimFilter")
138 skimfilter.set_name(
"SkimFilter_" + skimDecayMode)
139 skimfilter.param(
"particleLists", skimParticleLists)
140 path.add_module(skimfilter)
141 filter_path = basf2.create_path()
142 skimfilter.if_value(
"=1", filter_path, basf2.AfterConditionPath.CONTINUE)
145 skim_path = basf2.create_path()
146 saveParticleLists = skimParticleLists + outputParticleLists
151 if dataDescription
is None:
154 dataDescription.setdefault(
"skimDecayMode", skimDecayMode)
160 dataDescription=dataDescription,
163 filter_path.add_independent_path(skim_path,
"skim_" + skimDecayMode)
166 def add_udst_dump(path, print_untested=False):
168 Add a PrintObjectsModule to a path for printing the uDST contents to
169 test and maintain backwards compatibility.
171 See also: mdst.add_mdst_dump
174 path (basf2.Path): Path to add modules to
175 print_untested (bool): If True print the names of all methods which
176 are not explicitly printed to make sure we don't
177 miss addition of new members
180 eparticlesourceobjects = [i
for i
in range(7)]
184 protected_udst_dataobjects = [
199 "getMomentumMagnitude",
209 "getMomentumVertexErrorMatrix",
210 "getMomentumErrorMatrix",
211 "getVertexErrorMatrix",
216 "getDaughterIndices",
217 "getDaughterProperties",
219 "getFinalStateDaughters",
222 "getPDGCodeUsedForFit",
223 "wasExactFitHypothesisUsed",
227 "getECLClusterEnergy",
228 "getECLClusterEHypothesisBit",
236 "getEffectiveMomentumScale",
240 "getRelationsWith": [
245 "getMdstArrayIndices": eparticlesourceobjects,
246 "addExtraInfo": [[
"foo", 1337]],
247 "hasExtraInfo": [
"foo",
"bar"],
248 "getExtraInfo": [
"foo"],
249 "getDaughter": [0, 1],
250 "getCosHelicityDaughter": [0],
251 "getParticleFromGeneralizedIndexString": [
"0:0",
"0:1"],
256 "ParticleExtraInfoMap",
260 "getIndex": [[0,
"foo"], [0,
"bar"]],
261 "getMapForNewVar": [[
"foo"], [
"bar"]],
272 "addExtraInfo": [[
"foo", 1337]],
273 "hasExtraInfo": [
"foo"],
274 "getExtraInfo": [
"foo"],
279 path.add_module(PrintObjectsModule(protected_udst_dataobjects, print_untested))
def add_mdst_output(path, mc=True, filename='mdst.root', additionalBranches=[], dataDescription=None)