#!/usr/bin/env python
# -*- coding: utf-8 -*-
from basf2 import B2INFO
from cdctrigger import add_cdc_trigger
from ecltrigger import add_ecl_trigger
from klmtrigger import add_klm_trigger
from grltrigger import add_grl_trigger
from gdltrigger import add_gdl_trigger
from effCalculation import EffCalculation
[docs]def add_tsim(
path,
SimulationMode=1,
shortTracks=False,
OpenFilter=False,
Belle2Phase="Phase3",
PrintResult=False,
component=["CDC", "ECL", "KLM", "GRL", "GDL"],
PrintInfo=False):
"""
add the gdl module to path
@param path module is added to this path
@param SimulationMode the simulation mode in TSIM, 1: fast simulation,
trigger algoritm simulation only, no firmware simulation
2: full simulation, both trigger algorithm and firmware
are simulated
@param minHits the minimum number of CDC super layers with hits, the default values is 4
@param OpenFilter if OpenFilter is True, the events failed to pass L1 trigger
will be discarded. Make sure you do need open filter before you
set the value to True
@param Belle2Phase the trigger menu at the phase is applied. Option: Phase2, Phase3
@param component list of sub-trigger components to be included in simulation
"""
if ("CDC" in component):
add_cdc_trigger(path=path, SimulationMode=SimulationMode, shortTracks=shortTracks, thetaDef='avg', zDef='min')
if ("ECL" in component):
add_ecl_trigger(path)
if ("KLM" in component):
add_klm_trigger(path)
if ("GRL" in component):
add_grl_trigger(path, SimulationMode)
if ("GDL" in component):
add_gdl_trigger(path=path, SimulationMode=SimulationMode, OpenFilter=OpenFilter, Belle2Phase=Belle2Phase)
if PrintResult:
EffCalculation(path, Belle2Phase=Belle2Phase)
path.add_module('StatisticsSummary').set_name('Sum_TriggerSimulation')
if PrintInfo:
B2INFO('The L1 trigger simulation (TSIM) is set up with the following configuration:',
SimulationMode=SimulationMode,
ShortTracks=shortTracks,
OpenFilter=OpenFilter,
Belle2Phase=Belle2Phase,
Components=', '.join(component))
[docs]def add_subdetector_tsim(
path,
SimulationMode=1,
shortTracks=False,
OpenFilter=False,
Belle2Phase="Phase3",
component=[
"CDC",
"ECL",
"KLM"]):
"""
add the trigger simlation of subdetector, no grl and gdl
the parameters are the same as above
"""
if ("CDC" in component):
add_cdc_trigger(path=path, SimulationMode=SimulationMode, shortTracks=shortTracks)
if ("ECL" in component):
add_ecl_trigger(path=path)
if ("KLM" in component):
add_klm_trigger(path=path)
[docs]def add_grl_gdl_tsim(path, SimulationMode=1, OpenFilter=False, Belle2Phase="Phase3", PrintResult=False):
"""
add grl and gdl, the function have to applied based on the
dataobjects produced in add_subdetector_trigger_simulation
the parameters are the same as above
"""
add_grl_trigger(path, SimulationMode)
add_gdl_trigger(path, SimulationMode, OpenFilter, Belle2Phase)
if PrintResult:
EffCalculation(path, Belle2Phase=Belle2Phase)