- Particle Identification (PID)
- PID and Monte Carlo
- Beta Operators
- Combining BtaCandidates
- BtaBooster, BtaHelicity and helicity angle
- Associators
- B Flavor Tagging
- Roofit: A ROOT toolkit
- WIRED: The BaBar event display

This section presents more advanced topics on the Beta analysis packages covering the basics on how to manipulate candidates with operators, Monte Carlo truth associators, and introduces several concepts useful for running physics analyses at BaBar. Users who are new to using Beta candidates should first read the Workbook Event Information section, and in particular the BtaCandidate section.

**Quick links:**

Charged PID Homepage

Neutral PID Homepage

Particle Identifcation (PID) is concerned with the identification
of *detected* particles - ones that live long enough to leave
an actual signal in the detector. The detected particles are electrons,
muons, pions, kaons, protons, and photons. Other particles decay too
quickly to be detected, and must be reconstructed by combining the
detected particles to form composite candidates, and testing these
candidates. You will learn about particle composition
later in this section.

The responsibility for Particle ID is divided between two groups: the Charged PID Group and the Neutral PID Group.

The PID groups develop, tests and maintain *particle
selectors*, standard sets of selection criteria used in all BaBar analyses
to identify the detected particles.

The *efficiency* of a selector is the fraction of signal events
accepted by the selector. The *purity* is the fraction of
all events selected that are signal events. In general, you want
high efficiency and high purity. However, there is usually a tradeoff
between efficiency and purity: if you tighten your selection criteria,
you will cut out more background events, but you will lose more signal events as well.

To provide each user with the level of selection required for his or her
analysis, each particle typically has several *levels* of selector,
from VeryLoose (most efficient, least pure) to VeryTight (most pure, least
efficient). You will need to determine which level of selector you require
by studying the efficiencies and purities of those selectors for your
specific analysis.

A PID list is a list of BtaCandidates that have passed a given particle selector. For example, one of the lists provided by the Charged PID group is the eMicroTight list of BtaCandidates that have passed the selector "TightElectronMicroSelection". The complete list of available PID lists can be found in the Workbook's Table of Run-time Lists.

Since Monte Carlo (simulated data) is not a perfect imitation of data, the performance of the particle selectors is not the same for data and Monte Carlo. So whenever an analysis uses Monte Carlo simulations to estimate the effect of a PID selector on data, the result must be corrected for differences between data and Monte Carlo.

The PID groups both provide methods for implementing data/MC corrections in your analysis. For Charged PID, you have a choice between two main methods: PID tweaking or PID weighting, which can be set via tcl. For Neutral PID, the procedure usually involves adding or changing some lines in a tcl file, and possibly adding a package with a given tag.

Unfortunately, in both groups (especially the Neutrals Group) the recommended procedure tends to change over time, so you need to consult the PID Group webpages at the time you do your analysis to find out what is the current method for data/MC corrections.

**Related Links:** (last updated: April 2007)

Charged PID data/MC corrections

18-series recipe for neutrals data/MC corrections

(I was unable to find links to instructions for R22 recipes. Probably they have not been created yet. If/when you find them, please email me and let me know so I can update this page.)

There are also many functions that can be performed *on*
BtaCandidates. These functions are not members of the BtaCandidate
class; rather, they take BtaCandidates as input. Vertexing, mass-constrained
fitting, and simple 4-vector addition are examples of such operators.
The analyst selects the operator needed at particular stages in the
analysis, trading off accuracy and completeness for speed and flexibility.
This is just the beginning of the list of all the possible operations
that can be performed on BtaCandidates:

- Cloning
- Setting particle type
- Combining 4-vectors
- Vertexing
- Applying constraints
- Obtaining Monte Carlo Truth
- Changing a reference frame
- ...............

**Simple addition**- Beta Candidate (class BtaCandidate) can be simply combined to form a new Beta Candidate. This type of addition imposes no constraints.
**Vertex and Kinematic Fitting**- These are fitters that can be used within a BaBar Framework application to create composite candidates, incorporating geometric constraints, kinematic constraints, or both.
**SimpleComposition**- SimpleComposition is a package full of BaBar Framework modules that create lists of composite particles, automating the work of making combinations, performing fits, and making cuts.

BtaCandidate* c1; BtaCandidate* c2; BtaOpAdd4 op; BtaCandidate c3= op.combine( *c1, *c2 );This operation combines BtaCandidates

`c1`

and
`c2`

to give the (putative) mother, `c3`

.
`BtaOpAdd4`

specifies a simple kinematic addition.
This type of addition does not take into account any geometric or kinematic constraints. The two BtaCandidates could be separated by a long distance in space, or combine to form a BtaCandidate with an impossible mass (for example, a mass that does not belong to any existing particle). So you will need to test the new BtaCandidate before you can be confident that it really is the mother.

Vertexers and kinematic fitters are both Beta operators. The input is a list or tree of BtaCandidates. A vertexer returns the most likely common vertex position, vertex momentum, and their errors. A kinematic fitter returns the best fit to the momenta/masses/energies of the candidates. Many Beta operators do both. The output is a modified version of the tree with improved vertices and momenta.

An example of the use of a vertexer can be found in the module, which came in your BetaMiniUser package. This module forms K0 candidates by vertexing pairs of pion candidates. Looking at MyK0Analysis.cc, you can see that the code #includes the required vertexing header files,

```
#include "VtxBase/BtaAbsVertexer.hh"
#include "VtxFitter/VtxFitterOper.hh"
#include "VtxBase/VtxAbsAlgorithm.hh"
```

initiates some vertexers,
```
, vtxFitAlgo("vtxFitAlgo", this, VtxAbsAlgorithm::GeoKin)
, vtxFitMode("vtxFitMode", this, VtxAbsAlgorithm::Standard)
```

and uses them to obtain a "fitted Vee" (that is, a fitted hypothetical
K -> pi+ pi- decay).
```
VtxFitterOper veeVertexer(initialVee,vtxFitAlgo.value(), vtxFitMode.value());
veeVertexer.fit();
fittedVee = veeVertexer.getFittedTree();
```

To learn how to use the vertexing operators go at the Vertexing/Kinematic
Fitting User's Guide. This is a well-written, detailed and up-to-date
guide based on analysis-21. (Note that it is based on a different
release than analysis-30, the release used in the Workbook Quicktour.)
*Related Documents:*

- Vertexing
and Composition Tools Group

An active site with many useful examples that is kept up-to-date - Tracking
and Fitting

Natalia Kuznetsova, Babar Detector Physics Series, November 1999

SimpleComposition provides an interface for fitting and refitting, applying and refining selection. Each "operation" that SimpleComposition supports is given a module, and that module is configure by the user via tcl

The SimpleComposition home page has links to many useful tutorials and examples on how to use the SimpleComposition package. Another good way to get started using SimpleComposition is to try the Workbook tutorial, How to generate a set of CM2 ntuples using SimpleComposition and BtaTupleMaker.

Some of the more useful BetaCoreTools include:

- Tools for calculating event shape variables, such as thrust, sphericity, the Fox Wolfram moment.
- Monte Carlo truth associators, which associate the reconstructed objects in the event store to the corresponding Monte Carlo truth candidate (if it exists).
- Tools providing additional event information, such as total momentum and B variables like deltaE, mes, and eBeam.
- Utility functions to carry out tasks such as boosting a candidate and all its decay products, and doing simple vertexing (adding 4 momenta)

- Selectors and particle candidate makers.
- Tools for making cuts/histogramming.
- Beta Candidate counters

Descriptions and documentation for these and other BetaTools can be found on the BetaTools and BetaCoreTools page.

Some of the more useful tools are described below.

The following short C++ routine can be used to compute the cosine of the helicity angle.

```
#include <TLorentzVector.h>
#include <Vector3.h>
Float_t coshel(TLorentzVector particle, TLorentzVector parent,
TLorentzVector grandparent) {
TVector3 boosttoparent = -(parent.BoostVector());
particle.Boost(boosttoparent);
grandparent.Boost(boosttoparent);
TVector3 particle3 = particle.Vect();
TVector3 grandparent3 = grandparent.Vect();
Float_t numerator = particle3.Dot(grandparent3);
Float_t denominator = (particle3.Mag())*(grandparent3.Mag());
Float_t temp = numerator/denominator;
return temp;
}
```

Alternatively, the helicity is expressed in terms of Lorentz invariant quantities in BAD 522 (V6), Eq. 141, page 120. This expression avoids the need to do boosts for calculating the helicity angle.

NOTE: You should NOT use BtaBooster to compute helicity, because you cannot compare angles between a BtaBooster'ed vector and an un-BtaBooster'ed vector, as the two coordinate systems have a relative rotation. Instead, a straight Lorentz boost should be used. In the special case where X and a are already boosted to the Y reference frame, you can use the BetaCoreTools package BtaHelicity to compute the helicity. The syntax is:

```
#include "BetaCoreTools/BtaHelicity.hh"
BtaHelicity h(a, b); // a and b are BtaCandidates in X -> a + b
double hel = h.helicity();
```

For example, in the BetaMiniUser package, BtaHelicity is used in MyK0Analysis.cc
to compute the helicity of d1 in the decay K-candidate -> d1 d2.
For example in efficiency studies it is important to be able to associate the Monte Carlo truth to the reconstructed objects. An example of how to do use associators is in our very own MyMiniAnalysis.cc, where a truth map is initiated,

```
, _btaTruthMap( "btaTruthMap", this, "GHit")
```

made framework-accessible,
```
commands()->append( &_btaTruthMap );
```

accessed,
```
// get the default truth mapping
//
BtaMcAssoc* truthMap =
Ifd< BtaMcAssoc >::get(anEvent, _btaTruthMap.value());
```

and finally used to associate each Beta Candidate in
the list *btaMicroList with its MC partner.
```
// Simple example of map usage
HepAListIterator<BtaCandidate> recoIter(*btaMicroList);
while (BtaCandidate* reco = recoIter()){
BtaCandidate *mcPartner = truthMap->mcFromReco(reco);
```

Then the difference between the momentum of the MC partner
and the original candidate is written to a histogram:
```
_aHisto->accumulate(mcPartner->p() - reco->p());
```

A typical scenario is that one of the B-mesons (the signal B) decays in the mode of interest, while the other B-meson (the tagging B) is used to determine the flavor. The tagging B decays to a charged lepton or kaon. Then the b-quark flavor can be determined from the correlation between the b-quark charge and the charge of the "tagging" lepton or kaon.

The home page of the B Tagging Tools Group includes links to BaBar Analysis Document (BAD) 729, which describes Tag04, the latest (2004) B-tagging algorithm, and a recipe for making ntuples in CM2 with release 14.5.2.

*Related Documents:*

*These older BADs describe earlier versions of the B-tagging algorithm:*

- BAD 317: BTagger - A Multivariate Tagging Algorithm with Categories Based on the Physics of the Btag Decay
- BAD 242: A User's Guide to the BaBar B Flavor Tagging Tools

*Related Documents:*

- RooFit home page Includes a slide show and introductory tutorial.
- BaBar RooFit home page

- WIRED for CM2. Basic instructions.
- SLAC WIRED Users Home Page. Detailed instructions.