Belle II Software  release-05-01-25
L1trigger.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 from basf2 import B2INFO
5 from cdctrigger import add_cdc_trigger
6 from ecltrigger import add_ecl_trigger
7 from klmtrigger import add_klm_trigger
8 from grltrigger import add_grl_trigger
9 from gdltrigger import add_gdl_trigger
10 from effCalculation import EffCalculation
11 
12 
13 def add_tsim(
14  path,
15  SimulationMode=1,
16  shortTracks=False,
17  OpenFilter=False,
18  Belle2Phase="Phase3",
19  PrintResult=False,
20  component=["CDC", "ECL", "KLM", "GRL", "GDL"],
21  PrintInfo=False):
22  """
23  add the gdl module to path
24  @param path module is added to this path
25  @param SimulationMode the simulation mode in TSIM, 1: fast simulation,
26  trigger algoritm simulation only, no firmware simulation
27  2: full simulation, both trigger algorithm and firmware
28  are simulated
29  @param minHits the minimum number of CDC super layers with hits, the default values is 4
30  @param OpenFilter if OpenFilter is True, the events failed to pass L1 trigger
31  will be discarded. Make sure you do need open filter before you
32  set the value to True
33  @param Belle2Phase the trigger menu at the phase is applied. Option: Phase2, Phase3
34  @param component list of sub-trigger components to be included in simulation
35  """
36  if ("CDC" in component):
37  add_cdc_trigger(path=path, SimulationMode=SimulationMode, shortTracks=shortTracks, thetaDef='avg', zDef='min')
38  if ("ECL" in component):
39  add_ecl_trigger(path)
40  if ("KLM" in component):
41  add_klm_trigger(path)
42  if ("GRL" in component):
43  add_grl_trigger(path, SimulationMode)
44  if ("GDL" in component):
45  add_gdl_trigger(path=path, SimulationMode=SimulationMode, OpenFilter=OpenFilter, Belle2Phase=Belle2Phase)
46  if PrintResult:
47  EffCalculation(path, Belle2Phase=Belle2Phase)
48  path.add_module('StatisticsSummary').set_name('Sum_TriggerSimulation')
49  if PrintInfo:
50  B2INFO('The L1 trigger simulation (TSIM) is set up with the following configuration:',
51  SimulationMode=SimulationMode,
52  ShortTracks=shortTracks,
53  OpenFilter=OpenFilter,
54  Belle2Phase=Belle2Phase,
55  Components=', '.join(component))
56 
57 
58 def add_subdetector_tsim(
59  path,
60  SimulationMode=1,
61  shortTracks=False,
62  OpenFilter=False,
63  Belle2Phase="Phase3",
64  component=[
65  "CDC",
66  "ECL",
67  "KLM"]):
68  """
69  add the trigger simlation of subdetector, no grl and gdl
70  the parameters are the same as above
71  """
72  if ("CDC" in component):
73  add_cdc_trigger(path=path, SimulationMode=SimulationMode, shortTracks=shortTracks)
74  if ("ECL" in component):
75  add_ecl_trigger(path=path)
76  if ("KLM" in component):
77  add_klm_trigger(path=path)
78 
79 
80 def add_grl_gdl_tsim(path, SimulationMode=1, OpenFilter=False, Belle2Phase="Phase3", PrintResult=False):
81  """
82  add grl and gdl, the function have to applied based on the
83  dataobjects produced in add_subdetector_trigger_simulation
84  the parameters are the same as above
85  """
86  add_grl_trigger(path, SimulationMode)
87  add_gdl_trigger(path, SimulationMode, OpenFilter, Belle2Phase)
88  if PrintResult:
89  EffCalculation(path, Belle2Phase=Belle2Phase)