Belle II Software  release-08-01-10
070_fei.py
1 #!/usr/bin/env python3
2 
3 import sys
4 import basf2 as b2
5 import fei
6 import modularAnalysis as ma
7 from variables import variables as vm
8 
9 # get input file number from the command line
10 filenumber = sys.argv[1]
11 
12 # create path
13 main = b2.Path()
14 
15 # load input data from mdst/udst file
16 ma.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]
22 b2.conditions.prepend_globaltag(ma.getAnalysisGlobaltag()) # [E23]
23 
24 # Get FEI default channels. [S10]
25 # Utilise the arguments to toggle on and off certain channels
26 particles = 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]
34 configuration = fei.FeiConfiguration(
35  prefix="FEIv4_2021_MC14_release_05_01_12", monitor=False
36 ) # [E20]
37 
38 # Get FEI path [S30]
39 feistate = fei.get_path(particles, configuration)
40 
41 # Add FEI path to the path to be processed
42 main.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
46 ma.matchMCTruth(list_name="B+:generic", path=main) # [E40]
47 
48 # Rank B+ candidates by signal classifier output [S50]
49 ma.rankByHighest(
50  particleList="B+:generic",
51  variable="extraInfo(SignalProbability)",
52  outputVariable="FEIProbabilityRank",
53  path=main,
54 )
55 vm.addAlias("FEIProbRank", "extraInfo(FEIProbabilityRank)")
56 
57 vm.addAlias("SigProb", "extraInfo(SignalProbability)") # [S41]
58 vm.addAlias("decayModeID", "extraInfo(decayModeID)")
59 
60 # Store tag-side variables of interest.
61 ma.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
77 b2.process(main)
78 print(b2.statistics)