Belle II Software development
setups.py
1#!/usr/bin/env python3
2
3
10
11import basf2 as b2
12from ROOT import Belle2
13from alignment import MillepedeCalibration
14
15# Default configurations
16components = []
17tracks = ['CosmicRecoTracks']
18particles = ['mu+:bbmu']
19vertices = []
20primary_vertices = ['Z0:mumu']
21gearbox_file = ''
22geometry_components = []
23do_reconstruction = False
24do_cosmics_reconstruction = False
25do_analysis = False
26magnet_off = False
27
28dirty_data = False
29
30
31def get_path(
32 gearboxFile=None,
33 geometryComponents=None,
34 doReconstruction=None,
35 doAnalysis=None,
36 magnetOff=None,
37 doCosmicsReconstruction=None):
38 if gearboxFile is None:
39 gearboxFile = gearbox_file
40 if geometryComponents is None:
41 geometryComponents = geometry_components
42 if doReconstruction is None:
43 doReconstruction = do_reconstruction
44 if doAnalysis is None:
45 doAnalysis = do_analysis
46 if magnetOff is None:
47 magnetOff = magnet_off
48 if do_cosmics_reconstruction is None:
49 doCosmicsReconstruction = do_cosmics_reconstruction
50
51 import modularAnalysis as ana
52 import reconstruction as reco
53
54 path = b2.create_path()
55 path.add_module('Progress')
56
57 path.add_module('Gearbox', fileName=gearboxFile) if gearboxFile else path.add_module('Gearbox')
58
59 if geometryComponents:
60 path.add_module('Geometry', components=geometryComponents, excludedComponents=['MagneticField'] if magnetOff else [])
61 else:
62 path.add_module('Geometry', excludedComponents=['MagneticField'] if magnetOff else [])
63
64 if doReconstruction:
65 if geometryComponents:
66 reco.add_reconstruction(path, pruneTracks=False, components=geometryComponents)
67 else:
68 reco.add_reconstruction(path, pruneTracks=False)
69
70 if doCosmicsReconstruction:
71 import pxd
72 import svd
73
74 if not geometryComponents or 'PXD' in geometryComponents:
76 if not geometryComponents or 'SVD' in geometryComponents:
78
79 if geometryComponents:
80 reco.add_cosmics_reconstruction(
81 path,
82 pruneTracks=False,
83 components=geometryComponents,
84 merge_tracks=True)
85 else:
86 reco.add_cosmics_reconstruction(
87 path,
88 pruneTracks=False,
89 merge_tracks=True)
90
91 if 'SetupGenfitExtrapolation' not in path:
92 path.add_module('SetupGenfitExtrapolation', noiseBetheBloch=False, noiseCoulomb=False, noiseBrems=False)
93
94 if doAnalysis:
95 ana.fillParticleList('mu+:bbmu', 'muonID > 0.1 and useLabFrame(p) > 0.5', True, path)
96 ana.fillParticleList('mu+:qed', 'muonID > 0.1 and useLabFrame(p) > 2.', True, path)
97 ana.reconstructDecay('Z0:mumu -> mu-:qed mu+:qed', '', writeOut=True, path=path)
98 ana.vertexRaveDaughtersUpdate('Z0:mumu', 0.0, path=path, constraint='ipprofile')
99
100 return path
101
102
103def setup_none():
104 millepede = MillepedeCalibration()
105 return millepede
106
107
108def setup_default():
109 millepede = MillepedeCalibration(components,
110 tracks=tracks,
111 particles=particles,
112 vertices=vertices,
113 primary_vertices=primary_vertices,
114 path=get_path())
115
116 if dirty_data:
117 millepede.set_command('chiscut', None)
118 millepede.set_command('outlierdownweighting', None)
119 millepede.set_command('dwfractioncut', None)
120
121 millepede.algo.invertSign()
122
123 return millepede
124
125
126def setup_Global():
127 millepede = setup_default()
128 millepede.set_command('Fortranfiles')
129 millepede.set_command('constraints.txt')
130 return millepede
131
132
133def setup_BeamVertex():
134 millepede = setup_default()
135 millepede.set_components(['BeamSpot'])
136 return millepede
137
138
139def setup_VXDHalfShells():
140 millepede = setup_default()
141 millepede.set_components(['VXDAlignment'])
142 millepede.fixSVDPat()
143 for layer in range(1, 7):
144 for ladder in range(1, 17):
145 # Fix also all ladders
146 millepede.fixVXDid(layer, ladder, 0)
147 for sensor in range(1, 6):
148 # Fix all sensors
149 millepede.fixVXDid(layer, ladder, sensor)
150 return millepede
151
152
153def setup_VXDFullHierarchy():
154 millepede = setup_default()
155 millepede.set_components(['VXDAlignment'])
156 millepede.set_command('Fortranfiles')
157 millepede.set_command('constraints.txt')
158 return millepede
159
160
161def setup_VXDSensors():
162 millepede = setup_default()
163 millepede.set_components(['VXDAlignment'])
164 millepede.fixSVDPat()
165 millepede.fixSVDMat()
166 millepede.fixPXDYing()
167 millepede.fixPXDYang()
168 for layer in range(1, 7):
169 for ladder in range(1, 17):
170 # Fix also all ladders
171 millepede.fixVXDid(layer, ladder, 0)
172 for sensor in range(1, 6):
173 # Fix all sensors
174 # millepede.fixVXDid(layer, ladder, sensor)
175 pass
176 millepede.fixVXDid(1, 1, 1)
177 return millepede
178
179
180def setup_CDCLayers():
181 millepede = setup_default()
182 millepede.set_components(['CDCAlignment', 'CDCLayerAlignment'])
183 millepede.fixCDCLayerX(49)
184 millepede.fixCDCLayerY(49)
185 millepede.fixCDCLayerRot(49)
186 millepede.fixCDCLayerX(55)
187 millepede.fixCDCLayerY(55)
188 millepede.fixCDCLayerRot(55)
189 return millepede
190
191
192def setup_CDCTimeWalks():
193 millepede = setup_default()
194 millepede.set_components(['CDCTimeWalks'])
195 millepede.fixCDCTimeWalk(1)
196 return millepede
197
198
199def setup_BKLMAlignment():
200 millepede = setup_default()
201 millepede.set_components(['BKLMAlignment'])
202 millepede.fixGlobalParam(Belle2.BKLMAlignment.getGlobalUniqueID(), Belle2.BKLMElementID(0, 3, 15).getID(), 1)
203 millepede.fixGlobalParam(Belle2.BKLMAlignment.getGlobalUniqueID(), Belle2.BKLMElementID(0, 3, 15).getID(), 2)
204
205 for sector in range(1, 9):
206 for layer in range(1, 16):
207 for forward in [0, 1]:
208 millepede.fixBKLMModule(forward, sector, layer, [1, 2, 3, 4, 5, 6])
209 return millepede
210
211
212def setup_EKLMAlignment():
213 millepede = setup_default()
214 millepede.set_components(['EKLMAlignment'])
215 millepede.fixEKLMModule(1, 12, 2, 1, 1, [1, 2, 6])
216 return millepede
217
218
219def setup_CDCLayers_GCR_Karim():
220 geometry = '/alignment/examples/GCR_Summer2017.xml'
221 recotracks = ['RecoTracks']
222 global do_cosmics_reconstruction
223 do_cosmics_reconstruction = True
224
225 # Inherit settings
226 millepede = setup_CDCLayers()
227 millepede.algo.invertSign(False)
228
229 millepede.set_param(recotracks, 'tracks')
230 millepede.set_param(geometry, 'fileName', 'Gearbox')
231 millepede.set_param(1.e-20, 'minPValue')
232
233 return millepede
static unsigned short getGlobalUniqueID()
Get global unique identifier.
Definition: BKLMAlignment.h:63
def add_pxd_reconstruction(path, clusterName=None, digitsName=None, usePXDClusterShapes=False, spacePointsName='PXDSpacePoints')
Definition: __init__.py:105
def add_svd_reconstruction(path, isROIsimulation=False, createRecoDigits=False, applyMasking=False)
Definition: __init__.py:14