Belle II Software development
L1trigger.py
1#!/usr/bin/env python
2
3
10
11from basf2 import B2INFO, B2FATAL
12from cdctrigger import add_cdc_trigger
13from ecltrigger import add_ecl_trigger
14from klmtrigger import add_klm_trigger
15from grltrigger import add_grl_trigger
16from gdltrigger import add_gdl_trigger
17
18
19def add_trigger_simulation(
20 path,
21 SimulationMode=1,
22 shortTracks=False,
23 FilterEvents=False,
24 Belle2Phase='Phase3',
25 components=['CDC', 'ECL', 'KLM', 'GRL', 'GDL'],
26 simulateT0jitter=False,
27 PrintInfo=False):
28 '''
29 Add the L1 trigger simulation (TSIM) modules to path.
30
31 @param path: Modules are added to this path.
32 @param SimulationMode: The simulation mode in TSIM: 1) fast simulation, trigger algoritm simulation only,
33 no firmware simulation; 2) full simulation, both trigger algorithm and firmware are simulated.
34 @param shortTracks: The standard CDC track finding requires hits in 4 axial super layers. With the shortTracks
35 option, tracks with hits in the 3 innermost super layers are also found.
36 @param FilterEvents: if True only the events that pass the L1 trigger will survive simulation, the other are discarded.
37 Make sure you do need to filter events before you set the value to True.
38 @param Belle2Phase: The trigger menu at the given Phase is applied. Available options: Phase2, Phase3.
39 @param components: List of sub-trigger components to be included in TSIM.
40 @param simulateT0jitter: if True L1 trigger jitter is simulated by EventT0Generator.
41 '''
42
43 add_subdetector_tsim(
44 path=path,
45 SimulationMode=SimulationMode,
46 shortTracks=shortTracks,
47 components=components)
48 add_grl_gdl_tsim(
49 path=path,
50 SimulationMode=SimulationMode,
51 FilterEvents=FilterEvents,
52 Belle2Phase=Belle2Phase,
53 simulateT0jitter=simulateT0jitter,
54 components=components)
55 if PrintInfo:
56 B2INFO('The L1 trigger simulation (TSIM) is set up with the following configuration:',
57 SimulationMode=SimulationMode,
58 ShortTracks=shortTracks,
59 FilterEvents=FilterEvents,
60 Belle2Phase=Belle2Phase,
61 Components=', '.join(components))
62
63
64def add_subdetector_tsim(
65 path,
66 SimulationMode=1,
67 shortTracks=False,
68 components=['CDC', 'ECL', 'KLM']):
69 '''
70 Add subdetector modules to the TSIM with no GRL and no GDL.
71
72 @param path: Modules are added to this path.
73 @param SimulationMode: The simulation mode in TSIM: 1) fast simulation, trigger algoritm simulation only,
74 no firmware simulation; 2) full simulation, both trigger algorithm and firmware are simulated.
75 @param shortTracks: The standard CDC track finding requires hits in 4 axial super layers. With the shortTracks
76 option, tracks with hits in the 3 innermost super layers are also found.
77 @param components: List of subdetector components to be included in TSIM.
78 '''
79
80 if ('CDC' in components):
81 add_cdc_trigger(path=path, SimulationMode=SimulationMode, shortTracks=shortTracks, thetaDef='avg', zDef='min')
82 if ('ECL' in components):
83 add_ecl_trigger(path=path)
84 if ('KLM' in components):
85 add_klm_trigger(path=path)
86
87
88def add_grl_gdl_tsim(
89 path,
90 SimulationMode=1,
91 FilterEvents=False,
92 Belle2Phase='Phase3',
93 simulateT0jitter=False,
94 components=['GRL', 'GDL']):
95 '''
96 Add GRL and GDL modules to the TSIM with no subdetectors. The function have to applied based on the dataobjects
97 produced by add_subdetector_tsim.
98
99 @param SimulationMode: The simulation mode in TSIM: 1) fast simulation, trigger algoritm simulation only,
100 no firmware simulation; 2) full simulation, both trigger algorithm and firmware are simulated.
101 @param FilterEvents: if True only the events that pass the L1 trigger will survive simulation, the other are discarded.
102 Make sure you do need to filter events before you set the value to True.
103 @param Belle2Phase: The trigger menu at the given Phase is applied. Available options: Phase2, Phase3.
104 @param simulateT0jitter: if True L1 trigger jitter is simulated by EventT0Generator.
105 @param components: List of logic components to be included in TSIM.
106 '''
107
108 if ('GRL' in components):
109 add_grl_trigger(path=path, SimulationMode=SimulationMode)
110 if ('GDL' in components):
111 add_gdl_trigger(
112 path=path,
113 SimulationMode=SimulationMode,
114 FilterEvents=FilterEvents,
115 Belle2Phase=Belle2Phase,
116 simulateT0jitter=simulateT0jitter)
117
118
119def add_tsim(
120 path,
121 SimulationMode=1,
122 shortTracks=False,
123 FilterEvents=False,
124 Belle2Phase='Phase3',
125 components=['CDC', 'ECL', 'KLM', 'GRL', 'GDL'],
126 PrintInfo=False):
127 '''
128 This convenience function is DEPRECATED!
129
130 The L1 trigger simulation (TSIM) is now included in ``add_simulation``.
131
132 If you already have a ``add_simulation`` in your path, you already get L1 trigger simulation.
133
134 If you do not have ``add_simulation``, and you need the L1 trigger simulation,\
135 please use ``add_trigger_simulation()``.
136
137 '''
138
139 B2FATAL("add_tsim() is deprecated. The L1 trigger simulation is now included\
140 in add_simulation(). If you do not have add_simulation in your path, and you\
141 need the L1 trigger simulation, please use add_trigger_simulation().")