13 <contact>software-tracking@belle2.org</contact>
14 <input>KShortGenSimNoBkg.root</input>
15 <output>V0ValidationSample.root, V0ValidationHarvested.root</output>
16 <description>This module generates events for the V0 validation.</description>
21 from tracking
import add_tracking_reconstruction
31 Validate Kshort reconstruction efficiency and collect all the necessary data.
33 class V0Harvester(HarvestingModule):
34 """Collects variables of interest for the V0Validation and the v0ValidationCreatePlots script."""
37 """Initialize the harvester.
38 Defines over which StoreArray is iterated and the output file.
40 HarvestingModule.__init__(self, foreach=
"MCParticles", output_file_name=
"../V0ValidationHarvested.root")
42 def pick(self, mc_particle):
43 """Selects all MCParticles which are KShort AND decay to Pi+Pi-.
45 :param mc_particle: Belle2::MCParticle.
46 :return: True if the MCParticle is a KShort decaying to two charged pions.
48 if abs(mc_particle.getPDG()) != 310:
50 daughters = mc_particle.getDaughters()
51 return len(daughters) == 2
and abs(daughters[0].getPDG()) == 211
and abs(daughters[1].getPDG()) == 211
54 """Selects MCTrue variables of interest for all KShort in the sample. If the KShort has a related reconstructed
55 V0, these values are written out too. Variables of interest are:
56 R: Radial (in xy) distance to origin.
57 Theta: Theta Angle of decay vertex.
58 Phi: Phi Angle of decay vertex.
59 P: Momentum of the KShort.
60 M: Invariant mass of the KShort.
61 Chi2: Chi2 of vertex fit.
62 isFound: True if MCParticle has a related V0.
64 If the MCParticle has no related V0, the variables are filled with NaN's.
66 :param mc: Belle2::MCParticle
67 :return: dict with the variables of interest.
69 mc_vertex = mc.getDecayVertex()
70 mc_perp = mc_vertex.Rho()
71 mc_theta = mc_vertex.Theta()
72 mc_phi = mc_vertex.Phi()
74 mc_p = mc.getMomentum().R()
76 v0 = mc.getRelated(
"V0ValidationVertexs")
79 v0_vertex = v0.getVertexPosition()
80 v0_perp = v0_vertex.Rho()
81 v0_theta = v0_vertex.Theta()
82 v0_phi = v0_vertex.Phi()
83 v0_m = v0.getFittedInvariantMass()
84 v0_p = v0.getFittedMomentum()
85 v0_chi2 = v0.getVertexChi2()
107 "THETA_MC": mc_theta,
120 save_tree = SaveTreeRefiner()
122 basf2.set_random_seed(1337)
123 path = basf2.create_path()
125 path.add_module(
'RootInput', inputFileName=
'../KShortGenSimNoBkg.root')
126 path.add_module(
'Gearbox')
128 add_tracking_reconstruction(path)
131 for module
in path.modules():
132 if module.name() ==
"V0Finder":
133 module.param(
"Validation",
True)
134 path.add_module(
'MCV0Matcher', V0ColName=
'V0ValidationVertexs')
135 path.add_module(V0Harvester())
137 path.add_module(
"Progress")
140 print(basf2.statistics)
143 if __name__ ==
'__main__':
147 print(
"This validation deactivated and thus basf2 is not executed.\n"
148 "If you want to run this validation, please set the 'ACTIVE' flag above to 'True'.\n"