The simulation library of the Belle II software system

SuperKEKB, the next generation B factory, has been constructed in Japan as an upgrade of KEKB. This brand new e+ e- collider is expected to deliver a very large data set for the Belle II experiment, which will be 50 times larger than the previous Belle sample. Both the triggered physics event rate and the background event rate will be increased by at least 10 times than the previous ones, and will create a challenging data taking environment for the Belle II detector. The software system of the Belle II experiment is designed to execute this ambitious plan. A full detector simulation library, which is a part of the Belle II software system, is created based on Geant4 and has been tested thoroughly. Recently the library has been upgraded with Geant4 version 10.1. The library is behaving as expected and it is utilized actively in producing Monte Carlo data sets for various studies. In this paper, we will explain the structure of the simulation library and the various interfaces to other packages including geometry and beam background simulation.


The Belle II detector
The SuperKEKB collider, which has been commissioned in 2016, provides a 7 GeV e beam and a 4 GeV e+ beam for the Belle II detector, which is being upgraded from the Belle detector. The overall size of the Belle II detector is about 7.5 m long and 7 m high [1].
At the interaction point, the diameter of the Beryllium beam pipe (IR) was reduced to 2 cm. A new vertex detector consisting of a 2-layer pixel detector (PXD) and a 4-layer of double-sided silicon detector (SVD) is being constructed. The central drift chamber (CDC) has been upgraded with small cells for the inner part, longer lever arm and fast electronics. These detectors are used to discover tracks of charged particles [1].
Just outside of the drift chamber, a time-of-propagation counter (TOP) is constructed for the barrel region and an aerogel ring Cerenkov detector (ARICH) is built for the forward endcap region. The original electromagnetic calorimeter (ECL) of the Belle detector has been refitted with a waveform sampling readout system and placed outside of these counters. The CsI(Tl) crystals from the Belle calorimeter are reused. There is a plan to upgrade the endcap regions of the calorimeter with pure CsI crystals. The outermost component (KLM) of the Belle II detector is used for the identification of K L and muon particles. Originally constructed with resistive plate counters, the inner two barrel layers and the components for the endcap regions are replaced with scintillators [1].

The basic structure of the Belle II software system
The Belle II software system is a framework named basf2 [2], capable of parallel processing [3]. The core part of the system is written in C++ and the job scripts are described by Python [4]. Each event is executed on a path, i.e., a chain of modules for specific tasks selected by users. The task itself could be as simple as printing out statistics or could be a complicated one such as reconstruction of an event. I/O for data objects are handled by ROOT [5] and the persistent data storage (DataStore) used by basf2 is in the ROOT format. Many ideas from the original Belle software system [6], the ILC framework, and other experiments are incorporated to construct basf2. The simulation package is based on the Geant4 software [7]. Figure 1 shows a typical basf2 execution in the framework aspect. Figure 2 is an example of a basf2 job script. Figure 1. An example of a basf2 job consists of user selected modules. Event data objects are kept in memory during the processing of the event (DataStore), and all or parts of these objects can be written to a persistent storage in the ROOT format. This is a variation of a version shown in [2].

3-D magnetic field in basf2
The main component of the magnetic field inside the Belle II detector is a 1.5 T solenoid. Outside of it is an iron yoke, intertwined with the outermost sub-detector, KLM. In addition, the beam-focusing system of the SuperKEKB collider, mostly quadrupole magnets, is modifying the field value. The yokes and shields around the quadrupole magnets create non-linearity in the magnetic field [1]. To exploit the Belle II detector to its full potential, an understanding of the magnetic field with a precision of 0.1% is necessary. Recently, a dedicated study of the magnetic field has been conducted with a simulation model based on the OPERA3D/Tosca software [8]. In-situ measurements of the magnetic field were executed in September 2015. The results from these studies are utilized to create a 3-D magnetic field map, which is implemented in basf2 [9]. More simulation studies and in-situ measurements are planned to improve the precision of the magnetic field map.

Handling of geometry
For the offline software library, the geometry of the Belle II detector is implemented by C++ codes and created during the Geant4 simulation in a basf2 path [1]. The input parameters for the geometry are stored in an XML repository file. We are developing a database scheme to replace the repository file. Both the created geometry and the XML repository are accessible to other modules further downstream in the basf2 path, such as simulation, reconstruction, track extrapolation, etc. Figure 3 shows this process in detail.
In addition of the nominal geometry, we are developing strategies to fill the gaps between the simulated geometry and the real detector geometry. The displacement library represents the design values and the constructed detector, in the run-independent aspects. The run-dependent aspects are covered by the alignment schemes. Finally, if necessary, run-dependent differences will be implemented in the simulation library as mis-alignment.

Figure 2.
To the left is an example of a basf2 job steering script in Python. To the right is the script for the simulation packages of basf2. This is an update of the version shown in [2].

Mixing of beam background hits
With much more intense luminosity created by SuperKEKB, we expect the level of beam background will be much higher in the Belle II detector. It's important to emulate the effects of this background in simulation precisely, which will definitely affect the performance of the Belle II detector. We approach the subject with two different strategies: the background mixing method and the background overlay method [9]. The first one uses a separate background simulation while the second one uses real data events. Figure 4 shows the position of these two methods in a basf2 path.
The background mixing method is built on the assumption that the majority of the beam background effects could be emulated by simulated beam background events. We also use Geant4 to simulate of background events, and steps of each particle trajectory created inside the Belle II detector are stored in a file. Then this file is used to mix the steps from the background events with the steps from a physics event. Next, the mixed sample is sent to the digitization module in basf2 for further processing.
The background overlay method uses random trigger events to create a background event sample. Then the sample is mixed with a physics event during the digitization process. Even the noise from the detector electronics can be included in this way. However, some background properties may be lost due the threshold effects. SimHits are steps of a trajectory generated during the execution of Geant4. At the following stage, the mixed set of SimHits is sent for digitization. The digitized output is called Digits. With option 2, data obtained from random trigger events are mixed at the digitization level.

Validation tools
The development version of basf2 is updated continuously. To ensure accuracy and stability of library, a set of validation tools is executed after the daily build-up of the development version. The most recent versions of daily build-up are compared with the references including release and monthly versions of basf2 library [10].
For the core of the simulation package, a set of basic parameters are checked in histograms:  Number of particles such as leptons, stable mesons, and stable baryons.  Energy and vertex distributions of electrons and photons.  Energy and vertex distributions of secondary atoms or their fragments. (The number of these secondary particles is very small, though.)  Energy spectrums of muons, stable mesons, and stable baryons. Figure 5 shows an example histogram from this package. We found that this set of simulation histograms is very sensitive to changes in the detector geometry, which makes it a very good indicator for changes in geometry. In addition to this, the generator group and each sub-detector group also maintains a set of histograms to check the modules used for simulation.

Summary
The nominal geometry of the Belle II detector has been implemented in basf2. Currently we are implementing the displacement geometry, which describes the differences between the design values and the actual construction. For the sub-detectors, we are also developing run-dependent alignment tools, which are separate from the displacement geometry.
The core part of the simulation library, the FullSim module, has been upgraded Geant4 from version 9.6.2 to version 10.1.2. The upgrade activities were completed without big incidents. Comparisons between two versions show that they behave quite similar except minor differences. One notable difference was that the amount of the neutrons in the beam background simulation samples based on Touscheck, radiative Bhabha and Coulomb interactions was decreased by 25%. The physics list input used for the FullSim module is FTFP_BERT, which is provided by the Geant4 group for the collider experiments.

Future plan
Currently the geometry parameters are stored in an XML repository file. This repository will be replaced by a Database. The simulation of the magnetic field will be further refined to reach a precision of 0.1%. For this, additional in-situ measurements and simulation studies are planned. Several strategies are in development to use the cosmic and Phase 2 data to validate and monitor the simulation.
There is also a plan to pursue the option of a fast simulation library in place of Geant4. However, the scale of the calorimeters of the Belle II detector is smaller compared to those of the LHC experiments, which translates into relatively lighter usage of computing resources by the Belle II calorimeters.