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