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