12 from ROOT
import Belle2
17 Example script showing how to train neural networks
18 to be used with the CDCTriggerNeuroModule.
20 This script uses realistic values for the amount of training data
21 and the number of runs, so it will run a long time.
29 basf2.set_random_seed(1)
36 mlpname =
'NeuroTrigger.root'
37 trainname =
'NeuroTriggerTraindata.root'
38 logname =
'NeuroTriggerLog'
44 particlegun_params = {
45 'pdgCodes': [-13, 13],
47 'momentumGeneration':
'inversePt',
48 'momentumParams': [0.3, 10.],
49 'thetaGeneration':
'uniformCos',
50 'thetaParams': [23, 144],
51 'phiGeneration':
'uniform',
52 'phiParams': [0, 360],
53 'vertexGeneration':
'uniform',
54 'xVertexParams': [0, 0.0],
55 'yVertexParams': [0, 0.0],
56 'zVertexParams': [-50.0, 50.0]}
59 bkgdir =
'/sw/belle2/bkg.mixing/'
66 main = basf2.create_path()
70 main.add_module(
'EventInfoSetter', evtNumList=1000000000)
71 main.add_module(
'Progress')
72 main.add_module(
'Gearbox')
73 main.add_module(
'Geometry', components=[
'BeamPipe',
'Cryostat',
75 'MagneticFieldConstant4LimitedRCDC'])
76 particlegun = basf2.register_module(
'ParticleGun')
77 particlegun.param(particlegun_params)
78 main.add_module(particlegun)
79 main.add_module(
'FullSim')
81 main.add_module(
'BeamBkgMixer',
82 backgroundFiles=glob.glob(os.path.join(bkgdir,
'*usual*.root')),
84 main.add_module(
'CDCDigitizer')
91 main.add_module(
'CDCTriggerTSF',
94 main.add_module(
'CDCTrigger2DFinder')
97 main.add_module(
'CDCTriggerETF', trueEventTime=
True)
106 main.add_module(
'CDCTriggerMCMatcher', minAxial=4, axialOnly=
True,
107 relateClonesAndMerged=
False,
108 TrgTrackCollectionName=
'TRGCDC2DFinderTracks')
110 main.add_module(
'CDCTriggerNeuroTrainer',
112 inputCollectionName=
'TRGCDC2DFinderTracks',
113 targetCollectionName=
'MCParticles',
114 trainOnRecoTracks=
False,
116 filename=os.path.join(mlpdir, mlpname),
117 trainFilename=os.path.join(traindir, trainname),
118 logFilename=os.path.join(logdir, logname),
122 SLpatternMask=[int(
'010101010', 2)],
123 SLpattern=[int(
'111111111', 2),
127 int(
'111111101', 2)],
129 invptRange=[[-5., 5.]],
130 phiRange=[[0., 360.]],
131 thetaRange=[[0., 180.]],
132 selectSectorByMC=
False,
133 invptRangeTrain=[[-5., 5.]],
134 phiRangeTrain=[[0., 360.]],
135 thetaRangeTrain=[[0., 180.]],
137 multiplyHidden=
False,
143 outputScale=[[-50., 50., 0., 180.]],
163 logLevel=basf2.LogLevel.DEBUG,
166 basf2.logging.set_info(basf2.LogLevel.DEBUG, basf2.LogInfo.LEVEL | basf2.LogInfo.MESSAGE)
173 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...