12 """ This script creates 10 events with 12 charged stable particles
13 per event, then extracts CNN value for each particle.
14 The CNN values represent probabilities for a track being
21 basf2 EclCNNPID.py -- [--beam-bkg-dir <path_to_beam_bkg_files>]
27 In this example script Gearbox and Geometry modules
28 are automatically registered in add_simulation().
30 In order to use CNN_PID_ECL module in your script,
31 it is essential to add the following lines before
32 fillParticleList() function:
33 mainPath.add_module('Gearbox')
34 mainPath.add_module('Geometry')
42 parser = argparse.ArgumentParser()
48 help=
'Directory that contains beam background files')
53 if __name__ ==
'__main__':
55 args = argparser().parse_args()
58 from ROOT
import Belle2
59 import modularAnalysis
as ma
60 from simulation
import add_simulation
61 from reconstruction
import add_reconstruction
62 from background
import get_background_files
63 from eclCNNPID
import CNN_PID_ECL
65 chargedStable_pdg_list = []
66 for idx
in range(len(Belle2.Const.chargedStableSet)):
67 particle = Belle2.Const.chargedStableSet.at(idx)
68 pdgId = particle.getPDGCode()
69 chargedStable_pdg_list.extend([pdgId, -pdgId])
72 b2.conditions.prepend_globaltag(
'cnn_pid_ecl')
75 mainPath = b2.create_path()
77 b2.set_log_level(b2.LogLevel.WARNING)
80 particleGun = b2.register_module(
'ParticleGun')
81 b2.set_random_seed(123)
83 'pdgCodes': chargedStable_pdg_list,
85 'momentumGeneration':
'uniformPt',
86 'momentumParams': [0.3, 0.9],
87 'thetaGeneration':
'uniform',
88 'thetaParams': [70, 90],
89 'phiGeneration':
'uniform',
90 'phiParams': [0, 360],
91 'xVertexParams': [0.0, 0.0],
92 'yVertexParams': [0.0, 0.0],
93 'zVertexParams': [0.0, 0.0],
95 particleGun.param(particleGun_param)
96 mainPath.add_module(particleGun)
104 if args.beam_bkg_dir:
108 bkgfiles=get_background_files(
109 folder=args.beam_bkg_dir
114 add_simulation(mainPath)
117 add_reconstruction(mainPath)
120 mainPath.add_module(
'ECLFillCellIdMapping')
123 mainPath.add_module(CNN_PID_ECL(path=mainPath))
125 name =
'pi+:particles'
126 ma.fillParticleList(name,
'', path=mainPath)
128 ma.variablesToNtuple(
130 variables=[
'cnn_pid_ecl_muon'],
131 treename=
'particles',
132 filename=
'test_chargedStable_particles_cnn_output.root',
136 mainPath.add_module(
'Progress')