Belle II Software prerelease-11-00-00a
testTOPBackSplashTiming.py
1#!/usr/bin/env python3
2
3
10
11# ---------------------------------------------------------------------------------
12# Example steering script that generates anti-neutron events with fixed momentum
13# and applies the TOPBackSplashTiming module
14# ---------------------------------------------------------------------------------
15
16import basf2 as b2
17import simulation as si
18import reconstruction as re
19import argparse
20import mdst
21
22parser = argparse.ArgumentParser(description="Generates nbar events and save TOP timing fits to neutral clusters")
23parser.add_argument('--mom', default=1, help='Momentum of nbars to generate [GeV/c]')
24parser.add_argument('--saveFits', action='store_true', default=False, help='Flag to save plots of RooFits')
25parser.add_argument('--minClusterE', type=float, default=0.5, help='Minimum (incl.) clusterE to be considered for timing')
26parser.add_argument('--minNphotons', type=int, default=2, help='Minimum (incl.) no. of Cherenkov photons for fit')
27parser.add_argument('--minClusterNHits', type=float, default=1, help='Minimum (incl.) no. of crystals in cluster required')
28parser.add_argument('--includeSlotsWithTracks', action='store_true', default=False, help='Flag to save plots of RooFits')
29parser.add_argument('--saveMoreFitParams', action='store_true', default=False,
30 help='Development flag to save more RooFit params (e.g. RooFit errors, fit params)')
31
32args = parser.parse_args()
33
34path = b2.create_path()
35
36path.add_module("EventInfoSetter", evtNumList=100)
37path.add_module("EventInfoPrinter")
38
39# control muon - needed to set event T0
40path.add_module(
41 "ParticleGun",
42 pdgCodes=[13],
43 nTracks=0,
44 momentumGeneration="fixed",
45 momentumParams=[1],
46 thetaGeneration="fixed",
47 thetaParams=[92],
48 phiGeneration="fixed",
49 phiParams=[11.25], # initial momentum towards slot1
50 vertexGeneration="fixed",
51 xVertexParams=[0],
52 yVertexParams=[0],
53 zVertexParams=[0],
54 independentVertices=False,
55).set_name("MuonGun")
56
57# nbar
58path.add_module(
59 "ParticleGun",
60 pdgCodes=[-2112], # anti-n0
61 nTracks=0,
62 momentumGeneration="fixed",
63 momentumParams=[float(args.mom)],
64 thetaGeneration="uniform",
65 thetaParams=[0, 180],
66 phiGeneration="uniform",
67 phiParams=[0, 360],
68 vertexGeneration="fixed",
69 xVertexParams=[0],
70 yVertexParams=[0],
71 zVertexParams=[0],
72 independentVertices=False,
73).set_name("AntiNeutronGun")
74
75# detector and L1 trigger simulation and reco
76si.add_simulation(path=path)
77re.add_reconstruction(path=path)
78
79# call module and plot timing fits
80path.add_module("TOPBackSplashTiming",
81 saveFits=args.saveFits,
82 minClusterE=args.minClusterE,
83 minNphotons=args.minNphotons,
84 minClusterNHits=args.minClusterNHits,
85 includeSlotsWithTracks=args.includeSlotsWithTracks,
86 saveMoreFitParams=args.saveMoreFitParams,
87 )
88
89# Save mdst with timing, no. of fitted photons and chi-2/dof
90mdst.add_mdst_output(path, mc=True, additionalBranches=['TOPBackSplashFitResults'])
91
92path.add_module("Progress")
93
94b2.process(path, calculateStatistics=True)
95
96# show call statistics
97print(b2.statistics)
add_mdst_output(path, mc=True, filename='mdst.root', additionalBranches=[], dataDescription=None)
Definition mdst.py:37