Belle II Software development
singleMuAlignment.py
1#!/usr/bin/env python3
2
3
10
11
24
25import sys
26from basf2 import (register_module, process, print_params, create_path,
27 statistics, conditions)
28from modularAnalysis import fillParticleList
29from modularAnalysis import cutAndCopyList
30from modularAnalysis import applyEventCuts
31from simulation import add_simulation
32from reconstruction import add_reconstruction
33from variables import variables
34
35# ..Check for the correct number of arguments
36narg = len(sys.argv)
37if(narg != 4):
38 print("Job arguments: nEvents name newGeom; ", narg-1, "provided")
39 sys.exit()
40
41# ..Use experiment 10 to match mc13b samples
42experiment = 1003
43run = 5201
44nevt = int(sys.argv[1])
45outputFileName = "ntuples/" + sys.argv[2] + ".root"
46
47# ..override ECL geometry if requested
48newGeom = int(sys.argv[3])
49if(newGeom == 1):
50 conditions.globaltags = ['ecl_alignment']
51if(newGeom == 2):
52 conditions.prepend_testing_payloads("localdb/database.txt")
53print(conditions.globaltags)
54
55# ---------------------------------------------------------------------
56# ..Set up particle gun
57particlegun = register_module('ParticleGun')
58
59particlegun.param('pdgCodes', [13])
60particlegun.param('nTracks', 1)
61particlegun.param('varyNTracks', False)
62particlegun.param('momentumGeneration', 'uniform')
63particlegun.param('momentumParams', [4.15, 4.5])
64particlegun.param('thetaGeneration', 'uniform')
65particlegun.param('thetaParams', [127.5, 131.5])
66particlegun.param('phiGeneration', 'uniform')
67particlegun.param('phiParams', [0., 360.])
68particlegun.param('vertexGeneration', 'fixed')
69particlegun.param('xVertexParams', [-0.05])
70particlegun.param('yVertexParams', [0.015])
71particlegun.param('zVertexParams', [0.])
72particlegun.param('independentVertices', False)
73
74print_params(particlegun)
75
76
77# ---------------------------------------------------------------------
78# ..The path
79main = create_path()
80main.add_module("EventInfoSetter", expList=experiment, runList=run, evtNumList=nevt)
81main.add_module("Progress")
82main.add_module(particlegun)
83
84add_simulation(main)
85add_reconstruction(main)
86
87
88# ---------------------------------------------------------------------
89# ..Select the muon to store
90fillParticleList('mu-:highp', 'useCMSFrame(p) > 3.5 and abs(d0) < 0.5 and abs(z0) < 4 and nCDCHits>0 and nVXDHits>0', path=main)
91cutAndCopyList('mu-:highE', 'mu-:highp', 'clusterE>1.', path=main)
92
93variables.addAlias('nhighp', 'nParticlesInList(mu-:highp)')
94variables.addAlias('nhighE', 'nParticlesInList(mu-:highE)')
95applyEventCuts('[nhighE==0] and [nhighp==1]', main)
96
97# ---------------------------------------------------------------------
98# ..Ntuple
99variables.addAlias('muThetaLab', 'formula(57.2957795*theta)')
100variables.addAlias('muPhiLab', 'formula(57.2957795*phi)')
101variables.addAlias('muPcms', 'useCMSFrame(p)')
102variables.addAlias('muptLab', 'pt')
103variables.addAlias('e1Uncorr', 'formula(clusterHighestE * clusterUncorrE / clusterE)')
104variables.addAlias('clustThetaLab', 'formula(57.2957795*clusterTheta)')
105variables.addAlias('clustPhiLab', 'formula(57.2957795*clusterPhi)')
106
107# ..dummies to match muon pair selection
108variables.addAlias('bestMuonID', 'muonID')
109variables.addAlias('worstMuonID', 'muonID')
110
111
112varsToStore = [
113 'charge',
114 'p',
115 'muPcms',
116 'muptLab',
117 'muThetaLab',
118 'muPhiLab',
119 'clusterE',
120 'e1Uncorr',
121 'clustThetaLab',
122 'clustPhiLab',
123 'HighLevelTrigger',
124 'muonID',
125 'bestMuonID',
126 'worstMuonID']
127main.add_module('VariablesToNtuple', particleList='mu-:highp', variables=varsToStore, fileName=outputFileName)
128
129
130# ---------------------------------------------------------------------
131# Process events
132process(main)
133print(statistics)