Belle II Software  release-08-01-10
muPairAlignment.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 
18 
19 import sys
20 import basf2 as b2
21 from modularAnalysis import inputMdst
22 from modularAnalysis import fillParticleList
23 from variables import variables
24 from modularAnalysis import reconstructDecay
25 from modularAnalysis import applyEventCuts
26 from modularAnalysis import rankByHighest
27 from modularAnalysis import cutAndCopyList
28 from modularAnalysis import variablesToEventExtraInfo
29 
30 # ..create path
31 mypath = b2.create_path()
32 
33 inputMdst('/group/belle2/dataprod/MC/MC13a_local/mumu/mumu_eph3_2295.root', path=mypath)
34 
35 # ..Muon list. Require that there be two high-p tracks, and none with clusterE>1 GeV
36 fillParticleList('mu-:highp', 'useCMSFrame(p) > 3.5 and abs(d0) < 0.5 and abs(z0) < 4 and nCDCHits>0 and nVXDHits>0', path=mypath)
37 cutAndCopyList('mu-:highE', 'mu-:highp', 'clusterE>1.', path=mypath)
38 
39 variables.addAlias('nhighp', 'nParticlesInList(mu-:highp)')
40 variables.addAlias('nhighE', 'nParticlesInList(mu-:highE)')
41 applyEventCuts('[nhighE==0] and [nhighp==2]', mypath)
42 
43 # ..Combine two muons, requiring back to back and high invariant mass
44 variables.addAlias('deltaPhiCMS', 'formula(57.2957795*abs(daughterDiffOfPhiCMS(0, 1)))')
45 variables.addAlias('sumThetaCMS', 'formula(57.2957795*(daughter(0, useCMSFrame(theta)) + daughter(1, useCMSFrame(theta))))')
46 event_cut = '175 < sumThetaCMS < 185 and deltaPhiCMS > 175 and 9 < M < 11'
47 reconstructDecay('vpho:0 -> mu-:highp mu+:highp', event_cut, path=mypath)
48 
49 # ..Require a good muon pair
50 variables.addAlias('nPair', 'nParticlesInList(vpho:0)')
51 applyEventCuts('nPair==1', mypath)
52 
53 # ..Record the highest and lowest muonID of the two muons in the event
54 cutAndCopyList('mu-:muonID', 'mu-:highp', '', path=mypath)
55 rankByHighest('mu-:muonID', 'muonID', path=mypath)
56 
57 cutAndCopyList('mu-:bestID', 'mu-:muonID', 'extraInfo(muonID_rank)==1', path=mypath)
58 variablesToEventExtraInfo(particleList='mu-:bestID', variables={'muonID': 'bestID'}, path=mypath)
59 variables.addAlias('bestMuonID', 'eventExtraInfo(bestID)')
60 
61 cutAndCopyList('mu-:worstID', 'mu-:muonID', 'extraInfo(muonID_rank)==2', path=mypath)
62 variablesToEventExtraInfo(particleList='mu-:worstID', variables={'muonID': 'worstID'}, path=mypath)
63 variables.addAlias('worstMuonID', 'eventExtraInfo(worstID)')
64 
65 # ..Variables to store (per muon)
66 variables.addAlias('muThetaLab', 'formula(57.2957795*theta)')
67 variables.addAlias('muPhiLab', 'formula(57.2957795*phi)')
68 variables.addAlias('muPcms', 'useCMSFrame(p)')
69 variables.addAlias('muptLab', 'pt')
70 variables.addAlias('e1Uncorr', 'formula(clusterHighestE * clusterUncorrE / clusterE)')
71 variables.addAlias('clustThetaLab', 'formula(57.2957795*clusterTheta)')
72 variables.addAlias('clustPhiLab', 'formula(57.2957795*clusterPhi)')
73 
74 varsToStore = [
75  'charge',
76  'p',
77  'muPcms',
78  'muptLab',
79  'muThetaLab',
80  'muPhiLab',
81  'clusterE',
82  'e1Uncorr',
83  'clustThetaLab',
84  'clustPhiLab',
85  'HighLevelTrigger',
86  'muonID',
87  'bestMuonID',
88  'worstMuonID']
89 
90 # ..store to ntuple
91 outputName = "muPairAlignment.root"
92 narg = len(sys.argv)
93 if(narg == 2):
94  outputName = sys.argv[1]
95 mypath.add_module('VariablesToNtuple', particleList='mu-:highp', variables=varsToStore, fileName=outputName)
96 
97 
98 # ..Process
99 b2.process(mypath)
100 print(b2.statistics)