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