Belle II Software development
generateTrueLRTable.py
1#!/usr/bin/env python3
2
3
10
11import basf2
12import os
13import glob
14from ROOT import gROOT, Belle2
15import reconstruction
16import simulation
17
18gROOT.ProcessLine("gErrorIgnoreLevel = 4000;") # ignore endless root errors for background files...
19
20"""
21Run the Track Segment Finder and save a table of true left/right for each hit pattern.
22This table can be used to create the left/right LUT (see createTSLUT.py),
23or to evaluate it (see evaluateTSLUT.py).
24"""
25
26# ------------ #
27# user options #
28# ------------ #
29
30# general options
31seed = 1
32evtnum = 1000 # 00
33clock = False
34backgroundLevel = 0.
35bkgdir = '/remote/neurobelle/bkg/'
36particlegun_params = {
37 'pdgCodes': [-13, 13],
38 'nTracks': 1,
39 'momentumGeneration': 'inversePt',
40 'momentumParams': [0.27, 7.2], # no curling tracks
41 'thetaGeneration': 'uniformCos',
42 'thetaParams': [35, 123], # hit all super layers
43 'phiGeneration': 'uniform',
44 'phiParams': [0, 360],
45 'vertexGeneration': 'fixed',
46 'xVertexParams': [0.],
47 'yVertexParams': [0.],
48 'zVertexParams': [0.]}
49# filenames for the generates tables
50# including the seed in the filename allows to combine several runs later
51innerFilename = f'innerTrueLRTable_Bkg{backgroundLevel:.1f}_{int(seed)}.dat'
52outerFilename = f'outerTrueLRTable_Bkg{backgroundLevel:.1f}_{int(seed)}.dat'
53innerrecoFilename = f'innerRecoLRTable_Bkg{backgroundLevel:.1f}_{int(seed)}.dat'
54outerrecoFilename = f'outerRecoLRTable_Bkg{backgroundLevel:.1f}_{int(seed)}.dat'
55
56# ------------------------- #
57# create path up to trigger #
58# ------------------------- #
59
60# set random seed
61basf2.set_random_seed(seed)
62# suppress messages and warnings during processing:
63basf2.set_log_level(basf2.LogLevel.ERROR)
64
65main = basf2.create_path()
66
67main.add_module('EventInfoSetter', evtNumList=evtnum)
68main.add_module('Progress')
69main.add_module('Gearbox')
70main.add_module('Geometry') # , components=['CDC',
71# 'MagneticFieldConstant4LimitedRCDC'])
72particlegun = basf2.register_module('ParticleGun')
73particlegun.param(particlegun_params)
74main.add_module(particlegun)
76# main.add_module('FullSim')
77if backgroundLevel > 0:
78 bkgmixer = basf2.register_module('BeamBkgMixer')
79 bkgfiles = glob.glob(os.path.join(bkgdir, '*[!(PXD)(ECL)]??.root'))
80 bkgmixer.param('backgroundFiles', bkgfiles)
81 bkgmixer.param('components', ['CDC'])
82 bkgmixer.param('overallScaleFactor', backgroundLevel)
83 main.add_module(bkgmixer)
84cdcdigitizer = basf2.register_module('CDCDigitizer')
85if clock:
86 cdcdigitizer.param('TrigTimeJitter', 32.)
87main.add_module(cdcdigitizer)
89tsf = basf2.register_module('CDCTriggerTSF')
90tsf_params = {
91 'InnerTSLUTFile': Belle2.FileSystem.findFile("data/trg/cdc/innerLUT_v3.0.coe"),
92 'OuterTSLUTFile': Belle2.FileSystem.findFile("data/trg/cdc/outerLUT_v3.0.coe"),
93 'ClockSimulation': clock,
94 'makeTrueLRTable': True,
95 'makeRecoLRTable': True,
96 'innerTrueLRTableFilename': innerFilename,
97 'outerTrueLRTableFilename': outerFilename,
98 'innerRecoLRTableFilename': innerrecoFilename,
99 'outerRecoLRTableFilename': outerrecoFilename}
100tsf.param(tsf_params)
101if clock:
102 tsf.param('CDCHitCollectionName', 'CDCHits4Trg')
103main.add_module(tsf)
104
105# Process events
106basf2.process(main)
107
108# Print call statistics
109print(basf2.statistics)
static std::string findFile(const std::string &path, bool silent=false)
Search for given file or directory in local or central release directory, and return absolute path if...
Definition: FileSystem.cc:151
def add_reconstruction(path, components=None, pruneTracks=True, add_trigger_calculation=True, skipGeometryAdding=False, trackFitHypotheses=None, addClusterExpertModules=True, use_second_cdc_hits=False, add_muid_hits=False, reconstruct_cdst=None, event_abort=default_event_abort, use_random_numbers_for_hlt_prescale=True, pxd_filtering_offline=False, create_intercepts_for_pxd_ckf=False, append_full_grid_cdc_eventt0=True, legacy_ecl_charged_pid=False, emulate_HLT=False, skip_full_grid_cdc_eventt0_if_svd_time_present=True)
def add_simulation(path, components=None, bkgfiles=None, bkgOverlay=True, forceSetPXDDataReduction=False, usePXDDataReduction=True, cleanupPXDDataReduction=True, generate_2nd_cdc_hits=False, simulateT0jitter=True, isCosmics=False, FilterEvents=False, usePXDGatedMode=False, skipExperimentCheckForBG=False, save_slow_pions_in_mc=False)
Definition: simulation.py:126