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>
21from tracking import add_tracking_reconstruction
22from tracking.harvest.harvesting import HarvestingModule
23from tracking.harvest.refiners import SaveTreeRefiner
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.
65 :param mc: Belle2::MCParticle
66 :return: dict
with the variables of interest.
68 mc_vertex = mc.getDecayVertex()
69 mc_perp = mc_vertex.Rho()
70 mc_theta = mc_vertex.Theta()
71 mc_phi = mc_vertex.Phi()
73 mc_p = mc.getMomentum().R()
75 v0 = mc.getRelated("V0ValidationVertexs")
78 v0_vertex = v0.getVertexPosition()
79 v0_perp = v0_vertex.Rho()
80 v0_theta = v0_vertex.Theta()
81 v0_phi = v0_vertex.Phi()
82 v0_m = v0.getFittedInvariantMass()
83 v0_p = v0.getFittedMomentum()
84 v0_chi2 = v0.getVertexChi2()
106 "THETA_MC": mc_theta,
119 save_tree = SaveTreeRefiner()
121 basf2.set_random_seed(1337)
122 path = basf2.create_path()
124 path.add_module(
'RootInput', inputFileName=
'../KShortGenSimNoBkg.root')
125 path.add_module(
'Gearbox')
127 add_tracking_reconstruction(path)
130 for module
in path.modules():
131 if module.name() ==
"V0Finder":
132 module.param(
"Validation",
True)
133 path.add_module(
'MCV0Matcher', V0ColName=
'V0ValidationVertexs')
134 path.add_module(V0Harvester())
136 path.add_module(
"Progress")
139 print(basf2.statistics)
142if __name__ ==
'__main__':
146 print(
"This validation deactivated and thus basf2 is not executed.\n"
147 "If you want to run this validation, please set the 'ACTIVE' flag above to 'True'.\n"