Belle II Software  release-06-01-15
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  environmentType="default",
18  filename=b2.find_file(f"starterkit/2021/1111540100_eph3_BGx0_{filenumber}.root", "examples"),
19  path=main,
20 )
21 
22 # Add the database with the classifier weight files for the FEI
23 b2.conditions.prepend_globaltag(ma.getAnalysisGlobaltag())
24 
25 # Get FEI default channels.
26 # Utilise the arguments to toggle on and off certain channels
27 particles = fei.get_default_channels(
28  chargedB=True,
29  neutralB=False,
30  hadronic=True,
31  semileptonic=False,
32  baryonic=True,
33 )
34 
35 # Set up FEI configuration specifying the FEI prefix
36 configuration = fei.FeiConfiguration(
37  prefix="FEIv4_2021_MC14_release_05_01_12", monitor=False
38 )
39 
40 # Get FEI path
41 feistate = fei.get_path(particles, configuration)
42 
43 # Add FEI path to the path to be processed
44 main.add_path(feistate.path)
45 
46 # Add MC matching when applying to MC.
47 # This is required for variables like isSignal and mcErrors below
48 ma.matchMCTruth(list_name="B+:generic", path=main)
49 
50 # Rank B+ candidates by signal classifier output
51 ma.rankByHighest(
52  particleList="B+:generic",
53  variable="extraInfo(SignalProbability)",
54  outputVariable="FEIProbabilityRank",
55  path=main,
56 )
57 vm.addAlias("FEIProbRank", "extraInfo(FEIProbabilityRank)")
58 
59 vm.addAlias("SigProb", "extraInfo(SignalProbability)")
60 vm.addAlias("decayModeID", "extraInfo(decayModeID)")
61 
62 # Store tag-side variables of interest.
63 ma.variablesToNtuple(
64  "B+:generic",
65  [
66  "Mbc",
67  "deltaE",
68  "mcErrors",
69  "SigProb",
70  "decayModeID",
71  "FEIProbRank",
72  "isSignal",
73  ],
74  filename="B_charged_hadronic.root",
75  path=main,
76 )
77 
78 # Process events
79 b2.process(main)
80 print(b2.statistics)