Belle II Software light-2406-ragdoll
reconstruction.py
1# @cond
2import b2luigi as luigi
3from b2luigi.basf2_helper import Basf2PathTask, Basf2nTupleMergeTask
4
5import json
6import basf2 as b2
7import modularAnalysis as ma
8import vertex as vx
9
10from skim import BatchesToTextFile
11
12
13class ReconstructBatch(Basf2PathTask):
14 queue = "s"
15 looper = luigi.IntParameter()
16 projectName = luigi.Parameter()
17 skim = luigi.Parameter(hashed=True)
18 runningOnMC = luigi.BoolParameter()
19
20 def requires(self):
21 yield BatchesToTextFile(
22 runningOnMC=self.runningOnMC, projectName=self.projectName, skim=self.skim
23 )
24
25 def output(self):
26 yield self.add_to_output("reco.root")
27
28 def create_path(self):
29
30 mypath = b2.create_path()
31 with open(self.get_input_file_names()[f"batch{self.looper}.json"][0]) as f:
32 inputMdstList = json.load(f)
33
34 ma.inputMdstList(filelist=inputMdstList, path=mypath)
35
36 ma.fillParticleList(
37 decayString='K+:my',
38 cut="dr < 0.5 and abs(dz) < 3 and thetaInCDCAcceptance and kaonID > 0.01",
39 path=mypath)
40 ma.fillParticleList(decayString='pi+:my', cut="dr < 0.5 and abs(dz) < 3 and thetaInCDCAcceptance", path=mypath)
41
42 ma.reconstructDecay(decayString="D-:K2Pi -> K+:my pi-:my pi-:my", cut="1.844 < M < 1.894", path=mypath)
43
44 ma.reconstructDecay(decayString='B0:PiD-toK2Pi -> D-:K2Pi pi+:my', cut='5.0 < Mbc and abs(deltaE) < 1.0', path=mypath)
45 vx.treeFit('B0:PiD-toK2Pi', 0, path=mypath, updateAllDaughters=False, ipConstraint=True, massConstraint=[411])
46
47 if(self.runningOnMC):
48 ma.matchMCTruth(list_name='B0:PiD-toK2Pi', path=mypath)
49
50 some_variables = ['Mbc', 'deltaE']
51 ma.variablesToNtuple(decayString='B0:PiD-toK2Pi', variables=some_variables,
52 filename=self.get_output_file_name("reco.root"), path=mypath, treename='BtoPiDtoKPiPi')
53 return mypath
54
55
56class ReconstructionWrapper(Basf2nTupleMergeTask):
57 batch_system = 'local'
58 projectName = luigi.Parameter()
59 skim = luigi.Parameter(hashed=True)
60
61 def requires(self):
62 for looper in range(BatchesToTextFile.NumBatches):
63 yield self.clone(ReconstructBatch, runningOnMC=True,
64 looper=looper, projectName=self.projectName, skim=self.skim)
65# @endcond
Definition: output.py:1