Belle II Software  release-05-01-25
test6_CPVAnalysisTools.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 """
5 <header>
6  <output>CPVToolsOutput.root</output>
7  <contact>Fernando Abudinen; abudinen@mpp.mpg.de</contact>
8  <description>This file employs all the time dependent CPV analysis tools. It reconstructs B0sig->J/PsiKs on the signal side
9  and applies the flavor tagger on the ROE. The vertex of B0sig is reconstructed and the vertex of B0tag is reconstructed
10  with the TagV module. </description>
11 </header>
12 """
13 
14 import basf2 as b2
15 import modularAnalysis as ma
16 import flavorTagger as ft
17 import vertex as vx
18 import variables.collections as vc
19 import variables.utils as vu
20 import ROOT
21 import sys
22 
23 # create path
24 cp_val_path = b2.Path()
25 
26 inputFile = b2.find_file(filename='analysis/mdst11_BGx1_b2jpsiks.root', data_type='validation')
27 ma.inputMdst(environmentType='default', filename=inputFile, path=cp_val_path)
28 
29 # ma.inputMdst(environmentType='default', filename='../mdst11_BGx1_b2jpsiks.root', path=cp_val_path)
30 
31 # Reconstruction of signal side and MC match
32 ma.fillParticleList(decayString='pi+:all', cut='', path=cp_val_path)
33 ma.fillParticleList(decayString='mu+:all', cut='', path=cp_val_path)
34 
35 ma.reconstructDecay(decayString='K_S0:pipi -> pi+:all pi-:all', cut='dM<0.25', path=cp_val_path)
36 ma.reconstructDecay(decayString='J/psi:mumu -> mu+:all mu-:all', cut='dM<0.11', path=cp_val_path)
37 ma.reconstructDecay(decayString='B0:jpsiks -> J/psi:mumu K_S0:pipi', cut='Mbc > 5.2 and abs(deltaE)<0.2', path=cp_val_path)
38 
39 ma.matchMCTruth(list_name='B0:jpsiks', path=cp_val_path)
40 
41 # build the rest of the event associated to the B0
42 ma.buildRestOfEvent(target_list_name='B0:jpsiks', path=cp_val_path)
43 
44 # Get Special GT for the flavor tagger weight files
45 b2.use_central_database("analysis_tools_release-03-01-00")
46 
47 # Flavor Tagger, Vertex of Signal Side and TagV
48 ft.flavorTagger(
49  particleLists=['B0:jpsiks'],
50  weightFiles='B2nunubarBGx1',
51  path=cp_val_path)
52 
53 vx.raveFit(list_name='B0:jpsiks', conf_level=0.0,
54  decay_string='B0:jpsiks -> [J/psi:mumu -> ^mu+ ^mu-] K_S0', constraint='', path=cp_val_path)
55 vx.TagV(list_name='B0:jpsiks', MCassociation='breco', path=cp_val_path)
56 
57 # Select variables that will be stored to ntuple
58 fs_vars = vc.pid + vc.track + vc.track_hits + vc.mc_truth
59 jpsiandk0s_vars = vc.mc_truth
60 vertex_vars = vc.vertex + vc.mc_vertex + vc.kinematics + vc.mc_kinematics
61 bvars = vc.reco_stats + \
62  vc.deltae_mbc + \
63  vc.mc_truth + \
64  vc.roe_multiplicities + \
65  ft.flavor_tagging + \
66  vc.tag_vertex + \
67  vc.mc_tag_vertex + \
68  vertex_vars + \
69  vu.create_aliases_for_selected(list_of_variables=fs_vars,
70  decay_string='B0 -> [J/psi -> ^mu+ ^mu-] [K_S0 -> ^pi+ ^pi-]') + \
71  vu.create_aliases_for_selected(list_of_variables=jpsiandk0s_vars,
72  decay_string='B0 -> [^J/psi -> mu+ mu-] [^K_S0 -> pi+ pi-]') + \
73  vu.create_aliases_for_selected(list_of_variables=vertex_vars,
74  decay_string='B0 -> [^J/psi -> ^mu+ ^mu-] [^K_S0 -> ^pi+ ^pi-]')
75 
76 # Saving variables to ntuple
77 ma.variablesToNtuple(decayString='B0:jpsiks',
78  variables=bvars,
79  filename='../CPVToolsOutput.root',
80  treename='B0tree',
81  path=cp_val_path)
82 
83 ma.summaryOfLists(particleLists=['B0:jpsiks'], path=cp_val_path)
84 
85 # Process the events
86 b2.process(cp_val_path)
87 
88 # print out the summary
89 print(b2.statistics)
variables.utils
Definition: utils.py:1
variables.collections
Definition: collections.py:1