Skip to content
Snippets Groups Projects
Jonas Eppelt's avatar
Jonas Eppelt authored
56162648
History
Name Last commit Last update
bb2etp
README.md
beambackgrounds.json
pyproject.toml

BB2ETP

Beam Background to ETP aka ETPackground

Just a YAML and some conviniece functions, to manage multiple beambackgrounds for different purposes at the ETP. The YAML maps beambackgroundfiles to different locations and adds some metadata.

Installation

  1. Clone the repository.
  2. Set the BEAMBACKGROUND_JSON enviroment variable. For ETP this is /work/jeppelt/etpackground/beambackgrounds.json
    • If you are not running at ETP, you are responsible to keep the JSON file up to date.

Usage

A single package of beambackgrounds

import basf2 as b2
import simulation as si
import os 
os.environ["BEAMBACKGROUND_JSON"] = "/work/jeppelt/etpackground/beambackgrounds.json"
from bb2etp import *

bbs = get_beam_background_by_key("26_898") #, get_beam_background_by_key("26_1485")]

for gt in bbs.global_tags:
    print(gt)
    b2.conditions.append_globaltag(gt)

path = b2.Path()

path.add_module('EventInfoSetter',
                evtNumList= [10],
                expList=bbs.expList,
                runList=bbs.run
)

si.add_simulation(path,
                  bkgfiles=bbs.get_file_list("ceph")
)

path.add_module("Progress")
b2.process(path)

Running in different places

Currently files can be read from these three locations:

  • KEKCC (only if on KEKCC), use kek keyword
  • Ceph@ETP (only if on ETP), use ceph keyword
  • ETP Belle2 Storage @ GridKA (only if X509_USER_PROXY is set), use gridka keyword

Example

Python:

beambackgrounds = get_beam_background_by_key("experiment22_run30")
add_simulation(basf2_path, bkgfiles=beambackgrouns.gridka_file_list)

Editing the JSON file

To update entries in the json file or add new entries, you simply create a BeambackgroundMetadata instance with the desired values. Then call its update_json_entry function. Be aware, that this will update the JSON file for everybody, so update with care. If you want to have a special version of a certain entry, create a new entry by setting the key property.