25.4.4. Various additions

What is Bremsstrahlung radiation?

As you may guess from its unfriendly typing, “Bremsstrahlung” is a German word, literally meaning “braking radiation”; it is used to describe the electromagnetic radiation that particles emit when decelerating. You can read more about it in the many, many pages available on the Internet, starting with Wikipedia and the PDG review.

At Belle II, Bremsstrahlung radiation is emitted by particles when traversing the different detector components. As the largest material load is near the interaction region, most Bremsstrahlung radiation is expected to originate there. The total radiated power due to Bremsstrahlung by a particle of charge \(q\) moving at speed (in units of \(c\)) \(\beta\) is given by

\[P = \frac{q^2\gamma^6}{6\pi\varepsilon_0 c} \left( \left(\dot{\vec{\beta}}\right)^2 - \left(\vec{\beta} \times \dot{\vec{\beta}}\right)^2 \right)\]

where \(\gamma = \frac{1}{\sqrt{1-\beta^2}}\).

For cases where the acceleration is parallel to the velocity, the radiated power is proportional to \(\gamma^6\), whereas for perpendicular acceleration it scales with \(\gamma^4\). As \(\gamma = E/mc^2\), lighter particles will lose more energy through Bremsstrahlung than heavier particles with the same energy. At Belle II, we usually only consider Bremsstrahlung loses for electrons and positrons.

Exercise (optional)

From the general equation for radiated power, derive the explicit form for the limit cases of perpendicular and parallel acceleration (if you are attending the Starter Kit, you may want to try this later, so it doesn’t interfere with the flow of the lesson).

Hint

The case of parallel acceleration and velocity should be straightforward. For the perpendicular case, the next identity may be useful:

\[\left(\vec{\beta}\cdot \dot{\vec{\beta}}\right)^2 = \dot{\beta}^2\beta^2 - \left(\vec{\beta} \times \dot{\vec{\beta}}\right)^2\]

Solution

\[P_{a\parallel v} = \frac{q^2a^2\gamma^6}{6\pi\varepsilon_0c^3} \hspace{1cm} P_{a\bot v} = \frac{q^2a^2\gamma^4}{6\pi\varepsilon_0c^3}\]

A proper method that accounts for Bremsstrahlung loses is of utmost importance at B factories; at the end of this section, you will be able to obtain the invariant mass distribution for the \(J/\psi \to e^+e^-\) meson decay after correcting for the Bremsstrahlung radiation, and compare it with the distribution you obtained in the previous lesson.

How do we look for Bremsstrahlung photons

Though we will not discuss it here (but, if you are interested, you can consult this document), the radiated power for relativistic particles is maximum around the particle’s direction of motion; we thus expect Bremsstrahlung photons to be mostly emitted in a cone around the momentum vector of the electrons (and positrons). The procedures we use to perform Bremsstrahlung recovery are based on this assumption.

The Belle like recovery looks for photons on a single cone around the initial momentum of the particle; on the other side, the Belle II method uses multiple cones, centered around the momentum of the particle at the points along its path where it was more likely to emit Bremsstrahlung radiation. The Belle II method also performs a pre-processing of the data, and applies some initial cuts on the Bremsstrahlung photons and on the electrons which the user cannot undo. Although we recommend using the Belle II method, you should check which procedure works best for your analysis.

In order to perform Bremsstrahlung recovery (either with the Belle or the Belle II methods), you need first to construct two particle lists: the first one will have the particles whose energies you want to recover, and the second one will contain the Bremsstrahlung photons you will use to recover said energies. Making use of the steering file developed in the previous sections, we already have our first particle list ready: e+:uncorrected (the reason why this particle list was given this name is, well, because these positrons haven’t been Bremsstrahlung corrected yet!).

Next we will build up the list of possible Bremsstrahlung photons. In order to reduce the number of background clusters included, we first define a minimum cluster energy according to the region in the ECL the cluster is found.

Because this cut will be a bit complicated, we will define aliases for cuts. This actually works with the addAlias function as well, if we combine it with the passesCut function.

Exercise

How would you define the alias myCut for the cut E > 1 and p > 1?

Solution

You can use the passesCut function to turn a cut into a variable and assign an alias for it.

from variables import variables as vm
vm.addAlias("myCut", "passesCut(E > 1 and p > 1")

Exercise

Create a particle list, called gamma:brems, with photons following the next cuts:

  1. If the photons are in the forward endcap of the ECL, their energy should be at least 75 MeV

  2. If they are in the barrel region, their energy should be larger than 50 MeV

  3. Finally, if they are in the backward endcap, their energy should be larger than 100 MeV

To do this, you need the clusterReg and clusterE variable. To keep everything neat and tidy, we recommend that you define the aliases goodFWDGamma, goodBRLGamma and goodBWDGamma for the three cuts. Finally you can combine them to a goodGamma cut and use this to fill the particle list.

Hint

The cuts will look like this:

vm.addAlias(
    "goodXXXGamma", "passesCut(clusterReg == XXX and clusterE > XXX)"
)

where the XXX should be filled by you.

Another hint

This is the first one:

32# apply Bremsstrahlung correction to electrons
33vm.addAlias(
34    "goodFWDGamma", "passesCut(clusterReg == 1 and clusterE > 0.075)"
35)

Solution

32# apply Bremsstrahlung correction to electrons
33vm.addAlias(
34    "goodFWDGamma", "passesCut(clusterReg == 1 and clusterE > 0.075)"
35)
36vm.addAlias(
37    "goodBRLGamma", "passesCut(clusterReg == 2 and clusterE > 0.05)"
38)
39vm.addAlias(
40    "goodBWDGamma", "passesCut(clusterReg == 3 and clusterE > 0.1)"
41)
42vm.addAlias(
43    "goodGamma", "passesCut(goodFWDGamma or goodBRLGamma or goodBWDGamma)"
44)

Next, we perform the actual recovery, using the correctBrems function in the Modular Analysis package.

This step will create a new particle list; each particle in this list will have momentum given by the sum of the original, uncorrected particle momentum, and the momenta of all the Bremsstrahlung photons in the gamma:brems list that fall inside the cone(s) we mentioned previously. Each new particle will also have as daughters the original particle and its Bremsstrahlung photons (if any), and an extraInfo field named bremsCorrected that will indicate if at least one Bremsstrahlung photon was added to this particle.

Exercise

Perform Bremsstrahlung recovery on the e+:uncorrected list, using the correctBrems function and the gamma:brems photons. Create a new variable, called isBremsCorrected, that tells us if a particle has been Bremsstrahlung corrected

Solution

46ma.correctBrems("e+:corrected", "e+:uncorrected", "gamma:brems", path=main)
47vm.addAlias("isBremsCorrected", "extraInfo(bremsCorrected)")

Question

Assume that one particle in the e+:corrected particle list has isBremsCorrected equal to False. How many daughters does this particle have? What is the relation between the daughter(s) momenta and this particle momentum?

Solution

No Bremsstrahlung photons were found for this particle, so it only has one daughter, the original uncorrected one. Since there was no correction performed, the momentum of this particle will simply be the same as the momentum of its daughter.

Exercise

How would you use the Belle method for Bremsstrahlung recovery, instead of the Belle II one?

Hint

Take a look at the documentation: correctBremsBelle

Solution

ma.correctBremsBelle('e+:corrected', 'e+:uncorrected', 'gamma:brems', path=main)

Note that the Bremsstrahlung correction methods have multiple optional parameters. Make sure to read their documentation in order to be able to make the best use of these tools.

When working on MC data, a special note of caution is at place. In the simulation, Bremsstrahlung photons do not have an mcParticle associated to them; because of this, the usual MC matching procedure will give faulty results. In order to avoid this, when checking the MC truth of decays containing Bremsstrahlung corrected particles, you can either replace the isSignal variable by the isSignalAcceptBremsPhotons one, or add the ?addbrems marker to the decay string:

49# combine final state particles to form composite particles
50ma.reconstructDecay(
51    "J/psi:ee -> e+:corrected e-:corrected ?addbrems",
52    cut="dM < 0.11",
53    path=main,
54)

Finally, let’s add the invariant mass of the \(J/\psi\) meson without any Bremsstrahlung recovery applied. Then, after running your steering file, compare this invariant mass with the one obtained after the recovery, by selecting only the correctly reconstructed \(J/\psi\). Can you see the effect of the Bremsstrahlung recovery?

Exercise

Create a variable to calculate the invariant mass of the \(J/\psi\) meson using the uncorrected momenta of the leptons. Call it M_uncorrected. You may find the meta-variable daughterCombination useful.

Hint

daughterCombination(M,0:0,1:0) will give us the invariant mass of the first daughter of the first daughter, and the first daughter of the second daughter. Since all particles in the e+:corrected particle list have as first daughter the uncorrected particle, we just need to calculate this daughter combination for the \(J/\psi\) meson.

Hint

We can do this by directly appending the expression to the list of \(J/\psi\) variables we want to store, or we can rather make it a variable of the B mesons, by using the daughter meta-variable.

Solution

112vm.addAlias(
113    "Jpsi_M_uncorrected", "daughter(0, daughterCombination(M,0:0,1:0))"
114)

Exercise

Your steering file should now be complete. Please run it or compare it with the solution.

Solution

Your steering file should look like this:

  1#!/usr/bin/env python3
  2
  3import sys
  4import basf2 as b2
  5import modularAnalysis as ma
  6import stdV0s
  7from variables import variables as vm  # shorthand for VariableManager
  8import variables.collections as vc
  9import variables.utils as vu
 10
 11# get input file number from the command line
 12filenumber = sys.argv[1]
 13
 14# create path
 15main = b2.Path()
 16
 17# load input data from mdst/udst file
 18ma.inputMdstList(
 19    environmentType="default",
 20    filelist=[b2.find_file(f"starterkit/2021/1111540100_eph3_BGx0_{filenumber}.root", "examples")],
 21    path=main,
 22)
 23
 24# fill final state particle lists
 25ma.fillParticleList(
 26    "e+:uncorrected",
 27    "electronID > 0.1 and dr < 0.5 and abs(dz) < 2 and thetaInCDCAcceptance",
 28    path=main,
 29)
 30stdV0s.stdKshorts(path=main)
 31
 32# apply Bremsstrahlung correction to electrons
 33vm.addAlias(
 34    "goodFWDGamma", "passesCut(clusterReg == 1 and clusterE > 0.075)"
 35)
 36vm.addAlias(
 37    "goodBRLGamma", "passesCut(clusterReg == 2 and clusterE > 0.05)"
 38)
 39vm.addAlias(
 40    "goodBWDGamma", "passesCut(clusterReg == 3 and clusterE > 0.1)"
 41)
 42vm.addAlias(
 43    "goodGamma", "passesCut(goodFWDGamma or goodBRLGamma or goodBWDGamma)"
 44)
 45ma.fillParticleList("gamma:brems", "goodGamma", path=main)
 46ma.correctBrems("e+:corrected", "e+:uncorrected", "gamma:brems", path=main)
 47vm.addAlias("isBremsCorrected", "extraInfo(bremsCorrected)")
 48
 49# combine final state particles to form composite particles
 50ma.reconstructDecay(
 51    "J/psi:ee -> e+:corrected e-:corrected ?addbrems",
 52    cut="dM < 0.11",
 53    path=main,
 54)
 55
 56# combine J/psi and KS candidates to form B0 candidates
 57ma.reconstructDecay(
 58    "B0 -> J/psi:ee K_S0:merged",
 59    cut="Mbc > 5.2 and abs(deltaE) < 0.15",
 60    path=main,
 61)
 62
 63# match reconstructed with MC particles
 64ma.matchMCTruth("B0", path=main)
 65
 66# build the rest of the event
 67ma.buildRestOfEvent("B0", fillWithMostLikely=True, path=main)
 68track_based_cuts = "thetaInCDCAcceptance and pt > 0.075"
 69ecl_based_cuts = "thetaInCDCAcceptance and E > 0.05"
 70roe_mask = ("my_mask", track_based_cuts, ecl_based_cuts)
 71ma.appendROEMasks("B0", [roe_mask], path=main)
 72
 73# Create list of variables to save into the output file
 74b_vars = []
 75
 76standard_vars = vc.kinematics + vc.mc_kinematics + vc.mc_truth
 77b_vars += vc.deltae_mbc
 78b_vars += standard_vars
 79
 80# ROE variables
 81roe_kinematics = ["roeE()", "roeM()", "roeP()", "roeMbc()", "roeDeltae()"]
 82roe_multiplicities = [
 83    "nROE_Charged()",
 84    "nROE_Photons()",
 85    "nROE_NeutralHadrons()",
 86]
 87b_vars += roe_kinematics + roe_multiplicities
 88# Let's also add a version of the ROE variables that includes the mask:
 89for roe_variable in roe_kinematics + roe_multiplicities:
 90    # e.g. instead of 'roeE()' (no mask) we want 'roeE(my_mask)'
 91    roe_variable_with_mask = roe_variable.replace("()", "(my_mask)")
 92    b_vars.append(roe_variable_with_mask)
 93
 94# Variables for final states (electrons, positrons, pions)
 95fs_vars = vc.pid + vc.track + vc.track_hits + standard_vars
 96b_vars += vu.create_aliases_for_selected(
 97    fs_vars + ["isBremsCorrected"],
 98    "B0 -> [J/psi -> ^e+ ^e-] K_S0",
 99    prefix=["ep", "em"],
100)
101b_vars += vu.create_aliases_for_selected(
102    fs_vars, "B0 -> J/psi [K_S0 -> ^pi+ ^pi-]", prefix=["pip", "pim"]
103)
104# Variables for J/Psi, KS
105jpsi_ks_vars = vc.inv_mass + standard_vars
106b_vars += vu.create_aliases_for_selected(jpsi_ks_vars, "B0 -> ^J/psi ^K_S0")
107# Add the J/Psi mass calculated with uncorrected electrons:
108vm.addAlias(
109    "Jpsi_M_uncorrected", "daughter(0, daughterCombination(M,0:0,1:0))"
110)
111b_vars += ["Jpsi_M_uncorrected"]
112# Also add kinematic variables boosted to the center of mass frame (CMS)
113# for all particles
114cmskinematics = vu.create_aliases(
115    vc.kinematics, "useCMSFrame({variable})", "CMS"
116)
117b_vars += vu.create_aliases_for_selected(
118    cmskinematics, "^B0 -> [^J/psi -> ^e+ ^e-] [^K_S0 -> ^pi+ ^pi-]"
119)
120
121vm.addAlias(
122    "withBremsCorrection",
123    "passesCut(passesCut(ep_isBremsCorrected == 1) or passesCut(em_isBremsCorrected == 1))",
124)
125b_vars += ["withBremsCorrection"]
126
127# Save variables to an output file (ntuple)
128ma.variablesToNtuple(
129    "B0",
130    variables=b_vars,
131    filename="Bd2JpsiKS.root",
132    treename="tree",
133    path=main,
134)
135
136# Start the event loop (actually start processing things)
137b2.process(main)
138
139# print out the summary
140print(b2.statistics)

Exercise

Plot a histogram of M and M_uncorrected for the correctly reconstructed \(J/\psi\) mesons

Solution

 1#!/usr/bin/env python3
 2
 3##########################################################################
 4# basf2 (Belle II Analysis Software Framework)                           #
 5# Author: The Belle II Collaboration                                     #
 6#                                                                        #
 7# See git log for contributors and copyright holders.                    #
 8# This file is licensed under LGPL-3.0, see LICENSE.md.                  #
 9##########################################################################
10
11import matplotlib as mpl
12import matplotlib.pyplot as plt
13from root_pandas import read_root
14
15# Only include this line if you're running from ipython an a remote server
16mpl.use("Agg")
17
18plt.style.use("belle2")  # use the official Belle II plotting style
19
20# Make sure that the .root file is in the same directory to find it
21df = read_root("Bd2JpsiKS.root")
22
23# Let's only consider signal J/Psi
24df_signal_only = df.query("Jpsi_isSignal == 1")
25
26fig, ax = plt.subplots()
27
28ax.hist(df_signal_only["Jpsi_M_uncorrected"], label="w/o brems corr", alpha=0.5)
29ax.hist(df_signal_only["Jpsi_M"], label="with brems corr", alpha=0.5)
30
31ax.set_yscale("log")  # set a logarithmic scale in the y-axis
32ax.set_xlabel("Invariant mass of the J/Psi")
33ax.set_ylabel("Events")
34ax.legend()  # show legend
35
36plt.savefig("brems_corr_invariant_mass.png")

The results should look similar to Fig. 25.23 (this was obtained with a different steering file, so do not mind if your plot is not exactly the same).

../../_images/brems_corr_invariant_mass.png

Fig. 25.23 Invariant mass distributions for the reconstructed decay, \(J/\psi \to e^+e^-\), with and without Bremsstrahlung correction

Extra exercises

  • Store the isBremsCorrected information of the positrons and electrons used in the \(J/\psi\) reconstruction

  • Create a variable named withBremsCorrection that indicates if any of the leptons used in the reconstruction of the B meson was Bremsstrahlung recovered

Key points

  • There are two ways of performing Bremsstrahlung correction: correctBrems and correctBremsBelle

  • Both of them create new particle lists

  • The members of the new particle list will have as daughter the original uncorrected particle and, if a correction was performed, the Bremsstrahlung photons used

  • MC matching with Bremsstrahlung corrected particles requires a special treatment: use the isSignalAcceptBremsPhotons variable, or add the ?addbrems marker in the decay string

Best Candidate Selection

Sometimes, even after multiple selection criteria have been applied, a single event may contain more than one candidate for the reconstructed decay. In those cases, it is necessary to use some indicator that measures the quality of the multiple reconstructions, and that allow us to select the best one (or, in certain studies, select one candidate at random). Which variable to use as indicator depends on the study, and even on the analyst. Our intention here is not to tell you how to select the best quality indicator, but rather to show yo how to use it in order to select the best candidate.

The Modular Analysis package has two very useful functions, rankByHighest and rankByLowest. Each one does exactly as its name indicates: they rank particles in descending (rankByHighest) or ascending (rankByLowest) order, using the value of the variable provided as a parameter. They append to each particle an extraInfo field with the name ${variable}_rank, with the best candidate having the value one (1). Notice that each particle/anti-particle list is sorted separately, i.e.,if certain event has multiple \(B^+\) and \(B^-\) candidates, and you apply the ranking function to any of the particle lists, each list will be ranked separately.

Best candidate selection can then be performed by simply selecting the particle with the lowest rank. You can do that by either applying a cut on the particle list, or directly through the rankByHighest and rankByLowest functions, by specifying a non-zero value for the numBest parameter. Make sure to check the documentation of these functions.

Continuing with our example, we will make a best candidate selection using the random variable, which returns a random number between 0 and 1 for each candidate. We will select candidates with the largest value of random. In order to have uniform results across different sessions, we manually set the random seed.

Exercise

Set the basf2 random seed to "Belle II StarterKit". Then, rank your B mesons using the random variable, with the one with the highest value first. Keep only the best candidate.

Hint

You may want to check the documentation for the rankByHighest and set_random_seed functions.

Solution

73# perform best candidate selection
74b2.set_random_seed("Belle II StarterKit")
75ma.rankByHighest("B0", variable="random", numBest=1, path=main)

Warning

Best candidate selection is used to pick the most adequately reconstructed decay, after all other selection cuts have been applied. As so, make sure to include it after you have performed all the other cuts in your analysis.

Exercise

Your steering file should now be complete. Run it or compare it with the solution.

Solution

  1#!/usr/bin/env python3
  2
  3import sys
  4import basf2 as b2
  5import modularAnalysis as ma
  6import stdV0s
  7from variables import variables as vm  # shorthand for VariableManager
  8import variables.collections as vc
  9import variables.utils as vu
 10
 11# get input file number from the command line
 12filenumber = sys.argv[1]
 13
 14# create path
 15main = b2.Path()
 16
 17# load input data from mdst/udst file
 18ma.inputMdstList(
 19    environmentType="default",
 20    filelist=[b2.find_file(f"starterkit/2021/1111540100_eph3_BGx0_{filenumber}.root", "examples")],
 21    path=main,
 22)
 23
 24# fill final state particle lists
 25ma.fillParticleList(
 26    "e+:uncorrected",
 27    "electronID > 0.1 and dr < 0.5 and abs(dz) < 2 and thetaInCDCAcceptance",
 28    path=main,
 29)
 30stdV0s.stdKshorts(path=main)
 31
 32# apply Bremsstrahlung correction to electrons
 33vm.addAlias(
 34    "goodFWDGamma", "passesCut(clusterReg == 1 and clusterE > 0.075)"
 35)
 36vm.addAlias(
 37    "goodBRLGamma", "passesCut(clusterReg == 2 and clusterE > 0.05)"
 38)
 39vm.addAlias(
 40    "goodBWDGamma", "passesCut(clusterReg == 3 and clusterE > 0.1)"
 41)
 42vm.addAlias(
 43    "goodGamma", "passesCut(goodFWDGamma or goodBRLGamma or goodBWDGamma)"
 44)
 45ma.fillParticleList("gamma:brems", "goodGamma", path=main)
 46ma.correctBrems("e+:corrected", "e+:uncorrected", "gamma:brems", path=main)
 47vm.addAlias("isBremsCorrected", "extraInfo(bremsCorrected)")
 48
 49# combine final state particles to form composite particles
 50ma.reconstructDecay(
 51    "J/psi:ee -> e+:corrected e-:corrected ?addbrems",
 52    cut="dM < 0.11",
 53    path=main,
 54)
 55
 56# combine J/psi and KS candidates to form B0 candidates
 57ma.reconstructDecay(
 58    "B0 -> J/psi:ee K_S0:merged",
 59    cut="Mbc > 5.2 and abs(deltaE) < 0.15",
 60    path=main,
 61)
 62
 63# match reconstructed with MC particles
 64ma.matchMCTruth("B0", path=main)
 65
 66# build the rest of the event
 67ma.buildRestOfEvent("B0", fillWithMostLikely=True, path=main)
 68track_based_cuts = "thetaInCDCAcceptance and pt > 0.075 and dr < 5 and abs(dz) < 10"
 69ecl_based_cuts = "thetaInCDCAcceptance and E > 0.05"
 70roe_mask = ("my_mask", track_based_cuts, ecl_based_cuts)
 71ma.appendROEMasks("B0", [roe_mask], path=main)
 72
 73# perform best candidate selection
 74b2.set_random_seed("Belle II StarterKit")
 75ma.rankByHighest("B0", variable="random", numBest=1, path=main)
 76
 77# Create list of variables to save into the output file
 78b_vars = []
 79
 80standard_vars = vc.kinematics + vc.mc_kinematics + vc.mc_truth
 81b_vars += vc.deltae_mbc
 82b_vars += standard_vars
 83
 84# ROE variables
 85roe_kinematics = ["roeE()", "roeM()", "roeP()", "roeMbc()", "roeDeltae()"]
 86roe_multiplicities = [
 87    "nROE_Charged()",
 88    "nROE_Photons()",
 89    "nROE_NeutralHadrons()",
 90]
 91b_vars += roe_kinematics + roe_multiplicities
 92# Let's also add a version of the ROE variables that includes the mask:
 93for roe_variable in roe_kinematics + roe_multiplicities:
 94    # e.g. instead of 'roeE()' (no mask) we want 'roeE(my_mask)'
 95    roe_variable_with_mask = roe_variable.replace("()", "(my_mask)")
 96    b_vars.append(roe_variable_with_mask)
 97
 98# Variables for final states (electrons, positrons, pions)
 99fs_vars = vc.pid + vc.track + vc.track_hits + standard_vars
100b_vars += vu.create_aliases_for_selected(
101    fs_vars + ["isBremsCorrected"],
102    "B0 -> [J/psi -> ^e+ ^e-] K_S0",
103    prefix=["ep", "em"],
104)
105b_vars += vu.create_aliases_for_selected(
106    fs_vars, "B0 -> J/psi [K_S0 -> ^pi+ ^pi-]", prefix=["pip", "pim"]
107)
108# Variables for J/Psi, KS
109jpsi_ks_vars = vc.inv_mass + standard_vars
110b_vars += vu.create_aliases_for_selected(jpsi_ks_vars, "B0 -> ^J/psi ^K_S0")
111# Add the J/Psi mass calculated with uncorrected electrons:
112vm.addAlias(
113    "Jpsi_M_uncorrected", "daughter(0, daughterCombination(M,0:0,1:0))"
114)
115b_vars += ["Jpsi_M_uncorrected"]
116# Also add kinematic variables boosted to the center of mass frame (CMS)
117# for all particles
118cmskinematics = vu.create_aliases(
119    vc.kinematics, "useCMSFrame({variable})", "CMS"
120)
121b_vars += vu.create_aliases_for_selected(
122    cmskinematics, "^B0 -> [^J/psi -> ^e+ ^e-] [^K_S0 -> ^pi+ ^pi-]"
123)
124
125vm.addAlias(
126    "withBremsCorrection",
127    "passesCut(passesCut(ep_isBremsCorrected == 1) or passesCut(em_isBremsCorrected == 1))",
128)
129b_vars += ["withBremsCorrection"]
130
131# Save variables to an output file (ntuple)
132ma.variablesToNtuple(
133    "B0",
134    variables=b_vars,
135    filename="Bd2JpsiKS.root",
136    treename="tree",
137    path=main,
138)
139
140# Start the event loop (actually start processing things)
141b2.process(main)
142
143# print out the summary
144print(b2.statistics)

Extra exercises

  • Remove the numBest parameter from the rankByHighest function, and store both the random and the extraInfo(random_rank) variables. You can, and probably should, use aliases for these variables. Make sure that the ranking is working properly by plotting one variable against the other for events with more than one candidate (the number of candidates for a certain event is stored automatically when performing a reconstruction. Take a look at the output root file in order to find how is this variable named).

  • Can you think of a good variable to rank our B mesons? Try to select candidates based on this new variable, and compare how much do your results improve by, i.e., comparing the number of true positives, false negatives, or the distributions of fitting variables such as the beam constrained mass.

Note

From light release light-2008-kronos, the Modular Analysis package introduces the convenience function applyRandomCandidateSelection, which is equivalent to using rankByHighest or rankByLowest with the random variable, and with numBest equal to 1.

Key points

  • Best candidate selection can be performed with the rankByHighest and rankByLowest functions

  • These functions sort particles and antiparticles separately

  • From light release light-2008-kronos, a new helper function can be used to perform random candidate selection: applyRandomCandidateSelection

Stuck? We can help!

If you get stuck or have any questions to the online book material, the #starterkit-workshop channel in our chat is full of nice people who will provide fast help.

Refer to Collaborative Tools. for other places to get help if you have specific or detailed questions about your own analysis.

Improving things!

If you know how to do it, we recommend you to report bugs and other requests with JIRA. Make sure to use the documentation-training component of the Belle II Software project.

If you just want to give very quick feedback, use the last box “Quick feedback”.

Please make sure to be as precise as possible to make it easier for us to fix things! So for example:

  • typos (where?)

  • missing bits of information (what?)

  • bugs (what did you do? what goes wrong?)

  • too hard exercises (which one?)

  • etc.

If you are familiar with git and want to create your first pull request for the software, take a look at How to contribute. We’d be happy to have you on the team!

Quick feedback!

Authors of this lesson

Alejandro Mora, Kilian Lieret