12from ROOT
import Belle2
17Example script showing how to train neural networks
18to be used with the CDCTriggerNeuroModule.
20This script uses realistic values for the amount of training data
21and the number of runs, so it will run a long time.
29basf2.set_random_seed(1)
36mlpname =
'NeuroTrigger.root'
37trainname =
'NeuroTriggerTraindata.root'
38logname =
'NeuroTriggerLog'
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]}
59bkgdir =
'/sw/belle2/bkg.mixing/'
66main = basf2.create_path()
70main.add_module(
'EventInfoSetter', evtNumList=1000000000)
71main.add_module(
'Progress')
72main.add_module(
'Gearbox')
73main.add_module(
'Geometry', components=[
'BeamPipe',
'Cryostat',
75 'MagneticFieldConstant4LimitedRCDC'])
76particlegun = basf2.register_module(
'ParticleGun')
77particlegun.param(particlegun_params)
78main.add_module(particlegun)
79main.add_module(
'FullSim')
81 main.add_module(
'BeamBkgMixer',
82 backgroundFiles=glob.glob(os.path.join(bkgdir,
'*usual*.root')),
84main.add_module(
'CDCDigitizer')
91main.add_module(
'CDCTriggerTSF',
94main.add_module(
'CDCTrigger2DFinder')
97main.add_module(
'CDCTriggerETF', trueEventTime=
True)
106main.add_module(
'CDCTriggerMCMatcher', minAxial=4, axialOnly=
True,
107 relateClonesAndMerged=
False,
108 TrgTrackCollectionName=
'TRGCDC2DFinderTracks')
110main.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,
166basf2.logging.set_info(basf2.LogLevel.DEBUG, basf2.LogInfo.LEVEL | basf2.LogInfo.MESSAGE)
173print(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...