Belle II Software development
070_fei.py
1#!/usr/bin/env python3
2
3import sys
4import basf2 as b2
5import fei
6import modularAnalysis as ma
7from variables import variables as vm
8
9# get input file number from the command line
10filenumber = sys.argv[1]
11
12# create path
13main = b2.Path()
14
15# load input data from mdst/udst file
16ma.inputMdst(
17 filename=b2.find_file(f"starterkit/2021/1111540100_eph3_BGx0_{filenumber}.root", "examples"),
18 path=main,
19) # [E13]
20
21# Add the database with the classifier weight files for the FEI [S23]
22b2.conditions.prepend_globaltag(ma.getAnalysisGlobaltag()) # [E23]
23
24# Get FEI default channels. [S10]
25# Utilise the arguments to toggle on and off certain channels
26particles = fei.get_default_channels(
27 chargedB=True,
28 neutralB=False,
29 hadronic=True,
30 semileptonic=False,
31 baryonic=True,
32) # [E10]
33# Set up FEI configuration specifying the FEI prefix [S20]
34configuration = fei.FeiConfiguration(
35 prefix="FEIv4_2021_MC14_release_05_01_12", monitor=False
36) # [E20]
37
38# Get FEI path [S30]
39feistate = fei.get_path(particles, configuration)
40
41# Add FEI path to the path to be processed
42main.add_path(feistate.path) # [E30]
43
44# Add MC matching when applying to MC. [S40]
45# This is required for variables like isSignal and mcErrors below
46ma.matchMCTruth(list_name="B+:generic", path=main) # [E40]
47
48# Rank B+ candidates by signal classifier output [S50]
49ma.rankByHighest(
50 particleList="B+:generic",
51 variable="extraInfo(SignalProbability)",
52 outputVariable="FEIProbabilityRank",
53 path=main,
54)
55vm.addAlias("FEIProbRank", "extraInfo(FEIProbabilityRank)")
56
57vm.addAlias("SigProb", "extraInfo(SignalProbability)") # [S41]
58vm.addAlias("decayModeID", "extraInfo(decayModeID)")
59
60# Store tag-side variables of interest.
61ma.variablesToNtuple(
62 "B+:generic",
63 [
64 "Mbc",
65 "deltaE",
66 "mcErrors",
67 "SigProb",
68 "decayModeID",
69 "FEIProbRank",
70 "isSignal",
71 ],
72 filename="B_charged_hadronic.root",
73 path=main,
74)
75# [E41|E50]
76# Process events
77b2.process(main)
78print(b2.statistics)