11""" This script creates 10 events with 12 charged stable particles
12 per event, then extracts CNN value for each particle.
13 The CNN values represent probabilities
for a track being
20 basf2 EclCNNPID.py -- [--beam-bkg-dir <path_to_beam_bkg_files>]
26 In this example script Gearbox
and Geometry modules
27 are automatically registered
in add_simulation().
29 In order to use CNN_PID_ECL module
in your script,
30 it
is essential to add the following lines before
31 fillParticleList() function:
32 mainPath.add_module(
'Gearbox')
33 mainPath.add_module(
'Geometry')
41 parser = argparse.ArgumentParser()
47 help=
'Directory that contains beam background files')
52if __name__ ==
'__main__':
54 args = argparser().parse_args()
57 from ROOT
import Belle2
58 import modularAnalysis
as ma
59 from simulation
import add_simulation
60 from reconstruction
import add_reconstruction
61 from background
import get_background_files
62 from eclCNNPID
import CNN_PID_ECL
64 chargedStable_pdg_list = []
65 for idx
in range(len(Belle2.Const.chargedStableSet)):
66 particle = Belle2.Const.chargedStableSet.at(idx)
67 pdgId = particle.getPDGCode()
68 chargedStable_pdg_list.extend([pdgId, -pdgId])
71 b2.conditions.prepend_globaltag(
'cnn_pid_ecl')
74 mainPath = b2.create_path()
76 b2.set_log_level(b2.LogLevel.WARNING)
79 particleGun = b2.register_module(
'ParticleGun')
80 b2.set_random_seed(123)
82 'pdgCodes': chargedStable_pdg_list,
84 'momentumGeneration':
'uniformPt',
85 'momentumParams': [0.3, 0.9],
86 'thetaGeneration':
'uniform',
87 'thetaParams': [70, 90],
88 'phiGeneration':
'uniform',
89 'phiParams': [0, 360],
90 'xVertexParams': [0.0, 0.0],
91 'yVertexParams': [0.0, 0.0],
92 'zVertexParams': [0.0, 0.0],
94 particleGun.param(particleGun_param)
95 mainPath.add_module(particleGun)
103 if args.beam_bkg_dir:
107 bkgfiles=get_background_files(
108 folder=args.beam_bkg_dir
113 add_simulation(mainPath)
116 add_reconstruction(mainPath)
119 mainPath.add_module(
'ECLFillCellIdMapping')
122 mainPath.add_module(CNN_PID_ECL(path=mainPath))
124 name =
'pi+:particles'
125 ma.fillParticleList(name,
'', path=mainPath)
127 ma.variablesToNtuple(
129 variables=[
'cnn_pid_ecl_muon'],
130 treename=
'particles',
131 filename=
'test_chargedStable_particles_cnn_output.root',
135 mainPath.add_module(
'Progress')