Belle II Software  release-06-02-00
exampleOfRetentionCheck.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 """Example showing the use of the RetentionCheck module
13 
14 To run the example, simply do
15 
16  basf2 exampleOfRetentionCheck.py -n 100
17 """
18 
19 import basf2 as b2
20 import modularAnalysis as ma
21 from skimExpertFunctions import get_test_file
22 from skimRetentionCheck import RetentionCheck, pathWithRetentionCheck
23 from skim.fei import runFEIforB0SL
24 
25 # Create a basf2 path.
26 path = b2.create_path()
27 
28 # Input a test mdst file.
29 ma.inputMdstList('default', get_test_file("MC12_mixedBGx1"), path=path)
30 
31 # Run pre-selection cuts and FEI.
32 runFEIforB0SL(path)
33 # Apply *arbitrary* cuts on the B tag list.
34 ma.applyCuts('B0:semileptonic', 'sigProb>0.0001', path=path)
35 ma.applyCuts('B0:semileptonic', '-4.0<cosThetaBY<3.0', path=path)
36 ma.applyCuts('B0:semileptonic', 'dmID<8', path=path)
37 ma.applyCuts('B0:semileptonic', '[[dmID<4 and d1_p_CMSframe>1.0] or [dmID>=4 and d2_p_CMSframe>1.0]]', path=path)
38 
39 # Add the retention tracker.
40 path = pathWithRetentionCheck(['B0:semileptonic'], path)
41 
42 # Process the basf2 path.
43 b2.process(path)
44 
45 # Print out the retention tracker results and create an associated plot.
46 RetentionCheck.print_results()
47 RetentionCheck.plot_retention('B0:semileptonic', save_as='retention_rate.pdf')